1996
|
1 |
/*
|
5520
|
2 |
* Copyright (c) 2009, 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
|
|
28 |
*/
|
|
29 |
|
|
30 |
import java.io.*;
|
|
31 |
import java.util.*;
|
|
32 |
|
|
33 |
public class T6595666 {
|
|
34 |
void m() {
|
|
35 |
// the following line must create warnings with -Xlint, because of unchecked conversion
|
|
36 |
List<Integer> list = new ArrayList();
|
|
37 |
}
|
|
38 |
|
|
39 |
public static void main(String... args) throws Exception {
|
|
40 |
File testSrc = new File(System.getProperty("test.src", "."));
|
|
41 |
|
|
42 |
String basename = T6595666.class.getName();
|
|
43 |
File srcFile = new File(testSrc, basename+".java");
|
|
44 |
File classFile = new File(basename+".class");
|
|
45 |
classFile.delete();
|
|
46 |
if (classFile.exists())
|
|
47 |
throw new Exception("setup error, can't delete " + classFile);
|
|
48 |
|
|
49 |
compile(1, "-d", ".", "-Xlint", "-Werror", srcFile.getPath());
|
|
50 |
if (classFile.exists())
|
|
51 |
throw new Exception("failed: found " + classFile);
|
|
52 |
|
|
53 |
compile(0, "-d", ".", "-Xlint", srcFile.getPath());
|
|
54 |
if (!classFile.exists())
|
|
55 |
throw new Exception("failed: " + classFile + " not found");
|
|
56 |
}
|
|
57 |
|
|
58 |
private static void compile(int rc, String... args) throws Exception {
|
|
59 |
System.err.println("compile: " + Arrays.asList(args));
|
|
60 |
StringWriter sw = new StringWriter();
|
|
61 |
PrintWriter pw = new PrintWriter(sw);
|
|
62 |
int rc2 = com.sun.tools.javac.Main.compile(args, pw);
|
|
63 |
pw.close();
|
|
64 |
System.err.println(sw);
|
|
65 |
if (rc != rc2)
|
|
66 |
throw new Exception("bad exit code; expected " + rc + ", found " + rc2);
|
|
67 |
}
|
|
68 |
}
|