diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-01-23 08:21:28 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-01-23 08:21:28 +0000 |
commit | 3e1490c1a1f1e1b9b48a79a697aa3f903c50955c (patch) | |
tree | 35c28079f4c7b251b91bedfaccbf80ccaba506bc | |
parent | 060b9ea06a1868c32f481f7b583174ea5c985138 (diff) | |
parent | a3c9c3caed216b8076efe7a2c4865c1f2622e361 (diff) | |
download | dexmaker-3e1490c1a1f1e1b9b48a79a697aa3f903c50955c.tar.gz |
Snap for 4560043 from a3c9c3caed216b8076efe7a2c4865c1f2622e361 to pi-release
Change-Id: Ic32358e62b065e4f9936bb4bf352c7700e9e6ea3
-rw-r--r-- | dexmaker-mockito-inline/src/main/java/com/android/dx/mockito/inline/JvmtiAgent.java | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/dexmaker-mockito-inline/src/main/java/com/android/dx/mockito/inline/JvmtiAgent.java b/dexmaker-mockito-inline/src/main/java/com/android/dx/mockito/inline/JvmtiAgent.java index 1b4a550..aca7a0c 100644 --- a/dexmaker-mockito-inline/src/main/java/com/android/dx/mockito/inline/JvmtiAgent.java +++ b/dexmaker-mockito-inline/src/main/java/com/android/dx/mockito/inline/JvmtiAgent.java @@ -34,7 +34,7 @@ import dalvik.system.BaseDexClassLoader; * Interface to the native jvmti agent in agent.cc */ class JvmtiAgent { - private static final String AGENT_LIB_NAME = "dexmakerjvmtiagent"; + private static final String AGENT_LIB_NAME = "libdexmakerjvmtiagent.so"; private static final Object lock = new Object(); @@ -65,32 +65,14 @@ class JvmtiAgent { + "by a BaseDexClassLoader"); } - // Currently Debug.attachJvmtiAgent requires a file in the right directory - File copiedAgent = File.createTempFile("agent", ".so"); - copiedAgent.deleteOnExit(); - - try (InputStream is = new FileInputStream( - ((BaseDexClassLoader) cl).findLibrary(AGENT_LIB_NAME))) { - try (OutputStream os = new FileOutputStream(copiedAgent)) { - byte[] buffer = new byte[64 * 1024]; - - while (true) { - int numRead = is.read(buffer); - if (numRead == -1) { - break; - } - os.write(buffer, 0, numRead); - } - } - } - try { /* * TODO (moltmann@google.com): Replace with regular method call once the API becomes * public */ Class.forName("android.os.Debug").getMethod("attachJvmtiAgent", String.class, - String.class).invoke(null, copiedAgent.getAbsolutePath(), null); + String.class, ClassLoader.class).invoke(null, AGENT_LIB_NAME, + null, cl); } catch (InvocationTargetException e) { loadJvmtiException = e.getCause(); } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException e) { @@ -99,7 +81,7 @@ class JvmtiAgent { if (loadJvmtiException != null) { if (loadJvmtiException instanceof IOException) { - throw (IOException)loadJvmtiException; + throw new IOException(cl.toString(), loadJvmtiException); } else { throw new IOException("Could not load jvmti plugin", loadJvmtiException); |