Add field access condition override example

This commit is contained in:
Gabriel Tofvesson 2020-04-16 03:16:07 +02:00
parent 7ed39dc319
commit c6cd8a4e15
2 changed files with 9 additions and 5 deletions

View File

@ -1,20 +1,24 @@
import dev.w1zzrd.asm.InjectClass;
import dev.w1zzrd.asm.Inject;
import dev.w1zzrd.asm.Merger;
@InjectClass(value = MergeTest.class)
public class MergeInject implements Runnable {
// Dummy field
String s;
@Inject
public String test(){
System.out.println(Merger.field("s"));
System.out.println(s);
return "Modified";
}
@Override
@Inject
public void run() {
for (int i = 0; i < 5; ++i)
for (int i = 0; i < 5; ++i) {
s = s + "!";
System.out.println(test());
}
}
}

View File

@ -1,10 +1,10 @@
public class MergeTest {
private String s = "Hello";
private final String s;
public MergeTest(){
s = "Hello";
}
public MergeTest(String s) {