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

IncompatibleClassChange with map-style constructor and overloaded setters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 4.0.22
    • 5.0.0-alpha-11
    • Static compilation
    • None

    Description

      I have a POJO that I use from Groovy code. After adding a setter overload, I now get IncompatibleClassChange at runtime because the static compiler generates ScriptBytecodeAdapter.setGroovyObjectProperty instead of a plain setter call.

      public class Entity {
        public void setId(String id) {}
        public void setId(UUID id) {}
      }
      
      class EntityTest extends Specification {
        @CompileStatic
        Entity createEntity(String id) {
          new Entity(id: id) // uses ScriptBytecodeAdapter.setGroovyObjectProperty
        }
      }
      

      The error is not encountered when calling setId(id) or using entity.id = id, without static compilation, or when the setter is not overloaded.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              chrylis Christopher Smith
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: