Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What does innermost mean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What does innermost mean?" Watch "What does innermost mean?" New topic
Author

What does innermost mean?

Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
What does innermost mean?
JLS 15.12.1 Compile-Time Step 1: Determine Class or Interface to Search

If it is a simple name, that is, just an Identifier, then the name of the method is the Identifier. If the Identifier appears within the scope (�6.3) of a visible method declaration with that name, then there must be an enclosing type declaration of which that method is a member. Let T be the innermost such type declaration. The class or interface to search is T.
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
I think it's saying that the method to look for in a simple method call should be looked for in the most immediate enclosing class or interface, relative to the call.
Defined this way, recursive method calls are also covered.
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
Hi Marlene,
This is how I understood it:

In this case, is t7i the innermost class or interface that it is talking about?
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Thank you Ray and Alton for considering my question.
Alton, I think the JLS uses innermost to mean a relationship between nested classes and enclosing classes. From your example, it looks like you would agree.
Now, is there an innermost class in this example?

What confuses me is, we know that m(A x, B y) is a member of both S and T. And m(B x, A y) is a member of T. Is T innermost?
Who would have thought a subclass is innermost in relation to its superclass?
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
Originally posted by Marlene Miller:

Who would have thought a subclass is innermost in relation to its superclass?

Hi Marlene,
In your last example, if the subclass T is the innermost and S is the outermost, then why does the compiler have to consider the method in S which would cause a compiler error? Shouldn't it had stopped once it found the method in T?
If you would compare this with my example, the compiler is not complaining that there is no most specific method, because it is not considering the outer method.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Hi Alton,
In your last example, if the subclass T is the innermost and S is the outermost, then why does the compiler have to consider the method in S which would cause a compiler error?
Because the method in S is a member of T.

In example 1, m(A x, B y) is a member of S1, m(B x, A y) is a member of T1. T1 is the innermost type.
In example 2, m(A x, B y) is a member of both S2 and T2, m(B x, A y) is a member of T2. I guess T2 is the innermost type.
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
Because the method in S is a member of T.
Which is my point. If there is an innermost boundary, the compiler would not have seen the other method in S. The method is already resolved in T.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Well, I am getting lazy. I almost forgot to thank you Alton for you time and opinions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does innermost mean?