EsotericSoftware / EsotericSoftware/kryo
Support for JDK17
- Dominant language
- HTML
- Stars
- 6.5k
- Forks
- 841
- Avg merge
- 39m
- Merged PRs (30d)
- 4
Description
**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.(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.(Util.java:47)
at com.esotericsoftware.kryo.serializers.OptionalSerializers.addDefaultSerializers(OptionalSerializers.java:38)
at com.esotericsoftware.kryo.Kryo.(Kryo.java:230)
at com.esotericsoftware.kryo.Kryo.(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?
Contributor guide
Assessment
This issue has not been assessed yet.