S
seyal.v.p
hi,
Is Class.class different from instanceOfClass.getClass() ?
I know it sounds blank. Let me explain the problem that I faced in
detail;
I have a class Class A with 2 protected methods and a private List
object.
Now in the test class of Class A, in a test case, I create a inner
class for Class A and override the two protected methods of Class A..
In addition I try to set up data in the List using relection.
i.e
testMtd(){
A a = new A(){
// Code for two overriden protected mtds here
};
Field f = A.class.getDeclaredField("NameOfTheListInClassA"); //This
works
Field f = a.getClass().getDeclaredField("NameOfTheListInClassA");
//This doesnt
}
Can anyone explain why?
Thanks in advance,
Seyal
Is Class.class different from instanceOfClass.getClass() ?
I know it sounds blank. Let me explain the problem that I faced in
detail;
I have a class Class A with 2 protected methods and a private List
object.
Now in the test class of Class A, in a test case, I create a inner
class for Class A and override the two protected methods of Class A..
In addition I try to set up data in the List using relection.
i.e
testMtd(){
A a = new A(){
// Code for two overriden protected mtds here
};
Field f = A.class.getDeclaredField("NameOfTheListInClassA"); //This
works
Field f = a.getClass().getDeclaredField("NameOfTheListInClassA");
//This doesnt
}
Can anyone explain why?
Thanks in advance,
Seyal