I was wondering if it is possible to do something like this with byte-code manipulation:
public class Foo {
public int getBlah() {
return 1;
}
}
public void hi(int x) {
System.out.println("hi: " + x);
}
public void hi(String x) {
System.out.println("wow: " + x);
}
Now I want to call:
hi(foo.getBlah());
and invoke the overloading hi method for the String parameter.
Can you handle a flagged value on
hi(int x)? If yes you could do something like this:It is basically:
getBlah()methodThreadLocal?) whatever String parameter you want to pass to the overloadedhimethod0,-1orInteger.MIN_VALUEIt is a little hacky and it looks best when you don’t have a primitive so you can use
nullas your flagged value. Hopefully someone has a better answer. 🙂