• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

What does innermost mean?

 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I am getting lazy. I almost forgot to thank you Alton for you time and opinions.
 
I am going to test your electrical conductivity with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic