Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 17 support for complex deep cloning #124

Open
gjevardat opened this issue Aug 29, 2023 · 2 comments
Open

Java 17 support for complex deep cloning #124

gjevardat opened this issue Aug 29, 2023 · 2 comments

Comments

@gjevardat
Copy link

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.

@KoSergey
Copy link

KoSergey commented Jan 5, 2024

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

@RazerFord
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants