Method and apparatus for dispatch table construction
AssigneeSun Microsystems, Inc.
InventorsGilad Bracha, Deepa Viswanathan
Life of this patent
Estimating the term…
Abstract
Apparatus, and computer program products are disclosed for constructing dispatch tables. In one embodiment of the present invention, the decision to allocate a new dispatch table entry is sensitive to the accessibility of a class. A dispatch table and dispatch table construction process is described in which the entries for a Vtable are determined such that conflicts between accessibility and class hierarchy are avoided. In particular, a dispatch table and dispatch table construction process is described which takes a method's accessibility and package status into consideration in determining the proper overriding semantics and table building techniques. The dispatch table may have more than one distinct entry for a method.
Claims22
A dispatch table for a class that inherits from at least one superclass, the dispatch table comprising:
- a plurality of entries in the dispatch table for a particular method, wherein each entry for the method is associated with a distinct accessibility such that the inheritance from the at least one superclass can be overwritten to avoid accessibility conflicts between the superclass and the class such that an appropriate level of accessibility is preserved.
A dispatch table for a class that inherits from at least one superclass, the dispatch table comprising:
- a plurality of entries in the dispatch table for a particular method, wherein each entry for the method is associated with a distinct accessibility such that the inheritance from the at least one superclass can be overwritten to avoid accessibility conflicts between the superclass and the class such that an appropriate level of accessibility is preserved and wherein the distinct accessibility is one of a public accessibility, a private accessibility, a protected accessibility or a package private accessibility.
A dispatch table for a class that inherits from at least one superclass, the dispatch table comprising:
- a plurality of entries for a particular method, wherein each entry for the method is associated with a distinct accessibility;
- a superclass dispatch table copied from one of the at least one superclass;
- a dispatch table index for the particular method and a common accessibility when the particular method and common accessibility exist in both the class and the at least one superclass;
- and
- a dispatch table entry for each index assigned to the particular method and the common accessibility.
A dispatch table for a class that inherits from a direct superclass, the dispatch table comprising:
- a plurality of entries for a particular method, wherein each entry for the method is associated with a distinct accessibility;
- a direct superclass dispatch table copied from the direct superclass;
- a new entry in the dispatch table for the particular method in the first class when the particular method also exists in the direct superclass and when the direct superclass of the version is not accessible;
- and
- an overwritten entry in the dispatch table for the particular method in the first class when the particular method also exists in the direct superclass and when the direct superclass of the version is accessible.
A method of creating a dispatch table comprising:
- providing an unprocessed method having a class;
- determining an inheritance from at least one of a plurality of superclasses;
- determining a distinct accessibility from each of the unprocessed method and the at least one of a plurality of superclasses;
- assigning a priority to each of the determined distinct accessibilities;
- and
- overwriting one of the distinct accessibilities in accord with the assigned priority wherein the inheritance from the at least one superclass can be overwritten to avoid accessibility conflicts between the superclass and the class.
Dependencies are inferred from the claim text.