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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/supertypes/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
import java.util.ArrayList;
public class A extends ArrayList<String> {
}
| 1,141 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/supertypes/pkg1/B.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
import java.util.ArrayList;
public class B<X> extends ArrayList<X> {
}
| 1,139 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/throwsGeneric/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the reading of generic methods and constructors.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
for (MethodDoc m : cd.methods())
tester.printMethod(m);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,845 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/throwsGeneric/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public interface A<T extends Throwable> {
void m1() throws T;
<U extends Throwable> void m2() throws U;
}
| 1,181 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/tparamCycle/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Check a type parameter whose bound cycles back on itself.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
}
public static boolean start(RootDoc root) {
ClassDoc cd = root.classes()[0];
System.out.println("*** " + cd);
TypeVariable E = cd.typeParameters()[0];
System.out.println("*** " + E);
Type bound = E.bounds()[0];
System.out.println("*** " + bound);
// Verify that we have an instantiation of Enum<E>, and not
// the generic interface.
ParameterizedType enumE = (ParameterizedType)bound;
if (enumE.asClassDoc() != cd) {
throw new Error("Type declaration and type use don't match up.");
} else {
return true;
}
}
}
| 2,142 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
LikeEnum.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/tparamCycle/pkg1/LikeEnum.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public interface LikeEnum<E extends LikeEnum<E>> {
}
| 1,120 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericSuper/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the contents of the ClassDoc of a generic class.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import java.util.Arrays;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester =
new Tester("Main", "pkg1", "-package");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
ClassDoc[] cds = root.classes();
Arrays.sort(cds);
for (ClassDoc cd : cds) {
tester.printClass(cd);
tester.println();
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,939 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericSuper/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
class S<T,U> {
}
interface I<R> {
}
public class A<V,W> extends S<W,V> implements I<String> {
}
| 1,165 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/wildcards/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the contents of the ClassDoc of a generic class.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
tester.printClass(cd);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,792 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/wildcards/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public class A<T> {
public A<?> f1;
public A<? extends Number> f2;
public A<? super Long> f3;
public void m1(A<?> p1) {}
public void m2(A<? extends Number> p2) {}
public void m3(A<? super Long> p3) {}
}
| 1,295 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/tparamTagOnMethod/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the reading of type parameter tags on methods.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
for (MethodDoc m : cd.methods()) {
tester.printMethod(m);
}
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,863 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/tparamTagOnMethod/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public interface A {
/**
* @param <T> the kind of thing
* @param <U> the other kind of thing
* @param t the thing itself
* @param u the other thing
*/
public <T,U> void m1(T t, U u);
}
| 1,285 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericMethod/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the reading of generic methods and constructors.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
for (ConstructorDoc c : cd.constructors())
tester.printConstructor(c);
for (MethodDoc m : cd.methods())
tester.printMethod(m);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,952 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericMethod/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public class A {
public <T> A() {}
public <T> void m1(T t) {}
public <T extends Number, U> void m2(T t, U u) {}
}
| 1,193 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericInnerAndOuter/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the contents of the ClassDoc of
* a generic class with a generic inner class.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import java.util.Arrays;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
ClassDoc[] cds = root.classes();
Arrays.sort(cds);
for (ClassDoc cd : cds) {
tester.printClass(cd);
tester.println();
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,954 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
X.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericInnerAndOuter/pkg1/X.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public class X<T> {
public class Y {
public class Z<S> {
public void m1(X<String>.Y.Z<Number> a) {}
}
}
}
| 1,209 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
O.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericInnerAndOuter/pkg1/O.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public class O<T> {
public class I<S> {
public void m1(O<String>.I<Number> a) {}
}
}
| 1,168 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericInterface/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the contents of the ClassDoc of a generic interface.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
tester.printClass(cd);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,796 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericInterface/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public interface A<T> {
void m1(T t);
}
| 1,111 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericClass/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the contents of the ClassDoc of a generic class.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
tester.printClass(cd);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,792 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/genericClass/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public class A<T> {
public T t;
public A<T> at;
public A<String> as;
public void m1(T t) {}
public void m2(A<T> at) {}
public void m3(A<String> as) {}
}
| 1,245 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/tparamTagOnType/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4421066
* @summary Verify the reading of a type parameter tag on an interface.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
tester.printClass(cd);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,796 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/generics/tparamTagOnType/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
/**
* @param <T> the type parameter
*/
public interface A<T> {
}
| 1,134 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
X.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/6176978/X.java | /*
* Copyright (c) 2008, 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 com.sun.javadoc.*;
public class X {
public static boolean start(RootDoc root) {
System.out.println("X.start");
return true;
}
}
| 1,218 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6176978.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/6176978/T6176978.java | /*
* Copyright (c) 2008, 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.
*/
/*
* @test
* @bug 6176978
* @summary current Javadoc's invocation and extension (Doclet) mechanisms are problematic
* @build T6176978
* @run main T6176978
*/
import java.io.*;
import java.net.*;
public class T6176978
{
public static void main(String[] args) throws Exception {
// create and use a temp dir that will not be on jtreg's
// default class path
File tmpDir = new File("tmp");
tmpDir.mkdirs();
File testSrc = new File(System.getProperty("test.src", "."));
String[] javac_args = {
"-d",
"tmp",
new File(testSrc, "X.java").getPath()
};
int rc = com.sun.tools.javac.Main.compile(javac_args);
if (rc != 0)
throw new Error("javac exit code: " + rc);
String[] jdoc_args = {
"-doclet",
"X",
new File(testSrc, "T6176978.java").getPath()
};
rc = com.sun.tools.javadoc.Main.execute(jdoc_args);
if (rc == 0)
throw new Error("javadoc unexpectedly succeeded");
Thread currThread = Thread.currentThread();
ClassLoader saveClassLoader = currThread.getContextClassLoader();
URLClassLoader urlCL = new URLClassLoader(new URL[] { tmpDir.toURL() });
currThread.setContextClassLoader(urlCL);
try {
rc = com.sun.tools.javadoc.Main.execute(jdoc_args);
if (rc != 0)
throw new Error("javadoc exit: " + rc);
}
finally {
currThread.setContextClassLoader(saveClassLoader);
}
}
}
| 2,660 | 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/javadoc/6227454/Test.java | /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6227454
* @summary package.html and overview.html may not be read fully
*/
import java.io.*;
import com.sun.javadoc.Doclet;
import com.sun.javadoc.RootDoc;
public class Test extends Doclet {
public static void main(String... args) throws Exception {
new Test().run();
}
void run() throws Exception {
test("<html><body>ABC XYZ</body></html>");
test("<html><body>ABC XYZ</BODY></html>");
test("<html><BODY>ABC XYZ</body></html>");
test("<html><BODY>ABC XYZ</BODY></html>");
test("<html><BoDy>ABC XYZ</bOdY></html>");
test("<html> ABC XYZ</bOdY></html>", "Body tag missing from HTML");
test("<html><body>ABC XYZ </html>", "Close body tag missing from HTML");
test("<html> ABC XYZ </html>", "Body tag missing from HTML");
test("<html><body>ABC" + bigText(8192, 40) + "XYZ</body></html>");
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
void test(String text) throws IOException {
test(text, null);
}
void test(String text, String expectError) throws IOException {
testNum++;
System.err.println("test " + testNum);
File file = writeFile("overview" + testNum + ".html", text);
String thisClassName = Test.class.getName();
File testSrc = new File(System.getProperty("test.src"));
String[] args = {
"-bootclasspath",
System.getProperty("java.class.path")
+ File.pathSeparator
+ System.getProperty("sun.boot.class.path"),
"-classpath", ".",
"-package",
"-overview", file.getPath(),
new File(testSrc, thisClassName + ".java").getPath()
};
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javadoc.Main.execute(
"javadoc",
pw, pw, pw,
thisClassName,
args);
pw.close();
String out = sw.toString();
if (!out.isEmpty())
System.err.println(out);
System.err.println("javadoc exit: rc=" + rc);
if (expectError == null) {
if (rc != 0)
error("unexpected exit from javadoc; rc:" + rc);
} else {
if (!out.contains(expectError))
error("expected error text not found: " + expectError);
}
}
String bigText(int lines, int lineLength) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < lineLength; i++)
sb.append(String.valueOf(i % 10));
sb.append("\n");
String line = sb.toString();
sb.setLength(0);
for (int i = 0; i < lines; i++)
sb.append(line);
return sb.toString();
}
File writeFile(String path, String body) throws IOException {
File f = new File(path);
FileWriter out = new FileWriter(f);
try {
out.write(body);
} finally {
out.close();
}
return f;
}
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
int testNum;
int errors;
public static boolean start(RootDoc root) {
String text = root.commentText();
if (text.length() < 64)
System.err.println("text: '" + text + "'");
else
System.err.println("text: '"
+ text.substring(0, 20)
+ "..."
+ text.substring(text.length() - 20)
+ "'");
return text.startsWith("ABC") && text.endsWith("XYZ");
}
}
| 4,839 | 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/javadoc/sourceOnly/Test.java | /*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 4548768
* @summary Javadoc in JDK 1.4 uses classpath and not just source dir
* @author gafter
* @compile p/SourceOnly.java
* @run main p.SourceOnly
*/
// this file is just a dummy to get the javadoc started.
//
// NOTE: this test only seems to work in separate JVM mode for
// reasons having something to do with javing tools.jar
// on the classpath. Until that is sorted out, these tests
// must be run in separate VM mode.
| 1,504 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SourceOnly.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/sourceOnly/p/SourceOnly.java | /*
* Copyright (c) 2002, 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.
*/
package p;
/** Test that when running javadoc on a package, we only get
* documentation for those classes for which source was provided.
*/
public class SourceOnly extends com.sun.javadoc.Doclet
{
public static void main(String[] args) {
// run javadoc on package p
int result = com.sun.tools.javadoc.Main.
execute("javadoc", "p.SourceOnly", SourceOnly.class.getClassLoader(), new String[] {"p"});
if (result != 0)
throw new Error();
}
public static boolean start(com.sun.javadoc.RootDoc root) {
if (root.classes().length != 1)
throw new Error("wrong set of classes documented: " + java.util.Arrays.asList(root.classes()));
return true;
}
}
| 1,796 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NestedClassB.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/nestedClass/NestedClassB.java | /*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 NestedClassB {
public static class Inner {}
}
| 1,115 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NestedClass.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/nestedClass/NestedClass.java | /*
* Copyright (c) 2002, 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 4694497
* @summary BDoclet API: Bad ClassDoc for nested classes when built from .class files
* @author gafter
* @compile NestedClass.java NestedClassB.java
* @run main NestedClass
*/
import com.sun.javadoc.*;
import java.util.*;
public class NestedClass extends Doclet
{
public NestedClassB b;
public static void main(String[] args) {
if (com.sun.tools.javadoc.Main.
execute("javadoc", "NestedClass", NestedClass.class.getClassLoader(),
new String[] {System.getProperty("test.src", ".") +
java.io.File.separatorChar +
"NestedClass.java"})
!= 0)
throw new Error();
}
public static boolean start(com.sun.javadoc.RootDoc root) {
ClassDoc[] classes = root.classes();
if (classes.length != 1)
throw new Error("1 " + Arrays.asList(classes));
ClassDoc self = classes[0];
FieldDoc B = self.fields()[0];
ClassDoc[] Binner = B.type().asClassDoc().innerClasses();
return Binner.length == 1;
}
}
| 2,183 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SubpackageIgnore.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/subpackageIgnore/SubpackageIgnore.java | /*
* Copyright (c) 2003, 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 4773013
* @summary When hunting subpackages, silently ignore any directory name that
* can't be part of a subpackage.
*/
import com.sun.javadoc.*;
public class SubpackageIgnore extends Doclet {
public static void main(String[] args) {
if (com.sun.tools.javadoc.Main.execute(
"javadoc",
"SubpackageIgnore",
SubpackageIgnore.class.getClassLoader(),
new String[] {"-Xwerror",
"-sourcepath",
System.getProperty("test.src", "."),
"-subpackages",
"pkg1"}) != 0)
throw new Error("Javadoc encountered warnings or errors.");
}
/*
* The world's simplest doclet.
*/
public static boolean start(RootDoc root) {
return true;
}
}
| 1,952 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SomeJavaFile.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/subpackageIgnore/pkg1/not-subpkg/SomeJavaFile.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
| 1,051 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotatePackage/Main.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5031168
* @summary Test package annotations and package-info.java package comments.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.*;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1", "pkg2");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (PackageDoc pkg : root.specifiedPackages()) {
tester.println("/**");
tester.println(pkg.commentText());
for (Tag tag : pkg.tags())
tester.println(tag);
tester.println("*/");
tester.printPackage(pkg);
tester.println();
}
for (ClassDoc cd : root.classes()) {
tester.println(cd);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 2,161 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotatePackage/pkg2/B.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Doc comment here is ignored.
*/
package pkg2;
public class B {
}
| 1,126 | 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/javadoc/annotations/annotatePackage/pkg1/package-info.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This is package pkg1.
*
* For every problem, there is a solution that is simple, elegant, and wrong.
*
* @author H. L. Mencken
* @since 1880
*/
@Deprecated
@A(boolean.class)
package pkg1;
| 1,254 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotatePackage/pkg1/A.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Doc comment here is ignored.
*/
package pkg1;
public @interface A {
Class value();
}
| 1,150 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/elementTypes/Main.java | /*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4904495
* @summary Test an annotation type and annotations with elements of various
* types.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import java.util.Arrays;
import com.sun.javadoc.*;
import com.sun.javadoc.AnnotationDesc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
ClassDoc[] cds = root.classes();
Arrays.sort(cds);
for (ClassDoc cd : cds) {
tester.printClass(cd);
tester.println();
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,990 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/elementTypes/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public @interface A {
int i();
double d();
boolean b();
String s();
Class c();
Class<? extends Number> w();
java.lang.annotation.ElementType e();
A a();
String[] sa();
}
| 1,273 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/elementTypes/pkg1/B.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
@A(i = 1+1,
d = 3.14,
b = true,
s = "sigh",
c = Boolean.class,
w = Long.class,
e = java.lang.annotation.ElementType.TYPE,
a = @A,
sa = {"up", "down"})
public interface B {
}
| 1,265 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotateParams/Main.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5031171
* @summary Test parameter annotations.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (PackageDoc pkg : root.specifiedPackages()) {
for (ClassDoc cd : pkg.ordinaryClasses()) {
for (ConstructorDoc c : cd.constructors()) {
tester.println(c);
tester.println();
for (Parameter p : c.parameters()) {
tester.printParameter(p);
}
tester.println();
}
for (MethodDoc m : cd.methods()) {
tester.println(m);
tester.println();
for (Parameter p : m.parameters()) {
tester.printParameter(p);
}
tester.println();
}
}
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 2,516 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
C.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotateParams/pkg1/C.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public class C {
public C(@A("p0") boolean p0) {
}
public void m(@A("p1") int p1,
int p2,
@Deprecated @A("p3") String p3) {
}
}
| 1,249 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotateParams/pkg1/A.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public @interface A {
String value();
}
| 1,111 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/shortcuts/Main.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4904495
* @summary Verify that "shortcuts" are used when printing annotations.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
if (cd.isInterface()) {
tester.printClass(cd);
}
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,858 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Marker.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/shortcuts/pkg1/Marker.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public @interface Marker {
}
| 1,096 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/shortcuts/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
@Value("there is only one")
@Array(favoriteNumbers={3.5})
@Marker
public interface A {
}
| 1,156 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Value.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/shortcuts/pkg1/Value.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public @interface Value {
String value();
}
| 1,115 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Array.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/shortcuts/pkg1/Array.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public @interface Array {
double[] favoriteNumbers();
}
| 1,127 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/badVals/Main.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5029874
* @summary Verify that bad annotation values don't result in NPE
* @library ../../lib
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
}
public static boolean start(RootDoc root) {
try {
for (ClassDoc cd : root.classes()) {
tester.printClass(cd);
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 1,702 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/badVals/pkg1/A.java | /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
import java.lang.annotation.*;
public class A {
@Retention(BOGUS) // illegal
public @interface A1 {}
@Target({BOGUS}) // illegal
public @interface A2 {}
@Retention(true) // illegal
public @interface A3 {}
public @interface A4 {
ElementType value() default BOGUS; // illegal
}
public @interface A5 {
int[] value() default {true}; // illegal
}
}
| 1,520 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/missing/Main.java | /*
* Copyright 2009 Google, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 6709246
* @summary Class-cast exception when annotation type is missing.
* @library ../../lib
*/
import java.io.IOException;
import com.sun.javadoc.RootDoc;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.AnnotationDesc;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "somepackage");
public static void main(String... args) throws Exception {
tester.run();
}
public static boolean start(RootDoc root) {
for (ClassDoc d : root.classes()) {
for (AnnotationDesc a : d.annotations()) {
System.out.println(a.annotationType());
}
}
return true;
}
}
| 1,753 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
MissingAnnotationClass.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/missing/somepackage/MissingAnnotationClass.java | /*
* Copyright 2009 Google, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 somepackage;
/**
* This class has an annotation which is not available.
*/
@NoSuchAnnotation
public class MissingAnnotationClass {
}
| 1,175 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/defaults/Main.java | /*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4904495
* @summary Test an annotation type with default element values, and
* annotations that use them.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
import com.sun.javadoc.AnnotationDesc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (AnnotationTypeDoc at :
root.specifiedPackages()[0].annotationTypes()) {
tester.printAnnotationType(at);
tester.println();
}
for (ClassDoc cd :
root.specifiedPackages()[0].interfaces()) {
for (MethodDoc m : cd.methods()) {
tester.printMethod(m);
}
tester.println();
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 2,240 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/defaults/pkg1/A.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public @interface A {
String value() default "sigh";
int i() default 1+1;
double d() default 3.14;
boolean b() default true;
Class c() default Boolean.class;
Class<? extends Number> w() default Long.class;
java.lang.annotation.ElementType e() default java.lang.annotation.ElementType.TYPE;
A a() default @A(d=2.718);
String[] sa() default {"up", "down"};
}
| 1,460 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/defaults/pkg1/B.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public interface B {
@A void m1();
@A("flip") void m2();
@A(value="flop") void m3();
@A(c=Boolean.class, w=Long.class, sa={})
void m4();
@A(i=0, e=java.lang.annotation.ElementType.FIELD) void m5();
@A(a=@A("splat")) void m6();
}
| 1,377 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotateMethodsFields/Main.java | /*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4904495 5008037
* @summary Test annotations of methods, fields, enum constants, and
* annotation type elements.
* Test an annotation type with a type nested within.
* @library ../../lib
* @compile ../../lib/Tester.java Main.java
* @run main Main
*/
import java.io.IOException;
import com.sun.javadoc.*;
public class Main extends Tester.Doclet {
private static final Tester tester = new Tester("Main", "pkg1");
public static void main(String[] args) throws IOException {
tester.run();
tester.verify();
}
public static boolean start(RootDoc root) {
try {
for (PackageDoc p : root.specifiedPackages()) {
for (AnnotationTypeDoc a : p.annotationTypes()) {
for (AnnotationTypeElementDoc e : a.elements()) {
tester.printAnnotationTypeElement(e);
}
tester.println();
}
for (ClassDoc e : p.enums()) {
for (FieldDoc ec : e.enumConstants()) {
tester.printField(ec);
}
tester.println();
}
for (ClassDoc cd : p.ordinaryClasses()) {
for (FieldDoc f : cd.fields()) {
tester.printField(f);
}
tester.println();
for (MethodDoc m : cd.methods()) {
tester.printMethod(m);
}
tester.println();
}
}
return true;
} catch (IOException e) {
return false;
}
}
}
| 2,785 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotateMethodsFields/pkg1/A.java | /*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public @interface A {
interface N {
}
@A("value")
String value();
}
| 1,158 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotateMethodsFields/pkg1/B.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public class B {
@A("f")
public int f;
@A("m1")
public void m1(int i) {
}
}
| 1,164 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
E.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/annotations/annotateMethodsFields/pkg1/E.java | /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
public enum E {
@A("econst")
econst
}
| 1,113 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6942366.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/6942366/T6942366.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 6942366
* @summary javadoc no longer inherits doc from sourcepath
* @build p.Base Test
* @run main T6942366
*/
import java.io.*;
import java.util.*;
public class T6942366 {
public static void main(String... args) throws Exception {
new T6942366().run();
}
File testSrc;
File testClasses;
int count;
int errors;
void run() throws Exception {
testSrc = new File(System.getProperty("test.src"));
testClasses = new File(System.getProperty("test.classes"));
test(true, false);
test(false, true);
test(true, true);
if (errors > 0)
throw new Exception(errors + " errors found");
}
void test(boolean useSourcePath, boolean useClassPath) throws Exception {
System.out.println("test " + (++count) + " sp:" + useSourcePath + " cp:" + useClassPath);
File testDir = new File("test" + count);
testDir.mkdirs();
List<String> args = new ArrayList<String>();
//args.add("-verbose");
args.add("-d");
args.add(testDir.getPath());
if (useSourcePath) {
args.add("-sourcepath");
args.add(testSrc.getPath());
}
if (useClassPath) {
args.add("-classpath");
args.add(testClasses.getPath());
} else {
// override classpath to avoid stuff jtreg might have put on papth
args.add("-classpath");
args.add(".");
}
// use a very simple bootclasspath to avoid stuff jtreg might have put on path
File javaHome = new File(System.getProperty("java.home"));
File rt_jar = new File(javaHome, "lib/rt.jar");
if (!rt_jar.exists())
throw new Exception("rt.jar not found");
args.add("-bootclasspath");
args.add(rt_jar.getPath());
args.add(new File(testSrc, "Test.java").getPath());
System.out.println("javadoc: " + args);
int rc = com.sun.tools.javadoc.Main.execute(args.toArray(new String[args.size()]));
if (rc != 0)
throw new Exception("unexpected exit from javadoc, rc=" + rc);
if (useSourcePath && useClassPath) {
long srcLastMod = new File(testSrc, "Test.java").lastModified();
long classLastMod = new File(testClasses, "Test.class").lastModified();
System.out.println("Test.java last modified: " + new Date(srcLastMod));
System.out.println("Test.class last modified: " + new Date(classLastMod));
System.out.println((srcLastMod > classLastMod ? "source" : "class") + " is newer");
}
String s = "javadoc-for-Base.m";
boolean expect = useSourcePath;
boolean found = contains(new File(testDir, "Test.html"), s);
if (found) {
if (expect)
System.out.println("javadoc content \"" + s + "\" found, as expected");
else
error("javadoc content \"" + s + "\" found unexpectedly");
} else {
if (expect)
error("javadoc content \"" + s + "\" not found");
else
System.out.println("javadoc content \"" + s + "\" not found, as expected");
}
System.out.println();
}
boolean contains(File f, String s) throws Exception {
byte[] buf = new byte[(int) f.length()];
try (DataInputStream in = new DataInputStream(new FileInputStream(f))) {
in.readFully(buf);
}
return new String(buf).contains(s);
}
void error(String msg) {
System.out.println("Error: " + msg);
errors++;
}
}
| 4,723 | 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/javadoc/6942366/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.
*/
public class Test extends p.Base {
// overrides Base.m
public void m() { }
}
| 1,138 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Base.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javadoc/6942366/p/Base.java | /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package p;
public class Base {
/** javadoc-for-Base.m. */
public void m() { }
}
| 1,142 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4459541.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4459541.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4459541
* @summary "javap -l" shows line numbers as signed short; they should be unsigned.
*/
import java.io.*;
public class T4459541 {
public static void main(String[] args) throws Exception {
new T4459541().run();
}
public void run() throws IOException {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
String output = javap(classFile);
verify(output);
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
println("class Test {");
println("void begin(int i) {");
println("i++;");
println("i++;");
println("}");
while (line < 32750)
println("// " + line);
println("void before_32767(int i) {");
println("i++;");
println("i++;");
println("}");
while (line < 32768-4)
println("// " + line);
println("void straddle_32768(int i) {");
while (line < 32768+4)
println("i++;");
println("}");
while (line < 65520)
println("// " + line);
println("void between_32768_and_65536(int i) {");
println("i++;");
println("i++;");
println("}");
while (line < 65536-4)
println("// " + line);
println("void straddle_65536(int i) {");
while (line < 65536+4)
println("i++;");
println("}");
println("}");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(File f) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { "-l", f.getPath() }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
void verify(String output) {
System.out.println(output);
if (output.indexOf("-") >= 0)
throw new Error("- found in output");
}
void println(String text) {
out.println(text);
line++;
}
PrintWriter out;
int line = 1;
}
| 3,603 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4777949.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4777949.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
import java.util.*;
import javax.tools.*;
import com.sun.tools.javap.*;
/*
* @test
* @bug 4777949
* @summary Warn javap usage on package with simple name
*/
public class T4777949 {
public static void main(String... args) throws Exception {
new T4777949().run();
}
void run() throws Exception {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
test(".", "p.q.r.Test", false);
test("p", "q.r.Test", true);
test("p/q", "r.Test", true);
test("p/q/r", "Test", true);
test(".", "p.q.r.Test.Inner", false);
test(".", "p.q.r.Test$Inner", false);
test("p", "q.r.Test.Inner", true);
test("p", "q.r.Test$Inner", true);
if (errors > 0)
throw new Exception(errors + " errors found");
}
void test(String classPath, String className, boolean expectWarnings) {
List<Diagnostic<? extends JavaFileObject>> diags =
javap(Arrays.asList("-classpath", classPath), Arrays.asList(className));
boolean foundWarnings = false;
for (Diagnostic<? extends JavaFileObject> d: diags) {
if (d.getKind() == Diagnostic.Kind.WARNING)
foundWarnings = true;
}
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("package p.q.r;");
out.println("class Test { class Inner { } }");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { "-d", ".", f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
List<Diagnostic<? extends JavaFileObject>> javap(List<String> args, List<String> classes) {
DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
JavaFileManager fm = JavapFileManager.create(dc, pw);
JavapTask t = new JavapTask(pw, fm, dc, args, classes);
boolean ok = t.run();
List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
if (!ok)
error("javap failed unexpectedly");
System.err.println("args=" + args + " classes=" + classes + "\n"
+ diags + "\n"
+ sw);
return diags;
}
void error(String msg) {
System.err.println("error: " + msg);
errors++;
}
int errors;
}
| 3,851 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6587786.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6587786.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6587786
* @summary Javap throws error : "ERROR:Could not find <classname>" for JRE classes
*/
import java.io.*;
public class T6587786 {
public static void main(String[] args) throws Exception {
new T6587786().run();
}
public void run() throws IOException {
javap("com.sun.javadoc.Doc", "com.sun.crypto.provider.ai");
javap("com.sun.crypto.provider.ai", "com.sun.javadoc.ClassDoc");
}
void javap(String... args) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
//sun.tools.javap.Main.entry(args);
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
System.out.println(sw.toString());
}
}
| 1,878 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6729471.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6729471.java | /*
* Copyright (c) 2009, 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 6729471
* @summary javap does not output inner interfaces of an interface
*/
import java.io.*;
import java.net.*;
import java.util.*;
public class T6729471
{
public static void main(String... args) {
new T6729471().run();
}
void run() {
File testClasses = new File(System.getProperty("test.classes"));
// simple class
verify("java.util.Map",
"public abstract boolean containsKey(java.lang.Object)");
// inner class
verify("java.util.Map.Entry",
"public abstract K getKey()");
// file name
verify(new File(testClasses, "T6729471.class").getPath(),
"public static void main(java.lang.String...)");
// file url
verify(new File(testClasses, "T6729471.class").toURI().toString(),
"public static void main(java.lang.String...)");
// jar url: rt.jar
File java_home = new File(System.getProperty("java.home"));
if (java_home.getName().equals("jre"))
java_home = java_home.getParentFile();
File rt_jar = new File(new File(new File(java_home, "jre"), "lib"), "rt.jar");
try {
verify("jar:" + rt_jar.toURL() + "!/java/util/Map.class",
"public abstract boolean containsKey(java.lang.Object)");
} catch (MalformedURLException e) {
error(e.toString());
}
// jar url: ct.sym, if it exists
File ct_sym = new File(new File(java_home, "lib"), "ct.sym");
if (ct_sym.exists()) {
try {
verify("jar:" + ct_sym.toURL() + "!/META-INF/sym/rt.jar/java/util/Map.class",
"public abstract boolean containsKey(java.lang.Object)");
} catch (MalformedURLException e) {
error(e.toString());
}
} else
System.err.println("warning: ct.sym not found");
if (errors > 0)
throw new Error(errors + " found.");
}
void verify(String className, String... expects) {
String output = javap(className);
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
String javap(String className) {
String testClasses = System.getProperty("test.classes", ".");
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
String[] args = { "-classpath", testClasses, className };
int rc = com.sun.tools.javap.Main.run(args, out);
out.close();
String output = sw.toString();
System.out.println("class " + className);
System.out.println(output);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
if (output.indexOf("Error:") != -1)
throw new Error("javap reported error.");
return output;
}
}
| 4,105 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6715767.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6715767.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6715767
* @summary javap on java.lang.ClassLoader crashes
*/
import java.io.*;
public class T6715767 {
public static void main(String... args) throws Exception {
new T6715767().run();
}
void run() throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String[] args = { "java.lang.ClassLoader" };
int rc = com.sun.tools.javap.Main.run(args, pw);
if (rc != 0 ||
sw.toString().indexOf("at com.sun.tools.javap.JavapTask.run") != -1) {
System.err.println("rc: " + rc);
System.err.println("log:\n" + sw);
throw new Exception("unexpected result");
}
}
}
| 1,786 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6622260.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6622260.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6622260
* @summary javap prints negative bytes incorrectly in hex
*/
import java.io.*;
public class T6622260 {
public static void main(String[] args) throws Exception {
new T6622260().run();
}
public void run() throws IOException {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
modifyClassFile(classFile);
String output = javap(classFile);
verify(output);
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("@Deprecated class Test { int f; void m() { } }");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
void modifyClassFile(File f) throws IOException {
String newAttributeName = "NonstandardAttribute";
byte[] newAttributeData = { 0, 1, 2, 127, (byte)128, (byte)129, (byte)254, (byte)255 };
DataInputStream in = new DataInputStream(new FileInputStream(f));
byte[] data = new byte[(int) f.length()];
in.readFully(data);
in.close();
in = new DataInputStream(new ByteArrayInputStream(data));
in.skipBytes(4); // magic
in.skipBytes(2); // minor
in.skipBytes(2); // minor
int constantPoolPos = data.length - in.available();
int constant_pool_count = skipConstantPool(in);
int flagsPos = data.length - in.available();
in.skipBytes(2); // access_flags
in.skipBytes(2); // this_class
in.skipBytes(2); // super_class
int interfaces_count = in.readUnsignedShort();
in.skipBytes(interfaces_count * 2);
int field_count = in.readUnsignedShort();
for (int i = 0; i < field_count; i++) {
in.skipBytes(6); // access_flags, name_index, descriptor_index
skipAttributes(in);
}
int method_count = in.readUnsignedShort();
for (int i = 0; i < method_count; i++) {
in.skipBytes(6); // access_flags, name_index, descriptor_index
skipAttributes(in);
}
int classAttributesPos = data.length - in.available();
int attributes_count = in.readUnsignedShort();
f.renameTo(new File(f.getPath() + ".BAK"));
DataOutputStream out = new DataOutputStream(new FileOutputStream(f));
// copy head
out.write(data, 0, constantPoolPos);
// copy constant pool, adding in name of new attribute
out.writeShort(constant_pool_count + 1);
out.write(data, constantPoolPos + 2, flagsPos - constantPoolPos - 2);
out.write(1); // CONSTANT_Utf8
out.writeUTF(newAttributeName);
// copy flags, class, superclass, interfaces, fields and methods
out.write(data, flagsPos, classAttributesPos - flagsPos);
// copy class attributes, adding in new attribute
out.writeShort(attributes_count + 1);
out.write(data, classAttributesPos + 2, data.length - classAttributesPos - 2);
out.writeShort(constant_pool_count); // index of new attribute name
out.writeInt(newAttributeData.length);
out.write(newAttributeData);
out.close();
}
int skipConstantPool(DataInputStream in) throws IOException {
int constant_pool_count = in.readUnsignedShort();
for (int i = 1; i < constant_pool_count; i++) {
int tag = in.readUnsignedByte();
switch (tag) {
case 1: // CONSTANT_Utf8
int length = in.readUnsignedShort();
in.skipBytes(length); // bytes
break;
case 3: // CONSTANT_Integer
case 4: // CONSTANT_Float
in.skipBytes(4); // bytes
break;
case 5: // CONSTANT_Long
case 6: // CONSTANT_Double
in.skipBytes(8); // high_bytes, low_bytes
break;
case 7: // CONSTANT_Class
in.skipBytes(2); // name_index
break;
case 8: // CONSTANT_String
in.skipBytes(2); // string_index
break;
case 9: // CONSTANT_FieldRef
case 10: // CONSTANT_Methodref
case 11: // CONSTANT_InterfaceMethodref
in.skipBytes(4); // class_index, name_and_type_index
break;
case 12: // CONSTANT_NameAndType
in.skipBytes(4); // name_index, descriptor_index
break;
default:
throw new Error("constant pool tag: " + tag);
}
}
return constant_pool_count;
}
int skipAttributes(DataInputStream in) throws IOException {
int attributes_count = in.readUnsignedShort();
for (int i = 0; i < attributes_count; i++) {
in.skipBytes(2); // attribute_name_index;
int length = in.readInt();
in.skipBytes(length); // info
}
return attributes_count;
}
String javap(File f) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
void verify(String output) {
System.out.println(output);
output = output.substring(output.indexOf("Test.java"));
if (output.indexOf("-") >= 0)
throw new Error("- found in output");
if (output.indexOf("FFFFFF") >= 0)
throw new Error("FFFFFF found in output");
}
}
| 7,095 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6622232.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6622232.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6622232
* @summary javap gets whitespace confused
*/
import java.io.*;
public class T6622232 {
public static void main(String[] args) throws Exception {
new T6622232().run();
}
public void run() throws IOException {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
String output = javap(classFile);
// these are all examples of bad whitespace from old javap
verifyNot(output,
"\\Q Constant value: int 3Deprecated: true\\E",
"^Deprecated: true",
"\\Q throws java.lang.Exception, java.lang.Error Deprecated: true\\E"
);
if (errors > 0)
throw new Error(errors + " found.");
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("class Test { ");
out.println(" @Deprecated static final int f1 = 3;");
out.println(" @Deprecated int f2;");
out.println(" @Deprecated void m() throws Exception, Error { }");
out.println("}");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(File f) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
System.out.println(sw.toString());
return sw.toString();
}
void verifyNot(String output, String... unexpects) {
for (String unexpect: unexpects) {
if (output.matches(unexpect))
error(unexpect + " unexpectedly found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 3,332 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4075403.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4075403.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4075403
* @summary Use javap to inquire about a specific inner class
*/
import java.io.*;
public class T4075403 {
public static void main(String[] args) throws Exception {
new T4075403().run();
}
public void run() throws IOException {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
javap("Outer.Inner");
}
File writeTestFile() throws IOException {
File f = new File("Outer.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("class Outer { ");
out.println(" class Inner { }");
out.println("}");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(String className) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { "-classpath", ".", className }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
System.out.println(sw.toString());
return sw.toString();
}
}
| 2,515 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6474890.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6474890.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6474890
* @summary javap does not open .zip files in -classpath
*/
import java.io.*;
import java.util.zip.*;
public class T6474890 {
public static void main(String[] args) throws Exception {
new T6474890().run();
}
public void run() throws IOException {
File classDir = new File("classes");
classDir.mkdir();
String className = "Test";
File javaFile = writeTestFile(className);
compileTestFile(classDir, javaFile);
File zipFile = zip(classDir, new File(classDir + ".zip"));
javap("-classpath", zipFile.getPath(), className);
File jarFile = zip(classDir, new File(classDir + ".jar"));
javap("-classpath", zipFile.getPath(), className);
}
File writeTestFile(String name) throws IOException {
File f = new File(name + ".java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("class " + name + " { }");
out.close();
return f;
}
void compileTestFile(File classDir, File file) {
int rc = com.sun.tools.javac.Main.compile(
new String[] { "-d", classDir.getPath(), file.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
}
File zip(File dir, File zipFile) throws IOException {
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
for (File file: dir.listFiles()) {
if (file.isFile()) {
byte[] data = new byte[(int) file.length()];
DataInputStream in = new DataInputStream(new FileInputStream(file));
in.readFully(data);
in.close();
zipOut.putNextEntry(new ZipEntry(file.getName()));
zipOut.write(data, 0, data.length);
zipOut.closeEntry();
}
}
zipOut.close();
return zipFile;
}
String javap(String... args) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
//sun.tools.javap.Main.entry(args);
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
}
| 3,382 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4501660.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4501660.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4501660
* @summary change diagnostic of -help as 'print this help message and exit'
* (actually, verify -help does not cause premature exit)
*/
import java.io.*;
import java.util.zip.*;
public class T4501660 {
public static void main(String[] args) throws Exception {
new T4501660().run();
}
public void run() throws IOException {
String testClasses = System.getProperty("test.classes", ".");
String output = javap("-classpath", testClasses, "-help", "T4501660");
verify(output,
"-public", "-protected", "-private", // check -help output is present
"class T4501660" // check class output is present
);
if (errors > 0)
throw new Error(errors + " found.");
}
String javap(String... args) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
//sun.tools.javap.Main.entry(args);
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
System.out.println(sw);
return sw.toString();
}
void verify(String output, String... expects) {
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 2,579 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6715251.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6715251.java | /*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
import java.util.*;
/*
* @test
* @bug 6715251
* @summary javap should be consistent with javac and return 2 if given no arguments
*/
public class T6715251 {
public static void main(String... args) throws Exception {
new T6715251().run();
}
void run() throws Exception {
String testClasses = System.getProperty("test.classes", ".");
test(2);
test(0, "-help");
test(0, "-version");
test(0, "-fullversion");
test(0, "-classpath", testClasses, "T6715251");
if (errors > 0)
throw new Exception(errors + " errors received");
}
void test(int expect, String ... args) {
int rc = javap(args);
if (rc != expect)
error("bad result: expected: " + expect + ", found " + rc + "\n"
+ log);
}
int javap(String... args) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args, pw);
log = sw.toString();
return rc;
}
void error(String msg) {
System.err.println(msg);
errors++;
}
String log;
int errors;
}
| 2,268 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestSuperclass.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/TestSuperclass.java | /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7031005
* @summary javap prints "extends java.lang.Object"
*/
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URI;
import java.util.Arrays;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
public class TestSuperclass {
enum ClassKind {
CLASS("class"),
INTERFACE("interface");
ClassKind(String keyword) {
this.keyword = keyword;
}
final String keyword;
}
enum GenericKind {
NO(""),
YES("<T>");
GenericKind(String typarams) {
this.typarams = typarams;
}
final String typarams;
}
enum SuperKind {
NONE(null),
SUPER("Super");
SuperKind(String name) {
this.name = name;
}
String extend() {
return (name == null) ? "" : "extends " + name;
}
String decl(ClassKind ck) {
return (name == null) ? "" : ck.keyword + " " + name + " { }";
}
final String name;
}
public static void main(String... args) throws Exception {
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
int errors = 0;
for (ClassKind ck: ClassKind.values()) {
for (GenericKind gk: GenericKind.values()) {
for (SuperKind sk: SuperKind.values()) {
errors += new TestSuperclass(ck, gk, sk).run(comp, fm);
}
}
}
if (errors > 0)
throw new Exception(errors + " errors found");
}
final ClassKind ck;
final GenericKind gk;
final SuperKind sk;
TestSuperclass(ClassKind ck, GenericKind gk, SuperKind sk) {
this.ck = ck;
this.gk = gk;
this.sk = sk;
}
int run(JavaCompiler comp, StandardJavaFileManager fm) throws IOException {
System.err.println("test: ck:" + ck + " gk:" + gk + " sk:" + sk);
File testDir = new File(ck + "-" + gk + "-" + sk);
testDir.mkdirs();
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(testDir));
JavaSource js = new JavaSource();
System.err.println(js.getCharContent(false));
CompilationTask t = comp.getTask(null, fm, null, null, null, Arrays.asList(js));
if (!t.call())
throw new Error("compilation failed");
File testClass = new File(testDir, "Test.class");
String out = javap(testClass);
// Extract class sig from first line of Java source
String expect = js.source.replaceAll("(?s)^(.* Test[^{]+?) *\\{.*", "$1");
// Extract class sig from line from javap output
String found = out.replaceAll("(?s).*\n(.* Test[^{]+?) *\\{.*", "$1");
checkEqual("class signature", expect, found);
return errors;
}
String javap(File file) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String[] args = { file.getPath() };
int rc = com.sun.tools.javap.Main.run(args, pw);
pw.close();
String out = sw.toString();
if (!out.isEmpty())
System.err.println(out);
if (rc != 0)
throw new Error("javap failed: rc=" + rc);
return out;
}
void checkEqual(String label, String expect, String found) {
if (!expect.equals(found))
error("Unexpected " + label + " found: '" + found + "', expected: '" + expect + "'");
}
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
int errors;
class JavaSource extends SimpleJavaFileObject {
static final String template =
"#CK Test#GK #EK { }\n"
+ "#SK\n";
final String source;
public JavaSource() {
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
source = template
.replace("#CK", ck.keyword)
.replace("#GK", gk.typarams)
.replace("#EK", sk.extend())
.replace("#SK", sk.decl(ck));
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return source;
}
}
}
| 5,669 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6824493.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6824493.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.*;
import java.util.*;
/*
* @test
* @bug 6824493
* @summary experimental support for additional info for instructions
* @compile -g T6824493.java
* @run main T6824493
*/
public class T6824493 {
public static void main(String... args) {
new T6824493().run();
}
void run() {
// for each of the options, we run javap and check for some
// marker strings in the output that generally indicate the
// presence of the expected output, without being as specific
// as a full golden file test.
test("-XDdetails:source",
"for (int i = 0; i < 10; i++) {",
"System.out.println(s + i);");
test("-XDdetails:tryBlocks",
"try[0]",
"end try[0]",
"catch[0]");
test("-XDdetails:stackMaps",
"StackMap locals: this java/lang/String int",
"StackMap stack: java/lang/Throwable");
test("-XDdetails:localVariables",
"start local 3 // java.util.List list",
"end local 3 // java.util.List list");
test("-XDdetails:localVariableTypes",
"start generic local 3 // java.util.List<java.lang.String> list",
"end generic local 3 // java.util.List<java.lang.String> list");
if (errors > 0)
throw new Error(errors + " errors found");
}
void test(String option, String... expect) {
String[] args = {
"-c",
"-classpath",
testSrc + File.pathSeparator + testClasses,
option,
"Test"
};
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args, pw);
if (rc != 0) {
error("unexpected return code from javap: " + rc);
return;
}
String out = sw.toString();
System.out.println(out);
for (String e: expect) {
if (!out.contains(e))
error("Not found: " + e);
}
}
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
private int errors;
private String testSrc = System.getProperty("test.src", ".");
private String testClasses = System.getProperty("test.classes", ".");
}
class Test {
void m(String s) {
for (int i = 0; i < 10; i++) {
try {
List<String> list = null;
System.out.println(s + i);
} catch (NullPointerException e) {
System.out.println("catch NPE");
} finally {
System.out.println("finally");
}
}
}
}
| 3,797 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T7004698.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T7004698.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 7004698
* @summary javap does not output CharacterRangeTable attributes correctly
*/
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class T7004698 {
public static void main(String... args) throws Exception {
new T7004698().run();
}
void run() throws Exception {
File srcDir = new File(System.getProperty("test.src"));
File srcFile = new File(srcDir, T7004698.class.getSimpleName() + ".java");
File classesDir = new File(".");
compile("-Xjcov", "-d", classesDir.getPath(), srcFile.getPath());
File classFile = new File(classesDir, T7004698.class.getSimpleName() + ".class");
String out = javap("-v", classFile.getPath());
Pattern attrBody = Pattern.compile("[0-9a-f, ]+//[-0-9a-z:, ]+");
Pattern endOfAttr = Pattern.compile("(^$|[A-Z][A-Za-z0-9_]+:.*|})");
boolean inAttr = false;
int count = 0;
int errors = 0;
for (String line: out.split(System.getProperty("line.separator"))) {
line = line.trim();
if (line.equals("CharacterRangeTable:")) {
inAttr = true;
count++;
} else if (inAttr) {
if (endOfAttr.matcher(line).matches()) {
inAttr = false;
} else if (!attrBody.matcher(line).matches()) {
System.err.println("unexpected line found: " + line);
errors++;
}
}
}
if (count == 0)
throw new Exception("no attribute instances found");
if (errors > 0)
throw new Exception(errors + " errors found");
}
void compile(String... args) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javac.Main.compile(args, pw);
pw.close();
String out = sw.toString();
if (!out.isEmpty())
System.err.println(out);
if (rc != 0)
throw new Exception("javac failed unexpectedly; rc=" + rc);
}
String javap(String... args) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args, pw);
pw.close();
String out = sw.toString();
if (!out.isEmpty())
System.err.println(out);
if (rc != 0)
throw new Exception("javap failed unexpectedly; rc=" + rc);
return out;
}
}
| 3,627 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6868539.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6868539.java | /*
* Copyright (c) 2009, 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 6868539 6868548
* @summary javap should use current names for constant pool entries,
* remove spurious ';' from constant pool entries
*/
import java.io.*;
import java.util.*;
public class T6868539
{
public static void main(String... args) {
new T6868539().run();
}
void run() {
String output = javap("T6868539");
verify(output, "Utf8 +java/lang/String"); // 1: Utf8
// 2: currently unused
verify(output, "Integer +123456"); // 3: Integer
verify(output, "Float +123456.0f"); // 4: Float
verify(output, "Long +123456l"); // 5: Long
verify(output, "Double +123456.0d"); // 6: Double
verify(output, "Class +#[0-9]+ +// + T6868539"); // 7: Class
verify(output, "String +#[0-9]+ +// + not found"); // 8: String
verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref
verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref
verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
// 11: InterfaceMethodref
verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType
if (errors > 0)
throw new Error(errors + " found.");
}
void verify(String output, String... expects) {
for (String expect: expects) {
if (!output.matches("(?s).*" + expect + ".*"))
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
String javap(String className) {
String testClasses = System.getProperty("test.classes", ".");
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
String[] args = { "-v", "-classpath", testClasses, className };
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
String output = sw.toString();
System.out.println("class " + className);
System.out.println(output);
return output;
}
int i = 123456;
float f = 123456.f;
double d = 123456.;
long l = 123456L;
void m(Runnable r) { r.run(); }
}
| 3,853 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6716452.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6716452.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test 6716452
* @summary need a method to get an index of an attribute
*/
import java.io.*;
import com.sun.tools.classfile.*;
public class T6716452 {
public static void main(String[] args) throws Exception {
new T6716452().run();
}
public void run() throws Exception {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
ClassFile cf = ClassFile.read(classFile);
for (Method m: cf.methods) {
test(cf, m);
}
if (errors > 0)
throw new Exception(errors + " errors found");
}
void test(ClassFile cf, Method m) {
test(cf, m, Attribute.Code, Code_attribute.class);
test(cf, m, Attribute.Exceptions, Exceptions_attribute.class);
}
// test the result of Attributes.getIndex according to expectations
// encoded in the method's name
void test(ClassFile cf, Method m, String name, Class<?> c) {
int index = m.attributes.getIndex(cf.constant_pool, name);
try {
String m_name = m.getName(cf.constant_pool);
System.err.println("Method " + m_name + " name:" + name + " index:" + index + " class: " + c);
boolean expect = (m_name.equals("<init>") && name.equals("Code"))
|| (m_name.indexOf(name) != -1);
boolean found = (index != -1);
if (expect) {
if (found) {
Attribute attr = m.attributes.get(index);
if (!c.isAssignableFrom(attr.getClass())) {
error(m + ": unexpected attribute found,"
+ " expected " + c.getName()
+ " found " + attr.getClass().getName());
}
} else {
error(m + ": expected attribute " + name + " not found");
}
} else {
if (found) {
error(m + ": unexpected attribute " + name);
}
}
} catch (ConstantPoolException e) {
error(m + ": " + e);
}
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("abstract class Test { ");
out.println(" abstract void m();");
out.println(" void m_Code() { }");
out.println(" abstract void m_Exceptions() throws Exception;");
out.println(" void m_Code_Exceptions() throws Exception { }");
out.println("}");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
void error(String msg) {
System.err.println("error: " + msg);
errors++;
}
int errors;
}
| 4,144 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4880663.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4880663.java | /*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4880663 6715757 7031005
* @summary javap could output whitespace between class name and opening brace
* javap prints "extends java.lang.Object"
*/
import java.io.*;
public class T4880663 {
public static void main(String[] args) throws Exception {
new T4880663().run();
}
public void run() throws IOException {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
verify(classFile, "class Test {");
if (errors > 0)
throw new Error(errors + " found.");
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("class Test { }");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(File classFile) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { classFile.getPath() }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
System.out.println(sw.toString());
return sw.toString();
}
void verify(File classFile, String... expects) {
String output = javap(classFile);
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 2,954 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4884240.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4884240.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 4884240
* @summary additional option required for javap
*/
import java.io.*;
public class T4884240 {
public static void main(String... args) throws Exception {
new T4884240().run();
}
public void run() throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String[] args = { "-sysinfo", "java.lang.Object" };
int rc = com.sun.tools.javap.Main.run(args, pw);
if (rc != 0)
throw new Exception("unexpected return code: " + rc);
pw.close();
String[] lines = sw.toString().split("\n");
if (lines.length < 3
|| !lines[0].trim().startsWith("Classfile")
|| !lines[1].trim().startsWith("Last modified")
|| !lines[2].trim().startsWith("MD5")) {
System.out.println(sw);
throw new Exception("unexpected output");
}
}
}
| 2,148 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4880672.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4880672.java | /*
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4880672 7031005
* @summary javap does not output inner interfaces of an interface
*/
import java.io.*;
import java.util.*;
public class T4880672
{
public static void main(String... args) {
new T4880672().run();
}
void run() {
verify("java.util.Map", "public interface java.util.Map$Entry");
verify("T4880672", "class T4880672$A$B");
verify("C", ""); // must not give error if no InnerClasses attribute
if (errors > 0)
throw new Error(errors + " found.");
}
void verify(String className, String... expects) {
String output = javap(className);
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
String javap(String className) {
String testClasses = System.getProperty("test.classes", ".");
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
String[] args = { "-XDinner", "-classpath", testClasses, className };
int rc = com.sun.tools.javap.Main.run(args, out);
out.close();
String output = sw.toString();
System.out.println("class " + className);
System.out.println(output);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
if (output.indexOf("Error:") != -1)
throw new Error("javap reported error.");
return output;
}
class A {
class B { }
}
}
class C { }
| 2,698 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6980017.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6980017.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 6980017
* @summary javap -XDdetail:source behaves badly if source not available.
*/
import java.io.*;
public class T6980017 {
public static void main(String... args) throws Exception {
new T6980017().run();
}
void run() throws Exception {
String[] args = {
"-v",
"-XDdetails:source",
"java.lang.Object"
};
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args, pw);
pw.close();
if (rc != 0)
error("Unexpected exit code: " + rc);
boolean foundBlankSourceLine = false;
boolean foundNoSourceLine = false;
for (String line: sw.toString().split("[\r\n]+")) {
System.err.println(line);
if (line.contains("Source code not available"))
foundNoSourceLine = true;
if (line.matches("\\s*\\( *[0-9]+\\)\\s*"))
foundBlankSourceLine = true;
}
if (foundBlankSourceLine)
error("found blank source lines");
if (!foundNoSourceLine)
error("did not find \"Source code not available\" message");
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 2,485 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExtPath.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/ExtPath.java | /*
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6428896
* @summary javap cannot read multiple entries on the extension classpath
* @author Wei Tao
* @run main/othervm ExtPath com.sun.crypto.provider.SunJCE
*/
import com.sun.tools.javap.Main;
import java.io.*;
public class ExtPath {
public static void main(String[] args) {
PrintWriter pw = new PrintWriter(System.out, true);
Main.run(args, pw);
}
}
| 1,467 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6715753.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6715753.java | /*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
/*
* @test
* @bug 6715753
* @summary Use javap to inquire about a specific inner class
*/
public class T6715753 {
public static void main(String... args) throws Exception {
new T6715753().run();
}
void run() throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String[] args = { "-notAnOption" };
int rc = com.sun.tools.javap.Main.run(args, pw);
String log = sw.toString();
if (rc == 0
|| log.indexOf("-notAnOption") == -1
|| log.indexOf("javap") == -1) { // locale-independent indication of usage message
System.err.println("rc: " + rc + ", log=\n" + log);
throw new Exception("test failed");
}
}
}
| 1,853 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4975569.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4975569.java | /*
* Copyright (c) 2008, 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.
*/
/*
* @test
* @bug 4975569 6622215
* @summary javap doesn't print new flag bits
*/
import java.io.*;
import java.util.*;
public class T4975569
{
public static void main(String... args) {
new T4975569().run();
}
void run() {
verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION");
verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM");
verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC",
"InnerClasses:\n static");
verify("T4975569$V", "void m(java.lang.String...)",
"flags: ACC_VARARGS");
verify("T4975569$Prot", "InnerClasses:\n protected");
//verify("T4975569$Priv", "InnerClasses");
if (errors > 0)
throw new Error(errors + " found.");
}
void verify(String className, String... expects) {
String output = javap(className);
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
String javap(String className) {
String newline = System.getProperty("line.separator");
String testClasses = System.getProperty("test.classes", ".");
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
String[] args = { "-v", "-classpath", testClasses, className };
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
String output = sw.toString().replaceAll(newline, "\n");
System.out.println("class " + className);
System.out.println(output);
return output;
}
List x() { return null; };
class V { void m(String... args) { } }
enum E { e; }
@interface Anno { }
static class S extends T4975569 {
ArrayList x() { return null; }
}
protected class Prot { }
//private class Priv { int i; }
}
| 3,205 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6622216.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6622216.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6622216
* @summary javap names some attributes incorrectly
*/
import java.io.*;
public class T6622216 {
public static void main(String[] args) throws Exception {
new T6622216().run();
}
public void run() throws IOException {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
String output = javap(classFile);
verify(output);
}
File writeTestFile() throws IOException {
File f = new File("Outer.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("class Outer {");
out.println(" class Inner { }");
out.println("}");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(File f) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
void verify(String output) {
System.out.println(output);
if (output.indexOf("InnerClasses") == -1)
throw new Error("InnerClasses not found in output");
}
}
| 2,659 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4876942.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4876942.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4876942 6715251
* @summary javap invoked without args does not print help screen
*/
import java.io.*;
import java.util.zip.*;
public class T4876942 {
public static void main(String[] args) throws Exception {
new T4876942().run();
}
public void run() throws IOException {
String output = javap();
verify(output, "-public", "-protected", "-private"); // check that some of the options are listed
if (errors > 0)
throw new Error(errors + " found.");
}
String javap(String... args) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
//sun.tools.javap.Main.entry(args);
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != (args.length == 0 ? 2 : 0))
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
void verify(String output, String... expects) {
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 2,279 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4501661.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T4501661.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
import java.util.*;
/*
* @test
* @bug 4501661
* @summary disallow mixing -public, -private, and -protected
*/
public class T4501661 {
public static void main(String... args) throws Exception {
new T4501661().run();
}
void run() throws Exception {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
boolean[] values = { false, true };
for (boolean priv: values) {
for (boolean prot: values) {
for (boolean publ: values) {
test(priv, prot, publ, classFile);
}
}
}
if (errors > 0)
throw new Exception(errors + " errors found");
}
void test(boolean priv, boolean prot, boolean publ, File classFile) {
List<String> args = new ArrayList<String>();
if (priv)
args.add("-private");
if (prot)
args.add("-protected");
if (publ)
args.add("-public");
boolean expectOK = (args.size() <= 1);
args.add(classFile.getPath());
String out = javap(args, expectOK);
if (out == null)
return;
if (!priv && !prot && !publ)
checkNone(out, "private");
if (prot)
checkNone(out, "private", "package");
if (publ)
checkNone(out, "private", "package", "protected");
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("abstract class Test { ");
out.println(" public void public_m() { }");
out.println(" protected void protected_m() { }");
out.println(" private void private_m() { }");
out.println(" void package_m() { }");
out.println("}");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(List<String> args, boolean expectOK) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
System.err.println(args);
System.err.println(sw);
if (expectOK) {
if (rc == 0)
return sw.toString();
else
error("javap failed unexpectedly; rc=" + rc + "\n" + sw);
} else {
if (rc == 0)
error("javap succeeded unexpectedly");
}
return null;
}
void checkNone(String log, String... words) {
for (String word: words) {
if (log.indexOf(word) != -1)
error("\"" + word + "\" unexpectedly found in output");
}
}
void error(String msg) {
System.err.println("error: " + msg);
errors++;
}
int errors;
}
| 4,252 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6879371.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6879371.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.
*/
/*
* @test
* @bug 6879371
* @summary javap does not close internal default file manager
*/
import java.io.*;
import java.util.zip.*;
public class T6879371 {
public static void main(String[] args) throws Exception {
new T6879371().run();
}
public void run() throws Exception {
// create a simple test class which we can put into
// a test zip file and know that it will be used by
// javap.
File classDir = new File("classes");
classDir.mkdir();
String className = "Test";
File javaFile = writeTestFile(className);
compileTestFile(classDir, javaFile);
test(classDir, className, false);
test(classDir, className, true);
}
void test(File classDir, String className, boolean useJavaUtilZip) throws Exception {
// javac should really not be using system properties like this
// -- it should really be using (hidden) options -- but until then
// take care to leave system properties as we find them, so as not
// to adversely affect other tests that might follow.
String prev = System.getProperty("useJavaUtilZip");
setProperty("useJavaUtilZip", (useJavaUtilZip ? "true" : null));
try {
File zipFile = zip(classDir, new File(classDir + ".zip"));
javap("-classpath", zipFile.getPath(), className);
if (!zipFile.delete())
throw new Exception("failed to delete " + zipFile);
} finally {
setProperty("useJavaUtilZip", prev);
}
}
File writeTestFile(String name) throws IOException {
File f = new File(name + ".java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("class " + name + " { }");
out.close();
return f;
}
void compileTestFile(File classDir, File file) {
int rc = com.sun.tools.javac.Main.compile(
new String[] { "-d", classDir.getPath(), file.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
}
File zip(File dir, File zipFile) throws IOException {
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
for (File file: dir.listFiles()) {
if (file.isFile()) {
byte[] data = new byte[(int) file.length()];
DataInputStream in = new DataInputStream(new FileInputStream(file));
in.readFully(data);
in.close();
zipOut.putNextEntry(new ZipEntry(file.getName()));
zipOut.write(data, 0, data.length);
zipOut.closeEntry();
}
}
zipOut.close();
return zipFile;
}
String javap(String... args) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
void setProperty(String key, String value) {
if (value != null)
System.setProperty(key, value);
else
System.getProperties().remove(key);
}
}
| 4,343 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6866657.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6866657.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.
*/
/*
* @test
* @bug 6866657
* @summary add byteLength() method to primary classfile types
*/
import java.io.*;
import java.util.*;
import javax.tools.*;
import com.sun.tools.javap.*;
public class T6866657
{
public static void main(String... args) {
new T6866657().run();
}
void run() {
verify("java.lang.Object");
verify("java.lang.String");
verify("java.util.List");
verify("java.util.ArrayList");
if (errors > 0)
throw new Error(errors + " found.");
}
void verify(String className) {
try {
PrintWriter log = new PrintWriter(System.out);
JavaFileManager fileManager = JavapFileManager.create(null, log);
JavaFileObject fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
if (fo == null) {
error("Can't find " + className);
} else {
JavapTask t = new JavapTask(log, fileManager, null);
t.handleOptions(new String[] { "-sysinfo", className });
JavapTask.ClassFileInfo cfInfo = t.read(fo);
expectEqual(cfInfo.cf.byteLength(), cfInfo.size);
}
} catch (Exception e) {
e.printStackTrace();
error("Exception: " + e);
}
}
void expectEqual(int found, int expected) {
if (found != expected)
error("bad value found: " + found + " expected: " + expected);
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 2,688 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6271787.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6271787.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6271787
* @summary javap dumps LocalVariableTypeTable attribute in hex, needs to print a table
*/
import java.io.*;
public class T6271787 {
public static void main(String[] args) throws Exception {
new T6271787().run();
}
public void run() throws IOException {
File javaFile = writeTestFile();
File classFile = compileTestFile(javaFile);
verify(classFile,
"LocalVariableTypeTable:",
"0 5 0 this LTest<TT;>;" // should consider decoding this in javap
);
if (errors > 0)
throw new Error(errors + " found.");
}
File writeTestFile() throws IOException {
File f = new File("Test.java");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
out.println("class Test<T> { }");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(File f) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
void verify(File classFile, String... expects) {
String output = javap(classFile);
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 2,977 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NotPackagePrivateInterface.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/NotPackagePrivateInterface.java | /*
* Copyright (c) 2003, 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.
*/
/*
* This class is used by PublicInterfaceTest.sh to generate a class
* file with a public interface to verify javap will output the
* "public" modifier for such interfaces. (At the vm level, the only
* access control properties an interface can can have are public and
* package private.)
*/
public interface NotPackagePrivateInterface {
}
| 1,408 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6863746.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/T6863746.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.*;
/*
* @test
* @bug 6863746
* @summary javap should not scan ct.sym by default
*/
public class T6863746 {
public static void main(String... args) throws Exception{
new T6863746().run();
}
public void run() throws Exception {
String[] args = { "-c", "java.lang.Object" };
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args, pw);
pw.close();
String out = sw.toString();
System.out.println(out);
String[] lines = out.split("\n");
// If ct.sym is being read, the output does not include
// Code attributes, so check for Code attributes as a
// way of detecting that ct.sym is not being used.
if (lines.length < 50 || out.indexOf("Code:") == -1)
throw new Exception("unexpected output from javap");
}
}
| 1,973 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6271292.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/stackmap/T6271292.java | /*
* Copyright (c) 2005, 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 T6271292 extends SuperClass {
public static void main(String[] args) {
SuperClass s = new SuperClass((args[0].equals("0")) ? 0 : 1);
s.test();
}
T6271292(boolean b) {
super(b ? 1 : 2);
}
}
class SuperClass {
double d;
SuperClass(double dd) { d = dd; }
double test() {
if (d == 0) {
return d;
} else if (d > 0) {
return d++;
} else {
return d--;
}
}
}
| 1,550 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4870651.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/4870651/T4870651.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4870651 6715757
* @summary javap should recognize generics, varargs, enum;
* javap prints "extends java.lang.Object"
* @build T4870651 Test
* @run main T4870651
*/
import java.io.*;
public class T4870651 {
public static void main(String[] args) throws Exception {
new T4870651().run();
}
public void run() throws IOException {
verify("Test",
"class Test<T extends java.lang.Object, " +
"E extends java.lang.Exception & java.lang.Comparable<T>, " +
"U extends java.lang.Comparable>",
"v1(java.lang.String...)");
verify("Test$Enum",
"flags: ACC_FINAL, ACC_SUPER, ACC_ENUM",
"flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_ENUM");
if (errors > 0)
throw new Error(errors + " found.");
}
String javap(String className) {
String testClasses = System.getProperty("test.classes", ".");
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
String[] args = { "-classpath", testClasses, "-v", className };
int rc = com.sun.tools.javap.Main.run(args, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
String output = sw.toString();
System.out.println("class " + className);
System.out.println(output);
return output;
}
void verify(String className, String... expects) {
String output = javap(className);
for (String expect: expects) {
if (output.indexOf(expect)< 0)
error(expect + " not found");
}
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
| 2,861 | 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/javap/4870651/Test.java | /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.*;
abstract class Test<T,E extends Exception & Comparable<T>,U extends Comparable> {
T t;
Test(T t) { }
<G> Test(G g, int i) { }
Test(String... args) { }
Test(int i, Object[]... args) { }
abstract void v1(String... args);
abstract void v2(int i, String[]... args);
abstract void a1(int x);
abstract void a2(int[] x);
abstract void a3(T x);
abstract void a4(T[] x);
abstract int r1();
abstract int[] r2();
abstract T r3();
abstract T[] r4();
abstract <G> void ga1(int x);
abstract <G> void ga2(int[] x);
abstract <G> void ga3(G x);
abstract <G> void ga4(G[] x);
abstract <G> int gr1();
abstract <G> int[] gr2();
abstract <G> G gr3();
abstract <G> G[] gr4();
abstract <G extends Exception> void ge() throws G;
abstract void w(List<?> l);
abstract void we(List<? extends T> l);
abstract void ws(List<? super T> l);
abstract void t1() throws Error;
abstract void t2() throws E;
abstract void t3() throws E,Error;
abstract void i1(Test<T, E, Comparable> x);
abstract void i3(Test<T, E, Comparable>.Inner<String> x);
class Inner<Q> { }
class Inner2<Q> extends Inner<Q> { }
class Simple { }
enum Enum { e1, e2, e3 }
}
| 2,338 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6887895.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/classfile/T6887895.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.
*/
/*
* @test
* @bug 6887895
* @summary CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
*/
import java.io.*;
import java.net.*;
import java.util.*;
import com.sun.tools.classfile.*;
import com.sun.tools.classfile.ConstantPool.*;
public class T6887895 {
public static void main(String[] args) throws Exception {
new T6887895().run();
}
void run() throws Exception {
Set<String> found = new TreeSet<String>();
ClassFile cf = getClassFile("T6887895$Test.class");
for (CPInfo cpInfo: cf.constant_pool.entries()) {
if (cpInfo instanceof CONSTANT_Class_info) {
CONSTANT_Class_info info = (CONSTANT_Class_info) cpInfo;
String name = info.getName();
String baseName = info.getBaseName();
System.out.println("found: " + name + " " + baseName);
if (baseName != null)
found.add(baseName);
}
}
String[] expectNames = {
"java/lang/Object",
"java/lang/String",
"T6887895",
"T6887895$Test"
};
Set<String> expect = new TreeSet<String>(Arrays.asList(expectNames));
if (!found.equals(expect)) {
System.err.println("found: " + found);
System.err.println("expect: " + expect);
throw new Exception("unexpected values found");
}
}
ClassFile getClassFile(String name) throws IOException, ConstantPoolException {
URL url = getClass().getResource(name);
InputStream in = url.openStream();
try {
return ClassFile.read(in);
} finally {
in.close();
}
}
class Test {
void m() {
boolean[] az = new boolean[0];
boolean[][] aaz = new boolean[0][];
boolean[][][] aaaz = new boolean[0][][];
byte[] ab = new byte[0];
byte[][] aab = new byte[0][];
byte[][][] aaab = new byte[0][][];
char[] ac = new char[0];
char[][] aac = new char[0][];
char[][][] aaac = new char[0][][];
double[] ad = new double[0];
double[][] aad = new double[0][];
double[][][] aaad = new double[0][][];
float[] af = new float[0];
float[][] aaf = new float[0][];
float[][][] aaaf = new float[0][][];
int[] ai = new int[0];
int[][] aai = new int[0][];
int[][][] aaai = new int[0][][];
long[] al = new long[0];
long[][] aal = new long[0][];
long[][][] aaal = new long[0][][];
short[] as = new short[0];
short[][] aas = new short[0][];
short[][][] aaas = new short[0][][];
String[] aS = new String[0];
String[][] aaS = new String[0][];
String[][][] aaaS = new String[0][][];
}
}
}
| 4,038 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
GetDeps.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/classfile/deps/GetDeps.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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
import java.util.*;
import java.util.regex.Pattern;
import javax.tools.*;
import com.sun.tools.classfile.*;
import com.sun.tools.classfile.Dependencies.*;
import com.sun.tools.classfile.Dependency.Location;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.Context;
/**
* Demo utility for using the classfile dependency analysis API framework.
*
* Usage:
* getdeps [options] classes
* where options include:
* -classpath path where to find classes to analyze
* -p package-name restrict analysis to classes in this package
* (may be given multiple times)
* -r regex restrict analysis to packages matching pattern
* (-p and -r are exclusive)
* -rev invert the dependencies in the output
* -t transitive closure of dependencies
*/
public class GetDeps {
public static void main(String... args) throws Exception {
new GetDeps().run(args);
}
void run(String... args) throws IOException, ClassFileNotFoundException {
PrintWriter pw = new PrintWriter(System.out);
try {
run(pw, args);
} finally {
pw.flush();
}
}
void run(PrintWriter out, String... args) throws IOException, ClassFileNotFoundException {
decodeArgs(args);
final StandardJavaFileManager fm = new JavacFileManager(new Context(), false, null);
if (classpath != null)
fm.setLocation(StandardLocation.CLASS_PATH, classpath);
ClassFileReader reader = new ClassFileReader(fm);
Dependencies d = new Dependencies();
if (regex != null)
d.setFilter(Dependencies.getRegexFilter(Pattern.compile(regex)));
if (packageNames.size() > 0)
d.setFilter(Dependencies.getPackageFilter(packageNames, false));
SortedRecorder r = new SortedRecorder(reverse);
d.findAllDependencies(reader, rootClassNames, transitiveClosure, r);
SortedMap<Location,SortedSet<Dependency>> deps = r.getMap();
for (Map.Entry<Location, SortedSet<Dependency>> e: deps.entrySet()) {
out.println(e.getKey());
for (Dependency dep: e.getValue()) {
out.println(" " + dep.getTarget());
}
}
}
void decodeArgs(String... args) {
rootClassNames = new TreeSet<String>();
packageNames = new TreeSet<String>();
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals("-classpath") && (i + 1 < args.length))
classpath = getPathFiles(args[++i]);
else if (arg.equals("-p") && (i + 1 < args.length))
packageNames.add(args[++i]);
else if (arg.equals("-r") && (i + 1 < args.length))
regex = args[++i];
else if (arg.equals("-rev"))
reverse = true;
else if (arg.equals("-t"))
transitiveClosure = true;
else if (arg.startsWith("-"))
throw new Error(arg);
else {
for ( ; i < args.length; i++)
rootClassNames.add(args[i]);
}
}
}
List<File> getPathFiles(String path) {
List<File> files = new ArrayList<File>();
for (String p: path.split(File.pathSeparator)) {
if (p.length() > 0)
files.add(new File(p));
}
return files;
}
boolean transitiveClosure;
List<File> classpath;
Set<String> rootClassNames;
Set<String> packageNames;
String regex;
boolean reverse;
static class ClassFileReader implements Dependencies.ClassFileReader {
private JavaFileManager fm;
ClassFileReader(JavaFileManager fm) {
this.fm = fm;
}
@Override
public ClassFile getClassFile(String className) throws ClassFileNotFoundException {
try {
JavaFileObject fo = fm.getJavaFileForInput(
StandardLocation.CLASS_PATH, className, JavaFileObject.Kind.CLASS);
if (fo == null)
fo = fm.getJavaFileForInput(
StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
if (fo == null)
throw new ClassFileNotFoundException(className);
InputStream in = fo.openInputStream();
try {
return ClassFile.read(in);
} finally {
in.close();
}
} catch (ConstantPoolException e) {
throw new ClassFileNotFoundException(className, e);
} catch (IOException e) {
throw new ClassFileNotFoundException(className, e);
}
}
};
static class SortedRecorder implements Recorder {
public SortedRecorder(boolean reverse) {
this.reverse = reverse;
}
public void addDependency(Dependency d) {
Location o = (reverse ? d.getTarget() : d.getOrigin());
SortedSet<Dependency> odeps = map.get(o);
if (odeps == null) {
Comparator<Dependency> c = (reverse ? originComparator : targetComparator);
map.put(o, odeps = new TreeSet<Dependency>(c));
}
odeps.add(d);
}
public SortedMap<Location, SortedSet<Dependency>> getMap() {
return map;
}
private Comparator<Dependency> originComparator = new Comparator<Dependency>() {
public int compare(Dependency o1, Dependency o2) {
return o1.getOrigin().toString().compareTo(o2.getOrigin().toString());
}
};
private Comparator<Dependency> targetComparator = new Comparator<Dependency>() {
public int compare(Dependency o1, Dependency o2) {
return o1.getTarget().toString().compareTo(o2.getTarget().toString());
}
};
private Comparator<Location> locationComparator = new Comparator<Location>() {
public int compare(Location o1, Location o2) {
return o1.toString().compareTo(o2.toString());
}
};
private final SortedMap<Location, SortedSet<Dependency>> map =
new TreeMap<Location, SortedSet<Dependency>>(locationComparator);
boolean reverse;
}
}
| 7,733 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6907575.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/classfile/deps/T6907575.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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 6907575
* @build GetDeps p.C1
* @run main T6907575
*/
import java.io.*;
public class T6907575 {
public static void main(String... args) throws Exception {
new T6907575().run();
}
void run() throws Exception {
String testSrc = System.getProperty("test.src");
String testClasses = System.getProperty("test.classes");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
GetDeps gd = new GetDeps();
gd.run(pw, "-classpath", testClasses, "-t", "-p", "p", "p/C1");
pw.close();
System.out.println(sw);
String ref = readFile(new File(testSrc, "T6907575.out"));
diff(sw.toString().replaceAll("[\r\n]+", "\n"), ref);
}
void diff(String actual, String ref) throws Exception {
System.out.println("EXPECT:>>>" + ref + "<<<");
System.out.println("ACTUAL:>>>" + actual + "<<<");
if (!actual.equals(ref))
throw new Exception("output not as expected");
}
String readFile(File f) throws IOException {
Reader r = new FileReader(f);
char[] buf = new char[(int) f.length()];
int offset = 0;
int n;
while (offset < buf.length && (n = r.read(buf, offset, buf.length - offset)) != -1)
offset += n;
return new String(buf, 0, offset);
}
}
| 2,591 | 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/javap/classfile/deps/p/C1.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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package p;
public class C1 {
C2 c2;
}
class C2 {
C3 c3;
}
class C3 {
}
| 1,290 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6888367.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javap/classfile/6888367/T6888367.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.*;
import java.net.*;
import java.util.*;
import com.sun.tools.classfile.*;
import com.sun.tools.classfile.Type.ArrayType;
import com.sun.tools.classfile.Type.ClassSigType;
import com.sun.tools.classfile.Type.ClassType;
import com.sun.tools.classfile.Type.MethodType;
import com.sun.tools.classfile.Type.SimpleType;
import com.sun.tools.classfile.Type.TypeParamType;
import com.sun.tools.classfile.Type.WildcardType;
/*
* @test
* @bug 6888367
* @summary classfile library parses signature attributes incorrectly
*/
/*
* This test is a pretty detailed test both of javac signature generation and classfile
* signature parsing. The first part of the test tests all the examples given in the
* second part of the test. Each example comes with one or two annotations, @Desc, @Sig,
* for the descriptor and signature of the annotated declaration. Annotations are
* provided whenever the annotated item is expected to have a corresponding value.
* Each annotation has two argument values. The first arg is the expected value of the
* descriptor/signature as found in the class file. This value is mostly for documentation
* purposes in reading the test. The second value is the rendering of the descriptor or
* signature using a custom Type visitor that explicitly includes an indication of the
* Type classes being used to represent the descriptor/signature. Thus we test
* that the descriptor/signature is being parsed into the expected type tree structure.
*/
public class T6888367 {
public static void main(String... args) throws Exception {
new T6888367().run();
}
public void run() throws Exception {
ClassFile cf = getClassFile("Test");
testFields(cf);
testMethods(cf);
testInnerClasses(cf); // recursive
if (errors > 0)
throw new Exception(errors + " errors found");
}
void testFields(ClassFile cf) throws Exception {
String cn = cf.getName();
ConstantPool cp = cf.constant_pool;
for (Field f: cf.fields) {
test("field " + cn + "." + f.getName(cp), f.descriptor, f.attributes, cp);
}
}
void testMethods(ClassFile cf) throws Exception {
String cn = cf.getName();
ConstantPool cp = cf.constant_pool;
for (Method m: cf.methods) {
test("method " + cn + "." + m.getName(cp), m.descriptor, m.attributes, cp);
}
}
void testInnerClasses(ClassFile cf) throws Exception {
ConstantPool cp = cf.constant_pool;
InnerClasses_attribute ic =
(InnerClasses_attribute) cf.attributes.get(Attribute.InnerClasses);
for (InnerClasses_attribute.Info info: ic.classes) {
String outerClassName = cp.getClassInfo(info.outer_class_info_index).getName();
if (!outerClassName.equals(cf.getName())) {
continue;
}
String innerClassName = cp.getClassInfo(info.inner_class_info_index).getName();
ClassFile icf = getClassFile(innerClassName);
test("class " + innerClassName, null, icf.attributes, icf.constant_pool);
testInnerClasses(icf);
}
}
void test(String name, Descriptor desc, Attributes attrs, ConstantPool cp)
throws Exception {
AnnotValues d = getDescValue(attrs, cp);
AnnotValues s = getSigValue(attrs, cp);
if (d == null && s == null) // not a test field or method if no @Desc or @Sig given
return;
System.err.println(name);
if (desc != null) {
System.err.println(" descriptor: " + desc.getValue(cp));
checkEqual(d.raw, desc.getValue(cp));
Type dt = new Signature(desc.index).getType(cp);
checkEqual(d.type, tp.print(dt));
}
Signature_attribute sa = (Signature_attribute) attrs.get(Attribute.Signature);
if (sa != null)
System.err.println(" signature: " + sa.getSignature(cp));
if (s != null || sa != null) {
if (s != null && sa != null) {
checkEqual(s.raw, sa.getSignature(cp));
Type st = new Signature(sa.signature_index).getType(cp);
checkEqual(s.type, tp.print(st));
} else if (s != null)
error("@Sig annotation found but not Signature attribute");
else
error("Signature attribute found but no @Sig annotation");
}
System.err.println();
}
ClassFile getClassFile(String name) throws IOException, ConstantPoolException {
URL url = getClass().getResource(name + ".class");
InputStream in = url.openStream();
try {
return ClassFile.read(in);
} finally {
in.close();
}
}
AnnotValues getDescValue(Attributes attrs, ConstantPool cp) throws Exception {
return getAnnotValues(Desc.class.getName(), attrs, cp);
}
AnnotValues getSigValue(Attributes attrs, ConstantPool cp) throws Exception {
return getAnnotValues(Sig.class.getName(), attrs, cp);
}
static class AnnotValues {
AnnotValues(String raw, String type) {
this.raw = raw;
this.type = type;
}
final String raw;
final String type;
}
AnnotValues getAnnotValues(String annotName, Attributes attrs, ConstantPool cp)
throws Exception {
RuntimeInvisibleAnnotations_attribute annots =
(RuntimeInvisibleAnnotations_attribute)attrs.get(Attribute.RuntimeInvisibleAnnotations);
if (annots != null) {
for (Annotation a: annots.annotations) {
if (cp.getUTF8Value(a.type_index).equals("L" + annotName + ";")) {
Annotation.Primitive_element_value pv0 =
(Annotation.Primitive_element_value) a.element_value_pairs[0].value;
Annotation.Primitive_element_value pv1 =
(Annotation.Primitive_element_value) a.element_value_pairs[1].value;
return new AnnotValues(
cp.getUTF8Value(pv0.const_value_index),
cp.getUTF8Value(pv1.const_value_index));
}
}
}
return null;
}
void checkEqual(String expect, String found) {
if (!(expect == null ? found == null : expect.equals(found))) {
System.err.println("expected: " + expect);
System.err.println(" found: " + found);
error("unexpected values found");
}
}
void error(String msg) {
System.err.println("error: " + msg);
errors++;
}
int errors;
TypePrinter tp = new TypePrinter();
class TypePrinter implements Type.Visitor<String,Void> {
String print(Type t) {
return t == null ? null : t.accept(this, null);
}
String print(String pre, List<? extends Type> ts, String post) {
if (ts == null)
return null;
StringBuilder sb = new StringBuilder();
sb.append(pre);
String sep = "";
for (Type t: ts) {
sb.append(sep);
sb.append(print(t));
sep = ",";
}
sb.append(post);
return sb.toString();
}
public String visitSimpleType(SimpleType type, Void p) {
return "S{" + type.name + "}";
}
public String visitArrayType(ArrayType type, Void p) {
return "A{" + print(type.elemType) + "}";
}
public String visitMethodType(MethodType type, Void p) {
StringBuilder sb = new StringBuilder();
sb.append("M{");
if (type.typeParamTypes != null)
sb.append(print("<", type.typeParamTypes, ">"));
sb.append(print(type.returnType));
sb.append(print("(", type.paramTypes, ")"));
if (type.throwsTypes != null)
sb.append(print("", type.throwsTypes, ""));
sb.append("}");
return sb.toString();
}
public String visitClassSigType(ClassSigType type, Void p) {
StringBuilder sb = new StringBuilder();
sb.append("CS{");
if (type.typeParamTypes != null)
sb.append(print("<", type.typeParamTypes, ">"));
sb.append(print(type.superclassType));
if (type.superinterfaceTypes != null)
sb.append(print("i(", type.superinterfaceTypes, ")"));
sb.append("}");
return sb.toString();
}
public String visitClassType(ClassType type, Void p) {
StringBuilder sb = new StringBuilder();
sb.append("C{");
if (type.outerType != null) {
sb.append(print(type.outerType));
sb.append(".");
}
sb.append(type.name);
if (type.typeArgs != null)
sb.append(print("<", type.typeArgs, ">"));
sb.append("}");
return sb.toString();
}
public String visitTypeParamType(TypeParamType type, Void p) {
StringBuilder sb = new StringBuilder();
sb.append("TA{");
sb.append(type.name);
if (type.classBound != null) {
sb.append(":c");
sb.append(print(type.classBound));
}
if (type.interfaceBounds != null)
sb.append(print(":i", type.interfaceBounds, ""));
sb.append("}");
return sb.toString();
}
public String visitWildcardType(WildcardType type, Void p) {
switch (type.kind) {
case UNBOUNDED:
return "W{?}";
case EXTENDS:
return "W{e," + print(type.boundType) + "}";
case SUPER:
return "W{s," + print(type.boundType) + "}";
default:
throw new AssertionError();
}
}
};
}
@interface Desc {
String d();
String t();
}
@interface Sig {
String s();
String t();
}
class Clss { }
interface Intf { }
class GenClss<T> { }
class Test {
// fields
@Desc(d="Z", t="S{boolean}")
boolean z;
@Desc(d="B", t="S{byte}")
byte b;
@Desc(d="C", t="S{char}")
char c;
@Desc(d="D", t="S{double}")
double d;
@Desc(d="F", t="S{float}")
float f;
@Desc(d="I", t="S{int}")
int i;
@Desc(d="J", t="S{long}")
long l;
@Desc(d="S", t="S{short}")
short s;
@Desc(d="LClss;", t="C{Clss}")
Clss clss;
@Desc(d="LIntf;", t="C{Intf}")
Intf intf;
@Desc(d="[I", t="A{S{int}}")
int[] ai;
@Desc(d="[LClss;", t="A{C{Clss}}")
Clss[] aClss;
@Desc(d="LGenClss;", t="C{GenClss}")
@Sig(s="LGenClss<LClss;>;", t="C{GenClss<C{Clss}>}")
GenClss<Clss> genClass;
// methods, return types
@Desc(d="()V", t="M{S{void}()}")
void mv0() { }
@Desc(d="()I", t="M{S{int}()}")
int mi0() { return 0; }
@Desc(d="()LClss;", t="M{C{Clss}()}")
Clss mclss0() { return null; }
@Desc(d="()[I", t="M{A{S{int}}()}")
int[] mai0() { return null; }
@Desc(d="()[LClss;", t="M{A{C{Clss}}()}")
Clss[] maClss0() { return null; }
@Desc(d="()LGenClss;", t="M{C{GenClss}()}")
@Sig(s="()LGenClss<LClss;>;", t="M{C{GenClss<C{Clss}>}()}")
GenClss<Clss> mgenClss0() { return null; }
@Desc(d="()LGenClss;", t="M{C{GenClss}()}")
@Sig(s="()LGenClss<*>;", t="M{C{GenClss<W{?}>}()}")
GenClss<?> mgenClssW0() { return null; }
@Desc(d="()LGenClss;", t="M{C{GenClss}()}")
@Sig(s="()LGenClss<+LClss;>;", t="M{C{GenClss<W{e,C{Clss}}>}()}")
GenClss<? extends Clss> mgenClssWExtClss0() { return null; }
@Desc(d="()LGenClss;", t="M{C{GenClss}()}")
@Sig(s="()LGenClss<-LClss;>;", t="M{C{GenClss<W{s,C{Clss}}>}()}")
GenClss<? super Clss> mgenClssWSupClss0() { return null; }
@Desc(d="()Ljava/lang/Object;", t="M{C{java/lang/Object}()}")
@Sig(s="<T:Ljava/lang/Object;>()TT;", t="M{<TA{T:cC{java/lang/Object}}>S{T}()}")
<T> T mt0() { return null; }
@Desc(d="()LGenClss;", t="M{C{GenClss}()}")
@Sig(s="<T:Ljava/lang/Object;>()LGenClss<+TT;>;",
t="M{<TA{T:cC{java/lang/Object}}>C{GenClss<W{e,S{T}}>}()}")
<T> GenClss<? extends T> mgenClssWExtT0() { return null; }
@Desc(d="()LGenClss;", t="M{C{GenClss}()}")
@Sig(s="<T:Ljava/lang/Object;>()LGenClss<-TT;>;", t="M{<TA{T:cC{java/lang/Object}}>C{GenClss<W{s,S{T}}>}()}")
<T> GenClss<? super T> mgenClssWSupT0() { return null; }
// methods, arg types
@Desc(d="(I)V", t="M{S{void}(S{int})}")
void mi1(int arg) { }
@Desc(d="(LClss;)V", t="M{S{void}(C{Clss})}")
void mclss1(Clss arg) { }
@Desc(d="([I)V", t="M{S{void}(A{S{int}})}")
void mai1(int[] arg) { }
@Desc(d="([LClss;)V", t="M{S{void}(A{C{Clss}})}")
void maClss1(Clss[] arg) { }
@Desc(d="(LGenClss;)V", t="M{S{void}(C{GenClss})}")
@Sig(s="(LGenClss<LClss;>;)V", t="M{S{void}(C{GenClss<C{Clss}>})}")
void mgenClss1(GenClss<Clss> arg) { }
@Desc(d="(LGenClss;)V", t="M{S{void}(C{GenClss})}")
@Sig(s="(LGenClss<*>;)V", t="M{S{void}(C{GenClss<W{?}>})}")
void mgenClssW1(GenClss<?> arg) { }
@Desc(d="(LGenClss;)V", t="M{S{void}(C{GenClss})}")
@Sig(s="(LGenClss<+LClss;>;)V", t="M{S{void}(C{GenClss<W{e,C{Clss}}>})}")
void mgenClssWExtClss1(GenClss<? extends Clss> arg) { }
@Desc(d="(LGenClss;)V", t="M{S{void}(C{GenClss})}")
@Sig(s="(LGenClss<-LClss;>;)V", t="M{S{void}(C{GenClss<W{s,C{Clss}}>})}")
void mgenClssWSupClss1(GenClss<? super Clss> arg) { }
@Desc(d="(Ljava/lang/Object;)V", t="M{S{void}(C{java/lang/Object})}")
@Sig(s="<T:Ljava/lang/Object;>(TT;)V",
t="M{<TA{T:cC{java/lang/Object}}>S{void}(S{T})}")
<T> void mt1(T arg) { }
@Desc(d="(LGenClss;)V", t="M{S{void}(C{GenClss})}")
@Sig(s="<T:Ljava/lang/Object;>(LGenClss<+TT;>;)V",
t="M{<TA{T:cC{java/lang/Object}}>S{void}(C{GenClss<W{e,S{T}}>})}")
<T> void mgenClssWExtT1(GenClss<? extends T> arg) { }
@Desc(d="(LGenClss;)V", t="M{S{void}(C{GenClss})}")
@Sig(s="<T:Ljava/lang/Object;>(LGenClss<-TT;>;)V",
t="M{<TA{T:cC{java/lang/Object}}>S{void}(C{GenClss<W{s,S{T}}>})}")
<T> void mgenClssWSupT1(GenClss<? super T> arg) { }
// methods, throws
@Desc(d="()V", t="M{S{void}()}")
void m_E() throws Exception { }
@Desc(d="()V", t="M{S{void}()}")
@Sig(s="<T:Ljava/lang/Throwable;>()V^TT;",
t="M{<TA{T:cC{java/lang/Throwable}}>S{void}()S{T}}")
<T extends Throwable> void m_T() throws T { }
// inner classes
static class X {
// no sig
class P { }
@Sig(s="<TQ:Ljava/lang/Object;>LTest$X$P;",
t="CS{<TA{TQ:cC{java/lang/Object}}>C{Test$X$P}}")
class Q<TQ> extends P { }
@Sig(s="<TR:Ljava/lang/Object;>LTest$X$Q<TTR;>;",
t="CS{<TA{TR:cC{java/lang/Object}}>C{Test$X$Q<S{TR}>}}")
class R<TR> extends Q<TR> { }
}
@Sig(s="<TY:Ljava/lang/Object;>Ljava/lang/Object;",
t="CS{<TA{TY:cC{java/lang/Object}}>C{java/lang/Object}}")
static class Y<TY> {
// no sig
class P { }
@Sig(s="<TQ:Ljava/lang/Object;>LTest$Y<TTY;>.P;",
t="CS{<TA{TQ:cC{java/lang/Object}}>C{C{Test$Y<S{TY}>}.P}}")
class Q<TQ> extends P { }
@Sig(s="<TR:Ljava/lang/Object;>LTest$Y<TTY;>.Q<TTR;>;",
t="CS{<TA{TR:cC{java/lang/Object}}>C{C{Test$Y<S{TY}>}.Q<S{TR}>}}")
class R<TR> extends Q<TR> {
// no sig
class R1 { }
@Sig(s="<TR2:Ljava/lang/Object;>LTest$Y<TTY;>.R<TTR;>.R1;",
t="CS{<TA{TR2:cC{java/lang/Object}}>C{C{C{Test$Y<S{TY}>}.R<S{TR}>}.R1}}")
class R2<TR2> extends R1 { }
}
@Sig(s="LTest$Y<TTY;>.Q<TTY;>;", t="C{C{Test$Y<S{TY}>}.Q<S{TY}>}")
class S extends Q<TY> {
// no sig
class S1 { }
@Sig(s="<TS2:Ljava/lang/Object;>LTest$Y<TTY;>.S.S1;",
t="CS{<TA{TS2:cC{java/lang/Object}}>C{C{C{Test$Y<S{TY}>}.S}.S1}}")
class S2<TS2> extends S1 { }
@Sig(s="LTest$Y<TTY;>.S.S2<TTY;>;",
t="C{C{C{Test$Y<S{TY}>}.S}.S2<S{TY}>}")
class S3 extends S2<TY> { }
}
}
}
| 17,557 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.