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

STC and default value in ctor is causing debugging error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.12
    • Fix Version/s: 2.4.13
    • Component/s: bytecode
    • Labels:
      None

      Description

      When debugging in the IDE, there is a curious behavior where it looks like step requests are not being respected. One thing I have found is that JDWP requests to the JVM process are failing to resolve the variable "this" in certain cases. I need some help from someone who knows the bytecode better than myself to figure out where the problem lies.

      Original issue: https://github.com/groovy/groovy-eclipse/issues/312

      I have narrowed it down to a small bit of code with static compilation enabled.

      @groovy.transform.CompileStatic
      class C {
        String string
        C(String s = null) { string = s }
      
        static void main(args) {
          def c = new C('') // put breakpoint on this line, run as Java app, and step
          println c
        }
      }
      

      Debug stepping fails when executing the constructor for C. If I use new C(string:''), the generated default constructor is used instead and debugging works fine. So I think it has something to do with the one-arg constructor's bytecode.

      I dumped the class file using javap and have attached them. C1.txt is for the code above. C2.txt is the above with the named args constructor used instead. I'm not sure if the local args table for the single-argument constructor is bad and that is why "this" cannot be resolved.

      There are several similar bugs reported for other tools and whatnots when looking for "JDWP error code 35". Hopefully, these help point to something in the bytecode that can be corrected.

      http://bugs.java.com/bugdatabase/view_bug.do?bug_id=5005668
      https://bugs.openjdk.java.net/browse/JDK-4992932

        Attachments

        1. C3.txt
          14 kB
          Eric Milles
        2. C2.txt
          14 kB
          Eric Milles
        3. C1.txt
          14 kB
          Eric Milles

          Issue Links

            Activity

              People

              • Assignee:
                paulk Paul King
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: