/ ** How to get the actual path of the loaded class in Java debugging java.security.codesource; java.security.protectionDomain;
CoDesource can give the location of the original URL of the class, but not every class has CODESOURCE. If the class is loaded by the boot-type loader, CODESource is empty.
** /
Import java.lang.reflect.method; import java.net.url; import java.security.codesource; import java.security.protectionDomain
Public class findclasspath {
public static void displayClassInfo (Class clazz, StringBuffer results) {displayClassInfo (clazz, results, true);} public static void displayClassInfo (Class clazz, StringBuffer results, boolean showParentClassLoaders) {
ClassLoader Cl = Clazz.getClassLoader (); Results.Append ("/ N" CLAZZ.GETNAME () "(" Integer.toHexString (ClassLoader = " Cl); ClassLoader PARENT = Cl; While (Parent! = null) {results.append ("/ n .." parent); URL [] URLS = getClassLoaderURLS (PARENT); int length = urls! = null? urls.length: 0; For (int u = 0; u Results.Append ("/ nimplement interfaces:"); class [] ifaces = clazz.getInterface (); for (int i = 0; i