assertj / assertj-swing

Fluent assertions for Swing apps
Other
108 stars 52 forks source link

Illegal reflective access warning on JDK11 #226

Open moovida opened 6 years ago

moovida commented 6 years ago

Hi, on java 11 I get the following test warnings due to illegal reflective access:

WARNING: Illegal reflective access by org.assertj.swing.dependency.fest_reflect.util.Accessibles$SetAccessibleAction (file:/home/hydrologis/.m2/repository/org/assertj/assertj-swing/3.8.0/assertj-swing-3.8.0.jar) to method javax.swing.SwingUtilities.appContextGet(java.lang.Object)
    at org.assertj.swing.dependency.fest_reflect.util.Accessibles$SetAccessibleAction.run(Accessibles.java:70)
    at org.assertj.swing.dependency.fest_reflect.util.Accessibles$SetAccessibleAction.run(Accessibles.java:60)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.assertj.swing.dependency.fest_reflect.util.Accessibles.setAccessible(Accessibles.java:57)
    at org.assertj.swing.dependency.fest_reflect.util.Accessibles.makeAccessible(Accessibles.java:46)
    at org.assertj.swing.dependency.fest_reflect.method.Invoker.invoke(Invoker.java:111)
    at org.assertj.swing.edt.FailOnThreadViolationRepaintManager.currentRepaintManager(FailOnThreadViolationRepaintManager.java:82)
    at org.assertj.swing.edt.FailOnThreadViolationRepaintManager.installNew(FailOnThreadViolationRepaintManager.java:94)
    at org.assertj.swing.edt.FailOnThreadViolationRepaintManager.install(FailOnThreadViolationRepaintManager.java:57)
    at org.geotools.swing.testutils.GraphicsTestBase.baseSetUpOnce(GraphicsTestBase.java:54)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
croesch commented 5 years ago

Thanks a lot @moovida for reporting this issue. Currently AssertJ Swing still requires Java 8. Now we know the term "or higher" ends at least with Java 11, so we have to work on that.

The exception above shows that the FailOnThreadViolationRepaintManager is the problem. Did you try to run your tests without it? Would be nice to have a feedback if the rest of the framework is still working.

Realistically this issue might be open for a while ... :/

moovida commented 5 years ago

Hi @croesch , yes, I ran the tests without that one and they all passed. I well understand you in that the issue might be open for a while. In fact everything still works well. But yeah, this might become an issue at some point. Anyway, thanks for everything!

croesch commented 5 years ago

Hi @moovida can you give some additional information about your environment because #229 seems to be related in a way that clicking seems to be broken with Java 11. Didn't you notice some behavior like that in your tests?

moovida commented 5 years ago

Hi @croesch , I am on ubuntu with :

Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 11.0.1, vendor: Oracle Corporation
Java home: /home/hydrologis/SOFTWARE/JAVA/JDKS/jdk-11.0.1
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-38-generic", arch: "amd64", family: "unix"

and using:

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-swing-junit</artifactId>
            <version>3.8.0</version>
            <scope>test</scope>
        </dependency>

I am not sure about the clicking thing though. Is there something I can do to check this?

croesch commented 5 years ago

Illegal reflective access in fest-reflect also mentioned in #237

future2r commented 4 years ago

Hi there!

Is anyone working on this issue? It is a real blocker for us...

joel-costigliola commented 4 years ago

I don't think so, contributions welcome ;-)

seltihood commented 3 years ago

Hi, We are having the same issue with Java 11. This is our pom dependencies:

11 11 5.7.0 3.5.15 This is the error: WARNING: Illegal reflective access by org.junitpioneer.jupiter.EnvironmentVariableUtils (file:**/.m2/repository/org/junit-pioneer/junit-pioneer/1.1.0/junit-pioneer-1.1.0.jar) to field java.lang.ProcessEnvironment.theEnvironment WARNING: Please consider reporting this to the maintainers of org.junitpioneer.jupiter.EnvironmentVariableUtils The test was simple: @ExtendWith(MockitoExtension.class) @DisplayName("JUnitPioneer system environment utilities") @WritesEnvironmentVariable class JwtGeneratorTest { @Test @SetEnvironmentVariable( key = "COMMUNITY_OPENFIRE_PRIVATE_KEY", value = COMMUNITY_OPENFIRE_PRIVATE_KEY) void givenValidInput_whenGenerateBasicJwt_thenJwtIsCreatedSuccessfully() { assertEquals(COMMUNITY_OPENFIRE_PRIVATE_KEY, System.getProperty("some property")); } There were other issues before getting here (I needed to reimport the junit-platform-commons). Maybe you should change in the README. "or higher" for java11. At least for the Environment variables :)
hakanai commented 3 years ago

The code it's running seems like it's just trying to get the current repaint manager:

      Object repaintManager = method("appContextGet").withReturnType(Object.class).withParameterTypes(Object.class)
                                                     .in(SwingUtilities.class).invoke(RepaintManager.class);

Whereas in the public API there is this:

    RepaintManager repaintManager = RepaintManager.currentManager((Component) null);

There's no @since tag on the method so I can't guess when it was added, but it's certainly available in JDK 8.

miurahr commented 7 months ago

Whereas in the public API there is this:

    RepaintManager repaintManager = RepaintManager.currentManager((Component) null);

There's no @since tag on the method so I can't guess when it was added, but it's certainly available in JDK 8.

By checking OpenJDK commit history, it have already existed from a start of OpenJDK project, which has "initial load" commit message. It means JDK 7 and later has it.