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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Sub.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T6180021/Sub.java | /*
* Copyright (c) 2005, 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 6180021
* @summary CompletionFailure during TypeTrans
* @author Peter von der Ah\u00e9
* @compile Super.java
* @clean Missing
* @compile Sub.java
*/
class Sub extends Super {}
| 1,267 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Super.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T6180021/Super.java | /*
* Copyright (c) 2005, 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 Super {
void m(Missing a) {}
void m(String a) {}
}
abstract class AbstractSuper {
abstract void m(Missing a);
abstract void m(String a);
}
interface Missing {}
| 1,236 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractSub.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T6180021/AbstractSub.java | /*
* Copyright (c) 2005, 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 6180021
* @summary CompletionFailure during TypeTrans
* @author Peter von der Ah\u00e9
* @compile Super.java
* @clean Missing
* @compile AbstractSub.java
*/
abstract class AbstractSub extends AbstractSuper {}
| 1,300 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
JavacTreeScannerTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/JavacTreeScannerTest.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.
*/
/**
* Utility and test program to check javac's internal TreeScanner class.
* The program can be run standalone, or as a jtreg test. For info on
* command line args, run program with no args.
*
* <p>
* jtreg: Note that by using the -r switch in the test description below, this test
* will process all java files in the langtools/test directory, thus implicitly
* covering any new language features that may be tested in this test suite.
*/
/*
* @test
* @bug 6923080
* @summary TreeScanner.visitNewClass should scan tree.typeargs
* @build AbstractTreeScannerTest JavacTreeScannerTest
* @run main JavacTreeScannerTest -q -r .
*/
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import javax.tools.*;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.TreeScanner;
import com.sun.tools.javac.util.List;
public class JavacTreeScannerTest extends AbstractTreeScannerTest {
/**
* Main entry point.
* If test.src is set, program runs in jtreg mode, and will throw an Error
* if any errors arise, otherwise System.exit will be used. In jtreg mode,
* the default base directory for file args is the value of ${test.src}.
* In jtreg mode, the -r option can be given to change the default base
* directory to the root test directory.
*/
public static void main(String... args) {
String testSrc = System.getProperty("test.src");
File baseDir = (testSrc == null) ? null : new File(testSrc);
boolean ok = new JavacTreeScannerTest().run(baseDir, args);
if (!ok) {
if (testSrc != null) // jtreg mode
throw new Error("failed");
else
System.exit(1);
}
}
int test(JCCompilationUnit tree) {
return new ScanTester().test(tree);
}
/**
* Main class for testing operation of tree scanner.
* The set of nodes found by the scanner are compared
* against the set of nodes found by reflection.
*/
private class ScanTester extends TreeScanner {
/** Main entry method for the class. */
int test(JCCompilationUnit tree) {
sourcefile = tree.sourcefile;
found = new HashSet<JCTree>();
scan(tree);
expect = new HashSet<JCTree>();
reflectiveScan(tree);
if (found.equals(expect)) {
//System.err.println(sourcefile.getName() + ": trees compared OK");
return found.size();
}
error(sourcefile, "differences found");
if (found.size() != expect.size())
error("Size mismatch; found: " + found.size() + ", expected: " + expect.size());
Set<JCTree> missing = new HashSet<JCTree>();
missing.addAll(expect);
missing.removeAll(found);
for (JCTree t: missing)
error(sourcefile, t, "missing");
Set<JCTree> excess = new HashSet<JCTree>();
excess.addAll(found);
excess.removeAll(expect);
for (JCTree t: excess)
error(sourcefile, t, "unexpected");
return 0;
}
/** Record all tree nodes found by scanner. */
@Override
public void scan(JCTree tree) {
if (tree == null)
return;
//System.err.println("FOUND: " + tree.getTag() + " " + trim(tree, 64));
found.add(tree);
super.scan(tree);
}
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
if (o == null)
return;
if (o instanceof JCTree) {
JCTree tree = (JCTree) o;
//System.err.println("EXPECT: " + tree.getTag() + " " + trim(tree, 64));
expect.add(tree);
for (Field f: getFields(tree)) {
try {
//System.err.println("FIELD: " + f.getName());
reflectiveScan(f.get(tree));
} catch (IllegalAccessException e) {
error(e.toString());
}
}
} else if (o instanceof List) {
List<?> list = (List<?>) o;
for (Object item: list)
reflectiveScan(item);
} else
error("unexpected item: " + o);
}
JavaFileObject sourcefile;
Set<JCTree> found;
Set<JCTree> expect;
}
}
| 5,663 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TreeKindTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/TreeKindTest.java | /*
* Copyright (c) 2006, 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 6341023
* @summary Tree API: Tree.Kind should have mapping to interface
*/
import com.sun.source.tree.*;
public class TreeKindTest{
public static void main(String... args) {
boolean ok = true;
for (Tree.Kind k: Tree.Kind.values()) {
//System.err.println(k + " " + k.asInterface());
Class<? extends Tree> i = k.asInterface();
switch (k) {
case POSTFIX_INCREMENT:
case POSTFIX_DECREMENT:
case PREFIX_INCREMENT:
case PREFIX_DECREMENT:
case UNARY_PLUS:
case UNARY_MINUS:
case BITWISE_COMPLEMENT:
case LOGICAL_COMPLEMENT:
ok = ok & verify(k, i, i == UnaryTree.class);
break;
case MULTIPLY:
case DIVIDE:
case REMAINDER:
case PLUS:
case MINUS:
case LEFT_SHIFT:
case RIGHT_SHIFT:
case UNSIGNED_RIGHT_SHIFT:
case LESS_THAN:
case GREATER_THAN:
case LESS_THAN_EQUAL:
case GREATER_THAN_EQUAL:
case EQUAL_TO:
case NOT_EQUAL_TO:
case AND:
case XOR:
case OR:
case CONDITIONAL_AND:
case CONDITIONAL_OR:
ok = ok & verify(k, i, i == BinaryTree.class);
break;
case MULTIPLY_ASSIGNMENT:
case DIVIDE_ASSIGNMENT:
case REMAINDER_ASSIGNMENT:
case PLUS_ASSIGNMENT:
case MINUS_ASSIGNMENT:
case LEFT_SHIFT_ASSIGNMENT:
case RIGHT_SHIFT_ASSIGNMENT:
case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
case AND_ASSIGNMENT:
case XOR_ASSIGNMENT:
case OR_ASSIGNMENT:
ok = ok & verify(k, i, i == CompoundAssignmentTree.class);
break;
case INT_LITERAL:
case LONG_LITERAL:
case FLOAT_LITERAL:
case DOUBLE_LITERAL:
case BOOLEAN_LITERAL:
case CHAR_LITERAL:
case STRING_LITERAL:
case NULL_LITERAL:
ok = ok & verify(k, i, i == LiteralTree.class);
break;
case UNBOUNDED_WILDCARD:
case EXTENDS_WILDCARD:
case SUPER_WILDCARD:
ok = ok & verify(k, i, i == WildcardTree.class);
break;
case INTERFACE:
case ANNOTATION_TYPE:
case ENUM:
case CLASS:
ok = ok & verify(k, i, i == ClassTree.class);
break;
case OTHER:
ok = ok & verify(k, i, i == null);
break;
default:
String ks = k.toString().replace("_", "") + "tree";
String iName = i.getName();
String is = iName.substring(iName.lastIndexOf(".") + 1);
ok = ok & verify(k, i, ks.equalsIgnoreCase(is));
}
}
if (!ok)
throw new AssertionError("test failed");
}
static boolean verify(Tree.Kind k, Class<?> c, boolean b) {
if (!b)
System.err.println("error: " + k + " " + c);
return b;
}
}
| 4,347 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ClassTreeTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/ClassTreeTest.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.
*/
/*
* @test
* @bug 6570730
* @summary com.sun.source.tree.ModifiersTree.getFlags() should return class type
*/
import java.io.*;
import java.util.*;
import javax.tools.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;
import com.sun.tools.javac.api.*;
public class ClassTreeTest {
public static void main(String... args) throws Exception {
new ClassTreeTest().run();
}
void run() throws Exception {
JavacTool tool = JavacTool.create();
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
List<String> opts = Collections.<String>emptyList();
File testSrc = new File(System.getProperty("test.src"));
File thisFile = new File(testSrc, ClassTreeTest.class.getSimpleName() + ".java");
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
JavacTask task = tool.getTask(null, fm, null, opts, null, fos);
for (CompilationUnitTree cu: task.parse()) {
check(cu, "CLASS", Tree.Kind.CLASS);
check(cu, "INTERFACE", Tree.Kind.INTERFACE);
check(cu, "ENUM", Tree.Kind.ENUM);
check(cu, "ANNOTATION_TYPE", Tree.Kind.ANNOTATION_TYPE);
}
int expected = 4;
if (checks != expected)
error("Unexpected number of checks performed; expected: " + expected + ", found: " + checks);
if (errors > 0)
throw new Exception(errors + " errors found");
}
void check(CompilationUnitTree cu, String name, Tree.Kind k) {
checks++;
TreeScanner<ClassTree,String> s = new TreeScanner<ClassTree,String>() {
@Override
public ClassTree visitClass(ClassTree c, String name) {
if (c.getSimpleName().toString().equals(name))
return c;
else
return super.visitClass(c, name);
}
@Override
public ClassTree reduce(ClassTree t1, ClassTree t2) {
return (t1 != null ? t1 : t2);
}
};
ClassTree c = s.scan(cu, name);
if (c == null)
error("Can't find node named " + name);
else if (c.getKind() != k)
error("Unexpected kind for node named " + name + ": expected: " + k + ", found: " + c.getKind());
}
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
int checks;
int errors;
class CLASS { }
interface INTERFACE { }
enum ENUM { }
@interface ANNOTATION_TYPE { }
}
| 3,632 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6963934.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/T6963934.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.
*/
/*
* @test
* @bug 6963934
* @summary JCCompilationUnit.getImports does not report all imports
*/
import java.io.File;
import javax.tools.JavaCompiler;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;; // NOTE: extra semicolon for test
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.ImportTree;
import com.sun.source.util.JavacTask;
; // NOTE: extra semicolon for test
public class T6963934 {
public static void main(String[] args) throws Exception {
File testSrc = new File(System.getProperty("test.src"));
File thisSrc = new File(testSrc, T6963934.class.getSimpleName() + ".java");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
JavacTask task = (JavacTask) compiler.getTask(null, fileManager, null, null, null,
fileManager.getJavaFileObjects(thisSrc));
CompilationUnitTree tree = task.parse().iterator().next();
int count = 0;
for (ImportTree importTree : tree.getImports()) {
System.out.println(importTree);
count++;
}
int expected = 7;
if (count != expected)
throw new Exception("unexpected number of imports found: " + count + ", expected: " + expected);
}
}
| 2,435 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TreePosTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/TreePosTest.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.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCNewClass;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.tree.TreeScanner;
import static com.sun.tools.javac.util.Position.NOPOS;
/**
* Utility and test program to check validity of tree positions for tree nodes.
* The program can be run standalone, or as a jtreg test. In standalone mode,
* errors can be displayed in a gui viewer. For info on command line args,
* run program with no args.
*
* <p>
* jtreg: Note that by using the -r switch in the test description below, this test
* will process all java files in the langtools/test directory, thus implicitly
* covering any new language features that may be tested in this test suite.
*/
/*
* @test
* @bug 6919889
* @summary assorted position errors in compiler syntax trees
* @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations -et ANNOTATED_TYPE .
*/
public class TreePosTest {
/**
* Main entry point.
* If test.src is set, program runs in jtreg mode, and will throw an Error
* if any errors arise, otherwise System.exit will be used, unless the gui
* viewer is being used. In jtreg mode, the default base directory for file
* args is the value of ${test.src}. In jtreg mode, the -r option can be
* given to change the default base directory to the root test directory.
*/
public static void main(String... args) {
String testSrc = System.getProperty("test.src");
File baseDir = (testSrc == null) ? null : new File(testSrc);
boolean ok = new TreePosTest().run(baseDir, args);
if (!ok) {
if (testSrc != null) // jtreg mode
throw new Error("failed");
else
System.exit(1);
}
}
/**
* Run the program. A base directory can be provided for file arguments.
* In jtreg mode, the -r option can be given to change the default base
* directory to the test root directory. For other options, see usage().
* @param baseDir base directory for any file arguments.
* @param args command line args
* @return true if successful or in gui mode
*/
boolean run(File baseDir, String... args) {
if (args.length == 0) {
usage(System.out);
return true;
}
List<File> files = new ArrayList<File>();
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals("-encoding") && i + 1 < args.length)
encoding = args[++i];
else if (arg.equals("-gui"))
gui = true;
else if (arg.equals("-q"))
quiet = true;
else if (arg.equals("-v"))
verbose = true;
else if (arg.equals("-t") && i + 1 < args.length)
tags.add(args[++i]);
else if (arg.equals("-ef") && i + 1 < args.length)
excludeFiles.add(new File(baseDir, args[++i]));
else if (arg.equals("-et") && i + 1 < args.length)
excludeTags.add(args[++i]);
else if (arg.equals("-r")) {
if (excludeFiles.size() > 0)
throw new Error("-r must be used before -ef");
File d = baseDir;
while (!new File(d, "TEST.ROOT").exists()) {
d = d.getParentFile();
if (d == null)
throw new Error("cannot find TEST.ROOT");
}
baseDir = d;
}
else if (arg.startsWith("-"))
throw new Error("unknown option: " + arg);
else {
while (i < args.length)
files.add(new File(baseDir, args[i++]));
}
}
for (File file: files) {
if (file.exists())
test(file);
else
error("File not found: " + file);
}
if (fileCount != 1)
System.err.println(fileCount + " files read");
if (errors > 0)
System.err.println(errors + " errors");
return (gui || errors == 0);
}
/**
* Print command line help.
* @param out output stream
*/
void usage(PrintStream out) {
out.println("Usage:");
out.println(" java TreePosTest options... files...");
out.println("");
out.println("where options include:");
out.println("-gui Display returns in a GUI viewer");
out.println("-q Quiet: don't report on inapplicable files");
out.println("-v Verbose: report on files as they are being read");
out.println("-t tag Limit checks to tree nodes with this tag");
out.println(" Can be repeated if desired");
out.println("-ef file Exclude file or directory");
out.println("-et tag Exclude tree nodes with given tag name");
out.println("");
out.println("files may be directories or files");
out.println("directories will be scanned recursively");
out.println("non java files, or java files which cannot be parsed, will be ignored");
out.println("");
}
/**
* Test a file. If the file is a directory, it will be recursively scanned
* for java files.
* @param file the file or directory to test
*/
void test(File file) {
if (excludeFiles.contains(file)) {
if (!quiet)
error("File " + file + " excluded");
return;
}
if (file.isDirectory()) {
for (File f: file.listFiles()) {
test(f);
}
return;
}
if (file.isFile() && file.getName().endsWith(".java")) {
try {
if (verbose)
System.err.println(file);
fileCount++;
PosTester p = new PosTester();
p.test(read(file));
} catch (ParseException e) {
if (!quiet) {
error("Error parsing " + file + "\n" + e.getMessage());
}
} catch (IOException e) {
error("Error reading " + file + ": " + e);
}
return;
}
if (!quiet)
error("File " + file + " ignored");
}
// See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Reporter r = new Reporter(pw);
JavacTool tool = JavacTool.create();
StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
/**
* Read a file.
* @param file the file to be read
* @return the tree for the content of the file
* @throws IOException if any IO errors occur
* @throws TreePosTest.ParseException if any errors occur while parsing the file
*/
JCCompilationUnit read(File file) throws IOException, ParseException {
JavacTool tool = JavacTool.create();
r.errors = 0;
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
Iterable<? extends CompilationUnitTree> trees = task.parse();
pw.flush();
if (r.errors > 0)
throw new ParseException(sw.toString());
Iterator<? extends CompilationUnitTree> iter = trees.iterator();
if (!iter.hasNext())
throw new Error("no trees found");
JCCompilationUnit t = (JCCompilationUnit) iter.next();
if (iter.hasNext())
throw new Error("too many trees found");
return t;
}
/**
* Report an error. When the program is complete, the program will either
* exit or throw an Error if any errors have been reported.
* @param msg the error message
*/
void error(String msg) {
System.err.println(msg);
errors++;
}
/** Number of files that have been analyzed. */
int fileCount;
/** Number of errors reported. */
int errors;
/** Flag: don't report irrelevant files. */
boolean quiet;
/** Flag: report files as they are processed. */
boolean verbose;
/** Flag: show errors in GUI viewer. */
boolean gui;
/** Option: encoding for test files. */
String encoding;
/** The GUI viewer for errors. */
Viewer viewer;
/** The set of tags for tree nodes to be analyzed; if empty, all tree nodes
* are analyzed. */
Set<String> tags = new HashSet<String>();
/** Set of files and directories to be excluded from analysis. */
Set<File> excludeFiles = new HashSet<File>();
/** Set of tag names to be excluded from analysis. */
Set<String> excludeTags = new HashSet<String>();
/** Table of printable names for tree tag values. */
TagNames tagNames = new TagNames();
/**
* Main class for testing assertions concerning tree positions for tree nodes.
*/
private class PosTester extends TreeScanner {
void test(JCCompilationUnit tree) {
sourcefile = tree.sourcefile;
endPosTable = tree.endPositions;
encl = new Info();
tree.accept(this);
}
@Override
public void scan(JCTree tree) {
if (tree == null)
return;
Info self = new Info(tree, endPosTable);
if (check(encl, self)) {
// Modifiers nodes are present throughout the tree even where
// there is no corresponding source text.
// Redundant semicolons in a class definition can cause empty
// initializer blocks with no positions.
if ((self.tag == JCTree.MODIFIERS || self.tag == JCTree.BLOCK)
&& self.pos == NOPOS) {
// If pos is NOPOS, so should be the start and end positions
check("start == NOPOS", encl, self, self.start == NOPOS);
check("end == NOPOS", encl, self, self.end == NOPOS);
} else {
// For this node, start , pos, and endpos should be all defined
check("start != NOPOS", encl, self, self.start != NOPOS);
check("pos != NOPOS", encl, self, self.pos != NOPOS);
check("end != NOPOS", encl, self, self.end != NOPOS);
// The following should normally be ordered
// encl.start <= start <= pos <= end <= encl.end
// In addition, the position of the enclosing node should be
// within this node.
// The primary exceptions are for array type nodes, because of the
// need to support legacy syntax:
// e.g. int a[]; int[] b[]; int f()[] { return null; }
// and because of inconsistent nesting of left and right of
// array declarations:
// e.g. int[][] a = new int[2][];
check("encl.start <= start", encl, self, encl.start <= self.start);
check("start <= pos", encl, self, self.start <= self.pos);
if (!(self.tag == JCTree.TYPEARRAY
&& (encl.tag == JCTree.VARDEF ||
encl.tag == JCTree.METHODDEF ||
encl.tag == JCTree.TYPEARRAY))) {
check("encl.pos <= start || end <= encl.pos",
encl, self, encl.pos <= self.start || self.end <= encl.pos);
}
check("pos <= end", encl, self, self.pos <= self.end);
if (!(self.tag == JCTree.TYPEARRAY && encl.tag == JCTree.TYPEARRAY)) {
check("end <= encl.end", encl, self, self.end <= encl.end);
}
}
}
Info prevEncl = encl;
encl = self;
tree.accept(this);
encl = prevEncl;
}
@Override
public void visitVarDef(JCVariableDecl tree) {
// enum member declarations are desugared in the parser and have
// ill-defined semantics for tree positions, so for now, we
// skip the synthesized bits and just check parts which came from
// the original source text
if ((tree.mods.flags & Flags.ENUM) != 0) {
scan(tree.mods);
if (tree.init != null) {
if (tree.init.getTag() == JCTree.NEWCLASS) {
JCNewClass init = (JCNewClass) tree.init;
if (init.args != null && init.args.nonEmpty()) {
scan(init.args);
}
if (init.def != null && init.def.defs != null) {
scan(init.def.defs);
}
}
}
} else
super.visitVarDef(tree);
}
boolean check(Info encl, Info self) {
if (excludeTags.size() > 0) {
if (encl != null && excludeTags.contains(tagNames.get(encl.tag))
|| excludeTags.contains(tagNames.get(self.tag)))
return false;
}
return tags.size() == 0 || tags.contains(tagNames.get(self.tag));
}
void check(String label, Info encl, Info self, boolean ok) {
if (!ok) {
if (gui) {
if (viewer == null)
viewer = new Viewer();
viewer.addEntry(sourcefile, label, encl, self);
}
String s = self.tree.toString();
String msg = sourcefile.getName() + ": " + label + ": " +
"encl:" + encl + " this:" + self + "\n" +
s.substring(0, Math.min(80, s.length())).replaceAll("[\r\n]+", " ");
error(msg);
}
}
JavaFileObject sourcefile;
Map<JCTree, Integer> endPosTable;
Info encl;
}
/**
* Utility class providing easy access to position and other info for a tree node.
*/
private class Info {
Info() {
tree = null;
tag = JCTree.ERRONEOUS;
start = 0;
pos = 0;
end = Integer.MAX_VALUE;
}
Info(JCTree tree, Map<JCTree, Integer> endPosTable) {
this.tree = tree;
tag = tree.getTag();
start = TreeInfo.getStartPos(tree);
pos = tree.pos;
end = TreeInfo.getEndPos(tree, endPosTable);
}
@Override
public String toString() {
return tagNames.get(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]";
}
final JCTree tree;
final int tag;
final int start;
final int pos;
final int end;
}
/**
* Names for tree tags.
* javac does not provide an API to convert tag values to strings, so this class uses
* reflection to determine names of public static final int values in JCTree.
*/
private static class TagNames {
String get(int tag) {
if (map == null) {
map = new HashMap<Integer, String>();
Class c = JCTree.class;
for (Field f : c.getDeclaredFields()) {
if (f.getType().equals(int.class)) {
int mods = f.getModifiers();
if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
try {
map.put(f.getInt(null), f.getName());
} catch (IllegalAccessException e) {
}
}
}
}
}
String name = map.get(tag);
return (name == null) ? "??" : name;
}
private Map<Integer, String> map;
}
/**
* Thrown when errors are found parsing a java file.
*/
private static class ParseException extends Exception {
ParseException(String msg) {
super(msg);
}
}
/**
* DiagnosticListener to report diagnostics and count any errors that occur.
*/
private static class Reporter implements DiagnosticListener<JavaFileObject> {
Reporter(PrintWriter out) {
this.out = out;
}
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
out.println(diagnostic);
switch (diagnostic.getKind()) {
case ERROR:
errors++;
}
}
int errors;
PrintWriter out;
}
/**
* GUI viewer for issues found by TreePosTester. The viewer provides a drop
* down list for selecting error conditions, a header area providing details
* about an error, and a text area with the ranges of text highlighted as
* appropriate.
*/
private class Viewer extends JFrame {
/**
* Create a viewer.
*/
Viewer() {
initGUI();
}
/**
* Add another entry to the list of errors.
* @param file The file containing the error
* @param check The condition that was being tested, and which failed
* @param encl the enclosing tree node
* @param self the tree node containing the error
*/
void addEntry(JavaFileObject file, String check, Info encl, Info self) {
Entry e = new Entry(file, check, encl, self);
DefaultComboBoxModel m = (DefaultComboBoxModel) entries.getModel();
m.addElement(e);
if (m.getSize() == 1)
entries.setSelectedItem(e);
}
/**
* Initialize the GUI window.
*/
private void initGUI() {
JPanel head = new JPanel(new GridBagLayout());
GridBagConstraints lc = new GridBagConstraints();
GridBagConstraints fc = new GridBagConstraints();
fc.anchor = GridBagConstraints.WEST;
fc.fill = GridBagConstraints.HORIZONTAL;
fc.gridwidth = GridBagConstraints.REMAINDER;
entries = new JComboBox();
entries.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showEntry((Entry) entries.getSelectedItem());
}
});
fc.insets.bottom = 10;
head.add(entries, fc);
fc.insets.bottom = 0;
head.add(new JLabel("check:"), lc);
head.add(checkField = createTextField(80), fc);
fc.fill = GridBagConstraints.NONE;
head.add(setBackground(new JLabel("encl:"), enclColor), lc);
head.add(enclPanel = new InfoPanel(), fc);
head.add(setBackground(new JLabel("self:"), selfColor), lc);
head.add(selfPanel = new InfoPanel(), fc);
add(head, BorderLayout.NORTH);
body = new JTextArea();
body.setFont(Font.decode(Font.MONOSPACED));
body.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent e) {
int dot = e.getDot();
int mark = e.getMark();
if (dot == mark)
statusText.setText("dot: " + dot);
else
statusText.setText("dot: " + dot + ", mark:" + mark);
}
});
JScrollPane p = new JScrollPane(body,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
p.setPreferredSize(new Dimension(640, 480));
add(p, BorderLayout.CENTER);
statusText = createTextField(80);
add(statusText, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(null); // centered on screen
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
try {
// update simple fields
setTitle(e.file.getName());
checkField.setText(e.check);
enclPanel.setInfo(e.encl);
selfPanel.setInfo(e.self);
// show file text with highlights
body.setText(e.file.getCharContent(true).toString());
Highlighter highlighter = body.getHighlighter();
highlighter.removeAllHighlights();
addHighlight(highlighter, e.encl, enclColor);
addHighlight(highlighter, e.self, selfColor);
scroll(body, getMinPos(enclPanel.info, selfPanel.info));
} catch (IOException ex) {
body.setText("Cannot read " + e.file.getName() + ": " + e);
}
}
/** Create a test field. */
private JTextField createTextField(int width) {
JTextField f = new JTextField(width);
f.setEditable(false);
f.setBorder(null);
return f;
}
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
int start = info.start;
int end = info.end;
if (start == -1 && end == -1)
return;
if (start == -1)
start = end;
if (end == -1)
end = start;
try {
h.addHighlight(info.start, info.end,
new DefaultHighlighter.DefaultHighlightPainter(c));
if (info.pos != -1) {
Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
h.addHighlight(info.pos, info.pos + 1,
new DefaultHighlighter.DefaultHighlightPainter(c2));
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
/** Get the minimum valid position in a set of info objects. */
private int getMinPos(Info... values) {
int i = Integer.MAX_VALUE;
for (Info info: values) {
if (info.start >= 0) i = Math.min(i, info.start);
if (info.pos >= 0) i = Math.min(i, info.pos);
if (info.end >= 0) i = Math.min(i, info.end);
}
return (i == Integer.MAX_VALUE) ? 0 : i;
}
/** Set the background on a component. */
private JComponent setBackground(JComponent comp, Color c) {
comp.setOpaque(true);
comp.setBackground(c);
return comp;
}
/** Scroll a text area to display a given position near the middle of the visible area. */
private void scroll(final JTextArea t, final int pos) {
// Using invokeLater appears to give text a chance to sort itself out
// before the scroll happens; otherwise scrollRectToVisible doesn't work.
// Maybe there's a better way to sync with the text...
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Rectangle r = t.modelToView(pos);
JScrollPane p = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, t);
r.y = Math.max(0, r.y - p.getHeight() * 2 / 5);
r.height += p.getHeight() * 4 / 5;
t.scrollRectToVisible(r);
} catch (BadLocationException ignore) {
}
}
});
}
private JComboBox entries;
private JTextField checkField;
private InfoPanel enclPanel;
private InfoPanel selfPanel;
private JTextArea body;
private JTextField statusText;
private Color selfColor = new Color(0.f, 1.f, 0.f, 0.2f); // 20% green
private Color enclColor = new Color(1.f, 0.f, 0.f, 0.2f); // 20% red
/** Panel to display an Info object. */
private class InfoPanel extends JPanel {
InfoPanel() {
add(tagName = createTextField(20));
add(new JLabel("start:"));
add(addListener(start = createTextField(6)));
add(new JLabel("pos:"));
add(addListener(pos = createTextField(6)));
add(new JLabel("end:"));
add(addListener(end = createTextField(6)));
}
void setInfo(Info info) {
this.info = info;
tagName.setText(tagNames.get(info.tag));
start.setText(String.valueOf(info.start));
pos.setText(String.valueOf(info.pos));
end.setText(String.valueOf(info.end));
}
JTextField addListener(final JTextField f) {
f.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
body.setCaretPosition(Integer.valueOf(f.getText()));
body.getCaret().setVisible(true);
}
});
return f;
}
Info info;
JTextField tagName;
JTextField start;
JTextField pos;
JTextField end;
}
/** Object to record information about an error to be displayed. */
private class Entry {
Entry(JavaFileObject file, String check, Info encl, Info self) {
this.file = file;
this.check = check;
this.encl = encl;
this.self= self;
}
@Override
public String toString() {
return file.getName() + " " + check + " " + getMinPos(encl, self);
}
final JavaFileObject file;
final String check;
final Info encl;
final Info self;
}
}
}
| 29,520 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6923080.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/T6923080.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.
*/
/*
* This file is not a regular test, but is processed by ./TreeScannerTest.java,
* which verifies the operation of the javac TreeScanner.
* @bug 6923080
* @summary TreeScanner.visitNewClass should scan tree.typeargs
*/
class T6923080 {
void test() {
C c = new <Integer>C(); // exercises TreeScanner.visitNewClass
Object o = c.<Float>m(); // exercises TreeScanner.visitApply
}
static class C {
<T> C() { }
<T> T m() { return null; }
}
}
| 1,546 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6993305.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/T6993305.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.
*/
/*
* @test
* @bug 6993305
* @summary starting position of a method without modifiers and with type parameters is incorrect
*/
import java.io.File;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.MethodTree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreeScanner;
import com.sun.source.util.Trees;
import com.sun.tools.javac.api.JavacTool;
import java.io.IOException;
/*
* Test verifies the starting position of all methods by computing the start position
* of each method as the first non-white character on the first line containing
* (" " + methodName + "("), and then comparing this value against the reported
* value in the SourcePositions table.
*/
public class T6993305 {
<T> void test1(T t) { } // this is the primary case to be tested
public <T> void test2(T t) { }
@Deprecated <T> void test3(T t) { }
public static void main(String... args) throws Exception {
new T6993305().run();
}
void run() throws Exception {
File testSrc = new File(System.getProperty("test.src"));
JavacTool tool = JavacTool.create();
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
File f = new File(testSrc, T6993305.class.getSimpleName() + ".java");
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(f);
JavacTask task = tool.getTask(null, fm, null, null, null, fos);
Iterable<? extends CompilationUnitTree> cus = task.parse();
TestScanner s = new TestScanner();
s.scan(cus, task);
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
int errors;
class TestScanner extends TreeScanner<Void, JavacTask> {
CompilationUnitTree cu;
SourcePositions sourcePositions;
String source;
void show(String label, int pos) {
System.err.println(label + ": " +
source.substring(pos, Math.min(source.length(), pos + 10)));
}
@Override public Void visitCompilationUnit(CompilationUnitTree tree, JavacTask task) {
cu = tree;
Trees trees = Trees.instance(task);
sourcePositions = trees.getSourcePositions();
try {
source = String.valueOf(tree.getSourceFile().getCharContent(true));
} catch (IOException e) {
throw new Error(e);
}
return super.visitCompilationUnit(tree, task);
}
// this is the core of the test
@Override public Void visitMethod(MethodTree tree, JavacTask task) {
String name = String.valueOf(tree.getName());
int pos = source.indexOf(" " + name + "(");
while (source.charAt(pos - 1) != '\n') pos--;
while (source.charAt(pos) == ' ') pos++;
int expectedStart = pos;
int reportedStart = (int) sourcePositions.getStartPosition(cu, tree);
System.err.println("Method " + name
+ " expectedStart:" + expectedStart
+ " reportedStart:" + reportedStart);
if (expectedStart != reportedStart) {
error("Unexpected value for " + name);
show("expected", expectedStart);
show("reported", reportedStart);
}
return super.visitMethod(tree, task);
}
}
}
| 4,695 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SourceTreeScannerTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/SourceTreeScannerTest.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.
*/
/**
* Utility and test program to check javac's internal TreeScanner class.
* The program can be run standalone, or as a jtreg test. For info on
* command line args, run program with no args.
*
* <p>
* jtreg: Note that by using the -r switch in the test description below, this test
* will process all java files in the langtools/test directory, thus implicitly
* covering any new language features that may be tested in this test suite.
*/
/*
* @test
* @bug 6923080
* @summary TreeScanner.visitNewClass should scan tree.typeargs
* @build AbstractTreeScannerTest SourceTreeScannerTest
* @run main SourceTreeScannerTest -q -r .
*/
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import javax.tools.*;
import com.sun.source.tree.Tree;
import com.sun.source.util.TreeScanner;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.TypeBoundKind;
import com.sun.tools.javac.util.List;
public class SourceTreeScannerTest extends AbstractTreeScannerTest {
/**
* Main entry point.
* If test.src is set, program runs in jtreg mode, and will throw an Error
* if any errors arise, otherwise System.exit will be used. In jtreg mode,
* the default base directory for file args is the value of ${test.src}.
* In jtreg mode, the -r option can be given to change the default base
* directory to the root test directory.
*/
public static void main(String... args) {
String testSrc = System.getProperty("test.src");
File baseDir = (testSrc == null) ? null : new File(testSrc);
boolean ok = new SourceTreeScannerTest().run(baseDir, args);
if (!ok) {
if (testSrc != null) // jtreg mode
throw new Error("failed");
else
System.exit(1);
}
}
int test(JCCompilationUnit tree) {
return new ScanTester().test(tree);
}
/**
* Main class for testing operation of tree scanner.
* The set of nodes found by the scanner are compared
* against the set of nodes found by reflection.
*/
private class ScanTester extends TreeScanner<Void,Void> {
/** Main entry method for the class. */
int test(JCCompilationUnit tree) {
sourcefile = tree.sourcefile;
found = new HashSet<Tree>();
scan(tree, null);
expect = new HashSet<Tree>();
reflectiveScan(tree);
if (found.equals(expect)) {
//System.err.println(sourcefile.getName() + ": trees compared OK");
return found.size();
}
error(sourcefile.getName() + ": differences found");
if (found.size() != expect.size())
error("Size mismatch; found: " + found.size() + ", expected: " + expect.size());
Set<Tree> missing = new HashSet<Tree>();
missing.addAll(expect);
missing.removeAll(found);
for (Tree t: missing)
error(sourcefile, t, "missing");
Set<Tree> excess = new HashSet<Tree>();
excess.addAll(found);
excess.removeAll(expect);
for (Tree t: excess)
error(sourcefile, t, "unexpected");
return 0;
}
/** Record all tree nodes found by scanner. */
@Override
public Void scan(Tree tree, Void ignore) {
if (tree == null)
return null;
//System.err.println("FOUND: " + tree.getKind() + " " + trim(tree, 64));
found.add(tree);
return super.scan(tree, ignore);
}
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
if (o == null)
return;
if (o instanceof JCTree) {
JCTree tree = (JCTree) o;
//System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
expect.add(tree);
for (Field f: getFields(tree)) {
if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
// not part of public API
continue;
}
if (JCTree.JCNewArray.class.isAssignableFrom(tree.getClass())
&& (f.getName().equals("annotations")
|| f.getName().equals("dimAnnotations"))) {
// these fields are incorrectly missing from the public API
// (CR 6983297)
continue;
}
try {
//System.err.println("FIELD: " + f.getName());
reflectiveScan(f.get(tree));
} catch (IllegalAccessException e) {
error(e.toString());
}
}
} else if (o instanceof List) {
List<?> list = (List<?>) o;
for (Object item: list)
reflectiveScan(item);
} else
error("unexpected item: " + o);
}
JavaFileObject sourcefile;
Set<Tree> found;
Set<Tree> expect;
}
}
| 6,379 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestAnnotatedAnonClass.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/TestAnnotatedAnonClass.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.
*/
/*
* This file is not a regular test, but is processed by ./TreePosTest.java,
* which verifies the position info in the javac tree.
* To run the test standalone, compile TreePosTest, then run TreePosTest
* on this file.
* @bug 6931927
* @summary position issues with synthesized anonymous class
*/
class TestAnnotatedAnonClass {
void m() {
Object o = new @Deprecated Object() { };
}
}
| 1,461 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractTreeScannerTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/AbstractTreeScannerTest.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.*;
import java.lang.reflect.*;
import java.util.*;
import javax.tools.*;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.List;
public abstract class AbstractTreeScannerTest {
/**
* Run the program. A base directory can be provided for file arguments.
* In jtreg mode, the -r option can be given to change the default base
* directory to the test root directory. For other options, see usage().
* @param baseDir base directory for any file arguments.
* @param args command line args
* @return true if successful or in gui mode
*/
boolean run(File baseDir, String... args) {
if (args.length == 0) {
usage(System.out);
return true;
}
ArrayList<File> files = new ArrayList<File>();
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals("-q"))
quiet = true;
else if (arg.equals("-v"))
verbose = true;
else if (arg.equals("-r")) {
File d = baseDir;
while (!new File(d, "TEST.ROOT").exists()) {
d = d.getParentFile();
if (d == null)
throw new Error("cannot find TEST.ROOT");
}
baseDir = d;
}
else if (arg.startsWith("-"))
throw new Error("unknown option: " + arg);
else {
while (i < args.length)
files.add(new File(baseDir, args[i++]));
}
}
for (File file: files) {
if (file.exists())
test(file);
else
error("File not found: " + file);
}
if (fileCount != 1)
System.err.println(fileCount + " files read");
System.err.println(treeCount + " tree nodes compared");
if (errors > 0)
System.err.println(errors + " errors");
return (errors == 0);
}
/**
* Print command line help.
* @param out output stream
*/
void usage(PrintStream out) {
out.println("Usage:");
out.println(" java " + getClass().getName() + " options... files...");
out.println("");
out.println("where options include:");
out.println("-q Quiet: don't report on inapplicable files");
out.println("-v Verbose: report on files as they are being read");
out.println("");
out.println("files may be directories or files");
out.println("directories will be scanned recursively");
out.println("non java files, or java files which cannot be parsed, will be ignored");
out.println("");
}
/**
* Test a file. If the file is a directory, it will be recursively scanned
* for java files.
* @param file the file or directory to test
*/
void test(File file) {
if (file.isDirectory()) {
for (File f: file.listFiles()) {
test(f);
}
return;
}
if (file.isFile() && file.getName().endsWith(".java")) {
try {
if (verbose)
System.err.println(file);
fileCount++;
treeCount += test(read(file));
} catch (ParseException e) {
if (!quiet) {
error("Error parsing " + file + "\n" + e.getMessage());
}
} catch (IOException e) {
error("Error reading " + file + ": " + e);
}
return;
}
if (!quiet)
error("File " + file + " ignored");
}
abstract int test(JCCompilationUnit t);
// See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Reporter r = new Reporter(pw);
JavacTool tool = JavacTool.create();
StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
/**
* Read a file.
* @param file the file to be read
* @return the tree for the content of the file
* @throws IOException if any IO errors occur
* @throws TreePosTest.ParseException if any errors occur while parsing the file
*/
JCCompilationUnit read(File file) throws IOException, ParseException {
JavacTool tool = JavacTool.create();
r.errors = 0;
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
Iterable<? extends CompilationUnitTree> trees = task.parse();
pw.flush();
if (r.errors > 0)
throw new ParseException(sw.toString());
Iterator<? extends CompilationUnitTree> iter = trees.iterator();
if (!iter.hasNext())
throw new Error("no trees found");
JCCompilationUnit t = (JCCompilationUnit) iter.next();
if (iter.hasNext())
throw new Error("too many trees found");
return t;
}
/**
* Report an error. When the program is complete, the program will either
* exit or throw an Error if any errors have been reported.
* @param msg the error message
*/
void error(String msg) {
System.err.println(msg);
errors++;
}
/**
* Report an error. When the program is complete, the program will either
* exit or throw an Error if any errors have been reported.
* @param msg the error message
*/
void error(JavaFileObject file, String msg) {
System.err.println(file.getName() + ": " + msg);
errors++;
}
/**
* Report an error for a specific tree node.
* @param file the source file for the tree
* @param t the tree node
* @param label an indication of the error
*/
void error(JavaFileObject file, Tree tree, String msg) {
JCTree t = (JCTree) tree;
error(file.getName() + ":" + getLine(file, t) + ": " + msg + " " + trim(t, 64));
}
/**
* Get a trimmed string for a tree node, with normalized white space and limited length.
*/
String trim(Tree tree, int len) {
JCTree t = (JCTree) tree;
String s = t.toString().replaceAll("\\s+", " ");
return (s.length() < len) ? s : s.substring(0, len);
}
/** Number of files that have been analyzed. */
int fileCount;
/** Number of trees that have been successfully compared. */
int treeCount;
/** Number of errors reported. */
int errors;
/** Flag: don't report irrelevant files. */
boolean quiet;
/** Flag: report files as they are processed. */
boolean verbose;
/**
* Thrown when errors are found parsing a java file.
*/
private static class ParseException extends Exception {
ParseException(String msg) {
super(msg);
}
}
/**
* DiagnosticListener to report diagnostics and count any errors that occur.
*/
private static class Reporter implements DiagnosticListener<JavaFileObject> {
Reporter(PrintWriter out) {
this.out = out;
}
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
out.println(diagnostic);
switch (diagnostic.getKind()) {
case ERROR:
errors++;
}
}
int errors;
PrintWriter out;
}
/**
* Get the set of fields for a tree node that may contain child tree nodes.
* These are the fields that are subtypes of JCTree or List.
* The results are cached, based on the tree's tag.
*/
Set<Field> getFields(JCTree tree) {
Set<Field> fields = map.get(tree.getTag());
if (fields == null) {
fields = new HashSet<Field>();
for (Field f: tree.getClass().getFields()) {
Class<?> fc = f.getType();
if (JCTree.class.isAssignableFrom(fc) || List.class.isAssignableFrom(fc))
fields.add(f);
}
map.put(tree.getTag(), fields);
}
return fields;
}
// where
Map<Integer, Set<Field>> map = new HashMap<Integer,Set<Field>>();
/** Get the line number for the primary position for a tree.
* The code is intended to be simple, although not necessarily efficient.
* However, note that a file manager such as JavacFileManager is likely
* to cache the results of file.getCharContent, avoiding the need to read
* the bits from disk each time this method is called.
*/
int getLine(JavaFileObject file, JCTree tree) {
try {
CharSequence cs = file.getCharContent(true);
int line = 1;
for (int i = 0; i < tree.pos; i++) {
if (cs.charAt(i) == '\n') // jtreg tests always use Unix line endings
line++;
}
return line;
} catch (IOException e) {
return -1;
}
}
}
| 10,471 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
MakeLiteralTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/MakeLiteralTest.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.
*/
/*
* @test
* @bug 6504896
* @summary TreeMaker.Literal(Object) does not support Booleans
*/
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.tree.JCTree.JCLiteral;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.tree.TreeMaker;
import static com.sun.tools.javac.code.TypeTags.*;
public class MakeLiteralTest {
public static void main(String... args) throws Exception {
new MakeLiteralTest().run();
}
void run() throws Exception {
Context context = new Context();
JavacFileManager.preRegister(context);
Symtab syms = Symtab.instance(context);
maker = TreeMaker.instance(context);
types = Types.instance(context);
test("abc", CLASS, syms.stringType, "abc");
test(Boolean.FALSE, BOOLEAN, syms.booleanType, Integer.valueOf(0));
test(Boolean.TRUE, BOOLEAN, syms.booleanType, Integer.valueOf(1));
test(Byte.valueOf((byte) 1), BYTE, syms.byteType, Byte.valueOf((byte) 1));
test(Character.valueOf('a'), CHAR, syms.charType, Integer.valueOf('a'));
test(Double.valueOf(1d), DOUBLE, syms.doubleType, Double.valueOf(1d));
test(Float.valueOf(1f), FLOAT, syms.floatType, Float.valueOf(1f));
test(Integer.valueOf(1), INT, syms.intType, Integer.valueOf(1));
test(Long.valueOf(1), LONG, syms.longType, Long.valueOf(1));
test(Short.valueOf((short) 1), SHORT, syms.shortType, Short.valueOf((short) 1));
if (errors > 0)
throw new Exception(errors + " errors found");
}
void test(Object value, int tag, Type type, Object constValue) {
JCLiteral l = maker.Literal(value);
if (l.type.tag != tag)
error("unexpected tag: " + l.getTag() + ": expected: " + tag);
if (!types.isSameType(l.type, type))
error("unexpected type: " + l.type + ": expected: " + type);
if (l.type.constValue().getClass() != constValue.getClass()
|| !constValue.equals(l.type.constValue())) {
error("unexpected const value: "
+ l.type.constValue().getClass() + " " + l.type.constValue()
+ ": expected:" + constValue.getClass() + " " + constValue);
}
}
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
TreeMaker maker;
Types types;
int errors;
}
| 3,762 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TreePosRoundsTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/tree/TreePosRoundsTest.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.
*/
/*
* @test
* @bug 6985205 6986246
* @summary access to tree positions and doc comments may be lost across annotation processing rounds
* @build TreePosRoundsTest
* @compile -proc:only -processor TreePosRoundsTest TreePosRoundsTest.java
* @run main TreePosRoundsTest
*/
import java.io.*;
import java.util.*;
import javax.annotation.processing.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;
import javax.tools.JavaCompiler.CompilationTask;
// This test is an annotation processor that performs multiple rounds of
// processing, and on each round, it checks that source positions are
// available and correct.
//
// The test can be run directly as a processor from the javac command line
// or via JSR 199 by invoking the main program.
@SupportedAnnotationTypes("*")
public class TreePosRoundsTest extends AbstractProcessor {
public static void main(String... args) throws Exception {
String testSrc = System.getProperty("test.src");
String testClasses = System.getProperty("test.classes");
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
String thisName = TreePosRoundsTest.class.getName();
File thisFile = new File(testSrc, thisName + ".java");
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
List<String> options = Arrays.asList(
"-proc:only",
"-processor", thisName,
"-processorpath", testClasses);
CompilationTask t = c.getTask(null, fm, null, options, null, files);
boolean ok = t.call();
if (!ok)
throw new Exception("processing failed");
}
Filer filer;
Messager messager;
Trees trees;
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
@Override
public void init(ProcessingEnvironment pEnv) {
super.init(pEnv);
filer = pEnv.getFiler();
messager = pEnv.getMessager();
trees = Trees.instance(pEnv);
}
int round = 0;
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
round++;
// Scan trees for elements, verifying source tree positions
for (Element e: roundEnv.getRootElements()) {
try {
TreePath p = trees.getPath(e);
new TestTreeScanner(p.getCompilationUnit(), trees).scan(trees.getPath(e), null);
} catch (IOException ex) {
messager.printMessage(Diagnostic.Kind.ERROR,
"Cannot get source: " + ex, e);
}
}
final int MAXROUNDS = 3;
if (round < MAXROUNDS)
generateSource("Gen" + round);
return true;
}
void generateSource(String name) {
StringBuilder text = new StringBuilder();
text.append("class ").append(name).append("{\n");
text.append(" int one = 1;\n");
text.append(" int two = 2;\n");
text.append(" int three = one + two;\n");
text.append("}\n");
try {
JavaFileObject fo = filer.createSourceFile(name);
Writer out = fo.openWriter();
try {
out.write(text.toString());
} finally {
out.close();
}
} catch (IOException e) {
throw new Error(e);
}
}
class TestTreeScanner extends TreePathScanner<Void,Void> {
TestTreeScanner(CompilationUnitTree unit, Trees trees) throws IOException {
this.unit = unit;
JavaFileObject sf = unit.getSourceFile();
source = sf.getCharContent(true).toString();
sourcePositions = trees.getSourcePositions();
}
@Override
public Void visitVariable(VariableTree tree, Void _) {
check(getCurrentPath());
return super.visitVariable(tree, _);
}
void check(TreePath tp) {
Tree tree = tp.getLeaf();
String expect = tree.toString();
if (tree.getKind() == Tree.Kind.VARIABLE) {
// tree.toString() does not know enough context to add ";",
// so deal with that manually...
Tree.Kind enclKind = tp.getParentPath().getLeaf().getKind();
//System.err.println(" encl: " +enclKind);
if (enclKind == Tree.Kind.CLASS || enclKind == Tree.Kind.BLOCK)
expect += ";";
}
//System.err.println("expect: " + expect);
int start = (int)sourcePositions.getStartPosition(unit, tree);
if (start == Diagnostic.NOPOS) {
messager.printMessage(Diagnostic.Kind.ERROR, "start pos not set for " + trim(tree));
return;
}
int end = (int)sourcePositions.getEndPosition(unit, tree);
if (end == Diagnostic.NOPOS) {
messager.printMessage(Diagnostic.Kind.ERROR, "end pos not set for " + trim(tree));
return;
}
String found = source.substring(start, end);
//System.err.println(" found: " + found);
// allow for long lines, in which case just compare beginning and
// end of the strings
boolean equal;
if (found.contains("\n")) {
String head = found.substring(0, found.indexOf("\n"));
String tail = found.substring(found.lastIndexOf("\n")).trim();
equal = expect.startsWith(head) && expect.endsWith(tail);
} else {
equal = expect.equals(found);
}
if (!equal) {
messager.printMessage(Diagnostic.Kind.ERROR,
"unexpected value found: '" + found + "'; expected: '" + expect + "'");
}
}
String trim(Tree tree) {
final int MAXLEN = 32;
String s = tree.toString().replaceAll("\\s+", " ").trim();
return (s.length() < MAXLEN) ? s : s.substring(0, MAXLEN);
}
CompilationUnitTree unit;
SourcePositions sourcePositions;
String source;
}
}
| 7,450 | 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/6996626/Main.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.
*/
/* @test
* @bug 6996626
* @summary Scope fix issues for ImportScope
* @compile pack1/Symbol.java
* @compile Main.java
*/
import pack1.*;
import pack1.Symbol.*;
// The following imports are just to trigger re-hashing (in
// com.sun.tools.javac.code.Scope.dble()) of the star-import scope.
import java.io.*;
import java.net.*;
import java.util.*;
public class Main {
public void main (String[] args) {
throw new CompletionFailure();
}
}
| 1,512 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Symbol.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6996626/pack1/Symbol.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.
*/
package pack1;
public class Symbol {
public static class CompletionFailure extends RuntimeException { }
}
| 1,165 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NestedEnum.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/NestedEnum.java | /*
* Copyright (c) 2004, 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 5071831
* @summary javac allows enum in an inner class
* @author gafter
*
* @compile/fail NestedEnum.java
*/
class NestedEnum {
class Inner {
enum NotAllowedInNonStaticInner {}
}
}
| 1,275 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumSwitch2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumSwitch2.java | /*
* Copyright (c) 2003, 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 4936393
* @summary enum switch case labels required to be unqualified.
* @author gafter
*
* @compile/fail EnumSwitch2.java
*/
package enumswitch2;
enum E1 { a, b, c, d, e }
class EnumSwitch2 {
void f(E1 e1) {
switch (e1) {
case E1.a:
case E1.d:
default:
break;
}
}
}
| 1,407 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T5081785c.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T5081785c.java | /*
* Copyright (c) 2004, 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 A {
class B {
enum C { X, Y, Z }
}
}
| 1,111 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumPrivateConstructor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumPrivateConstructor.java | /*
* Copyright (c) 2004, 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 5009601
* @summary enum constructors can be declared private
* @author Joseph D. Darcy
*
* @compile EnumPrivateConstructor.java
*/
enum EnumPrivateConstructor {
RED(255, 0, 0),
GREEN(0, 255, 0),
BLUE(0, 0, 255);
private int r, g, b;
private EnumPrivateConstructor(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
}
}
| 1,454 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Def.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/Def.java | /*
* Copyright (c) 2004, 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 5051679
* @summary constant static fields cannot be referenced from const, instance initializers
* @author gafter
*
* @compile Def.java
*/
package _enum.def;
enum Def {
red;
{
int i = 4;
switch (i) {
case N: break;
}
}
public final static int N = 12;
Def() {
k = N;
}
int k;
}
| 1,428 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
UserValue.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/UserValue.java | /*
* Copyright (c) 2003, 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 4901558
* @summary compiler crash on user-defined valueOf in enum
* @author gafter
*
* @compile UserValue.java
*/
public enum UserValue {
UP(0),
DOWN(1);
final int oldMode;
private UserValue(int mode) {
this.oldMode = mode;
}
public static UserValue valueOf(int rm) {
return UP;
}
}
| 1,408 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FauxEnum3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/FauxEnum3.java | /*
* Copyright (c) 2004, 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 5009574
* @summary verify an enum type can't be directly subclassed
* @author Joseph D. Darcy
*
* @compile/fail FauxEnum3.java
*/
public class FauxEnum3 extends SpecializedEnum {
}
enum SpecializedEnum {
RED {
boolean special() {return true;}
},
GREEN,
BLUE;
boolean special() {return false;}
}
| 1,402 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
OkFinal.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/OkFinal.java | /*
* Copyright (c) 2004, 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 5097250
* @summary Finalize methods on enums must be compile time error
* @author Peter von der Ah\u00e9
*/
public enum OkFinal {
A {
protected void finalize(Void nil) {
System.out.println("FISK");
}
};
public static void main(String[] args) {
System.out.println("HEST");
}
}
| 1,411 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FauxEnum1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/FauxEnum1.java | /*
* Copyright (c) 2004, 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 5009574
* @summary verify java.lang.Enum can't be directly subclassed
* @author Joseph D. Darcy
*
* @compile/fail FauxEnum1.java
*/
public class FauxEnum1 extends java.lang.Enum {
private FauxEnum1() {
// super("", 0);
}
}
| 1,317 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Enum3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/Enum3.java | /*
* Copyright (c) 2003, 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 4945532
* @summary enums: test switch
* @author gafter
*/
public enum Enum3 {
red, green, blue;
public static void main(String[] args) {
for (int i=0; i<3; i++) {
Enum3 v = values()[i];
switch (v) {
case red:
if (i == 0) continue;
break;
case green:
if (i == 1) continue;
break;
case blue:
if (i == 2) continue;
break;
default:
break;
}
throw new Error();
}
}
}
| 1,675 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T5075242.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T5075242.java | /*
* Copyright (c) 2004, 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 5075242
* @summary Cannot make compound type involving Enums
* @author Peter von der Ah\u00e9
*
* @compile T5075242.java
*/
interface Iface {
<T extends Enum<T> & Iface> void doThis(T e);
}
| 1,272 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumSwitch1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumSwitch1.java | /*
* Copyright (c) 2003, 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 4936393
* @summary enum switch case labels required to be unqualified.
* @author gafter
*
* @compile EnumSwitch1.java
*/
package enumswitch1;
enum E1 { a, b, c, d, e }
class EnumSwitch1 {
void f(E1 e1) {
switch (e1) {
case a:
case d:
default:
break;
}
}
}
| 1,396 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractEnum1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/AbstractEnum1.java | /*
* Copyright (c) 2004, 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 5054976
* @summary compiler fails to flag an enum abstract
* @author gafter
*/
import java.lang.reflect.Modifier;
public enum AbstractEnum1 implements AE1_I {
toto {
public void m() {
}
}
;
public static void main(String[] args) {
if (!Modifier.isAbstract(AbstractEnum1.class.getModifiers()))
throw new Error();
}
}
interface AE1_I {
void m();
}
| 1,484 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ValueOf.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/ValueOf.java | /*
* Copyright (c) 2003, 2004, 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 4872708 5058132
* @summary Improper signature for valueOf
* @author gafter
*/
public enum ValueOf {
a, b, c, d, e;
public static void main(String[] args) {
String[] names = {"b", "a"};
if (valueOf("a") != a) throw new Error();
if (valueOf("d") != d) throw new Error();
if (valueOf("e") != e) throw new Error();
try {
ValueOf f = valueOf("f");
throw new Error();
} catch (IllegalArgumentException ex) {
}
}
}
| 1,582 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FauxSpecialEnum1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/FauxSpecialEnum1.java | /*
* Copyright (c) 2004, 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 5009601
* @summary verify specialized enum classes can't be abstract
* @author Joseph D. Darcy
*
* @compile/fail FauxSpecialEnum1.java
*/
public enum FauxSpecialEnum1 {
INFRARED {
void test() {System.out.println("Concrete test");}
},
ULTRAVIOLET {
abstract void test();
};
abstract void test();
}
| 1,411 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6675483.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T6675483.java | /*
* Copyright (c) 2008, 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 6675483
*
* @summary Javac rejects multiple type-variable bound declarations starting with an enum type
* @author Maurizio Cimadamore
*
* @compile T6675483.java
*/
public class T6675483 {
enum E implements Comparable<E> {}
interface C<T extends E & Comparable<E>> {
<S extends E & Comparable<E>> void m();
}
}
| 1,410 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExplicitlyFinalEnum2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.java | /*
* Copyright (c) 2004, 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 5009601
* @summary enum's cannot be explicitly declared final
* @author Joseph D. Darcy
*
* @compile/fail ExplicitlyFinalEnum2.java
*/
final enum ExplicitlyFinalEnum2 {
FE {
void foo() {return;}
};
abstract void foo();
}
| 1,320 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
DA2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/DA2.java | /*
* Copyright (c) 2004, 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 5023177
* @summary One can refer static, const static variables from instance initializers of enum
* @author gafter
*
* @compile/fail DA2.java
*/
package da2;
enum T2 {
;
static int N = 12;
{
int M = N;
}
}
| 1,310 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExplicitlyFinalEnum1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.java | /*
* Copyright (c) 2004, 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 5009601
* @summary enum's cannot be explicitly declared final even if they are
* @author Joseph D. Darcy
*
* @compile/fail ExplicitlyFinalEnum1.java
*/
final enum ExplicitlyFinalEnum1 {
FE,
FI,
FO,
FUM;
}
| 1,299 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Enum1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/Enum1.java | /*
* Copyright (c) 2003, 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 4945532
* @summary enums: test output of values().toString()
* @author gafter
*/
import java.util.*;
public enum Enum1 {
red, green, blue;
public static void main(String[] args) {
if (!Arrays.asList(values()).toString().equals("[red, green, blue]"))
throw new Error();
}
}
| 1,383 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NoFinal.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/NoFinal.java | /*
* Copyright (c) 2004, 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 5097250 5087624
* @summary Finalize methods on enums must be compile time error
* @author Peter von der Ah\u00e9
* @compile/fail NoFinal.java
*/
enum NoFinal {
A {
protected void finalize() {
System.err.println("FISK");
}
};
}
| 1,346 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SynthValues.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/SynthValues.java | /*
* Copyright (c) 2004, 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 4984627
* @summary Enums: +VALUES field has no synthetic attribute
* @author gafter
*/
public enum SynthValues {
red, blue, green;
SynthValues[] $VALUES = null; // test for conflict with synth.
public static void main(String[] args) {
for (SynthValues t : values()) {
System.out.println(t);
}
}
}
| 1,417 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
DA1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/DA1.java | /*
* Copyright (c) 2004, 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 5023177
* @summary One can refer static, const static variables from instance initializers of enum
* @author gafter
*
* @compile/fail DA1.java
*/
package da1;
enum T1 {
;
static int N = 12;
int M = N;
}
| 1,294 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T5081785.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T5081785.java | /*
* Copyright (c) 2004, 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 5081785
*
* @summary Empty Enums allowed in non-static contexts
* @author Peter von der Ah\u00e9
*
* @compile/fail T5081785.java
* @compile/fail T5081785a.java
* @compile/fail T5081785b.java
* @compile/fail T5081785c.java
*/
class A {
public void check() {
class Foo {
enum STRENGTH{};
};
}
}
| 1,411 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExplicitlyAbstractEnum2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.java | /*
* Copyright (c) 2004, 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 5009601
* @summary enum's cannot be explicitly declared abstract even if they are abstract
* @author Joseph D. Darcy
*
* @compile/fail ExplicitlyAbstractEnum2.java
*/
abstract enum ExplicitlyAbstractEnum2 {
FE {
void foo() {return;}
};
abstract void foo();
}
| 1,358 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FauxSpecialEnum2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/FauxSpecialEnum2.java | /*
* Copyright (c) 2004, 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 5009601
* @summary verify specialized enum classes can't be abstract
* @author Joseph D. Darcy
*
* @compile/fail FauxSpecialEnum2.java
*/
public enum FauxSpecialEnum2 {
XRAY,
GAMMA {
abstract void test();
};
}
| 1,308 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumSwitch3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumSwitch3.java | /*
* Copyright (c) 2004, 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 4975914
* @summary javac crash when enum defined after use
* @author gafter
*
* @compile EnumSwitch3.java
*/
package enumswitch3;
class Test
{
public static void main(String[] args)
{
TestEnum e = TestEnum.A;
switch (e)
{
case A: System.out.println("A = A"); break;
case B: System.out.println("B = B"); break;
default: System.out.println("C = C"); break;
}
}
}
enum TestEnum
{
A, B, C;
}
| 1,551 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractEmptyEnum.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/AbstractEmptyEnum.java | /*
* Copyright (c) 2004, 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 5009601
* @summary empty enum cannot be abstract
* @author Joseph D. Darcy
*
* @compile/fail AbstractEmptyEnum.java
*/
public enum AbstractEmptyEnum {
;
abstract void m();
}
| 1,260 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6724345.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T6724345.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 6724345
*
* @summary incorrect method resolution for enum classes entered as source files
* @author Maurizio Cimadamore
*
* @compile T6509042.java
*/
class T6724345 {
interface I {
void i();
}
class U {
{
I i = E.V;
i.i();
E.V.i();
}
}
enum E implements I {
V {public void i() {}};
}
}
| 1,454 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
DA3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/DA3.java | /*
* Copyright (c) 2004, 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 5023177
* @summary One can refer static, const static variables from instance initializers of enum
* @author gafter
*
* @compile/fail DA3.java
*/
package da3;
enum T3 {
;
static int N = 12;
T3() {
int M = N;
}
}
| 1,315 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T5081785b.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T5081785b.java | /*
* Copyright (c) 2004, 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 A {
Object o = new Object() { enum STRENGTH{}; };
}
| 1,114 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6509042.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T6509042.java | /*
* Copyright (c) 2008, 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 6509042
*
* @summary javac rejects class literals in enum constructors
* @author Maurizio Cimadamore
*
* @compile T6509042.java
*/
enum T6509042 {
A, B;
Class<T6509042> cl = T6509042.class;
T6509042() {
Class<T6509042> cl2 = T6509042.class;
}
}
| 1,354 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T5081785a.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/T5081785a.java | /*
* Copyright (c) 2004, 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 A {
public A check() {
return new A() { enum STRENGTH{}; };
}
}
| 1,138 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumSwitch4.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumSwitch4.java | /*
* Copyright (c) 2004, 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 5006662
* @summary enum switch on null fails to throw NullPointerException
* @author gafter
*/
public enum EnumSwitch4 {
foo, bar, baz;
public static void main(String[] args) {
EnumSwitch4 e = null;
try {
switch (e) {
default: break;
}
throw new Error("failed to throw NullPointerException");
} catch (NullPointerException ex) {
System.out.println("passed");
}
}
}
| 1,546 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FauxEnum2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/FauxEnum2.java | /*
* Copyright (c) 2004, 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 5009574
* @summary verify java.lang.Enum can't be directly subclassed
* @author Joseph D. Darcy
*
* @compile/fail -source 1.4 FauxEnum2.java
*/
public class FauxEnum2 extends java.lang.Enum {
FauxEnum2() {
super("", 0);
}
}
| 1,318 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumProtectedConstructor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumProtectedConstructor.java | /*
* Copyright (c) 2004, 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 5009601
* @summary enum constructors cannot be declared public or protected
* @author Joseph D. Darcy
*
* @compile/fail EnumProtectedConstructor.java
*/
enum EnumProtectedConstructor {
RED(255, 0, 0),
GREEN(0, 255, 0),
BLUE(0, 0, 255);
private int r, g, b;
protected EnumProtectedConstructor(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
}
}
| 1,482 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumPublicConstructor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumPublicConstructor.java | /*
* Copyright (c) 2004, 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 5009601
* @summary enum constructors cannot be declared public or protected
* @author Joseph D. Darcy
*
* @compile/fail EnumPublicConstructor.java
*/
enum EnumPublicConstructor {
RED(255, 0, 0),
GREEN(0, 255, 0),
BLUE(0, 0, 255);
private int r, g, b;
public EnumPublicConstructor(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
}
}
| 1,470 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExplicitlyAbstractEnum1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.java | /*
* Copyright (c) 2004, 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 5009601
* @summary enum's cannot be explicitly declared abstract
* @author Joseph D. Darcy
*
* @compile/fail ExplicitlyAbstractEnum1.java
*/
abstract enum ExplicitlyAbstractEnum1 {
FE,
FI,
FO,
FUM;
}
| 1,294 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NoFinal2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/NoFinal2.java | /*
* Copyright (c) 2004, 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 5097250 5087624
* @summary Finalize methods on enums must be compile time error
* @author Peter von der Ah\u00e9
* @compile/fail NoFinal2.java
*/
enum NoFinal2 {
A, B, C;
protected void finalize() {
System.err.println("FISK");
}
}
| 1,334 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumImplicitPrivateConstructor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumImplicitPrivateConstructor.java | /*
* Copyright (c) 2004, 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 5009601 5010455 5005748
* @summary enum constructors can be declared private
* @author Joseph D. Darcy
*/
import java.util.*;
import java.lang.reflect.*;
import java.lang.annotation.*;
/*
* Arguably, only the final and abstract should be held in
* ExpectedModifiers; whether or not an enum should be static could be
* inferred from getDeclaringClass and working versions of
* getEnclosingMethod and getEnclosingConstructor. I.e. if
* getDeclaringClass, getEnclosingMethod, and getEnclosingConstructor
* were all null, the enum is a top-level class and should not be
* static; otherwise, it should be static.
*/
@ExpectedModifiers(Modifier.FINAL)
public enum EnumImplicitPrivateConstructor {
RED(255, 0, 0),
GREEN(0, 255, 0),
BLUE(0, 0, 255);
private int r, g, b;
EnumImplicitPrivateConstructor(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
}
/*
* Using reflection, Verify that
* 1. all non-synthetic constructors of enum classes are marked as private.
* 2. top-level enum classes are marked as static
* 3. enum's are marked final and abstract as appropriate
* 4. enum constructors *cannot* be invoked reflectively
*/
public static void main(String argv[]) throws Exception {
boolean passed = true;
Collection<Class> classes = new LinkedHashSet<Class>();
classes.add(Class.forName("EnumImplicitPrivateConstructor"));
classes.add(Class.forName("EnumImplicitPrivateConstructor$AnotherEnum"));
classes.add(Class.forName("EnumImplicitPrivateConstructor$YetAnotherEnum"));
classes.add(Class.forName("EnumImplicitPrivateConstructor$OneMoreEnum"));
// Add classes of specialized enum constants
for(Enum e: YetAnotherEnum.values())
classes.add(e.getClass());
for(Class clazz: classes) {
System.out.println("Testing class " + clazz);
int classModifiers = clazz.getModifiers();
// Why is this cast needed?
ExpectedModifiers em = (ExpectedModifiers)clazz.getAnnotation(ExpectedModifiers.class);
if (em != null) {
System.out.println("\tTesting expected modifiers");
int expected = em.value();
if (expected != (classModifiers & (Modifier.ABSTRACT|Modifier.FINAL|Modifier.STATIC))) {
passed = false;
System.out.println("\tFAILED: Expected 0x" + Integer.toHexString(expected) +
" got 0x" +Integer.toHexString(classModifiers));
}
}
for(Constructor ctor: clazz.getDeclaredConstructors() ) {
System.out.println("\tTesting constructor " + ctor);
// We don't need no stinkin' access rules
try {
ctor.setAccessible(true);
} catch (java.security.AccessControlException ex) {
}
int modifiers = ctor.getModifiers();
/*
* If clazz is for a specialized enum constant, the
* class will have the ENUM bit set but clazz.isEnum()
* will be false. A constructor in such a class must
* be non-private to allow the parent class to call
* the constructor. Therefore, only impose the
* private constructor check for genuine isEnum
* classes.
*/
if (clazz.isEnum()) {
if ((modifiers & Modifier.PRIVATE) == 0 &&
! ctor.isSynthetic() ) {
passed = false;
System.out.println("\tFAILED: Constructor not marked private: modifiers 0x" +
Integer.toHexString(modifiers));
}
}
try {
// Should get exception trying to invoke
Object o = null;
try {
o = ctor.newInstance("abc", 123);
} catch (IllegalAccessException ex) {
}
/*
* A better test would query the number (and type)
* of parameters and create an appropriate
* argument list since IllegalArgumentException can be
* thrown for just using the wrong number of arguments.
*/
if (o != null) {
passed = false;
System.err.println("Error: Created new enum object!");
System.err.println(o.getClass());
System.err.println(o.toString());
}
} catch (IllegalArgumentException iae) {}
}
}
if (!passed)
throw new RuntimeException("Error during testing.");
}
/*
* Should be final and not abstract.
*/
@ExpectedModifiers(Modifier.FINAL|Modifier.STATIC)
enum AnotherEnum {
YELLOW,
CYAN,
MAGENTA;
}
/*
* Should be neither final nor abstract.
*/
@ExpectedModifiers(Modifier.STATIC)
enum YetAnotherEnum {
GREEN {
int value(){ return 1;}
},
ORANGE {
int value(){ return 2;}
},
VIOLET {
int value(){ return 3;}
};
int value(){ return 0;}
}
/*
* Should be abstract and not final.
*/
@ExpectedModifiers(Modifier.ABSTRACT|Modifier.STATIC)
enum OneMoreEnum {
SANGUINE {
int value(){ return 1;}
},
VERDANT {
int value(){ return 2;}
},
CERULEAN {
int value(){ return 3;}
};
abstract int value();
}
}
@Retention(RetentionPolicy.RUNTIME)
@interface ExpectedModifiers {
int value();
}
| 7,097 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NoFinal5.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/NoFinal5.java | /*
* Copyright (c) 2004, 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 5097250 5087624
* @summary Finalize methods on enums must be compile time error
* @author Peter von der Ah\u00e9
* @compile/fail NoFinal5.java
*/
enum NoFinal5 {
A, B, C;
void finalize() {
System.err.println("FISK");
}
}
| 1,324 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NoFinal4.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/NoFinal4.java | /*
* Copyright (c) 2004, 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 5097250 5087624
* @summary Finalize methods on enums must be compile time error
* @author Peter von der Ah\u00e9
* @compile/fail NoFinal4.java
*/
enum NoFinal4 {
A, B, C;
private void finalize() {
System.err.println("FISK");
}
}
| 1,332 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TrailingComma.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/TrailingComma.java | /*
* Copyright (c) 2003, 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 4936392
* @summary enum spec allows trailing comma on enum constant list
* @author gafter
*
* @compile TrailingComma.java
*/
class TrailingComma {
enum a { , };
enum b { x , };
enum c { , ; };
enum d { x , ; };
}
| 1,307 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumInit.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/EnumInit.java | /*
* Copyright (c) 2004, 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 5025833
* @summary compiling annatations with nested enums issuing *.java leads to crash
* @author gafter
*
* @compile EnumInit.java
*/
package enum_init_;
import java.util.Arrays;
import java.lang.annotation.*;
@NestedEnum(getVehicles=NestedEnum.Vehicles.sports)
class AnnotationDriverTest {}
@Retention(RetentionPolicy.RUNTIME)
@interface NestedEnum {
enum Vehicles {
sports {
};
}
Vehicles getVehicles();
}
| 1,520 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Enum2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/Enum2.java | /*
* Copyright (c) 2003, 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
* @summary enums: an enumeration type may not be extended
* @author gafter
*
* @compile/fail Enum2.java
*/
public class Enum2 {
enum e1 { red, green, blue }
static class e2 extends e1 {}
}
| 1,267 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NoFinal3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/NoFinal3.java | /*
* Copyright (c) 2004, 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 5097250 5087624
* @summary Finalize methods on enums must be compile time error
* @author Peter von der Ah\u00e9
* @compile/fail NoFinal3.java
*/
enum NoFinal3 {
A, B, C;
public void finalize() {
System.err.println("FISK");
}
}
| 1,331 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
LocalEnum.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/LocalEnum.java | /*
* Copyright (c) 2004, 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 5019609
* @summary javac fails to reject local enums
* @author gafter
*
* @compile/fail LocalEnum.java
*/
public class LocalEnum {
void f() {
enum B {}
}
}
| 1,250 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6384542a.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/6384542/T6384542a.java | /**
* @test /nodynamiccopyright/
* @bug 6384542
* @summary crash: test/tools/javac/versions/check.sh
* @author Peter von der Ah\u00e9
* @compile/fail -source 5 T6384542a.java
* @compile -source 1.4 T6384542a.java
* @compile/fail/ref=T6384542a_5.out -source 5 -Xlint:-options -XDrawDiagnostics T6384542a.java
* @compile/ref=T6384542a_1_4.out -source 1.4 -Xlint:-options -XDrawDiagnostics T6384542a.java
*/
public class T6384542a {
T6384542a enum = null;
}
| 487 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6384542.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/6384542/T6384542.java | /**
* @test /nodynamiccopyright/
* @bug 6384542
* @summary crash: test/tools/javac/versions/check.sh
* @author Peter von der Ah\u00e9
* @compile/fail -source 1.4 -Xlint:-options T6384542.java
* @compile/fail/ref=T6384542.out -source 1.4 -Xlint:-options -XDrawDiagnostics T6384542.java
*/
import static java.lang.Math.sin;
public enum A { }
class B {
int i = 0xCafe.BabeP1;
List<X> l;
public static void main(String... args) {
for (String arg : args) {
System.out.println(arg);
}
}
@Override
public String toString() { return null; }
}
public klass C { }
| 621 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnumSwitch.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/enumSwitch/EnumSwitch.java | /*
* Copyright (c) 2004, 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 5055142
* @summary javac-generated code doesn't obey binary compatibility for enums
* @author gafter
*
* @compile EnumSwitch.java
* @compile Color2.java
* @run main EnumSwitch
*/
enum Color {
red, green
}
public class EnumSwitch {
static int f(Color c) {
switch(c) {
case red:
return 1;
case green: // no resolve error
return 2;
default:
return 0;
}
}
public static void main(String[] args) {
f(Color.red);
System.out.println("test passed");
}
}
| 1,640 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Color2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/enumSwitch/Color2.java | /*
* Copyright (c) 2004, 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.
*/
enum Color {
red
}
| 1,075 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestEnum.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/6350057/TestEnum.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.
*/
enum TestEnum {
MIDTERM,
FINAL;
}
| 1,094 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6350057.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/6350057/T6350057.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 6350057
* @summary Test that parameters on implicit enum methods have the right kind
* @author Joseph D. Darcy
* @compile T6350057.java
* @compile -processor T6350057 -proc:only TestEnum.java
*/
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.*;
import javax.lang.model.util.*;
import static javax.tools.Diagnostic.Kind.*;
@SupportedAnnotationTypes("*")
public class T6350057 extends AbstractProcessor {
static class LocalVarAllergy extends ElementKindVisitor6<Boolean, Void> {
@Override
public Boolean visitTypeAsEnum(TypeElement e, Void v) {
System.out.println("visitTypeAsEnum: " + e.getSimpleName().toString());
for(Element el: e.getEnclosedElements() )
this.visit(el);
return true;
}
@Override
public Boolean visitVariableAsLocalVariable(VariableElement e, Void v){
throw new IllegalStateException("Should not see any local variables!");
}
@Override
public Boolean visitVariableAsParameter(VariableElement e, Void v){
String senclm=e.getEnclosingElement().getEnclosingElement().getSimpleName().toString();
String sEncl = senclm+"."+e.getEnclosingElement().getSimpleName().toString();
String stype = e.asType().toString();
String name = e.getSimpleName().toString();
System.out.println("visitVariableAsParameter: " +sEncl+"." + stype + " " + name);
return true;
}
@Override
public Boolean visitExecutableAsMethod(ExecutableElement e, Void v){
String name=e.getEnclosingElement().getSimpleName().toString();
name = name + "."+e.getSimpleName().toString();
System.out.println("visitExecutableAsMethod: " + name);
for (VariableElement ve: e.getParameters())
this.visit(ve);
return true;
}
}
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver())
for(Element element : roundEnvironment.getRootElements())
element.accept(new LocalVarAllergy(), null);
return true;
}
}
| 3,506 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6424358.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/6424358/T6424358.java | /*
* Copyright (c) 2006, 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 6424358
* @summary Synthesized static enum method values() is final
* @author Peter von der Ah\u00e9
* @compile T6424358.java
* @compile -processor T6424358 -proc:only T6424358.java
*/
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.lang.model.util.*;
import javax.lang.model.SourceVersion;
import static javax.tools.Diagnostic.Kind.*;
@interface TestMe {}
@SupportedAnnotationTypes("*")
public class T6424358 extends AbstractProcessor {
@TestMe enum Test { FOO; }
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
final Messager log = processingEnv.getMessager();
final Elements elements = processingEnv.getElementUtils();
final TypeElement testMe = elements.getTypeElement("TestMe");
class Scan extends ElementScanner7<Void,Void> {
@Override
public Void visitExecutable(ExecutableElement e, Void p) {
System.err.println("Looking at " + e);
if ("values".contentEquals(e.getSimpleName()) &&
e.getModifiers().contains(Modifier.FINAL)) {
log.printMessage(ERROR, "final modifier on values()", e);
throw new AssertionError("final modifier on values()"); // See bug 6403468
}
return null;
}
}
Scan scan = new Scan();
for (Element e : roundEnvironment.getElementsAnnotatedWith(testMe))
scan.scan(e);
return true;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
| 2,803 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestEnum4.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/forwardRef/TestEnum4.java | /*
* Copyright (c) 2005, 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 6209839
* @summary Illegal forward reference to enum constants allowed by javac
* @author Peter von der Ah\u00e9
* @compile/fail TestEnum4.java
*/
enum TestEnum {
BAR,
QUX,
BAZ;
static String X = "X";
private String y = X;
}
| 1,333 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestEnum3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/forwardRef/TestEnum3.java | /*
* Copyright (c) 2005, 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 6209839
* @summary Illegal forward reference to enum constants allowed by javac
* @author Peter von der Ah\u00e9
* @compile/fail TestEnum3.java
*/
enum TestEnum {
BAR,
QUX,
BAZ {
private final String x = X;
};
static String X = "X";
}
| 1,351 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestEnum6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/forwardRef/TestEnum6.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 6424491
* @summary Cannot initialise nested enums
* @author Peter von der Ah\u00e9
* @compile/fail TestEnum6.java
*/
public enum TestEnum6 {
AAA(TestEnum6.AAA);
TestEnum6(TestEnum6 e) {
}
}
| 1,284 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestEnum2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/forwardRef/TestEnum2.java | /*
* Copyright (c) 2005, 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 6209839
* @summary Illegal forward reference to enum constants allowed by javac
* @author Peter von der Ah\u00e9
* @compile/fail TestEnum2.java
*/
enum TestEnum {
BAR,
QUX,
BAZ {
private final TestEnum a = BAR;
private final TestEnum b = QUX;
}
}
| 1,367 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestEnum1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/forwardRef/TestEnum1.java | /*
* Copyright (c) 2005, 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 6209839
* @summary Illegal forward reference to enum constants allowed by javac
* @author Peter von der Ah\u00e9
* @compile/fail TestEnum1.java
*/
enum TestEnum {
BAR {
private final TestEnum self = BAR;
private final TestEnum other = QUX;
},
QUX
}
| 1,365 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6425594.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/forwardRef/T6425594.java | /*
* @test /nodynamiccopyright/
* @bug 6424491
* @summary javac accepts illegal forward references
* @author Peter von der Ah\u00e9
* @compile/fail/ref=T6425594.out -XDrawDiagnostics -XDuseBeforeDeclarationWarning T6425594.java
*/
public class T6425594 {
static int x = T6425594.x;
static final int y = z;
static final int z = 0;
}
| 357 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestEnum5.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/enum/forwardRef/TestEnum5.java | /*
* Copyright (c) 2005, 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 6209839
* @summary Illegal forward reference to enum constants allowed by javac
* @author Peter von der Ah\u00e9
* @compile/fail TestEnum5.java
*/
enum TestEnum {
BAR,
QUX,
BAZ;
static String X = "X";
TestEnum() {
String y = X;
}
}
| 1,352 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExtendsAccess.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.java | /*
* @test /nodynamiccopyright/
* @bug 4087314 4087314 4785453
* @summary Test access checking within 'extends' and 'implements' clause.
* @author William Maddox (maddox)
* @compile/fail/ref=ExtendsAccess.out -XDrawDiagnostics ExtendsAccess.java
*/
/*
* Should compile with errors as noted.
*/
class ExtendsAccess {
class defaultClass { }
public class publicClass { }
private class privateClass { }
protected class protectedClass { }
static class defaultStaticClass { }
public static class publicStaticClass { }
private static class privateStaticClass { }
protected static class protectedStaticClass { }
interface defaultInterface { }
public interface publicInterface { }
private interface privateInterface { }
protected interface protectedInterface { }
}
class ExtendsAccess111 extends publicClass { } // ERROR - 'publicClass' not in scope
class ExtendsAccess112 extends defaultClass { } // ERROR - 'defaultClass' not in scope
class ExtendsAccess113 extends protectedClass { } // ERROR - 'protectedClass' not in scope
class ExtendsAccess114 extends privateClass { } // ERROR - 'privateClass' not in scope
class ExtendsAccess1211 extends ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1221 extends ExtendsAccess.defaultClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1231 extends ExtendsAccess.protectedClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1241 extends ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
class ExtendsAccess1212 extends p.ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1222 extends p.ExtendsAccess.defaultClass { } // ERROR - cannot access 'defaultClass'
class ExtendsAccess1232 extends p.ExtendsAccess.protectedClass { } // ERROR - cannot access 'protectedClass'
class ExtendsAccess1242 extends p.ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
class ExtendsAccess1311 extends ExtendsAccess {
class N extends publicClass { }
}
class ExtendsAccess1321 extends ExtendsAccess {
class N extends defaultClass { }
}
class ExtendsAccess1331 extends ExtendsAccess {
class N extends protectedClass { }
}
class ExtendsAccess1341 extends ExtendsAccess {
class N extends privateClass { } // ERROR - cannot access 'privateClass'
}
class ExtendsAccess1312 extends p.ExtendsAccess {
class N extends publicClass { }
}
class ExtendsAccess1322 extends p.ExtendsAccess {
class N extends defaultClass { } // ERROR - cannot access 'defaultClass'
}
class ExtendsAccess1332 extends p.ExtendsAccess {
class N extends protectedClass { }
}
class ExtendsAccess1342 extends p.ExtendsAccess {
class N extends privateClass { } // ERROR - cannot access 'privateClass'
}
class ExtendsAccess1411 extends ExtendsAccess {
class N extends ExtendsAccess.publicClass { }
}
class ExtendsAccess1421 extends ExtendsAccess {
class N extends ExtendsAccess.defaultClass { }
}
class ExtendsAccess1431 extends ExtendsAccess {
class N extends ExtendsAccess.protectedClass { }
}
class ExtendsAccess1441 extends ExtendsAccess {
class N extends ExtendsAccess1441.protectedClass { }
}
class ExtendsAccess1451 extends ExtendsAccess {
class N extends ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
}
class ExtendsAccess1412 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.publicClass { }
}
class ExtendsAccess1422 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.defaultClass { } // ERROR - cannot access 'defaultClass'
}
class ExtendsAccess1432 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.protectedClass { } // OK (was: should be error, see JLS 6.6.2)
}
class ExtendsAccess1442 extends p.ExtendsAccess {
class N extends ExtendsAccess1442.protectedClass { }
}
class ExtendsAccess1452 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
}
class ExtendsAccess211 extends publicStaticClass { } // ERROR - 'publicStaticClass' not in scope
class ExtendsAccess212 extends defaultStaticClass { } // ERROR - 'defaultStaticClass' not in scope
class ExtendsAccess213 extends protectedStaticClass { } // ERROR - 'protectedStaticClass' not in scope
class ExtendsAccess214 extends privateStaticClass { } // ERROR - 'privateStaticClass' not in scope
class ExtendsAccess2211 extends ExtendsAccess.publicStaticClass { }
class ExtendsAccess2221 extends ExtendsAccess.defaultStaticClass { }
class ExtendsAccess2231 extends ExtendsAccess.protectedStaticClass { }
class ExtendsAccess2241 extends ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
class ExtendsAccess2212 extends p.ExtendsAccess.publicStaticClass { }
class ExtendsAccess2222 extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
class ExtendsAccess2232 extends p.ExtendsAccess.protectedStaticClass { }// ERROR - cannot access 'protectedStaticClass'
class ExtendsAccess2242 extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
class ExtendsAccess2311 extends ExtendsAccess {
class N extends publicStaticClass { }
}
class ExtendsAccess2321 extends ExtendsAccess {
class N extends defaultStaticClass { }
}
class ExtendsAccess2331 extends ExtendsAccess {
class N extends protectedStaticClass { }
}
class ExtendsAccess2341 extends ExtendsAccess {
class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
}
class ExtendsAccess2312 extends p.ExtendsAccess {
class N extends publicStaticClass { }
}
class ExtendsAccess2322 extends p.ExtendsAccess {
class N extends defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
}
class ExtendsAccess2332 extends p.ExtendsAccess {
class N extends protectedStaticClass { }
}
class ExtendsAccess2342 extends p.ExtendsAccess {
class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
}
class ExtendsAccess2411 extends ExtendsAccess {
class N extends ExtendsAccess.publicStaticClass { }
}
class ExtendsAccess2421 extends ExtendsAccess {
class N extends ExtendsAccess.defaultStaticClass { }
}
class ExtendsAccess2431 extends ExtendsAccess {
class N extends ExtendsAccess.protectedStaticClass { } // OK (was should be error, see JLS 6.6.2)
}
class ExtendsAccess2441 extends ExtendsAccess {
class N extends ExtendsAccess2431.protectedStaticClass { }
}
class ExtendsAccess2451 extends ExtendsAccess {
class N extends ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
}
class ExtendsAccess2412 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.publicStaticClass { }
}
class ExtendsAccess2422 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
}
class ExtendsAccess2432 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.protectedStaticClass { } // OK (was: should be error, see JLS 6.6.2)
}
class ExtendsAccess2442 extends p.ExtendsAccess {
class N extends ExtendsAccess2442.protectedStaticClass { }
}
class ExtendsAccess2452 extends p.ExtendsAccess {
class N extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
}
class ExtendsAccess311 extends ExtendsAccess implements publicInterface { } // ERROR - 'publicInterface' not in scope
class ExtendsAccess312 extends ExtendsAccess implements defaultInterface { } // ERROR - 'defaultInterface' not in scope
class ExtendsAccess313 extends ExtendsAccess implements protectedInterface { } // ERROR - 'protectedInterface' not in scope
class ExtendsAccess314 extends ExtendsAccess implements privateInterface { } // ERROR - 'privateInterface' not in scope
class ExtendsAccess3211 extends ExtendsAccess implements ExtendsAccess.publicInterface { }
class ExtendsAccess3221 extends ExtendsAccess implements ExtendsAccess.defaultInterface { }
class ExtendsAccess3231 extends ExtendsAccess implements ExtendsAccess.protectedInterface { }
class ExtendsAccess3241 extends ExtendsAccess
implements ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
class ExtendsAccess3212 extends ExtendsAccess
implements p.ExtendsAccess.publicInterface { }
class ExtendsAccess3222 extends ExtendsAccess
implements p.ExtendsAccess.defaultInterface { } // ERROR - cannot access 'defaultStaticClass'
class ExtendsAccess3232 extends ExtendsAccess
implements p.ExtendsAccess.protectedInterface { } // ERROR - cannot access 'protectedStaticClass'
class ExtendsAccess3242 extends ExtendsAccess
implements p.ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
class ExtendsAccess331 extends ExtendsAccess {
class N implements publicInterface { }
}
class ExtendsAccess3321 extends ExtendsAccess {
class N implements defaultInterface { }
}
class ExtendsAccess3331 extends ExtendsAccess {
class N implements protectedInterface { }
}
class ExtendsAccess3341 extends ExtendsAccess {
class N implements privateInterface { } // ERROR - cannot access 'privateInterface'
}
class ExtendsAccess3312 extends p.ExtendsAccess {
class N implements publicInterface { }
}
class ExtendsAccess3322 extends p.ExtendsAccess {
class N implements defaultInterface { } // ERROR - cannot access 'defaultStaticClass'
}
class ExtendsAccess3332 extends p.ExtendsAccess {
class N implements protectedInterface { }
}
class ExtendsAccess3342 extends p.ExtendsAccess {
class N implements privateInterface { } // ERROR - cannot access 'privateInterface'
}
class ExtendsAccess341 extends ExtendsAccess {
class N implements ExtendsAccess.publicInterface { }
}
class ExtendsAccess3421 extends ExtendsAccess {
class N implements ExtendsAccess.defaultInterface { }
}
class ExtendsAccess3431 extends ExtendsAccess {
class N implements ExtendsAccess.protectedInterface { } // OK (was: should be error, see JLS 6.2.2)
}
class ExtendsAccess3441 extends ExtendsAccess {
class N implements ExtendsAccess3441.protectedInterface { }
}
class ExtendsAccess3451 extends ExtendsAccess {
class N implements ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
}
class ExtendsAccess342 extends p.ExtendsAccess {
class N implements p.ExtendsAccess.publicInterface { }
}
class ExtendsAccess3422 extends p.ExtendsAccess {
class N implements p.ExtendsAccess.defaultInterface { } // ERROR - cannot access 'defaultClass'
}
class ExtendsAccess3432 extends p.ExtendsAccess {
class N implements p.ExtendsAccess.protectedInterface { } // OK (was: should be error, see JLS 6.2.2)
}
class ExtendsAccess3442 extends p.ExtendsAccess {
class N implements ExtendsAccess3442.protectedInterface { }
}
class ExtendsAccess3452 extends p.ExtendsAccess {
class N implements p.ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
}
| 11,897 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExtendsAccess.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ExtendsAccess/p/ExtendsAccess.java | /*
* Copyright (c) 1997, 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.
*/
/*
* Auxiliary file for test for 087314.
* Test access checking within 'extends' and 'implements' clause.
*
*/
package p;
public class ExtendsAccess {
class defaultClass { }
public class publicClass { }
private class privateClass { }
protected class protectedClass { }
static class defaultStaticClass { }
public static class publicStaticClass { }
private static class privateStaticClass { }
protected static class protectedStaticClass { }
interface defaultInterface { }
public interface publicInterface { }
private interface privateInterface { }
protected interface protectedInterface { }
}
| 1,699 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T5017953.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/5017953/T5017953.java | /*
* @test /nodynamiccopyright/
* @bug 5017953
* @summary spurious cascaded diagnostics when name not found
* @compile/fail/ref=T5017953.out -XDrawDiagnostics T5017953.java
*/
class T5017953 {
int f = 0;
void test(int i) {}
{ test(NonExistentClass.f ++);
test(1 + NonExistentClass.f);
test(NonExistentClass.f + 1);
test(NonExistentClass.f + NonExistentClass.f);
test(NonExistentClass.f += 1);
test(f += NonExistentClass.f);
}
}
| 495 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6722234a.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java | /**
* @test /nodynamiccopyright/
* @bug 6722234
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
* @compile/fail/ref=T6722234a_1.out -XDrawDiagnostics -XDdiags=disambiguateTvars T6722234a.java
* @compile/fail/ref=T6722234a_2.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T6722234a.java
*/
class T6722234a<T extends String> {
<T extends Integer> void test(T t) {
m(t);
}
void m(T t) {}
}
| 476 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6722234d.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java | /**
* @test /nodynamiccopyright/
* @bug 6722234
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
* @compile/fail/ref=T6722234d_1.out -XDrawDiagnostics -XDdiags=where T6722234d.java
* @compile/fail/ref=T6722234d_2.out -XDrawDiagnostics -XDdiags=where,simpleNames T6722234d.java
*/
class T6722234d {
interface I1 {}
interface I2 {}
class A implements I1, I2 {}
class B implements I1, I2 {}
class Test {
<Z> Z m(Z z1, Z z2) { return null; }
void main(){
A a = m(new A(), new B());
}
}
}
| 604 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6722234b.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java | /**
* @test /nodynamiccopyright/
* @bug 6722234
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
* @compile/fail/ref=T6722234b_1.out -XDrawDiagnostics -XDdiags=simpleNames T6722234b.java
* @compile/fail/ref=T6722234b_2.out -XDrawDiagnostics -XDdiags=simpleNames,where T6722234b.java
*/
import java.util.*;
class T6722234b {
<T> void m(List<T> l1, List<T> l2) {}
void test(List<? extends T6722234b> list) {
m(list, list);
}
}
| 507 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6722234c.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java | /**
* @test /nodynamiccopyright/
* @bug 6722234
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
* @compile/fail/ref=T6722234c.out -XDrawDiagnostics -XDdiags=simpleNames T6722234c.java
*/
class T6722234c {
static class String {}
<T> void m(String s2) {}
void test() {
m("");
}
}
| 363 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6864382.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6864382/T6864382.java | /**
* @test /nodynamiccopyright/
* @bug 6864382
* @summary NullPointerException when compiling a negative java source
* @author mcimadamore
* @compile/fail/ref=T6864382.out -XDrawDiagnostics T6864382.java
*/
class T6864382<T> extends T {}
| 252 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6862608a.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java | /**
* @test /nodynamiccopyright/
* @bug 6862608
* @summary rich diagnostic sometimes contain wrong type variable numbering
* @author mcimadamore
* @compile/fail/ref=T6862608a.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T6862608a.java
*/
import java.util.*;
class T6862608a {
<T> Comparator<T> compound(Iterable<? extends Comparator<? super T>> it) {
return null;
}
public void test(List<Comparator<?>> x) {
Comparator<String> c3 = compound(x);
}
}
| 507 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6862608b.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java | /**
* @test /nodynamiccopyright/
* @bug 6862608
* @summary rich diagnostic sometimes contain wrong type variable numbering
* @author mcimadamore
* @compile/fail/ref=T6862608b.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T6862608b.java
*/
class T66862608b<T extends String, S> {
<S, T extends S> void foo(T t) {
test(t);
}
void test(T t) {}
}
| 380 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Test.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/7010608/Test.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.
*/
/*
* @test
* @bug 7010608
* @summary the string 'error' should appear in error messages
*/
import java.io.*;
import java.net.URI;
import java.util.*;
import javax.tools.*;
import javax.tools.JavaCompiler.CompilationTask;
public class Test {
public static void main(String... args) throws Exception {
new Test().run();
}
void run() throws Exception {
Locale prev = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
try {
test(Arrays.<String>asList(),
"myfo://test:1: error: cannot find symbol");
test(Arrays.asList("-XDdiagsFormat=OLD"),
"myfo://test:1: cannot find symbol");
test(Arrays.asList("-XDoldDiags"),
"myfo://test:1: cannot find symbol");
} finally {
Locale.setDefault(prev);
}
}
void test(List<String> options, String expect) throws Exception {
System.err.println("test: " + options);
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
JavaFileObject f = new MyFileObject("myfo://test", "class Bad { Missing x; }");
List<? extends JavaFileObject> files = Arrays.asList(f);
CompilationTask task = javac.getTask(pw, null, null, options, null, files);
boolean ok = task.call();
pw.close();
String out = sw.toString();
if (!out.isEmpty())
System.err.println(out);
if (ok)
throw new Exception("Compilation succeeded unexpectedly");
if (!out.contains(expect))
throw new Exception("expected text not found: " + expect);
}
class MyFileObject extends SimpleJavaFileObject {
MyFileObject(String uri, String text) {
super(URI.create(uri), JavaFileObject.Kind.SOURCE);
this.text = text;
}
@Override
public String getName() {
return uri.toString();
}
@Override
public String getCharContent(boolean ignoreEncodingErrors) {
return text;
}
final String text;
}
}
| 3,258 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6769027.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6769027/T6769027.java | /*
* Copyright (c) 2009, 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 6769027
* @summary Source line should be displayed immediately after the first diagnostic line
* @author Maurizio Cimadamore
* @run main/othervm T6769027
*/
import java.net.URI;
import java.util.regex.Matcher;
import javax.tools.*;
import com.sun.tools.javac.util.*;
public class T6769027 {
enum OutputKind {
RAW("rawDiagnostics","rawDiagnostics"),
BASIC("","");
String key;
String value;
void init(Options opts) {
opts.put(key, value);
}
OutputKind(String key, String value) {
this.key = key;
this.value = value;
}
}
enum CaretKind {
DEFAULT("", ""),
SHOW("showCaret","true"),
HIDE("showCaret","false");
String key;
String value;
void init(Options opts) {
opts.put(key, value);
}
CaretKind(String key, String value) {
this.key = key;
this.value = value;
}
boolean isEnabled() {
return this == DEFAULT || this == SHOW;
}
}
enum SourceLineKind {
DEFAULT("", ""),
AFTER_SUMMARY("sourcePosition", "top"),
BOTTOM("sourcePosition", "bottom");
String key;
String value;
void init(Options opts) {
opts.put(key, value);
}
SourceLineKind(String key, String value) {
this.key = key;
this.value = value;
}
boolean isAfterSummary() {
return this == DEFAULT || this == AFTER_SUMMARY;
}
}
enum XDiagsSource {
DEFAULT(""),
SOURCE("source"),
NO_SOURCE("-source");
String flag;
void init(Options opts) {
if (this != DEFAULT) {
String flags = opts.get("diags");
flags = flags == null ? flag : flags + "," + flag;
opts.put("diags", flags);
}
}
XDiagsSource(String flag) {
this.flag = flag;
}
String getOutput(CaretKind caretKind, IndentKind indent, OutputKind outKind) {
String spaces = (outKind == OutputKind.BASIC) ? indent.string : "";
return "\n" + spaces + "This is a source line" +
(caretKind.isEnabled() ? "\n" + spaces + " ^" : "");
}
}
enum XDiagsCompact {
DEFAULT(""),
COMPACT("short"),
NO_COMPACT("-short");
String flag;
void init(Options opts) {
if (this != DEFAULT) {
String flags = opts.get("diags");
flags = flags == null ? flag : flags + "," + flag;
opts.put("diags", flags);
}
}
XDiagsCompact(String flag) {
this.flag = flag;
}
}
enum ErrorKind {
SINGLE("single",
"compiler.err.single: Hello!",
"KXThis is a test error message Hello!"),
DOUBLE("double",
"compiler.err.double: Hello!",
"KXThis is a test error message.\n" +
"KXYThis is another line of the above error message Hello!");
String key;
String rawOutput;
String nonRawOutput;
String key() {
return key;
}
ErrorKind(String key, String rawOutput, String nonRawOutput) {
this.key = key;
this.rawOutput = rawOutput;
this.nonRawOutput = nonRawOutput;
}
String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent) {
return outKind == OutputKind.RAW ?
rawOutput :
nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", "");
}
String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent, String indent) {
return outKind == OutputKind.RAW ?
rawOutput :
nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", indent);
}
}
enum MultilineKind {
NONE(0),
DOUBLE(1),
NESTED(2),
DOUBLE_NESTED(3);
static String[][] rawTemplates = {
{"", ",{(E),(E)}", ",{(E,{(E)})}", ",{(E,{(E)}),(E,{(E)})}"}, //ENABLED
{"", "", "", "",""}, //DISABLED
{"", ",{(E)}", ",{(E,{(E)})}", ",{(E,{(E)})}"}, //LIMIT_LENGTH
{"", ",{(E),(E)}", ",{(E)}", ",{(E),(E)}"}, //LIMIT_DEPTH
{"", ",{(E)}", ",{(E)}", ",{(E)}"}}; //LIMIT_BOTH
static String[][] basicTemplates = {
{"", "\nE\nE", "\nE\nQ", "\nE\nQ\nE\nQ"}, //ENABLED
{"", "", "", "",""}, //DISABLED
{"", "\nE", "\nE\nQ", "\nE\nQ"}, //LIMIT_LENGTH
{"", "\nE\nE", "\nE", "\nE\nE"}, //LIMIT_DEPTH
{"", "\nE", "\nE", "\nE"}}; //LIMIT_BOTH
int index;
MultilineKind (int index) {
this.index = index;
}
boolean isDouble() {
return this == DOUBLE || this == DOUBLE_NESTED;
}
boolean isNested() {
return this == NESTED || this == DOUBLE_NESTED;
}
String getOutput(OutputKind outKind, ErrorKind errKind, MultilinePolicy policy,
IndentKind summaryIndent, IndentKind detailsIndent, IndentKind multiIndent) {
String constIndent = (errKind == ErrorKind.DOUBLE) ?
summaryIndent.string + detailsIndent.string :
summaryIndent.string;
constIndent += multiIndent.string;
String errMsg1 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent);
String errMsg2 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent + constIndent);
errMsg1 = errMsg1.replaceAll("compiler.err", "compiler.misc");
errMsg1 = errMsg1.replaceAll("error message", "subdiagnostic");
errMsg2 = errMsg2.replaceAll("compiler.err", "compiler.misc");
errMsg2 = errMsg2.replaceAll("error message", "subdiagnostic");
String template = outKind == OutputKind.RAW ?
rawTemplates[policy.index][index] :
basicTemplates[policy.index][index];
template = template.replaceAll("E", errMsg1);
return template.replaceAll("Q", errMsg2);
}
}
enum MultilinePolicy {
ENABLED(0, "multilinePolicy", "enabled"),
DISABLED(1, "multilinePolicy", "disabled"),
LIMIT_LENGTH(2, "multilinePolicy", "limit:1:*"),
LIMIT_DEPTH(3, "multilinePolicy", "limit:*:1"),
LIMIT_BOTH(4, "multilinePolicy", "limit:1:1");
String name;
String value;
int index;
MultilinePolicy(int index, String name, String value) {
this.name = name;
this.value = value;
this.index = index;
}
void init(Options options) {
options.put(name, value);
}
}
enum PositionKind {
NOPOS(Position.NOPOS, "- ", "error: "),
POS(5, "Test.java:1:6: ", "/Test.java:1: error: ");
int pos;
String rawOutput;
String nonRawOutput;
PositionKind(int pos, String rawOutput, String nonRawOutput) {
this.pos = pos;
this.rawOutput = rawOutput;
this.nonRawOutput = nonRawOutput;
}
JCDiagnostic.DiagnosticPosition pos() {
return new JCDiagnostic.SimpleDiagnosticPosition(pos);
}
String getOutput(OutputKind outputKind) {
return outputKind == OutputKind.RAW ?
rawOutput :
nonRawOutput;
}
}
static class MyFileObject extends SimpleJavaFileObject {
private String text;
public MyFileObject(String text) {
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
this.text = text;
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return text;
}
}
enum IndentKind {
NONE(""),
CUSTOM(" ");
String string;
IndentKind(String indent) {
string = indent;
}
}
class MyLog extends Log {
MyLog(Context ctx) {
super(ctx);
}
@Override
protected java.io.PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt) {
return new java.io.PrintWriter(System.out);
}
@Override
protected boolean shouldReport(JavaFileObject jfo, int pos) {
return true;
}
}
int nerrors = 0;
void exec(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
IndentKind subdiagsIndent) {
Context ctx = new Context();
Options options = Options.instance(ctx);
outputKind.init(options);
multiPolicy.init(options);
xdiagsSource.init(options);
xdiagsCompact.init(options);
caretKind.init(options);
sourceLineKind.init(options);
String indentString = "";
indentString = (summaryIndent == IndentKind.CUSTOM) ? "3" : "0";
indentString += (detailsIndent == IndentKind.CUSTOM) ? "|3" : "|0";
indentString += (sourceIndent == IndentKind.CUSTOM) ? "|3" : "|0";
indentString += (subdiagsIndent == IndentKind.CUSTOM) ? "|3" : "|0";
options.put("diagsIndentation", indentString);
MyLog log = new MyLog(ctx);
JavacMessages messages = JavacMessages.instance(ctx);
messages.add("tester");
JCDiagnostic.Factory diags = JCDiagnostic.Factory.instance(ctx);
log.useSource(new MyFileObject("This is a source line"));
JCDiagnostic d = diags.error(log.currentSource(),
posKind.pos(),
errorKind.key(), "Hello!");
if (multiKind != MultilineKind.NONE) {
JCDiagnostic sub = diags.fragment(errorKind.key(), "Hello!");
if (multiKind.isNested())
sub = new JCDiagnostic.MultilineDiagnostic(sub, List.of(sub));
List<JCDiagnostic> subdiags = multiKind.isDouble() ?
List.of(sub, sub) :
List.of(sub);
d = new JCDiagnostic.MultilineDiagnostic(d, subdiags);
}
String diag = log.getDiagnosticFormatter().format(d, messages.getCurrentLocale());
checkOutput(diag,
outputKind,
errorKind,
multiKind,
multiPolicy,
posKind,
xdiagsSource,
xdiagsCompact,
caretKind,
sourceLineKind,
summaryIndent,
detailsIndent,
sourceIndent,
subdiagsIndent);
}
void test() {
for (OutputKind outputKind : OutputKind.values()) {
for (ErrorKind errKind : ErrorKind.values()) {
for (MultilineKind multiKind : MultilineKind.values()) {
for (MultilinePolicy multiPolicy : MultilinePolicy.values()) {
for (PositionKind posKind : PositionKind.values()) {
for (XDiagsSource xdiagsSource : XDiagsSource.values()) {
for (XDiagsCompact xdiagsCompact : XDiagsCompact.values()) {
for (CaretKind caretKind : CaretKind.values()) {
for (SourceLineKind sourceLineKind : SourceLineKind.values()) {
for (IndentKind summaryIndent : IndentKind.values()) {
for (IndentKind detailsIndent : IndentKind.values()) {
for (IndentKind sourceIndent : IndentKind.values()) {
for (IndentKind subdiagsIndent : IndentKind.values()) {
exec(outputKind,
errKind,
multiKind,
multiPolicy,
posKind,
xdiagsSource,
xdiagsCompact,
caretKind,
sourceLineKind,
summaryIndent,
detailsIndent,
sourceIndent,
subdiagsIndent);
}
}
}
}
}
}
}
}
}
}
}
}
}
if (nerrors != 0)
throw new AssertionError(nerrors + " errors found");
}
void printInfo(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
IndentKind subdiagsIndent, String errorLine) {
String sep = "*********************************************************";
String desc = "raw=" + outputKind + " pos=" + posKind + " key=" + errorKind.key() +
" multiline=" + multiKind +" multiPolicy=" + multiPolicy.value +
" diags= " + java.util.Arrays.asList(xdiagsSource.flag, xdiagsCompact.flag) +
" caret=" + caretKind + " sourcePosition=" + sourceLineKind +
" summaryIndent=" + summaryIndent + " detailsIndent=" + detailsIndent +
" sourceIndent=" + sourceIndent + " subdiagsIndent=" + subdiagsIndent;
System.out.println(sep);
System.out.println(desc);
System.out.println(sep);
System.out.println(msg);
System.out.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine);
}
void checkOutput(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
IndentKind subdiagsIndent) {
boolean shouldPrintSource = posKind == PositionKind.POS &&
xdiagsSource != XDiagsSource.NO_SOURCE &&
(xdiagsSource == XDiagsSource.SOURCE ||
outputKind == OutputKind.BASIC);
String errorLine = posKind.getOutput(outputKind) +
errorKind.getOutput(outputKind, summaryIndent, detailsIndent);
if (xdiagsCompact != XDiagsCompact.COMPACT)
errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy, summaryIndent, detailsIndent, subdiagsIndent);
String[] lines = errorLine.split("\n");
if (xdiagsCompact == XDiagsCompact.COMPACT) {
errorLine = lines[0];
lines = new String[] {errorLine};
}
if (shouldPrintSource) {
if (sourceLineKind.isAfterSummary()) {
String sep = "\n";
if (lines.length == 1) {
errorLine += "\n";
sep = "";
}
errorLine = errorLine.replaceFirst("\n",
Matcher.quoteReplacement(xdiagsSource.getOutput(caretKind, sourceIndent, outputKind) + sep));
}
else
errorLine += xdiagsSource.getOutput(caretKind, sourceIndent, outputKind);
}
if (!msg.equals(errorLine)) {
printInfo(msg,
outputKind,
errorKind,
multiKind,
multiPolicy,
posKind,
xdiagsSource,
xdiagsCompact,
caretKind,
sourceLineKind,
summaryIndent,
detailsIndent,
sourceIndent,
subdiagsIndent,
errorLine);
nerrors++;
}
}
public static void main(String... args) throws Exception {
new T6769027().test();
}
}
| 18,621 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6799605.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6799605/T6799605.java | /**
* @test /nodynamiccopyright/
* @bug 6799605
* @summary Basic/Raw formatters should use type/symbol printer instead of toString()
* @author mcimadamore
* @compile/fail/ref=T6799605.out -XDrawDiagnostics T6799605.java
* @compile/fail/ref=T6799605.out -XDoldDiags -XDrawDiagnostics T6799605.java
*/
class T6799605<X> {
<T extends T6799605<T>> void m(T6799605<T> x1) {}
<T> void m(T6799605<T> x1, T6799605<T> x2) {}
<T> void m(T6799605<T> x1, T6799605<T> x2, T6799605<T> x3) {}
void test(T6799605<?> t) {
m(t);
m(t, t);
m(t, t, t);
}
}
| 597 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6860795.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Diagnostics/6860795/T6860795.java | /**
* @test /nodynamiccopyright/
* @bug 6860795
* @summary NullPointerException when compiling a negative java source
* @author mcimadamore
* @compile/fail/ref=T6860795.out -XDrawDiagnostics T6860795.java
*/
class Test {
void foo(float x, int x) {}
}
| 268 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6198196.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/unit/T6198196.java | /*
* Copyright (c) 2005, 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 6198196 6278523
* @summary package-info.java: Weird compiler error
* @author Peter von der Ah\u00e9
*/
import java.util.Arrays;
import javax.tools.*;
public class T6198196 {
static String pkginf = "package-info";
static StandardJavaFileManager fm;
static void test(String pathname, String filename, boolean result) {
JavaFileObject fo;
fo = fm.getJavaFileObjectsFromStrings(Arrays.asList(pathname)).iterator().next();
if (result != fo.isNameCompatible(filename, JavaFileObject.Kind.SOURCE))
throw new AssertionError("endsWith(" + pathname + ", "
+ filename + ") != " + result);
System.out.format("OK: endsWith(%s, %s) = %s%n", pathname, filename, result);
}
public static void main(String[] args) {
fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
boolean windows = System.getProperty("os.name").startsWith("Windows");
test("/x/y/z/package-info.java", pkginf, true);
if (windows) {
test("\\x\\y\\z\\package-info.java", pkginf, true);
test("..\\x\\y\\z\\package-info.java", pkginf, true);
} else {
test("\\x\\y\\z\\package-info.java", pkginf, false);
test("..\\x\\y\\z\\package-info.java", pkginf, false);
}
test("Package-info.java", pkginf, false);
test("../x/y/z/package-info.java", pkginf, true);
test("/x/y/z/package-info.java", pkginf, true);
test("x/y/z/package-info.java", pkginf, true);
test("package-info.java", pkginf, true);
}
}
| 2,703 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractList.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/unit/util/list/AbstractList.java | /*
* Copyright (c) 2005, 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 6320536
* @summary com.sun.tools.javac.util.List.from(A[]) shouldn't be deprecated
* @author Peter von der Ah\u00e9
* @library ../..
* @compile ../../util/list/AbstractList.java
* @run main util.list.AbstractList
*/
package util.list;
import static com.sun.tools.javac.util.List.from;
import java.util.List;
public class AbstractList {
public static void test(String... args) {
List<String> ss = from(args);
if (args != null) {
int index = 0;
for (String s : args) {
if (s != ss.get(index))
throw new AssertionError("s != ss.get(" + index + ")");
index++;
}
boolean ok = false;
try {
ss.get(-1);
} catch(IndexOutOfBoundsException ex) {
ok = true;
}
if (!ok)
throw new AssertionError();
ok = false;
try {
ss.get(args.length);
} catch(IndexOutOfBoundsException ex) {
ok = true;
}
if (!ok)
throw new AssertionError();
}
}
public static void main(String... args) {
test();
test("foo");
test("foo", "bar");
test("foo", "bar", "bax", "qux", "hest", "fisk", "ko", "fugl");
System.out.println("List.get(int) test OK");
}
}
| 2,491 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FromArray.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/unit/util/list/FromArray.java | /*
* Copyright (c) 2005, 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 6289436
* @summary com.sun.tools.javac.util.List.from(A[]) shouldn't be deprecated
* @author Peter von der Ah\u00e9
* @library ../..
* @compile ../../util/list/FromArray.java
* @run main util.list.FromArray
*/
package util.list;
import com.sun.tools.javac.util.List;
public class FromArray {
public static void test(String... args) {
List<String> ss = List.from(args);
if (args != null) {
for (String s : args) {
if (s != ss.head)
throw new AssertionError("s != ss.head (" + s + ", " + ss.head + ")");
ss = ss.tail;
}
}
if (!ss.isEmpty())
throw new AssertionError("!ss.isEmpty (" + ss + ")");
}
public static void main(String... args) {
test();
test((String[])null);
test("foo");
test("foo", "bar");
test("foo", "bar", "bax", "qux", "hest", "fisk", "ko", "fugl");
System.out.println("<A>List.from(A[]) test OK");
}
}
| 2,093 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EnclosingCandidates.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/unit/util/convert/EnclosingCandidates.java | /*
* Copyright (c) 2006, 2008, 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 6397652
* @summary javac compilation failure when imported class with $ sign in the name
* @author Peter von der Ah\u00e9
*/
import static com.sun.tools.javac.util.Convert.enclosingCandidates;
import com.sun.tools.javac.util.*;
import java.util.Arrays;
import java.util.Locale;
public class EnclosingCandidates {
Names names = Names.instance(new Context());
void test(String name, String... expected) {
List<Name> result = enclosingCandidates(names.fromString(name));
if (!result.isEmpty() || expected.length != 0) {
Name[] expectedNames = new Name[expected.length];
int i = 0;
for (String s : expected)
expectedNames[i++] = names.fromString(s);
if (!Arrays.equals(result.toArray(), expectedNames))
throw new AssertionError(name + " : " +
Arrays.toString(expectedNames) + " != " + result);
}
System.out.format((Locale)null, "OK: %s -> [%s]%n", name, result);
}
public static void main(String... args) {
EnclosingCandidates test = new EnclosingCandidates();
test.test("");
test.test("foo");
test.test("foo$bar", "foo");
test.test("foo$bar$baz", "foo", "foo$bar");
test.test("x$foo", "x");
test.test("$foo$", "$foo");
test.test("$foo$x", "$foo");
test.test("$foo");
test.test("foo$", "foo");
test.test("foo$bar$", "foo", "foo$bar");
}
}
| 2,589 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6404194.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/positions/T6404194.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 6404194
* @summary javac parser generates incorrect end position for annotations with parentheses.
* @author Peter von der Ah\u00e9
*/
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.Trees;
import java.io.IOException;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import static javax.tools.JavaFileObject.Kind.SOURCE;
import javax.tools.ToolProvider;
public class T6404194 {
public static void main(String... args) throws IOException {
class MyFileObject extends SimpleJavaFileObject {
MyFileObject() {
super(URI.create("myfo:///Test.java"), SOURCE);
}
@Override
public String getCharContent(boolean ignoreEncodingErrors) {
// 0 1 2 3
// 01234567890123456 7890 123456789012345
return "@SuppressWarning(\"foo\") @Deprecated class Test { Test() { } }";
}
}
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
List<JavaFileObject> compilationUnits =
Collections.<JavaFileObject>singletonList(new MyFileObject());
JavacTask task = (JavacTask)javac.getTask(null, null, null, null, null, compilationUnits);
Trees trees = Trees.instance(task);
CompilationUnitTree toplevel = task.parse().iterator().next();
ClassTree classTree = (ClassTree)toplevel.getTypeDecls().get(0);
List<? extends Tree> annotations = classTree.getModifiers().getAnnotations();
Tree tree1 = annotations.get(0);
Tree tree2 = annotations.get(1);
long pos = trees.getSourcePositions().getStartPosition(toplevel, tree1);
if (pos != 0)
throw new AssertionError(String.format("Start pos for %s is incorrect (%s)!",
tree1, pos));
pos = trees.getSourcePositions().getEndPosition(toplevel, tree1);
if (pos != 23)
throw new AssertionError(String.format("End pos for %s is incorrect (%s)!",
tree1, pos));
pos = trees.getSourcePositions().getStartPosition(toplevel, tree2);
if (pos != 24)
throw new AssertionError(String.format("Start pos for %s is incorrect (%s)!",
tree2, pos));
pos = trees.getSourcePositions().getEndPosition(toplevel, tree2);
if (pos != 35)
throw new AssertionError(String.format("End pos for %s is incorrect (%s)!",
tree2, pos));
}
}
| 3,959 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6264029.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/positions/T6264029.java | /*
* @test /nodynamiccopyright/
* @bug 6264029
* @summary Compiler issues wrong unchecked warning for anonymous inner class
* @author Seetharama Avadhanam
* @compile -Xlint:unchecked -XDdev T6264029.java
* @compile/ref=T6264029.out -Xlint:unchecked -XDdev -XDrawDiagnostics T6264029.java
*/
class T6264029A<T,K> {
public T6264029A(K k) {}
}
public class T6264029 {
T6264029A a = new T6264029A("saaa") {
public void getNoneTest() {}
};
}
| 480 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6402077.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/positions/T6402077.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 6402077
* @summary Start position is wrong for package private constructors
* @author Peter von der Ah\u00e9
*/
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.Trees;
import java.io.IOException;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import static javax.tools.JavaFileObject.Kind.SOURCE;
import javax.tools.ToolProvider;
public class T6402077 {
public static void main(String... args) throws IOException {
class MyFileObject extends SimpleJavaFileObject {
MyFileObject() {
super(URI.create("myfo:///Test.java"), SOURCE);
}
@Override
public String getCharContent(boolean ignoreEncodingErrors) {
// 0 1 2
// 0123456789012345678901234
return "class Test { Test() { } }";
}
}
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
List<JavaFileObject> compilationUnits =
Collections.<JavaFileObject>singletonList(new MyFileObject());
JavacTask task = (JavacTask)javac.getTask(null, null, null, null, null,
compilationUnits);
Trees trees = Trees.instance(task);
CompilationUnitTree toplevel = task.parse().iterator().next();
Tree tree = ((ClassTree)toplevel.getTypeDecls().get(0)).getMembers().get(0);
long pos = trees.getSourcePositions().getStartPosition(toplevel, tree);
if (pos != 13)
throw new AssertionError(String.format("Start pos for %s is incorrect (%s)!",
tree, pos));
pos = trees.getSourcePositions().getEndPosition(toplevel, tree);
if (pos != 23)
throw new AssertionError(String.format("End pos for %s is incorrect (%s)!",
tree, pos));
}
}
| 3,260 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6253161.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/positions/T6253161.java | /*
* @test /nodynamiccopyright/
* @bug 6253161
* @summary Compiler will fail to find the correct location of serial warnings for anonymous inner classes
* @author Seetharama Avadhanam
* @compile -Xlint:serial -XDdev T6253161.java
* @compile/ref=T6253161.out -Xlint:serial -XDdev -XDrawDiagnostics T6253161.java
*/
import java.util.List;
import java.util.ArrayList;
public class T6253161 {
@SuppressWarnings("unchecked")
public void anonymousMethod(){
List list = new ArrayList<String>(){
static final long serialVersionUID = 1;
List list = new ArrayList<Integer>();
public List<Integer> getMyList(){
final List floatList = new ArrayList<Float>(){
List integerList = new ArrayList<Float>();
public List<Float> getMyList(){
for(int i=0;i<10;i++)
integerList.add((int)((Float.parseFloat(i+""))+(1.11F)));
return (List)(Object)integerList;
}
public void testMethods(){
//...
}
}.getMyList();
for(int i=0;i<10;i++)
list.add((Float)(floatList.get(i)) * 11.232F * i);
return list;
}
}.getMyList();
}
}
| 1,370 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.