netty: Illegal reflective access warnings when running Netty with Java 9

Expected behavior

No warnings.

Actual behavior

Warnings when starting netty with java 9:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/doom369/.m2/repository/io/netty/netty-common/4.1.16.Final/netty-common-4.1.16.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

with --illegal-access=warn enabled :

WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/doom369/.m2/repository/io/netty/netty-common/4.1.16.Final/netty-common-4.1.16.Final.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/doom369/.m2/repository/io/netty/netty-common/4.1.16.Final/netty-common-4.1.16.Final.jar) to method java.nio.Bits.unaligned()

Steps to reproduce

Run any netty server with Java 9.

Netty version

4.1.16.Final

JVM version (e.g. java -version)

java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

Maybe it would be better to do not access above classes in case of java 9 to avoid warning?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Can we re-open this to actually solve the issue, I’d hate for things to break later on because this never got fixed?

The warning is quite clear this will break later on.

The error still occurs with netty 5.0.0.Alpha2. Please reopen the issue.

I think we could add a system property that tells netty to not even try to access this stuff when running on java9. Let me reopen

@johanneshiry You are seeing the warning because you have -Dio.netty.tryReflectionSetAccessible=true which overrides the default, which is false for Java 9 and above.

@rockwotj Actually when reflection access will be removed from Java 9 - netty will be ready. As fixed was already applied.

Netty was tested on EA builds were reflective access was removed and right now netty handles this case. So you don’t need to worry here.