Class nonpublicInterface =
fnnLoader1.loadClass("NonpublicInterface");
Class publicInterface =
fnnLoader1.loadClass("PublicInterface");
Proxy proxy1 = (Proxy) Proxy.newProxyInstance(parentNonpublic,
new Class[] {nonpublicInterface, publicInterface},
new TestInvocationHandler());
unmarshalProxyClass(proxy1, fnnLoader1, parentNonpublic, 1, null);
/* Case 2 */
Class zipConstantsClass =
Class.forName("java.util.zip.ZipConstants");
URLClassLoader fnnLoader2 =
new URLClassLoader(new URL[] {fnnUrl});
Proxy proxy2 = (Proxy) Proxy.newProxyInstance(null,
new Class[] {zipConstantsClass, Checksum.class},
new TestInvocationHandler());
unmarshalProxyClass(proxy2, fnnLoader2,
(ClassLoader) null, 2, null);
/* Case 3 */
Thread currentThread = Thread.currentThread();
ClassLoader fnnLoader3 = new URLClassLoader(
new URL[] {publicUrl, fnnUrl});
ClassLoader newCtxLoader =
new URLClassLoader(new URL[] {publicUrl}, fnnLoader3);
Class publicInterface3 =
fnnLoader3.loadClass("PublicInterface");
ClassLoader currentCtxLoader =
currentThread.getContextClassLoader();
currentThread.setContextClassLoader(newCtxLoader);
Proxy proxy3 = (Proxy) Proxy.newProxyInstance(newCtxLoader,
new Class[] {publicInterface3},
new TestInvocationHandler());
unmarshalProxyClass(proxy3, fnnLoader3, fnnLoader3,
3, new Case3Checker());
currentThread.setContextClassLoader(currentCtxLoader);
/* Case 4 */
ClassLoader bothNonpublicLoader =
new URLClassLoader(new URL[] {bothNonpublicUrl});
Class nonpublicInterface4a =
bothNonpublicLoader.loadClass("NonpublicInterface");
Class nonpublicInterface4b =
bothNonpublicLoader.loadClass("NonpublicInterface1");
Proxy proxy4 = (Proxy) Proxy.newProxyInstance(bothNonpublicLoader,
new Class[] {nonpublicInterface4a, nonpublicInterface4b},
new TestInvocationHandler());
ClassLoader nonpublicLoaderA =
new URLClassLoader(new URL[] {nonpublicUrl});
ClassLoader nonpublicLoaderB =
new URLClassLoader(new URL[] {nonpublicUrl1}, nonpublicLoaderA);
currentCtxLoader =
currentThread.getContextClassLoader();
currentThread.setContextClassLoader(nonpublicLoaderB);
IllegalAccessError illegal = null;
try {
unmarshalProxyClass(proxy4, fnnLoader2, nonpublicLoaderB,
4, null);
} catch (IllegalAccessError e) {
illegal = e;
}
if (illegal == null) {
TestLibrary.bomb("case4: IllegalAccessError not thrown " +
"when multiple nonpublic interfaces have \n" +
"different class loaders");
} else {
System.err.println("\ncase4: IllegalAccessError correctly " +
"thrown \n when trying to load proxy " +
"with multiple nonpublic interfaces in \n" +
" different class loaders");
}
currentThread.setContextClassLoader(currentCtxLoader);
/* Case 5*/
ClassLoader publicLoader =
new URLClassLoader(new URL[] {publicUrl});
Class publicInterface5 =
publicLoader.loadClass("PublicInterface");
Proxy proxy5 = (Proxy) Proxy.newProxyInstance(publicLoader,
new Class[] {publicInterface5},
new TestInvocationHandler());
currentCtxLoader =
currentThread.getContextClassLoader();
currentThread.setContextClassLoader(publicLoader);
unmarshalProxyClass(proxy5, fnnLoader2, publicLoader, 5,
new Case5Checker());
currentThread.setContextClassLoader(currentCtxLoader);
/* Case 6 */
ClassLoader fnnLoader6 =
new URLClassLoader(new URL[] {fnnUrl, publicUrl});
ClassLoader publicLoader6 =
new URLClassLoader(new URL[] {publicUrl1}, fnnLoader6);
Class publicInterface6a =
publicLoader6.loadClass("PublicInterface1");
Class publicInterface6b =
fnnLoader6.loadClass("PublicInterface");
Proxy proxy6 = (Proxy) Proxy.newProxyInstance(publicLoader6,
new Class[] {publicInterface6a, publicInterface6b},
new TestInvocationHandler());
ClassNotFoundException cnfe = null;
try {
unmarshalProxyClass(proxy6, fnnLoader6, publicLoader6, 6,