>>>>> "Stuart" == Stuart Ballard <[EMAIL PROTECTED]> writes:

>> The rule is, a default constructor inherits the access of its class.
>> I.E., 'protected' is correct here.

Stuart> Doesn't that mean that a class that inherits from JEditorPane can see
Stuart> the class but not the constructor? And isn't that a little weird? (Not
Stuart> disputing your JLS expertise, mind you :) )

Oh, no... access control quiz!

I think you are right, the access is disallowed.  It is a bit weird
but the default constructor access rule is pretty definitive:

http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#16823

The inherited member class can still be used in this case by making a
subclass of it.

>> Perhaps you can do it by noticing if the class has a synthetic
>> 'this$0' field.  This is the usual name for an 'outer this'
>> reference, meaning that the class is not static.

Stuart> Does every nonstatic inner class get its outer this prepended to every
Stuart> constructor? (It's easy enough to detect that the class isn't static,
Stuart> we already flag a japi error if the staticness is wrong)

Stuart> What about a doubly-nested inner class, does it get two or
Stuart> just the innermost?

Just the immediate outer instance is passed in.

Suppose you're making an instance of a doubly-nested inner class:

class Outer {
  class Middle {
    class Inner {
    }
  }
}

You have to write something like <middle>.new Inner().
The <middle> instance here, however it was made, already has its own
'this$0' pointing at the instance of Outer.

Hmm, actually there is a weird case, I think, where both the
instantiated class and its superclass have outer instances.  I forget
what happens in this situation.

Tom


_______________________________________________
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to