jjg@215: /* ohair@554: * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. jjg@215: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@215: * jjg@215: * This code is free software; you can redistribute it and/or modify it jjg@215: * under the terms of the GNU General Public License version 2 only, as jjg@215: * published by the Free Software Foundation. jjg@215: * jjg@215: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@215: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@215: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@215: * version 2 for more details (a copy is included in the LICENSE file that jjg@215: * accompanied this code). jjg@215: * jjg@215: * You should have received a copy of the GNU General Public License version jjg@215: * 2 along with this work; if not, write to the Free Software Foundation, jjg@215: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@215: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@215: */ jjg@215: jjg@215: /* jjg@215: * @test jjg@215: * @bug 6595666 jjg@215: * @summary fix -Werror jjg@215: */ jjg@215: jjg@215: import java.io.*; jjg@215: import java.util.*; jjg@215: jjg@215: public class T6595666 { jjg@215: void m() { jjg@215: // the following line must create warnings with -Xlint, because of unchecked conversion jjg@215: List list = new ArrayList(); jjg@215: } jjg@215: jjg@215: public static void main(String... args) throws Exception { jjg@215: File testSrc = new File(System.getProperty("test.src", ".")); jjg@215: jjg@215: String basename = T6595666.class.getName(); jjg@215: File srcFile = new File(testSrc, basename+".java"); jjg@215: File classFile = new File(basename+".class"); jjg@215: classFile.delete(); jjg@215: if (classFile.exists()) jjg@215: throw new Exception("setup error, can't delete " + classFile); jjg@215: jjg@215: compile(1, "-d", ".", "-Xlint", "-Werror", srcFile.getPath()); jjg@215: if (classFile.exists()) jjg@215: throw new Exception("failed: found " + classFile); jjg@215: jjg@215: compile(0, "-d", ".", "-Xlint", srcFile.getPath()); jjg@215: if (!classFile.exists()) jjg@215: throw new Exception("failed: " + classFile + " not found"); jjg@215: } jjg@215: jjg@215: private static void compile(int rc, String... args) throws Exception { jjg@215: System.err.println("compile: " + Arrays.asList(args)); jjg@215: StringWriter sw = new StringWriter(); jjg@215: PrintWriter pw = new PrintWriter(sw); jjg@215: int rc2 = com.sun.tools.javac.Main.compile(args, pw); jjg@215: pw.close(); jjg@215: System.err.println(sw); jjg@215: if (rc != rc2) jjg@215: throw new Exception("bad exit code; expected " + rc + ", found " + rc2); jjg@215: } jjg@215: }