-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
18.0.1
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Ubuntu 20.04
Java 11, 17.0.3, 18
A DESCRIPTION OF THE PROBLEM :
I am using JDI's API to register a breakpoint at a line number and then trying to extract local variables at that point. I use the following code snippet for registering the breakpoint event.
```java
List<Location> locations = event.referenceType().locationsOfLine(lineNumber);
BreakpointRequest br = erm.createBreakpointRequest(locations.get(0));
br.setEnabled(true);
```
I execute one of apache commons-lang test (https://github.com/khaes-kth/commons-lang/blob/master/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java#L425) and I intend to set a breakpoint on line 272 of WordUtils.java (https://github.com/khaes-kth/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/text/WordUtils.java#L272). However, I am unable to do that because `event.referenceType().locationsOfLine(272);` returns an empty list which means that there is no debugging information for line 272. I checked the class file and there indeed exists the information for it.
I tried to debug it further and I found that the calling `Method.allLineLocations` on this method (https://github.com/khaes-kth/commons-lang/blob/19676135286eca93ab4f3980ddb5aa7ffba43bed/src/main/java/org/apache/commons/lang3/text/WordUtils.java#L271) returns a list of locations which are offset by 2. For example, line number 274 is JDI.Location object corresponds to line number 272 of the source file.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute `testLANG1397` (https://github.com/khaes-kth/commons-lang/blob/master/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java#L425).
2. Set breakpoint on WordUtils.wrap # 272 (https://github.com/khaes-kth/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/text/WordUtils.java#L272)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I should be able to collect local variables for that line since it is an executable line.
ACTUAL -
I get no Location object corresponding to that line.
FREQUENCY : always
Ubuntu 20.04
Java 11, 17.0.3, 18
A DESCRIPTION OF THE PROBLEM :
I am using JDI's API to register a breakpoint at a line number and then trying to extract local variables at that point. I use the following code snippet for registering the breakpoint event.
```java
List<Location> locations = event.referenceType().locationsOfLine(lineNumber);
BreakpointRequest br = erm.createBreakpointRequest(locations.get(0));
br.setEnabled(true);
```
I execute one of apache commons-lang test (https://github.com/khaes-kth/commons-lang/blob/master/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java#L425) and I intend to set a breakpoint on line 272 of WordUtils.java (https://github.com/khaes-kth/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/text/WordUtils.java#L272). However, I am unable to do that because `event.referenceType().locationsOfLine(272);` returns an empty list which means that there is no debugging information for line 272. I checked the class file and there indeed exists the information for it.
I tried to debug it further and I found that the calling `Method.allLineLocations` on this method (https://github.com/khaes-kth/commons-lang/blob/19676135286eca93ab4f3980ddb5aa7ffba43bed/src/main/java/org/apache/commons/lang3/text/WordUtils.java#L271) returns a list of locations which are offset by 2. For example, line number 274 is JDI.Location object corresponds to line number 272 of the source file.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute `testLANG1397` (https://github.com/khaes-kth/commons-lang/blob/master/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java#L425).
2. Set breakpoint on WordUtils.wrap # 272 (https://github.com/khaes-kth/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/text/WordUtils.java#L272)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I should be able to collect local variables for that line since it is an executable line.
ACTUAL -
I get no Location object corresponding to that line.
FREQUENCY : always