diff --git a/src/share/classes/com/sun/tools/javac/code/Types.java b/src/share/classes/com/sun/tools/javac/code/Types.java index 8a3b4235714b6f7a86f2e7f0609edab1050f52f2..d3b6f4bcaf6fddbb54b0f15d9efa954bad1679c6 100644 --- a/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2864,7 +2864,7 @@ public class Types { if (elemtype == t.elemtype) return t; else - return new ArrayType(upperBound(elemtype), t.tsym); + return new ArrayType(elemtype, t.tsym); } @Override diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java index 6c523089e4a7387aa3915d74cf62f798f2365637..ff4d048fd5ca4a3070aac810503c1ef5159646ec 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -345,7 +345,7 @@ public class Resolve { boolean isAccessible(Env env, Type t, boolean checkInner) { return (t.hasTag(ARRAY)) - ? isAccessible(env, types.elemtype(t)) + ? isAccessible(env, types.upperBound(types.elemtype(t))) : isAccessible(env, t.tsym, checkInner); } diff --git a/test/tools/javac/generics/7034511/T7034511a.java b/test/tools/javac/generics/7034511/T7034511a.java index af1f5a97b1b83f292585442e2fb87e400921db52..26418d6308e7b7c719474d61cc64393e413bf3e0 100644 --- a/test/tools/javac/generics/7034511/T7034511a.java +++ b/test/tools/javac/generics/7034511/T7034511a.java @@ -1,13 +1,10 @@ /* * @test /nodynamiccopyright/ - * @ignore 7041019 Bogus type-variable substitution with array types with dependencies on accessibility check - * @bug 7034511 7040883 + * @bug 7034511 7040883 7041019 * @summary Loophole in typesafety * @compile/fail/ref=T7034511a.out -XDrawDiagnostics T7034511a.java */ -// backing out 7034511, see 7040883 - class T7034511a { interface A { diff --git a/test/tools/javac/generics/7034511/T7034511a.out b/test/tools/javac/generics/7034511/T7034511a.out index e05cd632368bd3b998597b49af92bee27856b7ff..4ce8eafd27a32cb1497a7c5c022266f11a1ec625 100644 --- a/test/tools/javac/generics/7034511/T7034511a.out +++ b/test/tools/javac/generics/7034511/T7034511a.out @@ -1,2 +1,2 @@ -T7034511a.java:18:14: compiler.err.cant.apply.symbol: kindname.method, foo, compiler.misc.type.captureof: 1, ?[], java.lang.String[], kindname.interface, T7034511a.A, (compiler.misc.no.conforming.assignment.exists: java.lang.String[], compiler.misc.type.captureof: 1, ?[]) +T7034511a.java:18:14: compiler.err.cant.apply.symbol: kindname.method, foo, compiler.misc.type.captureof: 1, ?[], java.lang.String[], kindname.interface, T7034511a.A, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String[], compiler.misc.type.captureof: 1, ?[])) 1 error diff --git a/test/tools/javac/generics/7034511/T7034511b.java b/test/tools/javac/generics/7034511/T7034511b.java index 2adebca079dadd012cd71177f540c69b1b7df912..93d16787e3c81d082075aa3fcddc6d66374adfea 100644 --- a/test/tools/javac/generics/7034511/T7034511b.java +++ b/test/tools/javac/generics/7034511/T7034511b.java @@ -1,13 +1,10 @@ /* * @test /nodynamiccopyright/ - * @ignore 7041019 Bogus type-variable substitution with array types with dependencies on accessibility check - * @bug 7034511 7040883 + * @bug 7034511 7040883 7041019 * @summary Loophole in typesafety * @compile/fail/ref=T7034511b.out -XDrawDiagnostics T7034511b.java */ -// backing out 7034511, see 7040883 - class T7034511b { static class MyList { E toArray(E[] e) { return null; } diff --git a/test/tools/javac/generics/7034511/T7034511b.out b/test/tools/javac/generics/7034511/T7034511b.out index 8d0d9335b1018788f96f3ec5c06c78007b26d58b..1cff6c38d3892f206a7ab9d069af6df5c7dffdac 100644 --- a/test/tools/javac/generics/7034511/T7034511b.out +++ b/test/tools/javac/generics/7034511/T7034511b.out @@ -1,2 +1,2 @@ -T7034511b.java:14:11: compiler.err.cant.apply.symbol: kindname.method, toArray, compiler.misc.type.captureof: 1, ?[], java.lang.Object[], kindname.class, T7034511b.MyList, (compiler.misc.no.conforming.assignment.exists: java.lang.Object[], compiler.misc.type.captureof: 1, ?[]) +T7034511b.java:14:11: compiler.err.cant.apply.symbol: kindname.method, toArray, compiler.misc.type.captureof: 1, ?[], java.lang.Object[], kindname.class, T7034511b.MyList, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object[], compiler.misc.type.captureof: 1, ?[])) 1 error diff --git a/test/tools/javac/generics/7034511/T7041019.java b/test/tools/javac/generics/7034511/T7041019.java new file mode 100644 index 0000000000000000000000000000000000000000..78b7bed7101be0eeb6e68b0d8e27c6b2b10c3404 --- /dev/null +++ b/test/tools/javac/generics/7034511/T7041019.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 7034511 7040883 7041019 + * @summary Bogus type-variable substitution with array types with dependencies on accessibility check + * + * @compile T7041019.java + */ +import java.util.List; + +class T7041019 { + List[] m(List l) { return null; } + + void test(List ls) { + int i = m(ls).length; + } +}