Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-660

Multi-threaded groovy: get java.lang.LinkageError: duplicate class definition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-8
    • 1.0-beta-9
    • None
    • None
    • eclipse 3.1M1, Sun JDK1.5.0

    Description

      I just switched to groovy, which is great BTW.

      I have an example which I can't get to work when I execute it in parallel in two threads within the same VM.

      It's about this type of code:

      Binding context = new Binding();
      GroovyShell shell = new GroovyShell();
      Script script = shell.parse("println 'foo'");
      script.setBinding(context);
      Object result = script.run();

      I always get an exception during the multi-threaded execution:
      java.lang.LinkageError: duplicate class definition: gjdk/groovy/lang/GroovyObjectSupport_GroovyReflector
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
      at groovy.lang.GroovyClassLoader.defineClass(GroovyClassLoader.java:478)
      at groovy.lang.MetaClassRegistry$2.run(MetaClassRegistry.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at groovy.lang.MetaClassRegistry.loadClass(MetaClassRegistry.java:151)
      at groovy.lang.MetaClass.loadReflectorClass(MetaClass.java:2250)
      at groovy.lang.MetaClass.loadReflector(MetaClass.java:2232)
      at groovy.lang.MetaClass.generateReflector(MetaClass.java:2182)
      at groovy.lang.MetaClass.checkInitialised(MetaClass.java:2129)
      at groovy.lang.MetaClassRegistry.getMetaClass(MetaClassRegistry.java:121)
      at groovy.lang.MetaClass.addNewStaticMethodsFrom(MetaClass.java:1281)
      at groovy.lang.MetaClass.addInheritedMethods(MetaClass.java:212)
      at groovy.lang.MetaClass.checkInitialised(MetaClass.java:2126)
      at groovy.lang.MetaClassRegistry.getMetaClass(MetaClassRegistry.java:121)
      at org.codehaus.groovy.runtime.Invoker.getMetaClass(Invoker.java:99)
      at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:94)
      at groovy.lang.GroovyObjectSupport.<init>(GroovyObjectSupport.java:61)
      at groovy.lang.Binding.<init>(Binding.java:62)

      When I run this code single-threaded, it works fine. Seems like a 'sometimes-per-thread, sometimes-global' thing to me.

      Thanks
      Andre

      Attachments

        Activity

          People

            spullara Sam Pullara
            pareis Andre R. Pareis
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: