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
T6548436d.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6548436/T6548436d.java
/* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6548436 * @summary Incorrect inconvertible types error * @author Maurizio Cimadamore * * @compile/fail T6548436d.java */ public class T6548436d { static class Base<E extends Comparable<E>> {} static void test(Base<? extends Double> je) { Object o = (Base<Integer>)je; } }
1,378
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6286112.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6286112/T6286112.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 6286112 * @summary Wildcard cast problem * @compile -Xlint:unchecked -Werror T6286112.java */ public class T6286112 { public Object saveA (AbstractClass<?> busObj) { return (ConcreteClass) busObj; } abstract class AbstractClass<B> {} class ConcreteClass extends AbstractClass<String> {} }
1,399
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6557182.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6557182/T6557182.java
/* * @test /nodynamiccopyright/ * @author Maurizio Cimadamore * @bug 6557182 * @summary Unchecked warning *and* inconvertible types * @compile/fail/ref=T6557182.out -XDrawDiagnostics -Xlint:unchecked T6557182.java */ class T6557182 { <T extends Number & Comparable<String>> void test1(T t) { Comparable<Integer> ci = (Comparable<Integer>) t; } <T extends Number & Comparable<? extends Number>> void test2(T t) { Comparable<Integer> ci = (Comparable<Integer>) t; } }
512
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6270087neg.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6270087/T6270087neg.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6270087 6932571 * @summary Javac rejects legal cast * @compile/fail/ref=T6270087neg.out -XDrawDiagnostics T6270087neg.java */ class T6270087neg { static class Foo<X> {} <U extends Integer, V extends String> void test2(Foo<V> lv) { Object o = (Foo<U>) lv; } }
1,359
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6270087.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6270087/T6270087.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6270087 6932571 * @summary Javac rejects legal cast * @compile T6270087.java */ class T6270087 { static class Foo<X> {} <S extends Comparable<S>> void test1(Comparable<Integer> c) { Object o = (Comparable<S>)c; } <U extends Throwable, V extends Runnable> void test2(Foo<V> lv) { Object o = (Foo<U>) lv; } }
1,424
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T4916620.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/4916620/T4916620.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 4916620 * @summary legal cast is rejected * @author Christian Plesner Hansen * @compile/fail -Xlint:unchecked -Werror T4916620.java * @compile -Xlint:unchecked T4916620.java */ public class T4916620 { static class BB<T, S> { } static class BD<T> extends BB<T, T> { } void f() { BD<Number> bd = new BD<Number>(); BB<? extends Number, ? super Integer> bb = bd; Object o = (BD<Number>) bb; } }
1,521
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6569057.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6569057/T6569057.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6569057 6932571 * @summary Generics regression on cast * @compile T6569057.java */ class T6569057 { static class A<X extends B<?>> { } static class B<X extends A<?>> { D<? extends B<X>> get() { return null; } } static class D<Y extends B<?>> {} <E extends B<?>> void test(E x, D<B<A<?>>> d) { boolean b = x.get() == d; } }
1,447
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6558559b.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6558559/T6558559b.java
/* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6558559 * @summary Extra "unchecked" diagnostic * @author Maurizio Cimadamore * * @compile T6558559b.java -Xlint:unchecked -Werror */ import java.util.*; class T6558559b { void test(List rawList, List<?> unboundList) { Throwable t0 = (Throwable) Collections.emptyList(); Throwable t1 = (Throwable) rawList; Throwable t2 = (Throwable) unboundList; Object o = unboundList; Throwable t3 = (Throwable) o; } }
1,538
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6558559a.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6558559/T6558559a.java
/* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6558559 * @summary Extra "unchecked" diagnostic * @author Maurizio Cimadamore * * @compile T6558559a.java -Xlint:unchecked -Werror */ class T6558559a { interface A<T> {} static class B<T> {} A<?> x = null; B<?> y = (B<?>)x; }
1,328
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6665356.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6665356/T6665356.java
/* * @test /nodynamiccopyright/ * @author Maurizio Cimadamore * @bug 6665356 * @summary Cast not allowed when both qualifying type and inner class are parameterized * @compile/fail/ref=T6665356.out -XDrawDiagnostics T6665356.java */ class T6665356 { class Outer<S> { class Inner<T> {} } void cast1(Outer<Integer>.Inner<Long> p) { Object o = (Outer<Integer>.Inner<Long>)p; } void cast2(Outer<Integer>.Inner<Long> p) { Object o = (Outer<? extends Number>.Inner<Long>)p; } void cast3(Outer<Integer>.Inner<Long> p) { Object o = (Outer<Integer>.Inner<? extends Number>)p; } void cast4(Outer<Integer>.Inner<Long> p) { Object o = (Outer<? extends Number>.Inner<? extends Number>)p; } void cast5(Outer<Integer>.Inner<Long> p) { Object o = (Outer<? super Number>.Inner<Long>)p; } void cast6(Outer<Integer>.Inner<Long> p) { Object o = (Outer<Integer>.Inner<? super Number>)p; } void cast7(Outer<Integer>.Inner<Long> p) { Object o = (Outer<? super Number>.Inner<? super Number>)p; } void cast8(Outer<Integer>.Inner<Long> p) { Object o = (Outer<? extends String>.Inner<Long>)p; } void cast9(Outer<Integer>.Inner<Long> p) { Object o = (Outer<Integer>.Inner<? extends String>)p; } void cast10(Outer<Integer>.Inner<Long> p) { Object o = (Outer<? super String>.Inner<Long>)p; } void cast11(Outer<Integer>.Inner<Long> p) { Object o = (Outer<Integer>.Inner<? super String>)p; } }
1,576
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T5065215.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/5065215/T5065215.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 5065215 * @summary javac reports unnecessary unchecked warning * @compile -Xlint:unchecked -Werror T5065215.java */ public class T5065215 { static <T, U extends T> T[] cast(U[] a) { return (T[]) a; } }
1,292
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6219964.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6219964/T6219964.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 6219964 * @summary Compiler allows illegal cast of anonymous inner class * @compile/fail T6219964.java */ public class T6219964 { interface I { } void foo() { new Object() { I bar() { return (I)this; } }; } }
1,363
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T5064736.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/5064736/T5064736.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 5064736 * @summary Incompatible types are cast without error * @compile/fail T5064736.java */ public class T5064736 { class A {} class B extends A {} public class Foo<T> { public <U extends B> void foo(Foo<? super A> param) { Foo<U> foo = (Foo<U>)param; } } }
1,391
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6211853.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6211853/T6211853.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 6211853 * @summary "unchecked" warning for checked cast * @compile -Xlint:unchecked -Werror T6211853.java */ public class T6211853 { static class StringList extends java.util.LinkedList<String> { } static class Test { public static void main(String[] args) { java.util.List<? extends String> a = new StringList(); java.util.List<String> b = (StringList) a; // warned but safe. } } }
1,531
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6586091.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6586091/T6586091.java
/* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @author Maurizio Cimadamore * @bug 6586091 * @summary javac crashes with StackOverflowError * @compile T6586091.java */ class T6586091 { static class A<T extends A<?>> {} static class B extends A<A<?>> {} A<A<?>> t = null; B c = (B)t; }
1,336
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T5043020.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/5043020/T5043020.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 5043020 * @summary Spurious unchecked cast warning * @author Peter von der Ah\u00e9 * @compile -Werror -Xlint:unchecked T5043020.java */ public class T5043020 { <T, U extends T, V extends T> T cond1(boolean z, U x1, V x2) { return (z? (T) x1: x2); } }
1,356
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6302214.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6302214/T6302214.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 6302214 * @summary erroneus "inconvertible types" error * @compile -Xlint:unchecked -Werror T6302214.java */ public class T6302214 { class B extends A<Object> { void m2() { m3((X2) m()); } void m3(X2 i) { } } public class A<T> { X<? extends T> m() { return null; } } class X2 extends X<String> { } class X<T> { } }
1,492
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6302214a.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6302214/T6302214a.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 6302214 * @summary erroneus "inconvertible types" error * @author Peter von der Ah\u00e9 * @compile -Xlint:unchecked -Werror T6302214a.java */ public class T6302214a { class X<T> {} class X2 extends X<String> {} class Test { X<? extends Object> x; X2 x2 = (X2)x; } }
1,387
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6932571neg.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6932571/T6932571neg.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6932571 * @summary Compiling Generics causing Inconvertible types * @compile/fail/ref=T6932571neg.out -XDrawDiagnostics T6932571neg.java */ class T6932571neg { interface I<T>{ } interface I1 extends I<String> {} static class Y implements I<String> {} final static class S implements I<String> {} <G extends I<G>> void test() { S s = new S(); G g = (G) s; } }
1,480
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6932571b.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6932571/T6932571b.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6932571 * @summary Compiling Generics causing Inconvertible types * @compile T6932571b.java */ class T6932571b { interface A1<T extends B<? super T>> { public T getT(); } interface A2<T extends B<? extends T>> { public T getT(); } class B<T extends B<T>> {} class C extends B<C> {} void test1(A1<?> a) { Object o = (C)a.getT(); } void test2(A2<?> a) { Object o = (C)a.getT(); } }
1,538
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6932571a.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6932571/T6932571a.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6932571 * @summary Compiling Generics causing Inconvertible types * @compile T6932571a.java */ class T6932571a { static class A<T extends Comparable<? super T>> { public void test(T v) { Object obj = (Integer)v; } } static class B<T extends Comparable<? extends T>> { public void test(T v) { Object obj = (Integer)v; } } }
1,476
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6467183a.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6467183/T6467183a.java
/* * @test /nodynamiccopyright/ * @author mcimadamore * @bug 6467183 * @summary * @compile/fail/ref=T6467183a.out -Xlint:unchecked -Werror -XDrawDiagnostics T6467183a.java */ class T6467183a<T> { class A<S> {} class B extends A<Integer> {} class C<X> extends A<X> {} void cast1(B b) { Object o = (A<T>)b; } void cast2(B b) { Object o = (A<? extends Number>)b; } void cast3(A<Integer> a) { Object o = (C<? extends Number>)a; } void cast4(A<Integer> a) { Object o = (C<? extends Integer>)a; } }
585
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6467183b.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6467183/T6467183b.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 * @author mcimadamore * @bug 6467183 * @summary * @compile/fail -Xlint:unchecked -Werror -XDrawDiagnostics T6467183b.java */ class T6665356b<T> { class A<S> {} class B<X> extends A<X> {} void cast(A<? extends Number> a) { Object o = (B<? extends Integer>)a; } }
1,362
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T654170.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/forum/T654170.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 5066774 * @summary Bad interaction between generics, instanceof, inner classes, and subclasses * @author RGibson * @compile -Werror T654170.java */ // http://forum.java.sun.com/thread.jspa?forumID=316&threadID=654170 import java.util.*; public class T654170 { public static void main(String[] args) { Base<?> b = new Sub (); if (b instanceof Sub) { } } } class Base<T extends List> {} class Sub extends Base<ArrayList> {}
1,546
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6256789.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6256789/T6256789.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 6256789 * @summary Legal cast rejected * @compile -Xlint:unchecked -Werror T6256789.java */ import java.lang.ref.*; public class T6256789 { public ExtraRef prob(ReferenceQueue<Object> refQ) throws InterruptedException { return ((ExtraRef)refQ.remove()); } public static class ExtraRef extends WeakReference<Object> { public ExtraRef(Object value) { super(value); } } }
1,510
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6795580.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6795580/T6795580.java
/* * @test /nodynamiccopyright/ * @author Maurizio Cimadamore * @bug 6795580 * @summary parser confused by square brackets in qualified generic cast * @compile/fail/ref=T6795580.out -XDrawDiagnostics T6795580.java */ class T6795580 { class Outer<S> { class Inner<T> {} } void cast1(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<Integer>.Inner<Long>[])p; } void cast2(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<? extends Number>.Inner<Long>[])p; } void cast3(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<Integer>.Inner<? extends Number>[])p; } void cast4(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<? extends Number>.Inner<? extends Number>[])p; } void cast5(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<? super Number>.Inner<Long>[])p; } void cast6(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<Integer>.Inner<? super Number>[])p; } void cast7(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<? super Number>.Inner<? super Number>[])p; } void cast8(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<? extends String>.Inner<Long>[])p; } void cast9(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<Integer>.Inner<? extends String>[])p; } void cast10(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<? super String>.Inner<Long>[])p; } void cast11(Outer<Integer>.Inner<Long>[] p) { Object o = (Outer<Integer>.Inner<? super String>[])p; } }
1,604
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7005095neg.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/7005095/T7005095neg.java
/* * @test /nodynamiccopyright/ * @bug 7005095 * @summary Cast: compile reject sensible cast from final class to interface * @compile/fail/ref=T7005095neg.out -XDrawDiagnostics T7005095neg.java */ class T7005095pos<T extends Integer> { interface Foo<T> {} static final class FooImpl implements Foo<String> {} Object o = (Foo<T>) new FooImpl(); }
370
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7005095pos.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/7005095/T7005095pos.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 7005095 * @summary Cast: compile reject sensible cast from final class to interface * @compile T7005095pos.java */ class T7005095pos<T extends CharSequence> { interface Foo<T> {} static final class FooImpl implements Foo<String> {} Object o = (Foo<T>) new FooImpl(); }
1,363
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6507317.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6507317/T6507317.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6507317 6932571 * @summary Problem when casting from parametrized type to concrete class * @compile T6507317.java */ import java.util.Comparator; abstract class T6507317<T extends Comparable<T>> implements Comparator<T> { void test(T t) { String s = (String)t; } }
1,362
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T5034609.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/5034609/T5034609.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 5034609 * @summary Capture conversion implementation breaks a cast test * @compile -Xlint:unchecked -Werror T5034609.java */ interface DA<T> { } interface DB<T> extends DA<T> { } interface DC<T> extends DA<Integer> { } public class T5034609 { Object o = (DC<?>) (DA<?>) null; // <<pass>> }
1,381
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6714835.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6714835/T6714835.java
/* * @test /nodynamiccopyright/ * @author mcimadamore * @bug 6714835 * @summary Safe cast is rejected (with warning) by javac * @compile/fail/ref=T6714835.out -Xlint:unchecked -Werror -XDrawDiagnostics T6714835.java */ import java.util.*; class T6714835 { void cast1(Iterable<? extends Integer> x) { Collection<? extends Number> x1 = (Collection<? extends Number>)x; //ok Collection<? super Integer> x2 = (Collection<? super Integer>)x; //warn } void cast2(Iterable<? super Number> x) { Collection<? super Integer> x1 = (Collection<? super Integer>)x; //ok Collection<? extends Number> x2 = (Collection<? extends Number>)x; //warn } }
696
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7123100d.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/7123100/T7123100d.java
/* * @test /nodynamiccopyright/ * @bug 7123100 * @summary javac fails with java.lang.StackOverflowError * @compile/fail/ref=T7123100d.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100d.java */ class T7123100d { <E extends Enum<E>> E m(Enum<E> e) { return null; } <Z> void test(Enum<?> e) { Z z = (Z)m(e); } }
358
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7123100b.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/7123100/T7123100b.java
/* * @test /nodynamiccopyright/ * @bug 7123100 * @summary javac fails with java.lang.StackOverflowError * @compile/fail/ref=T7123100b.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100b.java */ class T7123100b { <Z> void test(Enum<?> e) { Z z = (Z)e; } }
286
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7123100a.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/7123100/T7123100a.java
/* * @test /nodynamiccopyright/ * @bug 7123100 * @summary javac fails with java.lang.StackOverflowError * @compile/fail/ref=T7123100a.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100a.java */ class T7123100a { <E extends Enum<E>> E m() { return null; } <Z> void test() { Z z = (Z)m(); } }
339
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7123100c.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/7123100/T7123100c.java
/* * @test /nodynamiccopyright/ * @bug 7123100 * @summary javac fails with java.lang.StackOverflowError * @compile/fail/ref=T7123100c.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100c.java */ class T7123100c { <E> E m(E e) { return null; } <Z> void test(Enum<?> e) { Z z = (Z)m(e); } }
336
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7005671.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/7005671/T7005671.java
/* * @test /nodynamiccopyright/ * @author mcimadamore * @bug 7005671 * @summary Regression: compiler accepts invalid cast from X[] to primitive array * @compile/fail/ref=T7005671.out -XDrawDiagnostics T7005671.java */ class T7005671<X> { void test1() { Object o1 = (X[])(byte[])null; Object o2 = (X[])(short[])null; Object o3 = (X[])(int[])null; Object o4 = (X[])(long[])null; Object o5 = (X[])(float[])null; Object o6 = (X[])(double[])null; Object o7 = (X[])(char[])null; Object o8 = (X[])(boolean[])null; } void test2() { Object o1 = (byte[])(X[])null; Object o2 = (short[])(X[])null; Object o3 = (int[])(X[])null; Object o4 = (long[])(X[])null; Object o5 = (float[])(X[])null; Object o6 = (double[])(X[])null; Object o7 = (char[])(X[])null; Object o8 = (boolean[])(X[])null; } }
939
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6358534.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6358534/T6358534.java
/* * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6358534 * @summary Cast involving raw superclass not recognized as unchecked * @compile T6358534.java */ interface MyInterface<V> { } public class T6358534 implements MyInterface { MyInterface<Integer> o1 = (MyInterface<Integer>) (T6358534)null; T6358534 o2 = (T6358534) (MyInterface<Integer>)null; }
1,396
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6295056.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6295056/T6295056.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 6295056 * @summary Unchecked cast not reported as unsafe * @compile/fail -Xlint:unchecked -Werror T6295056.java * @compile T6295056.java */ public class T6295056 { interface Foo {} interface Bar<X> {} Object m(Foo f) { return (Bar<Object>)f; } }
1,359
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6302956.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/cast/6302956/T6302956.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 6302956 * @summary Illegal cast allowed Properties -> Map<String, String> * @compile/fail T6302956.java */ import java.util.Map; public class T6302956 { Object test() { return (Map<String, String>)System.getProperties(); } }
1,328
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ImportPrivate.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/ImportPrivate.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 4979456 * @summary NPE while compiling static import of inaccessible class member * @author gafter * * @compile/fail ImportPrivate.java */ package importPrivate; import static importPrivate.A.m; class A { private static int m() { return 8; } } class MyTest { public static void main(String argv[]) { m(); } }
1,423
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
StaticImport.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/StaticImport.java
/* * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 4855358 4965039 4970828 * @summary add support for JSR 201's static import facility * @author gafter * * @compile StaticImport.java * @run main StaticImport */ // for 4970828, the offending code is generated from Collections. // importing it is sufficient to trigger a javac failure. import static java.util.Collections.*; import static java.lang.Math.*; import static java.lang.System.out; public class StaticImport { public static void main(String[] args) { out.println(sin(PI/6)); if (abs(1.0 - 2*sin(PI/6)) > 0.000001) throw new Error(); } }
1,670
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ImportInherit.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/ImportInherit.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 4965363 * @summary static import versus inherited members * @author gafter * * @compile ImportInherit.java */ package importInherit; import static importInherit.B.x; class A { static int x = 12; } class B extends A { } class C { int y = x; }
1,333
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Ambig1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/Ambig1.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 4929736 * @summary Missing ambiguity error when two methods are equally specific * @author gafter * * @compile/fail Ambig1.java */ package ambig1; import static ambig1.A.f; import static ambig1.B.f; class A { static void f(int i) {} } class B { static void f(int i) {} } class Main { void g() { f(2); } }
1,411
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
StaticImport2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/StaticImport2.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 4855358 * @summary add support for JSR 201's static import facility * @author gafter * * @compile/fail StaticImport2.java */ package p; import static p.A.*; import static p.B.*; interface A { int K = 3; } interface B { int K = 4; } class C { void f() { int x = K; // ambiguous } }
1,387
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Shadow.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/Shadow.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 5017254 * @summary compiler fails to shadow inapplicable method with static import * @author gafter * * @compile/fail Shadow.java */ package shadow; import static shadow.T1.*; import static shadow.T2.m1; class T1 { public static void m1() {} } class T2 { public static void m1(int i) {} } class Test { void foo() { m1(); // <-- is this an error? } }
1,457
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PrivateStaticImport.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/PrivateStaticImport.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 4912075 * @summary static import of private field crashes compiler * @author gafter * * @compile/fail PrivateStaticImport.java */ package psi; import static psi.Foo.*; class Foo { private static int FOO_VALUE = 55; } class Bar { int value = FOO_VALUE; }
1,343
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6665223.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/6665223/T6665223.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 6665223 * @summary Static import of inherited protected method causes compiler exception * @author Maurizio Cimadamore * * @compile pkg/A.java */
1,223
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/staticImport/6665223/pkg/A.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. */ package pkg; import static pkg.B.b; class A { public static void main(String[] args) { b(); } }
1,165
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/staticImport/6665223/pkg/B.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. */ package pkg; class B extends B2 {} abstract class B2 { protected static void b() {} }
1,143
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6695838.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/6695838/T6695838.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 6695838 * @summary javac does not detect cyclic inheritance involving static inner classes after import clause * @author Maurizio Cimadamore * * @compile/fail a/FooInterface.java */
1,259
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FooInterface.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/6695838/a/FooInterface.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. */ package a; import a.Foo.InnerInterface; public interface FooInterface extends Foo.InnerInterface {}
1,155
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Foo.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/staticImport/6695838/a/Foo.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. */ package a; class Foo implements FooInterface { public static interface InnerInterface {} }
1,149
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FalseCycleBase.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/falseCycle/FalseCycleBase.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. */ /* * Auxiliary file for falseCycle */ class FalseCycleBase {} class FalseCycle2 extends FalseCycle {}
1,158
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FalseCycle.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/falseCycle/FalseCycle.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 4471999 * @summary Cyclic inheritance error reported when multiple classes in source file. * * @compile FalseCycle.java */ class FalseCycle extends FalseCycleBase {}
1,243
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InvokeMH.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/meth/InvokeMH.java
/* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6754038 6979327 * @summary Generate call sites for method handle * @author jrose * * @compile -source 7 -target 7 -XDallowTransitionalJSR292=no InvokeMH.java */ /* * Standalone testing: * <code> * $ cd $MY_REPO_DIR/langtools * $ (cd make; make) * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java * $ javap -c -classpath dist meth.InvokeMH * </code> */ package meth; import java.lang.invoke.MethodHandle; public class InvokeMH { void test(MethodHandle mh_SiO, MethodHandle mh_vS, MethodHandle mh_vi, MethodHandle mh_vv) throws Throwable { Object o; String s; int i; // for return type testing // next five must have sig = (String,int)Object mh_SiO.invokeExact("world", 123); mh_SiO.invokeExact("mundus", 456); Object k = "kosmos"; mh_SiO.invokeExact((String)k, 789); o = mh_SiO.invokeExact((String)null, 000); o = (Object) mh_SiO.invokeExact("arda", -123); // sig = ()String s = (String) mh_vS.invokeExact(); // sig = ()int i = (int) mh_vi.invokeExact(); o = (int) mh_vi.invokeExact(); // sig = ()void mh_vv.invokeExact(); } void testGen(MethodHandle mh_SiO, MethodHandle mh_vS, MethodHandle mh_vi, MethodHandle mh_vv) throws Throwable { Object o; String s; int i; // for return type testing // next five must have sig = (*,*)* o = mh_SiO.invoke((Object)"world", (Object)123); mh_SiO.invoke((Object)"mundus", (Object)456); Object k = "kosmos"; o = mh_SiO.invoke(k, 789); o = mh_SiO.invoke(null, 000); o = mh_SiO.invoke("arda", -123); // sig = ()String o = mh_vS.invoke(); // sig = ()int i = (int) mh_vi.invoke(); o = (int) mh_vi.invoke(); mh_vi.invoke(); // sig = ()void mh_vv.invoke(); o = mh_vv.invoke(); } }
3,105
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
XlintWarn.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/meth/XlintWarn.java
/* * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6999067 7010194 * @summary cast for invokeExact call gets redundant cast to <type> warnings * @author mcimadamore * * @compile -Werror -Xlint:cast XlintWarn.java */ import java.lang.invoke.*; class XlintWarn { void test(MethodHandle mh) throws Throwable { int i1 = (int)mh.invokeExact(); int i2 = (int)mh.invoke(); int i3 = (int)mh.invokeWithArguments(); } void test2(MethodHandle mh) throws Throwable { int i1 = (int)(mh.invokeExact()); int i2 = (int)(mh.invoke()); int i3 = (int)(mh.invokeWithArguments()); } void test3(MethodHandle mh) throws Throwable { int i1 = (int)((mh.invokeExact())); int i2 = (int)((mh.invoke())); int i3 = (int)((mh.invokeWithArguments())); } }
1,856
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCP.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/meth/TestCP.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 6991980 * @summary polymorphic signature calls don't share the same CP entries * @run main TestCP */ import com.sun.tools.classfile.Instruction; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool.*; import com.sun.tools.classfile.Method; import java.lang.invoke.*; import java.io.*; public class TestCP { static class TestClass { void test(MethodHandle mh) throws Throwable { Number n = (Number)mh.invokeExact("daddy",1,'n'); n = (Number)mh.invokeExact("bunny",1,'d'); n = (Number)(mh.invokeExact("foo",1,'d')); n = (Number)((mh.invokeExact("bar",1,'d'))); } } static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;"; static final int PS_CALLS_COUNT = 4; static final String SUBTEST_NAME = TestClass.class.getName() + ".class"; static final String TEST_METHOD_NAME = "test"; public static void main(String... args) throws Exception { new TestCP().run(); } public void run() throws Exception { String workDir = System.getProperty("test.classes"); File compiledTest = new File(workDir, SUBTEST_NAME); verifyMethodHandleInvocationDescriptors(compiledTest); } void verifyMethodHandleInvocationDescriptors(File f) { System.err.println("verify: " + f); try { int count = 0; ClassFile cf = ClassFile.read(f); Method testMethod = null; for (Method m : cf.methods) { if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) { testMethod = m; break; } } if (testMethod == null) { throw new Error("Test method not found"); } Code_attribute ea = (Code_attribute)testMethod.attributes.get(Attribute.Code); if (testMethod == null) { throw new Error("Code attribute for test() method not found"); } int instr_count = 0; int cp_entry = -1; for (Instruction i : ea.getInstructions()) { if (i.getMnemonic().equals("invokevirtual")) { instr_count++; if (cp_entry == -1) { cp_entry = i.getUnsignedShort(1); } else if (cp_entry != i.getUnsignedShort(1)) { throw new Error("Unexpected CP entry in polymorphic signature call"); } CONSTANT_Methodref_info methRef = (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry); String type = methRef.getNameAndTypeInfo().getType(); if (!type.equals(PS_TYPE)) { throw new Error("Unexpected type in polymorphic signature call: " + type); } } } if (instr_count != PS_CALLS_COUNT) { throw new Error("Wrong number of polymorphic signature call found: " + instr_count); } } catch (Exception e) { e.printStackTrace(); throw new Error("error reading " + f +": " + e); } } }
4,423
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCast6979683_GOOD.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6979683/TestCast6979683_GOOD.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6979683 * @summary Verify that casts can narrow and unbox at the same time * @author jrose * * @compile TestCast6979683_GOOD.java * @run main TestCast6979683_GOOD */ public class TestCast6979683_GOOD { public static void main(String... av) { bugReportExample(); for (int x = -1; x <= 2; x++) { zconvTests(x != 0); iconvTests(x); bconvTests((byte)x); cconvTests((char)x); } System.out.println("Successfully ran "+tests+" tests."); } static int tests; static void assertEquals(Object x, Object y) { if (!x.equals(y)) { throw new RuntimeException("assertEquals: "+x+" != "+y); } ++tests; } static void bugReportExample() { {} // example in bug report: Object x = (Object)1; int y = (int)x; {} // end example } static boolean zconv1(Boolean o) { return o; } static boolean zconv2(Object o) { return (boolean)o; } static boolean zconv3(Comparable<Boolean> o) { return (boolean)o; } static void zconvTests(boolean x) { assertEquals(x, zconv1(x)); assertEquals(x, zconv2(x)); assertEquals(x, zconv3(x)); } static int iconv1(Integer o) { return o; } static int iconv2(Object o) { return (int)o; } static int iconv3(java.io.Serializable o) { return (int)o; } static int iconv4(Number o) { return (int)o; } static int iconv5(Comparable<Integer> o) { return (int)o; } static void iconvTests(int x) { assertEquals(x, iconv1(x)); assertEquals(x, iconv2(x)); assertEquals(x, iconv3(x)); assertEquals(x, iconv4(x)); assertEquals(x, iconv5(x)); } static float bconv1(Byte o) { return o; } // note type "float" static float bconv2(Object o) { return (byte)o; } static float bconv3(java.io.Serializable o) { return (byte)o; } static float bconv4(Number o) { return (byte)o; } static void bconvTests(byte x) { float xf = x; assertEquals(xf, bconv1(x)); assertEquals(xf, bconv2(x)); assertEquals(xf, bconv3(x)); assertEquals(xf, bconv4(x)); } static float cconv1(Character o) { return o; } // note type "float" static float cconv2(Object o) { return (char)o; } static float cconv3(java.io.Serializable o) { return (char)o; } static float cconv4(Comparable<Character> o) { return (char)o; } static void cconvTests(char x) { float xf = x; assertEquals(xf, cconv1(x)); assertEquals(xf, cconv2(x)); assertEquals(xf, cconv3(x)); assertEquals(xf, cconv4(x)); } }
3,721
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCast6979683_BAD36.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6979683/TestCast6979683_BAD36.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6979683 * @summary Verify that casts can narrow and unbox at the same time * @author jrose * * @compile/fail/ref=TestCast6979683_BAD36.java.errlog -XDrawDiagnostics TestCast6979683_BAD36.java */ public class TestCast6979683_BAD36 { //... //... static int iconvBAD2(Comparable<Integer> o) { return o; } //BAD: cast needed //... //... //... }
1,443
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCast6979683_BAD38.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6979683/TestCast6979683_BAD38.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6979683 * @summary Verify that casts can narrow and unbox at the same time * @author jrose * * @compile/fail/ref=TestCast6979683_BAD38.java.errlog -XDrawDiagnostics TestCast6979683_BAD38.java */ public class TestCast6979683_BAD38 { //... //... //... //... static float cconvBAD1(Comparable<Character> o) { return o; } //BAD //... }
1,434
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCast6979683_BAD39.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6979683/TestCast6979683_BAD39.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6979683 * @summary Verify that casts can narrow and unbox at the same time * @author jrose * * @compile/fail/ref=TestCast6979683_BAD39.java.errlog -XDrawDiagnostics TestCast6979683_BAD39.java */ public class TestCast6979683_BAD39 { //... //... //... //... //... static float cconvBAD2(Number o) { return (char)o; } //BAD }
1,425
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCast6979683_BAD37.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6979683/TestCast6979683_BAD37.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6979683 * @summary Verify that casts can narrow and unbox at the same time * @author jrose * * @compile/fail/ref=TestCast6979683_BAD37.java.errlog -XDrawDiagnostics TestCast6979683_BAD37.java */ public class TestCast6979683_BAD37 { //... //... //... static int iconvBAD3(Comparable<Short> o) { return (int)o; } //BAD: wrong instance //... //... }
1,449
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCast6979683_BAD35.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6979683/TestCast6979683_BAD35.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6979683 * @summary Verify that casts can narrow and unbox at the same time * @author jrose * * @compile/fail/ref=TestCast6979683_BAD35.java.errlog -XDrawDiagnostics TestCast6979683_BAD35.java */ public class TestCast6979683_BAD35 { //... static int iconvBAD1(Number o) { return o; } //BAD: cast needed //... //... //... //... }
1,430
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestCast6979683_BAD34.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6979683/TestCast6979683_BAD34.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6979683 * @summary Verify that casts can narrow and unbox at the same time * @author jrose * * @compile/fail/ref=TestCast6979683_BAD34.java.errlog -XDrawDiagnostics TestCast6979683_BAD34.java */ public class TestCast6979683_BAD34 { static boolean zconvBAD1(Number o) { return o; } //BAD //... //... //... //... //... }
1,421
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6400383.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/6400383/T6400383.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 6400383 * @summary directory foo.java on javac command line causes javac to crash */ import java.io.*; import com.sun.tools.javac.api.*; public class T6400383 { public static void main(String... args) { File foo = new File("foo.java"); foo.delete(); // case 1: file not found JavacTool tool = JavacTool.create(); StringStream out = new StringStream(); tool.run(null, out, out, foo.getPath()); check(out.toString()); // case 2: file is a directory out.clear(); try { foo.mkdir(); tool.run(null, out, out, foo.getPath()); check(out.toString()); } finally { foo.delete(); } } private static void check(String s) { System.err.println(s); // If the compiler crashed and caught the error, it will print out // the "oh golly, I crashed!" message, which will contain the Java // name of the exception in the stack trace ... so look for the // string "Exception" or "Error". if (s.indexOf("Exception") != -1 || s.indexOf("Error") != -1) throw new AssertionError("found exception"); } private static class StringStream extends OutputStream { public void write(int i) { sb.append((char) i); } void clear() { sb.setLength(0); } public String toString() { return sb.toString(); } private StringBuilder sb = new StringBuilder(); } }
2,623
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg01.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg01.java
/* * @test /nodynamiccopyright/ * @bug 6943289 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author darcy * @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java * @compile -source 6 -XDrawDiagnostics Neg01.java * */ class Neg01 { static class A extends Exception {} static class B1 extends A {} static class B2 extends A {} class Test { void m() throws A { try { throw new B1(); } catch (final A ex1) { try { throw ex1; // used to throw A, now throws B1! } catch (B2 ex2) { }//unreachable } } } }
692
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos04.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos04.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6943289 * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') */ import java.lang.annotation.*; public class Pos04 { enum ExceptionKind { A(1), B(2), C(1); int expectedValue; ExceptionKind(int expectedValue) { this.expectedValue = expectedValue; } } @Retention(RetentionPolicy.RUNTIME) @interface CatchNumber { int value(); } @CatchNumber(1) static class A extends Exception { } @CatchNumber(2) static class B extends Exception { } @CatchNumber(1) static class C extends Exception { } static int sum = 0; public static void main(String[] args) { for (ExceptionKind ekind : ExceptionKind.values()) { test(ekind); } if (sum != 4) { throw new Error("bad checksum - expected:4, found:" + sum); } } public static void test(ExceptionKind ekind) { try { switch(ekind) { case A: throw new A(); case B: throw new B(); case C: throw new C(); } } catch(final A | C ex) {// Catch number 1 CatchNumber catchNumber = ex.getClass().getAnnotation(CatchNumber.class); if (catchNumber == null || catchNumber.value() != ekind.expectedValue) { throw new Error("was expecting 1 - got " + catchNumber); } sum += catchNumber.value(); } catch (final B ex) { // Catch number 2 CatchNumber catchNumber = ex.getClass().getAnnotation(CatchNumber.class); if (catchNumber == null || catchNumber.value() != ekind.expectedValue) { throw new Error("was expecting 2 - got " + catchNumber); } sum += catchNumber.value(); } } }
2,924
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos08.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos08.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6993963 * @summary Multicatch: crash while compiling simple code with a multicatch parameter * @compile Pos08.java */ class Pos08 { interface Foo {} static class X1 extends Exception implements Foo {} static class X2 extends Exception implements Foo {} void m(boolean cond) { try { if (cond) throw new X1(); else throw new X2(); } catch (final X1 | X2 ex) {} } }
1,541
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos08eff_final.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos08eff_final.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6993963 * @summary Multicatch: crash while compiling simple code with a multicatch parameter * @compile Pos08eff_final.java */ class Pos08eff_final { interface Foo {} static class X1 extends Exception implements Foo {} static class X2 extends Exception implements Foo {} void m(boolean cond) { try { if (cond) throw new X1(); else throw new X2(); } catch (X1 | X2 ex) {} } }
1,553
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos03.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos03.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6943289 * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @compile Pos03.java */ class Pos03 { static class A extends Exception { public void m() {}; public Object f;} static class B1 extends A {} static class B2 extends A {} void m() { try { if (true) { throw new B1(); } else { throw new B2(); } } catch (final B1 | B2 ex) { ex.m(); System.out.println(ex.f); } } }
1,626
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg03.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg03.java
/* * @test /nodynamiccopyright/ * @bug 6943289 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author mcimadamore * @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java * */ class Neg03 { static class A extends Exception { public void m() {}; public Object f;} static class B1 extends A {} static class B2 extends A {} void m() throws B1, B2 { try { if (true) { throw new B1(); } else { throw new B2(); } } catch (Exception ex) { ex = new B2(); //effectively final analysis disabled! throw ex; } } }
701
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg02.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg02.java
/* * @test /nodynamiccopyright/ * @bug 6943289 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author mcimadamore * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java * */ class Neg02 { static class A extends Exception {} static class B extends Exception {} void m() { try { if (true) { throw new A(); } else { throw new B(); } } catch (final A | B ex) { ex = new B(); } } }
561
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg02eff_final.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg02eff_final.java
/* * @test /nodynamiccopyright/ * @bug 6943289 6993963 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author mcimadamore * @compile/fail/ref=Neg02eff_final.out -XDrawDiagnostics Neg02eff_final.java * */ class Neg02eff_final { static class A extends Exception {} static class B extends Exception {} void m() { try { if (true) { throw new A(); } else { throw new B(); } } catch (A | B ex) { ex = new B(); } } }
590
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg04.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg04.java
/* * @test /nodynamiccopyright/ * @bug 6943289 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author mcimadamore * @compile/fail/ref=Neg04.out -XDrawDiagnostics Neg04.java * */ class Neg04 { static class A extends Exception {} static class B extends Exception {} void test() throws B { try { if (true) { throw new A(); } else if (false) { throw new B(); } else { throw (Throwable)new Exception(); } } catch (A e) {} catch (final Exception e) { throw e; } catch (Throwable t) {} } }
703
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg04eff_final.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg04eff_final.java
/* * @test /nodynamiccopyright/ * @bug 6943289 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author mcimadamore * @compile/fail/ref=Neg04eff_final.out -XDrawDiagnostics Neg04eff_final.java * */ class Neg04eff_final { static class A extends Exception {} static class B extends Exception {} void test() throws B { try { if (true) { throw new A(); } else if (false) { throw new B(); } else { throw (Throwable)new Exception(); } } catch (A e) {} catch (Exception e) { throw e; } catch (Throwable t) {} } }
724
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos07.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos07.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6993963 * @summary Project Coin: Use precise exception analysis for effectively final catch parameters * @compile Pos07.java */ class Pos07 { static class A extends Exception { public void m() {}; public Object f;} static class B1 extends A {} static class B2 extends A {} void m() throws B1, B2 { try { if (true) { throw new B1(); } else { throw new B2(); } } catch (Exception ex) { //effectively final analysis throw ex; } } }
1,643
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg01eff_final.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg01eff_final.java
/* * @test /nodynamiccopyright/ * @bug 6943289 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author darcy * @compile/fail/ref=Neg01eff_final.out -XDrawDiagnostics Neg01eff_final.java * @compile -source 6 -XDrawDiagnostics Neg01eff_final.java * */ class Neg01eff_final { static class A extends Exception {} static class B1 extends A {} static class B2 extends A {} class Test { void m() throws A { try { throw new B1(); } catch (A ex1) { try { throw ex1; // used to throw A, now throws B1! } catch (B2 ex2) { }//unreachable } } } }
722
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg06.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg06.java
/* * @test /nodynamiccopyright/ * @bug 7002070 * * @summary If catch clause has an incompatible type, error pointer points to first exception type in list * @author mcimadamore * @compile/fail/ref=Neg06.out -XDrawDiagnostics Neg06.java * */ class Neg06 { void test() { try { } catch (String | Integer s) {} } }
344
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T6978574.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/T6978574.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6978574 * @summary return statement in try block with multi-catch causes ClassFormatError */ public class T6978574 { static class A extends Exception { } static class B extends Exception { } static void foo() throws A { throw new A(); } static void bar() throws B { throw new B(); } static void test(boolean b) { try { if (b) foo(); else bar(); return; // This should *not* cause ClassFormatError } catch (final A | B e ) { caught = true; } return; } static boolean caught = false; public static void main(String[] args) { test(true); if (!caught) throw new AssertionError(); caught = false; test(false); if (!caught) throw new AssertionError(); } }
1,855
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos05.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos05.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6943289 * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @run main Pos05 */ import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.Code_attribute.Exception_data; import com.sun.tools.classfile.Method; import java.io.*; public class Pos05 { static class Pos05sub { class A extends Exception {} class B extends Exception {} class C extends Exception {} void test(boolean b1, boolean b2) { try { if (b1) { throw new A(); } else if (b2) { throw new B(); } else { throw new C(); } } catch (final A | B | C ex) { System.out.println("Exception caught"); } } } static final int TYPES_IN_MULTICATCH = 3; static final String SUBTEST_NAME = Pos05sub.class.getName() + ".class"; static final String TEST_METHOD_NAME = "test"; public static void main(String... args) throws Exception { new Pos05().run(); } public void run() throws Exception { String workDir = System.getProperty("test.classes"); File compiledTest = new File(workDir, SUBTEST_NAME); verifyMulticatchExceptionRanges(compiledTest); } void verifyMulticatchExceptionRanges(File f) { System.err.println("verify: " + f); try { int count = 0; ClassFile cf = ClassFile.read(f); Method testMethod = null; for (Method m : cf.methods) { if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) { testMethod = m; break; } } if (testMethod == null) { throw new Error("Test method not found"); } Code_attribute ea = (Code_attribute)testMethod.attributes.get(Attribute.Code); if (testMethod == null) { throw new Error("Code attribute for test() method not found"); } Exception_data firstExceptionTable = null; for (int i = 0 ; i < ea.exception_table_langth; i++) { if (firstExceptionTable == null) { firstExceptionTable = ea.exception_table[i]; } if (ea.exception_table[i].handler_pc != firstExceptionTable.handler_pc || ea.exception_table[i].start_pc != firstExceptionTable.start_pc || ea.exception_table[i].end_pc != firstExceptionTable.end_pc) { throw new Error("Multiple overlapping catch clause found in generated code"); } count++; } if (count != TYPES_IN_MULTICATCH) { throw new Error("Wrong number of exception data found: " + count); } } catch (Exception e) { e.printStackTrace(); throw new Error("error reading " + f +": " + e); } } }
4,271
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos09.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos09.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 6943289 7020044 * * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * @author mcimadamore * @compile Pos09.java * */ class Pos09 { static class Foo<X> { Foo(X x) {} } static interface Base<X> {} static class A extends Exception implements Base<String> {} static class B extends Exception implements Base<Integer> {} void m() { try { if (true) { throw new A(); } else { throw new B(); } } catch (A | B ex) { Foo<?> f = new Foo<>(ex); } } }
1,709
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Neg07.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Neg07.java
/* * @test /nodynamiccopyright/ * @bug 7039822 * @summary Verify typing of lub of exception parameter w.r.t getClass * @author Joseph D. Darcy * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java */ public class Neg07 { private static void test(int i) { try { thrower(i); } catch (SonException | DaughterException e) { Class<? extends HasFoo> clazz2 = e.getClass(); // Rejected! HasFoo m = e; e.foo(); } } private static interface HasFoo { void foo(); } static void thrower(int i) throws SonException, DaughterException { if (i == 0) throw new SonException(); else throw new DaughterException(); } private static class ParentException extends RuntimeException {} private static class SonException extends ParentException implements HasFoo { public void foo() { System.out.println("SonException.foo"); } } private static class DaughterException extends ParentException implements HasFoo { public void foo() { System.out.println("DaughterException.foo"); } } }
1,232
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos10.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos10.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 7039822 * @summary Verify lub of an exception parameter can be an intersection type * @author Joseph D. Darcy */ public class Pos10 { public static void main(String... args) { test(0); test(1); if (record != 0b11) throw new RuntimeException("Unexpected exception execution: " + record); if (closeRecord != 0b11) throw new RuntimeException("Unexpected close execution: " + closeRecord); } private static int record = 0; private static int closeRecord = 0; private static void test(int i) { try { thrower(i); } catch (SonException | DaughterException e) { Class<? extends ParentException> clazz = e.getClass(); HasFoo m = e; e.foo(); try (AutoCloseable ac = e) { e.toString(); } catch(Exception except) { throw new RuntimeException(except); } } } private static interface HasFoo { void foo(); } private static void thrower(int i) throws SonException, DaughterException { if (i == 0) throw new SonException(); else throw new DaughterException(); } private static class ParentException extends RuntimeException {} private static class SonException extends ParentException implements HasFoo, AutoCloseable { public void foo() { record |= 0b01; } @Override public void close() { closeRecord |= 0b01; } } private static class DaughterException extends ParentException implements HasFoo, AutoCloseable { public void foo() { record |= 0b10; } @Override public void close() { closeRecord |= 0b10; } } }
3,025
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos06.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos06.java
/* * @test /nodynamiccopyright/ * @bug 6993963 * * @summary Project Coin: Use precise exception analysis for effectively final catch parameters * @author mcimadamore * @compile Pos06.java * */ class Pos06 { static class A extends Exception {} static class B extends Exception {} void m() { try { if (true) { throw new A(); } else { throw new B(); } } catch (A | B ex) { System.out.println(ex); } } }
542
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos02.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos02.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6943289 * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * */ public class Pos02 { static class A extends Exception {} static class B extends Exception {} static class C extends Exception {} static class C1 extends C {} static class C2 extends C {} enum ExceptionKind { A, B, C1, C2 } static int caughtExceptions = 0; static int caughtRethrownExceptions = 0; static void test(ExceptionKind ekind) throws A, C1 { try { switch (ekind) { case A : throw new A(); case B : throw new B(); case C1: throw new C1(); case C2 : throw new C2(); } } catch (final C2 | B ex) { caughtExceptions++; } catch (final C | A ex) { caughtExceptions++; throw ex; } } public static void main(String[] args) { for (ExceptionKind ekind : ExceptionKind.values()) { try { test(ekind); } catch (final C1 | A ex) { caughtRethrownExceptions++; } } if (caughtExceptions != 4 && caughtRethrownExceptions == 2) { throw new AssertionError("Exception handler called " + caughtExceptions + "times" + " rethrown handler called " + caughtRethrownExceptions + "times"); } } }
2,567
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Pos01.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/Pos01.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 6943289 * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') * */ public class Pos01 { static class A extends Exception {} static class B extends Exception {} static int caughtExceptions = 0; static void test(boolean b) { try { if (b) { throw new A(); } else { throw new B(); } } catch (final A | B ex) { caughtExceptions++; } } public static void main(String[] args) { test(true); test(false); if (caughtExceptions != 2) { throw new AssertionError("Exception handler called " + caughtExceptions + "times"); } } }
1,818
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DisjunctiveTypeWellFormednessTest.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.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 7030606 * @summary Project-coin: multi-catch types should be pairwise disjoint */ import com.sun.source.util.JavacTask; import java.net.URI; import java.util.Arrays; import javax.tools.Diagnostic; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; import javax.tools.SimpleJavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; public class DisjunctiveTypeWellFormednessTest { enum Alternative { EXCEPTION("Exception"), RUNTIME_EXCEPTION("RuntimeException"), IO_EXCEPTION("java.io.IOException"), FILE_NOT_FOUND_EXCEPTION("java.io.FileNotFoundException"), ILLEGAL_ARGUMENT_EXCEPTION("IllegalArgumentException"); String exceptionStr; private Alternative(String exceptionStr) { this.exceptionStr = exceptionStr; } static String makeDisjunctiveType(Alternative... alternatives) { StringBuilder buf = new StringBuilder(); String sep = ""; for (Alternative alternative : alternatives) { buf.append(sep); buf.append(alternative.exceptionStr); sep = "|"; } return buf.toString(); } boolean disjoint(Alternative that) { return disjoint[this.ordinal()][that.ordinal()]; } static boolean[][] disjoint = { // Exception RuntimeException IOException FileNotFoundException IllegalArgumentException /*Exception*/ { false, false, false, false, false }, /*RuntimeException*/ { false, false, true, true, false }, /*IOException*/ { false, true, false, false, true }, /*FileNotFoundException*/ { false, true, false, false, true }, /*IllegalArgumentException*/ { false, false, true, true, false } }; } enum Arity { ONE(1), TWO(2), THREE(3), FOUR(4), FIVE(5); int n; private Arity(int n) { this.n = n; } } public static void main(String... args) throws Exception { //create default shared JavaCompiler - reused across multiple compilations JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); for (Arity arity : Arity.values()) { for (Alternative a1 : Alternative.values()) { if (arity == Arity.ONE) { new DisjunctiveTypeWellFormednessTest(a1).run(comp, fm); continue; } for (Alternative a2 : Alternative.values()) { if (arity == Arity.TWO) { new DisjunctiveTypeWellFormednessTest(a1, a2).run(comp, fm); continue; } for (Alternative a3 : Alternative.values()) { if (arity == Arity.THREE) { new DisjunctiveTypeWellFormednessTest(a1, a2, a3).run(comp, fm); continue; } for (Alternative a4 : Alternative.values()) { if (arity == Arity.FOUR) { new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4).run(comp, fm); continue; } for (Alternative a5 : Alternative.values()) { new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4, a5).run(comp, fm); } } } } } } } Alternative[] alternatives; JavaSource source; DiagnosticChecker diagChecker; DisjunctiveTypeWellFormednessTest(Alternative... alternatives) { this.alternatives = alternatives; this.source = new JavaSource(); this.diagChecker = new DiagnosticChecker(); } class JavaSource extends SimpleJavaFileObject { String template = "class Test {\n" + "void test() {\n" + "try {} catch (#T e) {}\n" + "}\n" + "}\n"; String source; public JavaSource() { super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); source = template.replace("#T", Alternative.makeDisjunctiveType(alternatives)); } @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) { return source; } } void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, null, null, Arrays.asList(source)); ct.analyze(); check(); } void check() { int non_disjoint = 0; int i = 0; for (Alternative a1 : alternatives) { int j = 0; for (Alternative a2 : alternatives) { if (i == j) continue; if (!a1.disjoint(a2)) { non_disjoint++; break; } j++; } i++; } if (non_disjoint != diagChecker.errorsFound) { throw new Error("invalid diagnostics for source:\n" + source.getCharContent(true) + "\nFound errors: " + diagChecker.errorsFound + "\nExpected errors: " + non_disjoint); } } static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> { int errorsFound; public void report(Diagnostic<? extends JavaFileObject> diagnostic) { if (diagnostic.getKind() == Diagnostic.Kind.ERROR && diagnostic.getCode().startsWith("compiler.err.multicatch.types.must.be.disjoint")) { errorsFound++; } } } }
7,491
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7030606.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/7030606/T7030606.java
/* * @test /nodynamiccopyright/ * @bug 7030606 * * @summary Project-coin: multi-catch types should be pairwise disjoint * @compile/fail/ref=T7030606.out -XDrawDiagnostics T7030606.java */ class T7030606 { class E1 extends Exception { } class E2 extends E1 { } void e1() throws E1 { } void e2() throws E2 { } void m1() { try { e1(); e2(); } catch (NonExistentType | E2 | E1 e) { } } void m2() { try { e1(); e2(); } catch (NonExistentType | E1 | E2 e) { } } void m3() { try { e1(); e2(); } catch (E2 | NonExistentType | E1 e) { } } void m4() { try { e1(); e2(); } catch (E1 | NonExistentType | E2 e) { } } void m5() { try { e1(); e2(); } catch (E2 | E1 | NonExistentType e) { } } void m6() { try { e1(); e2(); } catch (E1 | E2 | NonExistentType e) { } } }
1,073
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SubTest.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/7005371/SubTest.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.util.*; class SubTest { interface Foo {} static class X1 extends Exception implements Foo {} static class X2 extends Exception implements Foo {} void test(boolean cond, List<String> ls) { try { if (cond) throw new X1(); else throw new X2(); } catch (X1 | X2 ex) {} } }
1,436
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
T7005371.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/7005371/T7005371.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 7005371 * @summary Multicatch: assertion error while generating LocalVariableTypeTable attribute * @compile -g SubTest.java * @run main T7005371 */ import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.LocalVariableTypeTable_attribute; import com.sun.tools.classfile.Method; import java.io.*; public class T7005371 { static final String SUBTEST_NAME = SubTest.class.getName() + ".class"; static final String TEST_METHOD_NAME = "test"; static final int LVT_LENGTH = 1; static final String LVT_SIG_TYPE = "Ljava/util/List<Ljava/lang/String;>;"; public static void main(String... args) throws Exception { new T7005371().run(); } public void run() throws Exception { String workDir = System.getProperty("test.classes"); System.out.println(workDir); File compiledTest = new File(workDir, SUBTEST_NAME); verifyLocalVariableTypeTableAttr(compiledTest); } void verifyLocalVariableTypeTableAttr(File f) { System.err.println("verify: " + f); try { ClassFile cf = ClassFile.read(f); Method testMethod = null; for (Method m : cf.methods) { if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) { testMethod = m; break; } } if (testMethod == null) { throw new Error("Missing method: " + TEST_METHOD_NAME); } Code_attribute code = (Code_attribute)testMethod.attributes.get(Attribute.Code); if (code == null) { throw new Error("Missing Code attribute for method: " + TEST_METHOD_NAME); } LocalVariableTypeTable_attribute lvt_table = (LocalVariableTypeTable_attribute)code.attributes.get(Attribute.LocalVariableTypeTable); if (lvt_table == null) { throw new Error("Missing LocalVariableTypeTable attribute for method: " + TEST_METHOD_NAME); } if (lvt_table.local_variable_table_length != LVT_LENGTH) { throw new Error("LocalVariableTypeTable has wrong size" + "\nfound: " + lvt_table.local_variable_table_length + "\nrequired: " + LVT_LENGTH); } String sig = cf.constant_pool.getUTF8Value(lvt_table.local_variable_table[0].signature_index); if (sig == null || !sig.equals(LVT_SIG_TYPE)) { throw new Error("LocalVariableTypeTable has wrong signature" + "\nfound: " + sig + "\nrequired: " + LVT_SIG_TYPE); } } catch (Exception e) { e.printStackTrace(); throw new Error("error reading " + f +": " + e); } } }
4,016
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Member.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/model/Member.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 javax.lang.model.element.ElementKind; /** * Annotation used by ModelChecker to mark a member that is to be checked */ @interface Member { ElementKind value(); }
1,226
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ModelChecker.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/model/ModelChecker.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 6993963 * @summary Project Coin: Use precise exception analysis for effectively final catch parameters * @library ../../lib * @build JavacTestingAbstractProcessor ModelChecker * @compile -processor ModelChecker Model01.java */ import com.sun.source.tree.CatchTree; import com.sun.source.util.TreePathScanner; import com.sun.source.util.Trees; import com.sun.source.util.TreePath; import java.util.Set; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeKind; import javax.lang.model.type.UnionType; import javax.lang.model.type.UnknownTypeException; import javax.lang.model.util.SimpleTypeVisitor6; import javax.lang.model.util.SimpleTypeVisitor7; @SupportedAnnotationTypes("Check") public class ModelChecker extends JavacTestingAbstractProcessor { @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) return true; Trees trees = Trees.instance(processingEnv); TypeElement testAnno = elements.getTypeElement("Check"); for (Element elem: roundEnv.getElementsAnnotatedWith(testAnno)) { TreePath p = trees.getPath(elem); new MulticatchParamTester(trees).scan(p, null); } return true; } class MulticatchParamTester extends TreePathScanner<Void, Void> { Trees trees; public MulticatchParamTester(Trees trees) { super(); this.trees = trees; } @Override public Void visitCatch(CatchTree node, Void p) { TreePath param = new TreePath(getCurrentPath(), node.getParameter()); Element ex = trees.getElement(param); validateUnionTypeInfo(ex); if (ex.getSimpleName().contentEquals("ex")) { assertTrue(ex.getKind() == ElementKind.EXCEPTION_PARAMETER, "Expected EXCEPTION_PARAMETER - found " + ex.getKind()); for (Element e : types.asElement(trees.getLub(node)).getEnclosedElements()) { Member m = e.getAnnotation(Member.class); if (m != null) { assertTrue(e.getKind() == m.value(), "Expected " + m.value() + " - found " + e.getKind()); } } assertTrue(assertionCount == 9, "Expected 9 assertions - found " + assertionCount); } return super.visitCatch(node, p); } } private void validateUnionTypeInfo(Element ex) { UnionTypeInfo ut = ex.getAnnotation(UnionTypeInfo.class); assertTrue(ut != null, "UnionType annotation must be present"); TypeMirror expectedUnionType = ex.asType(); assertTrue(expectedUnionType.getKind() == TypeKind.UNION, "UNION kind expected"); try { new SimpleTypeVisitor6<Void, Void>(){}.visit(expectedUnionType); throw new RuntimeException("Expected UnknownTypeException not thrown."); } catch (UnknownTypeException ute) { ; // Expected } UnionType unionType = new SimpleTypeVisitor7<UnionType, Void>(){ @Override protected UnionType defaultAction(TypeMirror e, Void p) {return null;} @Override public UnionType visitUnion(UnionType t, Void p) {return t;} }.visit(expectedUnionType); assertTrue(unionType != null, "Must get a non-null union type."); assertTrue(ut.value().length == unionType.getAlternatives().size(), "Cardinalities do not match"); String[] typeNames = ut.value(); for(int i = 0; i < typeNames.length; i++) { TypeMirror typeFromAnnotation = nameToType(typeNames[i]); assertTrue(types.isSameType(typeFromAnnotation, unionType.getAlternatives().get(i)), "Types were not equal."); } } private TypeMirror nameToType(String name) { return elements.getTypeElement(name).asType(); } private static void assertTrue(boolean cond, String msg) { assertionCount++; if (!cond) throw new AssertionError(msg); } static int assertionCount = 0; }
5,504
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
UnionTypeInfo.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/model/UnionTypeInfo.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. */ /** * Used by ModelChecker to validate the modeling information of a union type. */ @interface UnionTypeInfo { String[] value(); }
1,189
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Model01.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/model/Model01.java
/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import javax.lang.model.element.ElementKind; @Check class Test { class A extends Exception { @Member(ElementKind.METHOD) public void m() {}; @Member(ElementKind.FIELD) public Object f; } class B1 extends A {} class B2 extends A {} void test(){ try { if (true) throw new B1(); else throw new B2(); } catch(@UnionTypeInfo({"Test.B1", "Test.B2"}) B1 | B2 ex) { } } }
1,562
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Check.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/multicatch/model/Check.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. */ /** * Annotation used by ModelChecker to mark the class whose model is to be checked */ @interface Check {}
1,162
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
test_ff2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ConstantValues/test_ff2.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. */ class test_ff { public final String fnl_str = "String found at runtime"; } // end Class test_ff
1,152
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstValInit.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ConstantValues/ConstValInit.java
/* * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please 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 4253590 * @summary Verify that non-static constant fields are initialized correctly. * Also, while a runtime initialization is required, verify that * references to such fields via a simple variable are correctly * recognized as constant expressions. * @author maddox (adapted from bug report) * * @run compile ConstValInit.java * @run main ConstValInit */ public class ConstValInit { public final String fnl_str = "Test string"; public final int fnl_int = 1; public static void main(String args[]) throws Exception { Class checksClass = Class.forName("ConstValInit"); ConstValInit checksObject = (ConstValInit)(checksClass.newInstance()); String reflected_fnl_str = (String)checksClass.getField("fnl_str").get(checksObject); if (!checksObject.fnl_str.equals(reflected_fnl_str)) { throw new Exception("FAILED: ordinary and reflected field values differ"); } } void foo() { // Statement below will not compile if fnl_int is not recognized // as a constant expression. switch (1) { case fnl_int: break; } } }
2,243
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
test_ff1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ConstantValues/test_ff1.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. */ class test_ff { public final String fnl_str = "String available at compile-time"; } // end Class test_ff
1,161
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstValInlining.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/ConstantValues/ConstValInlining.java
/* * Copyright (c) 1999, 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 4253590 4255513 4115099 * @summary Verify that non-static fields with a ConstValue attribute inlined only when used as a simple name. * @author maddox, gafter (adapted from leo's bug report) * * @run compile test_ff1.java * @run compile ConstValInlining.java * @run compile test_ff2.java * @run main ConstValInlining */ public class ConstValInlining { void test() throws Exception { Class checksClass = Class.forName("test_ff"); test_ff obj = new test_ff(); String reflected_fnl_str = (String)checksClass.getField("fnl_str").get(obj); T t = new T(); // even when used by a qualified name, the compiler must inline if (t.fnl_str.equals(reflected_fnl_str)) throw new Exception("FAILED: compiler failed to inline a qualified nonstatic constant"); // when used by an unqualified name, they must not differ t.test(reflected_fnl_str); } static class T extends test_ff { void test(String reflected) throws Exception { // when used by an unqualified qualified name, they must differ if (fnl_str.equals(reflected)) throw new Exception("FAILED: compiler failed to inline an unqualified nonstatic constant"); } }; public static void main(String args[]) throws Exception { new ConstValInlining().test(); } }
2,453
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DepAnn.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/tools/javac/warnings/DepAnn.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 4986256 * @compile DepAnn.java * @compile -Xlint:dep-ann DepAnn.java * @compile -Xlint:all DepAnn.java * @compile -Werror DepAnn.java * @compile/fail -Werror -Xlint:dep-ann DepAnn.java * @compile/fail -Werror -Xlint:all,-path DepAnn.java */ // control: this class should generate warnings /** @deprecated */ class DepAnn { /** @deprecated */ void m1(int i) { } } // tests: the warnings that would otherwise be generated should all be suppressed @SuppressWarnings("dep-ann") /** @deprecated */ class DepAnn1 { /** @deprecated */ void m1(int i) { /** @deprecated */ int x = 3; } } class DepAnn2 { @SuppressWarnings("dep-ann") /** @deprecated */ class Bar { /** @deprecated */ void m1(int i) { } } @SuppressWarnings("dep-ann") /** @deprecated */ void m2(int i) { } @SuppressWarnings("dep-ann") static int x = new DepAnn2() { /** @deprecated */ int m1(int i) { return 0; } }.m1(0); } // this class should produce warnings because @SuppressWarnings should not be inherited /** @deprecated */ class DepAnn3 extends DepAnn1 { /** @deprecated */ void m1(int i) { } }
2,329
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z