langtools/test/tools/javac/boxing/QualBoxedPostOp.java
author jlahoda
Mon, 12 Dec 2016 13:27:39 +0100
changeset 42499 49b675740462
permissions -rw-r--r--
8147527: Wrong code generated for postfix unary operators Summary: Avoiding use of duplicated tree nodes when these may be changed in place. Reviewed-by: mcimadamore, jlahoda Contributed-by: bsrbnd@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42499
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     1
/*
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     4
 *
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     8
 *
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    14
 *
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    18
 *
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    21
 * questions.
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    22
 */
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    23
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    24
/*
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    25
 * @test
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    26
 * @bug 8147527
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    27
 * @summary Qualified "this" and "super" boxed unary post operations.
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    28
 * @compile QualBoxedPostOp.java
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    29
 * @run main QualBoxedPostOp
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    30
 */
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    31
public class QualBoxedPostOp extends Parent {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    32
    public static void main(String[] args) {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    33
        new QualBoxedPostOp().testAll();
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    34
    }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    35
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    36
    private void testAll() {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    37
        equals(test(), 0);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    38
        equals(i, 1);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    39
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    40
        Inner in = new Inner();
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    41
        equals(in.test(), 1);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    42
        equals(i, 2);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    43
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    44
        equals(testParent(), 10);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    45
        equals(super.i, 11);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    46
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    47
        equals(in.testParent(), 11);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    48
        equals(super.i, 12);
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    49
    }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    50
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    51
    private void equals(int a, int b) {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    52
        if (a != b) throw new Error();
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    53
    }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    54
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    55
    Integer i=0;
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    56
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    57
    private Integer test() {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    58
        return this.i++;
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    59
    }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    60
    private Integer testParent() {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    61
        return super.i++;
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    62
    }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    63
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    64
    class Inner {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    65
        private Integer test() {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    66
            return QualBoxedPostOp.this.i++;
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    67
        }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    68
        private Integer testParent() {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    69
            return QualBoxedPostOp.super.i++;
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    70
        }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    71
    }
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    72
}
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    73
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    74
class Parent {
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    75
    protected Integer i=10;
49b675740462 8147527: Wrong code generated for postfix unary operators
jlahoda
parents:
diff changeset
    76
}