Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8317376

Minor improvements to the 'this' escape analyzer

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • None
    • tools
    • None
    • b19
    • generic
    • generic

      The 'this' escape analyzer is not intended to be perfect but there are a few improvements that can make it more precise with relatively little effort.

      * The analyzer is only tracking outer instance references originating from 'this'. This can easily be generalized to track outer instance references from any other type of tracked reference, e.g., variables and values on top of the Java stack.
      * Expressions like `Outer.this` are assumed to refer to the immediate outer instance. If they refer to a non-immediate outer instance, they should be handled differently.
      * The analyzer was treating constructors as if they returned void (as they are declared). This was missing the possibility of an expression like 'new Inner()' leaving an object on the Java stack that has a 'this' reference through its outer instance.
      * Some anonymous classes have no outer instance, e.g., those created inside a super() call. This is easy to check, and in these cases no need to track the nonexistent reference.

            acobbs Archie Cobbs
            acobbs Archie Cobbs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: