next up previous
Next: GNU make and preprocessor Up: Appendix Previous: Update to JDK 1.1

An implementation note on findMID.

The Capsule class has a static method that is called in the static initializer of a capsule, i.e.:

final private static byte[] MID = findMID("ants.DataCapsule");
This looks up the name in a table and finds the method id associated with that name. Since these names are now local to one particular InChannel, we must make sure that we consult the table of the InChannel whose class loader loaded this class. To be more exact, since the static initializers are executed in the course of the class loader's defineClass method, it must consult the table of the InChannel that is currently loading that class. Unfortunately, there is no way in Java to identify the current class loader in a static method: in a non-static method, getClass().getClassLoader() could be used. To circumvent this problem, we simply map the current thread to its InChannel, and maintain initializers tables per InChannel. We assume that the same thread that call defineClass will also execute the static initializers of the class being defined.



Jay Lepreau
Tue Jun 2 05:48:49 MDT 1998