author | rwestberg |
Mon, 04 Jun 2018 16:21:08 +0200 | |
changeset 50391 | 2bea53d7a27b |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
10541 | 1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
2 |
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
10541 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* @test |
|
26 |
* @bug 7068051 |
|
27 |
* @summary SIGSEGV in PhaseIdealLoop::build_loop_late_post on T5440 |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
28 |
* @library /test/lib |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
27699
diff
changeset
|
30 |
* java.management |
40059 | 31 |
* |
32 |
* @run main/othervm -showversion -Xbatch compiler.c2.Test7068051 |
|
10541 | 33 |
*/ |
34 |
||
40059 | 35 |
package compiler.c2; |
36 |
||
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
37 |
import jdk.test.lib.JDKToolLauncher; |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
38 |
import jdk.test.lib.process.OutputAnalyzer; |
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
39 |
|
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
40 |
import java.io.IOException; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
41 |
import java.io.InputStream; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
42 |
import java.nio.file.Files; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
43 |
import java.nio.file.Path; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
44 |
import java.nio.file.Paths; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
45 |
import java.nio.file.StandardCopyOption; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
46 |
import java.util.ArrayList; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
47 |
import java.util.Enumeration; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
48 |
import java.util.List; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
49 |
import java.util.zip.ZipEntry; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
50 |
import java.util.zip.ZipFile; |
10541 | 51 |
|
52 |
public class Test7068051 { |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
53 |
private static final String SELF_NAME = Test7068051.class.getSimpleName(); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
54 |
private static final String SELF_FILE_NAME = SELF_NAME + ".java"; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
55 |
private static final String JAR_NAME = "foo.jar"; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
56 |
private static final String TEST_PATH = System.getProperty("test.src"); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
57 |
private static final Path CURRENT_DIR = Paths.get("."); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
58 |
private static final Path TEST_SOURCE_PATH = Paths.get(TEST_PATH, SELF_FILE_NAME); |
10541 | 59 |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
60 |
public static void main (String[] args) throws IOException { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
61 |
createTestJarFile(); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
62 |
System.out.println("Running test..."); |
10541 | 63 |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
64 |
try (ZipFile zf = new ZipFile(JAR_NAME)) { |
10541 | 65 |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
66 |
Enumeration<? extends ZipEntry> entries = zf.entries(); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
67 |
ArrayList<String> names = new ArrayList<String>(); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
68 |
while (entries.hasMoreElements()) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
69 |
names.add(entries.nextElement().getName()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
70 |
} |
10541 | 71 |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
72 |
byte[] bytes = new byte[16]; |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
73 |
for (String name : names) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
74 |
ZipEntry e = zf.getEntry(name); |
10541 | 75 |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
76 |
if (e.isDirectory()) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
77 |
continue; |
10541 | 78 |
} |
79 |
||
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
80 |
try (final InputStream is = zf.getInputStream(e)) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
81 |
try { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
82 |
while (is.read(bytes) >= 0) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
83 |
} |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
84 |
} catch (IOException x) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
85 |
System.out.println(".................................."); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
86 |
System.out.println(" --> is :" + is); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
87 |
System.out.println(" is.hash :" + is.hashCode()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
88 |
System.out.println(); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
89 |
System.out.println(" e.name :" + e.getName()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
90 |
System.out.println(" e.hash :" + e.hashCode()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
91 |
System.out.println(" e.method :" + e.getMethod()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
92 |
System.out.println(" e.size :" + e.getSize()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
93 |
System.out.println(" e.csize :" + e.getCompressedSize()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
94 |
System.out.println(".................................."); |
10541 | 95 |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
96 |
throw new AssertionError("IOException was throwing while read the archive. Test failed.", x); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
97 |
} |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
98 |
} |
10541 | 99 |
} |
100 |
} |
|
27640
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
101 |
System.out.println("Test passed."); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
102 |
} |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
103 |
|
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
104 |
private static void createTestJarFile() { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
105 |
ArrayList<String> jarOptions = new ArrayList<>(); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
106 |
|
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
107 |
// jar cf foo.jar * |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
108 |
System.out.println("Creating jar file.."); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
109 |
jarOptions.add("cf"); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
110 |
jarOptions.add(JAR_NAME); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
111 |
try { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
112 |
for (int i = 0; i < 100; ++i) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
113 |
Path temp = Files.createTempFile(CURRENT_DIR, SELF_NAME, ".java"); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
114 |
Files.copy(TEST_SOURCE_PATH, temp, StandardCopyOption.REPLACE_EXISTING); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
115 |
jarOptions.add(temp.toString()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
116 |
} |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
117 |
} catch (IOException ex) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
118 |
throw new AssertionError("TESTBUG: Creating temp files failed.", ex); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
119 |
} |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
120 |
runJar(jarOptions); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
121 |
|
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
122 |
// jar -uf0 foo.jar Test7068051.java |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
123 |
System.out.println("Adding unpacked file..."); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
124 |
jarOptions.clear(); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
125 |
jarOptions.add("-uf0"); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
126 |
jarOptions.add(JAR_NAME); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
127 |
jarOptions.add(TEST_SOURCE_PATH.toString()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
128 |
runJar(jarOptions); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
129 |
} |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
130 |
|
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
131 |
private static void runJar(List<String> params) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
132 |
JDKToolLauncher jar = JDKToolLauncher.create("jar"); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
133 |
for (String p : params) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
134 |
jar.addToolArg(p); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
135 |
} |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
136 |
ProcessBuilder pb = new ProcessBuilder(jar.getCommand()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
137 |
try { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
138 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
139 |
output.shouldHaveExitValue(0); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
140 |
} catch (IOException ex) { |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
141 |
throw new AssertionError("TESTBUG: jar failed.", ex); |
3eab5c5bf81a
8062011: JT_HS/compiler/7068051 uses jre/lib/javaws.jar
iignatyev
parents:
10541
diff
changeset
|
142 |
} |
10541 | 143 |
} |
144 |
} |