jjg@376: /* jjg@376: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. jjg@376: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@376: * jjg@376: * This code is free software; you can redistribute it and/or modify it jjg@376: * under the terms of the GNU General Public License version 2 only, as jjg@376: * published by the Free Software Foundation. jjg@376: * jjg@376: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@376: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@376: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@376: * version 2 for more details (a copy is included in the LICENSE file that jjg@376: * accompanied this code). jjg@376: * jjg@376: * You should have received a copy of the GNU General Public License version jjg@376: * 2 along with this work; if not, write to the Free Software Foundation, jjg@376: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@376: * jjg@376: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, jjg@376: * CA 95054 USA or visit www.sun.com if you need additional information or jjg@376: * have any questions. jjg@376: */ jjg@376: jjg@376: import java.io.File; jjg@376: import java.io.PrintWriter; jjg@376: import java.io.StringWriter; jjg@376: import java.util.ArrayList; jjg@376: import java.util.List; jjg@376: jjg@376: /* jjg@376: * @test jjg@376: * @bug 6873849 jjg@376: * @summary suppress notes generated by javac jjg@376: */ jjg@376: jjg@376: public class T6873849 { jjg@376: public static void main(String... args) throws Exception { jjg@376: new T6873849().run(); jjg@376: } jjg@376: jjg@376: public void run() throws Exception { jjg@376: test(null, "- compiler.note.unchecked.filename: T6873849.java" + newline + jjg@376: "- compiler.note.unchecked.recompile" + newline); jjg@376: test("-XDsuppressNotes", ""); jjg@376: } jjg@376: jjg@376: void test(String opt, String expect) throws Exception { jjg@376: List args = new ArrayList(); jjg@376: if (opt != null) jjg@376: args.add(opt); jjg@376: args.add("-d"); jjg@376: args.add(testClasses.getPath()); jjg@376: args.add("-XDrawDiagnostics"); jjg@376: args.add(new File(testSrc, "T6873849.java").getPath()); jjg@376: StringWriter sw = new StringWriter(); jjg@376: PrintWriter pw = new PrintWriter(sw); jjg@376: System.err.println("compile: " + args); jjg@376: int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw); jjg@376: pw.close(); jjg@376: String out = sw.toString(); jjg@376: System.out.println(out); jjg@376: if (rc != 0) jjg@376: throw new Exception("compilation failed unexpectedly"); jjg@376: if (!out.equals(expect)) jjg@376: throw new Exception("unexpected output from compiler"); jjg@376: } jjg@376: jjg@376: void m(List t) { jjg@376: // force a note about unchecked usage jjg@376: t.add(new Object()); jjg@376: } jjg@376: jjg@376: private File testSrc = new File(System.getProperty("test.src", ".")); jjg@376: private File testClasses = new File(System.getProperty("test.classes", ".")); jjg@376: private String newline = System.getProperty("line.separator"); jjg@376: }