Use Runtime.version() instead of reflection
See gh-31444
This commit is contained in:
committed by
Stephane Nicoll
parent
98eb21712f
commit
b687e1c7ee
@@ -560,7 +560,7 @@ class JarFileTests {
|
||||
assertThat(entry.getName()).isEqualTo("multi-release.dat");
|
||||
InputStream inputStream = multiRelease.getInputStream(entry);
|
||||
assertThat(inputStream.available()).isEqualTo(1);
|
||||
assertThat(inputStream.read()).isEqualTo(getJavaVersion());
|
||||
assertThat(inputStream.read()).isEqualTo(Runtime.version().feature());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,14 +732,4 @@ class JarFileTests {
|
||||
assertThatIllegalStateException().isThrownBy(throwingCallable).withMessage("zip file closed");
|
||||
}
|
||||
|
||||
private int getJavaVersion() {
|
||||
try {
|
||||
Object runtimeVersion = Runtime.class.getMethod("version").invoke(null);
|
||||
return (int) runtimeVersion.getClass().getMethod("major").invoke(runtimeVersion);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user