file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
T7086261.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/7086261/T7086261.java
/* * Copyright (c) 20011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 7086261 * @summary javac doesn't report error as expected, it only reports ClientCodeWrapper$DiagnosticSourceUnwrapper */ import javax.tools.*; import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper; import com.sun.tools.javac.util.JCDiagnostic; import java.net.URI; import java.util.Arrays; import static javax.tools.StandardLocation.*; import static javax.tools.JavaFileObject.Kind.*; public class T7086261 { static class ErroneousSource extends SimpleJavaFileObject { public ErroneousSource() { super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); } public CharSequence getCharContent(boolean ignoreEncodingErrors) { return "class Test { NonexistentClass c = null; }"; } } static class DiagnosticChecker implements DiagnosticListener<javax.tools.JavaFileObject> { public void report(Diagnostic message) { if (!(message instanceof DiagnosticSourceUnwrapper)) { throw new AssertionError("Wrapped diagnostic expected!"); } String actual = message.toString(); JCDiagnostic jd = (JCDiagnostic)((DiagnosticSourceUnwrapper)message).d; String expected = jd.toString(); if (!actual.equals(expected)) { throw new AssertionError("expected = " + expected + "\nfound = " + actual); } } }; void test() throws Throwable { JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); JavaFileManager jfm = javac.getStandardFileManager(null, null, null); JavaCompiler.CompilationTask task = javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource())); task.call(); } public static void main(String[] args) throws Throwable { new T7086261().test(); } }
2,970
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6400303.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6400303/T6400303.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * @test * @bug 6400303 * @summary REGRESSION: javadoc crashes in b75 * @author Peter von der Ah\u00e9 * @compile Test1.java * @compile Test2.java * @run main/othervm -esa T6400303 */ import javax.tools.ToolProvider; import com.sun.tools.javac.api.JavacTaskImpl; import com.sun.tools.javac.code.Symbol.CompletionFailure; import com.sun.tools.javac.main.JavaCompiler; public class T6400303 { public static void main(String... args) { javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null); JavaCompiler compiler = JavaCompiler.instance(task.getContext()); try { compiler.resolveIdent("Test$1").complete(); } catch (CompletionFailure ex) { System.err.println("Got expected completion failure: " + ex.getLocalizedMessage()); return; } throw new AssertionError("No error reported"); } }
2,054
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Test1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6400303/Test1.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.util.Iterator; class Test { <T> void test() { new Iterable<T>() { public Iterator<T> iterator() { return null; } }; } }
1,221
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Test2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6400303/Test2.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ class Test {}
1,066
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6421756.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6421756/T6421756.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6421756 * @summary 6421756 JSR 199: In the method JavaCompilerTool.getTask 'options' can be supplied in the place of 'classes' * @author Peter von der Ah\u00e9 * @library ../lib * @compile T6421756.java * @run main T6421756 */ import java.util.Collections; public class T6421756 extends ToolTester { void test(String... args) { Iterable<String> options = Collections.singleton("-verbose"); try { task = tool.getTask(null, fm, null, null, options, null); throw new AssertionError("Expected IllegalArgumentException!"); } catch (IllegalArgumentException e) { System.out.println("OK: got expected error " + e.getLocalizedMessage()); } } public static void main(String... args) { new T6421756().test(args); } }
1,884
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
package-info.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6440528/package-info.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.foo.bar.baz;
1,081
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6440528.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6440528/T6440528.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6440528 * @summary javac deposits package-info.class in bogus directory * @author Peter von der Ah\u00e9 * @library ../lib * @compile T6440528.java * @run main T6440528 */ import java.io.File; import java.lang.reflect.Field; import java.util.Arrays; import static javax.tools.StandardLocation.CLASS_OUTPUT; import javax.tools.*; public class T6440528 extends ToolTester { void test(String... args) throws Exception { fm.setLocation(CLASS_OUTPUT, null); // no class files are // generated, so this will // not leave clutter in // the source directory Iterable<File> files = Arrays.asList(new File(test_src, "package-info.java")); JavaFileObject src = fm.getJavaFileObjectsFromFiles(files).iterator().next(); char sep = File.separatorChar; FileObject cls = fm.getFileForOutput(CLASS_OUTPUT, "com.sun.foo.bar.baz", "package-info.class", src); File expect = new File(test_src, "package-info.class"); File got = getUnderlyingFile(cls); if (!got.equals(expect)) throw new AssertionError(String.format("Expected: %s; got: %s", expect, got)); System.err.println("Expected: " + expect); System.err.println("Got: " + got); } private File getUnderlyingFile(Object o) throws Exception { Field file = o.getClass().getDeclaredField("file"); file.setAccessible(true); return (File)file.get(o); } public static void main(String... args) throws Exception { new T6440528().test(args); } }
2,878
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Main.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6471599/Main.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6471599 * @summary Type of rhs cannot be obtained when assigning to erroneous symbol * @author Peter von der Ah\u00e9 * @compile Main.java * @run main Main */ import com.sun.source.tree.AssignmentTree; import com.sun.source.tree.CompilationUnitTree; import com.sun.source.util.JavacTask; import com.sun.source.util.TreePath; import com.sun.source.util.TreePathScanner; import com.sun.source.util.Trees; import com.sun.tools.javac.util.List; import java.io.IOException; import java.net.URI; import javax.lang.model.type.TypeKind; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; import javax.tools.SimpleJavaFileObject; import javax.tools.ToolProvider; public class Main { static class MyFileObject extends SimpleJavaFileObject { public MyFileObject() { super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); } public CharSequence getCharContent(boolean ignoreEncodingErrors) { return "public class Test { { x = java.util.Collections.emptySet(); } }"; } } static Trees trees; public static void main(String[] args) throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); JavacTask task = (JavacTask) compiler.getTask(null, null, null, null, null, List.of(new MyFileObject())); trees = Trees.instance(task); Iterable<? extends CompilationUnitTree> asts = task.parse(); task.analyze(); for (CompilationUnitTree ast : asts) { new MyVisitor().scan(ast, null); } } static class MyVisitor extends TreePathScanner<Void,Void> { @Override public Void visitAssignment(AssignmentTree node, Void ignored) { TreePath path = TreePath.getPath(getCurrentPath(), node.getExpression()); if (trees.getTypeMirror(path).getKind() == TypeKind.ERROR) throw new AssertionError(path.getLeaf()); return null; } } }
3,059
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6415780.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6415780/T6415780.java
/* * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6415780 * @summary JSR 199: javax.tools.JavaFileManager.getClassLoader always fails * @author igor.tseytin@... * @author Peter von der Ah\u00e9 * @library ../lib */ import static javax.tools.StandardLocation.CLASS_PATH; public class T6415780 extends ToolTester { void test() { System.out.println(fm.getClassLoader(CLASS_PATH).toString()); // null-check } public static void main(String... args) { T6415780 tester = new T6415780(); tester.test(); } }
1,582
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6418694.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6418694/T6418694.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6418694 * @summary JSR 199: JavaFileManager.hasLocation(Location) * @author Peter von der Ah\u00e9 * @library ../lib * @compile T6418694.java * @run main T6418694 */ import javax.tools.StandardLocation; public class T6418694 extends ToolTester { void test(String... args) { for (StandardLocation loc : StandardLocation.values()) { switch (loc) { case CLASS_PATH: case SOURCE_PATH: case CLASS_OUTPUT: case PLATFORM_CLASS_PATH: if (!fm.hasLocation(loc)) throw new AssertionError("Missing location " + loc); break; default: if (fm.hasLocation(loc)) throw new AssertionError("Extra location " + loc); break; } } } public static void main(String... args) { new T6418694().test(args); } }
1,996
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6437349.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6437349/T6437349.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6437349 * @summary JSR 199: JavaFileObject.isNameCompatible() will give true with some incompatible kinds * @library ../lib * @compile T6437349.java * @run main T6437349 */ import java.io.IOException; import javax.tools.*; import static javax.tools.StandardLocation.*; import static javax.tools.JavaFileObject.Kind.*; public class T6437349 extends ToolTester { void test(String... args) throws IOException { task = tool.getTask(null, fm, null, null, null, null); JavaFileObject fo = fm.getJavaFileForInput(SOURCE_PATH, "T6437349", SOURCE); if (fo.isNameCompatible("T6437349.java", OTHER)) throw new AssertionError(); if (!fo.isNameCompatible("T6437349", SOURCE)) throw new AssertionError(); fo = fm.getJavaFileForInput(PLATFORM_CLASS_PATH, "java.lang.Object", CLASS); if (fo.isNameCompatible("Object.class", OTHER)) throw new AssertionError(); if (!fo.isNameCompatible("Object", CLASS)) throw new AssertionError(); } public static void main(String... args) throws IOException { new T6437349().test(args); } }
2,220
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6431435.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6431435/T6431435.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6431435 6439406 * @summary Tree API: source files loaded implicitly from source path * @run main T6431435 */ import java.io.*; import java.util.*; import javax.tools.*; import com.sun.source.util.*; import com.sun.tools.javac.api.*; public class T6431435 { public static void main(String... args) throws IOException { String testSrc = System.getProperty("test.src", "."); String testClasses = System.getProperty("test.classes", "."); JavacTool tool = JavacTool.create(); StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File("."))); fm.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(new File(testSrc))); Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList( new File(testSrc, "A.java"))); JavacTask task = tool.getTask(null, fm, null, null, null, files); boolean ok = true; ok &= check("parse", task.parse(), 1); // A.java ok &= check("analyze", task.analyze(), 3); // A, Foo, p.B ok &= check("generate", task.generate(), 5); // A, Foo, Foo$Baz, Foo$1, p.B if (!ok) throw new AssertionError("Test failed"); } private static boolean check(String name, Iterable<?> iter, int expect) { int found = 0; for (Object o: iter) { found++; //System.err.println(name + " " + found + " " + o); } if (found == expect) return true; System.err.println(name + ": found " + found + " -- expected " + expect); return false; } }
2,763
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
A.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6431435/A.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import p.*; class A { } class Foo { class Baz { } Runnable r = new Runnable() { public void run() { } }; B b; }
1,179
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
B.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6431435/p/B.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package p; public class B { }
1,082
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6731573.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6731573/T6731573.java
/* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6731573 * @summary diagnostic output should optionally include source line * @author Maurizio Cimadamore * @library ../lib */ import java.io.*; import java.util.*; import javax.tools.*; public class T6731573 extends ToolTester { enum DiagnosticType { BASIC(null) { boolean shouldDisplaySource(SourceLine sourceLine) { return sourceLine != SourceLine.DISABLED; } }, RAW("-XDrawDiagnostics") { boolean shouldDisplaySource(SourceLine sourceLine) { return sourceLine == SourceLine.ENABLED; } }; String optValue; DiagnosticType(String optValue) { this.optValue = optValue; } abstract boolean shouldDisplaySource(SourceLine sourceLine); } enum SourceLine { STANDARD(null), ENABLED("-XDshowSource=true"), DISABLED("-XDshowSource=false"); String optValue; SourceLine(String optValue) { this.optValue = optValue; } } void checkErrorLine(String output, boolean expected, List<String> options) { System.err.println("\noptions = "+options); System.err.println(output); boolean errLinePresent = output.contains("^"); if (errLinePresent != expected) { throw new AssertionError("Error in diagnostic: error line" + (expected ? "" : " not") + " expected but" + (errLinePresent ? "" : " not") + " found"); } } void exec(DiagnosticType diagType, SourceLine sourceLine) { final Iterable<? extends JavaFileObject> compilationUnits = fm.getJavaFileObjects(new File(test_src, "Erroneous.java")); StringWriter pw = new StringWriter(); ArrayList<String> options = new ArrayList<String>(); if (diagType.optValue != null) options.add(diagType.optValue); if (sourceLine.optValue != null) options.add(sourceLine.optValue); task = tool.getTask(pw, fm, null, options, null, compilationUnits); task.call(); checkErrorLine(pw.toString(), diagType.shouldDisplaySource(sourceLine), options); } void test() { for (DiagnosticType dt : DiagnosticType.values()) { for (SourceLine sl : SourceLine.values()) { exec(dt, sl); } } } public static void main(String... args) throws Exception { new T6731573().test(); } }
3,627
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6423003.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/api/6423003/T6423003.java
/* * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6423003 * @summary JSR 199: confusing help message with compiler API * @author Peter von der Ah\u00e9 * @library ../lib * @compile T6423003.java * @run main T6423003 */ import java.util.Arrays; public class T6423003 extends ToolTester { void test(String... args) { task = tool.getTask(null, fm, null, Arrays.asList("-Xlint:all"), null, null); try { task.call(); } catch (IllegalStateException ex) { return; } throw new AssertionError("Expected IllegalStateException not thrown"); } public static void main(String... args) { new T6423003().test(args); } }
1,728
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CheckExamples.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/CheckExamples.java
/* * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6968063 7127924 * @summary provide examples of code that generate diagnostics * @build Example CheckExamples * @run main/othervm CheckExamples */ /* * See CR 7127924 for info on why othervm is used. */ import java.io.*; import java.util.*; /** * Check invariants for a set of examples. * -- each example should exactly declare the keys that will be generated when * it is run. * -- together, the examples should cover the set of resource keys in the * compiler.properties bundle. A list of exceptions may be given in the * not-yet.txt file. Entries on the not-yet.txt list should not be * covered by examples. * When new keys are added to the resource bundle, it is strongly recommended * that corresponding new examples be added here, if at all practical, instead * of simply and lazily being added to the not-yet.txt list. */ public class CheckExamples { /** * Standard entry point. */ public static void main(String... args) throws Exception { new CheckExamples().run(); } /** * Run the test. */ void run() throws Exception { Set<Example> examples = getExamples(); Set<String> notYetList = getNotYetList(); Set<String> declaredKeys = new TreeSet<String>(); for (Example e: examples) { Set<String> e_decl = e.getDeclaredKeys(); Set<String> e_actual = e.getActualKeys(); for (String k: e_decl) { if (!e_actual.contains(k)) error("Example " + e + " declares key " + k + " but does not generate it"); } for (String k: e_actual) { if (!e_decl.contains(k)) error("Example " + e + " generates key " + k + " but does not declare it"); } for (String k: e.getDeclaredKeys()) { if (notYetList.contains(k)) error("Example " + e + " declares key " + k + " which is also on the \"not yet\" list"); declaredKeys.add(k); } } ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources.compiler"); Set<String> resourceKeys = new TreeSet<String>(b.keySet()); for (String dk: declaredKeys) { if (!resourceKeys.contains(dk)) error("Key " + dk + " is declared in tests but is not a valid key in resource bundle"); } for (String nk: notYetList) { if (!resourceKeys.contains(nk)) error("Key " + nk + " is declared in not-yet list but is not a valid key in resource bundle"); } for (String rk: resourceKeys) { if (!declaredKeys.contains(rk) && !notYetList.contains(rk)) error("Key " + rk + " is declared in resource bundle but is not in tests or not-yet list"); } System.err.println(examples.size() + " examples checked"); System.err.println(notYetList.size() + " keys on not-yet list"); Counts declaredCounts = new Counts(declaredKeys); Counts resourceCounts = new Counts(resourceKeys); List<String> rows = new ArrayList<String>(Arrays.asList(Counts.prefixes)); rows.add("other"); rows.add("total"); System.err.println(); System.err.println(String.format("%-14s %15s %15s %4s", "prefix", "#keys in tests", "#keys in javac", "%")); for (String p: rows) { int d = declaredCounts.get(p); int r = resourceCounts.get(p); System.err.print(String.format("%-14s %15d %15d", p, d, r)); if (r != 0) System.err.print(String.format(" %3d%%", (d * 100) / r)); System.err.println(); } if (errors > 0) throw new Exception(errors + " errors occurred."); } /** * Get the complete set of examples to be checked. */ Set<Example> getExamples() { Set<Example> results = new TreeSet<Example>(); File testSrc = new File(System.getProperty("test.src")); File examples = new File(testSrc, "examples"); for (File f: examples.listFiles()) { if (isValidExample(f)) results.add(new Example(f)); } return results; } boolean isValidExample(File f) { return (f.isDirectory() && f.list().length > 0) || (f.isFile() && f.getName().endsWith(".java")); } /** * Get the contents of the "not-yet" list. */ Set<String> getNotYetList() { Set<String> results = new TreeSet<String>(); File testSrc = new File(System.getProperty("test.src")); File notYetList = new File(testSrc, "examples.not-yet.txt"); try { String[] lines = read(notYetList).split("[\r\n]"); for (String line: lines) { int hash = line.indexOf("#"); if (hash != -1) line = line.substring(0, hash).trim(); if (line.matches("[A-Za-z0-9-_.]+")) results.add(line); } } catch (IOException e) { throw new Error(e); } return results; } /** * Read the contents of a file. */ String read(File f) throws IOException { byte[] bytes = new byte[(int) f.length()]; DataInputStream in = new DataInputStream(new FileInputStream(f)); try { in.readFully(bytes); } finally { in.close(); } return new String(bytes); } /** * Report an error. */ void error(String msg) { System.err.println("Error: " + msg); errors++; } int errors; static class Counts { static String[] prefixes = { "compiler.err.", "compiler.warn.", "compiler.note.", "compiler.misc." }; Counts(Set<String> keys) { nextKey: for (String k: keys) { for (String p: prefixes) { if (k.startsWith(p)) { inc(p); continue nextKey; } } inc("other"); } table.put("total", keys.size()); } int get(String p) { Integer i = table.get(p); return (i == null ? 0 : i); } void inc(String p) { Integer i = table.get(p); table.put(p, (i == null ? 1 : i + 1)); } Map<String,Integer> table = new HashMap<String,Integer>(); }; }
7,728
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FileManager.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/FileManager.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Pattern; import javax.lang.model.element.Modifier; import javax.lang.model.element.NestingKind; import javax.tools.JavaFileManager.Location; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import com.sun.tools.javac.api.WrappingJavaFileManager; /** * A JavaFileManager that can throw IOException on attempting to read or write * selected files that match a regular expression. */ public class FileManager extends WrappingJavaFileManager<StandardJavaFileManager> implements StandardJavaFileManager { private static final String CANT_READ = "cantRead:"; private static final String CANT_WRITE = "cantWrite:"; private Pattern cantRead; private Pattern cantWrite; public FileManager(StandardJavaFileManager fm, List<String> opts) { super(fm); for (String opt: opts) { if (opt.startsWith(CANT_READ)) cantRead = Pattern.compile(opt.substring(CANT_READ.length())); else if (opt.startsWith(CANT_WRITE)) cantWrite = Pattern.compile(opt.substring(CANT_WRITE.length())); else throw new IllegalArgumentException(opt); } } @Override protected JavaFileObject wrap(JavaFileObject fo) { return new WrappedFileObject(fo); } @Override protected JavaFileObject unwrap(JavaFileObject fo) { if (fo instanceof WrappedFileObject) return ((WrappedFileObject) fo).delegate; else return fo; } public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(Iterable<? extends File> files) { return wrap2(fileManager.getJavaFileObjectsFromFiles(files)); } public Iterable<? extends JavaFileObject> getJavaFileObjects(File... files) { return wrap2(fileManager.getJavaFileObjects(files)); } public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(Iterable<String> names) { return wrap2(fileManager.getJavaFileObjectsFromStrings(names)); } public Iterable<? extends JavaFileObject> getJavaFileObjects(String... names) { return wrap2(fileManager.getJavaFileObjects(names)); } /* This method is regrettably necessary because WrappingJavaFileManager.wrap takes * Iterable<JavaFileObject> fileObjects * instead of * Iterable<? extends JavaFileObject> fileObjects */ protected Iterable<JavaFileObject> wrap2(Iterable<? extends JavaFileObject> fileObjects) { List<JavaFileObject> mapped = new ArrayList<JavaFileObject>(); for (JavaFileObject fileObject : fileObjects) mapped.add(wrap(fileObject)); return Collections.unmodifiableList(mapped); } public void setLocation(Location location, Iterable<? extends File> path) throws IOException { fileManager.setLocation(location, path); } public Iterable<? extends File> getLocation(Location location) { return fileManager.getLocation(location); } class WrappedFileObject implements JavaFileObject { WrappedFileObject(JavaFileObject fileObject) { delegate = fileObject; } public Kind getKind() { return delegate.getKind(); } public boolean isNameCompatible(String simpleName, Kind kind) { return delegate.isNameCompatible(simpleName, kind); } public NestingKind getNestingKind() { return delegate.getNestingKind(); } public Modifier getAccessLevel() { return delegate.getAccessLevel(); } public URI toUri() { return delegate.toUri(); } public String getName() { return delegate.getName(); } public InputStream openInputStream() throws IOException { checkRead(); return delegate.openInputStream(); } public OutputStream openOutputStream() throws IOException { checkWrite(); return delegate.openOutputStream(); } public Reader openReader(boolean ignoreEncodingErrors) throws IOException { checkRead(); return delegate.openReader(ignoreEncodingErrors); } public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { checkRead(); return delegate.getCharContent(ignoreEncodingErrors); } public Writer openWriter() throws IOException { checkWrite(); return delegate.openWriter(); } public long getLastModified() { return delegate.getLastModified(); } public boolean delete() { return delegate.delete(); } void checkRead() throws IOException { String canonName = getName().replace(File.separatorChar, '/'); if (cantRead != null && cantRead.matcher(canonName).matches()) throw new IOException("FileManager: Can't read"); } void checkWrite() throws IOException { String canonName = getName().replace(File.separatorChar, '/'); if (cantWrite != null && cantWrite.matcher(canonName).matches()) throw new IOException("FileManager: Can't write"); } JavaFileObject delegate; } }
6,694
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CheckResourceKeys.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/CheckResourceKeys.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6964768 6964461 6964469 6964487 6964460 6964481 6980021 * @summary need test program to validate javac resource bundles */ import java.io.*; import java.util.*; import javax.tools.*; import com.sun.tools.classfile.*; /** * Compare string constants in javac classes against keys in javac resource bundles. */ public class CheckResourceKeys { /** * Main program. * Options: * -finddeadkeys * look for keys in resource bundles that are no longer required * -findmissingkeys * look for keys in resource bundles that are missing * * @throws Exception if invoked by jtreg and errors occur */ public static void main(String... args) throws Exception { CheckResourceKeys c = new CheckResourceKeys(); if (c.run(args)) return; if (is_jtreg()) throw new Exception(c.errors + " errors occurred"); else System.exit(1); } static boolean is_jtreg() { return (System.getProperty("test.src") != null); } /** * Main entry point. */ boolean run(String... args) throws Exception { boolean findDeadKeys = false; boolean findMissingKeys = false; if (args.length == 0) { if (is_jtreg()) { findDeadKeys = true; findMissingKeys = true; } else { System.err.println("Usage: java CheckResourceKeys <options>"); System.err.println("where options include"); System.err.println(" -finddeadkeys find keys in resource bundles which are no longer required"); System.err.println(" -findmissingkeys find keys in resource bundles that are required but missing"); return true; } } else { for (String arg: args) { if (arg.equalsIgnoreCase("-finddeadkeys")) findDeadKeys = true; else if (arg.equalsIgnoreCase("-findmissingkeys")) findMissingKeys = true; else error("bad option: " + arg); } } if (errors > 0) return false; Set<String> codeStrings = getCodeStrings(); Set<String> resourceKeys = getResourceKeys(); if (findDeadKeys) findDeadKeys(codeStrings, resourceKeys); if (findMissingKeys) findMissingKeys(codeStrings, resourceKeys); return (errors == 0); } /** * Find keys in resource bundles which are probably no longer required. * A key is probably required if there is a string fragment in the code * that is part of the resource key, or if the key is well-known * according to various pragmatic rules. */ void findDeadKeys(Set<String> codeStrings, Set<String> resourceKeys) { String[] prefixes = { "compiler.err.", "compiler.warn.", "compiler.note.", "compiler.misc.", "javac." }; for (String rk: resourceKeys) { // some keys are used directly, without a prefix. if (codeStrings.contains(rk)) continue; // remove standard prefix String s = null; for (int i = 0; i < prefixes.length && s == null; i++) { if (rk.startsWith(prefixes[i])) { s = rk.substring(prefixes[i].length()); } } if (s == null) { error("Resource key does not start with a standard prefix: " + rk); continue; } if (codeStrings.contains(s)) continue; // keys ending in .1 are often synthesized if (s.endsWith(".1") && codeStrings.contains(s.substring(0, s.length() - 2))) continue; // verbose keys are generated by ClassReader.printVerbose if (s.startsWith("verbose.") && codeStrings.contains(s.substring(8))) continue; // mandatory warning messages are synthesized with no characteristic substring if (isMandatoryWarningString(s)) continue; // check known (valid) exceptions if (knownRequired.contains(rk)) continue; // check known suspects if (needToInvestigate.contains(rk)) continue; error("Resource key not found in code: " + rk); } } /** * The keys for mandatory warning messages are all synthesized and do not * have a significant recognizable substring to look for. */ private boolean isMandatoryWarningString(String s) { String[] bases = { "deprecated", "unchecked", "varargs", "sunapi" }; String[] tails = { ".filename", ".filename.additional", ".plural", ".plural.additional", ".recompile" }; for (String b: bases) { if (s.startsWith(b)) { String tail = s.substring(b.length()); for (String t: tails) { if (tail.equals(t)) return true; } } } return false; } Set<String> knownRequired = new TreeSet<String>(Arrays.asList( // See Resolve.getErrorKey "compiler.err.cant.resolve.args", "compiler.err.cant.resolve.args.params", "compiler.err.cant.resolve.location.args", "compiler.err.cant.resolve.location.args.params", // JavaCompiler, reports #errors and #warnings "compiler.misc.count.error", "compiler.misc.count.error.plural", "compiler.misc.count.warn", "compiler.misc.count.warn.plural", // Used for LintCategory "compiler.warn.lintOption", // Other "compiler.misc.base.membership" // (sic) )); Set<String> needToInvestigate = new TreeSet<String>(Arrays.asList( "compiler.err.cant.read.file", // UNUSED "compiler.err.illegal.self.ref", // UNUSED "compiler.err.io.exception", // UNUSED "compiler.err.limit.pool.in.class", // UNUSED "compiler.err.name.reserved.for.internal.use", // UNUSED "compiler.err.no.match.entry", // UNUSED "compiler.err.not.within.bounds.explain", // UNUSED "compiler.err.signature.doesnt.match.intf", // UNUSED "compiler.err.signature.doesnt.match.supertype", // UNUSED "compiler.err.type.var.more.than.once", // UNUSED "compiler.err.type.var.more.than.once.in.result", // UNUSED "compiler.misc.ccf.found.later.version", // UNUSED "compiler.misc.non.denotable.type", // UNUSED "compiler.misc.unnamed.package", // should be required, CR 6964147 "compiler.misc.verbose.retro", // UNUSED "compiler.misc.verbose.retro.with", // UNUSED "compiler.misc.verbose.retro.with.list", // UNUSED "compiler.warn.proc.type.already.exists", // TODO in JavacFiler "javac.err.invalid.arg", // UNUSED ?? "javac.opt.arg.class", // UNUSED ?? "javac.opt.arg.pathname", // UNUSED ?? "javac.opt.moreinfo", // option commented out "javac.opt.nogj", // UNUSED "javac.opt.printflat", // option commented out "javac.opt.printsearch", // option commented out "javac.opt.prompt", // option commented out "javac.opt.retrofit", // UNUSED "javac.opt.s", // option commented out "javac.opt.scramble", // option commented out "javac.opt.scrambleall" // option commented out )); /** * For all strings in the code that look like they might be fragments of * a resource key, verify that a key exists. */ void findMissingKeys(Set<String> codeStrings, Set<String> resourceKeys) { for (String cs: codeStrings) { if (cs.matches("[A-Za-z][^.]*\\..*")) { // ignore filenames (i.e. in SourceFile attribute if (cs.matches(".*\\.java")) continue; // ignore package and class names if (cs.matches("(com|java|javax|sun)\\.[A-Za-z.]+")) continue; // explicit known exceptions if (noResourceRequired.contains(cs)) continue; // look for matching resource if (hasMatch(resourceKeys, cs)) continue; error("no match for \"" + cs + "\""); } } } // where private Set<String> noResourceRequired = new HashSet<String>(Arrays.asList( // system properties "application.home", // in Paths.java "env.class.path", "line.separator", "user.dir", // file names "ct.sym", "rt.jar", "tools.jar", // -XD option names "process.packages", "ignore.symbol.file", // prefix/embedded strings "compiler.", "compiler.misc.", "count.", "illegal.", "javac.", "verbose." )); /** * Look for a resource that ends in this string fragment. */ boolean hasMatch(Set<String> resourceKeys, String s) { for (String rk: resourceKeys) { if (rk.endsWith(s)) return true; } return false; } /** * Get the set of strings from (most of) the javac classfiles. */ Set<String> getCodeStrings() throws IOException { Set<String> results = new TreeSet<String>(); JavaCompiler c = ToolProvider.getSystemJavaCompiler(); JavaFileManager fm = c.getStandardFileManager(null, null, null); JavaFileManager.Location javacLoc = findJavacLocation(fm); String[] pkgs = { "javax.annotation.processing", "javax.lang.model", "javax.tools", "com.sun.source", "com.sun.tools.javac" }; for (String pkg: pkgs) { for (JavaFileObject fo: fm.list(javacLoc, pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) { String name = fo.getName(); // ignore resource files, and files which are not really part of javac if (name.contains("resources") || name.contains("Launcher.class") || name.contains("CreateSymbols.class")) continue; scan(fo, results); } } return results; } // depending on how the test is run, javac may be on bootclasspath or classpath JavaFileManager.Location findJavacLocation(JavaFileManager fm) { JavaFileManager.Location[] locns = { StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH }; try { for (JavaFileManager.Location l: locns) { JavaFileObject fo = fm.getJavaFileForInput(l, "com.sun.tools.javac.Main", JavaFileObject.Kind.CLASS); if (fo != null) return l; } } catch (IOException e) { throw new Error(e); } throw new IllegalStateException("Cannot find javac"); } /** * Get the set of strings from a class file. * Only strings that look like they might be a resource key are returned. */ void scan(JavaFileObject fo, Set<String> results) throws IOException { InputStream in = fo.openInputStream(); try { ClassFile cf = ClassFile.read(in); for (ConstantPool.CPInfo cpinfo: cf.constant_pool.entries()) { if (cpinfo.getTag() == ConstantPool.CONSTANT_Utf8) { String v = ((ConstantPool.CONSTANT_Utf8_info) cpinfo).value; if (v.matches("[A-Za-z0-9-_.]+")) results.add(v); } } } catch (ConstantPoolException ignore) { } finally { in.close(); } } /** * Get the set of keys from the javac resource bundles. */ Set<String> getResourceKeys() { Set<String> results = new TreeSet<String>(); for (String name : new String[]{"javac", "compiler"}) { ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources." + name); results.addAll(b.keySet()); } return results; } /** * Report an error. */ void error(String msg) { System.err.println("Error: " + msg); errors++; } int errors; }
14,446
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
HTMLWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/HTMLWriter.java
/* * Copyright (c) 1996,2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import java.io.Writer; import java.net.URL; import java.text.MessageFormat; import java.util.ResourceBundle; /** * A class to facilitate writing HTML via a stream. */ public class HTMLWriter { /** * Create an HTMLWriter object, using a default doctype for HTML 3.2. * @param out a Writer to which to write the generated HTML * @throws IOException if there is a problem writing to the underlying stream */ public HTMLWriter(Writer out) throws IOException { this(out, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"); } /** * Create an HTMLWriter object, using a specifed doctype header. * @param out a Writer to which to write the generated HTML * @param docType a string containing a doctype header for the HTML to be generetaed * @throws IOException if there is a problem writing to the underlying stream */ public HTMLWriter(Writer out, String docType) throws IOException { if (out instanceof BufferedWriter) this.out = (BufferedWriter) out; else this.out = new BufferedWriter(out); this.out.write(docType); this.out.newLine(); } /** * Create an HTMLWriter object, using a specified bundle for localizing messages. * @param out a Writer to which to write the generated HTML * @param i18n a resource bundle to use to localize messages * @throws IOException if there is a problem writing to the underlying stream */ public HTMLWriter(Writer out, ResourceBundle i18n) throws IOException { this(out); this.i18n = i18n; } /** * Create an HTMLWriter object, using a specifed doctype header and * using a specified bundle for l0calizing messages. * @param out a Writer to which to write the generated HTML * @param docType a string containing a doctype header for the HTML to be generetaed * @param i18n a resource bundle to use to localize messages * @throws IOException if there is a problem writing to the underlying stream */ public HTMLWriter(Writer out, String docType, ResourceBundle i18n) throws IOException { this(out, docType); this.i18n = i18n; } /** * Set the reource bundle to be used for localizing messages. * @param i18n the resource bundle to be used for localizing messages */ public void setResourceBundle(ResourceBundle i18n) { this.i18n = i18n; } /** * Flush the stream, and the underlying output stream. * @throws IOException if there is a problem writing to the underlying stream */ public void flush() throws IOException { out.flush(); } /** * Close the stream, and the underlying output stream. * @throws IOException if there is a problem closing the underlying stream */ public void close() throws IOException { out.close(); } /** * Write a newline to the underlying output stream. * @throws IOException if there is a problem writing to the underlying stream */ public void newLine() throws IOException { out.newLine(); } /** * Start an HTML tag. If a prior tag has been started, it will * be closed first. Once a tag has been opened, attributes for the * tag may be written out, followed by body content before finally * ending the tag. * @param tag the tag to be started * @throws IOException if there is a problem writing to the underlying stream * @see #writeAttr * @see #write * @see #endTag */ public void startTag(String tag) throws IOException { if (state == IN_TAG) { out.write(">"); state = IN_BODY; } //newLine(); out.write("<"); out.write(tag); state = IN_TAG; } /** * Finish an HTML tag. It is expected that a call to endTag will match * a corresponding earlier call to startTag, but there is no formal check * for this. * @param tag the tag to be closed. * @throws IOException if there is a problem writing to the underlying stream */ public void endTag(String tag) throws IOException { if (state == IN_TAG) { out.write(">"); state = IN_BODY; out.newLine(); } out.write("</"); out.write(tag); out.write(">"); //out.newLine(); // PATCHED, jjg state = IN_BODY; } /** * Finish an empty element tag, such as a META, BASE or LINK tag. * This is expected to correspond with a startTag. * @param tag the tag which is being closed. this is only useful for * validation, it is not written out * @throws IllegalStateException if this call does not follow startTag * (stream is not currently inside a tag) * @throws IOException if there is a problem writing to the underlying stream */ public void endEmptyTag(String tag) throws IOException { if (state != IN_TAG) throw new IllegalStateException(); out.write(">"); state = IN_BODY; out.newLine(); } /** * Write an attribute for a tag. A tag must previously have been started. * All tag attributes must be written before any body text is written. * The value will be quoted if necessary when writing it to the underlying * stream. No check is made that the attribute is valid for the current tag. * @param name the name of the attribute to be written * @param value the value of the attribute to be written * @throws IllegalStateException if the stream is not in a state to * write attributes -- e.g. if this call does not follow startTag or other * calls of writteAttr * @throws IOException if there is a problem writing to the underlying stream */ public void writeAttr(String name, String value) throws IOException { if (state != IN_TAG) throw new IllegalStateException(); out.write(" "); out.write(name); out.write("="); boolean alpha = true; for (int i = 0; i < value.length() && alpha; i++) alpha = Character.isLetter(value.charAt(i)); if (!alpha) out.write("\""); out.write(value); if (!alpha) out.write("\""); } /** * Write an attribute for a tag. A tag must previously have been started. * All tag attributes must be written before any body text is written. * The value will be quoted if necessary when writing it to the underlying * stream. No check is made that the attribute is valid for the current tag. * @param name the name of the attribute to be written * @param value the value of the attribute to be written * @throws IllegalStateException if the stream is not in a state to * write attributes -- e.g. if this call does not follow startTag or other * calls of writteAttr * @throws IOException if there is a problem writing to the underlying stream */ public void writeAttr(String name, int value) throws IOException { writeAttr(name, Integer.toString(value)); } /** * Write a line of text, followed by a newline. * The text will be escaped as necessary. * @param text the text to be written. * @throws IOException if there is a problem closing the underlying stream */ public void writeLine(String text) throws IOException { write(text); out.newLine(); } /** * Write body text, escaping it as necessary. * If this call follows a call of startTag, the open tag will be * closed -- meaning that no more attributes can be written until another * tag is started. If the text value is null, the current tag will still * be closed, but no other text will be written. * @param text the text to be written, may be null or zero length. * @throws IOException if there is a problem writing to the underlying stream */ public void write(String text) throws IOException { if (state == IN_TAG) { out.write(">"); state = IN_BODY; } if (text == null) return; // check to see if there are any special characters boolean specialChars = false; for (int i = 0; i < text.length() && !specialChars; i++) { switch (text.charAt(i)) { case '<': case '>': case '&': specialChars = true; } } // if there are special characters write the string character at a time; // otherwise, write it out as is if (specialChars) { for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); switch (c) { case '<': out.write("&lt;"); break; case '>': out.write("&gt;"); break; case '&': out.write("&amp;"); break; default: out.write(c); } } } else out.write(text); } /** * Write a basic HTML entity, such as &nbsp; or &#123; . * @param entity the entity to write * @throws IOException if there is a problem writing to the underlying stream */ public void writeEntity(String entity) throws IOException { if (state == IN_TAG) { out.write(">"); state = IN_BODY; } out.write(entity); } /** * Write an image tag, using a specified path for the image source attribute. * @param imagePath the path for the image source * @throws IOException if there is a problem closing the underlying stream */ public void writeImage(String imagePath) throws IOException { startTag(IMAGE); writeAttr(SRC, imagePath); } /** * Write an image tag, using a specified path for the image source attribute. * @param imageURL the url for the image source * @throws IOException if there is a problem closing the underlying stream */ public void writeImage(URL imageURL) throws IOException { writeImage(imageURL.toString()); } /** * Write a hypertext link. * @param anchor the target for the link * @param body the body text for the link * @throws IOException if there is a problem closing the underlying stream */ public void writeLink(String anchor, String body) throws IOException { startTag(A); writeAttr(HREF, anchor); write(body); endTag(A); } /** * Write a hypertext link. * @param file the target for the link * @param body the body text for the link * @throws IOException if there is a problem closing the underlying stream */ public void writeLink(File file, String body) throws IOException { startTag(A); StringBuffer sb = new StringBuffer(); String path = file.getPath().replace(File.separatorChar, '/'); if (file.isAbsolute() && !path.startsWith("/")) sb.append('/'); sb.append(path); writeAttr(HREF, sb.toString()); write(body); endTag(A); } /** * Write a hypertext link. * @param file the target and body for the link * @throws IOException if there is a problem closing the underlying stream */ public void writeLink(File file) throws IOException { writeLink(file, file.getPath()); } /** * Write a hypertext link. * @param url the target for the link * @param body the body text for the link * @throws IOException if there is a problem closing the underlying stream */ public void writeLink(URL url, String body) throws IOException { startTag(A); writeAttr(HREF, url.toString()); write(body); endTag(A); } /** * Write the destination marker for a hypertext link. * @param anchor the destination marker for hypertext links * @param body the body text for the marker * @throws IOException if there is a problem closing the underlying stream */ public void writeLinkDestination(String anchor, String body) throws IOException { startTag(A); writeAttr(NAME, anchor); write(body); endTag(A); } /** * Write a parameter tag. * @param name the name of the parameter * @param value the value of the parameter * @throws IOException if there is a problem closing the underlying stream */ public void writeParam(String name, String value) throws IOException { startTag(PARAM); writeAttr(NAME, name); writeAttr(VALUE, value); } /** * Write a style attribute. * @param value the value for the style atrtribute * @throws IOException if there is a problem closing the underlying stream */ public void writeStyleAttr(String value) throws IOException { writeAttr(STYLE, value); } /** * Write a localized message, using a specified resource bundle. * @param i18n the resource bundle used to localize the message * @param key the key for the message to be localized * @throws IOException if there is a problem closing the underlying stream */ public void write(ResourceBundle i18n, String key) throws IOException { write(getString(i18n, key)); } /** * Write a localized message, using a specified resource bundle. * @param i18n the resource bundle used to localize the message * @param key the key for the message to be localized * @param arg an argument to be formatted into the localized message * @throws IOException if there is a problem closing the underlying stream */ public void write(ResourceBundle i18n, String key, Object arg) throws IOException { write(getString(i18n, key, arg)); } /** * Write a localized message, using a specified resource bundle. * @param i18n the resource bundle used to localize the message * @param key the key for the message to be localized * @param args arguments to be formatted into the localized message * @throws IOException if there is a problem closing the underlying stream */ public void write(ResourceBundle i18n, String key, Object[] args) throws IOException { write(getString(i18n, key, args)); } /** * Write a localized message, using the default resource bundle. * @param key the key for the message to be localized * @throws IOException if there is a problem closing the underlying stream */ public void writeI18N(String key) throws IOException { write(getString(i18n, key)); } /** * Write a localized message, using the default resource bundle. * @param key the key for the message to be localized * @param arg an argument to be formatted into the localized message * @throws IOException if there is a problem closing the underlying stream */ public void writeI18N(String key, Object arg) throws IOException { write(getString(i18n, key, arg)); } /** * Write a localized message, using the default resource bundle. * @param key the key for the message to be localized * @param args arguments to be formatted into the localized message * @throws IOException if there is a problem closing the underlying stream */ public void writeI18N(String key, Object[] args) throws IOException { write(getString(i18n, key, args)); } private String getString(ResourceBundle rb, String key, Object... args) { String s = rb.getString(key); return MessageFormat.format(s, args); } /** The HTML "a" tag. */ public static final String A = "a"; /** The HTML "align" attribute. */ public static final String ALIGN = "align"; /** The HTML "b" tag. */ public static final String B = "b"; /** The HTML "body" tag. */ public static final String BODY = "body"; /** The HTML "border" attribute. */ public static final String BORDER = "border"; /** The HTML "br" tag. */ public static final String BR = "br"; /** The HTML "class" attribute. */ public static final String CLASS = "class"; /** The HTML "classid" attribute. */ public static final String CLASSID = "classid"; /** The HTML "code" tag. */ public static final String CODE = "code"; /** The HTML "color" attribte. */ public static final String COLOR = "color"; /** The HTML "col" attribute value. */ public static final String COL = "col"; /** The HTML "dd" tag. */ public static final String DD = "dd"; /** The HTML "div" tag. */ public static final String DIV = "div"; /** The HTML "dl" tag. */ public static final String DL = "dl"; /** The HTML "dt" tag. */ public static final String DT = "dt"; /** The HTML "font" tag. */ public static final String FONT = "font"; /** The HTML "h1" tag. */ public static final String H1 = "h1"; /** The HTML "h2" tag. */ public static final String H2 = "h2"; /** The HTML "h3" tag. */ public static final String H3 = "h3"; /** The HTML "h4" tag. */ public static final String H4 = "h4"; /** The HTML "h5" tag. */ public static final String H5 = "h5"; /** The HTML "head" tag. */ public static final String HEAD = "head"; /** The HTML "href" attribute. */ public static final String HREF = "href"; /** The HTML "html" tag. */ public static final String HTML = "html"; /** The HTML "hr" tag. */ public static final String HR = "hr"; /** The HTML "i" tag. */ public static final String I = "i"; /** The HTML "id" tag. */ public static final String ID = "id"; /** The HTML "image" tag. */ public static final String IMAGE = "image"; /** The HTML "left" attribute value. */ public static final String LEFT = "left"; /** The HTML "li" tag. */ public static final String LI = "li"; /** The HTML "link" tag. */ public static final String LINK = "link"; /** The HTML "name" attribute. */ public static final String NAME = "name"; /** The HTML "object" tag. */ public static final String OBJECT = "object"; /** The HTML "p" tag. */ public static final String PARAM = "param"; /** The HTML "param" tag. */ public static final String P = "p"; /** The HTML "rel" attribute value. */ public static final String REL = "rel"; /** The HTML "right" attribute value. */ public static final String RIGHT = "right"; /** The HTML "row" attribute value. */ public static final String ROW = "row"; /** The HTML "script" tag. */ public static final String SCRIPT = "script"; /** The HTML "small" tag. */ public static final String SMALL = "small"; /** The HTML "span" tag. */ public static final String SPAN = "span"; /** The HTML "src" attribute. */ public static final String SRC = "src"; /** The HTML "scope" attribute. */ public static final String SCOPE = "scope"; /** The HTML "style" attribute. */ public static final String STYLE = "style"; /** The HTML "table" tag. */ public static final String TABLE = "table"; /** The HTML "td" tag. */ public static final String TD = "td"; /** The HTML type for JavaScript. */ public static final String TEXT_JAVASCRIPT = "text/javascript"; /** The HTML "title"attribute. */ public static final String TITLE = "title"; /** The HTML "th" tag. */ public static final String TH = "th"; /** The HTML "top" attribute value. */ public static final String TOP = "top"; /** The HTML "tr" tag. */ public static final String TR = "tr"; /** The HTML "type" attribute. */ public static final String TYPE = "type"; /** The HTML "ul" tag. */ public static final String UL = "ul"; /** The HTML "valign" attribute. */ public static final String VALIGN = "valign"; /** The HTML "value" attribute. */ public static final String VALUE = "value"; private BufferedWriter out; private int state; private ResourceBundle i18n; private static final int IN_TAG = 1; private static final int IN_BODY = 2; }
21,495
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RunExamples.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/RunExamples.java
/* * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * @test * @bug 6968063 7127924 * @summary provide examples of code that generate diagnostics * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples * @run main/othervm RunExamples */ /* * See CR 7127924 for info on why othervm is used. */ import java.io.*; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Utility to run selected or all examples, writing results to * stdout, a plain text file or an HTML file. This program can be * run standalone, or as a jtreg test. * * Options: * -examples dir directory of examples. Defaults to ${test.src}/examples * -raw run examples with -XDrawDiagnostics * -showFiles include text of source files in the output * -verbose verbose output * -o file write output to file: format will be HTML if * file has .html extension; otherwise it will be plain text. * default is to stdout * -title string specify a title, only applies to HTML output */ public class RunExamples { public static void main(String... args) throws Exception { jtreg = (System.getProperty("test.src") != null); File tmpDir; if (jtreg) { // use standard jtreg scratch directory: the current directory tmpDir = new File(System.getProperty("user.dir")); } else { tmpDir = new File(System.getProperty("java.io.tmpdir"), RunExamples.class.getName() + (new SimpleDateFormat("yyMMddHHmmss")).format(new Date())); } Example.setTempDir(tmpDir); RunExamples r = new RunExamples(); try { if (r.run(args)) return; } finally { /* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the * jtreg scratch directory, which is the current directory. * In case someone is faking jtreg mode, make sure to only * clean tmpDir when it is reasonable to do so. */ if (tmpDir.isDirectory() && tmpDir.getName().startsWith(RunExamples.class.getName())) { if (clean(tmpDir)) tmpDir.delete(); } } if (jtreg) throw new Exception(r.errors + " errors occurred"); else System.exit(1); } boolean run(String... args) { Set<String> selectedKeys = new TreeSet<String>(); Set<Example> selectedExamples = new TreeSet<Example>(); File testSrc = new File(System.getProperty("test.src", ".")); File examplesDir = new File(testSrc, "examples"); File outFile = null; boolean raw = false; boolean showFiles = false; boolean verbose = false; boolean argTypes = false; String title = null; for (int i = 0; i < args.length; i++) { String arg = args[i]; if (arg.equals("-k") && (i + 1) < args.length) selectedKeys.add(args[++i]); else if (arg.equals("-examples") && (i + 1) < args.length) examplesDir = new File(args[++i]); else if (arg.equals("-raw")) raw = true; else if (arg.equals("-showFiles")) showFiles = true; else if (arg.equals("-verbose")) verbose = true; else if (arg.equals("-o") && (i + 1) < args.length) outFile = new File(args[++i]); else if (arg.equals("-title") && (i + 1) < args.length) title = args[++i]; else if (arg.equals("-argtypes")) argTypes = true; else if (arg.startsWith("-")) { error("unknown option: " + arg); return false; } else { while (i < args.length) { File f = new File(examplesDir, args[i]); selectedExamples.add(new Example(f)); i++; } } } // special mode to show message keys and the types of the args that // are used. if (argTypes) Example.Compiler.factory = new ArgTypeCompilerFactory(); if (selectedKeys.size() > 0) { Set<Example> examples = getExamples(examplesDir); nextKey: for (String k: selectedKeys) { for (Example e: examples) { if (e.getDeclaredKeys().contains(k)) continue nextKey; } error("Key " + k + ": no examples found"); } } else { if (selectedExamples.isEmpty()) selectedExamples = getExamples(examplesDir); } try { Runner r; if (outFile == null) { PrintWriter out = new PrintWriter(System.out); r = new TextRunner(out, showFiles, raw, verbose); } else if (outFile.getName().endsWith(".html")) r = new HTMLRunner(outFile, showFiles, raw, verbose, title); else r = new TextRunner(outFile, showFiles, raw, verbose); r.run(selectedExamples); r.close(); } catch (IOException e) { error("Error writing output: " + e); } return (errors == 0); } /** * Get the complete set of examples to be checked. */ Set<Example> getExamples(File examplesDir) { Set<Example> results = new TreeSet<Example>(); for (File f: examplesDir.listFiles()) { if (isValidExample(f)) results.add(new Example(f)); } return results; } boolean isValidExample(File f) { return (f.isDirectory() && (!jtreg || f.list().length > 0)) || (f.isFile() && f.getName().endsWith(".java")); } /** * Report an error. */ void error(String msg) { System.err.println("Error: " + msg); errors++; } static boolean jtreg; int errors; /** * Clean the contents of a directory. */ static boolean clean(File dir) { boolean ok = true; for (File f: dir.listFiles()) { if (f.isDirectory()) ok &= clean(f); ok &= f.delete(); } return ok; } static abstract class Runner { Runner(boolean showFiles, boolean raw, boolean verbose) { this.showFiles = showFiles; this.raw = raw; this.verbose = verbose; } void close() throws IOException { } void run(Collection<Example> examples) throws IOException { for (Example e: examples) { startExample(e); if (showFiles) { showFile(e, e.infoFile); Set<File> srcFiles = new TreeSet<File>(e.srcFiles); srcFiles.remove(e.infoFile); showFiles(e, srcFiles); showFiles(e, e.srcPathFiles); showFiles(e, e.procFiles); showFiles(e, e.supportFiles); } run(e); } } void showFiles(Example e, Collection<File> files) throws IOException { for (File f: files) showFile(e, f); } abstract void startExample(Example e) throws IOException; abstract void showFile(Example e, File f) throws IOException; abstract void run(Example e) throws IOException; protected String read(File f) throws IOException { byte[] bytes = new byte[(int) f.length()]; DataInputStream in = new DataInputStream(new FileInputStream(f)); try { in.readFully(bytes); } finally { in.close(); } return new String(bytes); } protected Pattern copyrightHeaderPat = Pattern.compile("(?s)(/\\*.*?Copyright.*?\\*/\n)\\s*(.*)"); protected Pattern infoHeaderPat = Pattern.compile("(?s)((?://\\s*[a-z]+:[^\n]*\n)+)\\s*(.*)"); protected boolean showFiles; protected boolean raw; protected boolean verbose; } static class TextRunner extends Runner { TextRunner(File file, boolean showFiles, boolean raw, boolean verbose) throws IOException { super(showFiles, raw, verbose); this.file = file; out = new PrintWriter(new FileWriter(file)); } TextRunner(PrintWriter out, boolean showFiles, boolean raw, boolean verbose) throws IOException { super(showFiles, raw, verbose); this.out = out; } @Override void close() { if (file != null) out.close(); } @Override void startExample(Example e) { out.println("----- " + e.getName() + " --------------------"); out.println(); } @Override void showFile(Example e, File f) { out.println("--- " + f); String text; try { text = read(f); } catch (IOException ex) { text = "Error reading " + f + "; " + ex; } Matcher m = copyrightHeaderPat.matcher(text); if (m.matches()) { out.println("(Copyright)"); writeLines(m.group(2)); } else { writeLines(text); } out.println(); } @Override void run(Example e) { // only show Output: header if also showing files if (showFiles) out.println("--- Output:"); e.run(out, raw, verbose); out.println(); } void writeLines(String text) { for (String line: text.split("\n")) out.println(line); } File file; PrintWriter out; } static class HTMLRunner extends Runner { HTMLRunner(File file, boolean showFiles, boolean raw, boolean verbose, String title) throws IOException { super(showFiles, raw, verbose); this.file = file; PrintWriter out = new PrintWriter(new FileWriter(file)); html = new HTMLWriter(out); html.startTag(HTMLWriter.HEAD); if (title != null) { html.startTag(HTMLWriter.TITLE); html.write(title); html.endTag(HTMLWriter.TITLE); } html.startTag(HTMLWriter.STYLE); html.newLine(); html.writeLine("div.file { background-color:#e0ffe0; margin-left:30px; margin-right:30px;\n" + " padding: 3px; border: thin solid silver; }"); html.writeLine("p.file { white-space: pre-wrap; font-family:monospace; margin: 0; }"); html.writeLine("div.output { background-color:#e0e0ff; margin-left:30px; margin-right:30px;\n" + " padding: 3px; border: thin solid silver; }"); html.writeLine("p.output { white-space: pre-wrap; font-family:monospace; margin: 0; }"); html.writeLine("table.index { border: thin solid silver; }"); html.writeLine(".copyright { font-size: x-small }"); html.writeLine(".hidden { display:none }"); html.writeLine(".unhidden { display:block }"); html.writeLine(".odd { background-color: #e0e0e0 }"); html.writeLine(".even { background-color: white }"); html.endTag(HTMLWriter.STYLE); html.startTag(HTMLWriter.SCRIPT); html.writeAttr(HTMLWriter.TYPE, HTMLWriter.TEXT_JAVASCRIPT); html.writeLine("\nfunction unhide(id) {\n" + " var item = document.getElementById(id);\n" + " if (item) {\n" + " item.className=(item.className=='hidden')?'unhidden':'hidden';\n" + " }\n" + "}"); html.endTag(HTMLWriter.SCRIPT); html.endTag(HTMLWriter.HEAD); html.startTag(HTMLWriter.BODY); if (title != null) { html.startTag(TITLE_HEADER); html.write(title); html.endTag(TITLE_HEADER); } } @Override void close() throws IOException { html.endTag(HTMLWriter.BODY); html.newLine(); html.flush(); } @Override void run(Collection<Example> examples) throws IOException { if (examples.size() > 1) writeIndex(examples); super.run(examples); } void writeIndex(Collection<Example> examples) throws IOException { Map<String, Set<Example>> index = new TreeMap<String, Set<Example>>(); Set<String> initials = new HashSet<String>(); for (Example e: examples) { for (String k: e.getDeclaredKeys()) { Set<Example> s = index.get(k); if (s == null) index.put(k, s = new TreeSet<Example>()); s.add(e); } initials.add(e.getName().substring(0, 1).toUpperCase()); } if (INDEX_HEADER != null) { html.startTag(INDEX_HEADER); html.write("Index"); html.endTag(INDEX_HEADER); } html.startTag(HTMLWriter.P); html.writeLine("Examples: "); for (char initial = 'A'; initial <= 'Z'; initial++) { String s = String.valueOf(initial); if (initials.contains(s)) { html.writeLink("#" + s, s); } else { html.write(s); } html.newLine(); } html.endTag(HTMLWriter.P); html.startTag(HTMLWriter.TABLE); html.writeAttr(HTMLWriter.CLASS, "index"); html.newLine(); int row = 0; for (Map.Entry<String, Set<Example>> entry: index.entrySet()) { html.startTag(HTMLWriter.TR); html.writeAttr(HTMLWriter.CLASS, (row++ % 2 == 0 ? "even" : "odd")); html.startTag(HTMLWriter.TD); html.writeAttr("valign", "top"); html.write(entry.getKey()); html.endTag(HTMLWriter.TD); html.newLine(); html.startTag(HTMLWriter.TD); html.writeAttr(HTMLWriter.ALIGN, "top"); String sep = ""; for (Example e: entry.getValue()) { html.write(sep); html.writeLink('#' + e.getName(), e.getName()); sep = ", "; } html.endTag(HTMLWriter.TD); html.endTag(HTMLWriter.TR); html.newLine(); } html.endTag(HTMLWriter.TABLE); } @Override void startExample(Example e) throws IOException { String name = e.getName(); String initial = name.substring(0, 1).toUpperCase(); if (!initial.equals(currInitial)) { html.writeLinkDestination(initial, ""); currInitial = initial; } html.writeLinkDestination(name, ""); html.startTag(EXAMPLE_HEADER); html.write(e.getName()); html.endTag(EXAMPLE_HEADER); } @Override void showFile(Example e, File f) throws IOException { String text; try { text = read(f); } catch (IOException ex) { text = "Error reading " + f + ": " + ex; } if (!f.equals(e.file)) { html.startTag(FILE_HEADER); html.write(e.file.toURI().relativize(f.toURI()).toString()); html.endTag(FILE_HEADER); } html.startTag(HTMLWriter.DIV); html.writeAttr(CLASS, FILE); String legalHeader; Matcher m1 = copyrightHeaderPat.matcher(text); if (m1.matches()) { legalHeader = m1.group(1); text = m1.group(2); } else legalHeader = null; String infoHeader; Matcher m2 = infoHeaderPat.matcher(text); if (m2.matches()) { infoHeader = m2.group(1); text = m2.group(2); } else infoHeader = null; String legalId = null, infoId = null; if (legalHeader != null || infoHeader != null) { String sep = ""; html.startTag(HTMLWriter.SPAN); html.writeStyleAttr("float: right"); if (legalHeader != null) { legalId = nextId(); html.startTag(HTMLWriter.A); html.writeAttr(HTMLWriter.HREF, "javascript:unhide('" + legalId + "');"); //html.writeEntity("&copy;"); html.write("Copyright"); html.endTag(HTMLWriter.A); sep = ", "; } if (infoHeader != null) { html.write(sep); infoId = nextId(); html.startTag(HTMLWriter.A); html.writeAttr(HTMLWriter.HREF, "javascript:unhide('" + infoId + "');"); html.write("Info"); html.endTag(HTMLWriter.A); sep = ", "; } html.endTag(HTMLWriter.SPAN); } html.startTag(HTMLWriter.P); html.writeAttr(CLASS, FILE); if (legalHeader != null) { html.startTag(HTMLWriter.SPAN); html.writeAttr(HTMLWriter.CLASS, "hidden"); html.writeAttr(HTMLWriter.ID, legalId); html.write(legalHeader); html.newLine(); html.endTag(HTMLWriter.SPAN); } if (infoHeader != null) { html.startTag(HTMLWriter.SPAN); html.writeAttr(HTMLWriter.CLASS, "hidden"); html.writeAttr(HTMLWriter.ID, infoId); html.write(infoHeader); html.newLine(); html.endTag(HTMLWriter.SPAN); } html.write(text); html.endTag(HTMLWriter.P); html.endTag(HTMLWriter.DIV); } @Override void run(Example e) throws IOException { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.run(pw, raw, verbose); pw.flush(); // only show Output: header if also showing files if (showFiles) { html.startTag(OUTPUT_HEADER); html.write("Output:"); html.endTag(OUTPUT_HEADER); } html.startTag(HTMLWriter.DIV); html.writeAttr(CLASS, OUTPUT); html.startTag(HTMLWriter.P); html.writeAttr(CLASS, OUTPUT); String[] lines = sw.toString().split("\n"); for (String line: lines) { html.write(line); html.newLine(); } html.endTag(HTMLWriter.P); html.endTag(HTMLWriter.DIV); } String nextId() { return "id" + (nextId++); } File file; HTMLWriter html; int nextId; String currInitial = ""; static final String TITLE_HEADER = HTMLWriter.H3; static final String INDEX_HEADER = HTMLWriter.H4; static final String EXAMPLE_HEADER = HTMLWriter.H4; static final String FILE_HEADER = HTMLWriter.H5; static final String OUTPUT_HEADER = HTMLWriter.H5; static final String CLASS = "class"; static final String FILE = "file"; static final String OUTPUT = "output"; } }
21,477
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ArgTypeCompilerFactory.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/ArgTypeCompilerFactory.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.*; import java.util.*; import java.util.List; import javax.tools.*; import com.sun.tools.javac.api.*; import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart; import com.sun.tools.javac.api.Formattable.LocalizedString; import com.sun.tools.javac.code.Flags.Flag; import com.sun.tools.javac.code.Kinds.KindName; import com.sun.tools.javac.code.*; import com.sun.tools.javac.file.*; import com.sun.tools.javac.main.Main; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.parser.Token; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration; import javax.lang.model.SourceVersion; /** * Compiler factory for instances of Example.Compiler that use custom * DiagnosticFormatter and Messages objects to track the types of args * when when localizing diagnostics. * The compiler objects only support "output" mode, not "check" mode. */ class ArgTypeCompilerFactory implements Example.Compiler.Factory { // Same code as Example.Compiler.DefaultFactory, but the names resolve differently public Example.Compiler getCompiler(List<String> opts, boolean verbose) { String first; String[] rest; if (opts == null || opts.isEmpty()) { first = null; rest = new String[0]; } else { first = opts.get(0); rest = opts.subList(1, opts.size()).toArray(new String[opts.size() - 1]); } if (first == null || first.equals("jsr199")) return new Jsr199Compiler(verbose, rest); else if (first.equals("simple")) return new SimpleCompiler(verbose); else if (first.equals("backdoor")) return new BackdoorCompiler(verbose); else throw new IllegalArgumentException(first); } /** * Compile using the JSR 199 API. The diagnostics generated are * scanned for resource keys. Not all diagnostic keys are generated * via the JSR 199 API -- for example, rich diagnostics are not directly * accessible, and some diagnostics generated by the file manager may * not be generated (for example, the JSR 199 file manager does not see * -Xlint:path). */ static class Jsr199Compiler extends Example.Compiler { List<String> fmOpts; Jsr199Compiler(boolean verbose, String... args) { super(verbose); for (int i = 0; i < args.length; i++) { String arg = args[i]; if (arg.equals("-filemanager") && (i + 1 < args.length)) { fmOpts = Arrays.asList(args[++i].split(",")); } else throw new IllegalArgumentException(arg); } } @Override boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) { assert out != null && keys == null; if (verbose) System.err.println("run_jsr199: " + opts + " " + files); JavacTool tool = JavacTool.create(); StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); if (fmOpts != null) fm = new FileManager(fm, fmOpts); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos); Context c = t.getContext(); ArgTypeMessages.preRegister(c); ArgTypeJavaCompiler.preRegister(c); Boolean ok = t.call(); return ok; } } /** * Run the test using the standard simple entry point. */ static class SimpleCompiler extends Example.Compiler { SimpleCompiler(boolean verbose) { super(verbose); } @Override boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) { assert out != null && keys == null; if (verbose) System.err.println("run_simple: " + opts + " " + files); List<String> args = new ArrayList<String>(); args.addAll(opts); for (File f: files) args.add(f.getPath()); Main main = new Main("javac", out); Context c = new Context() { @Override public void clear() { ((JavacFileManager) get(JavaFileManager.class)).close(); super.clear(); } }; JavacFileManager.preRegister(c); // can't create it until Log has been set up ArgTypeJavaCompiler.preRegister(c); ArgTypeMessages.preRegister(c); int result = main.compile(args.toArray(new String[args.size()]), c); return (result == 0); } } static class BackdoorCompiler extends Example.Compiler { BackdoorCompiler(boolean verbose) { super(verbose); } @Override boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) { assert out != null && keys == null; if (verbose) System.err.println("run_simple: " + opts + " " + files); List<String> args = new ArrayList<String>(opts); for (File f: files) args.add(f.getPath()); Context c = new Context(); JavacFileManager.preRegister(c); // can't create it until Log has been set up ArgTypeJavaCompiler.preRegister(c); ArgTypeMessages.preRegister(c); com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out); int rc = m.compile(args.toArray(new String[args.size()]), c); return (rc == 0); } } // <editor-fold defaultstate="collapsed" desc="Custom Javac components"> /** * Diagnostic formatter which reports formats a diag as a series of lines * containing a key, and a possibly empty set of descriptive strings for the * arg types. */ static class ArgTypeDiagnosticFormatter extends AbstractDiagnosticFormatter { ArgTypeDiagnosticFormatter(Options options) { super(null, new SimpleConfiguration(options, EnumSet.of(DiagnosticPart.SUMMARY, DiagnosticPart.DETAILS, DiagnosticPart.SUBDIAGNOSTICS))); } @Override protected String formatDiagnostic(JCDiagnostic d, Locale locale) { return formatMessage(d, locale); } @Override public String formatMessage(JCDiagnostic d, Locale l) { StringBuilder buf = new StringBuilder(); formatMessage(d, buf); return buf.toString(); } private void formatMessage(JCDiagnostic d, StringBuilder buf) { String key = d.getCode(); Object[] args = d.getArgs(); // report the primary arg types, without recursing into diag fragments buf.append(getKeyArgsString(key, args)); // report details for any diagnostic fragments for (Object arg: args) { if (arg instanceof JCDiagnostic) { buf.append("\n"); formatMessage((JCDiagnostic) arg, buf); } } // report details for any subdiagnostics for (String s: formatSubdiagnostics(d, null)) { buf.append("\n"); buf.append(s); } } @Override public boolean isRaw() { return true; } } /** * Trivial subtype of JavaCompiler to get access to the protected compilerKey field. * The factory is used to ensure that the log is initialized with an instance of * ArgTypeDiagnosticFormatter before we create the required JavaCompiler. */ static class ArgTypeJavaCompiler extends JavaCompiler { static void preRegister(Context context) { context.put(compilerKey, new Context.Factory<JavaCompiler>() { public JavaCompiler make(Context c) { Log log = Log.instance(c); Options options = Options.instance(c); log.setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options)); return new JavaCompiler(c); } }); } // not used private ArgTypeJavaCompiler() { super(null); } } /** * Diagnostic formatter which "localizes" a message as a line * containing a key, and a possibly empty set of descriptive strings for the * arg types. */ static class ArgTypeMessages extends JavacMessages { static void preRegister(Context context) { context.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() { public JavacMessages make(Context c) { return new ArgTypeMessages(c) { @Override public String getLocalizedString(Locale l, String key, Object... args) { return getKeyArgsString(key, args); } }; } }); } ArgTypeMessages(Context context) { super(context); } } /** * Utility method to generate a string for key and args */ static String getKeyArgsString(String key, Object... args) { StringBuilder buf = new StringBuilder(); buf.append(key); String sep = ": "; for (Object o : args) { buf.append(sep); buf.append(getArgTypeOrStringValue(o)); sep = ", "; } return buf.toString(); } static boolean showStringValues = false; static String getArgTypeOrStringValue(Object o) { if (showStringValues && o instanceof String) return "\"" + o + "\""; return getArgType(o); } static String getArgType(Object o) { if (o == null) return "null"; if (o instanceof Name) return "name"; if (o instanceof Boolean) return "boolean"; if (o instanceof Integer) return "number"; if (o instanceof String) return "string"; if (o instanceof Flag) return "modifier"; if (o instanceof KindName) return "symbol kind"; if (o instanceof Token) return "token"; if (o instanceof Symbol) return "symbol"; if (o instanceof Type) return "type"; if (o instanceof List) { List<?> l = (List<?>) o; if (l.isEmpty()) return "list"; else return "list of " + getArgType(l.get(0)); } if (o instanceof ListBuffer) return getArgType(((ListBuffer) o).toList()); if (o instanceof Set) { Set<?> s = (Set<?>) o; if (s.isEmpty()) return "set"; else return "set of " + getArgType(s.iterator().next()); } if (o instanceof SourceVersion) return "source version"; if (o instanceof FileObject || o instanceof File) return "file name"; if (o instanceof JCDiagnostic) return "message segment"; if (o instanceof LocalizedString) return "message segment"; // only instance is "no arguments" String s = o.getClass().getSimpleName(); return (s.isEmpty() ? o.getClass().getName() : s); } // </editor-fold> }
12,901
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Example.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/Example.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.*; import java.net.URL; import java.net.URLClassLoader; import java.util.*; import java.util.regex.*; import javax.annotation.processing.Processor; import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; import javax.tools.JavaCompiler.CompilationTask; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; // The following two classes are both used, but cannot be imported directly // import com.sun.tools.javac.Main // import com.sun.tools.javac.main.Main import com.sun.tools.javac.api.ClientCodeWrapper; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.JCDiagnostic; /** * Class to handle example code designed to illustrate javac diagnostic messages. */ class Example implements Comparable<Example> { /* Create an Example from the files found at path. * The head of the file, up to the first Java code, is scanned * for information about the test, such as what resource keys it * generates when run, what options are required to run it, and so on. */ Example(File file) { this.file = file; declaredKeys = new TreeSet<String>(); srcFiles = new ArrayList<File>(); procFiles = new ArrayList<File>(); supportFiles = new ArrayList<File>(); srcPathFiles = new ArrayList<File>(); findFiles(file, srcFiles); for (File f: srcFiles) { parse(f); } if (infoFile == null) throw new Error("Example " + file + " has no info file"); } private void findFiles(File f, List<File> files) { if (f.isDirectory()) { for (File c: f.listFiles()) { if (files == srcFiles && c.getName().equals("processors")) findFiles(c, procFiles); else if (files == srcFiles && c.getName().equals("sourcepath")) { srcPathDir = c; findFiles(c, srcPathFiles); } else if (files == srcFiles && c.getName().equals("support")) findFiles(c, supportFiles); else findFiles(c, files); } } else if (f.isFile() && f.getName().endsWith(".java")) { files.add(f); } } private void parse(File f) { Pattern keyPat = Pattern.compile(" *// *key: *([^ ]+) *"); Pattern optPat = Pattern.compile(" *// *options: *(.*)"); Pattern runPat = Pattern.compile(" *// *run: *(.*)"); Pattern javaPat = Pattern.compile(" *@?[A-Za-z].*"); try { String[] lines = read(f).split("[\r\n]+"); for (String line: lines) { Matcher keyMatch = keyPat.matcher(line); if (keyMatch.matches()) { foundInfo(f); declaredKeys.add(keyMatch.group(1)); continue; } Matcher optMatch = optPat.matcher(line); if (optMatch.matches()) { foundInfo(f); options = Arrays.asList(optMatch.group(1).trim().split(" +")); continue; } Matcher runMatch = runPat.matcher(line); if (runMatch.matches()) { foundInfo(f); runOpts = Arrays.asList(runMatch.group(1).trim().split(" +")); } if (javaPat.matcher(line).matches()) break; } } catch (IOException e) { throw new Error(e); } } private void foundInfo(File file) { if (infoFile != null && !infoFile.equals(file)) throw new Error("multiple info files found: " + infoFile + ", " + file); infoFile = file; } String getName() { return file.getName(); } /** * Get the set of resource keys that this test declares it will generate * when it is run. */ Set<String> getDeclaredKeys() { return declaredKeys; } /** * Get the set of resource keys that this test generates when it is run. * The test will be run if it has not already been run. */ Set<String> getActualKeys() { if (actualKeys == null) actualKeys = run(false); return actualKeys; } /** * Run the test. Information in the test header is used to determine * how to run the test. */ void run(PrintWriter out, boolean raw, boolean verbose) { if (out == null) throw new NullPointerException(); try { run(out, null, raw, verbose); } catch (IOException e) { e.printStackTrace(out); } } Set<String> run(boolean verbose) { Set<String> keys = new TreeSet<String>(); try { run(null, keys, true, verbose); } catch (IOException e) { e.printStackTrace(System.err); } return keys; } /** * Run the test. Information in the test header is used to determine * how to run the test. */ private void run(PrintWriter out, Set<String> keys, boolean raw, boolean verbose) throws IOException { ClassLoader loader = getClass().getClassLoader(); if (supportFiles.size() > 0) { File supportDir = new File(tempDir, "support"); supportDir.mkdirs(); clean(supportDir); List<String> sOpts = Arrays.asList("-d", supportDir.getPath()); new Jsr199Compiler(verbose).run(null, null, false, sOpts, procFiles); URLClassLoader ucl = new URLClassLoader(new URL[] { supportDir.toURI().toURL() }, loader); loader = ucl; } File classesDir = new File(tempDir, "classes"); classesDir.mkdirs(); clean(classesDir); List<String> opts = new ArrayList<String>(); opts.add("-d"); opts.add(classesDir.getPath()); if (options != null) opts.addAll(options); if (procFiles.size() > 0) { List<String> pOpts = Arrays.asList("-d", classesDir.getPath()); new Jsr199Compiler(verbose).run(null, null, false, pOpts, procFiles); opts.add("-classpath"); // avoid using -processorpath for now opts.add(classesDir.getPath()); createAnnotationServicesFile(classesDir, procFiles); } if (srcPathDir != null) { opts.add("-sourcepath"); opts.add(srcPathDir.getPath()); } try { Compiler c = Compiler.getCompiler(runOpts, verbose); c.run(out, keys, raw, opts, srcFiles); } catch (IllegalArgumentException e) { if (out != null) { out.println("Invalid value for run tag: " + runOpts); } } } void createAnnotationServicesFile(File dir, List<File> procFiles) throws IOException { File servicesDir = new File(new File(dir, "META-INF"), "services"); servicesDir.mkdirs(); File annoServices = new File(servicesDir, Processor.class.getName()); Writer out = new FileWriter(annoServices); try { for (File f: procFiles) { out.write(f.getName().toString().replace(".java", "")); } } finally { out.close(); } } @Override public int compareTo(Example e) { return file.compareTo(e.file); } @Override public String toString() { return file.getPath(); } /** * Read the contents of a file. */ private String read(File f) throws IOException { byte[] bytes = new byte[(int) f.length()]; DataInputStream in = new DataInputStream(new FileInputStream(f)); try { in.readFully(bytes); } finally { in.close(); } return new String(bytes); } /** * Clean the contents of a directory. */ boolean clean(File dir) { boolean ok = true; for (File f: dir.listFiles()) { if (f.isDirectory()) ok &= clean(f); ok &= f.delete(); } return ok; } File file; List<File> srcFiles; List<File> procFiles; File srcPathDir; List<File> srcPathFiles; List<File> supportFiles; File infoFile; private List<String> runOpts; private List<String> options; private Set<String> actualKeys; private Set<String> declaredKeys; static File tempDir = new File(System.getProperty("java.io.tmpdir")); static void setTempDir(File tempDir) { Example.tempDir = tempDir; } abstract static class Compiler { interface Factory { Compiler getCompiler(List<String> opts, boolean verbose); } static class DefaultFactory implements Factory { public Compiler getCompiler(List<String> opts, boolean verbose) { String first; String[] rest; if (opts == null || opts.isEmpty()) { first = null; rest = new String[0]; } else { first = opts.get(0); rest = opts.subList(1, opts.size()).toArray(new String[opts.size() - 1]); } if (first == null || first.equals("jsr199")) return new Jsr199Compiler(verbose, rest); else if (first.equals("simple")) return new SimpleCompiler(verbose); else if (first.equals("backdoor")) return new BackdoorCompiler(verbose); else throw new IllegalArgumentException(first); } } static Factory factory; static Compiler getCompiler(List<String> opts, boolean verbose) { if (factory == null) factory = new DefaultFactory(); return factory.getCompiler(opts, verbose); } protected Compiler(boolean verbose) { this.verbose = verbose; } abstract boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files); void setSupportClassLoader(ClassLoader cl) { loader = cl; } protected ClassLoader loader; protected boolean verbose; } /** * Compile using the JSR 199 API. The diagnostics generated are * scanned for resource keys. Not all diagnostic keys are generated * via the JSR 199 API -- for example, rich diagnostics are not directly * accessible, and some diagnostics generated by the file manager may * not be generated (for example, the JSR 199 file manager does not see * -Xlint:path). */ static class Jsr199Compiler extends Compiler { List<String> fmOpts; Jsr199Compiler(boolean verbose, String... args) { super(verbose); for (int i = 0; i < args.length; i++) { String arg = args[i]; if (arg.equals("-filemanager") && (i + 1 < args.length)) { fmOpts = Arrays.asList(args[++i].split(",")); } else throw new IllegalArgumentException(arg); } } @Override boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) { if (out != null && keys != null) throw new IllegalArgumentException(); if (verbose) System.err.println("run_jsr199: " + opts + " " + files); DiagnosticCollector<JavaFileObject> dc = null; if (keys != null) dc = new DiagnosticCollector<JavaFileObject>(); if (raw) { List<String> newOpts = new ArrayList<String>(); newOpts.add("-XDrawDiagnostics"); newOpts.addAll(opts); opts = newOpts; } JavaCompiler c = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = c.getStandardFileManager(dc, null, null); if (fmOpts != null) fm = new FileManager(fm, fmOpts); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); CompilationTask t = c.getTask(out, fm, dc, opts, null, fos); Boolean ok = t.call(); if (keys != null) { for (Diagnostic<? extends JavaFileObject> d: dc.getDiagnostics()) { scanForKeys(unwrap(d), keys); } } return ok; } /** * Scan a diagnostic for resource keys. This will not detect additional * sub diagnostics that might be generated by a rich diagnostic formatter. */ private static void scanForKeys(JCDiagnostic d, Set<String> keys) { keys.add(d.getCode()); for (Object o: d.getArgs()) { if (o instanceof JCDiagnostic) { scanForKeys((JCDiagnostic) o, keys); } } for (JCDiagnostic sd: d.getSubdiagnostics()) scanForKeys(sd, keys); } private JCDiagnostic unwrap(Diagnostic<? extends JavaFileObject> diagnostic) { if (diagnostic instanceof JCDiagnostic) return (JCDiagnostic) diagnostic; if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper) return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d; throw new IllegalArgumentException(); } } /** * Run the test using the standard simple entry point. */ static class SimpleCompiler extends Compiler { SimpleCompiler(boolean verbose) { super(verbose); } @Override boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) { if (out != null && keys != null) throw new IllegalArgumentException(); if (verbose) System.err.println("run_simple: " + opts + " " + files); List<String> args = new ArrayList<String>(); if (keys != null || raw) args.add("-XDrawDiagnostics"); args.addAll(opts); for (File f: files) args.add(f.getPath()); StringWriter sw = null; PrintWriter pw; if (keys != null) { sw = new StringWriter(); pw = new PrintWriter(sw); } else pw = out; int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw); if (keys != null) { pw.close(); scanForKeys(sw.toString(), keys); } return (rc == 0); } private static void scanForKeys(String text, Set<String> keys) { StringTokenizer st = new StringTokenizer(text, " ,\r\n():"); while (st.hasMoreElements()) { String t = st.nextToken(); if (t.startsWith("compiler.")) keys.add(t); } } } static class BackdoorCompiler extends Compiler { BackdoorCompiler(boolean verbose) { super(verbose); } @Override boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) { if (out != null && keys != null) throw new IllegalArgumentException(); if (verbose) System.err.println("run_simple: " + opts + " " + files); List<String> args = new ArrayList<String>(); if (out != null && raw) args.add("-XDrawDiagnostics"); args.addAll(opts); for (File f: files) args.add(f.getPath()); StringWriter sw = null; PrintWriter pw; if (keys != null) { sw = new StringWriter(); pw = new PrintWriter(sw); } else pw = out; Context c = new Context(); JavacFileManager.preRegister(c); // can't create it until Log has been set up MessageTracker.preRegister(c, keys); com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", pw); int rc = m.compile(args.toArray(new String[args.size()]), c); if (keys != null) { pw.close(); } return (rc == 0); } static class MessageTracker extends JavacMessages { MessageTracker(Context context) { super(context); } static void preRegister(Context c, final Set<String> keys) { if (keys != null) { c.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() { public JavacMessages make(Context c) { return new MessageTracker(c) { @Override public String getLocalizedString(Locale l, String key, Object... args) { keys.add(key); return super.getLocalizedString(l, key, args); } }; } }); } } } } }
18,841
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MessageFile.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/MessageFile.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Class to facilitate manipulating compiler.properties. */ class MessageFile { static final Pattern emptyOrCommentPattern = Pattern.compile("( *#.*)?"); static final Pattern infoPattern = Pattern.compile("# ([0-9]+: [-A-Za-z ]+, )*[0-9]+: [-A-Za-z ]+"); /** * A line of text within the message file. * The lines form a doubly linked list for simple navigation. */ class Line { String text; Line prev; Line next; Line(String text) { this.text = text; } boolean isEmptyOrComment() { return emptyOrCommentPattern.matcher(text).matches(); } boolean isInfo() { return infoPattern.matcher(text).matches(); } boolean hasContinuation() { return (next != null) && text.endsWith("\\"); } Line insertAfter(String text) { Line l = new Line(text); insertAfter(l); return l; } void insertAfter(Line l) { assert prev == null && next == null; l.prev = this; l.next = next; if (next == null) lastLine = l; else next.prev = l; next = l; } Line insertBefore(String text) { Line l = new Line(text); insertBefore(l); return l; } void insertBefore(Line l) { assert prev == null && next == null; l.prev = prev; l.next = this; if (prev == null) firstLine = l; else prev.next = l; prev = l; } void remove() { if (prev == null) firstLine = next; else prev.next = next; if (next == null) lastLine = prev; else next.prev = prev; prev = null; next = null; } } /** * A message within the message file. * A message is a series of lines containing a "name=value" property, * optionally preceded by a comment describing the use of placeholders * such as {0}, {1}, etc within the property value. */ static final class Message { final Line firstLine; private Info info; Message(Line l) { firstLine = l; } boolean needInfo() { Line l = firstLine; while (true) { if (l.text.matches(".*\\{[0-9]+\\}.*")) return true; if (!l.hasContinuation()) return false; l = l.next; } } Set<Integer> getPlaceholders() { Pattern p = Pattern.compile("\\{([0-9]+)\\}"); Set<Integer> results = new TreeSet<Integer>(); Line l = firstLine; while (true) { Matcher m = p.matcher(l.text); while (m.find()) results.add(Integer.parseInt(m.group(1))); if (!l.hasContinuation()) return results; l = l.next; } } /** * Get the Info object for this message. It may be empty if there * if no comment preceding the property specification. */ Info getInfo() { if (info == null) { Line l = firstLine.prev; if (l != null && l.isInfo()) info = new Info(l.text); else info = new Info(); } return info; } /** * Set the Info for this message. * If there was an info comment preceding the property specification, * it will be updated; otherwise, one will be inserted. */ void setInfo(Info info) { this.info = info; Line l = firstLine.prev; if (l != null && l.isInfo()) l.text = info.toComment(); else firstLine.insertBefore(info.toComment()); } /** * Get all the lines pertaining to this message. */ List<Line> getLines(boolean includeAllPrecedingComments) { List<Line> lines = new ArrayList<Line>(); Line l = firstLine; if (includeAllPrecedingComments) { // scan back to find end of prev message while (l.prev != null && l.prev.isEmptyOrComment()) l = l.prev; // skip leading blank lines while (l.text.isEmpty()) l = l.next; } else { if (l.prev != null && l.prev.isInfo()) l = l.prev; } // include any preceding lines for ( ; l != firstLine; l = l.next) lines.add(l); // include message lines for (l = firstLine; l != null && l.hasContinuation(); l = l.next) lines.add(l); lines.add(l); // include trailing blank line if present l = l.next; if (l != null && l.text.isEmpty()) lines.add(l); return lines; } } /** * An object to represent the comment that may precede the property * specification in a Message. * The comment is modelled as a list of fields, where the fields correspond * to the placeholder values (e.g. {0}, {1}, etc) within the message value. */ static final class Info { /** * An ordered set of descriptions for a placeholder value in a * message. */ static class Field { boolean unused; Set<String> values; boolean listOfAny = false; boolean setOfAny = false; Field(String s) { s = s.substring(s.indexOf(": ") + 2); values = new LinkedHashSet<String>(Arrays.asList(s.split(" or "))); for (String v: values) { if (v.startsWith("list of")) listOfAny = true; if (v.startsWith("set of")) setOfAny = true; } } /** * Return true if this field logically contains all the values of * another field. */ boolean contains(Field other) { if (unused != other.unused) return false; for (String v: other.values) { if (values.contains(v)) continue; if (v.equals("null") || v.equals("string")) continue; if (v.equals("list") && listOfAny) continue; if (v.equals("set") && setOfAny) continue; return false; } return true; } /** * Merge the values of another field into this field. */ void merge(Field other) { unused |= other.unused; values.addAll(other.values); // cleanup unnecessary entries if (values.contains("null") && values.size() > 1) { // "null" is superceded by anything else values.remove("null"); } if (values.contains("string") && values.size() > 1) { // "string" is superceded by anything else values.remove("string"); } if (values.contains("list")) { // list is superceded by "list of ..." for (String s: values) { if (s.startsWith("list of ")) { values.remove("list"); break; } } } if (values.contains("set")) { // set is superceded by "set of ..." for (String s: values) { if (s.startsWith("set of ")) { values.remove("set"); break; } } } if (other.values.contains("unused")) { values.clear(); values.add("unused"); } } void markUnused() { values = new LinkedHashSet<String>(); values.add("unused"); listOfAny = false; setOfAny = false; } @Override public String toString() { return values.toString(); } } /** The fields of the Info object. */ List<Field> fields = new ArrayList<Field>(); Info() { } Info(String text) throws IllegalArgumentException { if (!text.startsWith("# ")) throw new IllegalArgumentException(); String[] segs = text.substring(2).split(", "); fields = new ArrayList<Field>(); for (String seg: segs) { fields.add(new Field(seg)); } } Info(Set<String> infos) throws IllegalArgumentException { for (String s: infos) merge(new Info(s)); } boolean isEmpty() { return fields.isEmpty(); } boolean contains(Info other) { if (other.isEmpty()) return true; if (fields.size() != other.fields.size()) return false; Iterator<Field> oIter = other.fields.iterator(); for (Field values: fields) { if (!values.contains(oIter.next())) return false; } return true; } void merge(Info other) { if (fields.isEmpty()) { fields.addAll(other.fields); return; } if (other.fields.size() != fields.size()) throw new IllegalArgumentException(); Iterator<Field> oIter = other.fields.iterator(); for (Field d: fields) { d.merge(oIter.next()); } } void markUnused(Set<Integer> used) { for (int i = 0; i < fields.size(); i++) { if (!used.contains(i)) fields.get(i).markUnused(); } } @Override public String toString() { return fields.toString(); } String toComment() { StringBuilder sb = new StringBuilder(); sb.append("# "); String sep = ""; int i = 0; for (Field f: fields) { sb.append(sep); sb.append(i++); sb.append(": "); sep = ""; for (String s: f.values) { sb.append(sep); sb.append(s); sep = " or "; } sep = ", "; } return sb.toString(); } } Line firstLine; Line lastLine; Map<String, Message> messages = new TreeMap<String, Message>(); MessageFile(File file) throws IOException { Reader in = new FileReader(file); try { read(in); } finally { in.close(); } } MessageFile(Reader in) throws IOException { read(in); } final void read(Reader in) throws IOException { BufferedReader br = (in instanceof BufferedReader) ? (BufferedReader) in : new BufferedReader(in); String line; while ((line = br.readLine()) != null) { Line l; if (firstLine == null) l = firstLine = lastLine = new Line(line); else l = lastLine.insertAfter(line); if (line.startsWith("compiler.")) { int eq = line.indexOf("="); if (eq > 0) messages.put(line.substring(0, eq), new Message(l)); } } } void write(File file) throws IOException { Writer out = new FileWriter(file); try { write(out); } finally { out.close(); } } void write(Writer out) throws IOException { BufferedWriter bw = (out instanceof BufferedWriter) ? (BufferedWriter) out : new BufferedWriter(out); for (Line l = firstLine; l != null; l = l.next) { bw.write(l.text); bw.write("\n"); // always use Unix line endings } bw.flush(); } }
14,196
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MessageInfo.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/MessageInfo.java
/* * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * @test * @bug 7013272 7127924 * @summary Automatically generate info about how compiler resource keys are used * @build Example ArgTypeCompilerFactory MessageFile MessageInfo * @run main/othervm MessageInfo */ /* * See CR 7127924 for info on why othervm is used. */ import java.io.*; import java.text.SimpleDateFormat; import java.util.*; /** * Utility to manipulate compiler.properties, and suggest info comments based * on information derived from running examples. * * Options: * -examples dir location of examples directory * -o file output file * -check just check message file * -ensureNewlines ensure newline after each entry * -fixIndent fix indentation of continuation lines * -sort sort messages * -verbose verbose output * -replace replace comments instead of merging comments * file javac compiler.properties file * */ public class MessageInfo { public static void main(String... args) throws Exception { jtreg = (System.getProperty("test.src") != null); File tmpDir; if (jtreg) { // use standard jtreg scratch directory: the current directory tmpDir = new File(System.getProperty("user.dir")); } else { tmpDir = new File(System.getProperty("java.io.tmpdir"), MessageInfo.class.getName() + (new SimpleDateFormat("yyMMddHHmmss")).format(new Date())); } Example.setTempDir(tmpDir); Example.Compiler.factory = new ArgTypeCompilerFactory(); MessageInfo mi = new MessageInfo(); try { if (mi.run(args)) return; } finally { /* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the * jtreg scratch directory, which is the current directory. * In case someone is faking jtreg mode, make sure to only * clean tmpDir when it is reasonable to do so. */ if (tmpDir.isDirectory() && tmpDir.getName().startsWith(MessageInfo.class.getName())) { if (clean(tmpDir)) tmpDir.delete(); } } if (jtreg) throw new Exception(mi.errors + " errors occurred"); else System.exit(1); } void usage() { System.out.println("Usage:"); System.out.println(" java MessageInfo [options] [file]"); System.out.println("where options include"); System.out.println(" -examples dir location of examples directory"); System.out.println(" -o file output file"); System.out.println(" -check just check message file"); System.out.println(" -ensureNewlines ensure newline after each entry"); System.out.println(" -fixIndent fix indentation of continuation lines"); System.out.println(" -sort sort messages"); System.out.println(" -verbose verbose output"); System.out.println(" -replace replace comments instead of merging comments"); System.out.println(" file javac compiler.properties file"); } boolean run(String... args) { File testSrc = new File(System.getProperty("test.src", ".")); File examplesDir = new File(testSrc, "examples"); File notYetFile = null; File msgFile = null; File outFile = null; boolean verbose = false; boolean ensureNewlines = false; boolean fixIndent = false; boolean sort = false; boolean replace = false; boolean check = jtreg; // default true in jtreg mode for (int i = 0; i < args.length; i++) { String arg = args[i]; if (arg.equals("-examples") && (i + 1) < args.length) examplesDir = new File(args[++i]); else if(arg.equals("-notyet") && (i + 1) < args.length) notYetFile = new File(args[++i]); else if (arg.equals("-ensureNewlines")) ensureNewlines = true; else if (arg.equals("-fixIndent")) fixIndent = true; else if (arg.equals("-sort")) sort = true; else if (arg.equals("-verbose")) verbose = true; else if (arg.equals("-replace")) replace = true; else if (arg.equals("-check")) check = true; else if (arg.equals("-o") && (i + 1) < args.length) outFile = new File(args[++i]); else if (arg.startsWith("-")) { error("unknown option: " + arg); return false; } else if (i == args.length - 1) { msgFile = new File(arg); } else { error("unknown arg: " + arg); return false; } } if (!check && outFile == null) { usage(); return true; } if ((ensureNewlines || fixIndent || sort) && outFile == null) { error("must set output file for these options"); return false; } if (notYetFile == null) { notYetFile = new File(examplesDir.getParentFile(), "examples.not-yet.txt"); } if (msgFile == null) { for (File d = testSrc; d != null; d = d.getParentFile()) { if (new File(d, "TEST.ROOT").exists()) { d = d.getParentFile(); File f = new File(d, "src/share/classes/com/sun/tools/javac/resources/compiler.properties"); if (f.exists()) { msgFile = f; break; } } } if (msgFile == null) { if (jtreg) { System.err.println("Warning: no message file available, test skipped"); return true; } error("no message file available"); return false; } } MessageFile mf; try { mf = new MessageFile(msgFile); } catch (IOException e) { error("problem reading message file: " + e); return false; } Map<String, Set<String>> msgInfo = runExamples(examplesDir, verbose); if (ensureNewlines) ensureNewlines(mf); if (fixIndent) fixIndent(mf); if (sort) sort(mf, true); for (Map.Entry<String, Set<String>> e: msgInfo.entrySet()) { String k = e.getKey(); Set<String> suggestions = e.getValue(); MessageFile.Message m = mf.messages.get(k); if (m == null) { error("Can't find message for " + k + " in message file"); continue; } MessageFile.Info info = m.getInfo(); Set<Integer> placeholders = m.getPlaceholders(); MessageFile.Info suggestedInfo = new MessageFile.Info(suggestions); suggestedInfo.markUnused(placeholders); if (!info.isEmpty()) { if (info.contains(suggestedInfo)) continue; if (!replace) { if (info.fields.size() != suggestedInfo.fields.size()) error("Cannot merge info for " + k); else suggestedInfo.merge(info); } } if (outFile == null) { System.err.println("suggest for " + k); System.err.println(suggestedInfo.toComment()); } else m.setInfo(suggestedInfo); } if (check) check(mf, notYetFile); try { if (outFile != null) mf.write(outFile); } catch (IOException e) { error("problem writing file: " + e); return false; } return (errors == 0); } void check(MessageFile mf, File notYetFile) { Set<String> notYetList = null; for (Map.Entry<String, MessageFile.Message> e: mf.messages.entrySet()) { String key = e.getKey(); MessageFile.Message m = e.getValue(); if (m.needInfo() && m.getInfo().isEmpty()) { if (notYetList == null) notYetList = getNotYetList(notYetFile); if (notYetList.contains(key)) System.err.println("Warning: no info for " + key); else error("no info for " + key); } } } void ensureNewlines(MessageFile mf) { for (MessageFile.Message m: mf.messages.values()) { MessageFile.Line l = m.firstLine; while (l.text.endsWith("\\")) l = l.next; if (l.next != null && !l.next.text.isEmpty()) l.insertAfter(""); } } void fixIndent(MessageFile mf) { for (MessageFile.Message m: mf.messages.values()) { MessageFile.Line l = m.firstLine; while (l.text.endsWith("\\") && l.next != null) { if (!l.next.text.matches("^ \\S.*")) l.next.text = " " + l.next.text.trim(); l = l.next; } } } void sort(MessageFile mf, boolean includePrecedingNewlines) { for (MessageFile.Message m: mf.messages.values()) { for (MessageFile.Line l: m.getLines(includePrecedingNewlines)) { l.remove(); mf.lastLine.insertAfter(l); } } } Map<String, Set<String>> runExamples(File examplesDir, boolean verbose) { Map<String, Set<String>> map = new TreeMap<String, Set<String>>(); for (Example e: getExamples(examplesDir)) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.run(pw, true, verbose); pw.close(); String[] lines = sw.toString().split("\n"); for (String line: lines) { if (!line.startsWith("compiler.")) continue; int colon = line.indexOf(":"); if (colon == -1) continue; String key = line.substring(0, colon); StringBuilder sb = new StringBuilder(); sb.append("# "); int i = 0; String[] descs = line.substring(colon + 1).split(", *"); for (String desc: descs) { if (i > 0) sb.append(", "); sb.append(i++); sb.append(": "); sb.append(desc.trim()); } Set<String> set = map.get(key); if (set == null) map.put(key, set = new TreeSet<String>()); set.add(sb.toString()); } } return map; } /** * Get the complete set of examples to be checked. */ Set<Example> getExamples(File examplesDir) { Set<Example> results = new TreeSet<Example>(); for (File f: examplesDir.listFiles()) { if (isValidExample(f)) results.add(new Example(f)); } return results; } boolean isValidExample(File f) { return (f.isDirectory() && (!jtreg || f.list().length > 0)) || (f.isFile() && f.getName().endsWith(".java")); } /** * Get the contents of the "not-yet" list. */ Set<String> getNotYetList(File file) { Set<String> results = new TreeSet<String>(); try { String[] lines = read(file).split("[\r\n]"); for (String line: lines) { int hash = line.indexOf("#"); if (hash != -1) line = line.substring(0, hash).trim(); if (line.matches("[A-Za-z0-9-_.]+")) results.add(line); } } catch (IOException e) { throw new Error(e); } return results; } /** * Read the contents of a file. */ String read(File f) throws IOException { byte[] bytes = new byte[(int) f.length()]; DataInputStream in = new DataInputStream(new FileInputStream(f)); try { in.readFully(bytes); } finally { in.close(); } return new String(bytes); } /** * Report an error. */ void error(String msg) { System.err.println("Error: " + msg); errors++; } static boolean jtreg; int errors; /** * Clean the contents of a directory. */ static boolean clean(File dir) { boolean ok = true; for (File f: dir.listFiles()) { if (f.isDirectory()) ok &= clean(f); ok &= f.delete(); } return ok; } }
14,176
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
HasBeenDeprecated.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/HasBeenDeprecated.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.has.been.deprecated // options: -Xlint:deprecation package p; class Test { DeprecatedClass d; } @Deprecated class DeprecatedClass { }
1,215
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
IntfAnnotationMemberClash.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/IntfAnnotationMemberClash.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.intf.annotation.member.clash @interface X { String toString(); }
1,143
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
BreakOutsideSwitchLoop.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/BreakOutsideSwitchLoop.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.break.outside.switch.loop class BreakOutsideSwitchLoop { void m() { break; } }
1,169
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DuplicateDefaultLabel.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/DuplicateDefaultLabel.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.duplicate.default.label class DuplicateCaseLabel { String m(int arg) { switch (arg) { case 0: return "zero"; case 1: return "one"; default: return "??"; default: return "??"; } } }
1,329
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VarMightNotHaveBeenInitialized.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/VarMightNotHaveBeenInitialized.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.var.might.not.have.been.initialized class X { final int i; X(boolean b) { if (b) i = 3; } }
1,198
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PathElementNotFound.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/PathElementNotFound.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.path.element.not.found // options: -Xlint:path -classpath DoesNotExist // run: simple class PathElementNotFound { }
1,191
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MissingReturnStatement.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/MissingReturnStatement.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.missing.ret.stmt class MissingReturnStatement { int m() { } }
1,144
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassCantWrite.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/ClassCantWrite.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.class.cant.write // run: jsr199 -filemanager cantWrite:.*/ClassCantWrite.class class ClassCantWrite { }
1,178
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumTypesNotExtensible.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/EnumTypesNotExtensible.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.enum.types.not.extensible // key: compiler.err.cant.inherit.from.final enum E { A, B, C } class EnumTypesNotExtensible extends E { }
1,208
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SourceNoBootclasspath.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.source.no.bootclasspath // options: -source 6 class SourceNoBootclasspath { }
1,153
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UnreachableStatement.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/UnreachableStatement.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.unreachable.stmt class X { void m() { return; m(); } }
1,153
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CountError.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CountError.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.count.error // key: compiler.err.unreported.exception.need.to.catch.or.throw // key: compiler.err.error // run: backdoor class CountError { void m() { throw new Exception(); } }
1,263
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
OperatorCantBeApplied1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/OperatorCantBeApplied1.java
/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.operator.cant.be.applied.1 class OperatorCantBeApplied1 { String s = ("a" - "b"); }
1,162
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumAsIdentifier2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/EnumAsIdentifier2.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.enum.as.identifier class EnumAsIdentifier2 { int enum; }
1,135
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UnsafeUseOfVarargsParam.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/UnsafeUseOfVarargsParam.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.varargs.unsafe.use.varargs.param // options: -Xlint:varargs class UnsafeUseOfVarargsParam { @SafeVarargs static <X> void m(X... x) { Object[] o = x; } }
1,244
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AlreadyDefined.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/AlreadyDefined.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.already.defined class X { int i; int i; }
1,124
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FinalParamCantBeAssigned.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/FinalParamCantBeAssigned.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.final.parameter.may.not.be.assigned class FinalParamCantBeAssigned { void m(final int i) { i++; } }
1,190
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ContinueOutsideLoop.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/ContinueOutsideLoop.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cont.outside.loop class ContinueOutsideLoop { void m() { continue; } }
1,161
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UnreachableCatch1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/UnreachableCatch1.java
/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.unreachable.catch.1 import java.io.*; class UnreachableCatch1 { void test() { try { if (true) { throw new FileNotFoundException(); } else { throw new EOFException(); } } catch(FileNotFoundException fnf) { } catch(EOFException eof) { } catch(IOException ex) { } //unreachable } }
1,484
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TrustMeOnNonVarargsMeth.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/TrustMeOnNonVarargsMeth.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.varargs.invalid.trustme.anno // key: compiler.misc.varargs.trustme.on.non.varargs.meth // options: -Xlint:varargs class TrustMeOnNonVarargsMeth { @SafeVarargs static void m(String[] args) { } }
1,272
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VarargsOverride.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/VarargsOverride.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.varargs.override // key: compiler.warn.override.varargs.extra // options: -Xlint:overrides class Base { void m(Object... x) { } } class VarargsOverride extends Base { void m(Object[] x) { } }
1,276
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AssertAsIdentifier.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.assert.as.identifier // options: -source 1.3 -Xlint:-options class AssertAsIdentifier { int assert; }
1,181
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CantResolveLocationArgsParams.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParams.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cant.resolve.location.args.params // key: compiler.misc.location import java.util.*; class X { void m() { Object o = List.<String>unknown(); } }
1,242
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ForeachNotSupported.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/ForeachNotSupported.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.foreach.not.supported.in.source // options: -source 1.4 -Xlint:-options class ForeachNotSupported { void m(String[] args) { for (String a: args) { System.out.println(a); } } }
1,286
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CantResolveArgsParams.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CantResolveArgsParams.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cant.resolve.args.params class CantResolveArgsParams { Object o = new Object() { { this.<Integer,Double>m2(1, ""); } }; }
1,218
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SuperNotAllowedInEnum.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/SuperNotAllowedInEnum.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.call.to.super.not.allowed.in.enum.ctor enum SuperNotAllowedInEnum { A, B, C; SuperNotAllowedInEnum() { super(); } }
1,218
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
IntfAnnotationsCantHaveTypeParams.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/IntfAnnotationsCantHaveTypeParams.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.intf.annotation.members.cant.have.type.params @interface X { <T> String value(); }
1,161
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LocalVarNeedsFinal.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.local.var.accessed.from.icls.needs.final class LocalVarNeedsFinal { Runnable m() { int i = 3; return new Runnable() { public void run() { System.out.println(i); } }; } }
1,316
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CantExtendIntfAnno.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CantExtendIntfAnno.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cant.extend.intf.annotation @interface Anno { } @interface CantExtendIntfAnno extends Anno { }
1,170
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
IllegalComboModifiers.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/IllegalComboModifiers.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.illegal.combination.of.modifiers class IllegalComboModifiers { public private int x; }
1,165
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VarargsImplement.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/VarargsImplement.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.varargs.implement // key: compiler.warn.override.varargs.extra // options: -Xlint:overrides interface Base { void m(Object... x); } class VarargsImplement implements Base { public void m(Object[] x) { } }
1,289
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeNoParams.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/TypeNoParams.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.type.doesnt.take.params class TypeNoParams { Object<Integer> obj; }
1,146
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TryWithoutCatchOrFinallyOrResource.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/TryWithoutCatchOrFinallyOrResource.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.try.without.catch.finally.or.resource.decls class TryWithoutCatchOrFinallyOrResource { void m() { try { } } }
1,208
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
IncompatibleTypes1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/IncompatibleTypes1.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.incompatible.types.1 // key: compiler.misc.infer.no.conforming.instance.exists // key: compiler.err.prob.found.req class IncompatibleTypes1<V> { <T extends Integer & Runnable> IncompatibleTypes1<T> m() { return null; } IncompatibleTypes1<? super String> o = m(); }
1,361
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnoValueMustBeAnnotation.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/AnnoValueMustBeAnnotation.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.annotation.value.must.be.annotation @interface Anno1 { String value(); } @interface Anno2 { Anno1 value(); } @Anno2("3") class AnnoValueMustBeAnnotation { }
1,241
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ArrayAndVarargs.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/ArrayAndVarargs.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.array.and.varargs class ArrayAndVarags { void m(int[] array) { } void m(int... args) { } }
1,173
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CantDeref.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CantDeref.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cant.deref class X { int m(int i) { return i.x; } }
1,142
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TryWithoutCatchOrFinally.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/TryWithoutCatchOrFinally.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.try.without.catch.or.finally // options: -source 1.6 -Xlint:-options class TryWithoutCatchOrFinally { void m() { try { } } }
1,223
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CantRefBeforeConstr.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CantRefBeforeConstr.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cant.ref.before.ctor.called class Base { Base(int i) { } } class CantRefBeforeConstr extends Base { int i; CantRefBeforeConstr() { super(i); } }
1,245
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeVarCantBeDeref.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/TypeVarCantBeDeref.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.type.var.cant.be.deref class Base<T> { } class TypeVarCantBeDeref<T> extends Base<T.foo> {}
1,167
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Location.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/Location.java
/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cant.resolve.location // key: compiler.misc.location class Location { { Object o = v; } }
1,168
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
NotWithinBounds.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/NotWithinBounds.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.not.within.bounds class NotWithinBounds { static class Foo<X extends Number> { } Foo<String> f1 = null; }
1,190
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CantResolve.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CantResolve.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.cant.resolve class CantResolve { Object o = new Object() { int i = f; }; }
1,171
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FinallyCannotComplete.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/FinallyCannotComplete.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.finally.cannot.complete // options: -Xlint:finally class FinallyCannotComplete { void m() { try { } finally { throw new Error(); } } }
1,254
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
NameClashSameErasure.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/NameClashSameErasure.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.name.clash.same.erasure import java.util.*; class NameClassSameErasure { void m(List<Integer> list) { } void m(List<String> list) { } }
1,219
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VarMightAlreadyBeAssigned.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/VarMightAlreadyBeAssigned.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.var.might.already.be.assigned class VarMightAlreadyBeAssigned { void m(boolean b) { final int i; if (b) i = 3; i = 4; } }
1,240
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DivZero.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/DivZero.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.div.zero // options: -Xlint:divzero class DivZero { int m(int a) { return a / 0 ; } }
1,177
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UncheckedCast.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/UncheckedCast.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.prob.found.req // key: compiler.misc.unchecked.cast.to.type // options: -Xlint:unchecked import java.util.*; class UncheckedCast { <T,U> List<U> m(List<T> l) { return (List<U>) l; } }
1,276
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MissingDeprecatedAnnotation.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/MissingDeprecatedAnnotation.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.missing.deprecated.annotation // options: -Xlint:dep-ann /** @deprecated */ class MissingDeprecatedAnnotation { }
1,189
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
NoJavaLang.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/NoJavaLang.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.fatal.err.no.java.lang // options: -Xbootclasspath: // run: backdoor class NoJavaLang { }
1,165
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClashesWith.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/ClashesWith.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.clashes.with // key: compiler.err.override.incompatible.ret interface Base { int m(); } interface ClashesWith extends Base { String m(); }
1,223
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeReqClassArray.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/TypeReqClassArray.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.type.req.class.array // key: compiler.err.type.found.req import java.util.*; class TypeReqClassArray { boolean b = (this instanceof int); }
1,220
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Verbose.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/Verbose.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.verbose.parsing.started // key: compiler.misc.verbose.parsing.done // key: compiler.misc.verbose.sourcepath // key: compiler.misc.verbose.classpath // key: compiler.misc.verbose.loading // key: compiler.misc.verbose.checking.attribution // key: compiler.misc.verbose.wrote.file // key: compiler.misc.verbose.total // options: -verbose // run: backdoor class Verbose { }
1,445
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumAsIdentifier.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.enum.as.identifier // options: -source 1.3 -Xlint:-options class EnumAsIdentifier { int enum; }
1,175
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VarargsClash.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/VarargsClash.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.varargs.clash.with // key: compiler.warn.override.varargs.extra // options: -Xlint:overrides interface Base { void m(Object... x); } interface VarargsClash extends Base { void m(Object[] x); }
1,277
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
IllegalLineEndInCharLit.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/IllegalLineEndInCharLit.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.illegal.line.end.in.char.lit class IllegalLineEndInCharLit { char c = ' '; }
1,155
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
KindnameVariable.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/KindnameVariable.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.kindname.variable // key: compiler.misc.kindname.class // key: compiler.err.cant.resolve.location // key: compiler.misc.location // key: compiler.misc.count.error // key: compiler.err.error // run: backdoor class KindnameVariable { Object o = not_found; }
1,341
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ModifierNotAllowed.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/ModifierNotAllowed.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.mod.not.allowed.here synchronized interface ModifierNotAllowed { }
1,141
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MethodDoesNotOverride.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/MethodDoesNotOverride.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.method.does.not.override.superclass class X { @Override void m() { } }
1,153
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MissingSVUID.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/MissingSVUID.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.missing.SVUID // options: -Xlint:serial import java.io.Serializable; class MissingSVUID implements Serializable { }
1,192
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InvalidInstanceof.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/InvalidInstanceof.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.illegal.generic.type.for.instof import java.util.*; class IllegalInstanceof { List o; boolean b = (o instanceof List<String>); }
1,212
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UnreportedException.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/UnreportedException.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.unreported.exception.need.to.catch.or.throw class UnreportedException { void m() { throw new Exception(); } }
1,200
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CountWarn.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/CountWarn.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.count.warn // key: compiler.warn.warning // key: compiler.warn.lintOption // key: compiler.warn.prob.found.req // key: compiler.misc.unchecked.assign // options: -Xlint:unchecked // run: backdoor import java.util.*; class CountWarn { List<String> list = new ArrayList(); }
1,353
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RecursiveConstrInvocation.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/RecursiveConstrInvocation.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.recursive.ctor.invocation class X { X() { this(); } }
1,144
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
KindnameStaticInit.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/KindnameStaticInit.java
/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.already.defined.in.clinit // key: compiler.misc.kindname.static.init // key: compiler.misc.kindname.class // key: compiler.misc.kindname.variable // key: compiler.misc.count.error // key: compiler.err.error // run: backdoor class KindnameStaticInit { static { int i; int i; } }
1,376
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UncheckedAssignToVar.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/UncheckedAssignToVar.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.unchecked.assign.to.var // options: -Xlint:unchecked class Foo<T> { T t; } class UncheckedAssignToVar { void m() { Foo f = new Foo(); f.t = "??"; } }
1,254
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
WhereCaptured.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/WhereCaptured.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.where.captured // key: compiler.misc.where.description.captured.1 // key: compiler.misc.where.description.typevar // key: compiler.misc.where.typevar // key: compiler.err.cant.apply.symbol.1 // key: compiler.misc.infer.no.conforming.assignment.exists // key: compiler.misc.captured.type // options: -XDdiags=where,simpleNames // run: simple import java.util.*; class WhereCaptured { <T> void m(List<T> l1, List<T> l2) {} void test(List<? super WhereCaptured> list) { m(list, list); } }
1,583
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DotClassExpected.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/DotClassExpected.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.dot.class.expected class DotClassExpected { int f = int[] + 3; }
1,143
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnclClassRequired.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/EnclClassRequired.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.encl.class.required class Base { class Nested { } } class EnclClassRequired extends Base.Nested { }
1,179
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeReqRef.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/TypeReqRef.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.type.req.ref // key: compiler.err.type.found.req class TypeReqRef { int i; boolean b = (i instanceof Object); }
1,195
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DoesntExist.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/DoesntExist.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.doesnt.exist import DoesntExist.*;
1,109
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DiamondRedundantArgs1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/DiamondRedundantArgs1.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.diamond.redundant.args.1 // options: -XDfindDiamond class Foo<X> { Foo<?> fs = new Foo<String>(); }
1,178
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnonymousClass.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/AnonymousClass.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.misc.anonymous.class // key: compiler.warn.missing.SVUID // options: -Xlint:serial // run: simple class AnonymousClass { Exception m() { return new Exception() { }; } }
1,255
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
NoExplicitAnnoProcRequested.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/NoExplicitAnnoProcRequested.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.err.proc.no.explicit.annotation.processing.requested // options: UnknownClass // run: simple class NoExplicitAnnoProcRequested { }
1,201
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UnreachableCatch.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/diags/examples/UnreachableCatch.java
/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // key: compiler.warn.unreachable.catch class UnreachableCatch { void test() { try { throw new java.io.FileNotFoundException(); } catch(java.io.FileNotFoundException exc) { } catch(java.io.IOException exc) { } //unreachable } }
1,334
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z