xipki / pkcs11wrapper

PKCS#11 Wrapper for Java. Deprecated. Please use xipki/ipkcs11wrapper (preferred) or xipki/jpkcs11wrapper instead.
Other
34 stars 13 forks source link

Getting "WARNING: An illegal reflective access operation has occurred" #7

Closed Bragolgirith closed 2 years ago

Bragolgirith commented 3 years ago

When performing any PKCS11 cryptographic operation using Java 11, I'm getting similar warnings in the console: (example is for GCM encryption)

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by iaik.pkcs.pkcs11.parameters.GCMParameters (file:/C:/Users/{user}/.m2/repository/org/xipki/iaik/sunpkcs11-wrapper/1.4.7/sunpkcs11-wrapper-1.4.7.jar) to constructor sun.security.pkcs11.wrapper.CK_GCM_PARAMS(int,byte[],byte[])
WARNING: Please consider reporting this to the maintainers of iaik.pkcs.pkcs11.parameters.GCMParameters
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

The operation is nevertheless successful, but from the message it looks like it might eventually stop working for newer versions of Java.

Java version: openjdk 11.0.10 2021-01-19

xipki commented 3 years ago

The cause is that we need to access the sun.* package. I will keep testing the next LTS java version to ensure it works.

fdelapena commented 2 years ago

Now the Java 17 LTS is out and illegal access warning became errors. For sun.* they likely will need some --add-exports (or maybe --add-opens for reflection) for Maven compiler settings.

In case of JDK 8 compiler args incompatibility, it could require building with at least JDK 11 even when supporting JDK 8. Adding a profile could allow supporting both yet.

Or try the possibility to use own pure java code for the remaining sun.* definitions.

xipki commented 2 years ago

Add the support of Java 17 (LTS) in f65fa24. For details please refer to README.md