I have been given an abstract class:
public abstract FooPACImpl {
...
}
And two autogenerated subclasses:
public replyTypeFooPAC extends FooPACImpl {
...
}
public requestTypeFooPAC extends FooPACImpl {
...
}
And an API for creating a network pattern (request/reply) that uses a request Type and a reply Type (A and B are expected to be auto-generated sub-classes of FooPACImpl like the above):
Replier<A, B> get_simple_replier (
String topic,
Object<A> requestType,
Object<B> replyType) {...}
Requester<A, B> get_simple_requester (
String topic,
Object<A> requestType,
Object<B> replyType) {...}
I pull the topic string, and the string names of the two types A and B from an XML stub:
<rr>
<topic>MyReqRepTopic</topic>
<reqtype>foo.bar.baz.myReqTypeFooPAC</reqtype>
<replytype>foo.bar.baz.myReplyTypeFooPAC</replytype>
</rr>
Apparently, reflection in Java can't handle directly a "public abstract" super class?
FooPACImpl foopa = (FooPACImpl) Class.forName(reqtypeName).newInstance();
results in
java.lang.IllegalAccessException: Class foo.bar.fnorb.ServiceSupport \
can not access a member of class foo.bar.baz.myReqTypeFooPAC with \
modifiers "protected"
1) Why "with modifiers 'protected'"? FooPACImpl.getClass().getModifiers returns "public abstract"
2) Is this exception thrown because the class is abstract? or does it have to do with a possible constructor 'protected FooPACImpl () { };'?
3) And, is this even achievable? My understanding is that if you subclass AA with BB, you can use AA where a BB is expected, since BB will have anything that AA is expected to have (methods, fields, etc). Although, it's been awhile. I may be a bit hazy on the particulars of inheritance in java.
Thanks for any points/pointers, and a yes/no answer for #3 is sufficient. In the case of a 'no', hints to how it could be implemented without reflection. I do have access to the code generator templates for the autogenerated stuff, if that helps.