Skip to content

extractingResultOf fails on the module path #2760

@scordio

Description

@scordio

Describe the bug

  • AssertJ Core version: 3.23.1
  • Java version: 11.0.16+8 Temurin
  • Test framework version:

From #1504 (comment) by @beatngu13 and @aepfli:

We are facing similar issues since we test on the module path, see:

https://github.com/junit-pioneer/junit-pioneer/runs/8060473637?check_suite_focus=true#step:4:68

This is one of the failing tests:

https://github.com/junit-pioneer/junit-pioneer/blob/main/src/test/java/org/junitpioneer/internal/PioneerAnnotationUtilsTests.java#L516

Looks like the problematic path comes from extractingResultOf, @aepfli made it work switching to extracting:

https://github.com/junit-pioneer/junit-pioneer/pull/614/files#diff-169ff4622006e6406c530aec2c75d78a8b07f70493494a260e9fa40784a71cdb

We are using AssertJ 3.22.0. Note that the changes are not on main, this is the corresponding PR:

junit-pioneer/junit-pioneer#651

Test case reproducing the bug

Test case at: https://github.com/junit-pioneer/junit-pioneer/blob/main/src/test/java/org/junitpioneer/internal/PioneerAnnotationUtilsTests.java#L516

which yields:

> Task :test
WARNING: module-info.class ignored in patch: /home/runner/work/junit-pioneer/junit-pioneer/build/classes/java/main
WARNING: module-info.class ignored in patch: /home/runner/work/junit-pioneer/junit-pioneer/build/classes/java/main

Pioneer Annotation utilities > getting annotated annotations > finds annotated annotations on a method FAILED
    java.lang.IllegalStateException: java.lang.IllegalAccessException: class org.assertj.core.util.introspection.MethodSupport (in module org.assertj.core) cannot access class com.sun.proxy.jdk.proxy2.$Proxy30 (in module jdk.proxy2) because module jdk.proxy2 does not export com.sun.proxy.jdk.proxy2 to module org.assertj.core
        at org.assertj.core@3.23.1/org.assertj.core.util.introspection.MethodSupport.invokeMethod(MethodSupport.java:60)
        at org.assertj.core@3.23.1/org.assertj.core.util.introspection.MethodSupport.methodResultFor(MethodSupport.java:53)
        at org.assertj.core@3.23.1/org.assertj.core.extractor.ResultOfExtractor.apply(ResultOfExtractor.java:39)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
        at org.assertj.core@3.23.1/org.assertj.core.groups.FieldsOrPropertiesExtractor.extract(FieldsOrPropertiesExtractor.java:64)
        at org.assertj.core@3.23.1/org.assertj.core.api.AbstractIterableAssert.extractingResultOf(AbstractIterableAssert.java:1118)
        at org.junitpioneer/org.junitpioneer.internal.PioneerAnnotationUtilsTests$AnnotatedAnnotations.onMethods(PioneerAnnotationUtilsTests.java:509)

        Caused by:
        java.lang.IllegalAccessException: class org.assertj.core.util.introspection.MethodSupport (in module org.assertj.core) cannot access class com.sun.proxy.jdk.proxy2.$Proxy30 (in module jdk.proxy2) because module jdk.proxy2 does not export com.sun.proxy.jdk.proxy2 to module org.assertj.core
            at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
            at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
            at java.base/java.lang.reflect.Method.invoke(Method.java:558)
            at org.assertj.core@3.23.1/org.assertj.core.util.introspection.MethodSupport.invokeMethod(MethodSupport.java:58)
            ... 12 more

Additional tasks

Metadata

Metadata

Assignees

Labels

theme: module systemAn issue related to the Java module system

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions