JDK-4918173 : JVMTI GetLocalVariableTable returns two 'this' variables for ctor
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2003-09-05
  • Updated: 2004-03-16
  • Resolved: 2004-02-20
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.
Other
5.0 b40Fixed
Related Reports
Duplicate :  
Duplicate :  
Description

Name: egR10015			Date: 09/05/2003


--------------------------------------
 Test            : nsk/jvmti/GetLocalVariableTable/localtab004
                 : nsk/jvmti/RedefineClasses/redefclass009
 TestBase        : testbase_vm
 VM              : all
 Mode            : all
 Platform        : generic
 OS              : generic
 JDK             : 1.5.0-b18
--------------------------------------

The JVMTI function GetLocalVariableTable() returns two 'this' variables
for constructor.

The test 'localtab004' checks that the JVMTI function
GetLocalVariableTable() returns local variable information properly
for the tested class 'localtab004a' which should be compiled with
debugging info. An agent part verifies the local variable table for
the following methods of localtab004a:

  a) constructor
  b) static method statMethod()
  c) final instance method finMethod()

The test case a) fails as described above.

To reproduce the bug run

sh doit.sh $JAVA_HOME

in

/net/sqesvr.sfbay/export/vsn/GammaBase/Bugs/<this bug number>

where JAVA_HOME should point to jdk1.5

----------------- output on Solsparc with HS 1.5-b18: -------------------
$ sh doit.sh ~/hotspot/jdk1.5/solsparc
localtab004.c:
share/JVMTITools.c:
share/agent_tools.c:
share/jni_tools.c:
share/jvmti_tools.c:
share/native_thread.c:
share/nsk_tools.c:
Compiling test classes...
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b18)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b18, mixed mode)
Executing the test ...
# ERROR: localtab004.c, 114: TEST FAILED: instance method "<init>", signature "()V": found 7 vars in the LocalVariableTable, expected 6
	Here are the found vars:
# ERROR: localtab004.c, 117: 	#1) name: "this", signature: "Lnsk/jvmti/GetLocalVariableTable/localtab004a;"
# ERROR: localtab004.c, 117: 	#2) name: "this", signature: "Lnsk/jvmti/GetLocalVariableTable/localtab004a;"
# ERROR: localtab004.c, 117: 	#3) name: "constr_i", signature: "I"
# ERROR: localtab004.c, 117: 	#4) name: "constr_l", signature: "J"
# ERROR: localtab004.c, 117: 	#5) name: "constr_d", signature: "D"
# ERROR: localtab004.c, 117: 	#6) name: "constr_f", signature: "F"
# ERROR: localtab004.c, 117: 	#7) name: "constr_c", signature: "C"
# ERROR: localtab004.c, 118: 
- localtab004.c, 126: Checking vars in the LocalVariableTable of the instance method "finMethod", signature "(CJIJ)V" ...
	found 7 local vars as expected
- localtab004.c, 143: 	found var "this", signature: "Lnsk/jvmti/GetLocalVariableTable/localtab004a;" as expected
- localtab004.c, 143: 	found var "fin_c", signature: "C" as expected
- localtab004.c, 143: 	found var "fin_i", signature: "J" as expected
- localtab004.c, 143: 	found var "fin_j", signature: "I" as expected
- localtab004.c, 143: 	found var "fin_k", signature: "J" as expected
- localtab004.c, 143: 	found var "fin_l", signature: "J" as expected
- localtab004.c, 143: 	found var "fin_f", signature: "F" as expected
- localtab004.c, 148: 
- localtab004.c, 126: Checking vars in the LocalVariableTable of the static method "statMethod", signature "(III)D" ...
	found 5 local vars as expected
- localtab004.c, 143: 	found var "stat_i", signature: "I" as expected
- localtab004.c, 143: 	found var "stat_x", signature: "I" as expected
- localtab004.c, 143: 	found var "stat_y", signature: "I" as expected
- localtab004.c, 143: 	found var "stat_z", signature: "I" as expected
- localtab004.c, 143: 	found var "stat_j", signature: "D" as expected
- localtab004.c, 148: 
exit code = 97
-------------------------------------------------------------------------

The tests will be available in release 22 of the testbase_vm.
======================================================================

Name: pvR10198			Date: 09/07/2003


This bug also affects the following JVMDI test:
  nsk/jvmdi/RedefineClasses/redefclass009

Pavel Vyssotski <###@###.###>



======================================================================

###@###.### 2004-01-16

Some additional investigation.
Let's consider a class hello.java:

% cat hello.java

public class hello {
	String hell = "Hello!";
	public hello() {
		System.out.println(hell);
	}
}


