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

Incorrect generated bytecode (duplicate field and method) on service with multiple methods returning array of same type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.6.4, 1.7-beta-1
    • 1.6.5, 1.7-beta-2
    • None
    • None

    Description

      Grails 1.1.1, Groovy 1.6.3

      To reproduce:

      1. Create a new empty project
      2. Create the following class in src/java:

      package a;
      public class A {

      }

      3. Create the following service in grails-app/services:

      package b;
      import a.A;
      public class BService {
      public A[] m1()

      { return null; }

      public A[] m2()

      { return null; }

      }

      4. Run grails run-app
      The following exception will be thrown on startup:
      java.lang.ClassFormatError: Duplicate field name&signature in class file b/BService
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
      at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:300)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
      at java.security.AccessController.doPrivileged(Native Method)
      at grails.web.container.EmbeddableServer$start.call(Unknown Source)
      at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:145)
      at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
      at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:274)
      at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
      at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:137)
      at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
      at _GrailsRun_groovy.runInline(_GrailsRun_groovy:104)
      at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
      at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:58)
      at RunApp$_run_closure1.doCall(RunApp:33)
      at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
      at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
      at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
      at gant.Gant.withBuildListeners(Gant.groovy:344)
      at gant.Gant.this$2$withBuildListeners(Gant.groovy)
      at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
      at gant.Gant.dispatch(Gant.groovy:334)
      at gant.Gant.this$2$dispatch(Gant.groovy)
      at gant.Gant.invokeMethod(Gant.groovy)
      at gant.Gant.processTargets(Gant.groovy:495)
      at gant.Gant.processTargets(Gant.groovy:480)

      When inspecting the bytecode of B/BService.class with javap -private, you'll notice the following lines:
      private static java.lang.Class array$$class$a$A;
      private static java.lang.Class array$$class$a$A;
      ...
      private static java.lang.Class $get$array$$class$a$A();
      private static java.lang.Class $get$array$$class$a$A();

      Note, when BService is manually compiled with groovyc, the generated bytecode is okay (only one field and method entry).

      Attachments

        1. bytecode.zip
          189 kB
          Jeff Brown
        2. groovy-bytecode.zip
          5.05 MB
          Graeme Rocher

        Activity

          People

            blackdrag Jochen Theodorou
            rjseagraves Rich Seagraves
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: