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

Inconsistent application of and checking for GroovyObject in classgen

    XMLWordPrintableJSON

Details

    Description

      Verifier adds GroovyObject to most classes near the start of the classgen compile phase. However, classgen proceeds per class node and there are a number of places that check for GroovyObject and can be subject to order-of-operations issues.

      Consider the following (excerpt of GROOVY-5517 test case):

      class MyHashMap extends HashMap {
          public static int version = 123
      }
      def map = new MyHashMap()
      map['foo'] = 456
      print map.foo
      

      The script class can be processed before MyHashMap and the checks in AsmClassGenerator can produce different bytecode depending on detection of GroovyObject on MyHashMap. Under static compilation this means the difference between StaticTypesCallSiteWriter#makeGetPropertySite and StaticTypesCallSiteWriter#makeGroovyObjectGetPropertySite for "map.foo".

      https://stackoverflow.com/a/61071840/1082681
      https://github.com/groovy/groovy-eclipse/issues/1353

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              1 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 - 50m
                  50m