JDK-8048006 : Incorrect LOCALVARIABLE info
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u5
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86
  • Submitted: 2014-06-17
  • Updated: 2014-07-31
  • Resolved: 2014-07-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8u20Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Client VM (build 25.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 8

A DESCRIPTION OF THE PROBLEM :
JDK 8 started to generate incorrect LOCALVARIABLE info, because of that debugger does not show local variables in some cases, see http://youtrack.jetbrains.com/issue/IDEA-126287


REGRESSION.  Last worked in version 7u51

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile and stop on a breakpoint in the provided source code


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
j is available as a local variable
ACTUAL -
not available

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class LocalVar {
    int workingColumn = 0;
    Matrix matrix = new Matrix();

    public static void main(String[] args) {
        LocalVar lv = new LocalVar();
        lv.foo();
    }

    private void foo() {

        Rational factor = null;

        int i,j,k;
        workingColumn = 0;
        for (i = 0; i < matrix.getHeight(); i++) {

            int nnli = getXXX(i);
            if (nnli != -1) {
                matrix.swapLines(i, nnli);
                divideXXX(workingColumn, i);

                for (j = i+1; j < matrix.getHeight(); j++) {
                    System.out.println(j); // breakpoint here, j is not visible
                    factor = new Rational(matrix.getElementAtCoordinates
                            (workingColumn, j));
                }
            }
        }
    }

    private void divideXXX(int workingColumn, int i) {

    }

    private int getXXX(int line) {
        return 5;
    }

    class Matrix {
        int getWidth() {
            return 10;
        }

        int getHeight() {
            return 10;
        }

        void swapLines(int a, int b) {

        }

        public int getElementAtCoordinates(int workingColumn, int j) {
            return 2;
        }
    }

    class Rational {
        public Rational(int a) {
        }
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use jdk 7, it generates correct LOCALVARIABLE info


Comments
Appears to be already fixed as JDK-8037937.
31-07-2014

The Local Variable Table generated by JDK8 javac: LocalVariableTable: Start Length Slot Name Signature 56 8 3 j I 27 74 5 nnli I 0 108 0 this Ltestapp/Testapp; 2 106 1 factor Ltestapp/Testapp$Rational; 9 99 2 i I ----- The Local Variable Table generated by JDK7 javac: LocalVariableTable: Start Length Slot Name Signature 56 45 3 j I 27 74 5 nnli I 0 108 0 this Ltestapp/Testapp; 2 106 1 factor Ltestapp/Testapp$Rational; 9 99 2 i I *** Obviously, the scope for variable "j" is not correct. Therefore, the debugger does not show this variable at the breakpoint location because at that line number the variable has already went out of scope.
17-07-2014

According to the description this looks more like a javac issue.
16-07-2014