Premain fix (#2769)

* Rest-assured fix

* Cucumber fix

* HystrixManualTest

* Reformat HystrixTimeoutManualTest

* Premain fix
This commit is contained in:
Grzegorz Piwowarek 2017-10-19 23:23:47 +02:00 committed by GitHub
parent 8616b07506
commit 3096362fa2
1 changed files with 19 additions and 6 deletions

View File

@ -1,19 +1,32 @@
package com.baeldung.examples.asm.instrumentation;
import com.baeldung.examples.asm.CustomClassWriter;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
/**
*
* @author baeldung
*/
public class Premain {
public static void premain(String agentArgs, Instrumentation inst) {
inst.addTransformer((l, name, c, d, b) -> {
inst.addTransformer(new ClassFileTransformer() {
@Override
public byte[] transform(ClassLoader l, String name, Class c,
ProtectionDomain d, byte[] b)
throws IllegalClassFormatException {
if (name.equals("java/lang/Integer")) {
CustomClassWriter cr = new CustomClassWriter(b);
return cr.addField();
}
return b;
}
});
}
}