Ahh, I remember hearing this from you in the past.  However, as then, I
still don't get why it's bad to use the "most derived" class.  Why wouldn't
you want to give the user access to the DerivedFromHashtable (to use the
example in the docs)?  What if there are methods or fields in this derived
class that you'd like to provide for the user?  Is it simply a matter of
security or integrity of the object or what?

The call to ReflectObject.newInstance() in my case is in a base class that
is then extended by other similar classes.  What would be the difference
between putting

        ReflectObject.newInstance( interp, this.getClass(), this );

in the higher level class where this.getClass() resolved to the subclass and
putting

        ReflectObject.newInstance( interp, SubClass.class );

calls in each of the subclasses?

> ACK, NO! Do not call this.getClass() to get the second argument
> to the ReflectObject.newInstance() method. You need to use the
> actual Java Class object that the instance will be reflected as.
> For instance if you want to reflect a java.lang.String object
> you need to call it like the following example. Using getClass()
> seems like a good idea but you will end up shooting yourself in the foot.
> See the docs for ReflectObject.newInstance() if you want a
> detailed example of why that is so very wrong.
>
> obj = ReflectObject.newInstance( interp, String.class, "my string" );
>
>
> >             tclObject = ReflectObject.newInstance( interp,
> >                      this.getClass(), this );
> >             tclObject.preserve();
>>

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 

Reply via email to