You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/05/26 00:19:31 UTC

[groovy] branch GROOVY_3_0_X updated (1cf3372 -> 3c0bf68)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 1cf3372  Remove email address to avoid receiving potential spam mails.
     new b36cbbd  GROOVY-9569: check outers and uppers for static fields
     new 3c0bf68  GROOVY-5259: refactor handling of "this" reference in special ctor call

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../groovy/classgen/AsmClassGenerator.java         | 136 ++++++++++--------
 src/test/gls/innerClass/InnerClassTest.groovy      | 157 ++++++++++++++++++++-
 src/test/groovy/bugs/Groovy5259.groovy             | 131 -----------------
 3 files changed, 233 insertions(+), 191 deletions(-)
 delete mode 100644 src/test/groovy/bugs/Groovy5259.groovy


[groovy] 01/02: GROOVY-9569: check outers and uppers for static fields

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit b36cbbdca7bb1a3b8f0e3d9f333361db237da15f
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat May 23 08:32:39 2020 +0800

    GROOVY-9569: check outers and uppers for static fields
    
    - use ArrtibuteExpression for outer field
    - use PropertyExpression for upper field
    
    (cherry picked from commit 5a0426a85a82dd1f3ee984294788ef70ab87d486)
---
 .../groovy/classgen/AsmClassGenerator.java         |  79 +++++++----
 src/test/gls/innerClass/InnerClassTest.groovy      | 155 ++++++++++++++++++++-
 src/test/groovy/bugs/Groovy5259.groovy             | 131 -----------------
 3 files changed, 207 insertions(+), 158 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index a240869..2afa7a1 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -125,6 +125,13 @@ import java.util.Objects;
 import java.util.Optional;
 
 import static org.apache.groovy.util.BeanUtils.capitalize;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.attrX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.callX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.classX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.fieldX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.propX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.thisPropX;
