QualBoxedPostOp3.java revision 3810:e5e4064d037d
1259698Sdim/* 2259698Sdim * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3259698Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4259698Sdim * 5259698Sdim * This code is free software; you can redistribute it and/or modify it 6259698Sdim * under the terms of the GNU General Public License version 2 only, as 7259698Sdim * published by the Free Software Foundation. 8259698Sdim * 9259698Sdim * This code is distributed in the hope that it will be useful, but WITHOUT 10259698Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11259698Sdim * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12259698Sdim * version 2 for more details (a copy is included in the LICENSE file that 13259698Sdim * accompanied this code). 14259698Sdim * 15259698Sdim * You should have received a copy of the GNU General Public License version 16259698Sdim * 2 along with this work; if not, write to the Free Software Foundation, 17259698Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18259698Sdim * 19259698Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20259698Sdim * or visit www.oracle.com if you need additional information or have any 21259698Sdim * questions. 22259698Sdim */ 23259698Sdim 24259698Sdim/* 25259698Sdim * @test 26259698Sdim * @bug 8147527 27259698Sdim * @summary Verifies the runtime behavior of "super", "this" and "this$n" optimization for boxed unary post-operations. 28259698Sdim * @compile QualBoxedPostOp3.java QualBoxedPostOp3Parent.java 29259698Sdim * @run main QualBoxedPostOp3 30259698Sdim */ 31259698Sdimpublic class QualBoxedPostOp3 extends p.QualBoxedPostOp3Parent { 32259698Sdim public static void main(String[] args) { 33259698Sdim new QualBoxedPostOp3().testAll(); 34259698Sdim } 35259698Sdim 36259698Sdim private void testAll() { 37259698Sdim equals(test(), 1); 38259698Sdim equals(i, 2); 39259698Sdim 40259698Sdim Inner in = new Inner(); 41259698Sdim equals(in.test(), 3); 42259698Sdim equals(i, 4); 43259698Sdim 44259698Sdim equals(testParent(), 21); 45259698Sdim equals(super.j, 22); 46259698Sdim 47259698Sdim equals(in.testParent(), 23); 48259698Sdim equals(super.j, 24); 49259698Sdim } 50259698Sdim 51259698Sdim private void equals(int a, int b) { 52259698Sdim if (a != b) throw new Error(); 53259698Sdim } 54259698Sdim 55259698Sdim Integer i=0; 56259698Sdim 57259698Sdim private Integer test() { 58259698Sdim i++; 59259698Sdim return this.i++; 60259698Sdim } 61259698Sdim private Integer testParent() { 62259698Sdim j++; 63259698Sdim return super.j++; 64259698Sdim } 65259698Sdim 66259698Sdim class Inner { 67259698Sdim private Integer test() { 68259698Sdim i++; 69276479Sdim return QualBoxedPostOp3.this.i++; 70276479Sdim } 71259698Sdim private Integer testParent() { 72259698Sdim j++; 73259698Sdim return QualBoxedPostOp3.super.j++; 74276479Sdim } 75276479Sdim } 76276479Sdim} 77276479Sdim