Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 743209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:50:11+00:00 2026-05-14T08:50:11+00:00

For debug reasons, and curiosity, I wish to list all classes loaded to a

  • 0

For debug reasons, and curiosity, I wish to list all classes loaded to a specific class loader.

Seeing as most methods of a class loader are protected, what is the best way to accomplish what I want?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:50:11+00:00Added an answer on May 14, 2026 at 8:50 am

    Instrumentation.getInitiatedClasses(ClassLoader) may do what you want.

    According to the docs:

    Returns an array of all classes for which loader is an initiating loader.

    I’m not sure what “initiating loader” means though. If that does not give the right result try using the getAllLoadedClasses() method and manually filtering by ClassLoader.


    How to get an instance of Instrumentation

    Only the agent JAR (which is separate from the application JAR) can get an instance of the Instrumentation interface. A simple way to make it available to the application is to create an agent JAR containing one class with a premain method that does nothing but save a reference to the Instrumentation instance in the system properties.

    Example agent class:

    public class InstrumentHook {
    
        public static void premain(String agentArgs, Instrumentation inst) {
            if (agentArgs != null) {
                System.getProperties().put(AGENT_ARGS_KEY, agentArgs);
            }
            System.getProperties().put(INSTRUMENTATION_KEY, inst);
        }
    
        public static Instrumentation getInstrumentation() {
            return (Instrumentation) System.getProperties().get(INSTRUMENTATION_KEY);
        }
    
        // Needn't be a UUID - can be a String or any other object that
        // implements equals().    
        private static final Object AGENT_ARGS_KEY =
            UUID.fromString("887b43f3-c742-4b87-978d-70d2db74e40e");
    
        private static final Object INSTRUMENTATION_KEY =
            UUID.fromString("214ac54a-60a5-417e-b3b8-772e80a16667");
    
    }
    

    Example manifest:

    Manifest-Version: 1.0
    Premain-Class: InstrumentHook
    

    The resulting JAR must then be referenced by the application and specified on the command line (with the -javaagent option) when launching the application. It might be loaded twice in different ClassLoaders, but that is not a problem since the system Properties is a per-process singleton.

    Example application class

    public class Main {
        public static void main(String[] args) {
            Instrumentation inst = InstrumentHook.getInstrumentation();
            for (Class<?> clazz: inst.getAllLoadedClasses()) {
                System.err.println(clazz.getName());
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Debug HTTP is easy, you have all sort of tools to do it (like
Most of the time , the developers will be having hard time to debug
First of all, here's my config: VS2010/Debug/C++ Win32 Project/Vista Home Premium Invoking GetOpenFileName via
for Debug reasons i want to show my outgoing packets in Console. The packets
I have a SWF that I wish to debug on with the flash debugger.
For debug reasons, and on a whim, I'd like to include certain information in
Debug mode in MigLayout is quite powerful option for development and debugging. It is
Debug.WriteLine(Timer is high-resolution: {0}, Stopwatch.IsHighResolution); Debug.WriteLine(Timer frequency: {0}, Stopwatch.Frequency); Result: Timer is high-resolution: True
The debug configuration of my app is built against: PYTHON25_D.DLL MSVCR80D.DLL We use Python
To debug some JavaScript code, I am looking for JavaScript code (preferably just js,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.