EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 417 forks source link

Issues with Graal Native Images #160

Open AnthonyRuffino opened 4 years ago

AnthonyRuffino commented 4 years ago

I am trying to run an application as a Graal Native image which sets up a simple Kryonet server from the examples on this git page, but I have coming across the following issue. Any chance the devs of this project could make asmall working example of a Kryonet server ruinning as a native image?

Exception in thread "main" java.lang.IllegalArgumentException: Unable to create serializer "com.esotericsoftware.kryo.serializers.FieldSerializer" for class: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP at com.esotericsoftware.kryo.factories.ReflectionSerializerFactory.makeSerializer(ReflectionSerializerFactory.java:48) at com.esotericsoftware.kryo.factories.ReflectionSerializerFactory.makeSerializer(ReflectionSerializerFactory.java:26) at com.esotericsoftware.kryo.Kryo.newDefaultSerializer(Kryo.java:351) at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:344) at com.esotericsoftware.kryo.Kryo.register(Kryo.java:365) at com.esotericsoftware.kryonet.KryoSerialization.(KryoSerialization.java:31) at com.esotericsoftware.kryonet.KryoSerialization.(KryoSerialization.java:23) at com.esotericsoftware.kryonet.Server.(Server.java:91) ....

Caused by: java.lang.InstantiationException: Type com.esotericsoftware.kryo.serializers.FieldSerializer can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image. at java.lang.Class.newInstance(DynamicHub.java:850) at com.esotericsoftware.kryo.factories.ReflectionSerializerFactory.makeSerializer(ReflectionSerializerFactory.java:43) ... 11 more

RobertZenz commented 4 years ago

Can you tell Graal to add no-parameters constructor to all classes?

AnthonyRuffino commented 4 years ago

I do not think that is a feature of Graal.