We are working on an applet that handles/displays XML based content. We could not use Microsofts XML parser because the application has to run on different browsers and operating systems. We used suns XML implementation and use it in the applet to perform several transformations. In this way we have a platform independent XML parser. The disadvantage is that the packed cab/jar is big (around 700kb). We do not use all the functionality so some of the classes could be deleted from the package.
The question is now how to identify the classes that are really used in the applet? We tried to implement a custom classloader but did not succeed. What we want is to hook into the normal classloader and get the name of the loaded call, put them into a list and get this list into a file.
Is there another way to retrieve the list of loaded/used classes or can someone give us a hint how the custom classloader has to be hook into the native classloader?
Any help would be highly appreciated.
Philipp
<code>
public class sycomW extends Applet
{
private sycom s;
public void init() {
try {
MyClassLoader myClassLoader = new MyClassLoader();
s = (sycom) myClassLoader.loadClass("sycom"
.newInstance();
} catch (InstantiationException e) {System.out.println("InstantiationException"
;
} catch (IllegalAccessException i) {System.out.println("(IllegalAccessException"
;
} catch (ClassNotFoundException c) {System.out.println("ClassNotFoundException" + c);
}
}
public class MyClassLoader extends ClassLoader
{
protected MyClassLoader()
{
super();
}
protected Class findClass(String name) throws ClassNotFoundException
{
System.out.println("findClass: " + name);
return super.findClass(name);
}
public Class loadClass(String name) throws ClassNotFoundException
{
System.out.println("Load class: " + name);
super.loadClass(name);
return Class.forName(name);
}
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
{
System.out.println("Load classA: " + name);
return Class.forName(name);
}
}
</code>
The question is now how to identify the classes that are really used in the applet? We tried to implement a custom classloader but did not succeed. What we want is to hook into the normal classloader and get the name of the loaded call, put them into a list and get this list into a file.
Is there another way to retrieve the list of loaded/used classes or can someone give us a hint how the custom classloader has to be hook into the native classloader?
Any help would be highly appreciated.
Philipp
<code>
public class sycomW extends Applet
{
private sycom s;
public void init() {
try {
MyClassLoader myClassLoader = new MyClassLoader();
s = (sycom) myClassLoader.loadClass("sycom"
} catch (InstantiationException e) {System.out.println("InstantiationException"
} catch (IllegalAccessException i) {System.out.println("(IllegalAccessException"
} catch (ClassNotFoundException c) {System.out.println("ClassNotFoundException" + c);
}
}
public class MyClassLoader extends ClassLoader
{
protected MyClassLoader()
{
super();
}
protected Class findClass(String name) throws ClassNotFoundException
{
System.out.println("findClass: " + name);
return super.findClass(name);
}
public Class loadClass(String name) throws ClassNotFoundException
{
System.out.println("Load class: " + name);
super.loadClass(name);
return Class.forName(name);
}
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
{
System.out.println("Load classA: " + name);
return Class.forName(name);
}
}
</code>