test/tools/javac/generics/6711619/T6711619a.java

Thu, 23 Oct 2008 17:59:43 +0100

author
mcimadamore
date
Thu, 23 Oct 2008 17:59:43 +0100
changeset 155
4d2d8b6459e1
child 384
ed31953ca025
permissions
-rw-r--r--

6711619: javac doesn't allow access to protected members in intersection types
Summary: Accordingly to new accessibility rules all members of intersection types (but private ones) should be accessible
Reviewed-by: jjg

mcimadamore@155 1 /*
mcimadamore@155 2 * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
mcimadamore@155 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@155 4 *
mcimadamore@155 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@155 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@155 7 * published by the Free Software Foundation.
mcimadamore@155 8 *
mcimadamore@155 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@155 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@155 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@155 12 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@155 13 * accompanied this code).
mcimadamore@155 14 *
mcimadamore@155 15 * You should have received a copy of the GNU General Public License version
mcimadamore@155 16 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@155 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@155 18 *
mcimadamore@155 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
mcimadamore@155 20 * CA 95054 USA or visit www.sun.com if you need additional information or
mcimadamore@155 21 * have any questions.
mcimadamore@155 22 */
mcimadamore@155 23
mcimadamore@155 24 /*
mcimadamore@155 25 * @test
mcimadamore@155 26 * @bug 6711619
mcimadamore@155 27 *
mcimadamore@155 28 * @summary javac doesn't allow access to protected members in intersection types
mcimadamore@155 29 * @author Maurizio Cimadamore
mcimadamore@155 30 *
mcimadamore@155 31 * @compile/fail/ref=T6711619a.out -XDrawDiagnostics T6711619a.java
mcimadamore@155 32 */
mcimadamore@155 33 class T6711619a {
mcimadamore@155 34
mcimadamore@155 35 static class A {
mcimadamore@155 36 private void a() {}
mcimadamore@155 37 private A a;
mcimadamore@155 38 }
mcimadamore@155 39 static class B extends A {
mcimadamore@155 40 private B b() {}
mcimadamore@155 41 private B b;
mcimadamore@155 42 }
mcimadamore@155 43 static interface I{
mcimadamore@155 44 void i();
mcimadamore@155 45 }
mcimadamore@155 46 static interface I1{
mcimadamore@155 47 void i1();
mcimadamore@155 48 }
mcimadamore@155 49 static class E extends B implements I, I1{
mcimadamore@155 50 public void i() {}
mcimadamore@155 51 public void i1() {}
mcimadamore@155 52 }
mcimadamore@155 53 static class C<W extends B & I1, T extends W>{
mcimadamore@155 54 T t;
mcimadamore@155 55 W w;
mcimadamore@155 56 C(W w, T t) {
mcimadamore@155 57 this.w = w;
mcimadamore@155 58 this.t = t;
mcimadamore@155 59 }
mcimadamore@155 60 }
mcimadamore@155 61
mcimadamore@155 62 static void testMemberMethods(C<? extends A, ? extends I> arg) {
mcimadamore@155 63 arg.t.a();
mcimadamore@155 64 arg.t.b();
mcimadamore@155 65 }
mcimadamore@155 66
mcimadamore@155 67 static void testMemberFields(C<? extends A, ? extends I> arg) {
mcimadamore@155 68 A ta; B tb;
mcimadamore@155 69 ta = arg.t.a;
mcimadamore@155 70 tb = arg.t.b;
mcimadamore@155 71 ta = arg.w.a;
mcimadamore@155 72 tb = arg.w.b;
mcimadamore@155 73 }
mcimadamore@155 74 }

mercurial