cadence-java-client icon indicating copy to clipboard operation
cadence-java-client copied to clipboard

Java 17 support - Illegal reflective access in CustomThrowableTypeAdapter and CheckedExceptionWrapper

Open WellingR opened this issue 4 years ago • 4 comments

I tried using the cadence-java-client with java 17. However it appears that the CustomThrowableTypeAdapter uses a reflection method which no longer works in java 17.

The code https://github.com/uber/cadence-java-client/blob/master/src/main/java/com/uber/cadence/converter/CustomThrowableTypeAdapter.java#L83 Makes the cause field accessible in order to set a non-accessible field to null. This is no longer possible in java 17 because of https://openjdk.java.net/jeps/403 .

Similarly, the initializer of CheckedExceptionWrapper also uses a reflective method which is no longer allowed.

WellingR avatar Oct 26 '21 10:10 WellingR

It seems like there are some standard replacements recommended. Would you like to propose some changes to that?

longquanzheng avatar Nov 02 '21 21:11 longquanzheng

Is it possible to use the same solution as in temporal? https://github.com/temporalio/sdk-java/commit/4bb23c3a660de6a2630901d0dc6c049d9742ebe1

Also handling errors seems like a nice fix: https://github.com/temporalio/sdk-java/commit/6653b3d71af118824f5eedcbef6e33be103d9f1e

jontro avatar Mar 05 '23 22:03 jontro

Is there any solve or alternative proposed for this issue for using uber cadence with Java-17? I am facing java.lang.NoClassDefFoundError: Could not initialize class com.uber.cadence.internal.common.CheckedExceptionWrapper after upgrading to java 17. This should be related to the issue stated above.

agarwall-rohan avatar Oct 18 '23 12:10 agarwall-rohan

If you include the VM parameter "--add-opens java.base/java.lang=ALL-UNNAMED," it will prevent the exception from being thrown.

sodre90 avatar Feb 14 '24 21:02 sodre90