Method and apparatus for preforming method lookup in the presence of modularity constructs to support transitive method override
AssigneeSun Microsystems, Inc.
InventorGilad Bracha
Life of this patent
Estimating the term…
Loading patent…
AssigneeSun Microsystems, Inc.
InventorGilad Bracha
Estimating the term…
A method lookup mechanism is disclosed which not only enforces accessibility constraints imposed by modularity constructs but also enables transitive method override. According to one embodiment, when a method m is invoked on a target object, the resolved method m in a resolved class is checked to determine whether it has been declared as public/protected. If so, then standard method lookup may be used to determine the proper implementation of method m to invoke. However, if the resolved method is not declared as public/protected, then a path stack is constructed. The path stack provides a listing of the class hierarchy between the target object and the resolved class. Once constructed, the path stack is used to determine which implementation of method m to invoke in response to the method invocation. Specifically, the resolved method m is initially set as the candidate method to invoke. Then a downward search is performed through the classes on the path stack. At each class on the path stack, a determination is made as to whether that class: (1) provides an implementation for the method m; (2) can access the resolved method; and (3) has declared the method m as public/protected. If so, then the proper implementation for method m to be invoked may be determined using standard method lookup. However, if a class satisfies only the first two criteria, then the method m for that class is made the new candidate method, and the process loops back to test the next class on the path stack. This loop continues until either a class is found which satisfies all three criteria, in which case standard method lookup is used to invoke the proper implementation for method m, or until all of the classes on the path stack have been tested, in which case the last detected candidate method is invoked.
A computer implemented method for performing dynamic method dispatch, comprising:
An apparatus for performing dynamic method dispatch, comprising:
A computer readable medium having stored thereon instructions which, when executed by one or more processors, cause the one or more processors to perform dynamic method dispatch, said computer readable medium comprising:
Dependencies are inferred from the claim text.