----------------
The 1.4.2 javac generates a single entry in LVT for local variable "this",
but pc range is not correct. It should not start from pc=0.

ss45998@bratsk /java/re/jdk/1.4.2/promoted/latest/binaries/solaris-sparc/bin/javac -g hello.java; javap -l hello
Compiled from hello.java
public class hello extends java.lang.Object {
    java.lang.String hell;
    public hello();
}

Line numbers for method hello()
   line 4: 0
   line 3: 4
   line 5: 10
   line 6: 20

Local variables for method hello()
   hello this  pc=0, length=21, slot=0           <-- Incorrect pc range!
ss45998@bratsk 


----------------
The 1.5.0/b29 javac generates two entries in LVT for local variable "this".
The second entry is correct and pc range is correct as well but the first entry is redundant.

ss45998@bratsk /java/re/jdk/1.5.0/promoted/beta/b29/binaries/solaris-sparc/bin/javac -g hello.java; javap -l hello
Compiled from hello.java
public class hello extends java.lang.Object {
    java.lang.String hell;
    public hello();
}

Line numbers for method hello()
   line 4: 0
   line 3: 4
   line 5: 10
   line 6: 20

Local variables for method hello()
   hello this  pc=0, length=4, slot=0             <-- Wrong!
   hello this  pc=4, length=17, slot=0            <-- Correct
ss45998@bratsk 


----------------
The 1.5.0/b30 javac generates No entries in LVT. This looks wrong.

ss45998@bratsk /java/re/jdk/1.5.0/promoted/beta/b30/binaries/solaris-sparc/bin/javac -g hello.java; javap -l hello
Compiled from hello.java
public class hello extends java.lang.Object {
    java.lang.String hell;
    public hello();
}

Line numbers for method hello()
   line 4: 0
   line 3: 4
   line 5: 10
   line 6: 20
ss45998@bratsk 

This bug effects two jvmti tests:
	nsk/jvmti/GetLocalVariableTable/localtab004
	nsk/jvmti/GetLocalVariableTable/localtab005

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b40 tiger-beta2 VERIFIED IN: tiger-beta2
14-06-2004

PUBLIC COMMENTS ...
10-06-2004

EVALUATION This is not a JVMTI bug. Let's consider the following class: % cat A.java class A { A () {} } Compile it with 1.5 javac: % /net/tomsk.sfbay/export/home/ss45998/1.5/b20_ref/sparc/j2sdk1.5.0/bin/javac -version -g A.java javac 1.5.0-beta Run javap version 1.5: % /net/tomsk.sfbay/export/home/ss45998/1.5/b20_ref/sparc/j2sdk1.5.0/bin/javap -c -l A Compiled from "A.java" class A extends java.lang.Object{ A(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return LineNumberTable: line 2: 0 LocalVariableTable: Start Length Slot Name Signature 0 4 0 this LA; 4 1 0 this LA; } We can see 2 'this' variables with different scopes: 1-st has start_bci=0 and length=4 2-nd has start_bci=4 and length=1 It looks as bug in javac 1.5. javap version 1.4.2 prints almost the same information: % /net/tomsk.sfbay/export/home/ss45998/1.4.2/b28/sparc/j2sdk1.4.2/bin/javap -c -l A Compiled from "A.java" class A extends java.lang.Object{ A(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return LineNumberTable: line 2: 0 LocalVariableTable: Start Length Slot Name Signature 0 4 0 this LA; 4 1 0 this LA; } But if to use javac 1.4.2 then everything looks correct: % /net/tomsk.sfbay/export/home/ss45998/1.4.2/b28/sparc/j2sdk1.4.2/bin/javac -g A.java Both javap 1.4.2 and 1.5 outputs looks similarly correct: % /net/tomsk.sfbay/export/home/ss45998/1.4.2/b28/sparc/j2sdk1.4.2/bin/javap -c -l A Compiled from "A.java" class A extends java.lang.Object{ A(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return LineNumberTable: line 2: 0 LocalVariableTable: Start Length Slot Name Signature 0 5 0 this LA; } % /net/tomsk.sfbay/export/home/ss45998/1.5/b20_ref/sparc/j2sdk1.5.0/bin/javap -c -l A Compiled from "A.java" class A extends java.lang.Object{ A(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return LineNumberTable: line 2: 0 LocalVariableTable: Start Length Slot Name Signature 0 5 0 this LA; } Therefore, I move this bug to cat/subcat: 'javac/compiler' for further evaluation. ###@###.### 2003-09-23 ###@###.### 2003-11-12 This started happening in b14.
23-09-2003