My Oracle Support Banner

VirtualMachine.allClasses() Does Not Return a Loaded Class (Doc ID 2487540.1)

Last updated on MAY 11, 2020

Applies to:

Java SE JDK and JRE - Version 8 and later
Information in this document applies to any platform.

Symptoms

The Java Debug Interface (JDI) method VirtualMachine.allClasses() does not return a loaded class when the class is not initialized. This prevents reloading of the uninitialized class.  It is expected that the loaded class is returned whether the class is initialized or not.

The issue can be reproduced using the below test code called "Main.java" with the following steps:


1. Compile and run the test program

javac -d . Main.java


2. With debugger, stop at the breakpoint in debugger

jdb Main
> stop at Main:9

 

3. Run to breakpoint

> run

 

4. Check for Foo class
 

main[1] class Foo
"Foo" is not a valid id or class name.


5. Notice VirtualMachine.allClasses() does not contain a class Foo at this point.

6. Step into Foo (now Foo is initialized)
 

main[1] step

Step completed: "thread=main", Foo.(), line=16 bci=0
16 System.out.println("Foo initialized");



7. Check Foo is in VirtualMachine.allClasses()

main[1] class Foo
Class: Foo
extends: java.lang.Object

 

Test code "Main.java"



Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.