groovy
  1. groovy
  2. GROOVY-5122

static fields on interface not getting initialized, when being initialized to an anonymous class instance

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.4
    • Fix Version/s: 1.8.5, 2.0-beta-2, 1.7.11
    • Component/s: None
    • Labels:
      None
    • Environment:
      OS X (suspected all)
    • Number of attachments :
      0

      Description

      The following code shows a static field on an interface not initialized at the point when the constructor of an instance of an implementing class is being run.

      
      package ignored.alex.failingcallsite
      
      import java.lang.reflect.Field;
      
      class FailingCallSiteLocalClass {
      	public static void main(String[] args) {
      		new B()		
      	}
      }
      
      interface A {
      	public static X x = new X() {
      		public void foo() {}
      	}
      }
      
      interface X {
      	void foo()
      }
      
      class B implements A {
      	public B() {
              for (Field f in getClass().getFields()) {
      			println f
      			println f.get(this)
      		}
      	}
      }
      

      Throws java.lang.IllegalAccessError when x is accessed via f.get(this).

      I would expect x to have been initialized by this point. Is there something subtle in when interfaces are initialized?

      There is no problem if A is a class extended by B, and more curiously, no problem if x is set equal to a named outer class (e.g. a class X2 implements X).

        Activity

        Hide
        Alex Heneveld added a comment -

        I have seen various stack traces as I've tested it in various places.

        Firstly, in some instances it complains that the constructor A$1(java.lang.Class) cannot be accessed, which makes me suspect inner class issues (e.g. GROOVY-5109) may be related.

        public static transient boolean ignored.alex.failingcallsite.B.__$stMC
        false
        public static final ignored.alex.failingcallsite.X ignored.alex.failingcallsite.A.x
        Exception in thread "main" java.lang.ExceptionInInitializerError
        	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
        	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
        	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
        	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
        	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
        	at java.lang.reflect.Field.get(Field.java:358)
        	at java_lang_reflect_Field$get.call(Unknown Source)
        	at ignored.alex.failingcallsite.B.<init>(FailingCallSiteLocalClass.groovy:25)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
        	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
        	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
        	at ignored.alex.failingcallsite.FailingCallSiteLocalClass.main(FailingCallSiteLocalClass.groovy:7)
        Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: ignored.alex.failingcallsite.A$1(java.lang.Class)
        	at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1473)
        	at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1389)
        	at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:46)
        	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
        	at ignored.alex.failingcallsite.A.<clinit>(FailingCallSiteLocalClass.groovy:12)
        	... 18 more
        

        Running from the command-line shows the smaller trace:

        bugs% ../groovy-2.0.0-beta-1/bin/groovy -e 'ignored.alex.failingcallsite.FailingCallSiteLocalClass.main()'
        public static transient boolean ignored.alex.failingcallsite.B.__$stMC
        false
        public static long ignored.alex.failingcallsite.B.__timeStamp
        1321276852344
        public static long ignored.alex.failingcallsite.B.__timeStamp__239_neverHappen1321276852344
        0
        public static final ignored.alex.failingcallsite.X ignored.alex.failingcallsite.A.x
        Caught: java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A
        java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A
        	at ignored.alex.failingcallsite.A.<clinit>(FailingCallSiteLocalClass.groovy:12)
        	at java_lang_reflect_Field$get.call(Unknown Source)
        	at ignored.alex.failingcallsite.B.<init>(FailingCallSiteLocalClass.groovy:25)
        	at ignored.alex.failingcallsite.FailingCallSiteLocalClass.main(FailingCallSiteLocalClass.groovy:7)
        
        

        Finally, it might be useful to note that although this test case fails on all versions tested (1.7.2 through 1.8.4, and 2.0.0-beta1), it was extracted from a more complicated scenario which only started failing in 1.8.2 – was working for many months against 1.8.0-03.

        Show
        Alex Heneveld added a comment - I have seen various stack traces as I've tested it in various places. Firstly, in some instances it complains that the constructor A$1(java.lang.Class) cannot be accessed, which makes me suspect inner class issues (e.g. GROOVY-5109 ) may be related. public static transient boolean ignored.alex.failingcallsite.B.__$stMC false public static final ignored.alex.failingcallsite.X ignored.alex.failingcallsite.A.x Exception in thread "main" java.lang.ExceptionInInitializerError at sun.misc.Unsafe.ensureClassInitialized(Native Method) at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25) at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122) at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918) at java.lang.reflect.Field.getFieldAccessor(Field.java:899) at java.lang.reflect.Field.get(Field.java:358) at java_lang_reflect_Field$get.call(Unknown Source) at ignored.alex.failingcallsite.B.<init>(FailingCallSiteLocalClass.groovy:25) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186) at ignored.alex.failingcallsite.FailingCallSiteLocalClass.main(FailingCallSiteLocalClass.groovy:7) Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for : ignored.alex.failingcallsite.A$1(java.lang. Class ) at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1473) at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1389) at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:46) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190) at ignored.alex.failingcallsite.A.<clinit>(FailingCallSiteLocalClass.groovy:12) ... 18 more Running from the command-line shows the smaller trace: bugs% ../groovy-2.0.0-beta-1/bin/groovy -e 'ignored.alex.failingcallsite.FailingCallSiteLocalClass.main()' public static transient boolean ignored.alex.failingcallsite.B.__$stMC false public static long ignored.alex.failingcallsite.B.__timeStamp 1321276852344 public static long ignored.alex.failingcallsite.B.__timeStamp__239_neverHappen1321276852344 0 public static final ignored.alex.failingcallsite.X ignored.alex.failingcallsite.A.x Caught: java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A at ignored.alex.failingcallsite.A.<clinit>(FailingCallSiteLocalClass.groovy:12) at java_lang_reflect_Field$get.call(Unknown Source) at ignored.alex.failingcallsite.B.<init>(FailingCallSiteLocalClass.groovy:25) at ignored.alex.failingcallsite.FailingCallSiteLocalClass.main(FailingCallSiteLocalClass.groovy:7) Finally, it might be useful to note that although this test case fails on all versions tested (1.7.2 through 1.8.4, and 2.0.0-beta1), it was extracted from a more complicated scenario which only started failing in 1.8.2 – was working for many months against 1.8.0-03.
        Hide
        CÚdric Champeau added a comment -

        Without package definition, I obtain another error:
        {{java.lang.LinkageError: loader (instance of groovy/lang/GroovyClassLoader$InnerLoader): attempted duplicate class definition for name: "A$1"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:55)
        at groovy.lang.GroovyClassLoader$ClassCollector.createClass(GroovyClassLoader.java:519)
        at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(GroovyClassLoader.java:536)}}
        which is due to a mismatch in inner class id generation (GeneratorContext). After fixing this bug, cannot reproduce your issue on master, still investigating.

        Show
        CÚdric Champeau added a comment - Without package definition, I obtain another error: {{java.lang.LinkageError: loader (instance of groovy/lang/GroovyClassLoader$InnerLoader): attempted duplicate class definition for name: "A$1" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:55) at groovy.lang.GroovyClassLoader$ClassCollector.createClass(GroovyClassLoader.java:519) at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(GroovyClassLoader.java:536)}} which is due to a mismatch in inner class id generation (GeneratorContext). After fixing this bug, cannot reproduce your issue on master, still investigating.
        Hide
        Alex Heneveld added a comment -

        If it's working now in master then I'd guess it's fixed ... either the default/root package bug or maybe GROOVY-5109.

        Show
        Alex Heneveld added a comment - If it's working now in master then I'd guess it's fixed ... either the default/root package bug or maybe GROOVY-5109 .
        Hide
        CÚdric Champeau added a comment -

        What is curious is that I cannot reproduce your problem. I have the same duplicate class definition error if I use Groovy 1.8.2.

        Show
        CÚdric Champeau added a comment - What is curious is that I cannot reproduce your problem. I have the same duplicate class definition error if I use Groovy 1.8.2.
        Hide
        Alex Heneveld added a comment -

        I observed the duplicate class error only when running it in default/root package. Didn't know what I was colliding with but figured it was irrelevant. Are you getting dup-class-def with package ignored.alex.failingcallsite set?

        I'm on OS X 10.5 JDK 1.6.0_20 fwiw...

        Show
        Alex Heneveld added a comment - I observed the duplicate class error only when running it in default/root package. Didn't know what I was colliding with but figured it was irrelevant. Are you getting dup-class-def with package ignored.alex.failingcallsite set? I'm on OS X 10.5 JDK 1.6.0_20 fwiw...
        Hide
        CÚdric Champeau added a comment -

        I pushed the fix to branches 1.7.x, 1.8.x and master. I would be great to tell me if you still experience the problem.

        Show
        CÚdric Champeau added a comment - I pushed the fix to branches 1.7.x, 1.8.x and master. I would be great to tell me if you still experience the problem.
        Hide
        Alex Heneveld added a comment -

        Alas, nope. It is still failing on master for me with the same error.

        It also fails when the package line is removed, although the duplicated class error message is gone, I now get the analogous IllegalAccessException: tried to access field A$1.$class$A from class A.

        Here is how I am pull, build and running it, with the class above (including package) in bugs/FailingCallSiteLocalClass.groovy:

        ~/dev/explore/groovy/git/groovy-core% git pull ; ant install -DskipTests=true
        ...
        
        ~/dev/explore/groovy/git/groovy-core% cd ../../bugs/
        
        ~/dev/explore/groovy/bugs% rm -rf ignored/
        
        ~/dev/explore/groovy/bugs% ../git/groovy-core/target/install/bin/groovyc FailingCallSiteLocalClass.groovy 
        
        ~/dev/explore/groovy/bugs% ../git/groovy-core/target/install/bin/groovy -e 'ignored.alex.failingcallsite.FailingCallSiteLocalClass.main()'
        public static transient boolean ignored.alex.failingcallsite.B.__$stMC
        false
        public static long ignored.alex.failingcallsite.B.__timeStamp
        1321413751418
        public static long ignored.alex.failingcallsite.B.__timeStamp__239_neverHappen1321413751418
        0
        public static final ignored.alex.failingcallsite.X ignored.alex.failingcallsite.A.x
        Caught: java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A
        java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A
        	at ignored.alex.failingcallsite.A.<clinit>(FailingCallSiteLocalClass.groovy:12)
        	at java_lang_reflect_Field$get.call(Unknown Source)
        	at ignored.alex.failingcallsite.B.<init>(FailingCallSiteLocalClass.groovy:25)
        	at ignored.alex.failingcallsite.FailingCallSiteLocalClass.main(FailingCallSiteLocalClass.groovy:7)
        	at script_from_command_line.run(script_from_command_line:1)
        
        Show
        Alex Heneveld added a comment - Alas, nope. It is still failing on master for me with the same error. It also fails when the package line is removed, although the duplicated class error message is gone, I now get the analogous IllegalAccessException: tried to access field A$1.$class$A from class A . Here is how I am pull, build and running it, with the class above (including package) in bugs/FailingCallSiteLocalClass.groovy : ~/dev/explore/groovy/git/groovy-core% git pull ; ant install -DskipTests= true ... ~/dev/explore/groovy/git/groovy-core% cd ../../bugs/ ~/dev/explore/groovy/bugs% rm -rf ignored/ ~/dev/explore/groovy/bugs% ../git/groovy-core/target/install/bin/groovyc FailingCallSiteLocalClass.groovy ~/dev/explore/groovy/bugs% ../git/groovy-core/target/install/bin/groovy -e 'ignored.alex.failingcallsite.FailingCallSiteLocalClass.main()' public static transient boolean ignored.alex.failingcallsite.B.__$stMC false public static long ignored.alex.failingcallsite.B.__timeStamp 1321413751418 public static long ignored.alex.failingcallsite.B.__timeStamp__239_neverHappen1321413751418 0 public static final ignored.alex.failingcallsite.X ignored.alex.failingcallsite.A.x Caught: java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A java.lang.IllegalAccessError: tried to access field ignored.alex.failingcallsite.A$1.$class$ignored$alex$failingcallsite$A from class ignored.alex.failingcallsite.A at ignored.alex.failingcallsite.A.<clinit>(FailingCallSiteLocalClass.groovy:12) at java_lang_reflect_Field$get.call(Unknown Source) at ignored.alex.failingcallsite.B.<init>(FailingCallSiteLocalClass.groovy:25) at ignored.alex.failingcallsite.FailingCallSiteLocalClass.main(FailingCallSiteLocalClass.groovy:7) at script_from_command_line.run(script_from_command_line:1)
        Hide
        blackdrag blackdrag added a comment -

        I start suspecting this happens because the field is final and I think Sun/Oracle VM doesn't check that, while the OSX VM does.

        Show
        blackdrag blackdrag added a comment - I start suspecting this happens because the field is final and I think Sun/Oracle VM doesn't check that, while the OSX VM does.
        Hide
        CÚdric Champeau added a comment -

        I don't have an OSX machine to test that. It may be some problem with the order fields are initialized, we've seen that in the past, but it doesn't happen here on my JVM. What happens if you write the same code in Java ?

        Show
        CÚdric Champeau added a comment - I don't have an OSX machine to test that. It may be some problem with the order fields are initialized, we've seen that in the past, but it doesn't happen here on my JVM. What happens if you write the same code in Java ?
        Hide
        Alex Heneveld added a comment -

        Analogous code in Java is fine, happily prints:

        public static final ignored.alex.failingcallsite.poj.X ignored.alex.failingcallsite.poj.A.x
        ignored.alex.failingcallsite.poj.A$1@593d93f4
        

        So suspect you're right, something different in how the OSX JVM does things.

        Show
        Alex Heneveld added a comment - Analogous code in Java is fine, happily prints: public static final ignored.alex.failingcallsite.poj.X ignored.alex.failingcallsite.poj.A.x ignored.alex.failingcallsite.poj.A$1@593d93f4 So suspect you're right, something different in how the OSX JVM does things.
        Hide
        CÚdric Champeau added a comment -

        For reference, I just tested with Oracle JRockit on Linux 64 bit, it doesn't throw any IAE. I'm trying to download IBM JVM... but I'm stuck at download. Now trying various OpenJDK VM options.

        Show
        CÚdric Champeau added a comment - For reference, I just tested with Oracle JRockit on Linux 64 bit, it doesn't throw any IAE. I'm trying to download IBM JVM... but I'm stuck at download. Now trying various OpenJDK VM options.
        Hide
        Alex Heneveld added a comment -

        No, don't think it's OSX. I have a simpler test case which fails on OSX JVM and on Linux Sun JVM. (Not totally sure it is the same issue but seems like a better starting point.)

        % cat Groovy5122.groovy 
        package bug5122.small1
        
        class Groovy5122 {
        	public static void main(String[] args) {
        		println "x is: "+InterfaceWithStaticAnonymous.x;
        	}
        }
        
        interface InterfaceWithStaticAnonymous {
        	public static Object x = new Object() {};
        }
        

        Gives the following error (in all cases):

        % java -cp groovy-all.jar:. bug5122.small1.Groovy5122
        Exception in thread "main" java.lang.IllegalAccessError: tried to access field bug5122.small1.InterfaceWithStaticAnonymous$1.$class$bug5122$small1$InterfaceWithStaticAnonymous from class bug5122.small1.InterfaceWithStaticAnonymous
        	at bug5122.small1.InterfaceWithStaticAnonymous.<clinit>(Groovy5122.groovy:10)
        	at java.lang.Class.forName0(Native Method)
        	at java.lang.Class.forName(Class.java:169)
        	at bug5122.small1.Groovy5122.class$(Groovy5122.groovy)
        	at bug5122.small1.Groovy5122.$get$$class$bug5122$small1$InterfaceWithStaticAnonymous(Groovy5122.groovy)
        	at bug5122.small1.Groovy5122.main(Groovy5122.groovy:5)
        

        I observe this against v1.8.4 and against git master (with 5109 fix, and tried both with and without an additional patch from CÚdric). Problem goes away if we s/interface/class/ and/or if we s/{}//. Error is the same if we put it in the default package.

        Suggest we rename issue to IllegalAccessError for static field in interface being assigned to anonymous class instance.

        OSX JVM is 1.6.0_20. Linux JVM is Sun/Oracle 1.6.0_22.

        Show
        Alex Heneveld added a comment - No, don't think it's OSX. I have a simpler test case which fails on OSX JVM and on Linux Sun JVM. (Not totally sure it is the same issue but seems like a better starting point.) % cat Groovy5122.groovy package bug5122.small1 class Groovy5122 { public static void main( String [] args) { println "x is: " +InterfaceWithStaticAnonymous.x; } } interface InterfaceWithStaticAnonymous { public static Object x = new Object () {}; } Gives the following error (in all cases): % java -cp groovy-all.jar:. bug5122.small1.Groovy5122 Exception in thread "main" java.lang.IllegalAccessError: tried to access field bug5122.small1.InterfaceWithStaticAnonymous$1.$class$bug5122$small1$InterfaceWithStaticAnonymous from class bug5122.small1.InterfaceWithStaticAnonymous at bug5122.small1.InterfaceWithStaticAnonymous.<clinit>(Groovy5122.groovy:10) at java.lang. Class .forName0(Native Method) at java.lang. Class .forName( Class .java:169) at bug5122.small1.Groovy5122.class$(Groovy5122.groovy) at bug5122.small1.Groovy5122.$get$$class$bug5122$small1$InterfaceWithStaticAnonymous(Groovy5122.groovy) at bug5122.small1.Groovy5122.main(Groovy5122.groovy:5) I observe this against v1.8.4 and against git master (with 5109 fix, and tried both with and without an additional patch from CÚdric). Problem goes away if we s/interface/class/ and/or if we s/{}// . Error is the same if we put it in the default package. Suggest we rename issue to IllegalAccessError for static field in interface being assigned to anonymous class instance . OSX JVM is 1.6.0_20. Linux JVM is Sun/Oracle 1.6.0_22.
        Hide
        CÚdric Champeau added a comment -

        I am under Linux, and I don't face the problem. What bugs me is the way you start the main program. You are using:

        java -cp groovy-all.jar:. bug5122.small1.Groovy5122

        Which tells you have compiled the script previously. How did you compile the script ? I am using this :

        java -cp ~/GG/target/dist/groovy-all.jar:. groovy.ui.GroovyMain bug5122/small1/Groovy5122.groovy 
        x is: bug5122.small1.InterfaceWithStaticAnonymous$1@561777b1

        And the output is correct. Are you sure you are compiling the script with the right version of Groovy ?

        Show
        CÚdric Champeau added a comment - I am under Linux, and I don't face the problem. What bugs me is the way you start the main program. You are using: java -cp groovy-all.jar:. bug5122.small1.Groovy5122 Which tells you have compiled the script previously. How did you compile the script ? I am using this : java -cp ~/GG/target/dist/groovy-all.jar:. groovy.ui.GroovyMain bug5122/small1/Groovy5122.groovy x is: bug5122.small1.InterfaceWithStaticAnonymous$1@561777b1 And the output is correct. Are you sure you are compiling the script with the right version of Groovy ?
        Hide
        Alex Heneveld added a comment -

        Yes, I always recompile with the same version. Seemed safest.

        Different ways of starting it cause different problems but all cause problems.

        When I run with your syntax I get:

        alex@dynlin334:~/groovy/bugs$ java -cp ../current/embeddable/groovy-all-2.0.0-beta-2-SNAPSHOT.jar:. groovy.ui.GroovyMain Groovy5122.groovy 
        Caught: java.lang.LinkageError: loader (instance of  groovy/lang/GroovyClassLoader$InnerLoader): attempted  duplicate class definition for name: "bug5122/small1/InterfaceWithStaticAnonymous$1"
        java.lang.LinkageError: loader (instance of  groovy/lang/GroovyClassLoader$InnerLoader): attempted  duplicate class definition for name: "bug5122/small1/InterfaceWithStaticAnonymous$1"
        

        Same if I run with bin/groovy bug5122/small1/Groovy5122.groovy.

        Show
        Alex Heneveld added a comment - Yes, I always recompile with the same version. Seemed safest. Different ways of starting it cause different problems but all cause problems. When I run with your syntax I get: alex@dynlin334:~/groovy/bugs$ java -cp ../current/embeddable/groovy-all-2.0.0-beta-2-SNAPSHOT.jar:. groovy.ui.GroovyMain Groovy5122.groovy Caught: java.lang.LinkageError: loader (instance of groovy/lang/GroovyClassLoader$InnerLoader): attempted duplicate class definition for name: "bug5122/small1/InterfaceWithStaticAnonymous$1" java.lang.LinkageError: loader (instance of groovy/lang/GroovyClassLoader$InnerLoader): attempted duplicate class definition for name: "bug5122/small1/InterfaceWithStaticAnonymous$1" Same if I run with bin/groovy bug5122/small1/Groovy5122.groovy .
        Hide
        CÚdric Champeau added a comment -

        That puzzles me. I don't understand. The last error you show is the one fixed in the lastest master commit... I tried many JDKs, even managed to test on a JDK 1.5 Apple JDK, but none showed that IAE error

        Show
        CÚdric Champeau added a comment - That puzzles me. I don't understand. The last error you show is the one fixed in the lastest master commit... I tried many JDKs, even managed to test on a JDK 1.5 Apple JDK, but none showed that IAE error
        Hide
        Alex Heneveld added a comment -

        Ah, all good.

        Latest commit 2151e717653113c24f4c1f3e48c4960ee67d01c5 fixes it, it just wasn't in github when I pulled. Maybe some delay before things are shown in the mirror? Sorry for the noise.

        FWIW the patch you sent me for AsmClassGenerator (replacing ACC_SUPER with ACC_PUBLIC|ACC_STATIC) makes no apparent difference.

        Show
        Alex Heneveld added a comment - Ah, all good. Latest commit 2151e717653113c24f4c1f3e48c4960ee67d01c5 fixes it, it just wasn't in github when I pulled. Maybe some delay before things are shown in the mirror? Sorry for the noise. FWIW the patch you sent me for AsmClassGenerator (replacing ACC_SUPER with ACC_PUBLIC|ACC_STATIC) makes no apparent difference.
        Hide
        CÚdric Champeau added a comment -

        Ok, so you are telling me that you don't have any IAE anymore ?

        Show
        CÚdric Champeau added a comment - Ok, so you are telling me that you don't have any IAE anymore ?
        Hide
        Alex Heneveld added a comment -

        Yep. All errors are gone – IAE for $..class, IAE for call site, duplicate class, missing constructor. Have tried several of the failure cases I had, and all are now happy. Strange that it would manifest itself in so many different ways, but all good now.

        Show
        Alex Heneveld added a comment - Yep. All errors are gone – IAE for $..class, IAE for call site, duplicate class, missing constructor. Have tried several of the failure cases I had, and all are now happy. Strange that it would manifest itself in so many different ways, but all good now.
        Hide
        CÚdric Champeau added a comment -

        Ok, last check. When you say you don't have any errors, is it with or without the patch (which is not committed) on AsmClassGenerator ?

        Show
        CÚdric Champeau added a comment - Ok, last check. When you say you don't have any errors, is it with or without the patch (which is not committed) on AsmClassGenerator ?
        Hide
        Alex Heneveld added a comment -

        The patch makes no apparent difference. I get no errors without it, and I get no errors with it.

        Show
        Alex Heneveld added a comment - The patch makes no apparent difference. I get no errors without it, and I get no errors with it.
        Hide
        CÚdric Champeau added a comment -

        Great, thanks!

        Show
        CÚdric Champeau added a comment - Great, thanks!

          People

          • Assignee:
            CÚdric Champeau
            Reporter:
            Alex Heneveld
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: