| java.lang.Object org.netbeans.lib.profiler.server.ClassLoaderManager
ClassLoaderManager | class ClassLoaderManager implements CommonConstants(Code) | | Functionality that ultimately allows us to obtain a class given its name and class loader.
One reason for this class to exist, is to enable access to non-public methods of class java.lang.ClassLoader,
that allow one to obtain a class loaded by the given loader, or make sure that this class hasn't been loaded by
the given loader. Also this class provides accounting for parent loader for each registered loader, which is
needed at the client side to correctly perform class instrumentation. Finally, we keep track of class (actually
class loader) unloading events, which is necessary e.g. during memory profiling, to prevent
getMethodNamesForJMethodIds from crashing or returning "unknown method" results.
Manages:
- class unloading
- knowing what is loader for each class in CPU profiling
author: Misha Dmitriev author: Ian Formanek |
Method Summary | |
static void | addLoader(ClassLoader loader) | static void | checkForUnloadedClasses() This method SHOULD be called frequently enough to allow unloaded classes go away.
On the other hand, since currently it's called from monitoring code, which itself has to execute at regular
enough intervals, it has to return quickly - that's why we are using a separate thread in it, that does the
potentially long-executing work.
In addition to just clearing a PhantomReference, the code could have removed the relevant ClassLoaderManager
from Vector/Hashtable that contain these managers. | static int | getDefiningLoaderForClass(String className, int initiatingLoaderId) | static Class | getLoadedClass(String name, int loaderIdx) | static int[] | getParentLoaderIdTable() Creates a table that maps loader id to its parent class loader. | static int[] | getThisAndParentLoaderData(int thisLoaderId) This whole method exists, in addition to simple getParentLoaderId() above, to make possible passing to the tool
information about "chains of loaders" that may occasionally be discovered when a class is loaded. | static void | initialize(ProfilerServer inProfilerServer) | static int | registerLoader(Class clazz) | static void | setNotifyToolAboutUnloadedClasses(boolean v) | public String | toString() |
checkForUnloadedClasses | static void checkForUnloadedClasses()(Code) | | This method SHOULD be called frequently enough to allow unloaded classes go away.
On the other hand, since currently it's called from monitoring code, which itself has to execute at regular
enough intervals, it has to return quickly - that's why we are using a separate thread in it, that does the
potentially long-executing work.
In addition to just clearing a PhantomReference, the code could have removed the relevant ClassLoaderManager
from Vector/Hashtable that contain these managers. We can implement that later.
|
getDefiningLoaderForClass | static int getDefiningLoaderForClass(String className, int initiatingLoaderId)(Code) | | |
getParentLoaderIdTable | static int[] getParentLoaderIdTable()(Code) | | Creates a table that maps loader id to its parent class loader.
An array that maps class loader id (idx) to its parent class loader it ([idx]) |
getThisAndParentLoaderData | static int[] getThisAndParentLoaderData(int thisLoaderId)(Code) | | This whole method exists, in addition to simple getParentLoaderId() above, to make possible passing to the tool
information about "chains of loaders" that may occasionally be discovered when a class is loaded. I.e. it may
happen that a new loader A is created, then A creates a child loader B, and finally a class is loaded by B. At
this time we happen to register *both* loaders B and A in registerLoader() above, and also parent loader A gets
a loaderId with a *greater* value than that for B.
So for the tool to adequately reflect the class loader structure of the application, we need to pass info about
more than 2 loaders with a single class. Fortunately, when there are x>2 loaders involved, the first x-1 get
sequentially growing IDs. So what is returned here in the int[3] array, is the ID for the first and the last
loader in such a chain, plus the chain length (which is 0 in the case of a simple child-parent pair).
Parameters: thisLoaderId - Class loader Id whose parent we are looking for a 3 item array [0]=first loader in chain, [1]=last loader in chain, [2]=chain length, can be 0 insimple case |
registerLoader | static int registerLoader(Class clazz)(Code) | | |
setNotifyToolAboutUnloadedClasses | static void setNotifyToolAboutUnloadedClasses(boolean v)(Code) | | |
|
|