MCPcopy
hub / github.com/Col-E/Recaf / patchInstrumentation

Method patchInstrumentation

src/main/java/me/coley/recaf/util/VMUtil.java:306–319  ·  view source on GitHub ↗

Attempts to make an Instrumentation capable of transforming/redefining classes. @param instrumentation Instrumentation to patch.

(Instrumentation instrumentation)

Source from the content-addressed store, hash-verified

304 * Instrumentation to patch.
305 */
306 public static void patchInstrumentation(Instrumentation instrumentation) {
307 try {
308 Class<?> klass = instrumentation.getClass();
309 Field field = klass.getDeclaredField("mEnvironmentSupportsRedefineClasses");
310 field.setAccessible(true);
311 field.setBoolean(instrumentation, true);
312 (field = klass.getDeclaredField("mEnvironmentSupportsRetransformClassesKnown")).setAccessible(true);
313 field.setBoolean(instrumentation, true);
314 (field = klass.getDeclaredField("mEnvironmentSupportsRetransformClasses")).setAccessible(true);
315 field.setBoolean(instrumentation, true);
316 } catch (NoSuchFieldException | IllegalAccessException ex) {
317 Log.error("Could not patch instrumentation instance:", ex);
318 }
319 }
320
321 /**
322 * Attempts to patch {@link ZipOutputStream} to prevent

Callers 1

agentMethod · 0.95

Calls 2

errorMethod · 0.95
getClassMethod · 0.80

Tested by

no test coverage detected