Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal reflective access warning on JDK11 #226

Open
moovida opened this issue Oct 24, 2018 · 10 comments
Open

Illegal reflective access warning on JDK11 #226

moovida opened this issue Oct 24, 2018 · 10 comments

Comments

@moovida
Copy link

moovida commented Oct 24, 2018

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
Copy link
Collaborator

croesch commented Nov 19, 2018

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
Copy link
Author

moovida commented Nov 20, 2018

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
Copy link
Collaborator

croesch commented Nov 26, 2018

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
Copy link
Author

moovida commented Nov 27, 2018

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
Copy link
Collaborator

croesch commented Jul 17, 2019

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

@future2r
Copy link

Hi there!

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

@joel-costigliola
Copy link
Member

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

@seltihood
Copy link

Hi,
We are having the same issue with Java 11.
This is our pom dependencies:
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<junit.version>5.7.0</junit.version>
<mockito.version>3.5.15</mockito.version>

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
Copy link

hakanai commented Jun 1, 2021

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
Copy link

miurahr commented Mar 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants