OSDN Git Service

Revert "Change LoadNativeLibrary to use GetOrCreateAllocator"
authorMathieu Chartier <mathieuc@google.com>
Tue, 1 Dec 2015 01:20:00 +0000 (01:20 +0000)
committerMathieu Chartier <mathieuc@google.com>
Tue, 1 Dec 2015 01:20:00 +0000 (01:20 +0000)
This reverts commit 2d902b99bba7ae1ad77ebeb038a4ef63c3ed6399.

Change-Id: I4a674844f2f6d76d1c33741b46f12417ec7eab35

runtime/java_vm_ext.cc
test/068-classloader/expected.txt
test/068-classloader/src/FancyLoader.java
test/068-classloader/src/Main.java

index 58da7f2..7cc05f7 100644 (file)
@@ -736,7 +736,7 @@ bool JavaVMExt::LoadNativeLibrary(JNIEnv* env, const std::string& path, jobject
     // it's okay to decode it without worrying about unexpectedly marking it alive.
     mirror::ClassLoader* loader = soa.Decode<mirror::ClassLoader*>(class_loader);
     class_loader_allocator =
-        Runtime::Current()->GetClassLinker()->GetOrCreateAllocatorForClassLoader(loader);
+        Runtime::Current()->GetClassLinker()->GetAllocatorForClassLoader(loader);
     CHECK(class_loader_allocator != nullptr);
   }
   if (library != nullptr) {
index 36e4f48..8725799 100644 (file)
@@ -13,4 +13,3 @@ Got LinkageError on DI (early)
 Got LinkageError on IDI (early)
 class Main
 Got expected ClassNotFoundException
-JNI_OnLoad called
index b8eac7b..6a153cc 100644 (file)
@@ -38,7 +38,7 @@ public class FancyLoader extends ClassLoader {
     static final String CLASS_PATH = "classes-ex/";
 
     /* this is the "alternate" DEX/Jar file */
-    public static final String DEX_FILE = System.getenv("DEX_LOCATION") + "/068-classloader-ex.jar";
+    static final String DEX_FILE = System.getenv("DEX_LOCATION") + "/068-classloader-ex.jar";
 
     /* on Dalvik, this is a DexFile; otherwise, it's null */
     private Class mDexClass;
index e3bf82c..361e293 100644 (file)
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
 /**
  * Class loader test.
  */
@@ -64,28 +62,6 @@ public class Main {
         testSeparation();
 
         testClassForName();
-
-        // Attempt to load without a class table, regression test for b/25866849.
-        testLoadNativeLibrary(args[0]);
-    }
-
-    static void testLoadNativeLibrary(String libName) throws Exception {
-        Class pathClassLoader = Class.forName("dalvik.system.PathClassLoader");
-        if (pathClassLoader == null) {
-            throw new AssertionError("Couldn't find path class loader class");
-        }
-        Constructor constructor =
-            pathClassLoader.getDeclaredConstructor(String.class, ClassLoader.class);
-        ClassLoader loader = (ClassLoader) constructor.newInstance(
-            FancyLoader.DEX_FILE, ClassLoader.getSystemClassLoader());
-        Runtime runtime = Runtime.getRuntime();
-        Method method = runtime.getClass().getDeclaredMethod("loadLibrary", String.class,
-            ClassLoader.class);
-        if (method == null) {
-            throw new RuntimeException("loadLibrary not found");
-        }
-        method.setAccessible(true);
-        method.invoke(runtime, libName, loader);
     }
 
     static void testSeparation() {