+import static org.codehaus.groovy.transform.sc.StaticCompilationMetadataKeys.PROPERTY_OWNER;
 
 /**
  * Generates Java class versions of Groovy classes using ASM.
@@ -361,9 +368,6 @@ public class AsmClassGenerator extends ClassGenerator {
         return modifiers;
     }
 
-    public void visitGenericType(final GenericsType genericsType) {
-    }
-
     @Override
     protected void visitConstructorOrMethod(final MethodNode node, final boolean isConstructor) {
         controller.resetLineNumber();
@@ -1009,6 +1013,40 @@ public class AsmClassGenerator extends ClassGenerator {
         return classNode.getSuperClass().getGetterMethod(getterMethodName);
     }
 
+    private boolean checkStaticOuterField(final PropertyExpression pexp, final String name) {
+        for (final ClassNode outer : controller.getClassNode().getOuterClasses()) {
+            FieldNode field = outer.getDeclaredField(name);
+            if (field != null) {
+                if (!field.isStatic()) break;
+
+                Expression outerClass = classX(outer);
+                outerClass.setNodeMetaData(PROPERTY_OWNER, outer);
+                outerClass.setSourcePosition(pexp.getObjectExpression());
+
+                Expression outerField = attrX(outerClass, pexp.getProperty());
+                outerField.setSourcePosition(pexp);
+                outerField.visit(this);
+                return true;
+            } else {
+                field = outer.getField(name); // checks supers
+                if (field != null && !field.isPrivate() && (field.isPublic() || field.isProtected()
+                        || Objects.equals(field.getDeclaringClass().getPackageName(), outer.getPackageName()))) {
+                    if (!field.isStatic()) break;
+
+                    Expression upperClass = classX(field.getDeclaringClass());
+                    upperClass.setNodeMetaData(PROPERTY_OWNER, field.getDeclaringClass());
+                    upperClass.setSourcePosition(pexp.getObjectExpression());
+
+                    Expression upperField = propX(upperClass, pexp.getProperty());
+                    upperField.setSourcePosition(pexp);
+                    upperField.visit(this);
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     private boolean isGroovyObject(final Expression objectExpression) {
         if (isThisExpression(objectExpression)) return true;
         if (objectExpression instanceof ClassExpression) return false;
@@ -1035,35 +1073,25 @@ public class AsmClassGenerator extends ClassGenerator {
                 if (isSuperExpression(objectExpression)) {
                     field = classNode.getSuperClass().getDeclaredField(name);
                     privateSuperField = (field != null && field.isPrivate());
-                } else if (expression.isImplicitThis() || !controller.isInGeneratedFunction()) {
+                } else if (controller.isInGeneratedFunction()) {
+                    if (expression.isImplicitThis())
+                        field = classNode.getDeclaredField(name); // params are stored as fields
+                } else {
                     field = classNode.getDeclaredField(name);
-
-                    ClassNode outer = classNode.getOuterClass();
-                    if (field == null && outer != null) {
-                        do {
-                            FieldNode outerClassField = outer.getDeclaredField(name);
-                            if (outerClassField != null && outerClassField.isStatic()) {
-                                if (outerClassField.isPrivate() && classNode.getOuterClass() != outer) {
-                                    throw new GroovyBugError("Trying to access private field [" + outerClassField.getDeclaringClass() + "#" + outerClassField.getName() + "] from inner class");
-                                }
-                                PropertyExpression staticOuterField = new PropertyExpression(new ClassExpression(outer), expression.getProperty());
-                                staticOuterField.getObjectExpression().setSourcePosition(objectExpression);
-                                staticOuterField.visit(this);
-                                return;
-                            }
-                            outer = outer.getSuperClass();
-                        } while (outer != null);
+                    if (field == null && !isValidFieldNodeForByteCodeAccess(classNode.getField(name), classNode)) {
+                        // GROOVY-5259, GROOVY-9501, GROOVY-9569
+                        if (checkStaticOuterField(expression, name)) return;
                     }
                 }
 
                 if (field != null && !privateSuperField) { // GROOVY-4497: don't visit super field if it is private
-                    visitFieldExpression(new FieldExpression(field));
+                    fieldX(field).visit(this);
                     visited = true;
                 } else if (isSuperExpression(objectExpression)) {
                     if (controller.getCompileStack().isLHS()) {
                         setPropertyOfSuperClass(classNode, expression, controller.getMethodVisitor());
                     } else {
-                        visitMethodCallExpression(new MethodCallExpression(objectExpression, "get" + capitalize(name), MethodCallExpression.NO_ARGUMENTS));
+                        callX(objectExpression, "get" + capitalize(name)).visit(this); // TODO: "is"
                     }
                     visited = true;
                 }
@@ -1306,9 +1334,9 @@ public class AsmClassGenerator extends ClassGenerator {
 
     private void processClassVariable(final VariableExpression expression) {
         if (passingParams && controller.isInScriptBody()) {
-            //TODO: check if this part is actually used
+            // TODO: check if this part is actually used
             MethodVisitor mv = controller.getMethodVisitor();
-            // let's create a ScriptReference to pass into the closure
+            // create a ScriptReference to pass into the closure
             mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference");
             mv.visitInsn(DUP);
 
@@ -1317,10 +1345,9 @@ public class AsmClassGenerator extends ClassGenerator {
 
             mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V", false);
         } else {
-            PropertyExpression pexp = new PropertyExpression(new VariableExpression("this"), expression.getName());
+            PropertyExpression pexp = thisPropX(true, expression.getName());
             pexp.getObjectExpression().setSourcePosition(expression);
             pexp.getProperty().setSourcePosition(expression);
-            pexp.setImplicitThis(true);
             visitPropertyExpression(pexp);
         }
     }
diff --git a/src/test/gls/innerClass/InnerClassTest.groovy b/src/test/gls/innerClass/InnerClassTest.groovy
index 8053754..ee7c0d7 100644
--- a/src/test/gls/innerClass/InnerClassTest.groovy
+++ b/src/test/gls/innerClass/InnerClassTest.groovy
@@ -429,7 +429,7 @@ final class InnerClassTest {
         '''
     }
 
-    @Test  // inner class is static instead of final
+    @Test // inner class is static instead of final
     void testUsageOfOuterField8() {
         assertScript '''
             class Main extends Outer {
@@ -465,6 +465,159 @@ final class InnerClassTest {
         '''
     }
 
+    @Test // GROOVY-9569
+    void testUsageOfOuterField9() {
+        assertScript '''
+            class Main extends Outer {
+                static main(args) {
+                    newInstance().newThread()
+                    assert Outer.Inner.error == null
+                }
+            }
+
+            @groovy.transform.CompileStatic
+            abstract class Outer {
+                private static volatile boolean flag
+
+                void newThread() {
+                    Thread thread = new Inner()
+                    thread.start()
+                    thread.join()
+                }
+
+                private static class Inner extends Thread {
+                    @Override
+                    void run() {
+                        try {
+                            if (!flag) {
+                                // do work
+                            }
+                        } catch (e) {
+                            error = e
+                        }
+                    }
+                    public static error
+                }
+            }
+        '''
+    }
+
+    @Test
+    void testUsageOfOuterField10() {
+        assertScript '''
+            class Outer {
+                static final String OUTER_CONSTANT = 'Constant Value'
+
+                class Inner {
+                    String access() {
+                        return OUTER_CONSTANT
+                    }
+                }
+
+                void testInnerClassAccessOuterConst() {
+                    def inner = new Inner()
+                    assert inner.access() == OUTER_CONSTANT
+                }
+            }
+
+            def outer = new Outer()
+            outer.testInnerClassAccessOuterConst()
+        '''
+    }
+
+    @Test // GROOVY-5259
+    void testUsageOfOuterField11() {
+        assertScript '''
+            class Base {
+                Base(String string) {
+                }
+            }
+
+            class Outer {
+                static final String OUTER_CONSTANT = 'Constant Value'
+
+                class Inner extends Base {
+                    Inner() {
+                        super(OUTER_CONSTANT) // "this" is not initialized yet
+                    }
+
+                    String access() {
+                        return OUTER_CONSTANT
+                    }
+                }
+
+                void testInnerClassAccessOuterConst() {
+                    def inner = new Inner()
+                    assert inner.access() == OUTER_CONSTANT
+                }
+            }
+
+            def outer = new Outer()
+            outer.testInnerClassAccessOuterConst()
+        '''
+    }
+
+    @Test
+    void testUsageOfOuterSuperField() {
+        assertScript '''
+            class InnerBase {
+                InnerBase(String string) {
+                }
+            }
+
+            class OuterBase {
+                protected static final String OUTER_CONSTANT = 'Constant Value'
+            }
+
+            class Outer extends OuterBase {
+
+                class Inner extends InnerBase {
+                    Inner() {
+                        super(OUTER_CONSTANT)
+                    }
+
+                    String access() {
+                        return OUTER_CONSTANT
+                    }
+                }
+
+                void testInnerClassAccessOuterConst() {
+                    def inner = new Inner()
+                    assert inner.access() == OUTER_CONSTANT
+                }
+            }
+
+            def outer = new Outer()
+            outer.testInnerClassAccessOuterConst()
+        '''
+    }
+
+    /*@Test
+    void testUsageOfOuterField_WrongCallToSuper() {
+        shouldFail '''
+            class InnerAccessOuter {
+                protected static final String OUTER_CONSTANT = 'Constant Value'
+
+                class InnerClass {
+                    InnerClass() {
+                        // there's no Object#<init>(String) method, but it throws a VerifyError when a new instance
+                        // is created, meaning a wrong super call is generated
+                        super(OUTER_CONSTANT)
+                    }
+                    String m() {
+                         OUTER_CONSTANT
+                    }
+                }
+
+                void testInnerClassAccessOuter() {
+                    def inner = new InnerClass()
+                    inner.m()
+                }
+            }
+            new InnerAccessOuter().testInnerClassAccessOuter()
+        '''
+    }*/
+
     @Test
     void testUsageOfOuterFieldOverridden() {
         assertScript '''
diff --git a/src/test/groovy/bugs/Groovy5259.groovy b/src/test/groovy/bugs/Groovy5259.groovy
deleted file mode 100644
index 1b4bc28..0000000
--- a/src/test/groovy/bugs/Groovy5259.groovy
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package groovy.bugs
-
-import org.junit.Test
-
-import static groovy.test.GroovyAssert.assertScript
-import static groovy.test.GroovyAssert.shouldFail
-
-final class Groovy5259 {
-
-    @Test
-    void testInnerClassAccessingOuterClassConstant() {
-        assertScript '''
-            class InnerAccessOuter {
-                static final String OUTER_CONSTANT = 'Constant Value'
-
-                class InnerClass {
-                    InnerClass() {
-                    }
-
-                    String innerCompiled() {
-                        OUTER_CONSTANT
-                    }
-                }
-
-                void testInnerClassAccessOuter() {
-                    def inner = new InnerClass()
-                    assert OUTER_CONSTANT == inner.innerCompiled()
-                }
-            }
-            new InnerAccessOuter().testInnerClassAccessOuter()
-        '''
-    }
-
-    @Test
-    void testInnerClassWithWrongCallToSuperAccessingOuterClassConstant() {
-        shouldFail '''
-            class InnerAccessOuter {
-                protected static final String OUTER_CONSTANT = 'Constant Value'
-
-                class InnerClass {
-                    InnerClass() {
-                        // there's no Object#<init>(String) method, but it throws a VerifyError when a new instance
-                        // is created, meaning a wrong super call is generated
-                        super(OUTER_CONSTANT)
-                    }
-                    String m() {
-                         OUTER_CONSTANT
-                    }
-                }
-
-                void testInnerClassAccessOuter() {
-                    def inner = new InnerClass()
-                    inner.m()
-                }
-            }
-            new InnerAccessOuter().testInnerClassAccessOuter()
-        '''
-    }
-
-    @Test
-    void testInnerClassWithSuperClassAccessingOuterClassConstant() {
-        assertScript '''
-            class Base {
-                Base(String str) {}
-            }
-            class InnerAccessOuter {
-                static final String OUTER_CONSTANT = 'Constant Value'
-
-                class InnerClass extends Base {
-                    InnerClass() {
-                        super(OUTER_CONSTANT)
-                    }
-
-                    String innerCompiled() { OUTER_CONSTANT }
-                }
-
-                void testInnerClassAccessOuter() {
-                    def inner = new InnerClass() // throws a VerifyError
-                    assert OUTER_CONSTANT == inner.innerCompiled()
-                }
-            }
-            new InnerAccessOuter().testInnerClassAccessOuter()
-        '''
-    }
-
-    @Test
-    void testInnerClassWithSuperClassAccessingSuperOuterClassConstant() {
-        assertScript '''
-            class Base {
-                Base(String str) {}
-            }
-            class OuterBase {
-                protected static final String OUTER_CONSTANT = 'Constant Value'
-            }
-            class InnerAccessOuter extends OuterBase {
-
-                class InnerClass extends Base {
-                    InnerClass() {
-                        super(OUTER_CONSTANT)
-                    }
-
-                    String innerCompiled() { OUTER_CONSTANT }
-                }
-
-                void testInnerClassAccessOuter() {
-                    def inner = new InnerClass() // throws a VerifyError
-                    assert OUTER_CONSTANT == inner.innerCompiled()
-                }
-            }
-            new InnerAccessOuter().testInnerClassAccessOuter()
-        '''
-    }
-}


[groovy] 02/02: GROOVY-5259: refactor handling of "this" reference in special ctor call

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 3c0bf68a30524ac8b1b3f4f2ae5fd875bda625fa
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat May 23 11:34:20 2020 -0500

    GROOVY-5259: refactor handling of "this" reference in special ctor call
    
    (cherry picked from commit ba576edfd82e557658224685564d0dfba8f5c43b)
---
 .../groovy/classgen/AsmClassGenerator.java         | 65 ++++++++++------------
 src/test/gls/innerClass/InnerClassTest.groovy      | 28 +++++-----
 2 files changed, 43 insertions(+), 50 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index 2afa7a1..15fe90d 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -28,7 +28,6 @@ import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.ConstructorNode;
 import org.codehaus.groovy.ast.FieldNode;
-import org.codehaus.groovy.ast.GenericsType;
 import org.codehaus.groovy.ast.InnerClassNode;
 import org.codehaus.groovy.ast.InterfaceHelperClassNode;
 import org.codehaus.groovy.ast.MethodNode;
@@ -1079,7 +1078,7 @@ public class AsmClassGenerator extends ClassGenerator {
                 } else {
                     field = classNode.getDeclaredField(name);
                     if (field == null && !isValidFieldNodeForByteCodeAccess(classNode.getField(name), classNode)) {
-                        // GROOVY-5259, GROOVY-9501, GROOVY-9569
+                        // GROOVY-9501, GROOVY-9569
                         if (checkStaticOuterField(expression, name)) return;
                     }
                 }
@@ -1276,28 +1275,29 @@ public class AsmClassGenerator extends ClassGenerator {
 
     @Override
     public void visitVariableExpression(final VariableExpression expression) {
-        String variableName = expression.getName();
-
-        //-----------------------------------------------------------------------
-        // SPECIAL CASES
-
-        // "this" for static methods is the Class instance
-        ClassNode classNode = controller.getClassNode();
+        final String variableName = expression.getName();
 
         if (expression.isThisExpression()) {
-            if (controller.isStaticMethod() || (!controller.getCompileStack().isImplicitThis() && controller.isStaticContext())) {
-                if (controller.isInGeneratedFunction()) classNode = controller.getOutermostClass();
-                visitClassExpression(new ClassExpression(classNode));
+            // "this" in static context is Class instance
+            if (controller.isStaticMethod() || controller.getCompileStack().isInSpecialConstructorCall()
+                    || (!controller.getCompileStack().isImplicitThis() && controller.isStaticContext())) {
+                ClassNode thisType = controller.getClassNode();
+                if (controller.isInGeneratedFunction()) {
+                    do { thisType = thisType.getOuterClass();
+                    } while (ClassHelper.isGeneratedFunction(thisType));
+                }
+                classX(thisType).visit(this);
             } else {
                 loadThis(expression);
             }
             return;
         }
 
-        // "super" also requires special handling
         if (expression.isSuperExpression()) {
+            // "super" in static context is Class instance
             if (controller.isStaticMethod()) {
-                visitClassExpression(new ClassExpression(classNode.getSuperClass()));
+                ClassNode superType = controller.getClassNode().getSuperClass();
+                classX(superType).visit(this);
             } else {
                 loadThis(expression);
             }
@@ -1305,11 +1305,22 @@ public class AsmClassGenerator extends ClassGenerator {
         }
 
         BytecodeVariable variable = controller.getCompileStack().getVariable(variableName, false);
-        if (variable == null) {
-            processClassVariable(expression);
-        } else {
+        if (variable != null) {
             controller.getOperandStack().loadOrStoreVariable(variable, expression.isUseReferenceDirectly());
+        } else if (passingParams && controller.isInScriptBody()) {
+            MethodVisitor mv = controller.getMethodVisitor();
+            mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference");
+            mv.visitInsn(DUP);
+            loadThisOrOwner();
+            mv.visitLdcInsn(variableName);
+            mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V", false);
+        } else {
+            PropertyExpression pexp = thisPropX(true, variableName);
+            pexp.getObjectExpression().setSourcePosition(expression);
+            pexp.getProperty().setSourcePosition(expression);
+            pexp.visit(this);
         }
+
         if (!controller.getCompileStack().isLHS()) {
             controller.getAssertionWriter().record(expression);
         }
@@ -1332,26 +1343,6 @@ public class AsmClassGenerator extends ClassGenerator {
         }
     }
 
-    private void processClassVariable(final VariableExpression expression) {
-        if (passingParams && controller.isInScriptBody()) {
-            // TODO: check if this part is actually used
-            MethodVisitor mv = controller.getMethodVisitor();
-            // create a ScriptReference to pass into the closure
-            mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference");
-            mv.visitInsn(DUP);
-
-            loadThisOrOwner();
-            mv.visitLdcInsn(expression.getName());
-
-            mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V", false);
-        } else {
-            PropertyExpression pexp = thisPropX(true, expression.getName());
-            pexp.getObjectExpression().setSourcePosition(expression);
-            pexp.getProperty().setSourcePosition(expression);
-            visitPropertyExpression(pexp);
-        }
-    }
-
     protected void createInterfaceSyntheticStaticFields() {
         ClassNode icl =  controller.getInterfaceClassLoadingClass();
 
diff --git a/src/test/gls/innerClass/InnerClassTest.groovy b/src/test/gls/innerClass/InnerClassTest.groovy
index ee7c0d7..c07bcbc 100644
--- a/src/test/gls/innerClass/InnerClassTest.groovy
+++ b/src/test/gls/innerClass/InnerClassTest.groovy
@@ -592,31 +592,33 @@ final class InnerClassTest {
         '''
     }
 
-    /*@Test
+    @Test
     void testUsageOfOuterField_WrongCallToSuper() {
         shouldFail '''
-            class InnerAccessOuter {
+            class Outer {
                 protected static final String OUTER_CONSTANT = 'Constant Value'
 
-                class InnerClass {
-                    InnerClass() {
-                        // there's no Object#<init>(String) method, but it throws a VerifyError when a new instance
-                        // is created, meaning a wrong super call is generated
+                class Inner {
+                    Inner() {
+                        // there is no Object#<init>(String) method, but it throws a VerifyError for uninitialized this
                         super(OUTER_CONSTANT)
                     }
-                    String m() {
-                         OUTER_CONSTANT
+
+                    String access() {
+                        return OUTER_CONSTANT
                     }
                 }
 
-                void testInnerClassAccessOuter() {
-                    def inner = new InnerClass()
-                    inner.m()
+                void testInnerClassAccessOuterConst() {
+                    def inner = new Inner()
+                    inner.access()
                 }
             }
-            new InnerAccessOuter().testInnerClassAccessOuter()
+
+            def outer = new Outer()
+            outer.testInnerClassAccessOuterConst()
         '''
-    }*/
+    }
 
     @Test
     void testUsageOfOuterFieldOverridden() {