-
Enhancement
-
Resolution: Won't Fix
-
P3
-
None
-
8u45
JDK does not allow debuggers to step into ClassLoader.loadClass consistently.
Stepping into a code line where class loading happens (on first use of
class) sometimes goes into ClassLoader and sometimes not.
The only way we've found to consistently get JDK to allow debuggers to step
into ClassLoader is to call a constructor.
This behavior is seen across many debuggers. Those tested: jdb, Netbeans
8.0.2, IDEA, Eclipse 4.4.2 (Luna Service Release 2)
The following is a jdb session where debugger does not step into ClassLoader:
>jdb org.StartClass
Initializing jdb ...
> stop at org.StartClass:6
Deferring breakpoint org.StartClass:6.
It will be set after the class is loaded.
> run
run org.StartClass
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint org.StartClass:6
Breakpoint hit: "thread=main", org.StartClass.main(), line=6 bci=0
main[1] exclude "none"
main[1] step
>
Step completed: "thread=main", org.StartClass.main(), line=7 bci=4
The following is a jdb session where debugger steps into ClassLoader (on
constructor):
> jdb org.StartClass
Initializing jdb ...
> stop at org.StartClass:5
Deferring breakpoint org.StartClass:5.
It will be set after the class is loaded.
> run
run org.StartClass
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint org.StartClass:5
Breakpoint hit: "thread=main", org.StartClass.main(), line=5 bci=0
main[1] exclude "none"
main[1] step
>
Step completed: "thread=main", java.lang.ClassLoader.loadClass(), line=357
bci=0
Java Development has analyzed the issue and requested this enhancement
request based on the following:
Javap output differs between the two cases.
When we use the static instance:
javap -v org.StartClass:
public static void main(java.lang.String[]);
Code:
Stack=1, Locals=2, Args_size=1
0: getstatic #2; //Field org/Constants.INSTANCE:Lorg/Constants;
3: astore_1
4: return
LineNumberTable:
line 6: 0
line 7: 4
}
When we use the constructor:
javap -v org.StartClass:
public static void main(java.lang.String[]);
Code:
Stack=2, Locals=2, Args_size=1
0: new #2; //class org/Constants
3: dup
4: invokespecial #3; //Method org/Constants."<init>":()V
7: astore_1
8: return
LineNumberTable:
line 5: 0
line 7: 8
}
The debuggers "step" command can step into an invokespecial, but
unfortunately it currently can't for getstatic.
Implementing this facility will require an enhancement that could potentially
be backported.
- relates to
-
JDK-8163127 Debugger classExclusionFilter does not work correctly with method references
- Resolved