8156807: Pack200 must support v53.0 class files
Reviewed-by: mchung, shade
This commit is contained in:
parent
4dcf9fd923
commit
ca98819c49
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,9 +43,10 @@ class Constants {
|
|||||||
1.0 to 1.3.X 45,3
|
1.0 to 1.3.X 45,3
|
||||||
1.4 to 1.4.X 46,0
|
1.4 to 1.4.X 46,0
|
||||||
1.5 to 1.5.X 49,0
|
1.5 to 1.5.X 49,0
|
||||||
1.6 to 1.5.x 50,0
|
1.6 to 1.6.X 50,0
|
||||||
1.7 to 1.6.x 51,0
|
1.7 to 1.7.X 51,0
|
||||||
1.8 to 1.7.x 52,0
|
1.8 to 1.8.X 52,0
|
||||||
|
1.9 to 1.9.X 53,0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final Package.Version JAVA_MIN_CLASS_VERSION =
|
public static final Package.Version JAVA_MIN_CLASS_VERSION =
|
||||||
@ -63,6 +64,9 @@ class Constants {
|
|||||||
public static final Package.Version JAVA8_MAX_CLASS_VERSION =
|
public static final Package.Version JAVA8_MAX_CLASS_VERSION =
|
||||||
Package.Version.of(52, 00);
|
Package.Version.of(52, 00);
|
||||||
|
|
||||||
|
public static final Package.Version JAVA9_MAX_CLASS_VERSION =
|
||||||
|
Package.Version.of(53, 00);
|
||||||
|
|
||||||
public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
|
public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
|
||||||
|
|
||||||
public static final Package.Version JAVA5_PACKAGE_VERSION =
|
public static final Package.Version JAVA5_PACKAGE_VERSION =
|
||||||
@ -79,7 +83,7 @@ class Constants {
|
|||||||
|
|
||||||
// upper limit, should point to the latest class version
|
// upper limit, should point to the latest class version
|
||||||
public static final Package.Version JAVA_MAX_CLASS_VERSION =
|
public static final Package.Version JAVA_MAX_CLASS_VERSION =
|
||||||
JAVA8_MAX_CLASS_VERSION;
|
JAVA9_MAX_CLASS_VERSION;
|
||||||
|
|
||||||
// upper limit should point to the latest package version, for version info!.
|
// upper limit should point to the latest package version, for version info!.
|
||||||
public static final Package.Version MAX_PACKAGE_VERSION =
|
public static final Package.Version MAX_PACKAGE_VERSION =
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,30 +23,10 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
Java Class Version numbers history
|
|
||||||
1.0 to 1.3.X 45,3
|
|
||||||
1.4 to 1.4.X 46,0
|
|
||||||
1.5 to 1.5.X 49,0
|
|
||||||
1.6 to 1.5.x 50,0 NOTE Assumed for now
|
|
||||||
*/
|
|
||||||
|
|
||||||
// classfile constants
|
// classfile constants
|
||||||
#define JAVA_MAGIC 0xCAFEBABE
|
#define JAVA_MAGIC 0xCAFEBABE
|
||||||
#define JAVA_MIN_MAJOR_VERSION 45
|
|
||||||
#define JAVA_MIN_MINOR_VERSION 3
|
|
||||||
|
|
||||||
#define JAVA5_MAX_MAJOR_VERSION 49
|
// Class version history, refer to Constants.java
|
||||||
#define JAVA5_MAX_MINOR_VERSION 0
|
|
||||||
|
|
||||||
#define JAVA6_MAX_MAJOR_VERSION 50
|
|
||||||
#define JAVA6_MAX_MINOR_VERSION 0
|
|
||||||
|
|
||||||
#define JAVA7_MAX_MAJOR_VERSION 51
|
|
||||||
#define JAVA7_MAX_MINOR_VERSION 0
|
|
||||||
|
|
||||||
#define JAVA8_MAX_MAJOR_VERSION 52
|
|
||||||
#define JAVA8_MAX_MINOR_VERSION 0
|
|
||||||
|
|
||||||
// package file constants
|
// package file constants
|
||||||
#define JAVA_PACKAGE_MAGIC 0xCAFED00D
|
#define JAVA_PACKAGE_MAGIC 0xCAFED00D
|
||||||
|
@ -332,8 +332,6 @@ tools/launcher/FXLauncherTest.java 8068049 linux-al
|
|||||||
|
|
||||||
tools/pack200/Pack200Props.java 8155857 generic-all
|
tools/pack200/Pack200Props.java 8155857 generic-all
|
||||||
|
|
||||||
tools/pack200/TestNormal.java 8156807 windows-all
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# jdk_jdi
|
# jdk_jdi
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,85 +25,37 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @run main/timeout=600 TestNormal
|
* @run main/timeout=600 TestNormal
|
||||||
* @bug 8020802
|
* @bug 8020802 8156807
|
||||||
* @summary Need an ability to create jar files that are invariant to the pack200 packing/unpacking
|
* @summary Need an ability to create jar files that are invariant to the pack200 packing/unpacking
|
||||||
* @author Alexander Zuev
|
* @author Alexander Zuev
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.jar.JarEntry;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
|
|
||||||
public class TestNormal {
|
public class TestNormal {
|
||||||
private static String FS = File.separator;
|
private static String FS = File.separator;
|
||||||
|
|
||||||
public static void main(String args[]) throws Exception {
|
public static void main(String args[]) throws Exception {
|
||||||
Properties p = System.getProperties();
|
|
||||||
String java_home = p.getProperty("test.jdk");
|
|
||||||
String testdir = Utils.TEST_CLS_DIR.getAbsolutePath();
|
String testdir = Utils.TEST_CLS_DIR.getAbsolutePath();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
execJavaCommand(java_home, "jar cnf normalized.jar -C " + testdir + " .");
|
String jarCmd = Utils.getJarCmd();
|
||||||
execJavaCommand(java_home, "jar cf original.jar -C " + testdir + " .");
|
String packCmd = Utils.getPack200Cmd();
|
||||||
execJavaCommand(java_home, "pack200 -r repacked.jar original.jar");
|
|
||||||
compareJars(new JarFile("normalized.jar"), new JarFile("repacked.jar"));
|
// create the original jar
|
||||||
|
Utils.runExec(jarCmd, "cf", "original.jar", "-C", testdir, ".");
|
||||||
|
|
||||||
|
// create the reference jar
|
||||||
|
Utils.runExec(packCmd, "-r", "repacked.jar", "original.jar");
|
||||||
|
|
||||||
|
// create the normalized jar using jar(1)
|
||||||
|
Utils.runExec(jarCmd, "cnf", "normalized.jar", "-C", testdir, ".");
|
||||||
|
|
||||||
|
// compare archive contents bit wise, these should be identical!
|
||||||
|
Utils.doCompareBitWise(new File("repacked.jar"),
|
||||||
|
new File("normalized.jar"));
|
||||||
} finally {
|
} finally {
|
||||||
String[] cleanupList = {"normalized.jar", "original.jar", "repacked.jar"};
|
Utils.cleanup();
|
||||||
for (String s : cleanupList) {
|
|
||||||
delete(new File(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void execJavaCommand(String java_home, String cmd) throws Exception {
|
|
||||||
Process proc = Runtime.getRuntime().exec(java_home + FS + "bin" + FS + cmd);
|
|
||||||
String s;
|
|
||||||
BufferedReader stdInput =
|
|
||||||
new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
|
||||||
BufferedReader stdError =
|
|
||||||
new BufferedReader(new InputStreamReader(proc.getErrorStream()));
|
|
||||||
while ((s = stdInput.readLine()) != null) {
|
|
||||||
System.out.println(s);
|
|
||||||
}
|
|
||||||
while ((s = stdError.readLine()) != null) {
|
|
||||||
System.err.println(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception {
|
|
||||||
try {
|
|
||||||
if (jf1.size() != jf2.size()) {
|
|
||||||
throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName()
|
|
||||||
+ " have different number of entries");
|
|
||||||
}
|
|
||||||
for (JarEntry elem1 : Collections.list(jf1.entries())) {
|
|
||||||
JarEntry elem2 = jf2.getJarEntry(elem1.getName());
|
|
||||||
if (elem2 == null) {
|
|
||||||
throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName());
|
|
||||||
}
|
|
||||||
if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) {
|
|
||||||
throw new Exception("The crc of " + elem1.getName() + " is different.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
jf1.close();
|
|
||||||
jf2.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void delete(File f) throws IOException {
|
|
||||||
if (!f.exists()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (f.isDirectory()) {
|
|
||||||
for (File c : f.listFiles()) {
|
|
||||||
delete(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!f.delete()) {
|
|
||||||
throw new FileNotFoundException("Failed to delete file: " + f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
@ -483,9 +482,15 @@ class Utils {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static List<String> runExec(String... cmds) {
|
||||||
|
return runExec(Arrays.asList(cmds));
|
||||||
|
}
|
||||||
|
|
||||||
static List<String> runExec(List<String> cmdsList) {
|
static List<String> runExec(List<String> cmdsList) {
|
||||||
return runExec(cmdsList, null);
|
return runExec(cmdsList, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<String> runExec(List<String> cmdsList, Map<String, String> penv) {
|
static List<String> runExec(List<String> cmdsList, Map<String, String> penv) {
|
||||||
ArrayList<String> alist = new ArrayList<String>();
|
ArrayList<String> alist = new ArrayList<String>();
|
||||||
ProcessBuilder pb =
|
ProcessBuilder pb =
|
||||||
|
Loading…
Reference in New Issue
Block a user