QualifiedThisAndSuper_3.java revision 553
618N/A * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. 618N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 618N/A * This code is free software; you can redistribute it and/or modify it 618N/A * under the terms of the GNU General Public License version 2 only, as 618N/A * published by the Free Software Foundation. 618N/A * This code is distributed in the hope that it will be useful, but WITHOUT 618N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 618N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 618N/A * version 2 for more details (a copy is included in the LICENSE file that 618N/A * accompanied this code). 618N/A * You should have received a copy of the GNU General Public License version 618N/A * 2 along with this work; if not, write to the Free Software Foundation, 618N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 618N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 618N/A * or visit www.oracle.com if you need additional information or have any 618N/A * @summary Verify correct implementation of qualified 'this' and 'super'. 618N/A * @run main QualifiedThisAndSuper_3 private String n() {
return "csn"; }
protected String o() {
return "cso"; }
private String n() {
return "an"; }
protected String o() {
return "ao"; }
static private String xn() {
return "xan"; }
static protected String xo() {
return "xao"; }
public class B
extends BS {
private String n() {
return "bn"; }
protected String o() {
return "bo"; }
public class C
extends CS {
private String n() {
return "cn"; }
protected String o() {
return "co"; }
// Private to another package-member class: not accessible // check("QualifiedThisAndSuper_3.super.xn()", QualifiedThisAndSuper_3.super.xn(), "xasn"); // Private to another package-member class: not accessible // check("QualifiedThisAndSuper_3.super.xt", QualifiedThisAndSuper_3.super.xt, "xast"); check(
"this.m()",
this.m(),
"cm");
check(
"B.this.m()", B.
this.m(),
"bm");
check(
"C.this.m()", C.
this.m(),
"cm");
check(
"super.m()",
super.m(),
"csm");
check(
"B.super.m()", B.
super.m(),
"bsm");
check(
"C.super.m()", C.
super.m(),
"csm");
// should re-use access methods. check(
"B.super.m()", B.
super.m(),
"bsm");
check(
"C.super.m()", C.
super.m(),
"csm");
check(
"this.n()",
this.n(),
"cn");
check(
"B.this.n()", B.
this.n(),
"bn");
check(
"C.this.n()", C.
this.n(),
"cn");
check("super.n()", super.n(), "csn"); check("QualifiedThisAndSuper_3.super.n()", QualifiedThisAndSuper_3.super.n(), "asn"); check("B.super.n()", B.super.n(), "bsn"); check("C.super.n()", C.super.n(), "csn"); // should re-use access methods. check("QualifiedThisAndSuper_3.super.n()", QualifiedThisAndSuper_3.super.n(), "asn"); check("B.super.n()", B.super.n(), "bsn"); check("C.super.n()", C.super.n(), "csn"); check(
"this.o()",
this.o(),
"co");
check(
"B.this.o()", B.
this.o(),
"bo");
check(
"C.this.o()", C.
this.o(),
"co");
check(
"super.o()",
super.o(),
"cso");
check(
"B.super.o()", B.
super.o(),
"bso");
check(
"C.super.o()", C.
super.o(),
"cso");
// should re-use access methods. check(
"B.super.o()", B.
super.o(),
"bso");
check(
"C.super.o()", C.
super.o(),
"cso");
check(
"this.s",
this.s,
"cs");
check(
"B.this.s", B.
this.s,
"bs");
check(
"C.this.s", C.
this.s,
"cs");
check(
"this.t",
this.t,
"ct");
check(
"B.this.t", B.
this.t,
"bt");
check(
"C.this.t", C.
this.t,
"ct");
check(
"this.u",
this.u,
"cu");
check(
"B.this.u", B.
this.u,
"bu");
check(
"C.this.u", C.
this.u,
"cu");
check(
"super.s",
super.s,
"css");
check(
"B.super.s", B.
super.s,
"bss");
check(
"C.super.s", C.
super.s,
"css");
check("super.t", super.t, "cst"); check("QualifiedThisAndSuper_3.super.t", QualifiedThisAndSuper_3.super.t, "ast"); check("B.super.t", B.super.t, "bst"); check("C.super.t", C.super.t, "cst"); check(
"super.u",
super.u,
"csu");
check(
"B.super.u", B.
super.u,
"bsu");
check(
"C.super.u", C.
super.u,
"csu");
check(
"B.this.s", B.
this.s,
"bar");
check(
"C.this.s", C.
this.s,
"baz");
check(
"B.this.t", B.
this.t,
"bar");
check(
"C.this.t", C.
this.t,
"baz");
check(
"B.this.u", B.
this.u,
"bar");
check(
"C.this.u", C.
this.u,
"baz");
check(
"B.super.s", B.
super.s,
"bar");
check(
"C.super.s", C.
super.s,
"baz");
QualifiedThisAndSuper_3.super.t = "foo"; System.out.println(QualifiedThisAndSuper_3.super.t); check("QualifiedThisAndSuper_3.super.t", QualifiedThisAndSuper_3.super.t, "foo"); System.out.println(B.super.t); check("B.super.t", B.super.t, "bar"); System.out.println(C.super.t); check("C.super.t", C.super.t, "baz"); check(
"B.super.u", B.
super.u,
"bar");
check(
"C.super.u", C.
super.u,
"baz");