grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

Java21 + grpc 1.63.0 ServerBuilder.forPort() function error

Open mengqing20101212 opened this issue 1 year ago • 3 comments

EBUG|2024-05-11 14:13:10,249 +0800|io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0|direct buffer constructor: unavailable
java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
	at io.grpc.netty.shaded.io.netty.util.internal.ReflectionUtil.trySetAccessible(ReflectionUtil.java:31) ~[grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0$5.run(PlatformDependent0.java:293) ~[grpc-netty-shaded-1.63.0.jar:1.63.0]
	at java.security.AccessController.doPrivileged(AccessController.java:319) ~[?:?]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:286) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:331) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:86) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.<init>(AsciiString.java:225) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.<init>(AsciiString.java:212) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.cached(AsciiString.java:1403) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.<clinit>(AsciiString.java:48) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.Utils.<clinit>(Utils.java:80) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder.<clinit>(NettyServerBuilder.java:83) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerProvider.builderForPort(NettyServerProvider.java:40) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerProvider.builderForPort(NettyServerProvider.java:25) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.ServerBuilder.forPort(ServerBuilder.java:44) [grpc-api-1.63.0.jar:1.63.0]
	at com.tiktaalik.gs.GrpcServer.initGrpcServer(GrpcServer.java:89) [classes/:?]



DEBUG|2024-05-11 14:13:10,322 +0800|io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0|jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable
java.lang.IllegalAccessException: class io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0$7 cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @470734c3
	at jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:394) ~[?:?]
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:714) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:571) ~[?:?]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0$7.run(PlatformDependent0.java:429) ~[grpc-netty-shaded-1.63.0.jar:1.63.0]
	at java.security.AccessController.doPrivileged(AccessController.java:319) ~[?:?]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:420) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:331) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:86) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.<init>(AsciiString.java:225) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.<init>(AsciiString.java:212) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.cached(AsciiString.java:1403) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.netty.util.AsciiString.<clinit>(AsciiString.java:48) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.Utils.<clinit>(Utils.java:80) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder.<clinit>(NettyServerBuilder.java:83) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerProvider.builderForPort(NettyServerProvider.java:40) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerProvider.builderForPort(NettyServerProvider.java:25) [grpc-netty-shaded-1.63.0.jar:1.63.0]
	at io.grpc.ServerBuilder.forPort(ServerBuilder.java:44) [grpc-api-1.63.0.jar:1.63.0]
	at com.tiktaalik.gs.GrpcServer.initGrpcServer(GrpcServer.java:89) [classes/:?]

What version of gRPC-Java are you using?

What is your environment?

java21

What did you expect to see?

What did you see instead?

Steps to reproduce the bug

mengqing20101212 avatar May 11 '24 06:05 mengqing20101212

These are DEBUG logs. Did anything actually go wrong?

ejona86 avatar May 12 '24 13:05 ejona86

no, I just saw the exception being thrown, so I came to ask if it's caused by Java 21

mengqing20101212 avatar May 13 '24 01:05 mengqing20101212

It is just debugging logging to record why direct buffer constructor could not be used in the Netty library. Reg the first stacktrace for example, Netty code has different control flows for when direct buffer constructor is available vs not available, and it should not have any impact on the functionality. It looks like this log would be seen for any Java version 9 or above based on the check here.

kannanjgithub avatar May 13 '24 13:05 kannanjgithub

ok , I know , Thank you very much

mengqing20101212 avatar May 14 '24 07:05 mengqing20101212