author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 8837 | 141b22c7e7b2 |
permissions | -rw-r--r-- |
8837 | 1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
8837
diff
changeset
|
2 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
8837 | 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 6865530 |
|
27 |
* @summary ensure JavacFileManager handles non-standard zipfiles. |
|
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
8837
diff
changeset
|
28 |
* @modules jdk.compiler |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
8837
diff
changeset
|
29 |
* jdk.jartool/sun.tools.jar |
8837 | 30 |
* @compile -XDignore.symbol.file T6865530.java |
31 |
* @run main T6865530 |
|
32 |
*/ |
|
33 |
||
34 |
||
35 |
import java.io.File; |
|
36 |
||
37 |
||
38 |
public class T6865530 { |
|
39 |
||
40 |
public static void main(String... args) throws Exception { |
|
41 |
File badFile = new File("bad.exe"); |
|
42 |
File testJar = new File("test.jar"); |
|
43 |
File fooJava = new File("Foo.java"); |
|
44 |
File barJava = new File("Bar.java"); |
|
45 |
||
46 |
// create a jar by compiling a file, and append the jar to some |
|
47 |
// arbitrary data to offset the start of the zip/jar archive |
|
48 |
Utils.createJavaFile(fooJava); |
|
49 |
Utils.compile("-doe", "-verbose", fooJava.getName()); |
|
50 |
String[] jarArgs = { |
|
51 |
"cvf", testJar.getAbsolutePath(), "Foo.class" |
|
52 |
}; |
|
53 |
Utils.jarTool.run(jarArgs); |
|
54 |
Utils.cat(badFile, fooJava, testJar); |
|
55 |
||
56 |
// create test file and use the above file as a classpath |
|
57 |
Utils.createJavaFile(barJava); |
|
58 |
try { |
|
59 |
if (!Utils.compile("-doe", "-verbose", "-cp", badFile.getAbsolutePath(), "Bar.java")) { |
|
60 |
throw new RuntimeException("test fails javac did not compile"); |
|
61 |
} |
|
62 |
} finally { |
|
63 |
Utils.deleteFile(badFile); |
|
64 |
Utils.deleteFile(testJar); |
|
65 |
} |
|
66 |
} |
|
67 |
} |
|
68 |