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

ClassGenerator patches for a few VerifyErrors, primitive uses as parameters and local vars

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-5
    • 1.0-beta-5
    • class generator
    • None
    • XP, Sun JDK 1.4.2_04

    Description

      I have taken a few days to study the various bugs that seemed to be associated with bad bytecode. The bugs fell under two groups:

      1. Primitives used as function/closure parameters and local variables.

      2. Scope introducing constructs in clsures, such as if, switch and while. Those constructs would generate inconsistent stack height.

      Other related problems were

      – +=
      – return void from functions
      – bad constructor bytecode for scripts

      After some hair-pulling and losing time with JVM spec, disassemblers and decompilers, I believe most of these problems are gone with the patches attached here.

      I also have created a test case that tests the above issues (see ClassGeneratorFixes.groovy)

      Among the changes in the ClassGenerator are:

      – reflowing the code to create fields.
      – tuning the primitive types hanlding
      – setting optionl attributes to generate better looking decompiled
      code. (now I can get clean JAD decompiled source files with realtively simple groovy code)
      – adding variables to localVariableTable to provide better debugging info in the bytecode.
      – renaming some local variables to avoid warnings from compiler about hiding instance variables.

      A couple of helper functions were added to related classes and the patches are in the attached patch files.

      I have run all the changes through a full maven build and test (with the latest code from CVS HEAD) and came out clean.

      Noticing that some of these bugs are really critical for releasing groovy as version 1, I thought I'd uploaded these patches for other developers to test them and imrpove them.

      Thanks.

      Attachments

        1. BytecodeHelper.patch
          2 kB
          Bing Ran
        2. ClassGenerator.patch
          24 kB
          Bing Ran
        3. ClassGeneratorFixes.groovy
          1 kB
          Bing Ran
        4. ClassNode.patch
          6 kB
          Bing Ran
        5. GeneratorContext.patch
          3 kB
          Bing Ran
        6. ModuleNode.patch
          2 kB
          Bing Ran
        7. PrimitiveTypeFieldTest.groovy
          0.7 kB
          Bing Ran

        Activity

          People

            jstrachan James Strachan
            bingran Bing Ran
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: