Describe the bug
It seems that Kryo is currently not compatible with JDK17. When calling the default constructor it fails with:
java.lang.reflect.InaccessibleObjectException: Unable to make private java.nio.DirectByteBuffer(long,int) accessible: module java.base does not "opens java.nio" to unnamed module @61322f9d
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
at com.esotericsoftware.kryo.unsafe.UnsafeUtil.<clinit>(UnsafeUtil.java:100)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at com.esotericsoftware.kryo.util.Util.<clinit>(Util.java:47)
at com.esotericsoftware.kryo.serializers.OptionalSerializers.addDefaultSerializers(OptionalSerializers.java:38)
at com.esotericsoftware.kryo.Kryo.<init>(Kryo.java:230)
at com.esotericsoftware.kryo.Kryo.<init>(Kryo.java:168)
To Reproduce
Kryo kryo = new Kryo();
Environment:
- JDK Version: OpenJDK 17.0.2 (Corretto-17.0.2.8.1)
- Kryo Version: 5.3.0
Additional context
In my case I am also registering some standard classes.
It seems to work for classes like:
- java.util.Locale
- java.time.Instant
- java.util.HashMap
But it fails for java.util.regex.Pattern due to:
java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.util.regex.Pattern.pattern accessible: module java.base does not "opens java.util.regex" to unnamed module @185a6e9
What would be the proper way to fix this?
Describe the bug
It seems that Kryo is currently not compatible with JDK17. When calling the default constructor it fails with:
To Reproduce
Kryo kryo = new Kryo();Environment:
Additional context
In my case I am also registering some standard classes.
It seems to work for classes like:
But it fails for
java.util.regex.Patterndue to:What would be the proper way to fix this?