kostaskougios/cloning

Java 17 support for complex deep cloning

Opened this issue · 2 comments

I'am working on big space scientific mission for ESA and we were using this library in the past with Java 8.

After the switch to Java 17 the cloning of objects that are managed by the openJPA ORM are throwing dozens of error and I add to manually append all these directives

--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.util.zip=ALL-UNNAMED --add-opens java.base/java.util.jar=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.lang.ref=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/sun.util.calendar=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED

Is it expected to have all this open directives to add for Java 17 ? It is barely usable :(

But then it finally crashed with and here I have no idea and no really time to investigate of the internal reasons.

java.lang.NoClassDefFoundError: sun/nio/ch/NioSocketImpl$$Lambda$450/0x0000000800ff4da0
	at java.base/jdk.internal.reflect.GeneratedSerializationConstructorAccessor184.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:48)
	at com.rits.cloning.Cloner$CloneObjectCloner.deepClone(Cloner.java:627)
	at com.rits.cloning.Cloner.cloneInternal(Cloner.java:454)
Cloner cloner = new Cloner();
	cloner.dontCloneInstanceOf(MyClass1.class);
	cloner.dontCloneInstanceOf(MyClass2.class);
	...	
	MyTargetClass clone = cloner.deepClone(this);
        ...
	return clone;

Here MyTarget class is a JPA @entity were the instance is managed and contains lot of proxy internal fields.

Hi, have you found a solution to using it in Java 17?

Good afternoon. I'm guessing you need to add the following parameter to pom.xml:

<argLine> 
    --add-opens java.base/java.lang=ALL-UNNAMED 
    --add-opens java.base/java.io=ALL-UNNAMED 
    --add-opens java.base/java.util=ALL-UNNAMED 
</argLine>