[PATCH] 8147527: Non-optimal code generated for postfix unary operators

bsrbnd bsrbnd at gmail.com
Wed Nov 9 17:33:07 UTC 2016


Hi Jan,

2016-11-03 14:45 GMT+01:00 Jan Lahoda <jan.lahoda at oracle.com>:
> Hi Bernard,
>
> Thanks for looking at this. For the avoidance of the modification of
> tree.selected in Lower.visitSelect, what I meant was more that we would
> create a new instance of JCFieldAccess, to carry the new select. Might be
> easier that trying to work with the existing select.
>
> I think it might be useful to have a set of tests covering the usecases, so
> that we can more easily test patches (we will need tests eventually anyway).
> I can look at that, unless you want to.
>
Please find next a test for the first problem.

Bernard

diff --git a/test/tools/javac/boxing/QualBoxedPostOp.java
b/test/tools/javac/boxing/QualBoxedPostOp.java
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/boxing/QualBoxedPostOp.java
@@ -0,0 +1,51 @@
+/*
+ * @test
+ * @bug 8147527
+ * @summary Qualified "this" and "super" boxed unary post operations.
+ */
+public class QualBoxedPostOp extends Parent {
+    public static void main(String[] args) {
+        new QualBoxedPostOp().testAll();
+    }
+
+    private void testAll() {
+        equals(test(), 0);
+        equals(i, 1);
+
+        Inner in = new Inner();
+        equals(in.test(), 1);
+        equals(i, 2);
+
+        equals(testParent(), 10);
+        equals(super.i, 11);
+
+        equals(in.testParent(), 11);
+        equals(super.i, 12);
+    }
+
+    private void equals(int a, int b) {
+        if (a != b) throw new Error();
+    }
+
+    Integer i=0;
+
+    private Integer test() {
+        return this.i++;
+    }
+    private Integer testParent() {
+        return super.i++;
+    }
+
+    class Inner {
+        private Integer test() {
+            return QualBoxedPostOp.this.i++;
+        }
+        private Integer testParent() {
+            return QualBoxedPostOp.super.i++;
+        }
+    }
+}
+
+class Parent {
+    protected Integer i=10;
+}


More information about the compiler-dev mailing list