C
Cram TeXeD
Hi guys.
My question is for java killers and is not so dumb as she looks at
first glance.
Just a recall :
For two methods like :
public class Foo {
public void method(String str){
System.out.println("method with string !");
}
public void method(List list){
System.out.println("method with list !");
}
}
if you do
Object arg = (List) null;
foo.method(arg);
you will have public void method(List list) called.
Try if you dont't buy it !
Ok.
My purpose is to get the class of the null reference, like runtime
does !
I have try all things, in java.lang.Class, in java.lang.reflect, in
jakarta Lang : nothing to do !!
Has a java guru here (there' some no ?) a tips to get my null
reference class casting ?
Why to do all this stuff ?
Beacause of I have to select method according to somes args.
I get setProperty(String str) and setProperty(List list) methods in a
list and to do a "unset" operation with a null value I have to select
the right one !
So if I get :
// unset
Object nullValue = (String) null;
Method m = selectMethodByArg(new Object[] {nullValue));
How Can I write my selectMethodByArg without knowing the right
nullValue type ?
Cram TeXeD
My question is for java killers and is not so dumb as she looks at
first glance.
Just a recall :
For two methods like :
public class Foo {
public void method(String str){
System.out.println("method with string !");
}
public void method(List list){
System.out.println("method with list !");
}
}
if you do
Object arg = (List) null;
foo.method(arg);
you will have public void method(List list) called.
Try if you dont't buy it !
Ok.
My purpose is to get the class of the null reference, like runtime
does !
I have try all things, in java.lang.Class, in java.lang.reflect, in
jakarta Lang : nothing to do !!
Has a java guru here (there' some no ?) a tips to get my null
reference class casting ?
Why to do all this stuff ?
Beacause of I have to select method according to somes args.
I get setProperty(String str) and setProperty(List list) methods in a
list and to do a "unset" operation with a null value I have to select
the right one !
So if I get :
// unset
Object nullValue = (String) null;
Method m = selectMethodByArg(new Object[] {nullValue));
How Can I write my selectMethodByArg without knowing the right
nullValue type ?
Cram TeXeD