RFR: JDK-8293701: jdeps InverseDepsAnalyzer runs into NoSuchElementException: No value present [v2]
Mandy Chung
mchung at openjdk.org
Thu Sep 29 18:49:28 UTC 2022
On Thu, 29 Sep 2022 16:05:44 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
>> We noticed that with certain jar file input, jdeps runs into the following exception, this happens with jdk11, 17 and 20.
>>
>> jdeps.exe --multi-release 11 --module-path . --inverse --package com.sap.nw.performance.supa.client test.jar
>>
>> Inverse transitive dependences matching packages [com.sap.nw.performance.supa.client]
>> Exception in thread "main" java.util.NoSuchElementException: No value present
>> at java.base/java.util.Optional.get(Optional.java:148)
>> at jdk.jdeps/com.sun.tools.jdeps.InverseDepsAnalyzer.lambda$inverseDependences$2(InverseDepsAnalyzer.java:150)
>> at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>> at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
>> at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
>> at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
>> at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>> at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
>> at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>>
>> So an additional check might be a good idea.
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
>
> adjust check, add test
src/jdk.jdeps/share/classes/com/sun/tools/jdeps/InverseDepsAnalyzer.java line 150:
> 148: // filter "requires static" if the module is not resolved in the configuration
> 149: .filter(req -> !req.modifiers().contains(Requires.Modifier.STATIC)
> 150: || configuration.findModule(req.name()).isPresent())
Nit: indent further to the right for readability (maybe 16 spaces)
test/langtools/tools/jdeps/optionalDependency/OptionalDependencyError.java line 43:
> 41: import static org.testng.Assert.assertTrue;
> 42:
> 43: public class OptionalDependencyError {
I'd rename the test to `OptionalDependencyTest` since it's not expecting an error.
test/langtools/tools/jdeps/optionalDependency/OptionalDependencyError.java line 73:
> 71: */
> 72: @Test
> 73: public void noOptionalDependencyError() {
This test case verifies when m3 is resolved in the configuration. I suggest to rename this to `optionalDependenceResolved`. Please also add the comment something like
/*
* Test if a requires static dependence is resolved in the configuration.
*/
can you add one more test case that m3 is not resolved `optinalDependenceNotResolved`?
-------------
PR: https://git.openjdk.org/jdk/pull/10300
More information about the core-libs-dev
mailing list