views:

215

answers:

2

I've done some HotSpot optimization in Java. However, I'm now concerned about space in relation to loading classes (ie. only need one method in a class, don't want to load others). How would I go about doing so?

+1  A: 

Loading a class is an all or none proposition, as far as I know. You don't get to pick and choose by method.

What problem are you really trying to solve here? If you're having memory issues, this shouldn't be your first thought.

duffymo
+4  A: 

What kind of HotSpot optimization have you done? Are you rewriting the bytecode when defining classes?

Java allows for two levels of loading: unresolved and resolved. The latter means "load/link in any classes referenced by this class", which includes all classes that are referenced by any field or method signature and any classes needed by the static initializer. There is no way to load part of a class. If you only need one method in a certain class, why not throw that method into another class?

Rick C. Petty