public static void main (String[] args)
{
RootClassLoader rootCl = new RootClassLoader("root loader");
Class firstClass = load(rootCl, "First");
System.out.println("Main: loaded First.");
Object firstInst = null;
try {
System.out.println("Main: first.newInstance(....");
firstInst = firstClass.newInstance();
System.out.println("Main: ...)");
} catch (Exception X) {
System.out.println("Probably should put First class def'n in `First.java`");
X.printStackTrace();
}
System.out.println("Main: testing firstInst.");
if (!(firstInst instanceof BaseClass)) {
// Classloader for firstInst is RootClassLoader, while loader
// for inline BaseClass reference if default loader.
System.out.println("Notice that firstInst is *not* "+
"an instance of BaseClass, because class loaders differ.");
} else {
// won't happen:
((First)firstInst).here();
}
Object firstInst2 = new First("other");
((First)firstInst2).here();
// Kaffe's problem:
Class secondClass = load(rootCl, "Second");
System.out.println("loaded Second.");
Object secondInst=null;
try {
secondInst = secondClass.newInstance();
} catch (Exception X) {
System.out.println("Probably should put Second class def'n in `Second.java`");
X.printStackTrace();
}
}