codebase classes loading on their own?

I have been tracking down a performance issue. So I am tracing the classes loaded by my clients VM. I have a class defined like so

[code]

public final class GraphicFactory implements IGraphicFactory, Serializable{

private static final long serialVersionUID = 1L;

public IDSComponentInstance createComponentInstance(Point location, Dimension size){

if (location == null || size == null) {

throw new NullPointerException();

}

return new DBComponentInstance(location,size);

}

public IDSFunctionConnection createFunctionConnection(Point sourceLocation, Point targetLocation) {

if(sourceLocation == null || targetLocation == null){

throw new NullPointerException();

}

return new DBFunctionConnection(sourceLocation,targetLocation);

}

}

[code]

I want to pass this class to the client. So the client calls a method, and this class is returned. When that happens, the client immediately loads this class via the codebase. The thing I can not see is when the client loads the "DBFunctionConnection" and "DBComponentInstance" classes. These classes are also in jar files which can be found by the codebase. Obviously the client is getting them because its working. And they are definitely coming from the server. But I do not see any log of them being loaded.

Its like they get loaded in secret. I bet they do too. I think classes loaded as a result of another class loading are not logged.

But at the same time, I thought a class would not be loaded until it is needed!? If its loading it right away, then this is a good thing because otherwise the RMI system could throw an exception at a most unusual place when the class gets loaded because a method is called.

I can't quite figure out what is happening here :(

[1839 byte] By [_dnoyeBa] at [2007-11-26 16:10:25]
# 1
If the codebase contains JAR files the entire JAR is downloaded, not individual classes.
ejpa at 2007-7-8 22:32:50 > top of Java-index,Core,Core APIs...
# 2

I guess RMI classloader is just different. From testing I can see that when the main class is marshalled it seems as if the classes it contains are also marshalled. (Note: these are in seperate jars) The log is not telling me when classes are loaded, only when they are "found." And they are found every time they are used. So this does not help me to see the order in which classes are loaded.

So I am still stuck having a hard time knowing when the RMI is transferring classes. Maybe there is another property I can set on the client?

_dnoyeBa at 2007-7-8 22:32:50 > top of Java-index,Core,Core APIs...
# 3

> I guess RMI classloader is just different.

> From testing I can see that when the main class is

> marshalled it seems as if the classes it contains are

> also marshalled.

RMIClassLoader is little more than a URLClassLoader. Classes are neither marshalled nor unmarshalled in RMI, they are loaded via the codebase mechanism, using whatever WEB or other protocol you define in the codebase URL.

> The log is not telling me when classes are loaded,

So you're logging the wrong thing?

> So I am still stuck having a hard time knowing when

> the RMI is transferring classes.

RMI isn't transferring classes. The RMIClassLoader is transferring classes in response to class-loading requirements. This is completely separate from RMI marshalling. It is more strongly associated with RMI unmarshalling but these are still distinct operations.

ejpa at 2007-7-8 22:32:50 > top of Java-index,Core,Core APIs...
# 4

I am using sun.rmi.loader.logLevel=v

I did some more testing. The RMIClassloader loads the jars in order and searches them for the class. In my case I had the largest jar listed first which did not even have the class in it. when I changed the order, I got the pauses in my program as you would expect based on when classes are first needed.

So now I wonder if there is a way for the system to know up front which jar has which file so it does not need to download until required. Thats what the manifest does right?

_dnoyeBa at 2007-7-8 22:32:50 > top of Java-index,Core,Core APIs...
# 5
Figured that one out too. jar -i to create an index in my first jar will tell the system which jar has which files. Just need to make sure my first jar is my smallest.
_dnoyeBa at 2007-7-8 22:32:50 > top of Java-index,Core,Core APIs...