On Fri, 23 Jun 2000, Frank Krahmer wrote:
 
> Dear Sir,
> 
> how can I access a public baseclass attribute in a Java class via Jacl,
> when an object of derived class is instanciated ?
> 
> Java-class example :
> --------------------
> public class baseClass
> {     public String dummyAttribute;
> }
> public class derivedClass extends baseClass
> {     // anything
> }
> 
> Jacl-access example :
> ---------------------
> set theDerivedObj [java::new derivedClass]
> java::field $theDerivedObj dummyAttribute  "blabla"   // RUNTIME ERROR        
> // brings error tcl.lang.TclException: field "name" doesn't exist
> 
> set theBaseObj [java::new baseClass]
> java::field $theBaseObj dummyAttribute  "blabla"      // OK   
> 
> When the object is of class baseClass, the attribute is accessible.
> When the object is of class derivedClass, the attribute is not accessible.


You have found a bug in Tcl/Java. One should be able to access
fields from inherited classes by default. I am going to check
your test case into the CVS and then start look into how to solve
the problem. If you are interested in writing up a patch to fix
this problem, it will get fixed a lot sooner :)

The source files of interest are:

src/tcljava/tcl/lang/JavaFieldCmd.java
src/tcljava/tcl/lang/JavaInvoke.java (getField and setField methods)

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