8150976: JarFile and MRJAR tests should use the JDK specific Version API
Reviewed-by: alanb, mchung
--- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Mar 02 14:15:15 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Wed Mar 02 16:25:29 2016 +0000
@@ -158,7 +158,7 @@
RUNTIME_VERSION = AccessController.doPrivileged(
new PrivilegedAction<Integer>() {
public Integer run() {
- Integer v = sun.misc.Version.jdkMajorVersion(); // fixme when JEP 223 Version integrated
+ Integer v = jdk.Version.current().major();
Integer i = Integer.getInteger("jdk.util.jar.version", v);
i = i < 0 ? 0 : i;
return i > v ? v : i;
@@ -359,7 +359,7 @@
}
private boolean runtimeVersionExists() {
- int version = sun.misc.Version.jdkMajorVersion(); // fixme when JEP 223 integrated
+ int version = jdk.Version.current().major();
try {
Release.valueOf(version);
return true;
--- a/jdk/test/java/util/jar/JarFile/MultiReleaseJarAPI.java Wed Mar 02 14:15:15 2016 +0100
+++ b/jdk/test/java/util/jar/JarFile/MultiReleaseJarAPI.java Wed Mar 02 16:25:29 2016 +0000
@@ -39,9 +39,9 @@
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import jdk.Version;
import static java.util.jar.JarFile.Release;
-import static sun.misc.Version.jdkMajorVersion; // fixme JEP 223 Version
import org.testng.Assert;
import org.testng.annotations.AfterClass;
@@ -50,6 +50,9 @@
public class MultiReleaseJarAPI {
+
+ static final int MAJOR_VERSION = Version.current().major();
+
String userdir = System.getProperty("user.dir",".");
File unversioned = new File(userdir, "unversioned.jar");
File multirelease = new File(userdir, "multi-release.jar");
@@ -106,7 +109,7 @@
}
// assure that we have a Release object corresponding to the actual runtime version
- String version = "VERSION_" + jdkMajorVersion();
+ String version = "VERSION_" + MAJOR_VERSION;
boolean runtimeVersionExists = false;
for (Release value : values) {
if (version.equals(value.name())) runtimeVersionExists = true;
@@ -123,7 +126,7 @@
if (name.equals("BASE")) {
prefix = "";
} else if (name.equals("RUNTIME")) {
- prefix = "META-INF/versions/" + jdkMajorVersion() + "/";
+ prefix = "META-INF/versions/" + MAJOR_VERSION + "/";
} else {
prefix = "META-INF/versions/" + name.substring(8) + "/";
}
--- a/jdk/test/java/util/jar/JarFile/MultiReleaseJarIterators.java Wed Mar 02 14:15:15 2016 +0100
+++ b/jdk/test/java/util/jar/JarFile/MultiReleaseJarIterators.java Wed Mar 02 16:25:29 2016 +0000
@@ -42,9 +42,9 @@
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import java.util.zip.ZipFile;
+import jdk.Version;
import static java.util.jar.JarFile.Release;
-import static sun.misc.Version.jdkMajorVersion; // fixme JEP 223 Version
import org.testng.Assert;
import org.testng.annotations.AfterClass;
@@ -53,6 +53,9 @@
public class MultiReleaseJarIterators {
+
+ static final int MAJOR_VERSION = Version.current().major();
+
String userdir = System.getProperty("user.dir", ".");
File unversioned = new File(userdir, "unversioned.jar");
File multirelease = new File(userdir, "multi-release.jar");
@@ -121,7 +124,7 @@
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
Map<String,JarEntry> expectedEntries;
- switch (jdkMajorVersion()) {
+ switch (MAJOR_VERSION) {
case 9:
expectedEntries = v9Entries;
break;
--- a/jdk/test/java/util/jar/JarFile/MultiReleaseJarProperties.java Wed Mar 02 14:15:15 2016 +0100
+++ b/jdk/test/java/util/jar/JarFile/MultiReleaseJarProperties.java Wed Mar 02 16:25:29 2016 +0000
@@ -54,8 +54,7 @@
import java.nio.file.Files;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-
-import static sun.misc.Version.jdkMajorVersion; // fixme JEP 223 Version
+import jdk.Version;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
@@ -63,6 +62,9 @@
import org.testng.annotations.Test;
public class MultiReleaseJarProperties {
+
+ static final int MAJOR_VERSION = Version.current().major();
+
final static int ROOTVERSION = 8; // magic number from knowledge of internals
final static String userdir = System.getProperty("user.dir", ".");
final static File multirelease = new File(userdir, "multi-release.jar");
@@ -77,14 +79,14 @@
creator.compileEntries();
creator.buildMultiReleaseJar();
- rtVersion = Integer.getInteger("jdk.util.jar.version", jdkMajorVersion());
+ rtVersion = Integer.getInteger("jdk.util.jar.version", MAJOR_VERSION);
String mrprop = System.getProperty("jdk.util.jar.enableMultiRelease", "");
if (mrprop.equals("false")) {
rtVersion = ROOTVERSION;
} else if (rtVersion < ROOTVERSION) {
rtVersion = ROOTVERSION;
- } else if (rtVersion > jdkMajorVersion()) {
- rtVersion = jdkMajorVersion();
+ } else if (rtVersion > MAJOR_VERSION) {
+ rtVersion = MAJOR_VERSION;
}
force = mrprop.equals("force");
--- a/jdk/test/java/util/jar/JarFile/MultiReleaseJarSecurity.java Wed Mar 02 14:15:15 2016 +0100
+++ b/jdk/test/java/util/jar/JarFile/MultiReleaseJarSecurity.java Wed Mar 02 16:25:29 2016 +0000
@@ -40,6 +40,7 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipFile;
+import jdk.Version;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
@@ -47,6 +48,9 @@
import org.testng.annotations.Test;
public class MultiReleaseJarSecurity {
+
+ static final int MAJOR_VERSION = Version.current().major();
+
String userdir = System.getProperty("user.dir",".");
File multirelease = new File(userdir, "multi-release.jar");
File signedmultirelease = new File(userdir, "signed-multi-release.jar");
@@ -68,9 +72,8 @@
@Test
public void testCertsAndSigners() throws IOException {
try (JarFile jf = new JarFile(signedmultirelease, true, ZipFile.OPEN_READ, JarFile.Release.RUNTIME)) {
- int version = sun.misc.Version.jdkMajorVersion(); // fixme JEP 223 Version
CertsAndSigners vcas = new CertsAndSigners(jf, jf.getJarEntry("version/Version.class"));
- CertsAndSigners rcas = new CertsAndSigners(jf, jf.getJarEntry("META-INF/versions/" + version + "/version/Version.class"));
+ CertsAndSigners rcas = new CertsAndSigners(jf, jf.getJarEntry("META-INF/versions/" + MAJOR_VERSION + "/version/Version.class"));
Assert.assertTrue(Arrays.equals(rcas.getCertificates(), vcas.getCertificates()));
Assert.assertTrue(Arrays.equals(rcas.getCodeSigners(), vcas.getCodeSigners()));
}
--- a/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java Wed Mar 02 14:15:15 2016 +0100
+++ b/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java Wed Mar 02 16:25:29 2016 +0000
@@ -44,7 +44,7 @@
import org.testng.annotations.*;
public class MultiReleaseJarTest {
- final private int MAJOR_VERSION= Version.current().major();
+ final private int MAJOR_VERSION = Version.current().major();
final private String userdir = System.getProperty("user.dir",".");
final private Map<String,String> stringEnv = new HashMap<>();