Skip to content

Commit

Permalink
TKSS-730: SharedSecretsUtil should support JDK 21
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshajiang committed Mar 18, 2024
1 parent d44ab42 commit 7e74a3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public static boolean isJdk17() {
return Constants.JDK_VERSION.equals("17");
}

public static boolean isJdk21() {
return Constants.JDK_VERSION.equals("21");
}

public static boolean isAndroid() {
return Constants.JDK_VENDOR.contains("Android");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class SharedSecretsUtil {
javaIOAccessClass = Class.forName("jdk.internal.misc.JavaIOAccess");
inetAddressAccessClass = Class.forName("jdk.internal.misc.JavaNetInetAddressAccess");
secSignatureAccessClass = Class.forName("jdk.internal.misc.JavaSecuritySignatureAccess");
} else if (isJdk17()) {
} else if (isJdk17() || isJdk21()) {
sharedSecretsClass = Class.forName("jdk.internal.access.SharedSecrets");

javaLangAccessClass = Class.forName("jdk.internal.access.JavaLangAccess");
Expand All @@ -124,11 +124,11 @@ public class SharedSecretsUtil {
langNewStringNoRepl = isJdk8()
? null : javaLangAccessClass.getMethod(
"newStringNoRepl", byte[].class, Charset.class);
initialSystemIn = isJdk8()
initialSystemIn = isJdk8() || isJdk11() || isJdk17()
? null : javaLangAccessClass.getMethod("initialSystemIn");

console = javaIOAccessClass.getMethod("console");
charset = javaIOAccessClass.getMethod("charset");
charset = isJdk21() ? null : javaIOAccessClass.getMethod("charset");

cryptoSpecClearSecretKeySpec = javaxCryptoSpecAccessClass != null
? javaxCryptoSpecAccessClass.getMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public static OutputAnalyzer java(List<String> jvmOptions, Class<?> clazz,

if (CryptoUtils.isJdk11()) {
allJVMOptions.addAll(JDK11_OPTIONS);
} else if (CryptoUtils.isJdk17()) {
} else if (CryptoUtils.isJdk17() || CryptoUtils.isJdk21()) {
allJVMOptions.addAll(JDK17_OPTIONS);
}

Expand Down

0 comments on commit 7e74a3f

Please sign in to comment.