From 536f130595229f3a45df99c8170fbdc2dc793d6f Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Mon, 27 Jun 2011 12:15:50 +0900 Subject: [PATCH] Fixes issue 21 --- src/test/java/org/xerial/snappy/SnappyLoaderTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/xerial/snappy/SnappyLoaderTest.java b/src/test/java/org/xerial/snappy/SnappyLoaderTest.java index deb755a..24e71d5 100755 --- a/src/test/java/org/xerial/snappy/SnappyLoaderTest.java +++ b/src/test/java/org/xerial/snappy/SnappyLoaderTest.java @@ -85,18 +85,23 @@ public class SnappyLoaderTest @Test public void loadSnappyByDiffentClassloadersInTheSameJVM() throws Exception { + + // Parent class loader cannot see Snappy.class ClassLoader parent = this.getClass().getClassLoader().getParent(); ClassWorld cw = new ClassWorld(); ClassRealm P = cw.newRealm("P", parent); + // Prepare the child class loaders which can load Snappy.class URL classPath = new File("target/classes").toURI().toURL(); ClassRealm L1 = cw.newRealm("l1", URLClassLoader.newInstance(new URL[] { classPath }, parent)); ClassRealm L2 = cw.newRealm("l2", URLClassLoader.newInstance(new URL[] { classPath }, parent)); + // Actually load Snappy.class in a class loader Class< ? > S1 = L1.loadClass("org.xerial.snappy.Snappy"); Method m = S1.getMethod("getNativeLibraryVersion"); String v = (String) m.invoke(null); + // Load Snappy.class from another class loader Class< ? > S2 = L2.loadClass("org.xerial.snappy.Snappy"); Method m2 = S2.getMethod("getNativeLibraryVersion"); String v2 = (String) m2.invoke(null); @@ -107,7 +112,7 @@ public class SnappyLoaderTest @Ignore @Test - public void loadFromSytemClassLoader() throws Exception { + public void createByteCodeOfSnappyLoader() throws Exception { ClassLoader parent = this.getClass().getClassLoader().getParent(); ClassWorld cw = new ClassWorld();