• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does innermost mean?

 
Marlene Miller
Ranch Hand
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 326
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 443
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 443
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 443
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I am getting lazy. I almost forgot to thank you Alton for you time and opinions.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic