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

GContracts and Groovy3

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.0-rc-1
    • None
    • None

    Description

      The following runs fine in 2.5.8 (needs gcontracts and asm jars on classpath):

      import org.gcontracts.annotations.Invariant
      import groovy.transform.*
      
      @Invariant({ month >= 1 && month <= 12 && day >= 1 && day <= lastDay[month-1] })
      @MapConstructor
      @ToString(includeNames=true)
      class Calendar {
          private static final int[] lastDay = [31,29,31,30,31,30,31,31,30,31,30,31]
          int month
          int day
          
          def mutateByOneMonth() {
              month++
          }
      }
      
      new Calendar(month: 2, day: 2).mutateByOneMonth() // Okay
      new Calendar(month: 12, day: 2).mutateByOneMonth() // ClassInvariantViolation
      new Calendar(month: 1, day: 31).mutateByOneMonth() // ClassInvariantViolation
      

      but with 3.0.0-beta-3 I get:

      java.lang.IllegalAccessError: tried to access method org.codehaus.groovy.ast.stmt.EmptyStatement.<init>()V from class org.gcontracts.generation.TryCatchBlockGenerator
      

      We should check whether we have made an unneeded breaking change or whether a gcontracts upgrade might be needed.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m