Below is the response that Mo sent me when I could not access fields that
were inherited from a base class.  This will let you read/write fields from
a Base Class.

==========================================

This sounds like a documentation problem. The HTML docs do indicate
that this is possible but there is no example of how to do it.

You should be able to get or set a shadowed value like this:

java::field $obj {FIELD BASECLASS}
java::field $obj {FIELD BASECLASS} NEWVALUE

I will have to add a short example to the docs about this problem.

Mo Dejong
Red Hat Inc.

On Tue, 1 Feb 2000, Trella Christopher-P28453 wrote:

> If I have a class that inherits from a base class, I cannot use the
> java::field command to get access to fields that are inherited from the
base
> class.  Why can't I look at fields that are inherited from the base class.
>  
> Chris Trella
> 480-675-1347
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 

> -----Original Message-----
> From: Mo DeJong [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 23, 2000 1:19 PM
> To: Frank Krahmer
> Cc: [EMAIL PROTECTED]
> Subject: [Tcl Java] Re: [Tcl Java] Access to public baseclass data
> members via Jacl
> 
> 
> 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-> [EMAIL PROTECTED]
> 

----------------------------------------------------------------
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