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

Static compilation runtime error when using mapped constructor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.1.0-beta-1
    • Static compilation
    • None

    Description

      Take this class

      package compilestatic
      
      import groovy.transform.Canonical;
      import groovy.transform.CompileStatic;
      
      @CompileStatic
      class WTF {
      	public static void main(String[] args) {
      		new Person(name:"First")
      		first(new Person(name:"First"))
      	}
      
      	static Person first(Person p) {
      		p
      	}
      
      }
      
      @Canonical
      class Person {
      	String name
      }
      

      The following exception is thrown:

      Caught: java.lang.NoSuchMethodError: compilestatic.Person.<init>(Ljava/util/Map;)V
      java.lang.NoSuchMethodError: compilestatic.Person.<init>(Ljava/util/Map;)V
      	at compilestatic.WTF.main(wtf.groovy:10)
      

      Note that this exception comes from the second statement in the main method. Comment out that statement and there is no exception.

      Attachments

        Activity

          People

            melix Cédric Champeau
            werdna Andrew Eisenberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: