Re-enable tests 934 & 935

There were two issues causing problems with these tests.

1) The loading of classes could occur prior to the transformer being
   enabled. This was fixed by putting the classes under test into a
   different ClassLoader and disabling app-images.

2) DexToDex compilation was devirtualizing some calls meaning that
   reordering the methods was causing incorrect dispatch.

This reverts commit 50cc0cceb5ca0abd4fff2cb3467ea74e7590cb10.
This reverts commit e9f36b7cb42348ef5c4eb3c88bd3cfdd56390a3e.
This reverts commit 1e7e96e4a66f668255a1683b837863228489faf9.

Test: ART_TEST_INTERPRETER=true \
      ART_TEST_JIT=true \
      mma -j40 test-art-host

Test: ART_TEST_INTERPRETER_ACCESS_CHECKS=true \
      ART_TEST_RUN_TEST_NO_DEX2OAT=true \
      ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT=true \
      ART_TEST_RUN_TEST_NO_RELOCATE=true \
      mma -j40 test-art-host-run-test-934-load-transform \
               test-art-host-run-test-935-non-retransformable

Change-Id: Ia600ba37d45a5f9489b03c7f4d143849c887b8a7
diff --git a/test/934-load-transform/run b/test/934-load-transform/run
index c6e62ae..adb1a1c 100755
--- a/test/934-load-transform/run
+++ b/test/934-load-transform/run
@@ -14,4 +14,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-./default-run "$@" --jvmti
+./default-run "$@" --jvmti --no-app-image
diff --git a/test/934-load-transform/src-ex/TestMain.java b/test/934-load-transform/src-ex/TestMain.java
new file mode 100644
index 0000000..33be9cd
--- /dev/null
+++ b/test/934-load-transform/src-ex/TestMain.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class TestMain {
+  public static void runTest() {
+    new Transform().sayHi();
+  }
+}
diff --git a/test/934-load-transform/src/Transform.java b/test/934-load-transform/src-ex/Transform.java
similarity index 100%
rename from test/934-load-transform/src/Transform.java
rename to test/934-load-transform/src-ex/Transform.java
diff --git a/test/934-load-transform/src/Main.java b/test/934-load-transform/src/Main.java
index 0b7f2689..3bd913b 100644
--- a/test/934-load-transform/src/Main.java
+++ b/test/934-load-transform/src/Main.java
@@ -14,8 +14,11 @@
  * limitations under the License.
  */
 
+import java.lang.reflect.*;
 import java.util.Base64;
-public class Main {
+
+class Main {
+  public static String TEST_NAME = "934-load-transform";
 
   /**
    * base64 encoded class/dex file for
@@ -48,14 +51,36 @@
     "AOAAAAAGAAAAAQAAAAABAAABIAAAAgAAACABAAABEAAAAQAAAFwBAAACIAAADgAAAGIBAAADIAAA" +
     "AgAAABMCAAAAIAAAAQAAAB4CAAAAEAAAAQAAACwCAAA=");
 
-  public static void main(String[] args) {
-    doTest();
+  public static ClassLoader getClassLoaderFor(String location) throws Exception {
+    try {
+      Class<?> class_loader_class = Class.forName("dalvik.system.PathClassLoader");
+      Constructor<?> ctor = class_loader_class.getConstructor(String.class, ClassLoader.class);
+      /* on Dalvik, this is a DexFile; otherwise, it's null */
+      return (ClassLoader)ctor.newInstance(location + "/" + TEST_NAME + "-ex.jar",
+                                           Main.class.getClassLoader());
+    } catch (ClassNotFoundException e) {
+      // Running on RI. Use URLClassLoader.
+      return new java.net.URLClassLoader(
+          new java.net.URL[] { new java.net.URL("file://" + location + "/classes-ex/") });
+    }
   }
 
-  public static void doTest() {
+  public static void main(String[] args) {
     addCommonTransformationResult("Transform", CLASS_BYTES, DEX_BYTES);
     enableCommonRetransformation(true);
-    new Transform().sayHi();
+    try {
+      /* this is the "alternate" DEX/Jar file */
+      ClassLoader new_loader = getClassLoaderFor(System.getenv("DEX_LOCATION"));
+      Class<?> klass = (Class<?>)new_loader.loadClass("TestMain");
+      if (klass == null) {
+        throw new AssertionError("loadClass failed");
+      }
+      Method run_test = klass.getMethod("runTest");
+      run_test.invoke(null);
+    } catch (Exception e) {
+      System.out.println(e.toString());
+      e.printStackTrace();
+    }
   }
 
   // Transforms the class