7034495: Javac asserts on usage of wildcards in bounds

Fri, 29 Apr 2011 16:05:56 +0100

author
mcimadamore
date
Fri, 29 Apr 2011 16:05:56 +0100
changeset 991
1092b67b3cad
parent 990
9a847a77205d
child 992
dc3d9ef880a1

7034495: Javac asserts on usage of wildcards in bounds
Summary: Problem with intersection types and wildcards causing javac to crash
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Types.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/wildcards/7034495/T7034495.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/wildcards/7034495/T7034495.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Apr 29 16:05:29 2011 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Apr 29 16:05:56 2011 +0100
     1.3 @@ -412,6 +412,7 @@
     1.4                      return
     1.5                          s.tag == BOT || s.tag == CLASS ||
     1.6                          s.tag == ARRAY || s.tag == TYPEVAR;
     1.7 +                case WILDCARD: //we shouldn't be here - avoids crash (see 7034495)
     1.8                  case NONE:
     1.9                      return false;
    1.10                  default:
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/generics/wildcards/7034495/T7034495.java	Fri Apr 29 16:05:56 2011 +0100
     2.3 @@ -0,0 +1,42 @@
     2.4 +/*
     2.5 + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug     7034495
    2.30 + * @summary Javac asserts on usage of wildcards in bounds
    2.31 + * @compile/fail/ref=T7034495.out -XDrawDiagnostics T7034495.java
    2.32 + */
    2.33 +class T7034495 {
    2.34 +
    2.35 +    interface A<T> {
    2.36 +        T foo();
    2.37 +    }
    2.38 +
    2.39 +    interface B<T> {
    2.40 +        T foo();
    2.41 +    }
    2.42 +
    2.43 +    interface C<T extends A<?> & B<?>> { }
    2.44 +
    2.45 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/generics/wildcards/7034495/T7034495.out	Fri Apr 29 16:05:56 2011 +0100
     3.3 @@ -0,0 +1,2 @@
     3.4 +T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B<?>, T7034495.A<?>, foo()
     3.5 +1 error

mercurial