On Tue, 27 Jun 2000, Dr Wes Munsil wrote:

> A question, and a comment.
> 
> 1) What does that mean? Objects don't have types: variables have types, objects
> have classes (http://www.javasoft.com/docs/books/jls/html/4.doc.html#24887).
> o.getClass() is the class of the object. I don't mean to be pedantic, but if
> there is really some TclBlend requirement here I would like to understand it.

Objects do not have types, references to objects determine what behavior
the object will provide. In Tcl/Java you don't really have a reference
but you "reflect" an object as a type. You need to pass in the
java.lang.Class object that a given java.lang.Object will be reflected
as, and it needs to be the correct class (which is not always the same
as the one returned by Object.getClass() ).

> 2) The examples in the TclBlend docs I have seen that warn against using
> o.getClass() are framed in terms of subclasses. In this small test case,
> o.getClass() refers to java.util.Vector, and not any subclass of that.

I thought the docs were clear, but it sounds like they will need some
work. Would you like to help? I have tried writing them a couple
of times but it seems like the message is still not getting through.

1. If you call getClass() you will never be able to reflect an
  interface type.

2. If you call getClass() it will always return the most derived
   type, this is wrong is many many ways. It can lead to problems
   with method invocation and it will let you call methods that
   would not be accessable in regular Java.

3. This whole mess is what was fixed during the transition from
   Tcl/Java 1.0 to 1.1. If you call getClass() then we lose all
   the benefits we gained from the 1.0 -> 1.1 rewrite.

I am sure there are others I am forgetting.

Mo DeJong
Red Hat Inc

----------------------------------------------------------------
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]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to