Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method invocation

 
Oceana Wickramasinghe
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys, i was reading through the java specification,and i found this under "method invocation expression" section.

The first step in processing a method invocation at compile time is to figure out the name of the method to be invoked and which class or interface to check for definitions of methods of that name. There are several cases to consider, depending on the form that precedes the left parenthesis, as follows:
If the form is MethodName, then there are three subcases:
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.

im having a hard time understanding the underlined part. Can someone give me a code example. Thanks in advance


anyway this has nothing to do with my question, but has any of you noticed that sun's java specification is gone? i had to use google cache feature to access java specification.
 
Joe Areeda
Ranch Hand
Posts: 331
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oceana Wickramasinghe wrote:
If the form is MethodName, then there are three subcases:
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.

im having a hard time understanding the underlined part. Can someone give me a code example. Thanks in advance

This stuff is always fun. I think I know what they're talking about so here's something for people to make fun of:

The trick is nested and anonymous classes. Suppose you have something like

The underlined section says that the contructor of MyData will call MyData.setName() with an unqualified method invocation. If there were no setName in MyData it would call MyClass.setName(). The T refers to MyData in the example or MyClass if there isn't a setname method.

I'm pretty sure that's what they're talking about but no guarantees.

Joe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic