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
TestHelpOpts.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/TestHelpOpts.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 6893932 6990390 * @summary javah help screen lists -h and -? but does not accept them */ import java.io.*; import java.util.*; public class TestHelpOpts { public static void main(String... args) throws Exception { new TestHelpOpts().run(); } void run() throws Exception { Locale prev = Locale.getDefault(); try { Locale.setDefault(Locale.ENGLISH); String[] opts = { "-h", "-help", "-?", "--help" }; for (String opt: opts) test(opt); } finally { Locale.setDefault(prev); } if (errors > 0) throw new Exception(errors + " errors occurred"); } void test(String opt) { System.err.println("test " + opt); String[] args = { opt }; StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); int rc = com.sun.tools.javah.Main.run(args, pw); pw.close(); String out = sw.toString(); if (!out.isEmpty()) System.err.println(out); if (rc != 0) error("Unexpected exit: rc=" + rc); String flat = out.replaceAll("\\s+", " "); // canonicalize whitespace if (!flat.contains("Usage: javah [options] <classes> where [options] include:")) error("expected text not found"); if (flat.contains("main.opt")) error("key not found in resource bundle: " + flat.replaceAll(".*(main.opt.[^ ]*).*", "$1")); } void error(String msg) { System.err.println(msg); errors++; } int errors; }
2,674
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6893943.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/T6893943.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 6893943 6937318 * @summary exit code from javah with no args is 0 */ import java.io.*; import java.util.*; public class T6893943 { static final String[] NO_ARGS = { }; static final String[] HELP = { "-help" }; static final String NEWLINE = System.getProperty("line.separator"); public static void main(String... args) throws Exception { new T6893943().run(); } void run() throws Exception { testSimpleAPI(NO_ARGS, 1); testSimpleAPI(HELP, 0); testCommand(NO_ARGS, 1); testCommand(HELP, 0); } void testSimpleAPI(String[] args, int expect_rc) throws Exception { System.err.println("Test simple api: " + Arrays.asList(args)); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); int rc = com.sun.tools.javah.Main.run(args, pw); pw.close(); expect("testSimpleAPI", sw.toString(), rc, expect_rc); } void testCommand(String[] args, int expect_rc) throws Exception { System.err.println("Test command: " + Arrays.asList(args)); File javaHome = new File(System.getProperty("java.home")); if (javaHome.getName().equals("jre")) javaHome = javaHome.getParentFile(); List<String> command = new ArrayList<String>(); command.add(new File(new File(javaHome, "bin"), "javah").getPath()); command.add("-J-Xbootclasspath:" + System.getProperty("sun.boot.class.path")); command.addAll(Arrays.asList(args)); //System.err.println("command: " + command); ProcessBuilder pb = new ProcessBuilder(command); pb.redirectErrorStream(true); Process p = pb.start(); p.getOutputStream().close(); StringWriter sw = new StringWriter(); String line; BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = in.readLine()) != null) sw.write(line + NEWLINE); int rc = p.waitFor(); expect("testCommand", sw.toString(), rc, expect_rc); } void expect(String name, String out, int actual_rc, int expect_rc) throws Exception { if (out.isEmpty()) throw new Exception("No output from javah"); if (!out.startsWith("Usage:")) { System.err.println(out); throw new Exception("Unexpected output from javah"); } if (actual_rc != expect_rc) throw new Exception(name + ": unexpected exit: " + actual_rc + ", expected: " + expect_rc); } }
3,622
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VersionTest.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/VersionTest.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 6890226 * @summary javah -version is broken */ import java.io.*; import java.util.Locale; public class VersionTest { public static void main(String... args) { Locale prev = Locale.getDefault(); try { Locale.setDefault(Locale.ENGLISH); System.err.println(Locale.getDefault()); test("-version", "\\S+ version \"\\S+\""); test("-fullversion", "\\S+ full version \"\\S+\""); } finally { Locale.setDefault(prev); } } static void test(String option, String regex) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); String[] args = { option }; int rc = com.sun.tools.javah.Main.run(args, pw); pw.close(); if (rc != 0) throw new Error("javah failed: rc=" + rc); String out = sw.toString().trim(); System.err.println(out); if (!out.matches(regex)) throw new Error("output does not match pattern: " + regex); } }
2,111
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CompareTest.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/compareTest/CompareTest.java
/* * Copyright (c) 2009, 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.DataInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.jar.JarEntry; import java.util.jar.JarFile; import com.sun.tools.classfile.AccessFlags; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Method; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.LinkedHashSet; public class CompareTest { String[][] testCases = { { }, { "-jni" }, // { "-llni" }, }; public static void main(String... args) throws Exception { new CompareTest().run(args); } public void run(String... args) throws Exception { old_javah_cmd = new File(args[0]); rt_jar = new File(args[1]); Set<String> testClasses; if (args.length > 2) { testClasses = new LinkedHashSet<String>(Arrays.asList(Arrays.copyOfRange(args, 2, args.length))); } else testClasses = getNativeClasses(new JarFile(rt_jar)); for (String[] options: testCases) { for (String name: testClasses) { test(Arrays.asList(options), rt_jar, name); } } if (errors == 0) System.out.println(count + " tests passed"); else throw new Exception(errors + "/" + count + " tests failed"); } public void test(List<String> options, File bootclasspath, String className) throws IOException, InterruptedException { System.err.println("test: " + options + " " + className); count++; testOptions = options; testClassName = className; File oldOutDir = initDir(file(new File("old"), className)); int old_rc = old_javah(options, oldOutDir, bootclasspath, className); File newOutDir = initDir(file(new File("new"), className)); int new_rc = new_javah(options, newOutDir, bootclasspath, className); if (old_rc != new_rc) error("return codes differ; old: " + old_rc + ", new: " + new_rc); compare(oldOutDir, newOutDir); } int old_javah(List<String> options, File outDir, File bootclasspath, String className) throws IOException, InterruptedException { List<String> cmd = new ArrayList<String>(); cmd.add(old_javah_cmd.getPath()); cmd.addAll(options); cmd.add("-d"); cmd.add(outDir.getPath()); cmd.add("-bootclasspath"); cmd.add(bootclasspath.getPath()); cmd.add(className); System.err.println("old_javah: " + cmd); ProcessBuilder pb = new ProcessBuilder(cmd); pb.redirectErrorStream(true); Process p = pb.start(); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; StringBuilder sb = new StringBuilder(); while ((line = in.readLine()) != null) { sb.append(line); sb.append("\n"); } System.err.println("old javah out: " + sb.toString()); return p.waitFor(); } int new_javah(List<String> options, File outDir, File bootclasspath, String className) { List<String> args = new ArrayList<String>(); args.addAll(options); args.add("-d"); args.add(outDir.getPath()); args.add("-bootclasspath"); args.add(bootclasspath.getPath()); args.add(className); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); int rc = com.sun.tools.javah.Main.run(args.toArray(new String[args.size()]), pw); pw.close(); System.err.println("new javah out: " + sw.toString()); return rc; } Set<String> getNativeClasses(JarFile jar) throws IOException, ConstantPoolException { System.err.println("getNativeClasses: " + jar.getName()); Set<String> results = new TreeSet<String>(); Enumeration<JarEntry> e = jar.entries(); while (e.hasMoreElements()) { JarEntry je = e.nextElement(); if (isNativeClass(jar, je)) { String name = je.getName(); results.add(name.substring(0, name.length() - 6).replace("/", ".")); } } return results; } boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException { String name = entry.getName(); if (name.startsWith("META-INF") || !name.endsWith(".class")) return false; //String className = name.substring(0, name.length() - 6).replace("/", "."); //System.err.println("check " + className); InputStream in = jar.getInputStream(entry); ClassFile cf = ClassFile.read(in); for (int i = 0; i < cf.methods.length; i++) { Method m = cf.methods[i]; if (m.access_flags.is(AccessFlags.ACC_NATIVE)) { // System.err.println(className); return true; } } return false; } void compare(File f1, File f2) throws IOException { if (f1.isFile() && f2.isFile()) compareFiles(f1, f2); else if (f1.isDirectory() && f2.isDirectory()) compareDirectories(f1, f2); else error("files differ: " + f1 + " (" + getFileType(f1) + "), " + f2 + " (" + getFileType(f2) + ")"); } void compareDirectories(File d1, File d2) throws IOException { Set<String> list = new TreeSet<String>(); list.addAll(Arrays.asList(d1.list())); list.addAll(Arrays.asList(d2.list())); for (String c: list) compare(new File(d1, c), new File(d2, c)); } void compareFiles(File f1, File f2) throws IOException { byte[] c1 = readFile(f1); byte[] c2 = readFile(f2); if (!Arrays.equals(c1, c2)) error("files differ: " + f1 + ", " + f2); } byte[] readFile(File file) throws IOException { int size = (int) file.length(); byte[] data = new byte[size]; DataInputStream in = new DataInputStream(new FileInputStream(file)); try { in.readFully(data); } finally { in.close(); } return data; } String getFileType(File f) { return f.isDirectory() ? "directory" : f.isFile() ? "file" : f.exists() ? "other" : "not found"; } /** * Set up an empty directory. */ public File initDir(File dir) { if (dir.exists()) deleteAll(dir); dir.mkdirs(); return dir; } /** * Delete a file or a directory (including all its contents). */ boolean deleteAll(File file) { if (file.isDirectory()) { for (File f: file.listFiles()) deleteAll(f); } return file.delete(); } File file(File dir, String... path) { File f = dir; for (String p: path) f = new File(f, p); return f; } /** * Report an error. */ void error(String msg, String... more) { System.err.println("test: " + testOptions + " " + testClassName); System.err.println("error: " + msg); for (String s: more) System.err.println(s); errors++; System.exit(1); } File old_javah_cmd; File rt_jar; List<String> testOptions; String testClassName; int count; int errors; }
8,876
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FindNativeFiles.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/compareTest/FindNativeFiles.java
/* * Copyright (c) 2009, 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.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; import com.sun.tools.classfile.AccessFlags; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Method; import java.util.Comparator; import java.util.Set; import java.util.TreeSet; public class FindNativeFiles { public static void main(String[] args) throws IOException, ConstantPoolException { new FindNativeFiles().run(args); } public void run(String[] args) throws IOException, ConstantPoolException { JarFile jar = new JarFile(args[0]); Set<JarEntry> entries = getNativeClasses(jar); for (JarEntry e: entries) { String name = e.getName(); String className = name.substring(0, name.length() - 6).replace("/", "."); System.out.println(className); } } Set<JarEntry> getNativeClasses(JarFile jar) throws IOException, ConstantPoolException { Set<JarEntry> results = new TreeSet<JarEntry>(new Comparator<JarEntry>() { public int compare(JarEntry o1, JarEntry o2) { return o1.getName().compareTo(o2.getName()); } }); Enumeration<JarEntry> e = jar.entries(); while (e.hasMoreElements()) { JarEntry je = e.nextElement(); if (isNativeClass(jar, je)) results.add(je); } return results; } boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException { String name = entry.getName(); if (name.startsWith("META-INF") || !name.endsWith(".class")) return false; //String className = name.substring(0, name.length() - 6).replace("/", "."); //System.err.println("check " + className); InputStream in = jar.getInputStream(entry); ClassFile cf = ClassFile.read(in); in.close(); for (int i = 0; i < cf.methods.length; i++) { Method m = cf.methods[i]; if (m.access_flags.is(AccessFlags.ACC_NATIVE)) { // System.err.println(className); return true; } } return false; } }
3,359
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6572945.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/6572945/T6572945.java
/* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6572945 * @summary rewrite javah as an annotation processor, instead of as a doclet * @build TestClass1 TestClass2 TestClass3 * @run main T6572945 */ import java.io.*; import java.util.*; import com.sun.tools.javah.Main; public class T6572945 { static File testSrc = new File(System.getProperty("test.src", ".")); static File testClasses = new File(System.getProperty("test.classes", ".")); static boolean isWindows = System.getProperty("os.name").startsWith("Windows"); public static void main(String... args) throws IOException, InterruptedException { boolean ok = new T6572945().run(args); if (!ok) throw new Error("Test Failed"); } public boolean run(String[] args) throws IOException, InterruptedException { if (args.length == 1) jdk = new File(args[0]); test("-o", "jni.file.1", "-jni", "TestClass1"); test("-o", "jni.file.2", "-jni", "TestClass1", "TestClass2"); test("-d", "jni.dir.1", "-jni", "TestClass1", "TestClass2"); test("-o", "jni.file.3", "-jni", "TestClass3"); // The following tests are disabled because llni support has been // discontinued, and because bugs in old javah means that character // for character testing against output from old javah does not work. // In fact, the LLNI impl in new javah is actually better than the // impl in old javah because of a couple of significant bug fixes. // test("-o", "llni.file.1", "-llni", "TestClass1"); // test("-o", "llni.file.2", "-llni", "TestClass1", "TestClass2"); // test("-d", "llni.dir.1", "-llni", "TestClass1", "TestClass2"); // test("-o", "llni.file.3", "-llni", "TestClass3"); return (errors == 0); } void test(String... args) throws IOException, InterruptedException { String[] cp_args = new String[args.length + 2]; cp_args[0] = "-classpath"; cp_args[1] = testClasses.getPath(); System.arraycopy(args, 0, cp_args, 2, args.length); if (jdk != null) init(cp_args); File out = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("-o")) { out = new File(args[++i]); break; } else if (args[i].equals("-d")) { out = new File(args[++i]); out.mkdirs(); break; } } try { System.out.println("test: " + Arrays.asList(cp_args)); // // Uncomment and use the following lines to execute javah via the // // command line -- for example, to run old javah and set up the golden files // List<String> cmd = new ArrayList<String>(); // File javaHome = new File(System.getProperty("java.home")); // if (javaHome.getName().equals("jre")) // javaHome = javaHome.getParentFile(); // File javah = new File(new File(javaHome, "bin"), "javah"); // cmd.add(javah.getPath()); // cmd.addAll(Arrays.asList(cp_args)); // ProcessBuilder pb = new ProcessBuilder(cmd); // pb.redirectErrorStream(true); // pb.start(); // Process p = pb.start(); // String line; // BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); // while ((line = in.readLine()) != null) // System.err.println(line); // in.close(); // int rc = p.waitFor(); // Use new javah PrintWriter err = new PrintWriter(System.err, true); int rc = Main.run(cp_args, err); if (rc != 0) { error("javah failed: rc=" + rc); return; } // The golden files use the LL suffix for long constants, which // is used on Linux and Solaris. On Windows, the suffix is i64, // so compare will update the golden files on the fly before the // final comparison. compare(new File(new File(testSrc, "gold"), out.getName()), out); } catch (Throwable t) { t.printStackTrace(); error("javah threw exception"); } } void init(String[] args) throws IOException, InterruptedException { String[] cmdArgs = new String[args.length + 1]; cmdArgs[0] = new File(new File(jdk, "bin"), "javah").getPath(); System.arraycopy(args, 0, cmdArgs, 1, args.length); System.out.println("init: " + Arrays.asList(cmdArgs)); ProcessBuilder pb = new ProcessBuilder(cmdArgs); pb.directory(new File(testSrc, "gold")); pb.redirectErrorStream(true); Process p = pb.start(); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = in.readLine()) != null) System.out.println("javah: " + line); int rc = p.waitFor(); if (rc != 0) error("javah: exit code " + rc); } /** Compare two directories. * @param f1 The golden directory * @param f2 The directory to be compared */ void compare(File f1, File f2) { compare(f1, f2, null); } /** Compare two files or directories * @param f1 The golden directory * @param f2 The directory to be compared * @param p An optional path identifying a file within the two directories */ void compare(File f1, File f2, String p) { File f1p = (p == null ? f1 : new File(f1, p)); File f2p = (p == null ? f2 : new File(f2, p)); System.out.println("compare " + f1p + " " + f2p); if (f1p.isDirectory() && f2p.isDirectory()) { Set<String> children = new HashSet<String>(); children.addAll(Arrays.asList(f1p.list())); children.addAll(Arrays.asList(f2p.list())); for (String c: children) { compare(f1, f2, new File(p, c).getPath()); // null-safe for p } } else if (f1p.isFile() && f2p.isFile()) { String s1 = read(f1p); if (isWindows) { // f1/s1 is the golden file // on Windows, long constants use the i64 suffix, not LL s1 = s1.replaceAll("( [0-9]+)LL\n", "$1i64\n"); } String s2 = read(f2p); if (!s1.equals(s2)) { System.out.println("File: " + f1p + "\n" + s1); System.out.println("File: " + f2p + "\n" + s2); error("Files differ: " + f1p + " " + f2p); } } else if (f1p.exists() && !f2p.exists()) error("Only in " + f1 + ": " + p); else if (f2p.exists() && !f1p.exists()) error("Only in " + f2 + ": " + p); else error("Files differ: " + f1p + " " + f2p); } private String read(File f) { try { BufferedReader in = new BufferedReader(new FileReader(f)); try { StringBuilder sb = new StringBuilder((int) f.length()); String line; while ((line = in.readLine()) != null) { sb.append(line); sb.append("\n"); } return sb.toString(); } finally { try { in.close(); } catch (IOException e) { } } } catch (IOException e) { error("error reading " + f + ": " + e); return ""; } } private void error(String msg) { System.out.println(msg); errors++; } private int errors; private File jdk; }
8,898
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestClass2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/6572945/TestClass2.java
/* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public class TestClass2 { byte b; short s; int i; long l; float f; double d; Object o; String t; }
1,183
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestClass1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/6572945/TestClass1.java
/* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.util.List; public class TestClass1 { // simple types byte b; short s; int i; long l; float f; double d; Object o; String t; List<String> g; // constants static final byte bc = 0; static final short sc = 0; static final int ic = 0; static final long lc = 0; static final float fc = 0; static final double dc = 0; static final Object oc = null; static final String tc = ""; static final List<String> gc = null; // simple arrays byte[] ba; short[] sa; // not handled corrected by javah v6 int[] ia; long[] la; float[] fa; double[] da; Object[] oa; String[] ta; List<String>[] ga; // multidimensional arrays byte[][] baa; short[][] saa; int[][] iaa; long[][] laa; float[][] faa; double[][] daa; Object[][] oaa; String[][] taa; List<String>[] gaa; // simple Java methods byte bm() { return 0; } short sm() { return 0; } int im() { return 0; } long lm() { return 0; } float fm() { return 0; } double dm() { return 0; } Object om() { return null; } String tm() { return ""; } List<String> gm() { return null; } void vm() { } byte[] bam() { return null; } short[] sam() { return null; } int[] iam() { return null; } long[] lam() { return null; } float[] fam() { return null; } double[] dam() { return null; } Object[] oam() { return null; } String[] tam() { return null; } List<String>[] gam() { return null; } byte[][] baam() { return null; } short[][] saam() { return null; } int[][] iaam() { return null; } long[][] laam() { return null; } float[][] faam() { return null; } double[][] daam() { return null; } Object[][] oaam() { return null; } String[][] taam() { return null; } List<String>[] gaam() { return null; } // simple native methods native byte bmn(); native short smn(); native int imn(); native long lmn(); native float fmn(); native double dmn(); native Object omn(); native String tmn(); native List<String> gmn(); native void vmn(); native byte[] bamn(); native short[] samn(); native int[] iamn(); native long[] lamn(); native float[] famn(); native double[] damn(); native Object[] oamn(); native String[] tamn(); native List<String>[] gamn(); native byte[][] baamn(); native short[][] saamn(); native int[][] iaamn(); native long[][] laamn(); native float[][] faamn(); native double[][] daamn(); native Object[][] oaamn(); native String[][] taamn(); native List<String>[] gaamn(); // overloaded Java methods byte bm1() { return 0; } short sm1() { return 0; } int im1() { return 0; } long lm1() { return 0; } float fm1() { return 0; } double dm1() { return 0; } Object om1() { return null; } String tm1() { return ""; } List<String> gm1() { return null; } void vm1() { } byte bm2(int i) { return 0; } short sm2(int i) { return 0; } int im2(int i) { return 0; } long lm2(int i) { return 0; } float fm2(int i) { return 0; } double dm2(int i) { return 0; } Object om2(int i) { return null; } String tm2(int i) { return ""; } List<String> gm2(int i) { return null; } void vm2(int i) { } // overloaded native methods native byte bmn1(); native short smn1(); native int imn1(); native long lmn1(); native float fmn1(); native double dmn1(); native Object omn1(); native String tmn1(); native List<String> gmn1(); native void vmn1(); native byte bmn2(int i); native short smn2(int i); native int imn2(int i); native long lmn2(int i); native float fmn2(int i); native double dmn2(int i); native Object omn2(int i); native String tmn2(int i); native List<String> gmn2(int i); native void vmn2(int i); // arg types for Java methods void mb(byte b) { } void ms(short s) { } void mi(int i) { } void ml(long l) { } void mf(float f) { } void md(double d) { } void mo(Object o) { } void mt(String t) { } void mg(List<String> g) { } // arg types for native methods native void mbn(byte b); native void msn(short s); native void min(int i); native void mln(long l); native void mfn(float f); native void mdn(double d); native void mon(Object o); native void mtn(String t); native void mgn(List<String> g); static class Inner1 { // simple types byte b; short s; int i; long l; float f; double d; Object o; String t; List<String> g; // constants static final byte bc = 0; static final short sc = 0; static final int ic = 0; static final long lc = 0; static final float fc = 0; static final double dc = 0; static final Object oc = null; static final String tc = ""; static final List<String> gc = null; // simple arrays byte[] ba; // short[] sa; // not handled corrected by javah v6 int[] ia; long[] la; float[] fa; double[] da; Object[] oa; String[] ta; List<String>[] ga; // multidimensional arrays byte[][] baa; short[][] saa; int[][] iaa; long[][] laa; float[][] faa; double[][] daa; Object[][] oaa; String[][] taa; List<String>[] gaa; // simple Java methods byte bm() { return 0; } short sm() { return 0; } int im() { return 0; } long lm() { return 0; } float fm() { return 0; } double dm() { return 0; } Object om() { return null; } String tm() { return ""; } List<String> gm() { return null; } void vm() { } // simple native methods native byte bmn(); native short smn(); native int imn(); native long lmn(); native float fmn(); native double dmn(); native Object omn(); native String tmn(); native List<String> gmn(); native void vmn(); // overloaded Java methods byte bm1() { return 0; } short sm1() { return 0; } int im1() { return 0; } long lm1() { return 0; } float fm1() { return 0; } double dm1() { return 0; } Object om1() { return null; } String tm1() { return ""; } List<String> gm1() { return null; } void vm1() { } byte bm2(int i) { return 0; } short sm2(int i) { return 0; } int im2(int i) { return 0; } long lm2(int i) { return 0; } float fm2(int i) { return 0; } double dm2(int i) { return 0; } Object om2(int i) { return null; } String tm2(int i) { return ""; } List<String> gm2(int i) { return null; } void vm2(int i) { } // overloaded native methods native byte bmn1(); native short smn1(); native int imn1(); native long lmn1(); native float fmn1(); native double dmn1(); native Object omn1(); native String tmn1(); native List<String> gmn1(); native void vmn1(); native byte bmn2(int i); native short smn2(int i); native int imn2(int i); native long lmn2(int i); native float fmn2(int i); native double dmn2(int i); native Object omn2(int i); native String tmn2(int i); native List<String> gmn2(int i); native void vmn2(int i); // arg types for Java methods void mb(byte b) { } void ms(short s) { } void mi(int i) { } void ml(long l) { } void mf(float f) { } void md(double d) { } void mo(Object o) { } void mt(String t) { } void mg(List<String> g) { } // arg types for native methods native void mbn(byte b); native void msn(short s); native void min(int i); native void mln(long l); native void mfn(float f); native void mdn(double d); native void mon(Object o); native void mtn(String t); native void mgn(List<String> g); } class Inner2 { // simple types byte b; short s; int i; long l; float f; double d; Object o; String t; List<String> g; // constants static final byte bc = 0; static final short sc = 0; static final int ic = 0; static final long lc = 0; static final float fc = 0; static final double dc = 0; //static final Object oc = null; static final String tc = ""; //static final List<String> gc = null; // simple arrays byte[] ba; // short[] sa; // not handled corrected by javah v6 int[] ia; long[] la; float[] fa; double[] da; Object[] oa; String[] ta; List<String>[] ga; // multidimensional arrays byte[][] baa; short[][] saa; int[][] iaa; long[][] laa; float[][] faa; double[][] daa; Object[][] oaa; String[][] taa; List<String>[] gaa; // simple Java methods byte bm() { return 0; } short sm() { return 0; } int im() { return 0; } long lm() { return 0; } float fm() { return 0; } double dm() { return 0; } Object om() { return null; } String tm() { return ""; } List<String> gm() { return null; } void vm() { } // simple native methods native byte bmn(); native short smn(); native int imn(); native long lmn(); native float fmn(); native double dmn(); native Object omn(); native String tmn(); native List<String> gmn(); native void vmn(); // overloaded Java methods byte bm1() { return 0; } short sm1() { return 0; } int im1() { return 0; } long lm1() { return 0; } float fm1() { return 0; } double dm1() { return 0; } Object om1() { return null; } String tm1() { return ""; } List<String> gm1() { return null; } void vm1() { } byte bm2(int i) { return 0; } short sm2(int i) { return 0; } int im2(int i) { return 0; } long lm2(int i) { return 0; } float fm2(int i) { return 0; } double dm2(int i) { return 0; } Object om2(int i) { return null; } String tm2(int i) { return ""; } List<String> gm2(int i) { return null; } void vm2(int i) { } // overloaded native methods native byte bmn1(); native short smn1(); native int imn1(); native long lmn1(); native float fmn1(); native double dmn1(); native Object omn1(); native String tmn1(); native List<String> gmn1(); native void vmn1(); native byte bmn2(int i); native short smn2(int i); native int imn2(int i); native long lmn2(int i); native float fmn2(int i); native double dmn2(int i); native Object omn2(int i); native String tmn2(int i); native List<String> gmn2(int i); native void vmn2(int i); // arg types for Java methods void mb(byte b) { } void ms(short s) { } void mi(int i) { } void ml(long l) { } void mf(float f) { } void md(double d) { } void mo(Object o) { } void mt(String t) { } void mg(List<String> g) { } // arg types for native methods native void mbn(byte b); native void msn(short s); native void min(int i); native void mln(long l); native void mfn(float f); native void mdn(double d); native void mon(Object o); native void mtn(String t); native void mgn(List<String> g); } }
13,331
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestClass3.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/6572945/TestClass3.java
/* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public class TestClass3 { public int tc3; public class Inner1 { public int tc3i1; public class Inner1A { public int tc3i1i1a; } public class Inner1B { public int tc3i1i1b; } } public class Inner2 { public int tc321; public class Inner2A { public int tc3i2i2a; } public class Inner2B { public int tc3i2i2b; } } }
1,519
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ParamClassTest.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/4942232/ParamClassTest.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. */ public class ParamClassTest { static { System.loadLibrary("Test"); } public native void method(Param s); public static void main(String[] a) { } } class Param { }
1,246
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/javah/4942232/Test.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 4942232 * @summary missing param class processes without error * @build ParamClassTest Test * @run main Test */ import java.io.*; import java.util.*; public class Test { public static void main(String... args) throws Exception { new Test().run(); } void run() throws Exception { File testSrc = new File(System.getProperty("test.src")); File testClasses = new File(System.getProperty("test.classes")); // standard use of javah on valid class file String[] test1Args = { "-d", mkdir("test1/out").getPath(), "-classpath", testClasses.getPath(), "ParamClassTest" }; test(test1Args, 0); // extended use of javah on valid source file String[] test2Args = { "-d", mkdir("test2/out").getPath(), "-classpath", testSrc.getPath(), "ParamClassTest" }; test(test2Args, 0); // javah on class file with missing referents File test3Classes = mkdir("test3/classes"); copy(new File(testClasses, "ParamClassTest.class"), test3Classes); String[] test3Args = { "-d", mkdir("test3/out").getPath(), "-classpath", test3Classes.getPath(), "ParamClassTest" }; test(test3Args, 1); // javah on source file with missing referents File test4Src = mkdir("test4/src"); String paramClassTestSrc = readFile(new File(testSrc, "ParamClassTest.java")); writeFile(new File(test4Src, "ParamClassTest.java"), paramClassTestSrc.replaceAll("class Param \\{\\s+\\}", "")); String[] test4Args = { "-d", mkdir("test4/out").getPath(), "-classpath", test4Src.getPath(), "ParamClassTest" }; test(test4Args, 15); if (errors > 0) throw new Exception(errors + " errors occurred"); } void test(String[] args, int expect) { System.err.println("test: " + Arrays.asList(args)); int rc = javah(args); if (rc != expect) error("Unexpected return code: " + rc + "; expected: " + expect); } int javah(String... args) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); int rc = com.sun.tools.javah.Main.run(args, pw); pw.close(); String out = sw.toString(); if (!out.isEmpty()) System.err.println(out); return rc; } File mkdir(String path) { File f = new File(path); f.mkdirs(); return f; } void copy(File from, File to) throws IOException { if (to.isDirectory()) to = new File(to, from.getName()); try (DataInputStream in = new DataInputStream(new FileInputStream(from)); FileOutputStream out = new FileOutputStream(to)) { byte[] buf = new byte[(int) from.length()]; in.readFully(buf); out.write(buf); } } String readFile(File f) throws IOException { try (DataInputStream in = new DataInputStream(new FileInputStream(f))) { byte[] buf = new byte[(int) f.length()]; in.readFully(buf); return new String(buf); } } void writeFile(File f, String body) throws IOException { try (FileWriter out = new FileWriter(f)) { out.write(body); } } void error(String msg) { System.err.println(msg); errors++; } int errors; }
4,628
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
foo.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/6257087/foo.java
/* * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ class foo { class bar { public native void aardvark(); } }
1,134
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
java.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/T7126832/java.java
/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package xx; class java { int fred; }
1,093
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7126832.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javah/T7126832/T7126832.java
/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 7126832 * @compile java.java * @summary com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast * @run main T7126832 */ import java.io.*; import java.util.*; public class T7126832 { public static void main(String... args) throws Exception { new T7126832().run(); } void run() throws Exception { Locale prev = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); try { // Verify that a .java file is correctly diagnosed File ff = writeFile(new File("JavahTest.java"), "class JavahTest {}"); test(Arrays.asList(ff.getPath()), 1, "Could not find class file for 'JavahTest.java'."); // Verify that a class named 'xx.java' is accepted. // Note that ./xx/java.class exists, so this should work ok test(Arrays.asList("xx.java"), 0, null); if (errors > 0) { throw new Exception(errors + " errors occurred"); } } finally { Locale.setDefault(prev); } } void test(List<String> args, int expectRC, String expectOut) { System.err.println("Test: " + args + " rc:" + expectRC + ((expectOut != null) ? " out:" + expectOut : "")); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); int rc = 0; String out = null; try { rc = com.sun.tools.javah.Main.run(args.toArray(new String[args.size()]), pw); out = sw.toString(); } catch(Exception ee) { rc = 1; out = ee.toString();; } pw.close(); if (!out.isEmpty()) { System.err.println(out); } if (rc != expectRC) { error("Unexpected exit code: " + rc + "; expected: " + expectRC); } if (expectOut != null && !out.contains(expectOut)) { error("Expected string not found: " + expectOut); } System.err.println(); } File writeFile(File ff, String ss) throws IOException { if (ff.getParentFile() != null) ff.getParentFile().mkdirs(); try (FileWriter out = new FileWriter(ff)) { out.write(ss); } return ff; } void error(String msg) { System.err.println(msg); errors++; } int errors; }
3,476
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MethodAnnotations.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/MethodAnnotations.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import annot.*; import annot.annot2.*; public class MethodAnnotations { static double d; @MySimple("value") @MyMarker @AnnotMarker @AnnotSimple("foo") @AnnotMarker2 @AnnotSimple2("bar") public void foo() { return; } private double bar(int baz) { @AnnotShangri_la int local = 0; return (double) baz; } static class NestedClass { protected int field; } }
1,496
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
StaticFieldAnnotations.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/StaticFieldAnnotations.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import annot.*; import annot.annot2.*; public class StaticFieldAnnotations { @MySimple("value") @MyMarker @AnnotMarker @AnnotSimple("foo") @AnnotMarker2 @AnnotSimple2("bar") static double d; public void foo() { return; } private double bar(int baz) { @AnnotShangri_la int local = 0; return (double) baz; } static class NestedClass { protected int field; } }
1,501
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FreshnessApf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/FreshnessApf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Indirect test of whether source or class files are used to provide * declaration information. */ public class FreshnessApf implements AnnotationProcessorFactory { // Process any set of annotations private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new FreshnessAp(env); } private static class FreshnessAp implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; FreshnessAp(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { System.out.println("Testing for freshness."); boolean empty = true; for (TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) { for (FieldDeclaration fieldDecl: typeDecl.getFields() ) { empty = false; System.out.println(typeDecl.getQualifiedName() + "." + fieldDecl.getSimpleName()); // Verify the declaration for the type of the // field is a class with an annotation. System.out.println(((DeclaredType) fieldDecl.getType()).getDeclaration().getAnnotationMirrors()); if (((DeclaredType) fieldDecl.getType()).getDeclaration().getAnnotationMirrors().size() == 0) env.getMessager().printError("Expected an annotation."); } } if (empty) env.getMessager().printError("No fields encountered."); } } }
3,446
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
StaticMethodAnnotations.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/StaticMethodAnnotations.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import annot.*; import annot.annot2.*; public class StaticMethodAnnotations { static double d; public void foo() { return; } @MySimple("value") @MyMarker @AnnotMarker @AnnotSimple("foo") @AnnotMarker2 @AnnotSimple2("bar") public static void baz() { } private double bar(int baz) { @AnnotShangri_la int local = 0; return (double) baz; } static class NestedClass { protected int field; } }
1,540
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
NullAPF.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/NullAPF.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; public class NullAPF implements AnnotationProcessorFactory { static class NullAP implements AnnotationProcessor { NullAP(AnnotationProcessorEnvironment ape) { } public void process() { return; } } static Collection<String> supportedTypes; static { String types[] = {"*"}; supportedTypes = java.util.Arrays.asList(types); } /* * Processor doesn't examine any options. */ public Collection<String> supportedOptions() { return java.util.Collections.emptySet(); } /* * All annotation types are supported. */ public Collection<String> supportedAnnotationTypes() { return supportedTypes; } /* * Return the same processor independent of what annotations are * present, if any. */ public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new NullAP(env); } }
2,278
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MisMatch.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/MisMatch.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Class that uses constructs whose language and vm interpretation * differ. */ public class MisMatch { static final int constant = 3; static int notConstant = 4; private static strictfp class NestedClass { } protected abstract class AbstractNestedClass { /** * Another doc comment. * * This one has multiple lines. */ void myMethod() throws RuntimeException , Error {} abstract void myAbstractMethod(); } void VarArgsMethod1(Number... num) { ; } void VarArgsMethod2(float f, double d, Number... num) { ; } } @interface Colors { } interface Inter { void interfaceMethod(); } enum MyEnum { RED, GREEN, BLUE; }
1,814
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Misc.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/Misc.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * Class with miscellaneous structures to exercise printing. */ import java.util.Collection; public final class Misc<T> implements Marker2, Marker3 { private static final long longConstant = Long.MAX_VALUE; private static final String asciispecials = "\t\n\u0007"; public void covar(Collection<? extends T> s) {return;} public void contravar(Collection<? super T> s) {return;} public <S> S varUse(int i) {return null;} Object o = (new Object() {}); // verify fix for 5019108 } interface Marker1 {} interface Marker2 extends Marker1 {} interface Marker3 {}
1,660
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Aggregate.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/Aggregate.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public class Aggregate { static { System.out.println("xxyzzy"); } private Aggregate() {} private static double hypot(double Berkeley, double SantaCruz) { return 0.0; } public int hashcode() {return 42;} public boolean equals(Aggregate a) {return this == a;} public static void main(String[] argv) { System.out.println("Hello World."); } }
1,462
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Lacuna.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/Lacuna.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ class Lacuna extends Missing {}
1,091
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ParameterAnnotations.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/ParameterAnnotations.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import annot.*; import annot.annot2.*; public class ParameterAnnotations { static double d; public void foo() { return; } private double bar(@MySimple("value") @MyMarker @AnnotMarker @AnnotSimple("foo") @AnnotMarker2 @AnnotSimple2("bar") int baz) { @AnnotShangri_la int local = 0; return (double) baz; } static class NestedClass { protected int field; } }
1,556
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Indirect.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/Indirect.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * Class that is used to provide a pointer to another class * declaration. */ public class Indirect { Milk skim = null; }
1,190
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestGetTypeDeclarationApf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/TestGetTypeDeclarationApf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * This class is used to test getTypeDeclaration on classes that are * not already loaded. */ public class TestGetTypeDeclarationApf implements AnnotationProcessorFactory { // Process any set of annotations private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new TestGetTypeDeclarationAp(env); } private static class TestGetTypeDeclarationAp implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; TestGetTypeDeclarationAp(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { String classNames[] = { "java.lang.String", // should be already available "java.lang.Thread.State", // should be already available "java.util.Collection", "java.util.Map.Entry", "foo.bar.Baz.Xxyzzy.Wombat", "foo.bar.Baz.Xxyzzy", "foo.bar.Baz", "foo.bar.Quux", "foo.bar.Quux.Xxyzzy", "foo.bar.Quux.Xxyzzy.Wombat", "NestedClassAnnotations", "NestedClassAnnotations.NestedClass", }; for(String className: classNames) { TypeDeclaration t = env.getTypeDeclaration(className); if (t == null) throw new RuntimeException("No declaration found for " + className); if (! t.getQualifiedName().equals(className)) throw new RuntimeException("Class with wrong name found for " + className); } // Test obscuring behavior; i.e. nested class C1 in class // p1 where p1 is member of package p2 should be favored // over class C1 in package p1.p2. String nonuniqueCanonicalNames[] = { "p1.p2.C1", }; for(String className: nonuniqueCanonicalNames) { ClassDeclaration c1 = (ClassDeclaration) env.getTypeDeclaration(className); ClassDeclaration c2 = (ClassDeclaration) c1.getDeclaringType(); PackageDeclaration p = env.getPackage("p1"); if (!p.equals(c1.getPackage()) || c2 == null || !"C1".equals(c1.getSimpleName())) { throw new RuntimeException("Bad class declaration"); } } String notClassNames[] = { "", "XXYZZY", "java", "java.lang", "java.lang.Bogogogous", "1", "1.2", "3.14159", "To be or not to be is a tautology", "1+2=3", "foo+.x", "foo+x", "+", "?", "***", "java.*", }; for(String notClassName: notClassNames) { Declaration t = env.getTypeDeclaration(notClassName); if (t != null) { System.err.println("Unexpected declaration:" + t); throw new RuntimeException("Declaration found for ``" + notClassName + "''."); } } } } }
5,196
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MyMarker.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/MyMarker.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public @interface MyMarker { }
1,091
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
NestedClassAnnotations.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/NestedClassAnnotations.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import annot.*; import annot.annot2.*; public class NestedClassAnnotations { static double d; public void foo() { return; } public static void baz() { } private double bar(int baz) { @AnnotShangri_la int local = 0; return (double) baz; } @MySimple("value") @MyMarker @AnnotMarker @AnnotSimple("foo") @AnnotMarker2 @AnnotSimple2("bar") static class NestedClass { protected int field; } }
1,539
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Milk.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/Milk.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.lang.annotation.*; @Fresh public class Milk { // Moo. } @Retention(RetentionPolicy.SOURCE) @interface Fresh { }
1,189
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassAnnotations.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/ClassAnnotations.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import annot.*; import annot.annot2.*; @MySimple("value") @MyMarker @AnnotMarker @AnnotSimple("foo") @AnnotMarker2 @AnnotSimple2("bar") public class ClassAnnotations { static double d; public void foo() { return; } private double bar(int baz) { @AnnotShangri_la int local = 0; return (double) baz; } static class NestedClass { protected int field; } }
1,483
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestGetPackageApf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/TestGetPackageApf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * This class is used to test getPackage on classes that are * not already loaded. */ public class TestGetPackageApf implements AnnotationProcessorFactory { // Process any set of annotations private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new TestGetPackageAp(env); } private static class TestGetPackageAp implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; TestGetPackageAp(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { boolean failed = false; String packageNames[] = { "", // unnamed package "java.lang.annotation", "java.lang", "java.util", "java.awt.image.renderable", "foo.bar", "foo", "p1", // "p1.p2", // class p1.p2 obscures package p1.p2 }; for(String packageName: packageNames) { PackageDeclaration p = env.getPackage(packageName); if (p == null) { failed = true; System.err.println("ERROR: No declaration found for ``" + packageName + "''."); } else if (!packageName.equals(p.getQualifiedName())) { failed = true; System.err.println("ERROR: Unexpected package name; expected " + packageName + "got " + p.getQualifiedName()); } } String notPackageNames[] = { "XXYZZY", "java.lang.String", "1", "1.2", "3.14159", "To be or not to be is a tautology", "1+2=3", }; for(String notPackageName: notPackageNames) { PackageDeclaration p = env.getPackage(notPackageName); if (p != null) { failed = true; System.err.println("ERROR: Unexpected declaration: ``" + p + "''."); } } if (failed) throw new RuntimeException("Errors found testing getPackage."); } } }
4,174
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MySimple.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/MySimple.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public @interface MySimple { String value() default "default"; }
1,129
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
GenClass.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/GenClass.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * A trivial generic class to test the fix for 5018369. */ class GenClass<T> { }
1,145
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotMarker.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/annot/AnnotMarker.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package annot; public @interface AnnotMarker { }
1,109
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotSimple.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/annot/AnnotSimple.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package annot; public @interface AnnotSimple { String value() default "default"; }
1,147
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotShangri_la.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/annot/AnnotShangri_la.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package annot; /* * This annotation is used by the tests only to annotate local * variables; therefore, this annotation should not affect the * discovery process and should not appear in the list printed by * -XListAnnotationTypes. */ public @interface AnnotShangri_la { }
1,338
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotSimple2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/annot/annot2/AnnotSimple2.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package annot.annot2; public @interface AnnotSimple2 { String value() default "default"; }
1,155
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotMarker2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/annot/annot2/AnnotMarker2.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package annot.annot2; public @interface AnnotMarker2 { }
1,117
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Baz.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/foo/bar/Baz.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package foo.bar; public class Baz { public class Xxyzzy { public class Wombat { } } }
1,171
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Quux.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/foo/bar/Quux.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package foo.bar; public class Quux { public class Xxyzzy { public class Wombat { } } }
1,172
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
p2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/p1/p2.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package p1; public class p2 { public static class C1 {} }
1,122
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
C1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Basics/p1/p2/C1.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package p1.p2; public class C1 { }
1,095
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Ignore.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/lib/Ignore.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.lang.annotation.*; /** * An annotation used to indicate that a test -- a method annotated * with @Test -- should not be executed. * * @author Scott Seligman */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Ignore { /** * Reason for ignoring this test. */ String value() default ""; }
1,416
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestProcessorFactory.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/lib/TestProcessorFactory.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.util.*; import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.util.*; /** * A factory for generating the TestProcessor annotation processor, which * processes the @Test annotation. * * @author Scott Seligman */ public class TestProcessorFactory implements AnnotationProcessorFactory { public Collection<String> supportedOptions() { return new ArrayList<String>(); } public Collection<String> supportedAnnotationTypes() { ArrayList<String> res = new ArrayList<String>(); res.add("Test"); res.add("Ignore"); return res; } public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> as, AnnotationProcessorEnvironment env) { // The tester that's running. Tester tester = Tester.activeTester; try { // Find the tester's class declaration. ClassDeclaration testerDecl = null; for (TypeDeclaration decl : env.getSpecifiedTypeDeclarations()) { if (decl.getQualifiedName().equals( tester.getClass().getName())) { testerDecl = (ClassDeclaration) decl; break; } } // Give the tester access to its own declaration and to the env. tester.thisClassDecl = testerDecl; tester.env = env; // Initializer the tester. tester.init(); return new TestProcessor(env, tester); } catch (Exception e) { throw new Error("Couldn't create test annotation processor", e); } } }
2,818
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Tester.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/lib/Tester.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * A utility used to invoke and test the apt tool. * Tests should subclass Tester, and invoke run(). * * @author Scott Seligman */ import java.io.*; import java.util.*; import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; public abstract class Tester { /** * The declaration corresponding to this tester's class. Set by * TestProcessorFactory after the constructor completes, and * before init() is invoked. */ ClassDeclaration thisClassDecl; /** * The environment for this apt run. Set by TestProcessorFactory * after the constructor completes, and before init() is invoked. */ AnnotationProcessorEnvironment env; // TestProcessorFactory looks here to find the tester that's running // when it's invoked. static Tester activeTester; private static final String[] DEFAULT_ARGS = { "-nocompile", "-XPrintAptRounds", "-XListDeclarations", }; private static final String[] NO_STRINGS = {}; // Force processor and factory to be compiled private static Class dummy = TestProcessorFactory.class; private final String testSrc = System.getProperty("test.src", "."); private final String testClasses = System.getProperty("test.classes", "."); // apt command-line args private String[] args; static { // Enable assertions in the unnamed package. ClassLoader loader = Tester.class.getClassLoader(); if (loader != null) { loader.setPackageAssertionStatus(null, true); } } protected Tester(String... additionalArgs) { String sourceFile = testSrc + File.separator + getClass().getName() + ".java"; ArrayList<String> as = new ArrayList<String>(); Collections.addAll(as, DEFAULT_ARGS); as.add("-sourcepath"); as.add(testSrc); as.add("-factory"); as.add(TestProcessorFactory.class.getName()); Collections.addAll(as, additionalArgs); as.add(sourceFile); args = as.toArray(NO_STRINGS); } /** * Run apt. */ protected void run() { activeTester = this; if (com.sun.tools.apt.Main.process(args) != 0) { throw new Error("apt errors encountered."); } } /** * Called after thisClassDecl and env have been set, but before any * tests are run, to allow the tester subclass to perform any * needed initialization. */ protected void init() { } /** * Returns the declaration of a named method in this class. If this * method name is overloaded, one method is chosen arbitrarily. * Returns null if no method is found. */ protected MethodDeclaration getMethod(String methodName) { for (MethodDeclaration m : thisClassDecl.getMethods()) { if (methodName.equals(m.getSimpleName())) { return m; } } return null; } /** * Returns the declaration of a named field in this class. * Returns null if no field is found. */ protected FieldDeclaration getField(String fieldName) { for (FieldDeclaration f : thisClassDecl.getFields()) { if (fieldName.equals(f.getSimpleName())) { return f; } } return null; } /** * Returns the annotation mirror of a given type on a named method * in this class. If this method name is overloaded, one method is * chosen arbitrarily. Returns null if no appropriate annotation * is found. */ protected AnnotationMirror getAnno(String methodName, String annoType) { MethodDeclaration m = getMethod(methodName); if (m != null) { TypeDeclaration at = env.getTypeDeclaration(annoType); for (AnnotationMirror a : m.getAnnotationMirrors()) { if (at == a.getAnnotationType().getDeclaration()) { return a; } } } return null; } }
5,134
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestProcessor.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/lib/TestProcessor.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.lang.reflect.Method; import java.util.*; import com.sun.mirror.apt.*; /** * Annotation processor for the @Test annotation. * Invokes each method so annotated, and verifies the result. * Throws an Error on failure. * * @author Scott Seligman */ public class TestProcessor implements AnnotationProcessor { AnnotationProcessorEnvironment env; // The tester that's running. Tester tester = Tester.activeTester; TestProcessor(AnnotationProcessorEnvironment env, Tester tester) { this.env = env; this.tester = tester; } /** * Reflectively invoke the @Test-annotated methods of the live * tester. Those methods perform the actual exercising of the * mirror API. Then back here to verify the results by * reading the live annotations. Convoluted, you say? */ public void process() { System.out.printf("\n> Processing %s\n", tester.getClass()); boolean failed = false; // true if a test returns wrong result for (Method m : tester.getClass().getDeclaredMethods()) { Test anno = m.getAnnotation(Test.class); Ignore ignore = m.getAnnotation(Ignore.class); if (anno != null) { if (ignore == null) { System.out.println(">> Invoking test " + m.getName()); Object result; try { result = m.invoke(tester); } catch (Exception e) { throw new Error("Test invocation failed", e); } boolean ok = true; // result of this test if (Collection.class.isAssignableFrom(m.getReturnType())) { ok = verifyResults((Collection) result, anno.result(), anno.ordered()); } else if (m.getReturnType() != void.class) { ok = verifyResult(result, anno.result()); } if (!ok) { System.out.println(">>> Expected: " + anno); System.out.println(">>> Got: " + result); failed = true; } } else { System.out.println(">> Ignoring test " + m.getName()); if (ignore.value().length() > 0) { System.out.println(">>> Reason: " + ignore.value()); } } } } if (failed) { throw new Error("Test(s) returned unexpected result"); } } /** * Verify that a single-valued (non-Collection) result matches * its expected value. */ private boolean verifyResult(Object result, String[] expected) { assert expected.length == 1 : "Single-valued test expecting " + expected.length + " results"; return expected[0].equals(String.valueOf(result)); } /** * Verify that a multi-valued result (a Collection) matches * its expected values. */ private boolean verifyResults(Collection result, String[] expected, boolean ordered) { if (result.size() != expected.length) { return false; } // Convert result to an array of strings. String[] res = new String[result.size()]; int i = 0; for (Object e : result) { res[i++] = String.valueOf(e); } if (!ordered) { Arrays.sort(res); Arrays.sort(expected); } return Arrays.equals(res, expected); } }
4,770
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/apt/lib/Test.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.lang.annotation.*; /** * An annotation used to indicate that a method constitutes a test, * and which provides the expected result. The method must take no parameters. * * @author Scott Seligman */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Test { /** * An array containing the method's expected result (or * elements of the result if the return type is a Collection). * Value is ignored if return type is void. * Entries are converted to strings via {@link String#valueOf(Object)}. */ String[] result() default {}; /** * True if the order of the elements in result() is significant. */ boolean ordered() default false; }
1,792
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MemberOrderApf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Scanners/MemberOrderApf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * The processor of this factory verifies class members are returned * in source-code order. */ public class MemberOrderApf implements AnnotationProcessorFactory { // Process any set of annotations private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new MemberOrderAp(env); } private static class MemberOrderAp implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; MemberOrderAp(AnnotationProcessorEnvironment env) { this.env = env; } private void verifyOrder(Collection<? extends Declaration> decls) { int count = 0; for(Declaration decl: decls) { VisitOrder order = decl.getAnnotation(VisitOrder.class); if (order.value() <= count) throw new RuntimeException("Out of order declarations"); count = order.value(); } } public void process() { for(TypeDeclaration td: env.getSpecifiedTypeDeclarations()) { verifyOrder(td.getFields()); verifyOrder(td.getMethods()); } } } }
3,040
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/apt/Scanners/TestEnum.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public enum TestEnum { QUIZ, EXAM, MIDTERM, FINAL, QUALIFIER; }
1,143
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VisitOrder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Scanners/VisitOrder.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * Integer to indicate what order a declaration is expected to be * visited in by a DeclarationScanner. */ @interface VisitOrder { int value(); }
1,215
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Scanner.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Scanners/Scanner.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Map; import java.util.Arrays; import java.util.Collections; public class Scanner implements AnnotationProcessorFactory { static class ScannerProc implements AnnotationProcessor { AnnotationProcessorEnvironment env; ScannerProc(AnnotationProcessorEnvironment env) { this.env = env; } static class CountingVisitor extends SimpleDeclarationVisitor { int count; CountingVisitor() { count = 0; } public void visitDeclaration(Declaration d) { count++; Collection<AnnotationMirror> ams = d.getAnnotationMirrors(); if (ams == null) throw new RuntimeException("Declaration " + d + " not annotated with visit order."); else { if (ams.size() != 1) throw new RuntimeException("Declaration " + d + " has wrong number of declarations."); else { for(AnnotationMirror am: ams) { Map<AnnotationTypeElementDeclaration,AnnotationValue> elementValues = am.getElementValues(); for(AnnotationTypeElementDeclaration atmd: elementValues.keySet()) { if (!atmd.getDeclaringType().toString().equals("VisitOrder")) throw new RuntimeException("Annotation " + atmd + " is the wrong type."); else { AnnotationValue av = elementValues.get(atmd); Integer value = (Integer) av.getValue(); if (value.intValue() != count) throw new RuntimeException("Expected declaration " + d + " to be in position " + count + " instead of " + value.intValue()); System.out.println("Declaration " + d + ": visit order " + value.intValue()); } } } } } } } public void process() { for(TypeDeclaration td: env.getSpecifiedTypeDeclarations() ) { td.accept(DeclarationVisitors.getSourceOrderDeclarationScanner(new CountingVisitor(), DeclarationVisitors.NO_OP)); } } } static Collection<String> supportedTypes; static { String types[] = {"*"}; supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); } static Collection<String> supportedOptions; static { String options[] = {""}; supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options)); } public Collection<String> supportedOptions() { return supportedOptions; } public Collection<String> supportedAnnotationTypes() { return supportedTypes; } public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new ScannerProc(env); } }
4,934
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Counter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Scanners/Counter.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Used to verify counts from different kinds of declaration scanners. */ public class Counter implements AnnotationProcessorFactory { static class CounterProc implements AnnotationProcessor { static class CountingVisitor extends SimpleDeclarationVisitor { int count; int count() { return count; } CountingVisitor() { count = 0; } public void visitDeclaration(Declaration d) { count++; System.out.println(d.getSimpleName()); } } AnnotationProcessorEnvironment env; CounterProc(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { for(TypeDeclaration td: env.getSpecifiedTypeDeclarations() ) { CountingVisitor sourceOrder = new CountingVisitor(); CountingVisitor someOrder = new CountingVisitor(); System.out.println("Source Order Scanner"); td.accept(getSourceOrderDeclarationScanner(sourceOrder, NO_OP)); System.out.println("\nSome Order Scanner"); td.accept(getDeclarationScanner(someOrder, NO_OP)); if (sourceOrder.count() != someOrder.count() ) throw new RuntimeException("Counts from different scanners don't agree"); } } } static Collection<String> supportedTypes; static { String types[] = {"*"}; supportedTypes = unmodifiableCollection(Arrays.asList(types)); } static Collection<String> supportedOptions; static { String options[] = {""}; supportedOptions = unmodifiableCollection(Arrays.asList(options)); } public Collection<String> supportedOptions() { return supportedOptions; } public Collection<String> supportedAnnotationTypes() { return supportedTypes; } public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new CounterProc(env); } }
3,664
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Order.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Scanners/Order.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ @VisitOrder(1) public class Order { @VisitOrder(2) static double d; @VisitOrder(3) private Order() {} @VisitOrder(4) int i; @VisitOrder(5) static class InnerOrder { @VisitOrder(6) InnerOrder(){} @VisitOrder(7) String toString() {return "";} } @VisitOrder(8) String toString() {return "";} @VisitOrder(9) InnerOrder io; @VisitOrder(10) String foo() {return toString();} }
1,530
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PackageDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/PackageDecl.java
/* * Copyright (c) 2004, 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 4853450 5031168 * @summary PackageDeclaration tests * @library ../../lib * @compile -source 1.5 PackageDecl.java * @run main/othervm PackageDecl */ import java.io.File; import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import pkg1.pkg2.*; /** * Sed Quis custodiet ipsos custodes? */ public class PackageDecl extends Tester { public PackageDecl() { super(System.getProperty("test.src", ".") + File.separator + "pkg1" + File.separator + "package-info.java"); } public static void main(String[] args) { (new PackageDecl()).run(); } private PackageDeclaration pkg1 = null; // a package private PackageDeclaration pkg2 = null; // a subpackage protected void init() { pkg1 = env.getPackage("pkg1"); pkg2 = env.getPackage("pkg1.pkg2"); } // Declaration methods @Test(result="package") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); pkg1.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitPackageDeclaration(PackageDeclaration p) { res.add("package"); } }); return res; } @Test(result={"@pkg1.AnAnnoType"}) Collection<AnnotationMirror> getAnnotationMirrors() { return pkg1.getAnnotationMirrors(); } @Test(result=" Herein lieth the package comment.\n" + " A doc comment it be, and wonderous to behold.\n") String getDocCommentFromPackageInfoFile() { return pkg1.getDocComment(); } @Test(result="\nHerein lieth the package comment.\n" + "An HTML file it be, and wonderous to behold.\n\n") @Ignore("Not yet supported") String getDocCommentFromHtmlFile() { return pkg2.getDocComment(); } @Test(result={}) Collection<Modifier> getModifiers() { return pkg1.getModifiers(); } @Test(result="null") SourcePosition getPosition() { return thisClassDecl.getPackage().getPosition(); } @Test(result="package-info.java") String getPositionFromPackageInfoFile() { return pkg1.getPosition().file().getName(); } @Test(result="pkg1/pkg2/package.html") @Ignore("Not yet supported") String getPositionFromHtmlFile() { return pkg2.getPosition().file().getName() .replace(File.separatorChar, '/'); } @Test(result="pkg1") String getSimpleName1() { return pkg1.getSimpleName(); } @Test(result="pkg2") String getSimpleName2() { return pkg2.getSimpleName(); } // PackageDeclaration methods @Test(result="pkg1.AnAnnoType") Collection<AnnotationTypeDeclaration> getAnnotationTypes() { return pkg1.getAnnotationTypes(); } @Test(result={"pkg1.AClass", "pkg1.AnEnum"}) Collection<ClassDeclaration> getClasses() { return pkg1.getClasses(); } @Test(result="pkg1.AnEnum") Collection<EnumDeclaration> getEnums() { return pkg1.getEnums(); } @Test(result={"pkg1.AnInterface", "pkg1.AnAnnoType"}) Collection<InterfaceDeclaration> getInterfaces() { return pkg1.getInterfaces(); } @Test(result="pkg1") String getQualifiedName1() { return pkg1.getQualifiedName(); } @Test(result="pkg1.pkg2") String getQualifiedName2() { return pkg2.getQualifiedName(); } }
4,729
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/ClassDecl.java
/* * Copyright (c) 2004, 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 4853450 4997614 * @summary ClassDeclaration tests * @library ../../lib * @compile -source 1.5 ClassDecl.java * @run main/othervm ClassDecl */ import java.io.Serializable; import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; /** * Sed Quis custodiet ipsos custodes? */ @AT1 @AT2 public class ClassDecl extends Tester { public static void main(String[] args) { (new ClassDecl()).run(); } private ClassDeclaration nested = null; // a nested type private ClassDeclaration object = null; // java.lang.object // A constructor to be found private ClassDecl() { } // Another constructor to be found private ClassDecl(int i) { this(); } // An extra field to be found static int i; // Static initializer isn't among this class's methods. static { i = 7; } // A nested class with some accoutrements private static strictfp class NestedClass<T> implements Serializable { void m1() {} void m2() {} void m2(int i) {} } protected void init() { nested = (ClassDeclaration) thisClassDecl.getNestedTypes().iterator().next(); object = (ClassDeclaration) env.getTypeDeclaration("java.lang.Object"); } // Declaration methods @Test(result="class") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); thisClassDecl.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitClassDeclaration(ClassDeclaration c) { res.add("class"); } public void visitEnumDeclaration(EnumDeclaration e) { res.add("enum"); } }); return res; } @Test(result={"@AT1", "@AT2"}) Collection<AnnotationMirror> getAnnotationMirrors() { return thisClassDecl.getAnnotationMirrors(); } @Test(result=" Sed Quis custodiet ipsos custodes?\n") String getDocComment() { return thisClassDecl.getDocComment(); } @Test(result={"public"}) Collection<Modifier> getModifiers1() { return thisClassDecl.getModifiers(); } // Check that static nested class has "static" modifier, even though // the VM doesn't set that bit. @Test(result={"private", "static", "strictfp"}) Collection<Modifier> getModifiers2() { return nested.getModifiers(); } @Test(result="ClassDecl.java") String getPosition() { return thisClassDecl.getPosition().file().getName(); } @Test(result="ClassDecl") String getSimpleName1() { return thisClassDecl.getSimpleName(); } @Test(result="NestedClass") String getSimpleName2() { return nested.getSimpleName(); } // MemberDeclaration method @Test(result="null") TypeDeclaration getDeclaringType1() { return thisClassDecl.getDeclaringType(); } @Test(result="ClassDecl") TypeDeclaration getDeclaringType2() { return nested.getDeclaringType(); } // TypeDeclaration methods @Test(result={"nested", "object", "i"}) Collection<FieldDeclaration> getFields() { return thisClassDecl.getFields(); } @Test(result={}) Collection<TypeParameterDeclaration> getFormalTypeParameters1() { return thisClassDecl.getFormalTypeParameters(); } @Test(result="T") Collection<TypeParameterDeclaration> getFormalTypeParameters2() { return nested.getFormalTypeParameters(); } @Test(result="ClassDecl.NestedClass<T>") Collection<TypeDeclaration> getNestedTypes() { return thisClassDecl.getNestedTypes(); } @Test(result="") PackageDeclaration getPackage1() { return thisClassDecl.getPackage(); } @Test(result="java.lang") PackageDeclaration getPackage2() { return object.getPackage(); } @Test(result="ClassDecl") String getQualifiedName1() { return thisClassDecl.getQualifiedName(); } @Test(result="ClassDecl.NestedClass") String getQualifiedName2() { return nested.getQualifiedName(); } @Test(result="java.lang.Object") String getQualifiedName3() { return object.getQualifiedName(); } @Test(result="java.io.Serializable") Collection<InterfaceType> getSuperinterfaces() { return nested.getSuperinterfaces(); } // ClassDeclaration methods @Test(result={"ClassDecl()", "ClassDecl(int)"}) Collection<ConstructorDeclaration> getConstructors1() { return thisClassDecl.getConstructors(); } // Check for default constructor. // 4997614: visitConstructionDeclaration reports info when there is no ctor @Test(result={"NestedClass()"}) Collection<ConstructorDeclaration> getConstructors2() { return nested.getConstructors(); } @Test(result={"m1()", "m2()", "m2(int)"}) Collection<MethodDeclaration> getMethods() { return nested.getMethods(); } @Test(result={"Tester"}) ClassType getSuperclass() { return thisClassDecl.getSuperclass(); } @Test(result={"null"}) ClassType objectHasNoSuperclass() { return object.getSuperclass(); } } // Annotations used for testing. @interface AT1 { } @interface AT2 { }
6,571
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnoTypeElemDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/AnnoTypeElemDecl.java
/* * Copyright (c) 2004, 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 4853450 4993299 5010385 5014539 * @summary AnnotationTypeElementDeclaration tests * @library ../../lib * @compile -source 1.5 AnnoTypeElemDecl.java * @run main/othervm AnnoTypeElemDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class AnnoTypeElemDecl extends Tester { public static void main(String[] args) { (new AnnoTypeElemDecl()).run(); } // Some annotation type elements to use. private AnnotationTypeElementDeclaration elem1 = null; // s() private AnnotationTypeElementDeclaration elem2 = null; // i() private AnnotationTypeElementDeclaration elem3 = null; // b() protected void init() { for (TypeDeclaration at : thisClassDecl.getNestedTypes()) { for (MethodDeclaration meth : at.getMethods()) { AnnotationTypeElementDeclaration elem = (AnnotationTypeElementDeclaration) meth; if (elem.getSimpleName().equals("s")) { elem1 = elem; // s() } else if (elem.getSimpleName().equals("i")) { elem2 = elem; // i() } else { elem3 = elem; // b() } } } } // Declaration methods @Test(result="anno type element") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); elem1.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitExecutableDeclaration(ExecutableDeclaration e) { res.add("executable"); } public void visitMethodDeclaration(MethodDeclaration m) { res.add("method"); } public void visitAnnotationTypeElementDeclaration( AnnotationTypeElementDeclaration a) { res.add("anno type element"); } }); return res; } @Test(result={"@AnnoTypeElemDecl.AT2"}) Collection<AnnotationMirror> getAnnotationMirrors() { return elem1.getAnnotationMirrors(); } @Test(result=" Sed Quis custodiet ipsos custodes?\n") String getDocComment() { return elem1.getDocComment(); } @Test(result={"public", "abstract"}) Collection<Modifier> getModifiers() { return elem1.getModifiers(); } @Test(result="AnnoTypeElemDecl.java") String getPosition() { return elem1.getPosition().file().getName(); } @Test(result="s") String getSimpleName() { return elem1.getSimpleName(); } // MemberDeclaration method @Test(result="AnnoTypeElemDecl.AT1") TypeDeclaration getDeclaringType() { return elem1.getDeclaringType(); } // ExecutableDeclaration methods @Test(result={}) Collection<TypeParameterDeclaration> getFormalTypeParameters() { return elem1.getFormalTypeParameters(); } @Test(result={}) Collection<ParameterDeclaration> getParameters() { return elem1.getParameters(); } @Test(result={}) Collection<ReferenceType> getThrownTypes() { return elem1.getThrownTypes(); } @Test(result="false") Boolean isVarArgs() { return elem1.isVarArgs(); } // AnnotationTypeElementDeclaration method @Test(result="\"default\"") AnnotationValue getDefaultValue1() { return elem1.getDefaultValue(); } @Test(result="null") AnnotationValue getDefaultValue2() { return elem2.getDefaultValue(); } // 5010385: getValue() returns null for boolean type elements @Test(result="false") Boolean getDefaultValue3() { return (Boolean) elem3.getDefaultValue().getValue(); } // toString @Test(result="s()") String toStringTest() { return elem1.toString(); } // Declarations used by tests. @interface AT1 { /** * Sed Quis custodiet ipsos custodes? */ @AT2 String s() default "default"; int i(); boolean b() default false; } @interface AT2 { } }
5,394
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ParameterDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/ParameterDecl.java
/* * Copyright (c) 2004, 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 4853450 5031171 * @summary ParameterDeclaration tests * @library ../../lib * @run main/othervm ParameterDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class ParameterDecl extends Tester { public static void main(String[] args) { (new ParameterDecl()).run(); } // Declarations used by tests @interface AT1 { } @interface AT2 { boolean value(); } private void m1(@AT1 @AT2(true) final int p1) { } private void m2(int p1) { } private ParameterDeclaration p1 = null; // a parameter protected void init() { p1 = getMethod("m1").getParameters().iterator().next(); } // Declaration methods @Test(result="param") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); p1.accept(new SimpleDeclarationVisitor() { public void visitFieldDeclaration(FieldDeclaration f) { res.add("field"); } public void visitParameterDeclaration(ParameterDeclaration p) { res.add("param"); } }); return res; } @Test(result={"@ParameterDecl.AT1", "@ParameterDecl.AT2(true)"}) Collection<AnnotationMirror> getAnnotationMirrors() { return p1.getAnnotationMirrors(); } @Test(result={"final"}) Collection<Modifier> getModifiers() { return p1.getModifiers(); } @Test(result="ParameterDecl.java") String getPosition() { return p1.getPosition().file().getName(); } @Test(result="p1") String getSimpleName() { return p1.getSimpleName(); } // ParameterDeclaration methods @Test(result="int") TypeMirror getType() { return p1.getType(); } // toString, equals @Test(result="int p1") String toStringTest() { return p1.toString(); } @Test(result="true") boolean equalsTest1() { ParameterDeclaration p = getMethod("m1").getParameters().iterator().next(); return p1.equals(p); } // Not all p1's are equal. @Test(result="false") boolean equalsTest2() { ParameterDeclaration p2 = getMethod("m2").getParameters().iterator().next(); return p1.equals(p2); } }
3,463
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnoVal.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/AnnoVal.java
/* * Copyright (c) 2004, 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 4853450 5014539 5034991 * @summary Tests AnnotationValue methods. * @library ../../lib * @compile -source 1.5 AnnoVal.java * @run main/othervm AnnoVal */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; public class AnnoVal extends Tester { public static void main(String[] args) { (new AnnoVal()).run(); } @Test(result={ "i Integer 2", "l Long 4294967296", "d Double 3.14", "b Boolean true", "c Character @", "s String sigh", // The following results reflect some implementation details. "k ClassTypeImpl java.lang.Boolean", "kb PrimitiveTypeImpl boolean", "ka ArrayTypeImpl java.lang.Boolean[]", "kab ArrayTypeImpl int[][]", "w ClassTypeImpl java.lang.Long", "e EnumConstantDeclarationImpl TYPE", "sa ArrayList [\"up\", \"down\"]", "a AnnotationMirrorImpl @AT1"}) @AT2(i = 1 + 1, l = 1024 * 1024 * 1024 * 4L, d = 3.14, b = true, c = '@', s = "sigh", k = Boolean.class, kb = boolean.class, ka = Boolean[].class, // bugid 5020899 kab = int[][].class, // " w = Long.class, e = java.lang.annotation.ElementType.TYPE, sa = {"up", "down"}, a = @AT1) Collection<String> getValue() { Collection<String> res = new ArrayList<String>(); AnnotationMirror anno = getAnno("getValue", "AT2"); for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> e : anno.getElementValues().entrySet()) { Object val = e.getValue().getValue(); res.add(String.format("%s %s %s", e.getKey().getSimpleName(), simpleClassName(val), val)); } return res; } @Test(result={ "int i 2", "long l 4294967296L", "double d 3.14", "boolean b true", "char c '@'", "java.lang.String s \"sigh\"", "java.lang.Class k java.lang.Boolean.class", "java.lang.Class kb boolean.class", "java.lang.Class ka java.lang.Boolean[].class", "java.lang.Class kab int[][].class", "java.lang.Class<? extends java.lang.Number> w java.lang.Long.class", "java.lang.annotation.ElementType e java.lang.annotation.ElementType.TYPE", "java.lang.String[] sa {\"up\", \"down\"}", "AT1 a @AT1"}) Collection<String> toStringTests() { Collection<String> res = new ArrayList<String>(); AnnotationMirror anno = getAnno("getValue", "AT2"); for (Map.Entry<AnnotationTypeElementDeclaration,AnnotationValue> e : anno.getElementValues().entrySet()) { res.add(String.format("%s %s %s", e.getKey().getReturnType(), e.getKey().getSimpleName(), e.getValue().toString())); } return res; } @Test(result={ "byte b 0x0b", "float f 3.0f", "double nan 0.0/0.0", "double hi 1.0/0.0", "float lo -1.0f/0.0f", "char newline '\\n'", "char ff '\\u00ff'", "java.lang.String s \"\\\"high\\tlow\\\"\"", "java.lang.String smiley \"\\u263a\""}) @AT3(b = 11, f = 3, nan = 0.0/0.0, hi = 1.0/0.0, lo = -1.0f/0.0f, newline = '\n', ff = '\u00FF', s = "\"high\tlow\"", smiley = "\u263A") Collection<String> toStringFancy() { Collection<String> res = new ArrayList<String>(); AnnotationMirror anno = getAnno("toStringFancy", "AT3"); for (Map.Entry<AnnotationTypeElementDeclaration,AnnotationValue> e : anno.getElementValues().entrySet()) { res.add(String.format("%s %s %s", e.getKey().getReturnType(), e.getKey().getSimpleName(), e.getValue().toString())); } return res; } /** * Returns the simple name of an object's class. */ private String simpleClassName(Object o) { return (o == null) ? "null" : o.getClass().getName().replaceFirst(".*\\.", ""); } } /* * Annotations used for testing. */ @interface AT1 { String value() default ""; } @interface AT2 { int i(); long l(); double d(); boolean b(); char c(); String s(); Class k(); Class kb(); Class ka(); Class kab(); Class<? extends Number> w(); java.lang.annotation.ElementType e(); String[] sa(); AT1 a(); } @interface AT3 { byte b(); float f(); double nan(); double hi(); float lo(); char newline(); char ff(); String s(); String smiley(); }
6,091
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnoMirror.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/AnnoMirror.java
/* * Copyright (c) 2004, 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 4853450 5014539 * @summary Tests AnnotationMirror and AnnotationValue methods. * @library ../../lib * @compile -source 1.5 AnnoMirror.java * @run main/othervm AnnoMirror */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; public class AnnoMirror extends Tester { public static void main(String[] args) { (new AnnoMirror()).run(); } @Test(result={"AT1"}) @AT1 AnnotationType getAnnotationType() { AnnotationMirror anno = getAnno("getAnnotationType", "AT1"); return anno.getAnnotationType(); } @Test(result={}) @AT1 Set getElementValuesNone() { AnnotationMirror anno = getAnno("getElementValuesNone", "AT1"); return anno.getElementValues().entrySet(); } // The seemingly out-of-place parens in the following "result" // entry are needed due to the shortcut of having the test return // the entry set directly. @Test(result={"i()=2", "b()=true", "k()=java.lang.Boolean.class", "a()=@AT1"}) @AT2(i = 1+1, b = true, k = Boolean.class, a = @AT1) Set getElementValues() { AnnotationMirror anno = getAnno("getElementValues", "AT2"); return anno.getElementValues().entrySet(); } @Test(result={"@AT1(\"zax\")", "@AT2(i=2, b=true, k=java.lang.Boolean.class, a=@AT1)", "@AT3(arr={1})", "@AT4({2, 3, 4})"}) Collection<AnnotationMirror> toStringTests() { for (MethodDeclaration m : thisClassDecl.getMethods()) { if (m.getSimpleName().equals("toStringTestsHelper")) { return m.getAnnotationMirrors(); } } throw new AssertionError(); } @AT1("zax") @AT2(i = 1+1, b = true, k = Boolean.class, a = @AT1) @AT3(arr={1}) @AT4({2,3,4}) private void toStringTestsHelper() { } } /* * Annotations used for testing. */ @interface AT1 { String value() default ""; } @interface AT2 { int i(); boolean b(); Class k(); AT1 a(); } @interface AT3 { int[] arr(); } @interface AT4 { int[] value(); }
3,321
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
GetAnno.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/GetAnno.java
/* * Copyright (c) 2004, 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 4989091 5050782 5051962 * @summary Tests Declaration.getAnnotation method * @library ../../lib * @compile -source 1.5 GetAnno.java * @run main/othervm GetAnno */ import java.lang.annotation.*; import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import static java.lang.annotation.RetentionPolicy.*; public class GetAnno extends Tester { public static void main(String[] args) { (new GetAnno()).run(); } // Annotations used by tests @Retention(RUNTIME) @interface AT1 { long l(); String s(); RetentionPolicy e(); String[] sa(); AT2 a(); } @Inherited @interface AT2 { } @interface AT3 { Class value() default String.class; } // Array-valued elements of various kinds. @interface AT4 { boolean[] bs(); long[] ls(); String[] ss(); RetentionPolicy[] es(); AT2[] as(); } @Test(result="@GetAnno$AT1(l=7, s=sigh, e=CLASS, sa=[in, out], " + "a=@GetAnno$AT2())") @AT1(l=7, s="sigh", e=CLASS, sa={"in", "out"}, a=@AT2) public Annotation getAnnotation() { MethodDeclaration m = getMethod("getAnnotation"); AT1 a = m.getAnnotation(AT1.class); if (a.l() != 7 || !a.s().equals("sigh") || a.e() != CLASS) throw new AssertionError(); return a; } @Test(result="null") public Annotation getAnnotationNotThere() { return thisClassDecl.getAnnotation(Deprecated.class); } @Test(result="@GetAnno$AT4(bs=[true, false], " + "ls=[9, 8], " + "ss=[black, white], " + "es=[CLASS, SOURCE], " + "as=[@GetAnno$AT2(), @GetAnno$AT2()])") @AT4(bs={true, false}, ls={9, 8}, ss={"black", "white"}, es={CLASS, SOURCE}, as={@AT2, @AT2}) public AT4 getAnnotationArrayValues() { MethodDeclaration m = getMethod("getAnnotationArrayValues"); return m.getAnnotation(AT4.class); } @Test(result="@GetAnno$AT3(value=java.lang.String)") @AT3(String.class) public AT3 getAnnotationWithClass1() { MethodDeclaration m = getMethod("getAnnotationWithClass1"); return m.getAnnotation(AT3.class); } @Test(result="java.lang.String") public TypeMirror getAnnotationWithClass2() { AT3 a = getAnnotationWithClass1(); try { Class c = a.value(); throw new AssertionError(); } catch (MirroredTypeException e) { return e.getTypeMirror(); } } @Test(result="boolean") @AT3(boolean.class) public TypeMirror getAnnotationWithPrim() { MethodDeclaration m = getMethod("getAnnotationWithPrim"); AT3 a = m.getAnnotation(AT3.class); try { Class c = a.value(); throw new AssertionError(); } catch (MirroredTypeException e) { return e.getTypeMirror(); } } // 5050782 @Test(result="null") public AT2 getInheritedAnnotation() { return thisClassDecl.getAnnotation(AT2.class); } /** * Verify that an annotation created by Declaration.getAnnotation() * has the same hash code as a like annotation created by core * reflection. */ @Test(result="true") @AT1(l=7, s="sigh", e=CLASS, sa={"in", "out"}, a=@AT2) public boolean getAnnotationHashCode() { MethodDeclaration m1 = getMethod("getAnnotationHashCode"); AT1 a1 = m1.getAnnotation(AT1.class); java.lang.reflect.Method m2 = null; try { m2 = this.getClass().getMethod("getAnnotationHashCode"); } catch (NoSuchMethodException e) { assert false; } AT1 a2 = m2.getAnnotation(AT1.class); return a1.hashCode() == a2.hashCode(); } }
5,044
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstExpr.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/ConstExpr.java
/* * Copyright (c) 2004, 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 5027675 5048535 * @summary Tests FieldDeclaration.getConstantExpression method * @library ../../lib * @compile -source 1.5 ConstExpr.java * @run main/othervm ConstExpr */ import java.math.RoundingMode; import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import static java.math.RoundingMode.UP; import static com.sun.mirror.util.DeclarationVisitors.*; public class ConstExpr extends Tester { public static void main(String[] args) { (new ConstExpr()).run(); } // Declarations used by tests public static final byte B = (byte) 0xBE; public static final short S = (short) 32767; public static final int I = -4; public static final long l = 4294967296L; public static final float f = 3.5f; public static final double PI = Math.PI; public static final char C = 'C'; public static final String STR = "cheese"; public static final char SMILEY = '\u263A'; public static final String TWOLINES = "ab\ncd"; public static final double D1 = Double.POSITIVE_INFINITY; public static final double D2 = Double.NEGATIVE_INFINITY; public static final double D3 = Double.NaN; public static final float F1 = Float.POSITIVE_INFINITY; public static final float F2 = Float.NEGATIVE_INFINITY; public static final float F3 = Float.NaN; public static final String NOSTR = null; // not a compile-time constant public static final RoundingMode R = UP; // not a compile-time constant @Test(result={ "0xbe", "32767", "-4", "4294967296L", "3.5f", "3.141592653589793", "'C'", "\"cheese\"", "'\\u263a'", "\"ab\\ncd\"", "1.0/0.0", "-1.0/0.0", "0.0/0.0", "1.0f/0.0f", "-1.0f/0.0f", "0.0f/0.0f", "null", "null" }, ordered=true) Collection<String> getConstantExpression() { final Collection<String> res = new ArrayList<String>(); thisClassDecl.accept( DeclarationVisitors.getSourceOrderDeclarationScanner( NO_OP, new SimpleDeclarationVisitor() { public void visitFieldDeclaration(FieldDeclaration f) { res.add(f.getConstantExpression()); } })); return res; } }
3,626
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstructorDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/ConstructorDecl.java
/* * Copyright (c) 2004, 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 4853450 4993299 * @summary ConstructorDeclaration tests * @library ../../lib * @compile -source 1.5 ConstructorDecl.java * @run main/othervm ConstructorDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class ConstructorDecl extends Tester { /** * Sed Quis custodiet ipsos custodes? */ @AT1 public ConstructorDecl() { } public static void main(String[] args) { (new ConstructorDecl()).run(); } private ConstructorDeclaration ctor = null; // a constructor private ConstructorDeclaration ctorDef = null; // a default c'tor private ConstructorDeclaration ctorInner = null; // an inner class c'tor protected void init() { ctor = getAConstructor(thisClassDecl); ctorDef = getAConstructor((ClassDeclaration) env.getTypeDeclaration("C1")); ctorInner = getAConstructor((ClassDeclaration) env.getTypeDeclaration("C1.C2")); } // Return a constructor of a class. private ConstructorDeclaration getAConstructor(ClassDeclaration c) { return c.getConstructors().iterator().next(); } // Declaration methods @Test(result="constructor") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); ctor.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitExecutableDeclaration(ExecutableDeclaration e) { res.add("executable"); } public void visitConstructorDeclaration(ConstructorDeclaration c) { res.add("constructor"); } }); return res; } @Test(result={"@AT1"}) Collection<AnnotationMirror> getAnnotationMirrors() { return ctor.getAnnotationMirrors(); } @Test(result=" Sed Quis custodiet ipsos custodes?\n") String getDocComment() { return ctor.getDocComment(); } @Test(result={"public"}) Collection<Modifier> getModifiers() { return ctor.getModifiers(); } @Test(result="ConstructorDecl.java") String getPosition() { return ctor.getPosition().file().getName(); } @Test(result="ConstructorDecl.java") String getPositionDefault() { return ctorDef.getPosition().file().getName(); } @Test(result="ConstructorDecl") String getSimpleName() { return ctor.getSimpleName(); } @Test(result="C2") String getSimpleNameInner() { return ctorInner.getSimpleName(); } // MemberDeclaration method @Test(result="ConstructorDecl") TypeDeclaration getDeclaringType() { return ctor.getDeclaringType(); } // ExecutableDeclaration methods @Test(result={}) Collection<TypeParameterDeclaration> getFormalTypeParameters1() { return ctor.getFormalTypeParameters(); } @Test(result={"N extends java.lang.Number"}) Collection<TypeParameterDeclaration> getFormalTypeParameters2() { return ctorInner.getFormalTypeParameters(); } @Test(result={}) Collection<ParameterDeclaration> getParameters1() { return ctor.getParameters(); } // 4993299: verify synthetic parameters to inner class constructors // aren't visible @Test(result={"N n1", "N n2", "java.lang.String[] ss"}, ordered=true) Collection<ParameterDeclaration> getParameters2() { return ctorInner.getParameters(); } @Test(result={"java.lang.Throwable"}) Collection<ReferenceType> getThrownTypes() { return ctorInner.getThrownTypes(); } @Test(result="false") Boolean isVarArgs1() { return ctor.isVarArgs(); } @Test(result="true") Boolean isVarArgs2() { return ctorInner.isVarArgs(); } // toString @Test(result="<N extends java.lang.Number> C2(N, N, String...)") @Ignore("This is what it would be nice to see.") String toStringTest() { return ctorInner.toString(); } } // Classes and interfaces used for testing. class C1 { class C2 { <N extends Number> C2(N n1, N n2, String... ss) throws Throwable { } } } @interface AT1 { }
5,491
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InterfaceDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/InterfaceDecl.java
/* * Copyright (c) 2004, 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 4853450 4993303 5004618 5010746 * @summary InterfaceDeclaration tests * @library ../../lib * @compile -source 1.5 InterfaceDecl.java * @run main/othervm InterfaceDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; /** * Sed Quis custodiet ipsos custodes? */ @AT1 @AT2 public class InterfaceDecl extends Tester { public static void main(String[] args) { (new InterfaceDecl()).run(); } private InterfaceDeclaration iDecl = null; // an interface private InterfaceDeclaration nested = null; // a nested interface protected void init() { iDecl = (InterfaceDeclaration) env.getTypeDeclaration("I"); nested = (InterfaceDeclaration) iDecl.getNestedTypes().iterator().next(); } // Declaration methods @Test(result="interface") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); iDecl.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitClassDeclaration(ClassDeclaration c) { res.add("class"); } public void visitInterfaceDeclaration(InterfaceDeclaration e) { res.add("interface"); } public void visitAnnotationTypeDeclaration( AnnotationTypeDeclaration e) { res.add("annotation type"); } }); return res; } @Test(result="true") boolean equals1() { return iDecl.equals(iDecl); } @Test(result="false") boolean equals2() { return iDecl.equals(nested); } @Test(result="true") boolean equals3() { return iDecl.equals(env.getTypeDeclaration("I")); } @Test(result={"@AT1", "@AT2"}) Collection<AnnotationMirror> getAnnotationMirrors() { return iDecl.getAnnotationMirrors(); } @Test(result=" Sed Quis custodiet ipsos custodes?\n") String getDocComment() { return iDecl.getDocComment(); } // Check that interface has "abstract" modifier, even though it's implict // in the source code. @Test(result={"abstract"}) Collection<Modifier> getModifiers1() { return iDecl.getModifiers(); } // Check that nested interface has "static" modifier, even though // it's implicit in the source code and the VM doesn't set that bit. @Test(result={"public", "abstract", "static"}) Collection<Modifier> getModifiers2() { return nested.getModifiers(); } @Test(result="InterfaceDecl.java") String getPosition() { return iDecl.getPosition().file().getName(); } @Test(result="I") String getSimpleName1() { return iDecl.getSimpleName(); } @Test(result="Nested") String getSimpleName2() { return nested.getSimpleName(); } // MemberDeclaration method @Test(result="null") TypeDeclaration getDeclaringType1() { return iDecl.getDeclaringType(); } @Test(result="I<T extends java.lang.Number>") TypeDeclaration getDeclaringType2() { return nested.getDeclaringType(); } // TypeDeclaration methods @Test(result={"i"}) Collection<FieldDeclaration> getFields() { return iDecl.getFields(); } @Test(result={"T extends java.lang.Number"}) Collection<TypeParameterDeclaration> getFormalTypeParameters1() { return iDecl.getFormalTypeParameters(); } @Test(result={}) Collection<TypeParameterDeclaration> getFormalTypeParameters2() { return nested.getFormalTypeParameters(); } // 4993303: verify policy on Object methods being visible @Test(result={"m()", "toString()"}) Collection<? extends MethodDeclaration> getMethods() { return nested.getMethods(); } @Test(result="I.Nested") Collection<TypeDeclaration> getNestedTypes() { return iDecl.getNestedTypes(); } @Test(result="") PackageDeclaration getPackage1() { return iDecl.getPackage(); } @Test(result="java.util") PackageDeclaration getPackage2() { InterfaceDeclaration set = (InterfaceDeclaration) env.getTypeDeclaration("java.util.Set"); return set.getPackage(); } @Test(result="I") String getQualifiedName1() { return iDecl.getQualifiedName(); } @Test(result="I.Nested") String getQualifiedName2() { return nested.getQualifiedName(); } @Test(result="java.util.Set") String getQualifiedName3() { InterfaceDeclaration set = (InterfaceDeclaration) env.getTypeDeclaration("java.util.Set"); return set.getQualifiedName(); } @Test(result="java.lang.Runnable") Collection<InterfaceType> getSuperinterfaces() { return iDecl.getSuperinterfaces(); } } // Interfaces used for testing. /** * Sed Quis custodiet ipsos custodes? */ @AT1 @AT2 interface I<T extends Number> extends Runnable { int i = 6; void m1(); void m2(); void m2(int j); interface Nested { void m(); String toString(); } } @interface AT1 { } @interface AT2 { }
6,427
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/EnumDecl.java
/* * Copyright (c) 2004, 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 4853450 4989987 5010050 * @summary EnumDeclaration tests * @library ../../lib * @compile -source 1.5 EnumDecl.java * @run main/othervm EnumDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class EnumDecl extends Tester { public static void main(String[] args) { (new EnumDecl()).run(); } private EnumDeclaration eDecl; protected void init() { eDecl = (EnumDeclaration) env.getTypeDeclaration("E"); } // Declaration methods @Test(result="enum") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); eDecl.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitClassDeclaration(ClassDeclaration c) { res.add("class"); } public void visitEnumDeclaration(EnumDeclaration e) { res.add("enum"); } }); return res; } // ClassDeclaration methods // 4989987: Verify synthetic enum constructor parameters are not visible @Test(result={"E(java.lang.String)"}) Collection<ConstructorDeclaration> getConstructors() { return eDecl.getConstructors(); } // 4989987: Verify synthetic enum constructor parameters are not visible @Test(result={"java.lang.String color"}) Collection<ParameterDeclaration> getConstructorParams() { return eDecl.getConstructors().iterator().next().getParameters(); } @Test(result={"values()", "valueOf(java.lang.String)"}) Collection<MethodDeclaration> getMethods() { return eDecl.getMethods(); } // 5010050: Cannot find parameter names for valueOf(String name) method... @Test(result={"java.lang.String name"}) Collection<ParameterDeclaration> getMethodParams() { for (MethodDeclaration m : eDecl.getMethods()) { if (m.getSimpleName().equals("valueOf")) { return m.getParameters(); } } throw new AssertionError(); } // EnumDeclaration methods @Test(result={"stop", "slow", "go"}) Collection<EnumConstantDeclaration> getEnumConstants() { return eDecl.getEnumConstants(); } } // An enum to use for testing. enum E { stop("red"), slow("amber"), go("green"); private String color; E(String color) { this.color = color; } }
3,640
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FieldDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/FieldDecl.java
/* * Copyright (c) 2004, 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 4853450 5008309 * @summary FieldDeclaration tests * @library ../../lib * @compile -source 1.5 FieldDecl.java * @run main/othervm FieldDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class FieldDecl extends Tester { public static void main(String[] args) { (new FieldDecl()).run(); } private FieldDeclaration f1 = null; // a field private FieldDeclaration f2 = null; // a static field private FieldDeclaration f3 = null; // a constant field protected void init() { f1 = getField("aField"); f2 = getField("aStaticField"); f3 = getField("aConstantField"); } // Declaration methods @Test(result="field") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); f1.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitFieldDeclaration(FieldDeclaration f) { res.add("field"); } public void visitEnumConstantDeclaration( EnumConstantDeclaration e) { res.add("enum const"); } }); return res; } @Test(result={"@FieldDecl.AT1"}) Collection<AnnotationMirror> getAnnotationMirrors() { return f1.getAnnotationMirrors(); } @Test(result=" Sed Quis custodiet ipsos custodes?\n") String getDocComment() { return f1.getDocComment(); } @Test(result={"public"}) Collection<Modifier> getModifiers() { return f1.getModifiers(); } @Test(result="FieldDecl.java") String getPosition() { return f1.getPosition().file().getName(); } @Test(result="aField") String getSimpleName() { return f1.getSimpleName(); } // MemberDeclaration method @Test(result="FieldDecl") TypeDeclaration getDeclaringType() { return f1.getDeclaringType(); } // FieldDeclaration methods @Test(result="java.util.List<java.lang.String>") TypeMirror getType1() { return f1.getType(); } @Test(result="int") TypeMirror getType2() { return f2.getType(); } @Test(result="null") Object getConstantValue1() { return f1.getConstantValue(); } // 5008309: FieldDeclaration.getConstantValue() doesn't return anything @Test(result="true") Object getConstantValue2() { return f3.getConstantValue(); } // toString @Test(result="aField") String toStringTest() { return f1.toString(); } // Declarations used by tests. /** * Sed Quis custodiet ipsos custodes? */ @AT1 public List<String> aField = new ArrayList<String>(); static int aStaticField; public static final boolean aConstantField = true; @interface AT1 { } }
4,135
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnoTypeDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/AnnoTypeDecl.java
/* * Copyright (c) 2004, 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 4853450 5014539 * @summary AnnotationTypeDeclaration tests * @library ../../lib * @compile -source 1.5 AnnoTypeDecl.java * @run main/othervm AnnoTypeDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class AnnoTypeDecl extends Tester { public static void main(String[] args) { (new AnnoTypeDecl()).run(); } private AnnotationTypeDeclaration at; protected void init() { at = (AnnotationTypeDeclaration) env.getTypeDeclaration("AT"); } // Declaration methods @Test(result="annotation type") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); at.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitClassDeclaration(ClassDeclaration c) { res.add("class"); } public void visitInterfaceDeclaration(InterfaceDeclaration i) { res.add("interface"); } public void visitAnnotationTypeDeclaration( AnnotationTypeDeclaration a) { res.add("annotation type"); } }); return res; } // AnnotationTypeDeclaration methods @Test(result={"s()"}) Collection<AnnotationTypeElementDeclaration> getMethods() { return at.getMethods(); } } // An annotation type to use for testing. @interface AT { String s(); }
2,700
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MethodDecl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/MethodDecl.java
/* * Copyright (c) 2004, 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 4853450 5010746 * @summary MethodDeclaration tests * @library ../../lib * @compile -source 1.5 MethodDecl.java * @run main/othervm MethodDecl */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class MethodDecl extends Tester { public static void main(String[] args) { (new MethodDecl()).run(); } private MethodDeclaration meth1 = null; // a method private MethodDeclaration meth2 = null; // another method protected void init() { meth1 = getMethod("m1"); meth2 = getMethod("m2"); } // Declaration methods @Test(result="method") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); meth1.accept(new SimpleDeclarationVisitor() { public void visitTypeDeclaration(TypeDeclaration t) { res.add("type"); } public void visitExecutableDeclaration(ExecutableDeclaration e) { res.add("executable"); } public void visitMethodDeclaration(MethodDeclaration m) { res.add("method"); } public void visitAnnotationTypeElementDeclaration( AnnotationTypeElementDeclaration a) { res.add("anno type element"); } }); return res; } @Test(result={"@AT1"}) Collection<AnnotationMirror> getAnnotationMirrors() { return meth1.getAnnotationMirrors(); } @Test(result=" Sed Quis custodiet ipsos custodes?\n") String getDocComment() { return meth1.getDocComment(); } @Test(result={"private", "static", "strictfp"}) Collection<Modifier> getModifiers() { return meth1.getModifiers(); } // Interface methods are implicitly public and abstract. @Test(result={"public", "abstract"}) Collection<Modifier> getModifiersInterface() { for (TypeDeclaration t : thisClassDecl.getNestedTypes()) { for (MethodDeclaration m : t.getMethods()) { return m.getModifiers(); } } throw new AssertionError(); } @Test(result="MethodDecl.java") String getPosition() { return meth1.getPosition().file().getName(); } @Test(result="m2") String getSimpleName() { return meth2.getSimpleName(); } // MemberDeclaration method @Test(result="MethodDecl") TypeDeclaration getDeclaringType() { return meth1.getDeclaringType(); } // ExecutableDeclaration methods @Test(result={}) Collection<TypeParameterDeclaration> getFormalTypeParameters1() { return meth1.getFormalTypeParameters(); } @Test(result={"T", "N extends java.lang.Number"}, ordered=true) Collection<TypeParameterDeclaration> getFormalTypeParameters2() { return meth2.getFormalTypeParameters(); } @Test(result={}) Collection<ParameterDeclaration> getParameters1() { return meth1.getParameters(); } @Test(result={"N n", "java.lang.String[] ss"}, ordered=true) Collection<ParameterDeclaration> getParameters2() { return meth2.getParameters(); } @Test(result="true") boolean parameterEquals1() { ParameterDeclaration p1 = getMethod("m3").getParameters().iterator().next(); ParameterDeclaration p2 = getMethod("m3").getParameters().iterator().next(); return p1.equals(p2); } @Test(result="false") boolean parameterEquals2() { ParameterDeclaration p1 = getMethod("m3").getParameters().iterator().next(); ParameterDeclaration p2 = getMethod("m4").getParameters().iterator().next(); return p1.equals(p2); } @Test(result="true") boolean parameterHashCode() { ParameterDeclaration p1 = getMethod("m3").getParameters().iterator().next(); ParameterDeclaration p2 = getMethod("m3").getParameters().iterator().next(); return p1.hashCode() == p2.hashCode(); } @Test(result={"java.lang.Throwable"}) Collection<ReferenceType> getThrownTypes() { return meth2.getThrownTypes(); } @Test(result="false") Boolean isVarArgs1() { return meth1.isVarArgs(); } @Test(result="true") Boolean isVarArgs2() { return meth2.isVarArgs(); } // MethodDeclaration methods @Test(result="void") TypeMirror getReturnType1() { return meth1.getReturnType(); } @Test(result="N") TypeMirror getReturnType2() { return meth2.getReturnType(); } // toString @Test(result="<T, N extends java.lang.Number> m2(N, java.lang.String...)") @Ignore("This is what it would be nice to see.") String toStringTest() { return meth2.toString(); } // Declarations used by tests. /** * Sed Quis custodiet ipsos custodes? */ @AT1 private static strictfp void m1() { } private <T, N extends Number> N m2(N n, String... ss) throws Throwable { return null; } private void m3(String s) { } private void m4(String s) { } // A nested interface interface I { void m(); } } // Annotation type used by tests. @interface AT1 { }
6,515
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
package-info.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/pkg1/package-info.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Herein lieth the package comment. * A doc comment it be, and wonderous to behold. */ @AnAnnoType package pkg1;
1,179
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnAnnoType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/pkg1/AnAnnoType.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package pkg1; public @interface AnAnnoType { }
1,108
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnInterface.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/pkg1/AnInterface.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package pkg1; public interface AnInterface { }
1,108
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AClass.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/pkg1/AClass.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package pkg1; public class AClass { }
1,098
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnEnum.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/pkg1/AnEnum.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package pkg1; enum AnEnum { }
1,090
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnInterface.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/declaration/pkg1/pkg2/AnInterface.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package pkg1.pkg2; public interface AnInterface { }
1,111
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ArrayTyp.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/ArrayTyp.java
/* * Copyright (c) 2004, 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 4853450 5009357 * @summary ArrayType tests * @library ../../lib * @compile -source 1.5 ArrayTyp.java * @run main/othervm ArrayTyp */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class ArrayTyp extends Tester { public static void main(String[] args) { (new ArrayTyp()).run(); } // Declaration used by tests private boolean[] bs; private String[][] bss; private ArrayType arr; // an array type private ArrayType arrarr; // a multi-dimensional array type protected void init() { arr = (ArrayType) getField("bs").getType(); arrarr = (ArrayType) getField("bss").getType(); } // TypeMirror methods @Test(result="array") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); arr.accept(new SimpleTypeVisitor() { public void visitTypeMirror(TypeMirror t) { res.add("type"); } public void visitArrayType(ArrayType t) { res.add("array"); } public void visitReferenceType(ReferenceType t) { res.add("ref type"); } }); return res; } @Test(result="boolean[]") String toStringTest() { return arr.toString(); } @Test(result="java.lang.String[][]") String toStringTestMulti() { return arrarr.toString(); } // ArrayType method @Test(result="boolean") TypeMirror getComponentType() { return (PrimitiveType) arr.getComponentType(); } @Test(result="java.lang.String[]") TypeMirror getComponentTypeMulti() { return (ArrayType) arrarr.getComponentType(); } }
2,888
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
WildcardTyp.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/WildcardTyp.java
/* * Copyright (c) 2004, 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 4853450 5009396 5010636 5031156 * @summary WildcardType tests * @library ../../lib * @compile -source 1.5 WildcardTyp.java * @run main/othervm WildcardTyp */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class WildcardTyp extends Tester { public static void main(String[] args) { (new WildcardTyp()).run(); } // Declarations to use for testing interface G<T> { } interface G1<N extends Number & Runnable> { } interface G2<T extends G2<T>> { } // Some wildcard types to test. private G<?> f0; // unbound private G<? extends Number> f1; // covariant private G<? super Number> f2; // contravariant private G<? extends Object> f3; // <sigh> private G1<?> f4; // "true" upper bound is an intersection type private G2<?> f5; // 'true" upper bound is a recursive F-bound and // not expressible private static final int NUMTYPES = 6; // Type mirrors corresponding to the wildcard types of the above fields private WildcardType[] t = new WildcardType[NUMTYPES]; protected void init() { for (int i = 0; i < t.length; i++) { DeclaredType type = (DeclaredType) getField("f"+i).getType(); t[i] = (WildcardType) type.getActualTypeArguments().iterator().next(); } } private WildcardType wildcardFor(String field) { DeclaredType d = (DeclaredType) getField(field).getType(); return (WildcardType) d.getActualTypeArguments().iterator().next(); } // TypeMirror methods @Test(result="wild thing") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); t[0].accept(new SimpleTypeVisitor() { public void visitTypeMirror(TypeMirror t) { res.add("type"); } public void visitReferenceType(ReferenceType t) { res.add("ref type"); } public void visitWildcardType(WildcardType t) { res.add("wild thing"); } }); return res; } @Test(result={ "?", "? extends java.lang.Number", "? super java.lang.Number", "? extends java.lang.Object", "?", "?" }, ordered=true) Collection<String> toStringTests() { Collection<String> res = new ArrayList<String>(); for (WildcardType w : t) { res.add(w.toString()); } return res; } // WildcardType methods @Test(result={ "null", "null", "java.lang.Number", "null", "null", "null" }, ordered=true) Collection<ReferenceType> getLowerBounds() { Collection<ReferenceType> res = new ArrayList<ReferenceType>(); for (WildcardType w : t) { Collection<ReferenceType> bounds = w.getLowerBounds(); int num = bounds.size(); if (num > 1) { throw new AssertionError("Bounds abound"); } res.add((num > 0) ? bounds.iterator().next() : null); } return res; } @Test(result={ "null", "java.lang.Number", "null", "java.lang.Object", "null", "null" }, ordered=true) Collection<ReferenceType> getUpperBounds() { Collection<ReferenceType> res = new ArrayList<ReferenceType>(); for (WildcardType w : t) { Collection<ReferenceType> bounds = w.getUpperBounds(); int num = bounds.size(); if (num > 1) { throw new AssertionError("Bounds abound"); } res.add((num > 0) ? bounds.iterator().next() : null); } return res; } }
5,163
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumTyp.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/EnumTyp.java
/* * Copyright (c) 2004, 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 4853450 * @summary EnumType tests * @library ../../lib * @compile -source 1.5 EnumTyp.java * @run main/othervm EnumTyp */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class EnumTyp extends Tester { public static void main(String[] args) { (new EnumTyp()).run(); } // Declarations used by tests enum Suit { CIVIL, CRIMINAL } private Suit s; private EnumType e; // an enum type protected void init() { e = (EnumType) getField("s").getType(); } // TypeMirror methods @Test(result="enum") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); e.accept(new SimpleTypeVisitor() { public void visitTypeMirror(TypeMirror t) { res.add("type"); } public void visitReferenceType(ReferenceType t) { res.add("ref type"); } public void visitClassType(ClassType t) { res.add("class"); } public void visitEnumType(EnumType t) { res.add("enum"); } public void visitInterfaceType(InterfaceType t) { res.add("interface"); } }); return res; } // EnumType method @Test(result="EnumTyp.Suit") EnumDeclaration getDeclaration() { return e.getDeclaration(); } }
2,599
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InterfaceTyp.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/InterfaceTyp.java
/* * Copyright (c) 2004, 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 4853450 5055963 * @summary InterfaceType tests * @library ../../lib * @run main/othervm InterfaceTyp */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class InterfaceTyp<T1,T2> extends Tester { public static void main(String[] args) { (new InterfaceTyp()).run(); } // Declarations used by tests interface I1<S> extends Set<String> { interface I2<R> { } } // Generate some interface types to test private I1<T1> f0; private I1<String> f1; private I1 f2; private I1.I2<String> f3; private I1.I2 f4; private I1<T1> f5; private I3<T1> f6; private static final int NUMTYPES = 7; // Type mirrors corresponding to the types of the above fields private InterfaceType[] t = new InterfaceType[NUMTYPES]; protected void init() { for (int i = 0; i < t.length; i++) { t[i] = (InterfaceType) getField("f"+i).getType(); } } // TypeMirror methods @Test(result="interface") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); t[0].accept(new SimpleTypeVisitor() { public void visitReferenceType(ReferenceType t) { res.add("ref type"); } public void visitClassType(ClassType t) { res.add("class"); } public void visitInterfaceType(InterfaceType t) { res.add("interface"); } }); return res; } @Test(result="true") boolean equals1() { return t[0].equals(t[0]); } @Test(result="false") boolean equals2() { return t[0].equals(t[1]); } // Raw type is not same as type instantiated with unbounded type var. @Test(result="false") boolean equals3() { return t[0].equals(t[2]); } // I1<T1> is same type as I1<T1> @Test(result="true") boolean equals4() { return t[0].equals(t[5]); } @Test(result={ "InterfaceTyp.I1<T1>", "InterfaceTyp.I1<java.lang.String>", "InterfaceTyp.I1", "InterfaceTyp.I1.I2<java.lang.String>", "InterfaceTyp.I1.I2", "InterfaceTyp.I1<T1>", "I3<T1>" }, ordered=true) Collection<String> toStringTests() { Collection<String> res = new ArrayList<String>(); for (InterfaceType i : t) { res.add(i.toString()); } return res; } // DeclaredType methods @Test(result={"T1"}) Collection<TypeMirror> getActualTypeArguments1() { return t[0].getActualTypeArguments(); } @Test(result={}) Collection<TypeMirror> getActualTypeArguments2() { return t[2].getActualTypeArguments(); } @Test(result={"java.lang.String"}) Collection<TypeMirror> getActualTypeArguments3() { return t[3].getActualTypeArguments(); } @Test(result="InterfaceTyp") DeclaredType getContainingType1() { return t[0].getContainingType(); } @Test(result="InterfaceTyp.I1") DeclaredType getContainingType2() { return t[3].getContainingType(); } @Test(result="null") DeclaredType getContainingTypeTopLevel() { return t[6].getContainingType(); } @Test(result={"java.util.Set<java.lang.String>"}) Collection<InterfaceType> getSuperinterfaces() { return t[0].getSuperinterfaces(); } // InterfaceType method @Test(result="InterfaceTyp.I1<S>") InterfaceDeclaration getDeclaration1() { return t[0].getDeclaration(); } @Test(result="InterfaceTyp.I1.I2<R>") InterfaceDeclaration getDeclaration2a() { return t[3].getDeclaration(); } @Test(result="InterfaceTyp.I1.I2<R>") InterfaceDeclaration getDeclaration2b() { return t[4].getDeclaration(); } @Test(result="true") boolean getDeclarationCaching() { return t[0].getDeclaration() == t[5].getDeclaration(); } } // A top-level interface used by tests. interface I3<T> { }
5,267
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnoTyp.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/AnnoTyp.java
/* * Copyright (c) 2004, 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 4853450 * @summary AnnotationType tests * @library ../../lib * @compile -source 1.5 AnnoTyp.java * @run main/othervm AnnoTyp */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class AnnoTyp extends Tester { public static void main(String[] args) { (new AnnoTyp()).run(); } // Declaration used by tests @interface AT { } private AnnotationType at; // an annotation type @AT protected void init() { at = getAnno("init", "AnnoTyp.AT").getAnnotationType(); } // TypeMirror methods @Test(result="anno type") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); at.accept(new SimpleTypeVisitor() { public void visitReferenceType(ReferenceType t) { res.add("ref type"); } public void visitClassType(ClassType t) { res.add("class"); } public void visitInterfaceType(InterfaceType t) { res.add("interface"); } public void visitAnnotationType(AnnotationType t) { res.add("anno type"); } }); return res; } // AnnotationType method @Test(result="AnnoTyp.AT") AnnotationTypeDeclaration getDeclaration() { return at.getDeclaration(); } }
2,520
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassTyp.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/ClassTyp.java
/* * Copyright (c) 2004, 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 4853450 5009360 5055963 * @summary ClassType tests * @library ../../lib * @run main/othervm ClassTyp */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class ClassTyp<T1,T2> extends Tester { public static void main(String[] args) { (new ClassTyp()).run(); } // Declarations used by tests static class C1<S> extends AbstractSet<S> implements Set<S> { class C2<R> { } static class C3<R> { class C4<Q> { } } public Iterator<S> iterator() { return null; } public int size() { return 0; } } // Generate some class types to test. private C1<T1> f0; private C1<String> f1; private C1 f2; private C1.C3<T2> f3; private C1<T1>.C2<T2> f4; private C1.C2 f5; private C1<T1> f6; private C1.C3<T2>.C4<T1> f7; private static final int NUMTYPES = 8; // Type mirrors corresponding to the types of the above fields private ClassType[] t = new ClassType[NUMTYPES]; // One more type: our own. private ClassTyp<T1,T2> me = this; protected void init() { for (int i = 0; i < t.length; i++) { t[i] = (ClassType) getField("f"+i).getType(); } } // TypeMirror methods @Test(result="class") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); t[0].accept(new SimpleTypeVisitor() { public void visitReferenceType(ReferenceType t) { res.add("ref type"); } public void visitClassType(ClassType t) { res.add("class"); } public void visitInterfaceType(InterfaceType t) { res.add("interface"); } }); return res; } @Test(result="true") boolean equals1() { return t[0].equals(t[0]); } @Test(result="false") boolean equals2() { return t[0].equals(t[1]); } // Raw type is not same as type instantiated with unbounded type var. @Test(result="false") boolean equals3() { return t[0].equals(t[2]); } // C1<T1> is same type as C1<T1> @Test(result="true") boolean equals4() { return t[0].equals(t[6]); } @Test(result={ "ClassTyp.C1<T1>", "ClassTyp.C1<java.lang.String>", "ClassTyp.C1", "ClassTyp.C1.C3<T2>", "ClassTyp.C1<T1>.C2<T2>", "ClassTyp.C1.C2", "ClassTyp.C1<T1>", "ClassTyp.C1.C3<T2>.C4<T1>" }, ordered=true) Collection<String> toStringTests() { Collection<String> res = new ArrayList<String>(); for (ClassType c : t) { res.add(c.toString()); } return res; } // DeclaredType methods @Test(result={"T1"}) Collection<TypeMirror> getActualTypeArguments1() { return t[0].getActualTypeArguments(); } @Test(result={}) Collection<TypeMirror> getActualTypeArguments2() { return t[2].getActualTypeArguments(); } @Test(result={"T2"}) Collection<TypeMirror> getActualTypeArguments3() { return t[3].getActualTypeArguments(); } @Test(result="null") DeclaredType getContainingType1() { ClassType thisType = (ClassType) getField("me").getType(); return thisType.getContainingType(); } @Test(result="ClassTyp") DeclaredType getContainingType2() { return t[0].getContainingType(); } @Test(result="ClassTyp.C1") DeclaredType getContainingType3() { return t[3].getContainingType(); } @Test(result="ClassTyp.C1<T1>") DeclaredType getContainingType4() { return t[4].getContainingType(); } @Test(result={"java.util.Set<T1>"}) Collection<InterfaceType> getSuperinterfaces() { return t[0].getSuperinterfaces(); } // ClassType methods @Test(result="ClassTyp.C1<S>") ClassDeclaration getDeclaration1() { return t[0].getDeclaration(); } @Test(result="ClassTyp.C1.C3<R>") ClassDeclaration getDeclaration2() { return t[3].getDeclaration(); } @Test(result="ClassTyp.C1<S>.C2<R>") ClassDeclaration getDeclaration3a() { return t[4].getDeclaration(); } @Test(result="ClassTyp.C1<S>.C2<R>") ClassDeclaration getDeclaration3b() { return t[5].getDeclaration(); } @Test(result="true") boolean getDeclarationEq() { return t[0].getDeclaration() == t[6].getDeclaration(); } @Test(result="java.util.AbstractSet<T1>") ClassType getSuperclass1() { return t[0].getSuperclass(); } @Test(result="java.lang.Object") ClassType getSuperclass2() { return t[4].getSuperclass(); } @Test(result="null") ClassType getSuperclassOfObject() { return t[4].getSuperclass().getSuperclass(); } }
6,151
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeVar.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/TypeVar.java
/* * Copyright (c) 2004, 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 4853450 * @summary TypeVariable tests * @library ../../lib * @compile -source 1.5 TypeVar.java * @run main/othervm TypeVar */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class TypeVar<T, S extends Number & Runnable> extends Tester { public static void main(String[] args) { (new TypeVar()).run(); } // Declarations used by tests private T t; private S s; private TypeVariable tvT; // type variable T private TypeVariable tvS; // type variable S protected void init() { tvT = (TypeVariable) getField("t").getType(); tvS = (TypeVariable) getField("s").getType(); } // TypeMirror methods @Test(result="type var") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); tvT.accept(new SimpleTypeVisitor() { public void visitTypeMirror(TypeMirror t) { res.add("type"); } public void visitReferenceType(ReferenceType t) { res.add("ref type"); } public void visitTypeVariable(TypeVariable t) { res.add("type var"); } }); return res; } @Test(result="T") String toStringTest1() { return tvT.toString(); } @Test(result="S") String toStringTest2() { return tvS.toString(); } // TypeVariable method @Test(result="S extends java.lang.Number & java.lang.Runnable") TypeParameterDeclaration getDeclaration() { return tvS.getDeclaration(); } }
2,738
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PrimitiveTyp.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/type/PrimitiveTyp.java
/* * Copyright (c) 2004, 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 4853450 * @summary PrimitiveType tests * @library ../../lib * @compile -source 1.5 PrimitiveTyp.java * @run main/othervm PrimitiveTyp */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class PrimitiveTyp extends Tester { public static void main(String[] args) { (new PrimitiveTyp()).run(); } // Declaration used by tests private boolean b; private PrimitiveType prim; // a primitive type protected void init() { prim = (PrimitiveType) getField("b").getType(); } // TypeMirror methods @Test(result="primitive") Collection<String> accept() { final Collection<String> res = new ArrayList<String>(); prim.accept(new SimpleTypeVisitor() { public void visitTypeMirror(TypeMirror t) { res.add("type"); } public void visitPrimitiveType(PrimitiveType t) { res.add("primitive"); } public void visitReferenceType(ReferenceType t) { res.add("ref type"); } }); return res; } @Test(result="boolean") String toStringTest() { return prim.toString(); } // PrimitiveType method @Test(result="BOOLEAN") PrimitiveType.Kind getKind() { return prim.getKind(); } }
2,485
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeCreation.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/util/TypeCreation.java
/* * Copyright (c) 2004, 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 5033381 * @summary Test the type creation methods in Types. * @library ../../lib * @run main/othervm TypeCreation */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import static com.sun.mirror.type.PrimitiveType.Kind.*; public class TypeCreation extends Tester { public static void main(String[] args) { (new TypeCreation()).run(); } // Declarations used by tests class A { } class O<T> { class I<S> { } } private Types types; private TypeDeclaration A; private TypeDeclaration O; private TypeDeclaration I; private DeclaredType AType; protected void init() { types = env.getTypeUtils(); A = env.getTypeDeclaration("TypeCreation.A"); O = env.getTypeDeclaration("TypeCreation.O"); I = env.getTypeDeclaration("TypeCreation.O.I"); AType = types.getDeclaredType(A); } @Test(result="boolean") PrimitiveType getPrimitiveType() { return types.getPrimitiveType(BOOLEAN); } @Test(result="void") VoidType getVoidType() { return types.getVoidType(); } @Test(result="boolean[]") ArrayType getArrayType1() { return types.getArrayType( types.getPrimitiveType(BOOLEAN)); } @Test(result="TypeCreation.A[]") ArrayType getArrayType2() { return types.getArrayType(AType); } @Test(result="? extends TypeCreation.A") WildcardType getWildcardType() { Collection<ReferenceType> uppers = new ArrayList<ReferenceType>(); Collection<ReferenceType> downers = new ArrayList<ReferenceType>(); uppers.add(AType); return types.getWildcardType(uppers, downers); } @Test(result="TypeCreation.O<java.lang.String>") DeclaredType getDeclaredType1() { TypeDeclaration stringDecl = env.getTypeDeclaration("java.lang.String"); DeclaredType stringType = types.getDeclaredType(stringDecl); return types.getDeclaredType(O, stringType); } @Test(result="TypeCreation.O<java.lang.String>.I<java.lang.Number>") DeclaredType getDeclaredType2() { TypeDeclaration numDecl = env.getTypeDeclaration("java.lang.Number"); DeclaredType numType = types.getDeclaredType(numDecl); DeclaredType OType = getDeclaredType1(); return types.getDeclaredType(OType, I, numType); } }
3,535
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Overrides.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/mirror/util/Overrides.java
/* * Copyright (c) 2004, 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 5037165 * @summary Test the Declarations.overrides method * @library ../../lib * @run main/othervm Overrides */ import java.util.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; public class Overrides extends Tester { public static void main(String[] args) { (new Overrides()).run(); } // Declarations used by tests static class A { void m1(int i) {}; // does not override itself void m2(int i) {}; static void m3(int i) {}; } static class B extends A { void m1(int j) {}; // overrides A.m1 void m1(String i) {}; // does not override A.m1 void m4(int i) {}; // does not override A.m1 } static class C extends B { void m1(int i) {}; // overrides A.m1 and B.m1 void m2(int i) {}; // overrides A.m2 } static class D extends A { static void m3(int i) {}; // does not override A.m3 } static class E { void m1(int i) {}; // does not override A.m1 } private Declarations decls; private TypeDeclaration A; private TypeDeclaration B; private TypeDeclaration C; private TypeDeclaration D; private TypeDeclaration E; private MethodDeclaration Am1; private MethodDeclaration Am2; private MethodDeclaration Am3; private MethodDeclaration Bm1; private MethodDeclaration Bm1b; private MethodDeclaration Bm4; private MethodDeclaration Cm1; private MethodDeclaration Cm2; private MethodDeclaration Dm3; private MethodDeclaration Em1; protected void init() { decls = env.getDeclarationUtils(); A = env.getTypeDeclaration("Overrides.A"); B = env.getTypeDeclaration("Overrides.B"); C = env.getTypeDeclaration("Overrides.C"); D = env.getTypeDeclaration("Overrides.D"); E = env.getTypeDeclaration("Overrides.E"); Am1 = getMethod(A, "m1", "i"); Am2 = getMethod(A, "m2", "i"); Am3 = getMethod(A, "m3", "i"); Bm1 = getMethod(B, "m1", "j"); Bm1b = getMethod(B, "m1", "i"); Bm4 = getMethod(B, "m4", "i"); Cm1 = getMethod(C, "m1", "i"); Cm2 = getMethod(C, "m2", "i"); Dm3 = getMethod(D, "m3", "i"); Em1 = getMethod(E, "m1", "i"); } private MethodDeclaration getMethod(TypeDeclaration t, String methodName, String paramName) { for (MethodDeclaration m : t.getMethods()) { if (methodName.equals(m.getSimpleName()) && paramName.equals(m.getParameters().iterator().next() .getSimpleName())) { return m; } } throw new AssertionError(); } // Declarations methods @Test(result={"false", "true", "false", "false", "true", "true", "true", "false", "false"}, ordered=true) List<Boolean> overrides() { return Arrays.asList( decls.overrides(Am1, Am1), decls.overrides(Bm1, Am1), decls.overrides(Bm1b,Am1), decls.overrides(Bm4, Am1), decls.overrides(Cm1, Am1), decls.overrides(Cm1, Bm1), decls.overrides(Cm2, Am2), decls.overrides(Dm3, Am3), decls.overrides(Em1, Am1)); } }
4,775
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Round3Apf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/Round3Apf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Factory to help test updated discovery policy. */ public class Round3Apf implements AnnotationProcessorFactory { // Process @Round3 private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("Round3")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } private static int round = 0; public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new Round3Ap(env, atds.size() == 0); } private static class Round3Ap implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; private final boolean empty; Round3Ap(AnnotationProcessorEnvironment env, boolean empty) { this.env = env; this.empty = empty; } public void process() { Round3Apf.round++; try { if (!empty) env.getFiler().createSourceFile("Dummy4").println("@Round4 class Dummy4{}"); } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } System.out.println("Round3Apf: " + round); } } }
2,862
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Round4Apf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/Round4Apf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Factory to help test updated discovery policy. */ public class Round4Apf implements AnnotationProcessorFactory { // Process @Round4 private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("Round4")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } private static int round = 0; public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new Round4Ap(env, atds.size() == 0); } private static class Round4Ap implements AnnotationProcessor, RoundCompleteListener { private final AnnotationProcessorEnvironment env; private final boolean empty; Round4Ap(AnnotationProcessorEnvironment env, boolean empty) { this.env = env; this.empty = empty; } public void process() { Round4Apf.round++; try { if (!empty) env.getFiler().createSourceFile("Dummy5").println("@Round5 class Dummy5{}"); } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } System.out.println("Round4Apf: " + round); env.addListener(this); } public void roundComplete(RoundCompleteEvent event) { RoundState rs = event.getRoundState(); System.out.println("\t" + rs.toString()); System.out.println("Round4Apf: " + round + " complete"); if (rs.finalRound()) { System.out.println("Valediction"); } } } }
3,270
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Round2Apf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/Round2Apf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import java.io.IOException; import java.io.File; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Factory to help test updated discovery policy. */ public class Round2Apf implements AnnotationProcessorFactory { // Process @Round2 private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("Round2")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } private static int round = 0; public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new Round2Ap(env, atds.size() == 0); } private static class Round2Ap implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; private final boolean empty; Round2Ap(AnnotationProcessorEnvironment env, boolean empty) { this.env = env; this.empty = empty; } public void process() { Round2Apf.round++; Filer f = env.getFiler(); try { f.createSourceFile("Dummy2").println("@Round2 class Dummy2{}"); throw new RuntimeException("Duplicate file creation allowed"); } catch (IOException io) {} try { f.createTextFile(Filer.Location.SOURCE_TREE, "", new File("foo.txt"), null).println("xxyzzy"); throw new RuntimeException("Duplicate file creation allowed"); } catch (IOException io) {} try { f.createClassFile("Vacant"); throw new RuntimeException("Duplicate file creation allowed"); } catch (IOException io) {} try { f.createBinaryFile(Filer.Location.CLASS_TREE, "", new File("onezero")); throw new RuntimeException("Duplicate file creation allowed"); } catch (IOException io) {} try { if (!empty) { // Create corresponding files of opposite kind to // the files created by Round1Apf; these should // only generate warnings f.createClassFile("Dummy2"); f.createSourceFile("Vacant").println("class Vacant{}"); f.createSourceFile("Dummy3").println("@Round3 class Dummy3{}"); // This should generated a warning too f.createClassFile("Dummy3"); } } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } System.out.println("Round2Apf: " + round); } } }
4,423
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
StaticApf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/StaticApf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; /* * This class is used to test the ability to store static state across * apt rounds. */ public class StaticApf implements AnnotationProcessorFactory { static int round = -1; // Process any set of annotations private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new StaticAp(env); } private static class StaticAp implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; StaticAp(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { int size = env.getSpecifiedTypeDeclarations().size(); try { round++; switch (size) { case 0: if (round == 0) { env.getFiler().createSourceFile("Round1").print("class Round1 {}"); } else throw new RuntimeException("Got " + size + " decl's in round " + round); break; case 1: if (round == 1) { env.getFiler().createSourceFile("AhOne").print("class AhOne {}"); env.getFiler().createSourceFile("AndAhTwo").print("class AndAhTwo {}"); env.getFiler().createClassFile("Foo"); } else throw new RuntimeException("Got " + size + " decl's in round " + round); break; case 2: if (round != 2) { throw new RuntimeException("Got " + size + " decl's in round " + round); } break; } } catch (java.io.IOException ioe) { throw new RuntimeException(); } } } }
3,681
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
HelloAnnotation.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/HelloAnnotation.java
/* /nodynamiccopyright/ */ import java.lang.annotation.*; @Target(ElementType.ANNOTATION_TYPE) @Retention(RetentionPolicy.RUNTIME) @HelloAnnotation @interface HelloAnnotation { Target value() default @Target(ElementType.METHOD); }
235
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
HelloWorld.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/HelloWorld.java
/* /nodynamiccopyright/ */ public class HelloWorld { public static void main(String argv[]) { System.out.println("Hello World."); } }
150
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Rounds.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/Rounds.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ @interface Round1{} @interface Round2{} @interface Round3{} @interface Round4{} @interface Round5{}
1,163
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ErrorAPF.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/ErrorAPF.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Construct a processor that does nothing but report an error. */ public class ErrorAPF implements AnnotationProcessorFactory { static class ErrorAP implements AnnotationProcessor { AnnotationProcessorEnvironment env; ErrorAP(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { Messager messager = env.getMessager(); messager.printError("It's a mad, mad, mad, mad world"); messager.printError("Something wicked this way comes"); for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) messager.printError(typeDecl.getPosition(), "Boring class name"); } } static Collection<String> supportedTypes; static { String types[] = {"*"}; supportedTypes = unmodifiableCollection(Arrays.asList(types)); } static Collection<String> supportedOptions; static { String options[] = {""}; supportedOptions = unmodifiableCollection(Arrays.asList(options)); } public Collection<String> supportedOptions() { return supportedOptions; } public Collection<String> supportedAnnotationTypes() { return supportedTypes; } public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new ErrorAP(env); } }
2,830
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Dummy1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/Dummy1.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ @Round1 class Dummy1{}
1,082
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
WarnAPF.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/WarnAPF.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Map; import java.util.Arrays; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Construct a processor that does nothing but report a warning. */ public class WarnAPF implements AnnotationProcessorFactory { static class WarnAP implements AnnotationProcessor { AnnotationProcessorEnvironment env; WarnAP(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { Messager messager = env.getMessager(); messager.printWarning("Beware the ides of March!"); for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) { messager.printNotice(typeDecl.getPosition(), "You are about to be warned"); messager.printWarning(typeDecl.getPosition(), "Strange class name"); for(AnnotationMirror annotMirror : typeDecl.getAnnotationMirrors()) { messager.printNotice("MIRROR " + annotMirror.getPosition().toString()); Map<AnnotationTypeElementDeclaration,AnnotationValue> map = annotMirror.getElementValues(); if (map.keySet().size() > 0) for(AnnotationTypeElementDeclaration key : map.keySet() ) { AnnotationValue annotValue = map.get(key); Object o = annotValue.getValue(); // asserting getPosition is non-null messager.printNotice("VALUE " + annotValue.getPosition().toString()); } else { Collection<AnnotationTypeElementDeclaration> ateds = annotMirror.getAnnotationType().getDeclaration().getMethods(); for(AnnotationTypeElementDeclaration ated : ateds ) { AnnotationValue annotValue = ated.getDefaultValue(); Object o = annotValue.getValue(); messager.printNotice("VALUE " + "HelloAnnotation.java:5"); } } } } } } static final Collection<String> supportedTypes; static { String types[] = {"*"}; supportedTypes = unmodifiableCollection(Arrays.asList(types)); } public Collection<String> supportedAnnotationTypes() {return supportedTypes;} static final Collection<String> supportedOptions; static { String options[] = {""}; supportedOptions = unmodifiableCollection(Arrays.asList(options)); } public Collection<String> supportedOptions() {return supportedOptions;} public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new WarnAP(env); } }
4,225
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
WrappedStaticApf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/WrappedStaticApf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.AnnotationProcessorFactory; /* * Pass an instantiated StaticApf object to the * com.sun.tools.apt.Main.process entry point. */ public class WrappedStaticApf { public static void main(String argv[]) { AnnotationProcessorFactory factory = new StaticApf(); System.exit(com.sun.tools.apt.Main.process(factory, argv)); } }
1,431
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassDeclApf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/ClassDeclApf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import java.io.*; import static java.util.Collections.*; /* * This class is used to test the ability to store static state across * apt rounds. */ public class ClassDeclApf implements AnnotationProcessorFactory { static int round = -1; // Process any set of annotations private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new ClassDeclAp(env); } private static class ClassDeclAp implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; ClassDeclAp(AnnotationProcessorEnvironment env) { this.env = env; } // Simple inefficient drain void drain(InputStream is, OutputStream os) { try { while (is.available() > 0 ) os.write(is.read()); } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } } public void process() { int size = env.getSpecifiedTypeDeclarations().size(); try { round++; switch (size) { case 0: if (round == 0) { drain(new FileInputStream("./tmp/classes/Round1Class.class"), env.getFiler().createClassFile("Round1Class")); } else throw new RuntimeException("Got " + size + " decl's in round " + round); break; case 1: if (round == 1) { drain(new FileInputStream("./tmp/classes/AhOneClass.class"), env.getFiler().createClassFile("AhOneClass")); drain(new FileInputStream("./tmp/classes/AndAhTwoClass.class"), env.getFiler().createClassFile("AndAhTwoClass")); } else throw new RuntimeException("Got " + size + " decl's in round " + round); break; case 2: if (round != 2) { throw new RuntimeException("Got " + size + " decl's in round " + round); } break; } } catch (java.io.IOException ioe) { throw new RuntimeException(); } } } }
4,174
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassDeclApf2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/ClassDeclApf2.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import java.io.*; import static java.util.Collections.*; /* * This class is used to test the the interaction of -XclassesAsDecls * with command line options handling. */ public class ClassDeclApf2 implements AnnotationProcessorFactory { static int round = -1; // Process any set of annotations private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new ClassDeclAp(env); } private static class ClassDeclAp implements AnnotationProcessor { private final AnnotationProcessorEnvironment env; ClassDeclAp(AnnotationProcessorEnvironment env) { this.env = env; } // Simple inefficient drain void drain(InputStream is, OutputStream os) { try { while (is.available() > 0 ) os.write(is.read()); } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } } public void process() { int size = env.getSpecifiedTypeDeclarations().size(); Filer f = env.getFiler(); try { round++; switch (size) { case 3: if (round == 0) { drain(new FileInputStream("./tmp/classes/Round1Class.class"), f.createClassFile("Round1Class")); } else throw new RuntimeException("Got " + size + " decl's in round " + round); break; case 1: if (round == 1) { f.createSourceFile("AhOne").println("public class AhOne {}"); System.out.println("Before writing AndAhTwoClass"); drain(new FileInputStream("./tmp/classes/AndAhTwoClass.class"), f.createClassFile("AndAhTwoClass")); System.out.println("After writing AndAhTwoClass"); } else throw new RuntimeException("Got " + size + " decl's in round " + round); break; case 2: if (round != 2) { throw new RuntimeException("Got " + size + " decl's in round " + round); } break; default: throw new RuntimeException("Unexpected number of declarations:" + size + "\n Specified:" + env.getSpecifiedTypeDeclarations() + "\n Included:" + env.getTypeDeclarations() ); } } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } } } }
4,586
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Round1Apf.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/Round1Apf.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import java.io.File; import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; /* * Factory to help test updated discovery policy. */ public class Round1Apf implements AnnotationProcessorFactory { // Process @Round1 private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("Round1")); // No supported options private static final Collection<String> supportedOptions = emptySet(); public Collection<String> supportedAnnotationTypes() { return supportedAnnotations; } public Collection<String> supportedOptions() { return supportedOptions; } private static int round = 0; public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { return new Round1Ap(env, atds.size() == 0); } private static class Round1Ap implements AnnotationProcessor, RoundCompleteListener { private final AnnotationProcessorEnvironment env; private final boolean empty; Round1Ap(AnnotationProcessorEnvironment env, boolean empty) { this.env = env; this.empty = empty; } public void process() { Round1Apf.round++; try { if (!empty) { Filer f = env.getFiler(); f.createSourceFile("Dummy2").println("@Round2 class Dummy2{}"); f.createTextFile(Filer.Location.SOURCE_TREE, "", new File("foo.txt"), null).println("xxyzzy"); f.createClassFile("Vacant"); f.createBinaryFile(Filer.Location.CLASS_TREE, "", new File("onezero")); } } catch (java.io.IOException ioe) { throw new RuntimeException(ioe); } System.out.println("Round1Apf: " + round); env.addListener(this); } public void roundComplete(RoundCompleteEvent event) { RoundState rs = event.getRoundState(); if (event.getSource() != this.env) throw new RuntimeException("Wrong source!"); Filer f = env.getFiler(); try { f.createSourceFile("AfterTheBell").println("@Round2 class AfterTheBell{}"); throw new RuntimeException("Inappropriate source file creation."); } catch (java.io.IOException ioe) {} System.out.printf("\t[final round: %b, error raised: %b, "+ "source files created: %b, class files created: %b]%n", rs.finalRound(), rs.errorRaised(), rs.sourceFilesCreated(), rs.classFilesCreated()); System.out.println("Round1Apf: " + round + " complete"); } } }
4,389
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AhOneClass.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/src/AhOneClass.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public class AhOneClass {}
1,086
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AndAhTwoClass.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/src/AndAhTwoClass.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public class AndAhTwoClass {}
1,089
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Round1Class.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/apt/Compile/src/Round1Class.java
/* * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ public class Round1Class {}
1,087
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z