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 warnings when running Netty with Java 9 #7817

Closed
Bhashinee opened this issue Mar 30, 2018 · 9 comments · Fixed by #11164
Closed

Illegal reflective access warnings when running Netty with Java 9 #7817

Bhashinee opened this issue Mar 30, 2018 · 9 comments · Fixed by #11164
Milestone

Comments

@Bhashinee
Copy link

Expected behavior

Run without warnings.

Actual behavior

I get following warning,

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/bhashinee/.m2/repository/io/netty/netty-common/4.1.22.Final/netty-common-4.1.22.Final.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I specified this system property,
-Dio.netty.tryReflectionSetAccessible=true

Found that this has been fixed in 4.1.21.Final version according to this link. But when I upgraded netty version to 4.1.22.Final, I still get the same warnings. To get rid of these warnings what should I do?

Netty version

4.1.22.Final

JVM version (e.g. java -version)

java version "9.0.4"

OS version (e.g. uname -a)

Ubuntu

@johnou
Copy link
Contributor

johnou commented Mar 30, 2018

-Dio.netty.tryReflectionSetAccessible=false

@Bhashinee
Copy link
Author

Bhashinee commented Mar 30, 2018

When I set that to false -Dio.netty.tryReflectionSetAccessible=false I get this error,

java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
	at io.netty.util.internal.ReflectionUtil.trySetAccessible(ReflectionUtil.java:31) ~[netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.internal.PlatformDependent0$4.run(PlatformDependent0.java:225) ~[netty-common-4.1.21.Final.jar:4.1.21.Final]
	at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
	at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:219) ~[netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:208) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:79) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.ConstantPool.<init>(ConstantPool.java:32) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.Signal$1.<init>(Signal.java:27) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.Signal.<clinit>(Signal.java:27) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.concurrent.DefaultPromise.<clinit>(DefaultPromise.java:43) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.concurrent.GlobalEventExecutor.<init>(GlobalEventExecutor.java:46) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.concurrent.GlobalEventExecutor.<clinit>(GlobalEventExecutor.java:43) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at org.wso2.transport.http.netty.contractimpl.DefaultHttpWsConnectorFactory.<init>(DefaultHttpWsConnectorFactory.java:51) [classes/:na]
	at org.wso2.transport.http.netty.ClientConnectorClosureAfterRequestReadTestCase.<init>(ClientConnectorClosureAfterRequestReadTestCase.java:57) [test-classes/:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [na:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [na:na]
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [na:na]
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488) [na:na]
	at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29) [testng-6.9.10.jar:na]
	at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:377) [testng-6.9.10.jar:na]
	at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:290) [testng-6.9.10.jar:na]
	at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:125) [testng-6.9.10.jar:na]
	at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:190) [testng-6.9.10.jar:na]
	at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:130) [testng-6.9.10.jar:na]
	at org.testng.TestRunner.initMethods(TestRunner.java:424) [testng-6.9.10.jar:na]
	at org.testng.TestRunner.init(TestRunner.java:247) [testng-6.9.10.jar:na]
	at org.testng.TestRunner.init(TestRunner.java:217) [testng-6.9.10.jar:na]
	at org.testng.TestRunner.<init>(TestRunner.java:161) [testng-6.9.10.jar:na]
	at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:556) [testng-6.9.10.jar:na]
	at org.testng.SuiteRunner.init(SuiteRunner.java:168) [testng-6.9.10.jar:na]
	at org.testng.SuiteRunner.<init>(SuiteRunner.java:117) [testng-6.9.10.jar:na]
	at org.testng.TestNG.createSuiteRunner(TestNG.java:1319) [testng-6.9.10.jar:na]
	at org.testng.TestNG.createSuiteRunners(TestNG.java:1306) [testng-6.9.10.jar:na]
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1160) [testng-6.9.10.jar:na]
	at org.testng.TestNG.run(TestNG.java:1064) [testng-6.9.10.jar:na]
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:281) [surefire-testng-2.19.1.jar:2.19.1]
	at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75) [surefire-testng-2.19.1.jar:2.19.1]
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:121) [surefire-testng-2.19.1.jar:2.19.1]
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290) [surefire-booter-2.19.1.jar:2.19.1]
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242) [surefire-booter-2.19.1.jar:2.19.1]
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121) [surefire-booter-2.19.1.jar:2.19.1]
12:41:02.835 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: unavailable true
java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
	at io.netty.util.internal.ReflectionUtil.trySetAccessible(ReflectionUtil.java:31) ~[netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.internal.PlatformDependent0$5.run(PlatformDependent0.java:274) ~[netty-common-4.1.21.Final.jar:4.1.21.Final]
	at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]

@johnou
Copy link
Contributor

johnou commented Mar 30, 2018

It's not an error, it's a debug message with a stacktrace, change your logger level to something else apart from debug eg. info or warn.

@normanmaurer
Copy link
Member

exactly like @johnou said. Closing

@idemax
Copy link

idemax commented Dec 11, 2018

Where did you add this property?

@johnou
Copy link
Contributor

johnou commented Dec 11, 2018

@marcelolfilho pass it into the JVM with the -D switch or use System.setProperty before initialising Netty.

@renannprado
Copy link

I know it's just a warning, but I tried to use the JVM parameter with version 4.1.31 of Netty and Java11 and nothing changes.

@marco-brandizi
Copy link

