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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
T6253161a.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/positions/T6253161a.java | /*
* @test /nodynamiccopyright/
* @bug 6253161
* @summary Compiler will fail to find the correct location of serial warnings for anonymous inner classes
* @author Seetharama Avadhanam
* @compile -Xlint:serial -XDdev T6253161a.java
* @compile/ref=T6253161a.out -Xlint:serial -XDdev -XDrawDiagnostics T6253161a.java
*/
import java.util.List;
import java.util.ArrayList;
public class T6253161a {
@SuppressWarnings("unchecked")
public void anonymousMethod(){
List list = new ArrayList<String>(){
static final long serialVersionUID = 1;
List list = new ArrayList<Integer>();
public List<Integer> getMyList(){
final List floatList = new ArrayList<Float>(){
// Blank ....
};
for(int i=0;i<10;i++)
list.add((Float)(floatList.get(i)) * 11.232F * i);
return list;
}
}.getMyList();
}
}
| 970 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ImportCanonical1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/importChecks/ImportCanonical1.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 4462745
* @summary compiler permits to import class given by its non-canonical name
* @author gafter
*
* @compile/fail ImportCanonical1.java ImportCanonical2.java
*/
package p1;
class A1 { static class I {} }
class A2 extends A1 {}
| 1,310 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ImportCanonical2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/importChecks/ImportCanonical2.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.
*/
package p1;
import p1.A2.I;
class A3 { I x; }
| 1,099 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ImportIsFullyQualified.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/importChecks/ImportIsFullyQualified.java | /*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 4335264
* @summary Verify that import-on-demand must be fully qualified.
* @author maddox
*
* @compile/fail ImportIsFullyQualified.java
*/
import java.awt.*;
import JobAttributes.*; // class JobAttributes is contained in package java.awt
public class ImportIsFullyQualified {
JobAttributes.DefaultSelectionType x;
}
| 1,400 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
InvalidImportsNoClasses.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.java | /*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 4312063
* @summary Verify that nonexistent imports detected when no classes declared in compilation unit.
* @author maddox
*
* @compile/fail InvalidImportsNoClasses.java
*/
import nonexistent.pack.cls;
| 1,280 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ImportOfOwnClass.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/importChecks/ImportOfOwnClass.java | /*
* Copyright (c) 2000, 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 4081024 4662489
* @summary Verify that clash is allowed between class declaration and import of same class.
* @author maddox, gafter
*
* @compile ImportOfOwnClass.java
*/
package p;
import p.ImportOfOwnClass;
public class ImportOfOwnClass { // name clashes with import
ImportOfOwnClass() {}
}
| 1,384 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6390045a.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6390045/T6390045a.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 6390045
* @summary Unexpected error "cannot access java.lang.Void" with '-target cldc1.0' with -source >=1.5
*
* @author mcimadamore
* @compile -XDfailcomplete=java.lang.Void T6390045a.java
*/
class T6390045a {
boolean b;
short s;
Object o;
Object p = b ? o : s;
}
| 1,359 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6390045b.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6390045/T6390045b.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 6390045
* @summary Unexpected error "cannot access java.lang.Void" with '-target cldc1.0' with -source >=1.5
*
* @author mcimadamore
* @compile -XDfailcomplete=java.lang.Void T6390045b.java
*/
class T6390045b {
short s;
Object o;
Object p = choose(o, s);
<T> T choose(T t1, T t2) { return t1; }
}
| 1,391 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6342411.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6342411/T6342411.java | /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6342411
* @summary Add bridge method to allow reflective access to public method in non-public class
* @author Neal M Gafter
*/
import a.Pub;
import java.lang.reflect.*;
public class T6342411 {
public static void main(String[] args) throws Exception {
Pub p = new Pub();
p.f();
Method m = Pub.class.getMethod("f");
m.invoke(p);
}
}
| 1,455 | 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/javac/6342411/a/Base.java | /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package a;
class Base {
public void f() {
System.out.println("Hello, world!");
}
}
| 1,152 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Pub.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6342411/a/Pub.java | /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package a;
public class Pub extends Base {}
| 1,097 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T5090220.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/overload/T5090220.java | /*
* Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5090220
* @summary Autoboxing applied when calculating most-specific method
* @compile/fail T5090220.java
*/
class T5090220 {
static void foo(int i1, Integer i2) {
System.out.println("Integer");
}
static void foo(Integer i1, double d) {
System.out.println("double");
}
public static void main(String[] args) {
foo(5, 5);
}
}
| 1,455 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6776289.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/overload/T6776289.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 6776289
* @summary Regression: javac7 doesnt resolve method calls properly
* @compile T6776289.java
*/
class A {
private void m(int a, int b) { }
}
class T6776289 {
static void m(int a, String s) { }
class B extends A {
public void test() {
m(1, "");
}
}
}
| 1,378 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4494762.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/overload/T4494762.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4494762 6491939
* @summary Request for Clarification of JLS 15.12.2.2
* @author Peter von der Ah\u00e9
* @compile T4494762.java
*/
public class T4494762 {
static class Homer {
float doh(float f) {
System.out.println("doh(float)");
return 1.0f;
}
char doh(char c) {
System.out.println("doh(string)");
return 'd';
}
}
static class Bart extends Homer {
float doh(float f) {
System.out.println("doh(float)");
return 1.0f;
}
}
public static void main(String[] args) {
Bart b = new Bart();
b.doh('x');//compiler error in this line
b.doh(1);
b.doh(1.0f);
}
}
| 1,814 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4723909.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/overload/T4723909.java | /*
* Copyright (c) 2002, 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 4723909 4758654 4839284
* @summary class methods do not conform to JLS 15.12.2.2 definition of most specific method
* @author gafter
*
* @compile T4723909.java
*/
class T4723909 {
static class Test {
public static void main(String[] args) {
new Subclass().test(0);
}
}
static class Superclass {
static void test(int i) {
System.out.println("test(int i)");
}
}
static class Subclass extends Superclass {
static void test(long l) {
System.out.println("test(long l)");
}
}
}
| 1,664 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4743490.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/overload/T4743490.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 4743490
* @summary overloading versus super.f(args) versus interfaces
* @author gafter
*
* @compile/fail T4743490.java
*/
class T4743490 {
static class A {
public void m(Object o, String s) {}
}
interface B {
void m(String s, Object o);
}
static abstract class C extends A implements B {
}
static abstract class D extends C {
void foo() {
C c = null;
super.m("", ""); // should be ambiguous.
}
}
}
| 1,564 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6835430.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6835430/T6835430.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 6835430
* @summary 6835430: javac does not generate signature attributes for classes extending parameterized inner classes
* @author mcimadamore
*
* @compile A.java
* @compile T6835430.java
*/
class T6835430 {
void test(B.D d) {
B b = d.getT();
}
}
| 1,344 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6835430/A.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.
*/
class A<T extends A<T>> {
class C {
public T getT() { return null; }
}
}
class B extends A<B> {
public class D extends A<B>.C {}
}
| 1,204 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Dummy.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ImportUnnamed/Dummy.java | /*
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 4361575
* @summary Correct scoping and diagnostics for import declarations.
* @author gafter
*
* @compile/fail foo/A.java
*/
public class Dummy {}
| 1,225 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ImportUnnamed/foo/A.java | /*
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 Dummy;
class A {
Dummy x = null;
}
| 1,099 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6440583.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6440583/T6440583.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6440583
* @summary better error recovery
*/
import java.io.*;
import java.util.*;
import javax.tools.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;
import com.sun.tools.javac.api.*;
import com.sun.tools.javac.tree.JCTree.*;
public class T6440583 {
public static void main(String... args) throws Exception {
String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes", ".");
JavacTool tool = JavacTool.create();
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
Iterable<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
JavacTask task = tool.getTask(null, fm, null, null, null, files);
Iterable<? extends Tree> trees = task.parse();
TreeScanner<Boolean,Void> checker = new TreeScanner<Boolean,Void>() {
public Boolean visitErroneous(ErroneousTree tree, Void ignore) {
JCErroneous etree = (JCErroneous) tree;
List<? extends Tree> errs = etree.getErrorTrees();
System.err.println("errs: " + errs);
if (errs == null || errs.size() == 0)
throw new AssertionError("no error trees found");
found = true;
return true;
}
};
for (Tree tree: trees)
checker.scan(tree, null);
if (!found)
throw new AssertionError("no ErroneousTree nodes found");
}
private static boolean found;
}
| 2,677 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6440583/A.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class A {
public static void m() {
1+1
}
}
| 1,111 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AnnoProcessor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T7142672/AnnoProcessor.java | /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("Anno")
public class AnnoProcessor extends AbstractProcessor {
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment re) {
System.out.println("RUNNING...");
if(set.isEmpty()) {
return false;
}
return false;
}
}
| 1,633 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Bug.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T7142672/Bug.java | /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7142672
* @summary Problems with the value passed to the 'classes' param of JavaCompiler.CompilationTask.getTask(...)
* @author holmlund
* @compile AnnoProcessor.java Bug.java Test3.java
* @run main Bug Test2.java
* @run main Bug Test2.foo
* @run main Bug Test3.java
*/
import java.io.*;
import java.util.*;
import javax.tools.*;
// Each run should output the 'could not find class file' message, and not throw an AssertError.
public class Bug {
public static void main(String... arg) throws Throwable {
String name = arg[0];
final String expectedMsg = "error: Could not find class file for '" + name + "'.";
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
JavaCompiler.CompilationTask task2;
StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
DiagnosticListener<? super javax.tools.JavaFileObject> dl =
new DiagnosticListener<javax.tools.JavaFileObject>() {
public void report(Diagnostic message) {
pw.print("Diagnostic:\n"+ message.toString()+"\n");
if (!message.toString().equals(expectedMsg)){
System.err.println("Diagnostic:\n"+ message.toString()+"\n");
System.err.println("--Failed: Unexpected diagnostic");
System.exit(1);
}
}
};
StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null);
List<String> opts = new ArrayList<String>();
opts.add("-proc:only");
opts.add("-processor");
opts.add("AnnoProcessor");
boolean xxx;
System.err.println("\n-- " + name);
task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null);
xxx = task2.call();
String out = sw.toString();
System.err.println(out);
if (out.contains("Assert")) {
System.err.println("--Failed: Assertion failure");
System.exit(1);
}
if (!out.contains(expectedMsg)) {
System.err.println("--Failed: Expected diagnostic not found");
System.exit(1);
}
}
}
| 3,256 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Test3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T7142672/Test3.java | /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class Test3 {
}
| 1,068 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Test2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T7142672/Test2.java | /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class Test2 {
}
| 1,068 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T4880220.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/4880220/T4880220.java | /*
* @test /nodynamiccopyright/
* @bug 4880220
* @summary Add a warning when accessing a static method via an reference
*
* @compile/ref=T4880220.empty.out T4880220.java
* @compile/ref=T4880220.warn.out -XDrawDiagnostics -Xlint:static T4880220.java
* @compile/ref=T4880220.warn.out -XDrawDiagnostics -Xlint:all T4880220.java
* @compile/ref=T4880220.empty.out -XDrawDiagnostics -Xlint:all,-static T4880220.java
* @compile/ref=T4880220.error.out/fail -XDrawDiagnostics -Werror -Xlint:all T4880220.java
*/
public class T4880220 {
void m1() {
int good_1 = C.m();
int good_2 = C.f;
int good_3 = C.x;
C c = new C();
int bad_inst_1 = c.m();
int bad_inst_2 = c.f;
int bad_inst_3 = c.x;
int bad_expr_1 = c().m();
int bad_expr_2 = c().f;
int bad_expr_3 = c().x;
}
void m2() {
Class<?> good_1 = C.class;
Class<?> good_2 = C[].class;
}
C c() {
return new C();
}
static class C {
static int m() { return 0; }
static int f;
static final int x = 3;
}
}
| 1,226 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver01.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver01.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver01.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver01.java
*/
class Test { { x = "" } }
| 261 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver04.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver04.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver04.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver04.java
*/
class Test {
{ new Unknown() {}; }
}
| 274 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver11.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver11.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver11.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver11.java
*/
class Test extends Test {
boolean cond;
void m(Object o) {}
{ m(cond ? null : null); }
}
| 338 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver09.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver09.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver09.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver09.java
*/
class Test extends Test {
Integer x = 1;
{ for (x = 0 ; x ; x++) {}; }
}
| 315 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver02.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver02.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver02.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver02.java
*/
class Test implements AutoCloseable {
void test() {
try(Test t = null) {}
}
}
| 328 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver14.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver14.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver14.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver14.java
*/
class Test extends Test {
{ for (Integer x : !x) { } }
}
| 297 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver03.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver03.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver03.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver03.java
*/
class Test extends Test {
Test i;
}
| 273 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
CheckAttributedTree.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/CheckAttributedTree.java | /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import com.sun.source.util.TaskEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.TaskListener;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCImport;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.tree.TreeScanner;
import com.sun.tools.javac.util.Pair;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.lang.model.element.Element;
/**
* Utility and test program to check validity of tree positions for tree nodes.
* The program can be run standalone, or as a jtreg test. In standalone mode,
* errors can be displayed in a gui viewer. For info on command line args,
* run program with no args.
*
* <p>
* jtreg: Note that by using the -r switch in the test description below, this test
* will process all java files in the langtools/test directory, thus implicitly
* covering any new language features that may be tested in this test suite.
*/
/*
* @test
* @bug 6970584
* @summary assorted position errors in compiler syntax trees
* @run main CheckAttributedTree -q -r -et ERRONEOUS .
*/
public class CheckAttributedTree {
/**
* Main entry point.
* If test.src is set, program runs in jtreg mode, and will throw an Error
* if any errors arise, otherwise System.exit will be used, unless the gui
* viewer is being used. In jtreg mode, the default base directory for file
* args is the value of ${test.src}. In jtreg mode, the -r option can be
* given to change the default base directory to the root test directory.
*/
public static void main(String... args) {
String testSrc = System.getProperty("test.src");
File baseDir = (testSrc == null) ? null : new File(testSrc);
boolean ok = new CheckAttributedTree().run(baseDir, args);
if (!ok) {
if (testSrc != null) // jtreg mode
throw new Error("failed");
else
System.exit(1);
}
}
/**
* Run the program. A base directory can be provided for file arguments.
* In jtreg mode, the -r option can be given to change the default base
* directory to the test root directory. For other options, see usage().
* @param baseDir base directory for any file arguments.
* @param args command line args
* @return true if successful or in gui mode
*/
boolean run(File baseDir, String... args) {
if (args.length == 0) {
usage(System.out);
return true;
}
List<File> files = new ArrayList<File>();
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals("-encoding") && i + 1 < args.length)
encoding = args[++i];
else if (arg.equals("-gui"))
gui = true;
else if (arg.equals("-q"))
quiet = true;
else if (arg.equals("-v"))
verbose = true;
else if (arg.equals("-t") && i + 1 < args.length)
tags.add(args[++i]);
else if (arg.equals("-ef") && i + 1 < args.length)
excludeFiles.add(new File(baseDir, args[++i]));
else if (arg.equals("-et") && i + 1 < args.length)
excludeTags.add(args[++i]);
else if (arg.equals("-r")) {
if (excludeFiles.size() > 0)
throw new Error("-r must be used before -ef");
File d = baseDir;
while (!new File(d, "TEST.ROOT").exists()) {
if (d == null)
throw new Error("cannot find TEST.ROOT");
d = d.getParentFile();
}
baseDir = d;
}
else if (arg.startsWith("-"))
throw new Error("unknown option: " + arg);
else {
while (i < args.length)
files.add(new File(baseDir, args[i++]));
}
}
for (File file: files) {
if (file.exists())
test(file);
else
error("File not found: " + file);
}
if (fileCount != 1)
System.err.println(fileCount + " files read");
if (errors > 0)
System.err.println(errors + " errors");
return (gui || errors == 0);
}
/**
* Print command line help.
* @param out output stream
*/
void usage(PrintStream out) {
out.println("Usage:");
out.println(" java CheckAttributedTree options... files...");
out.println("");
out.println("where options include:");
out.println("-q Quiet: don't report on inapplicable files");
out.println("-gui Display returns in a GUI viewer");
out.println("-v Verbose: report on files as they are being read");
out.println("-t tag Limit checks to tree nodes with this tag");
out.println(" Can be repeated if desired");
out.println("-ef file Exclude file or directory");
out.println("-et tag Exclude tree nodes with given tag name");
out.println("");
out.println("files may be directories or files");
out.println("directories will be scanned recursively");
out.println("non java files, or java files which cannot be parsed, will be ignored");
out.println("");
}
/**
* Test a file. If the file is a directory, it will be recursively scanned
* for java files.
* @param file the file or directory to test
*/
void test(File file) {
if (excludeFiles.contains(file)) {
if (!quiet)
error("File " + file + " excluded");
return;
}
if (file.isDirectory()) {
for (File f: file.listFiles()) {
test(f);
}
return;
}
if (file.isFile() && file.getName().endsWith(".java")) {
try {
if (verbose)
System.err.println(file);
fileCount++;
NPETester p = new NPETester();
p.test(read(file));
} catch (AttributionException e) {
if (!quiet) {
error("Error attributing " + file + "\n" + e.getMessage());
}
} catch (IOException e) {
error("Error reading " + file + ": " + e);
}
return;
}
if (!quiet)
error("File " + file + " ignored");
}
// See CR: 6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Reporter r = new Reporter(pw);
JavacTool tool = JavacTool.create();
StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
/**
* Read a file.
* @param file the file to be read
* @return the tree for the content of the file
* @throws IOException if any IO errors occur
* @throws TreePosTest.ParseException if any errors occur while parsing the file
*/
List<Pair<JCCompilationUnit, JCTree>> read(File file) throws IOException, AttributionException {
JavacTool tool = JavacTool.create();
r.errors = 0;
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" };
JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files);
final List<Element> analyzedElems = new ArrayList<>();
task.setTaskListener(new TaskListener() {
public void started(TaskEvent e) {
if (e.getKind() == TaskEvent.Kind.ANALYZE)
analyzedElems.add(e.getTypeElement());
}
public void finished(TaskEvent e) { }
});
try {
Iterable<? extends CompilationUnitTree> trees = task.parse();
task.analyze();
List<Pair<JCCompilationUnit, JCTree>> res = new ArrayList<>();
//System.out.println("Try to add pairs. Elems are " + analyzedElems);
for (CompilationUnitTree t : trees) {
JCCompilationUnit cu = (JCCompilationUnit)t;
for (JCTree def : cu.defs) {
if (def.getTag() == JCTree.CLASSDEF &&
analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) {
//System.out.println("Adding pair...");
res.add(new Pair<>(cu, def));
}
}
}
return res;
}
catch (Throwable t) {
throw new AttributionException("Exception while attributing file: " + file);
}
}
/**
* Report an error. When the program is complete, the program will either
* exit or throw an Error if any errors have been reported.
* @param msg the error message
*/
void error(String msg) {
System.err.println(msg);
errors++;
}
/** Number of files that have been analyzed. */
int fileCount;
/** Number of errors reported. */
int errors;
/** Flag: don't report irrelevant files. */
boolean quiet;
/** Flag: show errors in GUI viewer. */
boolean gui;
/** The GUI viewer for errors. */
Viewer viewer;
/** Flag: report files as they are processed. */
boolean verbose;
/** Option: encoding for test files. */
String encoding;
/** The set of tags for tree nodes to be analyzed; if empty, all tree nodes
* are analyzed. */
Set<String> tags = new HashSet<String>();
/** Set of files and directories to be excluded from analysis. */
Set<File> excludeFiles = new HashSet<File>();
/** Set of tag names to be excluded from analysis. */
Set<String> excludeTags = new HashSet<String>();
/** Utility class for trees */
TreeUtil treeUtil = new TreeUtil();
/**
* Main class for testing assertions concerning types/symbol
* left uninitialized after attribution
*/
private class NPETester extends TreeScanner {
void test(List<Pair<JCCompilationUnit, JCTree>> trees) {
for (Pair<JCCompilationUnit, JCTree> p : trees) {
sourcefile = p.fst.sourcefile;
endPosTable = p.fst.endPositions;
encl = new Info(p.snd, endPosTable);
p.snd.accept(this);
}
}
@Override
public void scan(JCTree tree) {
if (tree == null ||
excludeTags.contains(treeUtil.nameFromTag(tree.getTag()))) {
return;
}
Info self = new Info(tree, endPosTable);
check(!mandatoryType(tree) ||
(tree.type != null &&
checkFields(tree)),
"'null' found in tree ",
self);
Info prevEncl = encl;
encl = self;
tree.accept(this);
encl = prevEncl;
}
private boolean mandatoryType(JCTree that) {
return that instanceof JCTree.JCExpression ||
that.getTag() == JCTree.VARDEF ||
that.getTag() == JCTree.METHODDEF ||
that.getTag() == JCTree.CLASSDEF;
}
private final List<String> excludedFields = Arrays.asList("varargsElement");
void check(boolean ok, String label, Info self) {
if (!ok) {
if (gui) {
if (viewer == null)
viewer = new Viewer();
viewer.addEntry(sourcefile, label, encl, self);
}
error(label + self.toString() + " encl: " + encl.toString() + " in file: " + sourcefile + " " + self.tree);
}
}
boolean checkFields(JCTree t) {
List<Field> fieldsToCheck = treeUtil.getFieldsOfType(t,
excludedFields,
Symbol.class,
Type.class);
for (Field f : fieldsToCheck) {
try {
if (f.get(t) == null) {
return false;
}
}
catch (IllegalAccessException e) {
System.err.println("Cannot read field: " + f);
//swallow it
}
}
return true;
}
@Override
public void visitImport(JCImport tree) { }
@Override
public void visitTopLevel(JCCompilationUnit tree) {
scan(tree.defs);
}
JavaFileObject sourcefile;
Map<JCTree, Integer> endPosTable;
Info encl;
}
/**
* Utility class providing easy access to position and other info for a tree node.
*/
private class Info {
Info() {
tree = null;
tag = JCTree.ERRONEOUS;
start = 0;
pos = 0;
end = Integer.MAX_VALUE;
}
Info(JCTree tree, Map<JCTree, Integer> endPosTable) {
this.tree = tree;
tag = tree.getTag();
start = TreeInfo.getStartPos(tree);
pos = tree.pos;
end = TreeInfo.getEndPos(tree, endPosTable);
}
@Override
public String toString() {
return treeUtil.nameFromTag(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]";
}
final JCTree tree;
final int tag;
final int start;
final int pos;
final int end;
}
/**
* Names for tree tags.
* javac does not provide an API to convert tag values to strings, so this class uses
* reflection to determine names of public static final int values in JCTree.
*/
private static class TreeUtil {
String nameFromTag(int tag) {
if (names == null) {
names = new HashMap<Integer, String>();
Class c = JCTree.class;
for (Field f : c.getDeclaredFields()) {
if (f.getType().equals(int.class)) {
int mods = f.getModifiers();
if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
try {
names.put(f.getInt(null), f.getName());
} catch (IllegalAccessException e) {
}
}
}
}
}
String name = names.get(tag);
return (name == null) ? "??" : name;
}
List<Field> getFieldsOfType(JCTree t, List<String> excludeNames, Class<?>... types) {
List<Field> buf = new ArrayList<Field>();
for (Field f : t.getClass().getDeclaredFields()) {
if (!excludeNames.contains(f.getName())) {
for (Class<?> type : types) {
if (type.isAssignableFrom(f.getType())) {
f.setAccessible(true);
buf.add(f);
break;
}
}
}
}
return buf;
}
private Map<Integer, String> names;
}
/**
* Thrown when errors are found parsing a java file.
*/
private static class ParseException extends Exception {
ParseException(String msg) {
super(msg);
}
}
private static class AttributionException extends Exception {
AttributionException(String msg) {
super(msg);
}
}
/**
* DiagnosticListener to report diagnostics and count any errors that occur.
*/
private static class Reporter implements DiagnosticListener<JavaFileObject> {
Reporter(PrintWriter out) {
this.out = out;
}
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
out.println(diagnostic);
switch (diagnostic.getKind()) {
case ERROR:
errors++;
}
}
int errors;
PrintWriter out;
}
/**
* GUI viewer for issues found by TreePosTester. The viewer provides a drop
* down list for selecting error conditions, a header area providing details
* about an error, and a text area with the ranges of text highlighted as
* appropriate.
*/
private class Viewer extends JFrame {
/**
* Create a viewer.
*/
Viewer() {
initGUI();
}
/**
* Add another entry to the list of errors.
* @param file The file containing the error
* @param check The condition that was being tested, and which failed
* @param encl the enclosing tree node
* @param self the tree node containing the error
*/
void addEntry(JavaFileObject file, String check, Info encl, Info self) {
Entry e = new Entry(file, check, encl, self);
DefaultComboBoxModel m = (DefaultComboBoxModel) entries.getModel();
m.addElement(e);
if (m.getSize() == 1)
entries.setSelectedItem(e);
}
/**
* Initialize the GUI window.
*/
private void initGUI() {
JPanel head = new JPanel(new GridBagLayout());
GridBagConstraints lc = new GridBagConstraints();
GridBagConstraints fc = new GridBagConstraints();
fc.anchor = GridBagConstraints.WEST;
fc.fill = GridBagConstraints.HORIZONTAL;
fc.gridwidth = GridBagConstraints.REMAINDER;
entries = new JComboBox();
entries.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showEntry((Entry) entries.getSelectedItem());
}
});
fc.insets.bottom = 10;
head.add(entries, fc);
fc.insets.bottom = 0;
head.add(new JLabel("check:"), lc);
head.add(checkField = createTextField(80), fc);
fc.fill = GridBagConstraints.NONE;
head.add(setBackground(new JLabel("encl:"), enclColor), lc);
head.add(enclPanel = new InfoPanel(), fc);
head.add(setBackground(new JLabel("self:"), selfColor), lc);
head.add(selfPanel = new InfoPanel(), fc);
add(head, BorderLayout.NORTH);
body = new JTextArea();
body.setFont(Font.decode(Font.MONOSPACED));
body.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent e) {
int dot = e.getDot();
int mark = e.getMark();
if (dot == mark)
statusText.setText("dot: " + dot);
else
statusText.setText("dot: " + dot + ", mark:" + mark);
}
});
JScrollPane p = new JScrollPane(body,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
p.setPreferredSize(new Dimension(640, 480));
add(p, BorderLayout.CENTER);
statusText = createTextField(80);
add(statusText, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(null); // centered on screen
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
try {
// update simple fields
setTitle(e.file.getName());
checkField.setText(e.check);
enclPanel.setInfo(e.encl);
selfPanel.setInfo(e.self);
// show file text with highlights
body.setText(e.file.getCharContent(true).toString());
Highlighter highlighter = body.getHighlighter();
highlighter.removeAllHighlights();
addHighlight(highlighter, e.encl, enclColor);
addHighlight(highlighter, e.self, selfColor);
scroll(body, getMinPos(enclPanel.info, selfPanel.info));
} catch (IOException ex) {
body.setText("Cannot read " + e.file.getName() + ": " + e);
}
}
/** Create a test field. */
private JTextField createTextField(int width) {
JTextField f = new JTextField(width);
f.setEditable(false);
f.setBorder(null);
return f;
}
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
int start = info.start;
int end = info.end;
if (start == -1 && end == -1)
return;
if (start == -1)
start = end;
if (end == -1)
end = start;
try {
h.addHighlight(info.start, info.end,
new DefaultHighlighter.DefaultHighlightPainter(c));
if (info.pos != -1) {
Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
h.addHighlight(info.pos, info.pos + 1,
new DefaultHighlighter.DefaultHighlightPainter(c2));
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
/** Get the minimum valid position in a set of info objects. */
private int getMinPos(Info... values) {
int i = Integer.MAX_VALUE;
for (Info info: values) {
if (info.start >= 0) i = Math.min(i, info.start);
if (info.pos >= 0) i = Math.min(i, info.pos);
if (info.end >= 0) i = Math.min(i, info.end);
}
return (i == Integer.MAX_VALUE) ? 0 : i;
}
/** Set the background on a component. */
private JComponent setBackground(JComponent comp, Color c) {
comp.setOpaque(true);
comp.setBackground(c);
return comp;
}
/** Scroll a text area to display a given position near the middle of the visible area. */
private void scroll(final JTextArea t, final int pos) {
// Using invokeLater appears to give text a chance to sort itself out
// before the scroll happens; otherwise scrollRectToVisible doesn't work.
// Maybe there's a better way to sync with the text...
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Rectangle r = t.modelToView(pos);
JScrollPane p = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, t);
r.y = Math.max(0, r.y - p.getHeight() * 2 / 5);
r.height += p.getHeight() * 4 / 5;
t.scrollRectToVisible(r);
} catch (BadLocationException ignore) {
}
}
});
}
private JComboBox entries;
private JTextField checkField;
private InfoPanel enclPanel;
private InfoPanel selfPanel;
private JTextArea body;
private JTextField statusText;
private Color selfColor = new Color(0.f, 1.f, 0.f, 0.2f); // 20% green
private Color enclColor = new Color(1.f, 0.f, 0.f, 0.2f); // 20% red
/** Panel to display an Info object. */
private class InfoPanel extends JPanel {
InfoPanel() {
add(tagName = createTextField(20));
add(new JLabel("start:"));
add(addListener(start = createTextField(6)));
add(new JLabel("pos:"));
add(addListener(pos = createTextField(6)));
add(new JLabel("end:"));
add(addListener(end = createTextField(6)));
}
void setInfo(Info info) {
this.info = info;
tagName.setText(treeUtil.nameFromTag(info.tag));
start.setText(String.valueOf(info.start));
pos.setText(String.valueOf(info.pos));
end.setText(String.valueOf(info.end));
}
JTextField addListener(final JTextField f) {
f.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
body.setCaretPosition(Integer.valueOf(f.getText()));
body.getCaret().setVisible(true);
}
});
return f;
}
Info info;
JTextField tagName;
JTextField start;
JTextField pos;
JTextField end;
}
/** Object to record information about an error to be displayed. */
private class Entry {
Entry(JavaFileObject file, String check, Info encl, Info self) {
this.file = file;
this.check = check;
this.encl = encl;
this.self= self;
}
@Override
public String toString() {
return file.getName() + " " + check + " " + getMinPos(encl, self);
}
final JavaFileObject file;
final String check;
final Info encl;
final Info self;
}
}
}
| 28,739 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver08.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver08.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver08.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver08.java
*/
class Test extends Test {
Integer x = 1;
{ while (x) {}; }
}
| 303 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver12.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver12.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver12.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver12.java
*/
class Test extends Test {
Integer x = 1;
{ try {} catch (Exception e) {} }
}
| 321 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver05.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver05.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver05.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver05.java
*/
class Test extends Test {
{ for ( Integer x : null) {} }
}
| 296 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver06.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver06.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver06.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver06.java
*/
class Test extends Test {
Inference x = 1;
{ if (x == 1) { } else { } }
}
| 316 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver10.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver10.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver10.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver10.java
*/
class Test extends Test {
boolean cond;
{ Object o = null; }
}
| 307 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver15.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver15.java | /*
* @test /nodynamiccopyright/
* @bug 6970584 7060926
* @summary Attr.PostAttrAnalyzer misses a case
*
* @compile/fail/ref=FailOver15.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver15.java
*/
class Test {
void m() {
new UnknownClass<String, Void>() {
public String getString() {
String s = "";
s += "more";
return s;
}
}
}
}
| 444 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver07.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver07.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver07.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver07.java
*/
class Test extends Test {
Integer x = 1;
{ do {} while (x); }
}
| 306 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FailOver13.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/failover/FailOver13.java | /*
* @test /nodynamiccopyright/
* @bug 6970584
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver13.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver13.java
*/
class Test extends Test {
Integer x = 1;
{ x = (Object)o; }
}
| 306 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
A.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/javazip/A.java | /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// A class that references another
class A {
B b;
}
| 1,108 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/javazip/bad/B.java | /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// this class is invalid
class B
| 1,085 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/javazip/good/B.java | /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// this is a valid class
public class B {
}
| 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/javac/6403424/A.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class A { }
| 1,071 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
B.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6403424/B.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class B extends A { }
| 1,074 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6403424.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6403424/T6403424.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6403424
* @summary JavacFileManager.inferBinaryName is not case-insensitive on Windows
*/
import java.io.*;
import java.util.*;
import com.sun.tools.javac.api.*;
public class T6403424 {
public static void main(String[] args) {
File testSrc = new File(System.getProperty("test.src", "."));
File TMP = new File("TMP");
TMP.mkdirs();
// first, compile A to the TMP directory
File A_java = new File(testSrc, "A.java");
compile("-d", TMP.getPath(), A_java.getPath());
// now compile B, which references A,
// with TMP on classpath and tmp on bootclasspath
File B_java = new File(testSrc, "B.java");
compile("-classpath", TMP.getPath(),
"-Xbootclasspath/p:" + TMP.getPath().toLowerCase(),
"-d", ".",
B_java.getPath());
// should not get NPE from compiler
}
private static void compile(String... args) {
System.err.println("compile: " + Arrays.asList(args));
JavacTool javac = JavacTool.create();
int rc = javac.run(null, null, null, args);
if (rc != 0)
throw new AssertionError("test compilation failed");
}
}
| 2,283 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SameJVM.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Paths/SameJVM.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.
*/
/*
* Support routines to allow running `javac' or `jar' within the same JVM.
*/
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
class SameJVM {
private static ClassLoader toolsClassLoader() {
File javaHome = new File(System.getProperty("java.home"));
File classesDir = new File(javaHome, "classes");
File libDir = new File(javaHome.getParentFile(), "lib");
File toolsJar = new File(libDir, "tools.jar");
try {
return new URLClassLoader(
new URL[] {classesDir.toURL(), toolsJar.toURL()});
} catch (MalformedURLException e) { throw new AssertionError(e); }
}
private static final ClassLoader cl = toolsClassLoader();
static void javac(String... args) throws Exception {
Class c = Class.forName("com.sun.tools.javac.Main", true, cl);
int status = (Integer)
c.getMethod("compile", new Class[] {String[].class})
.invoke(c.newInstance(), new Object[] {args});
if (status != 0)
throw new Exception("javac failed: status=" + status);
}
static void jar(String... args) throws Exception {
Class c = Class.forName("sun.tools.jar.Main", true, cl);
Object instance = c.getConstructor(
new Class[] {PrintStream.class, PrintStream.class, String.class})
.newInstance(System.out, System.err, "jar");
boolean result = (Boolean)
c.getMethod("run", new Class[] {String[].class})
.invoke(instance, new Object[] {args});
if (! result)
throw new Exception("jar failed");
}
}
| 2,692 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
CompileClose.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Paths/CompileClose.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 5071352
* @summary Make sure compiler closes all open files on Windows
* @author Martin Buchholz
*
* @run main/othervm -Xms200m -Xmx200m CompileClose
*/
// -Xms120m is sufficient to inhibit a gc during a compile.
// -Xms200m leaves room for expansion and was used by the customer.
import java.io.*;
public class CompileClose {
static void writeFile(String f, String contents) throws IOException {
PrintStream s = new PrintStream(new FileOutputStream(f));
s.println(contents);
s.close();
}
static void rm(String filename) throws Exception {
File f = new File(filename);
f.delete();
if (f.exists())
throw new Exception(filename + ": couldn't remove");
}
static void clean() throws Exception {
rm("tmpCompileClose.java");
rm("tmpCompileClose.class");
rm("tmpCompileClose.jar");
}
public static void main(String args[]) throws Exception {
try {
clean();
main1();
} finally {
clean();
}
}
static void main1() throws Exception {
writeFile("tmpCompileClose.java",
"public class tmpCompileClose {}");
// Any old jar file will do
SameJVM.jar("cf", "tmpCompileClose.jar", "tmpCompileClose.java");
System.gc(); // Inhibit gc during next compile
SameJVM.javac("-cp", "tmpCompileClose.jar", "tmpCompileClose.java");
// The following rm is the actual test!
rm("tmpCompileClose.jar");
}
}
| 2,616 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
WsCompileExample.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Paths/6638501/WsCompileExample.java | /*
* Copyright (c) 2007, 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.List;
import java.util.ArrayList;
import java.io.File;
//for CompilerHelper
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
public class WsCompileExample {
File destDir;
File srcDir;
protected boolean compilerDebug = false;
protected boolean compilerOptimize = false;
protected String userClasspath = null;
public static void main(String[] args) {
new WsCompileExample().do_main(args);
}
public void do_main(String[] args) {
if(!args[0].equals("-s")) {
throw new RuntimeException("specify -s for src");
}
//run it once
srcDir = new File(args[1]);
if(!args[2].equals("-d")) {
throw new RuntimeException("specify -d for dest");
}
destDir = new File(args[3]);
if(!destDir.exists())
destDir.mkdirs();
System.out.println("----test compile 1-----");
compileGeneratedClasses();
//run it twice
srcDir = new File(args[1]+"1");
destDir = new File(args[3]+"1");
if(!destDir.exists())
destDir.mkdirs();
System.out.println("----test compile 2-----");
compileGeneratedClasses();
}
protected void compileGeneratedClasses() {
List sourceFiles = new ArrayList();
for (File f: srcDir.listFiles()) {
if (f.getName().endsWith(".java")) {
sourceFiles.add(f.getAbsolutePath());
}
}
if (sourceFiles.size() > 0) {
String classDir = destDir.getAbsolutePath();
String classpathString = createClasspathString();
System.out.println("classpathString: " + classpathString);
String[] args = new String[4 + (compilerDebug == true ? 1 : 0) +
(compilerOptimize == true ? 1 : 0) +
sourceFiles.size()];
args[0] = "-d";
args[1] = classDir;
args[2] = "-classpath";
args[3] = classpathString;
// args[4]="-DnonBatchMode";
int baseIndex = 4;
if (compilerDebug) {
args[baseIndex++] = "-g";
}
if (compilerOptimize) {
args[baseIndex++] = "-O";
}
for (int i = 0; i < sourceFiles.size(); ++i) {
args[baseIndex + i] = (String)sourceFiles.get(i);
}
// ByteArrayOutputStream javacOutput = new ByteArrayOutputStream();
JavaCompilerHelper compilerHelper = new JavaCompilerHelper(System.out);
boolean result = compilerHelper.compile(args);
if (!result) {
System.out.println("wscompile.compilation Failed");
}
}
}
protected String createClasspathString() {
if (userClasspath == null) {
userClasspath = "";
}
String jcp = userClasspath + File.pathSeparator + System.getProperty("java.class.path");
return jcp;
}
}
///////////////////////////////////////////////////////////////////
class JavaCompilerHelper {
public JavaCompilerHelper(OutputStream out) {
this.out = out;
}
public boolean compile(String[] args) {
return internalCompile(args);
}
protected boolean internalCompile(String[] args) {
System.out.println("Args: ");
for(String arg : args){
System.out.print(arg+" ");
}
System.out.println();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class comSunToolsJavacMainClass = null;
try {
/* try to use the new compiler */
comSunToolsJavacMainClass =
cl.loadClass("com.sun.tools.javac.Main");
try {
Method compileMethod =
comSunToolsJavacMainClass.getMethod(
"compile",
compile141MethodSignature);
try {
Object result =
compileMethod.invoke(
null,
new Object[] { args, new PrintWriter(out)});
if (!(result instanceof Integer)) {
return false;
}
return ((Integer) result).intValue() == 0;
} catch (IllegalAccessException e3) {
return false;
} catch (IllegalArgumentException e3) {
return false;
} catch (InvocationTargetException e3) {
return false;
}
} catch (NoSuchMethodException e2) {
System.out.println("ERROR: Compile failed with error:" + e2.toString() );
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
return false;
} catch (SecurityException e) {
return false;
}
return true;
}
protected String getGenericErrorMessage() {return "javacompiler.error"; }
protected void run() { }
protected boolean parseArguments(String[] args) {return false;}
protected OutputStream out;
protected static final Class[] compile141MethodSignature;
static
{
compile141MethodSignature = new Class[2];
compile141MethodSignature[0] = (new String[0]).getClass();
compile141MethodSignature[1] = PrintWriter.class;
}
}
| 7,402 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
JarFromManifestFailure.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Paths/6638501/JarFromManifestFailure.java | /*
* Copyright (c) 2007, 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 6638501
* @summary REGRESSION: Java Compiler cannot find jar files referenced by other
* @run main JarFromManifestFailure
*/
import java.io.*;
import java.nio.*;
import java.util.*;
import java.util.jar.*;
import javax.tools.*;
import javax.tools.StandardJavaFileManager.*;
public class JarFromManifestFailure {
static File testSrc = new File(System.getProperty("test.src", "."));
static File testClasses = new File(System.getProperty("test.classes", "."));
public static void main(String... args) throws Exception {
compile(testClasses, null, new File(testSrc, "HelloLib/test/HelloImpl.java"), new File(testSrc, "WsCompileExample.java"));
File libFile = new File(testClasses, "lib");
libFile.mkdir();
jar(new File(libFile, "HelloLib.jar"), new ArrayList(), testClasses, new File("test"));
ArrayList arList = new ArrayList();
arList.add(new File("HelloLib.jar"));
jar(new File(libFile, "JarPointer.jar"), arList, testClasses);
String[] args1 = {
"-d", ".",
"-cp", new File(libFile, "JarPointer.jar").getPath().replace('\\', '/'),
new File(testSrc, "test/SayHello.java").getPath().replace('\\', '/')
};
System.err.println("First compile!!!");
if (com.sun.tools.javac.Main.compile(args1) != 0) {
throw new AssertionError("Failure in first compile!");
}
System.err.println("Second compile!!!");
args1 = new String[] {
"-d", ".",
"-cp", new File(libFile, "JarPointer.jar").getPath().replace('\\', '/'),
new File(testSrc, "test1/SayHelloToo.java").getPath().replace('\\', '/')
};
if (com.sun.tools.javac.Main.compile(args1) != 0) {
throw new AssertionError("Failure in second compile!");
}
}
static void compile(File classOutDir, Iterable<File> classPath, File... files) {
System.err.println("compile...");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
Iterable<? extends JavaFileObject> fileObjects =
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
List<String> options = new ArrayList<String>();
if (classOutDir != null) {
options.add("-d");
options.add(classOutDir.getPath());
}
if (classPath != null) {
options.add("-classpath");
options.add(join(classPath, File.pathSeparator));
}
options.add("-verbose");
JavaCompiler.CompilationTask task =
compiler.getTask(null, fm, null, options, null, fileObjects);
if (!task.call())
throw new AssertionError("compilation failed");
}
static void jar(File jar, Iterable<File> classPath, File base, File... files)
throws IOException {
System.err.println("jar...");
Manifest m = new Manifest();
if (classPath != null) {
Attributes mainAttrs = m.getMainAttributes();
mainAttrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
mainAttrs.put(Attributes.Name.CLASS_PATH, join(classPath, " "));
}
OutputStream out = new BufferedOutputStream(new FileOutputStream(jar));
JarOutputStream j = new JarOutputStream(out, m);
add(j, base, files);
j.close();
}
static void add(JarOutputStream j, File base, File... files) throws IOException {
if (files == null)
return;
for (File f: files)
add(j, base, f);
}
static void add(JarOutputStream j, File base, File file) throws IOException {
File f = new File(base, file.getPath());
if (f.isDirectory()) {
JarEntry e = new JarEntry(new String(file.getPath() + File.separator).replace('\\', '/'));
e.setSize(file.length());
j.putNextEntry(e);
String[] children = f.list();
if (children != null) {
for (String c: children) {
add(j, base, new File(file, c));
}
}
} else {
JarEntry e = new JarEntry(file.getPath().replace('\\', '/'));
e.setSize(f.length());
j.putNextEntry(e);
j.write(read(f));
j.closeEntry();
}
}
static byte[] read(File f) throws IOException {
byte[] buf = new byte[(int) f.length()];
BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
int offset = 0;
while (offset < buf.length) {
int n = in.read(buf, offset, buf.length - offset);
if (n < 0)
throw new EOFException();
offset += n;
}
return buf;
}
static <T> Iterable<T> iterable(T single) {
return Collections.singleton(single);
}
static <T> String join(Iterable<T> iter, String sep) {
StringBuilder p = new StringBuilder();
for (T t: iter) {
if (p.length() > 0)
p.append(' ');
p.append(t);
}
return p.toString();
}
}
| 6,313 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SayHello.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Paths/6638501/test/SayHello.java | /*
* Copyright (c) 2007, 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 test.HelloImpl;
public class SayHello extends HelloImpl {
public static void main(String... args) {
new SayHello().Hello();
}
}
| 1,201 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SayHelloToo.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Paths/6638501/test1/SayHelloToo.java | /*
* Copyright (c) 2007, 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 test.HelloImpl;
public class SayHelloToo extends HelloImpl {
public static void main(String... args) {
new SayHelloToo().Hello();
}
}
| 1,207 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
HelloImpl.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/Paths/6638501/HelloLib/test/HelloImpl.java | /*
* Copyright (c) 2007, 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 test;
public class HelloImpl {
public void Hello() {
java.lang.System.out.println("Hello");
}
}
| 1,171 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
HashCollisionTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/HashCollisionTest.java | /*
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7004029
* @summary Ensure Scope impl can cope with hash collisions
*/
import java.lang.reflect.*;
import java.io.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Scope.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.file.JavacFileManager;
import static com.sun.tools.javac.code.Kinds.*;
public class HashCollisionTest {
public static void main(String... args) throws Exception {
new HashCollisionTest().run();
}
void run() throws Exception {
// set up basic environment for test
Context context = new Context();
JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
names = Names.instance(context); // Name.Table impls tied to an instance of Names
symtab = Symtab.instance(context);
// determine hashMask for an empty scope
Scope emptyScope = new Scope(symtab.unnamedPackage); // any owner will do
Field sHashMask = Scope.class.getDeclaredField("hashMask");
sHashMask.setAccessible(true);
scopeHashMask = sHashMask.getInt(emptyScope);
log("scopeHashMask: " + scopeHashMask);
// 1. determine the Name.hashCode of "Entry", and therefore the index of
// Entry in an empty scope. i.e. name.hashCode() & Scope.hashMask
Name entry = names.fromString("Entry");
// 2. create names of the form *$Entry until we find a name with a
// hashcode which yields the same index as Entry in an empty scope.
// Since Name.hashCode is a function of position (and not content) it
// should work to create successively longer names until one with the
// desired characteristics is found.
Name outerName;
Name innerName;
StringBuilder sb = new StringBuilder("C");
int i = 0;
do {
sb.append(Integer.toString(i % 10));
innerName = names.fromString(sb + "$Entry");
} while (!clash(entry, innerName) && (++i) < MAX_TRIES);
if (clash(entry, innerName)) {
log("Detected expected hash collision for " + entry + " and " + innerName
+ " after " + i + " tries");
} else {
throw new Exception("No potential collision found after " + i + " tries");
}
outerName = names.fromString(sb.toString());
/*
* Now we can set up the scenario.
*/
// 3. Create a nested class named Entry
ClassSymbol cc = createClass(names.fromString("C"), symtab.unnamedPackage);
ClassSymbol ce = createClass(entry, cc);
// 4. Create a package containing a nested class using the name from 2
PackageSymbol p = new PackageSymbol(names.fromString("p"), symtab.rootPackage);
p.members_field = new Scope(p);
ClassSymbol inner = createClass(innerName, p);
// we'll need this later when we "rename" cn
ClassSymbol outer = createClass(outerName, p);
// 5. Create a star-import scope
log ("createStarImportScope");
// if StarImportScope exists, use it, otherwise, for testing legacy code,
// fall back on ImportScope
Scope starImportScope;
Method importAll;
PackageSymbol pkg = new PackageSymbol(names.fromString("pkg"), symtab.rootPackage);
try {
Class<?> c = Class.forName("com.sun.tools.javac.code.Scope$StarImportScope");
Constructor ctor = c.getDeclaredConstructor(new Class[] { Symbol.class });
importAll = c.getDeclaredMethod("importAll", new Class[] { Scope.class });
starImportScope = (Scope) ctor.newInstance(new Object[] { pkg });
} catch (ClassNotFoundException e) {
starImportScope = new ImportScope(pkg);
importAll = null;
}
dump("initial", starImportScope);
// 6. Insert the contents of the package from 4.
Scope p_members = p.members();
if (importAll != null) {
importAll.invoke(starImportScope, p_members);
} else {
Scope fromScope = p_members;
Scope toScope = starImportScope;
// The following lines are taken from MemberEnter.importAll,
// before the use of StarImportScope.importAll.
for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) {
if (e.sym.kind == TYP && !toScope.includes(e.sym))
toScope.enter(e.sym, fromScope);
}
}
dump("imported p", starImportScope);
// 7. Insert the class from 3.
starImportScope.enter(ce, cc.members_field);
dump("imported ce", starImportScope);
/*
* Set the trap.
*/
// 8. Rename the nested class to Entry. so that there is a bogus entry in the star-import scope
p.members_field.remove(inner);
inner.name = entry;
inner.owner = outer;
outer.members_field.enter(inner);
// 9. Lookup Entry
Scope.Entry e = starImportScope.lookup(entry);
dump("final", starImportScope);
if (e.sym == null)
throw new Exception("symbol not found: " + entry);
}
/*
* Check for a (probable) hash collision in an empty scope.
*/
boolean clash(Name n1, Name n2) {
log(n1 + " hc:" + n1.hashCode() + " v:" + (n1.hashCode() & scopeHashMask) + ", " +
n2 + " hc:" + n2.hashCode() + " v:" + (n2.hashCode() & scopeHashMask));
return (n1.hashCode() & scopeHashMask) == (n2.hashCode() & scopeHashMask);
}
/**
* Create a class symbol, init the members scope, and add it to owner's scope.
*/
ClassSymbol createClass(Name name, Symbol owner) {
ClassSymbol sym = new ClassSymbol(0, name, owner);
sym.members_field = new Scope(sym);
if (owner != symtab.unnamedPackage)
owner.members().enter(sym);
return sym;
}
/**
* Dump the contents of a scope to System.err.
*/
void dump(String label, Scope s) throws Exception {
dump(label, s, System.err);
}
/**
* Dump the contents of a scope to a stream.
*/
void dump(String label, Scope s, PrintStream out) throws Exception {
out.println(label);
Field sTable = Scope.class.getDeclaredField("table");
sTable.setAccessible(true);
out.println("owner:" + s.owner);
Scope.Entry[] table = (Scope.Entry[]) sTable.get(s);
for (int i = 0; i < table.length; i++) {
if (i > 0)
out.print(", ");
out.print(i + ":" + toString(table[i], table, false));
}
out.println();
}
/**
* Create a string showing the contents of an entry, using the table
* to help identify cross-references to other entries in the table.
* @param e the entry to be shown
* @param table the table containing the other entries
*/
String toString(Scope.Entry e, Scope.Entry[] table, boolean ref) {
if (e == null)
return "null";
if (e.sym == null)
return "sent"; // sentinel
if (ref) {
int index = indexOf(table, e);
if (index != -1)
return String.valueOf(index);
}
return "(" + e.sym.name + ":" + e.sym
+ ",shdw:" + toString(e.next(), table, true)
+ ",sibl:" + toString(e.sibling, table, true)
+ ((e.sym.owner != e.scope.owner)
? (",BOGUS[" + e.sym.owner + "," + e.scope.owner + "]")
: "")
+ ")";
}
<T> int indexOf(T[] array, T item) {
for (int i = 0; i < array.length; i++) {
if (array[i] == item)
return i;
}
return -1;
}
/**
* Write a message to stderr.
*/
void log(String msg) {
System.err.println(msg);
}
int MAX_TRIES = 100; // max tries to find a hash clash before giving up.
int scopeHashMask;
Names names;
Symtab symtab;
}
| 9,229 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
StarImportTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/StarImportTest.java | /*
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7004029
* @summary Basher for star-import scopes
*/
import java.lang.reflect.*;
import java.util.*;
import java.util.List;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Scope.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.file.JavacFileManager;
import static com.sun.tools.javac.code.Kinds.*;
public class StarImportTest {
public static void main(String... args) throws Exception {
new StarImportTest().run(args);
}
void run(String... args) throws Exception {
int count = 1;
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals("-seed") && (i + 1 < args.length))
seed = Long.parseLong(args[++i]);
else if(arg.equals("-tests") && (i + 1 < args.length))
count = Integer.parseInt(args[++i]);
else
throw new Exception("unknown arg: " + arg);
}
rgen = new Random(seed);
for (int i = 0; i < count; i++) {
Test t = new Test();
t.run();
}
if (errors > 0)
throw new Exception(errors + " errors found");
}
/**
* Select a random element from an array of choices.
*/
<T> T random(T... choices) {
return choices[rgen.nextInt(choices.length)];
}
/**
* Write a message to stderr.
*/
void log(String msg) {
System.err.println(msg);
}
/**
* Write a message to stderr, and dump a scope.
*/
void log(String msg, Scope s) {
System.err.print(msg);
System.err.print(": ");
String sep = "(";
for (Scope.Entry se = s.elems; se != null; se = se.sibling) {
for (Scope.Entry e = se; e.sym != null; e = e.next()) {
System.err.print(sep + e.sym.name + ":" + e.sym);
sep = ",";
}
System.err.print(")");
sep = ", (";
}
System.err.println();
}
/**
* Write an error message to stderr.
*/
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
Random rgen;
long seed = 0;
int errors;
enum SetupKind { NAMES, PACKAGE, CLASS };
static final int MAX_SETUP_COUNT = 50;
static final int MAX_SETUP_NAME_COUNT = 20;
static final int MAX_SETUP_PACKAGE_COUNT = 20;
static final int MAX_SETUP_CLASS_COUNT = 20;
/** Class to encapsulate a test run. */
class Test {
/** Run the test. */
void run() throws Exception {
log ("starting test");
setup();
createStarImportScope();
test();
}
/**
* Setup env by creating pseudo-random collection of names, packages and classes.
*/
void setup() {
log ("setup");
context = new Context();
JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
names = Names.instance(context); // Name.Table impls tied to an instance of Names
symtab = Symtab.instance(context);
int setupCount = rgen.nextInt(MAX_SETUP_COUNT);
for (int i = 0; i < setupCount; i++) {
switch (random(SetupKind.values())) {
case NAMES:
setupNames();
break;
case PACKAGE:
setupPackage();
break;
case CLASS:
setupClass();
break;
}
}
}
/**
* Set up a random number of names.
*/
void setupNames() {
int count = rgen.nextInt(MAX_SETUP_NAME_COUNT);
log("setup: creating " + count + " new names");
for (int i = 0; i < count; i++) {
names.fromString("n" + (++nextNameSerial));
}
}
/**
* Set up a package containing a random number of member elements.
*/
void setupPackage() {
Name name = names.fromString("p" + (++nextPackageSerial));
int count = rgen.nextInt(MAX_SETUP_PACKAGE_COUNT);
log("setup: creating package " + name + " with " + count + " entries");
PackageSymbol p = new PackageSymbol(name, symtab.rootPackage);
p.members_field = new Scope(p);
for (int i = 0; i < count; i++) {
String outer = name + "c" + i;
String suffix = random(null, "$Entry", "$Entry2");
ClassSymbol c1 = createClass(names.fromString(outer), p);
// log("setup: created " + c1);
if (suffix != null) {
ClassSymbol c2 = createClass(names.fromString(outer + suffix), p);
// log("setup: created " + c2);
}
}
// log("package " + p, p.members_field);
packages.add(p);
imports.add(p);
}
/**
* Set up a class containing a random number of member elements.
*/
void setupClass() {
Name name = names.fromString("c" + (++nextClassSerial));
int count = rgen.nextInt(MAX_SETUP_CLASS_COUNT);
log("setup: creating class " + name + " with " + count + " entries");
ClassSymbol c = createClass(name, symtab.unnamedPackage);
// log("setup: created " + c);
for (int i = 0; i < count; i++) {
ClassSymbol ic = createClass(names.fromString("Entry" + i), c);
// log("setup: created " + ic);
}
classes.add(c);
imports.add(c);
}
/**
* Create a star-import scope and a model therof, from the packages and
* classes created by setupPackages and setupClasses.
* @throws Exception for fatal errors, such as from reflection
*/
void createStarImportScope() throws Exception {
log ("createStarImportScope");
PackageSymbol pkg = new PackageSymbol(names.fromString("pkg"), symtab.rootPackage);
// if StarImportScope exists, use it, otherwise, for testing legacy code,
// fall back on ImportScope
Method importAll;
try {
Class<?> c = Class.forName("com.sun.tools.javac.code.Scope$StarImportScope");
Constructor ctor = c.getDeclaredConstructor(new Class[] { Symbol.class });
importAll = c.getDeclaredMethod("importAll", new Class[] { Scope.class });
starImportScope = (Scope) ctor.newInstance(new Object[] { pkg });
} catch (ClassNotFoundException e) {
starImportScope = new ImportScope(pkg);
importAll = null;
}
starImportModel = new Model();
for (Symbol imp: imports) {
Scope members = imp.members();
if (importAll != null) {
// log("importAll", members);
importAll.invoke(starImportScope, members);
} else {
Scope fromScope = members;
Scope toScope = starImportScope;
// The following lines are taken from MemberEnter.importAll,
// before the use of StarImportScope.importAll.
for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) {
if (e.sym.kind == TYP && !toScope.includes(e.sym))
toScope.enter(e.sym, fromScope);
}
}
for (Scope.Entry e = members.elems; e != null; e = e.sibling) {
starImportModel.enter(e.sym);
}
}
// log("star-import scope", starImportScope);
starImportModel.check(starImportScope);
}
/**
* The core of the test. In a random order, move nested classes from
* the package in which they created to the class which should own them.
*/
void test() {
log ("test");
List<ClassSymbol> nestedClasses = new LinkedList<ClassSymbol>();
for (PackageSymbol p: packages) {
for (Scope.Entry se = p.members_field.elems; se != null; se = se.sibling) {
if (se.sym.name.toString().contains("$"))
nestedClasses.add((ClassSymbol) se.sym);
}
}
for (int i = nestedClasses.size(); i > 0; i--) {
// select a random nested class to move from package to class
ClassSymbol sym = nestedClasses.remove(rgen.nextInt(i));
log("adjusting class " + sym);
// remove from star import model
starImportModel.remove(sym);
String s = sym.name.toString();
int dollar = s.indexOf("$");
// owner should be a package
assert (sym.owner.kind == PCK);
// determine new owner
Name outerName = names.fromString(s.substring(0, dollar));
// log(sym + " owner: " + sym.owner, sym.owner.members());
Scope.Entry outerEntry = sym.owner.members().lookup(outerName);
ClassSymbol outer = (ClassSymbol) outerEntry.sym;
// log("outer: " + outerName + " " + outer);
// remove from package
sym.owner.members().remove(sym);
// rename and insert into class
sym.name = names.fromString(s.substring(dollar + 1));
outer.members().enter(sym);
sym.owner = outer;
// verify
starImportModel.check(starImportScope);
}
}
ClassSymbol createClass(Name name, Symbol owner) {
ClassSymbol sym = new ClassSymbol(0, name, owner);
sym.members_field = new Scope(sym);
if (owner != symtab.unnamedPackage)
owner.members().enter(sym);
return sym;
}
Context context;
Symtab symtab;
Names names;
int nextNameSerial;
List<PackageSymbol> packages = new ArrayList<PackageSymbol>();
int nextPackageSerial;
List<ClassSymbol> classes = new ArrayList<ClassSymbol>();
List<Symbol> imports = new ArrayList<Symbol>();
int nextClassSerial;
Scope starImportScope;
Model starImportModel;
}
class Model {
private Map<Name, Set<Symbol>> map = new HashMap<Name, Set<Symbol>>();
private Set<Symbol> bogus = new HashSet<Symbol>();
void enter(Symbol sym) {
Set<Symbol> syms = map.get(sym.name);
if (syms == null)
map.put(sym.name, syms = new LinkedHashSet<Symbol>());
syms.add(sym);
}
void remove(Symbol sym) {
Set<Symbol> syms = map.get(sym.name);
if (syms == null)
error("no entries for " + sym.name + " found in reference model");
else {
boolean ok = syms.remove(sym);
if (ok) {
// log(sym.name + "(" + sym + ") removed from reference model");
} else {
error(sym.name + " not found in reference model");
}
if (syms.isEmpty())
map.remove(sym.name);
}
}
/**
* Check the contents of a scope
*/
void check(Scope scope) {
// First, check all entries in scope are in map
int bogusCount = 0;
for (Scope.Entry se = scope.elems; se != null; se = se.sibling) {
Symbol sym = se.sym;
if (sym.owner != se.scope.owner) {
if (bogus.contains(sym)) {
bogusCount++;
} else {
log("Warning: " + sym.name + ":" + sym + " appears to be bogus");
bogus.add(sym);
}
} else {
Set<Symbol> syms = map.get(sym.name);
if (syms == null) {
error("check: no entries found for " + sym.name + ":" + sym + " in reference map");
} else if (!syms.contains(sym)) {
error("check: symbol " + sym.name + ":" + sym + " not found in reference map");
}
}
}
if (bogusCount > 0) {
log("Warning: " + bogusCount + " other bogus entries previously reported");
}
// Second, check all entries in map are in scope
for (Map.Entry<Name,Set<Symbol>> me: map.entrySet()) {
Name name = me.getKey();
Scope.Entry se = scope.lookup(name);
assert (se != null);
if (se.sym == null) {
error("check: no entries found for " + name + " in scope");
continue;
}
nextSym:
for (Symbol sym: me.getValue()) {
for (Scope.Entry e = se; e.sym != null; e = e.next()) {
if (sym == e.sym)
continue nextSym;
}
error("check: symbol " + sym + " not found in scope");
}
}
}
}
}
| 14,789 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
CompoundScopeTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/7017664/CompoundScopeTest.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 7017664 7036906
* @summary Basher for CompoundScopes
*/
import java.util.Random;
import java.util.Map;
import java.util.HashMap;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Scope.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.file.JavacFileManager;
public class CompoundScopeTest {
public static void main(String... args) throws Exception {
new CompoundScopeTest().run(args);
}
static final int MAX_SYMBOLS_COUNT = 20;
static final int PASSES = 10;
void run(String... args) throws Exception {
int count = PASSES;
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals("-seed") && (i + 1 < args.length))
seed = Long.parseLong(args[++i]);
else if(arg.equals("-tests") && (i + 1 < args.length))
count = Integer.parseInt(args[++i]);
else
throw new Exception("unknown arg: " + arg);
}
rgen = new Random(seed);
for (int i = 0; i < count; i++) {
Test t = new Test();
t.run();
}
if (errors > 0)
throw new Exception(errors + " errors found");
}
/**
* Write a message to stderr.
*/
void log(String msg) {
System.err.println(msg);
}
/**
* Write an error message to stderr.
*/
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
Random rgen;
long seed = 0;
int errors;
/** Class to encapsulate a test run. */
class Test {
List<Symbol> elems = List.nil();
Map<Name, List<Symbol>> shadowedMap = new HashMap<Name, List<Symbol>>();
/** Run the test. */
void run() throws Exception {
log ("starting test");
setup();
Scope[] scopes = { createScope(rgen.nextInt(MAX_SYMBOLS_COUNT)),
createScope(rgen.nextInt(MAX_SYMBOLS_COUNT)),
createScope(rgen.nextInt(MAX_SYMBOLS_COUNT)) };
boolean[][] scopeNesting = { {false, true, false, true},
{false, true, true, true},
{false, false, true, true} };
/**
* We want to generate (and check) the following compound scopes:
* C1 = C(S1, S2, S3)
* C2 = C((S1, S2), S3)
* C3 = C(S1, (S2, S3))
* C3 = C(C(S1, S2, S3))
*/
for (int i = 0 ; i < 4 ; i ++) {
CompoundScope root = new CompoundScope(symtab.noSymbol);
CompoundScope sub = new CompoundScope(symtab.noSymbol);
boolean subAdded = false;
for (int sc = 0 ; sc < 3 ; sc ++) {
if (scopeNesting[sc][i]) {
sub.addSubScope(scopes[sc]);
if (!subAdded) {
root.addSubScope(sub);
subAdded = true;
}
} else {
root.addSubScope(scopes[sc]);
}
}
log("testing scope: " + root);
checkElems(root, null);
checkElems(root, new OddFilter());
checkShadowed(root, null);
checkShadowed(root, new OddFilter());
}
}
class OddFilter implements Filter<Symbol> {
public boolean accepts(Symbol s) {
Name numPart = s.name.subName(1, s.name.length());
return Integer.parseInt(numPart.toString()) % 2 != 0;
}
}
/**
* Create a scope containing a given number of synthetic symbols
*/
Scope createScope(int nelems) {
Scope s = new Scope(symtab.noSymbol);
for (int i = 0 ; i < nelems ; i++) {
Symbol sym = new TypeSymbol(0, names.fromString("s" + i), null, null);
s.enter(sym);
elems = elems.prepend(sym);
List<Symbol> shadowed = shadowedMap.get(sym.name);
if (shadowed == null) {
shadowed = List.nil();
}
shadowedMap.put(sym.name, shadowed.prepend(sym));
}
return s;
}
/**
* Setup compiler context
*/
void setup() {
log ("setup");
context = new Context();
JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
names = Names.instance(context); // Name.Table impls tied to an instance of Names
symtab = Symtab.instance(context);
}
/**
* Check that CompoundScope.getElements() correctly visits all symbols
* in all subscopes (in the correct order)
*/
void checkElems(CompoundScope cs, Filter<Symbol> sf) {
int count = 0;
ListBuffer<Symbol> found = ListBuffer.lb();
List<Symbol> allSymbols = sf == null ?
elems :
filter(elems, sf);
int expectedCount = allSymbols.length();
for (Symbol s : sf == null ? cs.getElements() : cs.getElements(sf)) {
checkSameSymbols(s, allSymbols.head);
allSymbols = allSymbols.tail;
found.append(s);
count++;
}
if (count != expectedCount) {
error("CompoundScope.getElements() did not returned enough symbols");
}
}
/**
* Check that CompoundScope.getElements() correctly visits all symbols
* with a given name in all subscopes (in the correct order)
*/
void checkShadowed(CompoundScope cs, Filter<Symbol> sf) {
for (Map.Entry<Name, List<Symbol>> shadowedEntry : shadowedMap.entrySet()) {
int count = 0;
List<Symbol> shadowed = sf == null ?
shadowedEntry.getValue() :
filter(shadowedEntry.getValue(), sf);
int expectedCount = shadowed.length();
Name name = shadowedEntry.getKey();
for (Symbol s : sf == null ? cs.getElementsByName(name) : cs.getElementsByName(name, sf)) {
checkSameSymbols(s, shadowed.head);
shadowed = shadowed.tail;
count++;
}
if (count != expectedCount) {
error("CompoundScope.lookup() did not returned enough symbols for name " + name);
}
}
}
List<Symbol> filter(List<Symbol> elems, Filter<Symbol> sf) {
ListBuffer<Symbol> res = ListBuffer.lb();
for (Symbol s : elems) {
if (sf.accepts(s)) {
res.append(s);
}
}
return res.toList();
}
void checkSameSymbols(Symbol found, Symbol req) {
if (found != req) {
error("Symbol mismatch - found : " + found + ":" + found.hashCode() + "\n" +
" required : " + req + ":" + req.hashCode());
}
}
Context context;
Symtab symtab;
Names names;
}
}
| 8,569 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ImplementationCacheTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.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 7017664
* @summary Basher for CompoundScopes
*/
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.code.Symbol.*;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import javax.lang.model.element.Element;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.ToolProvider;
import static javax.tools.JavaFileObject.Kind;
public class ImplementationCacheTest {
static class SourceFile extends SimpleJavaFileObject {
final String source = "interface I { void m(); }\n" +
"class A implements I { public void m() {} }\n" +
"class B extends A { }\n";
public SourceFile() {
super(URI.create("test.java"), Kind.SOURCE);
}
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return source;
}
}
public static void main(String[] args) throws IOException {
List<? extends JavaFileObject> files = Arrays.asList(new SourceFile());
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files);
Context ctx = new Context();
JavacFileManager.preRegister(ctx);
checkImplementationCache(ct.analyze(), Types.instance(ctx));
}
static void checkImplementationCache(Iterable<? extends Element> elements, Types types) {
if (types == null) {
throw new AssertionError("problems initializing Types");
}
Symbol a = null;
Symbol b = null;
Symbol i = null;
for (Element e : elements) {
if (e.getSimpleName().contentEquals("A")) {
a = (Symbol)e;
} else if (e.getSimpleName().contentEquals("B")) {
b = (Symbol)e;
} else if (e.getSimpleName().contentEquals("I")) {
i = (Symbol)e;
}
}
if (a == null || b == null || i == null) {
throw new AssertionError("missing class");
}
MethodSymbol I_m = null;
for (Symbol sym : i.members().getElements()) {
if (sym.name.contentEquals("m")) {
I_m = (MethodSymbol)sym;
}
}
if (I_m == null) {
throw new AssertionError("missing method m() in scope of interface I");
}
Symbol impl = I_m.implementation((TypeSymbol)b, types, true);
if (impl == null || impl.owner != a) {
throw new AssertionError("wrong implementation for m() in B");
}
b.members().enter(I_m.clone(b));
Symbol newImpl = I_m.implementation((TypeSymbol)b, types, true);
if (newImpl == impl) {
throw new AssertionError("stale implementation for m() in B");
}
if (newImpl == null || newImpl.owner != b) {
throw new AssertionError("wrong implementation for m() in B");
}
}
}
| 4,312 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6214959.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/T6214959.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6214959
* @summary Compiler fails do produce error message with ODD number of import static
* @author Peter von der Ah\u00e9
* @compile/fail T6214959.java
*/
import static a.Star.*;
import static a.Ambiguous.*;
import static a.Star.*;
public class T6214959 {
{ y(); }
}
| 1,359 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Baz.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/Baz.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test;
public class Baz extends Bar {}
| 1,099 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Bar.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/Bar.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test;
public class Bar {
public final static int ERA = 0;
}
| 1,125 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
StaticImportAccess.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/StaticImportAccess.java | /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6225935
* @summary "import static" accessibility rules for symbols different for no reason
* @author Martin Buchholz
* @compile StaticImportAccess.java
*/
import static java.util.zip.ZipFile.ENDSIG;
public class StaticImportAccess {
public static long i = ENDSIG;
}
| 1,359 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Test.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/Test.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6381787
* @summary Failing Japanese Calendar regression tests
* @author Peter von der Ah\u00e9
* @compile Test.java Bar.java Baz.java
*/
import static test.Bar.*;
import static test.Baz.*;
class Test {
int i = ERA;
}
| 1,305 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6225935.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/T6225935.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6225935
* @summary "import static" accessibility rules for symbols different for no reason
* @author Peter von der Ah\u00e9
* @compile a/Private.java a/Named.java a/Star.java T6225935.java
* @run main/othervm -Xfuture T6225935
*/
import static a.Named.x;
import static a.Named.X;
import static a.Star.*;
public class T6225935 {
public static void main(String[] args) {
X o1 = new X();
Y o2 = new Y();
x();
System.err.println(x);
y();
System.err.println(y);
}
}
| 1,601 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Estatico4.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/Estatico4.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 6214959
* @summary Compiler fails do produce error message with ODD number of import static
* @compile/fail Estatico4.java
*/
import static javax.swing.JLabel.*;
import static java.awt.FlowLayout.*;
import static javax.swing.JLabel.*;
public class Estatico4 {
public static void main(String[] s) {
System.out.println(CENTER);
}
}
| 1,429 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6381787.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/T6381787.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6381787
* @summary Failing Japanese Calendar regression tests
* @author Peter von der Ah\u00e9
* @compile T6381787.java
*/
import static java.util.Calendar.*;
import static java.util.GregorianCalendar.*;
public class T6381787 {
int i = ERA;
Object o = getInstance();
}
| 1,361 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Ambiguous.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/a/Ambiguous.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package a;
public class Ambiguous {
public static void y() {}
}
| 1,121 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Named.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/a/Named.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package a;
public class Named extends Private {}
| 1,102 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Private.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/a/Private.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package a;
class Private {
public static int x = 10;
public static void x() {}
public static int y = 10;
public static void y() {}
public static class X {};
public static class Y {};
}
| 1,262 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Star.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6225935/a/Star.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package a;
public class Star extends Private {}
| 1,101 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6392998.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/6392998/T6392998.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6392998
* @summary Mustang compiler throws AssertionError (beta2-b71 and higher)
* @author Peter von der Ah\u00e9
* @compile T6392998.java
*/
package pck;
import static pck.T6392998.B.C;
import static pck.T6392998.B.*;
public class T6392998 {
public static class A {
public enum C { FOO; }
public static Object C() { return null; }
public enum D { FOO; }
public static Object D() { return null; }
}
public static class B extends A {}
Object o = C.FOO;
Object p = C();
Object q = D.FOO;
Object r = D();
}
| 1,648 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
EagerInterfaceCompletionTest.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.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 7046348
* @summary Regression: javac complains of missing classfile for a seemingly unrelated interface
*/
import java.io.File;
import java.net.URI;
import java.util.Arrays;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.ToolProvider;
public class EagerInterfaceCompletionTest {
JavaCompiler javacTool;
File testDir;
HierarchyKind hierarchyKind;
TestKind testKind;
ActionKind actionKind;
EagerInterfaceCompletionTest(JavaCompiler javacTool, File testDir,
HierarchyKind hierarchyKind, TestKind testKind, ActionKind actionKind) {
this.javacTool = javacTool;
this.hierarchyKind = hierarchyKind;
this.testDir = testDir;
this.testKind = testKind;
this.actionKind = actionKind;
}
void test() {
testDir.mkdirs();
compile(null, hierarchyKind.source);
actionKind.doAction(this);
DiagnosticChecker dc = new DiagnosticChecker();
compile(dc, testKind.source);
if (testKind.completionFailure(actionKind, hierarchyKind) != dc.errorFound) {
if (dc.errorFound) {
error("Unexpected completion failure" +
"\nhierarhcyKind " + hierarchyKind +
"\ntestKind " + testKind +
"\nactionKind " + actionKind);
} else {
error("Missing completion failure " +
"\nhierarhcyKind " + hierarchyKind +
"\ntestKind " + testKind +
"\nactionKind " + actionKind);
}
}
}
void compile(DiagnosticChecker dc, JavaSource... sources) {
try {
CompilationTask ct = javacTool.getTask(null, null, dc,
Arrays.asList("-d", testDir.getAbsolutePath(), "-cp", testDir.getAbsolutePath()),
null, Arrays.asList(sources));
ct.call();
}
catch (Exception e) {
e.printStackTrace();
error("Internal compilation error");
}
}
void removeClass(String classToRemoveStr) {
File classToRemove = new File(testDir, classToRemoveStr);
if (!classToRemove.exists()) {
error("Expected file " + classToRemove + " does not exists in folder " + testDir);
}
classToRemove.delete();
};
void error(String msg) {
System.err.println(msg);
nerrors++;
}
class DiagnosticChecker implements DiagnosticListener<JavaFileObject> {
boolean errorFound = false;
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
errorFound = true;
}
}
//global declarations
enum HierarchyKind {
INTERFACE("interface A { boolean f = false; void m(); }\n" +
"class B implements A { public void m() {} }"),
CLASS("class A { boolean f; void m() {} }\n" +
"class B extends A { void m() {} }"),
ABSTRACT_CLASS("abstract class A { boolean f; abstract void m(); }\n" +
"class B extends A { void m() {} }");
JavaSource source;
private HierarchyKind(String code) {
this.source = new JavaSource("Test1.java", code);
}
}
enum ActionKind {
REMOVE_A("A.class"),
REMOVE_B("B.class");
String classFile;
private ActionKind(String classFile) {
this.classFile = classFile;
}
void doAction(EagerInterfaceCompletionTest test) {
test.removeClass(classFile);
};
}
enum TestKind {
ACCESS_ONLY("class C { B b; }"),
SUPER("class C extends B {}"),
METHOD("class C { void test(B b) { b.m(); } }"),
FIELD("class C { void test(B b) { boolean b2 = b.f; } }"),
CONSTR("class C { void test() { new B(); } }");
JavaSource source;
private TestKind(final String code) {
this.source = new JavaSource("Test2.java", code);
}
boolean completionFailure(ActionKind ak, HierarchyKind hk) {
switch (this) {
case ACCESS_ONLY:
case CONSTR: return ak == ActionKind.REMOVE_B;
case FIELD:
case SUPER: return true;
case METHOD: return hk != HierarchyKind.INTERFACE || ak == ActionKind.REMOVE_B;
default: throw new AssertionError("Unexpected test kind " + this);
}
}
}
public static void main(String[] args) throws Exception {
String SCRATCH_DIR = System.getProperty("user.dir");
JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
int n = 0;
for (HierarchyKind hierarchyKind : HierarchyKind.values()) {
for (TestKind testKind : TestKind.values()) {
for (ActionKind actionKind : ActionKind.values()) {
File testDir = new File(SCRATCH_DIR, "test"+n);
new EagerInterfaceCompletionTest(javacTool, testDir, hierarchyKind, testKind, actionKind).test();
n++;
}
}
}
if (nerrors > 0) {
throw new AssertionError("Some errors have been detected");
}
}
static class JavaSource extends SimpleJavaFileObject {
String source;
public JavaSource(String filename, String source) {
super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
this.source = source;
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return source;
}
}
static int nerrors = 0;
}
| 6,984 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ProtectedInnerClass_2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java | /*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please 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 4307565
* @summary Verify that access to inaccessable protected inner class is rejected.
* @author William Maddox (maddox)
*
* @run compile p1/ProtectedInnerClass1.java
* @run compile/fail p2/ProtectedInnerClass3.java
*/
class Dummy {}
| 1,314 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ProtectedInnerClass1.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ProtectedInnerClass/p1/ProtectedInnerClass1.java | /*
* Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Auxiliary file for test for 4087314.
* Verify allowed access to protected class from another package.
* This file must be compiled prior to compiling p2.ProtectedInnerClass2.
* It is that compilation that will either succeed or fail.
*/
package p1;
public class ProtectedInnerClass1 {
protected class Foo {
public String getBar() { return "bar"; }
}
}
| 1,438 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ProtectedInnerClass3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass3.java | /*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Auxiliary file for ProtectedInnerClass_2.java (bugid 4307565)
*/
package p2;
public class ProtectedInnerClass3 {
void test() {
p1.ProtectedInnerClass1.Foo x;
}
}
| 1,233 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ProtectedInnerClass2.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass2.java | /*
* Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Auxiliary file for test for 4087314.
* Verify allowed access to protected class from another package.
*
* This file should compile and run successfully.
* Note that class p1.ProtectedInnerClass1 must be compiled first.
*/
package p2;
public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1
{
class Bug extends Foo {
String getBug() { return getBar(); }
}
public static void main(String[] args) {
ProtectedInnerClass2 x = new ProtectedInnerClass2();
Bug y = x.new Bug();
System.out.println(y.getBug());
}
}
| 1,636 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6304921.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6304921/T6304921.java | /*
* @test (important: no SCCS keywords to affect offsets in golden file.) /nodynamiccopyright/
* @bug 6304921
* @compile/fail/ref=T6304921.out -XDcompilePolicy=bytodo -XDrawDiagnostics -Xjcov -Xlint:all,-path -Werror T6304921.java
*/
import java.util.ArrayList;
import java.util.List;
class T6304921 {
void m1(int i) {
switch (i) {
case 1:
i++;
// fallthrough
default:
}
try {
i++;
}
finally {
throw new Error();
// finally does not complete normally
}
}
void m2() {
List<Integer> list = new ArrayList();
}
}
class X {
void m1() {
System.orr.println("abc"); // name not found
}
boolean m2() {
return 123 + true; // bad binary expression
}
}
| 832 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TestLog.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6304921/TestLog.java | /*
* Copyright (c) 2005, 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 6304912
* @summary unit test for Log
*/
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.parser.Parser;
import com.sun.tools.javac.parser.ParserFactory;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeScanner;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.JCDiagnostic;
import com.sun.tools.javac.util.Options;
public class TestLog
{
public static void main(String... args) throws IOException {
test(false);
test(true);
}
static void test(boolean genEndPos) throws IOException {
Context context = new Context();
Options options = Options.instance(context);
options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");
Log log = Log.instance(context);
log.multipleErrors = true;
JavacFileManager.preRegister(context);
ParserFactory pfac = ParserFactory.instance(context);
final String text =
"public class Foo {\n"
+ " public static void main(String[] args) {\n"
+ " if (args.length == 0)\n"
+ " System.out.println(\"no args\");\n"
+ " else\n"
+ " System.out.println(args.length + \" args\");\n"
+ " }\n"
+ "}\n";
JavaFileObject fo = new StringJavaFileObject("Foo", text);
log.useSource(fo);
CharSequence cs = fo.getCharContent(true);
Parser parser = pfac.newParser(cs, false, genEndPos, false);
JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
log.setEndPosTable(fo, tree.endPositions);
TreeScanner ts = new LogTester(log, tree.endPositions);
ts.scan(tree);
check(log.nerrors, 4, "errors");
check(log.nwarnings, 4, "warnings");
}
private static void check(int found, int expected, String name) {
if (found == expected)
System.err.println(found + " " + name + " found, as expected.");
else {
System.err.println("incorrect number of " + name + " found.");
System.err.println("expected: " + expected);
System.err.println(" found: " + found);
throw new IllegalStateException("test failed");
}
}
private static class LogTester extends TreeScanner {
LogTester(Log log, java.util.Map<JCTree, Integer> endPositions) {
this.log = log;
this.endPositions = endPositions;
}
public void visitIf(JCTree.JCIf tree) {
JCDiagnostic.DiagnosticPosition nil = null;
// generate dummy messages to exercise the log API
log.error("not.stmt");
log.error(tree.pos, "not.stmt");
log.error(tree.pos(), "not.stmt");
log.error(nil, "not.stmt");
log.warning("div.zero");
log.warning(tree.pos, "div.zero");
log.warning(tree.pos(), "div.zero");
log.warning(nil, "div.zero");
}
private Log log;
private java.util.Map<JCTree, Integer> endPositions;
}
private static class StringJavaFileObject extends SimpleJavaFileObject {
StringJavaFileObject(String name, String text) {
super(URI.create(name), JavaFileObject.Kind.SOURCE);
this.text = text;
}
public CharSequence getCharContent(boolean b) {
return text;
}
public InputStream openInputStream() {
throw new UnsupportedOperationException();
}
public OutputStream openOutputStream() {
throw new UnsupportedOperationException();
}
private String text;
}
}
| 4,995 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Void.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Void.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Void
{
}
| 1,101 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Double.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Double.java | package java.lang;
public class Double extends Number
{
public static Double valueOf(double v) {
return new Double(v);
}
public Double(double v) {
value = v;
}
public double doubleValue() {
return value;
}
private double value;
}
| 286 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Serializable.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Serializable.java | /*
* Copyright (c) 2007, 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 java.io;
public interface Serializable {
}
| 1,110 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Boolean.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Boolean.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Boolean
{
public static Boolean valueOf(boolean v) {
return new Boolean(v);
}
public Boolean(boolean v) {
value = v;
}
public boolean booleanValue() {
return value;
}
private boolean value;
}
| 1,338 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Main.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Main.java | /*
* Copyright (c) 2007, 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 6627364 6627366
* @summary Synthesize important classes if they are missing from the (boot)classpath
*/
import java.io.*;
import java.util.*;
public class Main
{
File testSrc = new File(System.getProperty("test.src"));
public static void main(String[] args) throws Exception {
new Main().run();
}
public void run() throws Exception {
// compile with standard bootclasspath
compile(true, "Test.java");
// compile with various missing system classes
List<String> base_files = Arrays.asList(
"Boolean.java",
"Byte.java",
"Character.java",
"Integer.java",
"Long.java",
"Number.java",
"Object.java",
"Short.java",
"Void.java"
);
List<String> extra_files = Arrays.asList(
"Double.java",
"Float.java",
"Cloneable.java",
"Serializable.java"
);
List<String> files = new ArrayList<String>();
files.addAll(base_files);
files.add("Test.java");
compile(false, files);
for (String f: extra_files) {
files = new ArrayList<String>();
files.addAll(base_files);
files.addAll(extra_files);
files.remove(f);
files.add("Test.java");
compile(false, files);
}
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
void compile(boolean stdBootClassPath, String... files) {
compile(stdBootClassPath, Arrays.asList(files));
}
void compile(boolean stdBootClassPath, List<String> files) {
File empty = new File("empty");
empty.mkdirs();
List<String> args = new ArrayList<String>();
args.add("-classpath");
args.add("empty");
if (!stdBootClassPath) {
args.add("-bootclasspath");
args.add("empty");
}
args.add("-d");
args.add(".");
for (String f: files)
args.add(new File(testSrc, f).getPath());
System.out.println("Compile: " + args);
StringWriter out = new StringWriter();
int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]),
new PrintWriter(out));
System.out.println(out.toString());
System.out.println("result: " + rc);
System.out.println();
if (rc != 0)
errors++;
}
private int errors;
}
| 3,648 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Character.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Character.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Character
{
public static Character valueOf(char v) {
return new Character(v);
}
public Character(char v) {
value = v;
}
public char characterValue() {
return value;
}
private char value;
}
| 1,336 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Short.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Short.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Short extends Number
{
public static Short valueOf(short v) {
return new Short(v);
}
public Short(short v) {
value = v;
}
public short shortValue() {
return value;
}
private short value;
}
| 1,335 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Object.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Object.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Object
{
}
| 1,102 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Cloneable.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Cloneable.java | /*
* Copyright (c) 2007, 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 java.lang;
public interface Cloneable {
}
| 1,109 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Number.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Number.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Number
{
}
| 1,103 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Byte.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Byte.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Byte
{
public static Byte valueOf(byte v) {
return new Byte(v);
}
public Byte(byte v) {
value = v;
}
public byte byteValue() {
return value;
}
private byte value;
}
| 1,311 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Float.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Float.java | package java.lang;
public class Float extends Number
{
public static Float valueOf(float v) {
return new Float(v);
}
public Float(float v) {
value = v;
}
public float floatValue() {
return value;
}
private float value;
}
| 277 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Integer.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Integer.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Integer extends Number
{
public static Integer valueOf(int v) {
return new Integer(v);
}
public Integer(int v) {
value = v;
}
public int integerValue() {
return value;
}
private int value;
}
| 1,337 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Test.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Test.java | /*
* Copyright (c) 2007, 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.
*/
// This code (indirectly) requires the presence of
// Cloneable and Serializable (supertypes for Java arrays)
// Double and Float (for boxing/unboxing)
public class Test
{
Object f(boolean b, int[] array) {
return b ? array : 2;
}
}
| 1,307 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Long.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/synthesize/Long.java | /*
* Copyright (c) 2007, 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 java.lang;
public class Long extends Number
{
public static Long valueOf(long v) {
return new Long(v);
}
public Long(long v) {
value = v;
}
public long longValue() {
return value;
}
private long value;
}
| 1,326 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6520152/T.java | import java.io.Serializable;
public class T {
public static void main(String[] args) {
T t = new T();
t.createObject();
}
public Object createObject() {
return new Serializable() {
void method() {
}
};
}
}
| 280 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6520152.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6520152/T6520152.java | /**
* @test
* @bug 6520152
* @summary ACC_FINAL flag for anonymous classes shouldn't be set
* @compile T.java
* @run main/othervm T6520152
*/
import java.lang.reflect.Method;
import static java.lang.reflect.Modifier.*;
public class T6520152 {
public static void main(String [] args) throws Exception {
Class clazz = Class.forName("T$1");
if ((clazz.getModifiers() & FINAL) != 0) {
throw new RuntimeException("Failed: " + clazz.getName() + " shouldn't be marked final.");
}
}
}
| 533 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6435291.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T6435291/T6435291.java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6435291
* @summary javac shouldn't throw NPE while compiling invalid RuntimeInvisibleParameterAnnotations
* @author Wei Tao
* @run main/othervm T6435291
*/
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.jvm.ClassReader.BadClassFile;
import com.sun.tools.javac.main.JavaCompiler;
import javax.tools.ToolProvider;
public class T6435291 {
public static void main(String... args) {
javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null);
JavaCompiler compiler = JavaCompiler.instance(task.getContext());
try {
compiler.resolveIdent("T").complete();
} catch (BadClassFile e) {
System.err.println("Passed: expected completion failure " + e.getClass().getName());
return;
} catch (Exception e) {
throw new RuntimeException("Failed: unexpected exception");
}
throw new RuntimeException("Failed: no error reported");
}
}
| 2,142 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
T6231246.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/T6231246/T6231246.java | /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6231246
* @summary Javac crash with -g:none
* @author Peter von der Ah\u00e9
* @compile -g:none T6231246.java
*/
public class T6231246 {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
| 1,321 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ProtectedAccess_3.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/protectedAccess/ProtectedAccess_3.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 4804371
* @summary javac and java disagree about protected; results in a VerifyError
* @author gafter
*
* @compile ProtectedAccess_3.java
* @run main ProtectedAccess_3
*/
public class ProtectedAccess_3 {
ProtectedAccess_3() {
new Object() {
public void finalize() throws Throwable {
ProtectedAccess_3.this.finalize();
}
};
}
public static void main(String[] argv) {
new ProtectedAccess_3();
}
}
| 1,555 | 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.