my dog learned polymorphism*
The moose likes Java in General and the fly likes method invocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "method invocation" Watch "method invocation" New topic
Author

method invocation

Oceana Wickramasinghe
Ranch Hand

Joined: Mar 02, 2011
Posts: 77
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

Joined: Apr 15, 2011
Posts: 294
    
    2

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


It's not what your program can do, it's what your users do with the program.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method invocation
 
Similar Threads
Inner class
About Overridden II (a Mock Question question...)
method invocation
I just destroyed Polymorphism
Help with Dan's Chapter 6, exam 1, question 8.