Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Codewarrior Java > Is this a CW co...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 40 of 81
Post > Topic >>

Is this a CW compiler problem?

by Jonathan Wilcox <jonathan.wilcox@[EMAIL PROTECTED] > May 6, 2004 at 09:43 PM

I have a puzzle involving inner cl***** that look like this:

public class TP {
    	public final String tpName;
    	public TP(String name) { tpName = name; }
    	public TCP tpc = new TCP(name+".tcp");
    	public DataObject getListed(int index) {...}
    	public class TPC { // non-static inner class
    	    	public final String tpcName;
    	    	public TPC(String name) { tpcName = name; }
    		public TPCR tpcr = new TPCR(name+".tpcr");
    	    	public DataObject getDataObject(int index) {
    	    	    	return getListed(index);    	    	    	
    	    	}
    	      public class TPCR { // non-static inner class
    	    	    	public final String tpcrName;
    	    	    	public TPCP(String name) { tpcrName = name; }
    	    	    	public void display(int n) {
    	    	    	    	DataObject d = getDataObject(n);
    	    	    	    	if(d != null)
    	    	    	    	    	System.out.println(d.toString());
    	    	    	    	} // end isListed()
    	    	    	} // end display()
    	    	} // end inner class TPCR
    	} // end inner class TPC
} // end class TP

I have two TP objects: tp_1 and tp_2, and each has one
TCP object, and each TCP object has one TPCR object.

When calling 'tpcr.display(n) from the context of tp_2', I 
find that the function executes in the context of tp_2 in 
the call to 'getDataObject(n)', but it executes in the context 
of tp_1 in the nested call to 'getListed(n)'.

Upon return from the call stack, however, the context of 
tp_2 has been restored.

Each object has a String 'xName' member, and I have determined
context by examining the name of the outermost container.  
Perhaps a detailed examination of the call stack would show
something different, but this apparent switch of context is
puzzling and disturbing.

I am using version 5.0.0.951 of the CW IDE and the included
CW Java compiler. Has any similar problem with inner cl*****
been re****ted?  

Thanks in advance.

Jonathan Wilcox
 




 2 Posts in Topic:
Is this a CW compiler problem?
Jonathan Wilcox <jonat  2004-05-06 21:43:37 
Re: Is this a CW compiler problem?
MW Ron <mwron@[EMAIL P  2004-05-10 15:02:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 14:12:00 CDT 2008.