test/tools/javac/generics/6531090/T6531090b.java

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

mcimadamore@19 1 /*
ohair@554 2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
mcimadamore@19 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@19 4 *
mcimadamore@19 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@19 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@19 7 * published by the Free Software Foundation.
mcimadamore@19 8 *
mcimadamore@19 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@19 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@19 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@19 12 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@19 13 * accompanied this code).
mcimadamore@19 14 *
mcimadamore@19 15 * You should have received a copy of the GNU General Public License version
mcimadamore@19 16 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@19 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@19 18 *
ohair@554 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 20 * or visit www.oracle.com if you need additional information or have any
ohair@554 21 * questions.
mcimadamore@19 22 */
mcimadamore@19 23
mcimadamore@19 24 /*
mcimadamore@19 25 * @test
mcimadamore@155 26 * @bug 6531090 6711619
mcimadamore@19 27 *
mcimadamore@19 28 * @summary Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore@19 29 * @author Maurizio Cimadamore
mcimadamore@19 30 *
mcimadamore@19 31 */
mcimadamore@19 32 public class T6531090b {
mcimadamore@19 33
mcimadamore@19 34 static class A {
mcimadamore@155 35 public void a1() {}
mcimadamore@155 36 protected void a2() {}
mcimadamore@155 37 void a3() {}
mcimadamore@155 38 public A a1;
mcimadamore@155 39 protected A a2;
mcimadamore@155 40 A a3;
mcimadamore@19 41 }
mcimadamore@19 42 static class B extends A {
mcimadamore@155 43 public void b1() {}
mcimadamore@155 44 protected void b2() {}
mcimadamore@155 45 void b3() {}
mcimadamore@155 46 public B b1;
mcimadamore@155 47 protected B b2;
mcimadamore@155 48 B b3;
mcimadamore@19 49 }
mcimadamore@19 50 static interface I{
mcimadamore@19 51 void i();
mcimadamore@19 52 }
mcimadamore@19 53 static interface I1{
mcimadamore@19 54 void i1();
mcimadamore@19 55 }
mcimadamore@19 56 static class E extends B implements I, I1{
mcimadamore@19 57 public void i() {}
mcimadamore@19 58 public void i1() {}
mcimadamore@19 59 }
mcimadamore@19 60 static class C<W extends B & I1, T extends W>{
mcimadamore@19 61 T t;
mcimadamore@19 62 W w;
mcimadamore@19 63 C(W w, T t) {
mcimadamore@19 64 this.w = w;
mcimadamore@19 65 this.t = t;
mcimadamore@19 66 }
mcimadamore@19 67 }
mcimadamore@19 68
mcimadamore@19 69 public static void main(String... args) {
mcimadamore@19 70 C<E,E> c = new C<E,E>(new E(), new E());
mcimadamore@19 71 testMemberMethods(c);
mcimadamore@19 72 testMemberFields(c);
mcimadamore@19 73 }
mcimadamore@19 74
mcimadamore@19 75 static void testMemberMethods(C<? extends A, ? extends I> arg) {
mcimadamore@155 76 arg.t.a1();
mcimadamore@155 77 arg.t.a2();
mcimadamore@155 78 arg.t.a3();
mcimadamore@155 79 arg.t.b1();
mcimadamore@155 80 arg.t.b2();
mcimadamore@155 81 arg.t.b3();
mcimadamore@19 82 arg.t.i1();
mcimadamore@155 83 arg.w.a1();
mcimadamore@155 84 arg.w.a2();
mcimadamore@155 85 arg.w.a3();
mcimadamore@155 86 arg.w.b1();
mcimadamore@155 87 arg.w.b2();
mcimadamore@155 88 arg.w.b3();
mcimadamore@19 89 arg.w.i1();
mcimadamore@19 90 }
mcimadamore@19 91
mcimadamore@19 92 static void testMemberFields(C<? extends A, ? extends I> arg) {
mcimadamore@155 93 A ta; B tb;
mcimadamore@155 94 ta = arg.t.a1;
mcimadamore@155 95 ta = arg.t.a2;
mcimadamore@155 96 ta = arg.t.a3;
mcimadamore@155 97 tb = arg.t.b1;
mcimadamore@155 98 tb = arg.t.b2;
mcimadamore@155 99 tb = arg.t.b3;
mcimadamore@155 100 ta = arg.w.a1;
mcimadamore@155 101 ta = arg.w.a2;
mcimadamore@155 102 ta = arg.w.a3;
mcimadamore@155 103 tb = arg.w.b1;
mcimadamore@155 104 tb = arg.w.b2;
mcimadamore@155 105 tb = arg.w.b3;
mcimadamore@19 106 }
mcimadamore@19 107 }

mercurial