author | alanb |
Mon, 21 Jan 2013 23:23:12 -0500 | |
changeset 15684 | e5b41bd22ec9 |
parent 12857 | 0a5f341c2a28 |
child 18594 | b6a3c9f71ac8 |
permissions | -rw-r--r-- |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
1 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
2 |
/* |
12544 | 3 |
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
5 |
* |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
9 |
* |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
14 |
* accompanied this code). |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
15 |
* |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
19 |
* |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
22 |
* questions. |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
23 |
*/ |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
24 |
|
6314
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
25 |
/* |
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
26 |
* @test |
12857
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
12544
diff
changeset
|
27 |
* @bug 6712743 6991164 7168401 |
6314
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
28 |
* @summary verify package versions |
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
29 |
* @compile -XDignore.symbol.file Utils.java PackageVersionTest.java |
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
30 |
* @run main PackageVersionTest |
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
31 |
* @author ksrini |
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
32 |
*/ |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
33 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
34 |
import java.io.ByteArrayOutputStream; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
35 |
import java.io.Closeable; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
36 |
import java.io.File; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
37 |
import java.io.FileOutputStream; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
38 |
import java.io.IOException; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
39 |
import java.io.PrintStream; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
40 |
import java.util.jar.JarFile; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
41 |
import java.util.jar.Pack200; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
42 |
import java.util.jar.Pack200.Packer; |
6891
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
43 |
import java.util.jar.Pack200.Unpacker; |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
44 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
45 |
public class PackageVersionTest { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
46 |
private static final File javaHome = new File(System.getProperty("java.home")); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
47 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
48 |
public final static int JAVA5_PACKAGE_MAJOR_VERSION = 150; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
49 |
public final static int JAVA5_PACKAGE_MINOR_VERSION = 7; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
50 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
51 |
public final static int JAVA6_PACKAGE_MAJOR_VERSION = 160; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
52 |
public final static int JAVA6_PACKAGE_MINOR_VERSION = 1; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
53 |
|
12544 | 54 |
public final static int JAVA7_PACKAGE_MAJOR_VERSION = 170; |
55 |
public final static int JAVA7_PACKAGE_MINOR_VERSION = 1; |
|
56 |
||
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
57 |
public static void main(String... args) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
58 |
if (!javaHome.getName().endsWith("jre")) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
59 |
throw new RuntimeException("Error: requires an SDK to run"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
60 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
61 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
62 |
File out = new File("test.pack"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
63 |
createClassFile("Test5"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
64 |
createClassFile("Test6"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
65 |
createClassFile("Test7"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
66 |
|
6891
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
67 |
verify6991164(); |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
68 |
verifyPack("Test5.class", JAVA5_PACKAGE_MAJOR_VERSION, |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
69 |
JAVA5_PACKAGE_MINOR_VERSION); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
70 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
71 |
verifyPack("Test6.class", JAVA6_PACKAGE_MAJOR_VERSION, |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
72 |
JAVA6_PACKAGE_MINOR_VERSION); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
73 |
|
12857
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
12544
diff
changeset
|
74 |
// a jar file devoid of indy classes must generate 160.1 package file |
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
12544
diff
changeset
|
75 |
verifyPack("Test7.class", JAVA6_PACKAGE_MAJOR_VERSION, |
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
12544
diff
changeset
|
76 |
JAVA6_PACKAGE_MINOR_VERSION); |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
77 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
78 |
// test for resource file, ie. no class files |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
79 |
verifyPack("Test6.java", JAVA5_PACKAGE_MAJOR_VERSION, |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
80 |
JAVA5_PACKAGE_MINOR_VERSION); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
81 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
82 |
|
6891
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
83 |
static void verify6991164() { |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
84 |
Unpacker unpacker = Pack200.newUnpacker(); |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
85 |
String versionStr = unpacker.toString(); |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
86 |
String expected = "Pack200, Vendor: " + |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
87 |
System.getProperty("java.vendor") + ", Version: " + |
12857
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
12544
diff
changeset
|
88 |
JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION; |
6891
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
89 |
if (!versionStr.equals(expected)) { |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
90 |
System.out.println("Expected: " + expected); |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
91 |
System.out.println("Obtained: " + versionStr); |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
92 |
throw new RuntimeException("did not get expected string " + expected); |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
93 |
} |
f8a528363fa5
6991164: pack source needs vendor rebranding changes (jdk7 only)
ksrini
parents:
6314
diff
changeset
|
94 |
} |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
95 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
96 |
static void createClassFile(String name) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
97 |
createJavaFile(name); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
98 |
String target = name.substring(name.length() - 1); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
99 |
String javacCmds[] = { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
100 |
"-source", |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
101 |
"5", |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
102 |
"-target", |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
103 |
name.substring(name.length() - 1), |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
104 |
name + ".java" |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
105 |
}; |
6314
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
106 |
Utils.compiler(javacCmds); |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
107 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
108 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
109 |
static void createJavaFile(String name) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
110 |
PrintStream ps = null; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
111 |
FileOutputStream fos = null; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
112 |
File outputFile = new File(name + ".java"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
113 |
outputFile.delete(); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
114 |
try { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
115 |
fos = new FileOutputStream(outputFile); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
116 |
ps = new PrintStream(fos); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
117 |
ps.format("public class %s {}", name); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
118 |
} catch (IOException ioe) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
119 |
throw new RuntimeException("creation of test file failed"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
120 |
} finally { |
6314
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
121 |
Utils.close(ps); |
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
122 |
Utils.close(fos); |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
123 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
124 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
125 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
126 |
static void verifyPack(String filename, int expected_major, int expected_minor) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
127 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
128 |
File jarFileName = new File("test.jar"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
129 |
jarFileName.delete(); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
130 |
String jargs[] = { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
131 |
"cvf", |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
132 |
jarFileName.getName(), |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
133 |
filename |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
134 |
}; |
6314
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
135 |
Utils.jar(jargs); |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
136 |
JarFile jfin = null; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
137 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
138 |
try { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
139 |
jfin = new JarFile(jarFileName); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
140 |
Packer packer = Pack200.newPacker(); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
141 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
142 |
packer.pack(jfin, baos); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
143 |
baos.flush(); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
144 |
baos.close(); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
145 |
byte[] buf = baos.toByteArray(); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
146 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
147 |
int minor = buf[4] & 0x000000ff; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
148 |
int major = buf[5] & 0x000000ff; |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
149 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
150 |
if (major != expected_major || minor != expected_minor) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
151 |
String msg = |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
152 |
String.format("test fails: expected:%d.%d but got %d.%d\n", |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
153 |
expected_major, expected_minor, |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
154 |
major, minor); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
155 |
throw new Error(msg); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
156 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
157 |
|
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
158 |
System.out.println(filename + ": OK"); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
159 |
} catch (IOException ioe) { |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
160 |
throw new RuntimeException(ioe.getMessage()); |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
161 |
} finally { |
6314
8ab691ddb904
6966737: (pack200) the pack200 regression tests need to be more robust.
ksrini
parents:
5811
diff
changeset
|
162 |
Utils.close((Closeable) jfin); |
5811
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
163 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
164 |
} |
f4d1f45c0058
6712743: pack200: should default to 150.7 pack format for classfiles without any classes.
ksrini
parents:
diff
changeset
|
165 |
} |