Skip to content

Commit 3096362

Browse files
authored
Premain fix (eugenp#2769)
* Rest-assured fix * Cucumber fix * HystrixManualTest * Reformat HystrixTimeoutManualTest * Premain fix
1 parent 8616b07 commit 3096362

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

  • asm/src/main/java/com/baeldung/examples/asm/instrumentation
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
package com.baeldung.examples.asm.instrumentation;
22

33
import com.baeldung.examples.asm.CustomClassWriter;
4-
4+
import java.lang.instrument.ClassFileTransformer;
5+
import java.lang.instrument.IllegalClassFormatException;
56
import java.lang.instrument.Instrumentation;
7+
import java.security.ProtectionDomain;
68

9+
/**
10+
*
11+
* @author baeldung
12+
*/
713
public class Premain {
814

915
public static void premain(String agentArgs, Instrumentation inst) {
10-
inst.addTransformer((l, name, c, d, b) -> {
16+
inst.addTransformer(new ClassFileTransformer() {
17+
18+
@Override
19+
public byte[] transform(ClassLoader l, String name, Class c,
20+
ProtectionDomain d, byte[] b)
21+
throws IllegalClassFormatException {
1122

12-
if (name.equals("java/lang/Integer")) {
13-
CustomClassWriter cr = new CustomClassWriter(b);
14-
return cr.addField();
23+
if (name.equals("java/lang/Integer")) {
24+
CustomClassWriter cr = new CustomClassWriter(b);
25+
return cr.addField();
26+
}
27+
return b;
1528
}
16-
return b;
1729
});
1830
}
31+
1932
}

0 commit comments

Comments
 (0)