author | mcimadamore |
Wed, 26 Oct 2016 15:41:25 +0100 | |
changeset 41856 | 13a056e8f16e |
parent 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
1996 | 1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
5520
diff
changeset
|
2 |
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. |
1996 | 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 |
* |
|
5520 | 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. |
|
1996 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 6595666 |
|
27 |
* @summary fix -Werror |
|
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
5520
diff
changeset
|
28 |
* @modules jdk.compiler |
1996 | 29 |
*/ |
30 |
||
31 |
import java.io.*; |
|
32 |
import java.util.*; |
|
33 |
||
34 |
public class T6595666 { |
|
35 |
void m() { |
|
36 |
// the following line must create warnings with -Xlint, because of unchecked conversion |
|
37 |
List<Integer> list = new ArrayList(); |
|
38 |
} |
|
39 |
||
40 |
public static void main(String... args) throws Exception { |
|
41 |
File testSrc = new File(System.getProperty("test.src", ".")); |
|
42 |
||
43 |
String basename = T6595666.class.getName(); |
|
44 |
File srcFile = new File(testSrc, basename+".java"); |
|
45 |
File classFile = new File(basename+".class"); |
|
46 |
classFile.delete(); |
|
47 |
if (classFile.exists()) |
|
48 |
throw new Exception("setup error, can't delete " + classFile); |
|
49 |
||
50 |
compile(1, "-d", ".", "-Xlint", "-Werror", srcFile.getPath()); |
|
51 |
if (classFile.exists()) |
|
52 |
throw new Exception("failed: found " + classFile); |
|
53 |
||
54 |
compile(0, "-d", ".", "-Xlint", srcFile.getPath()); |
|
55 |
if (!classFile.exists()) |
|
56 |
throw new Exception("failed: " + classFile + " not found"); |
|
57 |
} |
|
58 |
||
59 |
private static void compile(int rc, String... args) throws Exception { |
|
60 |
System.err.println("compile: " + Arrays.asList(args)); |
|
61 |
StringWriter sw = new StringWriter(); |
|
62 |
PrintWriter pw = new PrintWriter(sw); |
|
63 |
int rc2 = com.sun.tools.javac.Main.compile(args, pw); |
|
64 |
pw.close(); |
|
65 |
System.err.println(sw); |
|
66 |
if (rc != rc2) |
|
67 |
throw new Exception("bad exit code; expected " + rc + ", found " + rc2); |
|
68 |
} |
|
69 |
} |