mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 16:44:36 +02:00
8075166: Group 14d: golden files for tests in tools/javac/generics/wildcards dir
Reviewed-by: jjg
This commit is contained in:
parent
4676493261
commit
945f55124f
34 changed files with 170 additions and 1258 deletions
|
@ -1,33 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
* @test /nodynamiccopyright/
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please 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 4897892
|
* @bug 4897892
|
||||||
* @summary cast to parameterized type is accepted although it should be rejected
|
* @summary cast to parameterized type is accepted although it should be rejected
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile/fail -Werror -Xlint:unchecked AmbiguousCast.java
|
* @compile/ref=AmbiguousCast.out -XDrawDiagnostics -Xlint:unchecked AmbiguousCast.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
AmbiguousCast.java:25:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Object, Test.GenericWrapper<java.lang.String>
|
||||||
|
1 warning
|
|
@ -1,33 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
* @test /nodynamiccopyright/
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please 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 4916634
|
* @bug 4916634
|
||||||
* @summary Wildcard capture
|
* @summary Wildcard capture
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile/fail Capture.java
|
* @compile/fail/ref=Capture.out -XDrawDiagnostics Capture.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class X<T> {}
|
class X<T> {}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Capture.java:14:9: compiler.err.cant.apply.symbol: kindname.method, f4, X<X<T>>, X<X<? extends java.lang.Number>>, kindname.class, Capture, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: X<X<? extends java.lang.Number>>, X<X<T>>))
|
||||||
|
1 error
|
125
langtools/test/tools/javac/generics/wildcards/neg/CastFail.java
Normal file
125
langtools/test/tools/javac/generics/wildcards/neg/CastFail.java
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please 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 4916607
|
||||||
|
* @summary Test casts (errors)
|
||||||
|
* @author gafter
|
||||||
|
*
|
||||||
|
* @compile/fail/ref=CastFail.out -XDrawDiagnostics CastFail.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class CastFail {
|
||||||
|
|
||||||
|
// --- Directly transferring parameters ---
|
||||||
|
|
||||||
|
private class AA<T> { }
|
||||||
|
|
||||||
|
private class AB<T> extends AA<T> { }
|
||||||
|
private class AC<T> extends AA<Vector<T>> { }
|
||||||
|
private class AD<T> extends AA<Vector<? extends T>> { }
|
||||||
|
private class AE<T> extends AA<Vector<? super T>> { }
|
||||||
|
private class AF<T> extends AA<T[]> { }
|
||||||
|
private class AG<T> extends AA<String> { }
|
||||||
|
|
||||||
|
private void parameterTransfer() {
|
||||||
|
Object o;
|
||||||
|
|
||||||
|
o = (AB<String>) (AA<Number>) null; // <<fail 1>>
|
||||||
|
o = (AC<String>) (AA<Vector<Number>>) null; // <<fail 2>>
|
||||||
|
o = (AC<String>) (AA<Stack<String>>) null; // <<fail 3>>
|
||||||
|
o = (AD<String>) (AA<Vector<? extends Number>>) null; // <<fail 4>>
|
||||||
|
o = (AE<Number>) (AA<Vector<? super String>>) null; // <<fail 5>>
|
||||||
|
o = (AF<String>) (AA<Number[]>) null; // <<fail 6>>
|
||||||
|
o = (AG<?>) (AA<Number>) null; // <<fail 7>>
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Inconsistent matches ---
|
||||||
|
|
||||||
|
private class BA<T> { }
|
||||||
|
private class BB<T, S> { }
|
||||||
|
|
||||||
|
private class BC<T> extends BA<Integer> { }
|
||||||
|
private class BD<T> extends BB<T, T> { }
|
||||||
|
|
||||||
|
private void inconsistentMatches() {
|
||||||
|
Object o;
|
||||||
|
|
||||||
|
o = (BC<?>) (BA<String>) null; // <<fail 8>>
|
||||||
|
o = (BD<String>) (BB<String, Number>) null; // <<fail 9>>
|
||||||
|
o = (BD<String>) (BB<Number, String>) null; // <<fail 10>>
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Transferring parameters via supertypes ---
|
||||||
|
|
||||||
|
private interface CA<T> { }
|
||||||
|
private interface CB<T> extends CA<T> { }
|
||||||
|
private interface CC<T> extends CA<T> { }
|
||||||
|
|
||||||
|
private class CD<T> implements CB<T> { }
|
||||||
|
private interface CE<T> extends CC<T> { }
|
||||||
|
|
||||||
|
private interface CF<S> { }
|
||||||
|
private interface CG<T> { }
|
||||||
|
private class CH<S, T> implements CF<S>, CG<T> { }
|
||||||
|
private interface CI<S> extends CF<S> { }
|
||||||
|
private interface CJ<T> extends CG<T> { }
|
||||||
|
private interface CK<S, T> extends CI<S>, CJ<T> { }
|
||||||
|
|
||||||
|
private void supertypeParameterTransfer() {
|
||||||
|
Object o;
|
||||||
|
CD<?> cd = (CE<?>) null; // <<fail 11>>
|
||||||
|
CE<?> ce = (CD<?>) null; // <<fail 12>>
|
||||||
|
o = (CE<Number>) (CD<String>) null; // <<fail 13>>
|
||||||
|
|
||||||
|
// 4916622: unnecessary warning with cast
|
||||||
|
// o = (CH<String, Integer>) (CK<String, Integer>) null; // <<pass>> <<todo: cast-infer>>
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Disjoint ---
|
||||||
|
|
||||||
|
private interface DA<T> { }
|
||||||
|
private interface DB<T> extends DA<T> { }
|
||||||
|
private interface DC<T> extends DA<Integer> { }
|
||||||
|
|
||||||
|
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
||||||
|
Object o;
|
||||||
|
|
||||||
|
// Classes
|
||||||
|
o = (DA<Number>) (DA<Integer>) null; // <<fail 14>>
|
||||||
|
o = (DA<? extends Integer>) (DA<Number>) null; // <<fail 15>>
|
||||||
|
o = (DA<? super Number>) (DA<Integer>) null; // <<fail 16>>
|
||||||
|
o = (DA<? extends Runnable>) (DA<? extends String>) null; // <<fail 17>>
|
||||||
|
o = (DA<? super Number>) (DA<? extends Integer>) null; // <<fail 18>>
|
||||||
|
|
||||||
|
// Typevars
|
||||||
|
o = (DA<? extends String>) (DA<I>) null; // <<fail 19>>
|
||||||
|
o = (DA<S>) (DA<R>) null; // <<fail 20>>
|
||||||
|
|
||||||
|
// Raw (asymmetrical!)
|
||||||
|
o = (DC<?>) (DA<? super String>) null; // <<fail 21>>
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
CastFail.java:51:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.AA<java.lang.Number>, CastFail.AB<java.lang.String>)
|
||||||
|
CastFail.java:52:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.AA<java.util.Vector<java.lang.Number>>, CastFail.AC<java.lang.String>)
|
||||||
|
CastFail.java:53:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.AA<java.util.Stack<java.lang.String>>, CastFail.AC<java.lang.String>)
|
||||||
|
CastFail.java:54:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.AA<java.util.Vector<? extends java.lang.Number>>, CastFail.AD<java.lang.String>)
|
||||||
|
CastFail.java:55:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.AA<java.util.Vector<? super java.lang.String>>, CastFail.AE<java.lang.Number>)
|
||||||
|
CastFail.java:56:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.AA<java.lang.Number[]>, CastFail.AF<java.lang.String>)
|
||||||
|
CastFail.java:57:21: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.AA<java.lang.Number>, CastFail.AG<?>)
|
||||||
|
CastFail.java:71:21: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.BA<java.lang.String>, CastFail.BC<?>)
|
||||||
|
CastFail.java:72:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.BB<java.lang.String,java.lang.Number>, CastFail.BD<java.lang.String>)
|
||||||
|
CastFail.java:73:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.BB<java.lang.Number,java.lang.String>, CastFail.BD<java.lang.String>)
|
||||||
|
CastFail.java:94:20: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.CE<compiler.misc.type.captureof: 1, ?>, CastFail.CD<?>)
|
||||||
|
CastFail.java:95:20: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.CD<compiler.misc.type.captureof: 1, ?>, CastFail.CE<?>)
|
||||||
|
CastFail.java:96:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.CD<java.lang.String>, CastFail.CE<java.lang.Number>)
|
||||||
|
CastFail.java:112:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<java.lang.Integer>, CastFail.DA<java.lang.Number>)
|
||||||
|
CastFail.java:113:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<java.lang.Number>, CastFail.DA<? extends java.lang.Integer>)
|
||||||
|
CastFail.java:114:34: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<java.lang.Integer>, CastFail.DA<? super java.lang.Number>)
|
||||||
|
CastFail.java:115:38: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<compiler.misc.type.captureof: 1, ? extends java.lang.String>, CastFail.DA<? extends java.lang.Runnable>)
|
||||||
|
CastFail.java:116:34: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, CastFail.DA<? super java.lang.Number>)
|
||||||
|
CastFail.java:119:36: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<I>, CastFail.DA<? extends java.lang.String>)
|
||||||
|
CastFail.java:120:21: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<R>, CastFail.DA<S>)
|
||||||
|
CastFail.java:123:21: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: CastFail.DA<compiler.misc.type.captureof: 1, ? super java.lang.String>, CastFail.DC<?>)
|
||||||
|
21 errors
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail1.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Directly transferring parameters ---
|
|
||||||
|
|
||||||
private class AA<T> { }
|
|
||||||
|
|
||||||
private class AB<T> extends AA<T> { }
|
|
||||||
private class AC<T> extends AA<Vector<T>> { }
|
|
||||||
private class AD<T> extends AA<Vector<? extends T>> { }
|
|
||||||
private class AE<T> extends AA<Vector<? super T>> { }
|
|
||||||
private class AF<T> extends AA<T[]> { }
|
|
||||||
private class AG<T> extends AA<String> { }
|
|
||||||
|
|
||||||
private void parameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (AB<String>) (AA<Number>) null; // <<fail 1>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail10.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Inconsistent matches ---
|
|
||||||
|
|
||||||
private class BA<T> { }
|
|
||||||
private class BB<T, S> { }
|
|
||||||
|
|
||||||
private class BC<T> extends BA<Integer> { }
|
|
||||||
private class BD<T> extends BB<T, T> { }
|
|
||||||
|
|
||||||
private void inconsistentMatches() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (BD<String>) (BB<Number, String>) null; // <<fail 10>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail11.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Transferring parameters via supertypes ---
|
|
||||||
|
|
||||||
private interface CA<T> { }
|
|
||||||
private interface CB<T> extends CA<T> { }
|
|
||||||
private interface CC<T> extends CA<T> { }
|
|
||||||
|
|
||||||
private class CD<T> implements CB<T> { }
|
|
||||||
private interface CE<T> extends CC<T> { }
|
|
||||||
|
|
||||||
private interface CF<S> { }
|
|
||||||
private interface CG<T> { }
|
|
||||||
private class CH<S, T> implements CF<S>, CG<T> { }
|
|
||||||
private interface CI<S> extends CF<S> { }
|
|
||||||
private interface CJ<T> extends CG<T> { }
|
|
||||||
private interface CK<S, T> extends CI<S>, CJ<T> { }
|
|
||||||
|
|
||||||
private void supertypeParameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
CD<?> cd = (CE<?>) null; // <<fail 11>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail12.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Transferring parameters via supertypes ---
|
|
||||||
|
|
||||||
private interface CA<T> { }
|
|
||||||
private interface CB<T> extends CA<T> { }
|
|
||||||
private interface CC<T> extends CA<T> { }
|
|
||||||
|
|
||||||
private class CD<T> implements CB<T> { }
|
|
||||||
private interface CE<T> extends CC<T> { }
|
|
||||||
|
|
||||||
private interface CF<S> { }
|
|
||||||
private interface CG<T> { }
|
|
||||||
private class CH<S, T> implements CF<S>, CG<T> { }
|
|
||||||
private interface CI<S> extends CF<S> { }
|
|
||||||
private interface CJ<T> extends CG<T> { }
|
|
||||||
private interface CK<S, T> extends CI<S>, CJ<T> { }
|
|
||||||
|
|
||||||
private void supertypeParameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
CE<?> ce = (CD<?>) null; // <<fail 12>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail13.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Transferring parameters via supertypes ---
|
|
||||||
|
|
||||||
private interface CA<T> { }
|
|
||||||
private interface CB<T> extends CA<T> { }
|
|
||||||
private interface CC<T> extends CA<T> { }
|
|
||||||
|
|
||||||
private class CD<T> implements CB<T> { }
|
|
||||||
private interface CE<T> extends CC<T> { }
|
|
||||||
|
|
||||||
private interface CF<S> { }
|
|
||||||
private interface CG<T> { }
|
|
||||||
private class CH<S, T> implements CF<S>, CG<T> { }
|
|
||||||
private interface CI<S> extends CF<S> { }
|
|
||||||
private interface CJ<T> extends CG<T> { }
|
|
||||||
private interface CK<S, T> extends CI<S>, CJ<T> { }
|
|
||||||
|
|
||||||
private void supertypeParameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
o = (CE<Number>) (CD<String>) null; // <<fail 13>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail14.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
// Classes
|
|
||||||
o = (DA<Number>) (DA<Integer>) null; // <<fail 14>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail15.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (DA<? extends Integer>) (DA<Number>) null; // <<fail 15>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail16.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (DA<? super Number>) (DA<Integer>) null; // <<fail 16>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail17.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (DA<? extends Runnable>) (DA<? extends String>) null; // <<fail 17>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail18.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (DA<? super Number>) (DA<? extends Integer>) null; // <<fail 18>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail19.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (DA<? extends String>) (DA<I>) null; // <<fail 19>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail2.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Directly transferring parameters ---
|
|
||||||
|
|
||||||
private class AA<T> { }
|
|
||||||
|
|
||||||
private class AB<T> extends AA<T> { }
|
|
||||||
private class AC<T> extends AA<Vector<T>> { }
|
|
||||||
private class AD<T> extends AA<Vector<? extends T>> { }
|
|
||||||
private class AE<T> extends AA<Vector<? super T>> { }
|
|
||||||
private class AF<T> extends AA<T[]> { }
|
|
||||||
private class AG<T> extends AA<String> { }
|
|
||||||
|
|
||||||
private void parameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (AC<String>) (AA<Vector<Number>>) null; // <<fail 2>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail20.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (DA<S>) (DA<R>) null; // <<fail 20>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail20.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Disjoint ---
|
|
||||||
|
|
||||||
private interface DA<T> { }
|
|
||||||
private interface DB<T> extends DA<T> { }
|
|
||||||
private interface DC<T> extends DA<Integer> { }
|
|
||||||
|
|
||||||
private <N extends Number, I extends Integer, R extends Runnable, S extends String> void disjointness() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (DC<?>) (DA<? super String>) null; // <<fail 21>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail3.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Directly transferring parameters ---
|
|
||||||
|
|
||||||
private class AA<T> { }
|
|
||||||
|
|
||||||
private class AB<T> extends AA<T> { }
|
|
||||||
private class AC<T> extends AA<Vector<T>> { }
|
|
||||||
private class AD<T> extends AA<Vector<? extends T>> { }
|
|
||||||
private class AE<T> extends AA<Vector<? super T>> { }
|
|
||||||
private class AF<T> extends AA<T[]> { }
|
|
||||||
private class AG<T> extends AA<String> { }
|
|
||||||
|
|
||||||
private void parameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (AC<String>) (AA<Stack<String>>) null; // <<fail 3>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail4.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Directly transferring parameters ---
|
|
||||||
|
|
||||||
private class AA<T> { }
|
|
||||||
|
|
||||||
private class AB<T> extends AA<T> { }
|
|
||||||
private class AC<T> extends AA<Vector<T>> { }
|
|
||||||
private class AD<T> extends AA<Vector<? extends T>> { }
|
|
||||||
private class AE<T> extends AA<Vector<? super T>> { }
|
|
||||||
private class AF<T> extends AA<T[]> { }
|
|
||||||
private class AG<T> extends AA<String> { }
|
|
||||||
|
|
||||||
private void parameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (AD<String>) (AA<Vector<? extends Number>>) null; // <<fail 4>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail5.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Directly transferring parameters ---
|
|
||||||
|
|
||||||
private class AA<T> { }
|
|
||||||
|
|
||||||
private class AB<T> extends AA<T> { }
|
|
||||||
private class AC<T> extends AA<Vector<T>> { }
|
|
||||||
private class AD<T> extends AA<Vector<? extends T>> { }
|
|
||||||
private class AE<T> extends AA<Vector<? super T>> { }
|
|
||||||
private class AF<T> extends AA<T[]> { }
|
|
||||||
private class AG<T> extends AA<String> { }
|
|
||||||
|
|
||||||
private void parameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (AE<Number>) (AA<Vector<? super String>>) null; // <<fail 5>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail6.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Directly transferring parameters ---
|
|
||||||
|
|
||||||
private class AA<T> { }
|
|
||||||
|
|
||||||
private class AB<T> extends AA<T> { }
|
|
||||||
private class AC<T> extends AA<Vector<T>> { }
|
|
||||||
private class AD<T> extends AA<Vector<? extends T>> { }
|
|
||||||
private class AE<T> extends AA<Vector<? super T>> { }
|
|
||||||
private class AF<T> extends AA<T[]> { }
|
|
||||||
private class AG<T> extends AA<String> { }
|
|
||||||
|
|
||||||
private void parameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (AF<String>) (AA<Number[]>) null; // <<fail 6>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail7.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Directly transferring parameters ---
|
|
||||||
|
|
||||||
private class AA<T> { }
|
|
||||||
|
|
||||||
private class AB<T> extends AA<T> { }
|
|
||||||
private class AC<T> extends AA<Vector<T>> { }
|
|
||||||
private class AD<T> extends AA<Vector<? extends T>> { }
|
|
||||||
private class AE<T> extends AA<Vector<? super T>> { }
|
|
||||||
private class AF<T> extends AA<T[]> { }
|
|
||||||
private class AG<T> extends AA<String> { }
|
|
||||||
|
|
||||||
private void parameterTransfer() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (AG<?>) (AA<Number>) null; // <<fail 7>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail8.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Inconsistent matches ---
|
|
||||||
|
|
||||||
private class BA<T> { }
|
|
||||||
private class BB<T, S> { }
|
|
||||||
|
|
||||||
private class BC<T> extends BA<Integer> { }
|
|
||||||
private class BD<T> extends BB<T, T> { }
|
|
||||||
|
|
||||||
private void inconsistentMatches() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (BC<?>) (BA<String>) null; // <<fail 8>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 4916607
|
|
||||||
* @summary Test casts (legal, warning, and errors)
|
|
||||||
* @author gafter
|
|
||||||
*
|
|
||||||
* @compile/fail CastFail9.java
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
class CastTest {
|
|
||||||
|
|
||||||
// --- Inconsistent matches ---
|
|
||||||
|
|
||||||
private class BA<T> { }
|
|
||||||
private class BB<T, S> { }
|
|
||||||
|
|
||||||
private class BC<T> extends BA<Integer> { }
|
|
||||||
private class BD<T> extends BB<T, T> { }
|
|
||||||
|
|
||||||
private void inconsistentMatches() {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
o = (BD<String>) (BB<String, Number>) null; // <<fail 9>>
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,10 +24,10 @@
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4916607
|
* @bug 4916607
|
||||||
* @summary Test casts (legal, warning, and errors)
|
* @summary Test casts (legal)
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile/fail -Werror -Xlint:unchecked CastWarn14.java
|
* @compile CastTest.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -49,24 +49,13 @@ class CastTest {
|
||||||
Object o;
|
Object o;
|
||||||
|
|
||||||
o = (AB<String>) (AA<String>) null; // <<pass>>
|
o = (AB<String>) (AA<String>) null; // <<pass>>
|
||||||
o = (AB<String>) (AA<Number>) null; // <<fail 1>>
|
|
||||||
o = (AC<String>) (AA<Vector<String>>) null; // <<pass>>
|
o = (AC<String>) (AA<Vector<String>>) null; // <<pass>>
|
||||||
o = (AC<String>) (AA<Vector<Number>>) null; // <<fail 2>>
|
|
||||||
o = (AC<String>) (AA<Stack<String>>) null; // <<fail 3>>
|
|
||||||
|
|
||||||
o = (AD<Number>) (AA<Vector<? extends Number>>) null; // <<pass>>
|
o = (AD<Number>) (AA<Vector<? extends Number>>) null; // <<pass>>
|
||||||
o = (AD<String>) (AA<Vector<? extends Number>>) null; // <<fail 4>>
|
|
||||||
o = (AD<?>) (AA<Vector<? extends Object>>) null; // <<pass>>
|
o = (AD<?>) (AA<Vector<? extends Object>>) null; // <<pass>>
|
||||||
o = (AD<Object>) (AA<Vector<?>>) null; // <<pass>>
|
o = (AD<Object>) (AA<Vector<?>>) null; // <<pass>>
|
||||||
|
|
||||||
o = (AE<String>) (AA<Vector<? super String>>) null; // <<pass>>
|
o = (AE<String>) (AA<Vector<? super String>>) null; // <<pass>>
|
||||||
o = (AE<Number>) (AA<Vector<? super String>>) null; // <<fail 5>>
|
|
||||||
|
|
||||||
o = (AF<String>) (AA<String[]>) null; // <<pass>>
|
o = (AF<String>) (AA<String[]>) null; // <<pass>>
|
||||||
o = (AF<String>) (AA<Number[]>) null; // <<fail 6>>
|
|
||||||
|
|
||||||
o = (AG<?>) (AA<String>) null; // <<pass>>
|
o = (AG<?>) (AA<String>) null; // <<pass>>
|
||||||
o = (AG<?>) (AA<Number>) null; // <<fail 7>>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Inconsistent matches ---
|
// --- Inconsistent matches ---
|
||||||
|
@ -81,10 +70,7 @@ class CastTest {
|
||||||
Object o;
|
Object o;
|
||||||
|
|
||||||
o = (BC<?>) (BA<Integer>) null; // <<pass>>
|
o = (BC<?>) (BA<Integer>) null; // <<pass>>
|
||||||
o = (BC<?>) (BA<String>) null; // <<fail 8>>
|
|
||||||
o = (BD<String>) (BB<String, String>) null; // <<pass>>
|
o = (BD<String>) (BB<String, String>) null; // <<pass>>
|
||||||
o = (BD<String>) (BB<String, Number>) null; // <<fail 9>>
|
|
||||||
o = (BD<String>) (BB<Number, String>) null; // <<fail 10>>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void whyMustEverythingBeSo_______Complicated() {
|
private void whyMustEverythingBeSo_______Complicated() {
|
||||||
|
@ -113,10 +99,7 @@ class CastTest {
|
||||||
|
|
||||||
private void supertypeParameterTransfer() {
|
private void supertypeParameterTransfer() {
|
||||||
Object o;
|
Object o;
|
||||||
CD<?> cd = (CE<?>) null; // <<fail 11>>
|
|
||||||
CE<?> ce = (CD<?>) null; // <<fail 12>>
|
|
||||||
o = (CE<String>) (CD<String>) null; // <<pass>>
|
o = (CE<String>) (CD<String>) null; // <<pass>>
|
||||||
o = (CE<Number>) (CD<String>) null; // <<fail 13>>
|
|
||||||
|
|
||||||
// 4916622: unnecessary warning with cast
|
// 4916622: unnecessary warning with cast
|
||||||
// o = (CH<String, Integer>) (CK<String, Integer>) null; // <<pass>> <<todo: cast-infer>>
|
// o = (CH<String, Integer>) (CK<String, Integer>) null; // <<pass>> <<todo: cast-infer>>
|
||||||
|
@ -132,39 +115,24 @@ class CastTest {
|
||||||
Object o;
|
Object o;
|
||||||
|
|
||||||
// Classes
|
// Classes
|
||||||
o = (DA<Number>) (DA<Integer>) null; // <<fail 14>>
|
|
||||||
o = (DA<? extends Number>) (DA<Integer>) null; // <<pass>>
|
o = (DA<? extends Number>) (DA<Integer>) null; // <<pass>>
|
||||||
o = (DA<? extends Integer>) (DA<Number>) null; // <<fail 15>>
|
|
||||||
o = (DA<? super Integer>) (DA<Number>) null; // <<pass>>
|
o = (DA<? super Integer>) (DA<Number>) null; // <<pass>>
|
||||||
o = (DA<? super Number>) (DA<Integer>) null; // <<fail 16>>
|
|
||||||
o = (DA<?>) (DA<Integer>) null; // <<pass>>
|
o = (DA<?>) (DA<Integer>) null; // <<pass>>
|
||||||
|
|
||||||
o = (DA<? extends Runnable>) (DA<? extends String>) null; // <<fail 17>>
|
|
||||||
|
|
||||||
o = (DA<? super Number>) (DA<? extends Integer>) null; // <<fail 18>>
|
|
||||||
o = (DA<?>) (DA<? extends Integer>) null; // <<pass>>
|
o = (DA<?>) (DA<? extends Integer>) null; // <<pass>>
|
||||||
|
|
||||||
o = (DA<?>) (DA<? super String>) null; // <<pass>>
|
o = (DA<?>) (DA<? super String>) null; // <<pass>>
|
||||||
|
|
||||||
o = (DA<?>) (DA<?>) null; // <<pass>>
|
o = (DA<?>) (DA<?>) null; // <<pass>>
|
||||||
|
|
||||||
// Typevars
|
// Typevars
|
||||||
o = (DA<? extends Number>) (DA<I>) null; // <<pass>>
|
o = (DA<? extends Number>) (DA<I>) null; // <<pass>>
|
||||||
o = (DA<? extends String>) (DA<I>) null; // <<fail 19>>
|
|
||||||
|
|
||||||
o = (DA<S>) (DA<R>) null; // <<fail 20>>
|
|
||||||
|
|
||||||
// Raw (asymmetrical!)
|
// Raw (asymmetrical!)
|
||||||
o = (DA) (DB<Number>) null; // <<pass>>
|
o = (DA) (DB<Number>) null; // <<pass>>
|
||||||
o = (DA<?>) (DB) null; // <<pass>>
|
o = (DA<?>) (DB) null; // <<pass>>
|
||||||
o = (DA<? extends Object>) (DB) null; // <<pass>>
|
o = (DA<? extends Object>) (DB) null; // <<pass>>
|
||||||
|
|
||||||
o = (DB) (DA<Number>) null; // <<pass>>
|
o = (DB) (DA<Number>) null; // <<pass>>
|
||||||
o = (DB<?>) (DA) null; // <<pass>>
|
o = (DB<?>) (DA) null; // <<pass>>
|
||||||
o = (DB<? extends Object>) (DA) null; // <<pass>>
|
o = (DB<? extends Object>) (DA) null; // <<pass>>
|
||||||
|
|
||||||
o = (DC<?>) (DA<?>) null; // <<pass>>
|
o = (DC<?>) (DA<?>) null; // <<pass>>
|
||||||
o = (DC<?>) (DA<? super String>) null; // <<fail 21>>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,33 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
* @test /nodynamiccopyright/
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please 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 4916567
|
* @bug 4916567
|
||||||
* @summary Description
|
* @summary integrate improved wildcard substitution from CPH
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile/fail ParamCast.java
|
* @compile/fail/ref=ParamCast.out -XDrawDiagnostics ParamCast.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class A<T> {}
|
class A<T> {}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ParamCast.java:15:36: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: A<java.lang.String>, B<?,java.lang.Integer>)
|
||||||
|
1 error
|
|
@ -1,33 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
* @test /nodynamiccopyright/
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please 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 4916607 4931647
|
* @bug 4916607 4931647
|
||||||
* @summary an extends-bound (covariant) wildcard is like readonly
|
* @summary an extends-bound (covariant) wildcard is like readonly
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile/fail Readonly.java
|
* @compile/fail/ref=Readonly.out -XDrawDiagnostics Readonly.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Err<T> {
|
class Err<T> {
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Readonly.java:15:10: compiler.err.cant.apply.symbol: kindname.method, put, Err<compiler.misc.type.captureof: 1, ? extends java.lang.String>, Err<compiler.misc.type.captureof: 2, ? extends java.lang.String>, kindname.class, Err<T>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: Err<compiler.misc.type.captureof: 2, ? extends java.lang.String>, Err<compiler.misc.type.captureof: 1, ? extends java.lang.String>))
|
||||||
|
1 error
|
|
@ -1,33 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
* @test /nodynamiccopyright/
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please 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 4916607
|
* @bug 4916607
|
||||||
* @summary an unbounded (bivariant) wildcard doesn't allow reading
|
* @summary an unbounded (bivariant) wildcard doesn't allow reading
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile/fail Unbounded.java
|
* @compile/fail/ref=Unbounded.out -XDrawDiagnostics Unbounded.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Unbounded.java:14:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String)
|
||||||
|
1 error
|
Loading…
Add table
Add a link
Reference in a new issue