Someone in my group asked me about accessing static nested classes
from Jacl.  Below is a description and a solution.

http://java.sun.com/docs/books/tutorial/java/more/nested.html
says:
     A static nested class is called just that: a static nested
     class. A nonstatic nested class is called an inner class. 

The innerclass spec has a slightly different terminology
http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc.html
says:
     In addition, the programmer can define a class as a static member
     of any top-level class. Classes which are static class members
     and classes which are package members are both called top-level
     classes. They differ from inner classes in that a top-level class
     can make direct use only of its own instance variables. The
     ability to nest classes in this way allows any top-level class to
     provide a package-like organization for a logically related group
     of secondary top-level classes, all of which share full access to
     private members.

Below is a small test case:

cxh@maury 84% cat TestInnerClasses.java
public class TestInnerClasses {

    public static void main(String args[]) {
        MyInnerClass mic = new MyInnerClass();
        System.out.println( mic.testing());
    }
    public static class MyInnerClass {
        public String testing() {
            return new String("MyInnerClass::testing()");
        }
    }
}
cxh@maury 85% setenv CLASSPATH .
cxh@maury 86% javac TestInnerClasses.java
cxh@maury 87% java TestInnerClasses
MyInnerClass::testing()
cxh@maury 88% /usr/tools/bin/ptjacl
% set tic [java::new TestInnerClasses]
java0x1
% set mic [java::new TestInnerClasses\$MyInnerClass]
java0x2
% java::info class $mic
TestInnerClasses$MyInnerClass
% $mic testing
MyInnerClass::testing()

Using the \$ syntax seems a little dicey, but apparently it works.

-Christopher

----------------------------------------------------------------
The TclJava mailing list is sponsored by WebNet Technologies.
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]'. 
A list archive is at: http://www.findmail.com/listsaver/tcldallas/

Reply via email to