It's not an error, it's a debug message with a stacktrace, change your logger level to something else apart from debug eg. info or warn.

As I explained on neo4j/neo4j-java-driver#857, this is just a warning, but it produces a big ugly stack trace, which will likely confuse the end-users and cause many unnecessary support requests.

Please, could this issue be reopened, or another one created to perform this probing differently? The generated exception could be thrown and a smaller warning only could be reported. AFAIK, in JDK11 setAccessible( true ) isn't available anyway, so if that is the case and if this code is checking that, Java version >= 11 might already give a negative answer.

chrisvest added a commit to chrisvest/netty that referenced this issue Apr 16, 2021
Motivation:
We are increasingly running in environments where Unsafe, setAccessible, etc. are not available.
When debug logging is enabled, we log a complete stack trace every time one of these initialisations fail.
Seeing these stack traces can cause people unnecessary concern.
For instance, people might have alerts that are triggered by a stack trace showing up in logs, regardless of its log level.

Modification:
We continue to print debug log messages on the result of our initialisations, but now we only include the full stack trace is _trace_ logging (or FINEST, or equivalent in whatever logging framework is configured) is enabled.

Result:
We now only log these initialisation stack traces when the lowest possible log level is enabled.

Fixes netty#7817
normanmaurer pushed a commit that referenced this issue Apr 19, 2021
Motivation:
We are increasingly running in environments where Unsafe, setAccessible, etc. are not available.
When debug logging is enabled, we log a complete stack trace every time one of these initialisations fail.
Seeing these stack traces can cause people unnecessary concern.
For instance, people might have alerts that are triggered by a stack trace showing up in logs, regardless of its log level.

Modification:
We continue to print debug log messages on the result of our initialisations, but now we only include the full stack trace is _trace_ logging (or FINEST, or equivalent in whatever logging framework is configured) is enabled.

Result:
We now only log these initialisation stack traces when the lowest possible log level is enabled.

Fixes #7817
normanmaurer pushed a commit that referenced this issue Apr 19, 2021
Motivation:
We are increasingly running in environments where Unsafe, setAccessible, etc. are not available.
When debug logging is enabled, we log a complete stack trace every time one of these initialisations fail.
Seeing these stack traces can cause people unnecessary concern.
For instance, people might have alerts that are triggered by a stack trace showing up in logs, regardless of its log level.

Modification:
We continue to print debug log messages on the result of our initialisations, but now we only include the full stack trace is _trace_ logging (or FINEST, or equivalent in whatever logging framework is configured) is enabled.

Result:
We now only log these initialisation stack traces when the lowest possible log level is enabled.

Fixes #7817
@normanmaurer normanmaurer added this to the 4.1.64.Final milestone Apr 19, 2021
raidyue pushed a commit to raidyue/netty that referenced this issue Jul 8, 2022
Motivation:
We are increasingly running in environments where Unsafe, setAccessible, etc. are not available.
When debug logging is enabled, we log a complete stack trace every time one of these initialisations fail.
Seeing these stack traces can cause people unnecessary concern.
For instance, people might have alerts that are triggered by a stack trace showing up in logs, regardless of its log level.

Modification:
We continue to print debug log messages on the result of our initialisations, but now we only include the full stack trace is _trace_ logging (or FINEST, or equivalent in whatever logging framework is configured) is enabled.

Result:
We now only log these initialisation stack traces when the lowest possible log level is enabled.

Fixes netty#7817
thescouser89 added a commit to thescouser89/bacon that referenced this issue Aug 10, 2022
When running on Java 11, Netty prints a scary *debug* message about not
being able to access the Unsafe APIs. This is normal and just printed as
a debug, but it looks like an error message.

This commit adjusts our logging to only print Netty error messages
instead.

Sources:
- https://stackoverflow.com/questions/64043706/java-lang-illegalaccessexception-class-io-netty-util-internal-platformdependent
- netty/netty#7817 (comment)

```
It's not an error, it's a debug message with a stacktrace, change your logger level to something else apart from debug eg. info or warn.
```
thescouser89 added a commit to project-ncl/bacon that referenced this issue Aug 10, 2022
When running on Java 11, Netty prints a scary *debug* message about not
being able to access the Unsafe APIs. This is normal and just printed as
a debug, but it looks like an error message.

This commit adjusts our logging to only print Netty error messages
instead.

Sources:
- https://stackoverflow.com/questions/64043706/java-lang-illegalaccessexception-class-io-netty-util-internal-platformdependent
- netty/netty#7817 (comment)

```
It's not an error, it's a debug message with a stacktrace, change your logger level to something else apart from debug eg. info or warn.
```
@tarokon
Copy link

tarokon commented Feb 1, 2024

It's not an error, it's a debug message with a stacktrace, change your logger level to something else apart from debug eg. info or warn.

But the log has the words "Exception" !!!!
Why is a debug message getting printed as a stacktrace ?
There is no indication in the logs (stacktrace) to indicate that this is a debug message and not a crash/Exception.
How are people who are not familiar with netty supposed to know that it's meant for debug ?
Is it possible to convert this from a stack trace to a debug log ? It would save a lot of time of other developers and won't raise alarm bells forcing developers to start digging on this Exception.

Once this is fixed from stacktrace to debug, I request you to please update that comment stating the version in which the stacktrace has been converted to debug so that the world can start using that build onwards.

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

Successfully merging a pull request may close this issue.

7 participants