Allowing non-generified methods to override generified methods
AssigneeOracle America, Inc.
InventorsPeter von der Ahe, Gilad Bracha
Life of this patent
Estimating the term…
Abstract
In accordance with one embodiment of the present invention, there is provided a technique for allowing a first method to override a second method as long as specified criteria are satisfied, even if the types of the parameters of the first method differ from the types of the parameters of the second method, and even if the return type of the first method differs from the return type of the second method. As a result of the technique, older methods, which do not have generic return types and/or generically typed parameters, can continue to override methods that did not used to have generic return types and/or generically typed parameters, but now do.
Claims15
A machine-readable medium comprising one or more sequence of instructions stored therein, which instructions, when executed by one or more processors, cause the one or more processors to carry out the steps of:
- determining whether a first method in a first class has a same name as a second method in a second class that is a subclass of the first class;
- in response to a determination that the first method has the same name as the second method, determining, by a compiler, whether each criterion of one or more criteria are satisfied, wherein the one or more criteria include a criterion that an erasure of a signature of the first method is the same as a signature of the second method;
- and
- allowing, by the compiler, the second method to directly override the first method only when all of the one or more criteria are satisfied,
- wherein the first method is a generified method while the second method is a non-generified method,
- wherein the generified method comprises a parameter is a generic type, and
- wherein the non-generified method does not comprise any parameter being the generic type.
A machine-readable medium comprising one or more sequences of instructions stored therein, which instructions, when executed by one or more processors, cause the one or more processors to carry out the steps of:
- determining whether a first method in a first class has a same name as a second method in a second class that is a subclass of the first class;
- in response to a determination that the first method has the same name as the second method, determining, by a compiler, whether each criterion of one or more criteria are satisfied, wherein the one or more criteria include a criterion that an erasure of a signature of the first method is the same as a signature of the second method;
- and
- allowing, by the compiler, the second method to directly override the first method only when all of the one or more criteria are satisfied,
- wherein the first method is a generified method while the second method is a non-generified method,
- wherein a return type of the generified method is the generic type, and
- wherein a return type of the non-generified method is not the generic type.
A computer system comprising:
- a processor;
- a memory;
- instructions, stored in the memory, that when executed by the processor, perform a method, the method comprising:
- determining whether a first method in a first class has a same name as a second method in a second class that is a subclass of the first class;
- determining, by a compiler, in response to a determination that the first method has the same name as the second method, whether each criterion of one or more criteria are satisfied, wherein the one or more criteria include a criterion that an erasure of a signature of the first method is the same as a signature of the second method;
- and
- allowing, by the compiler, the second method to directly override the first method only when all of the one or more criteria are satisfied,
- wherein the first method is a generified method while the second method is a non-generified method,
- wherein the generified method comprises a parameter is a generic type, and
- wherein the non-generified method does not comprise any parameter being the generic type.
Dependencies are inferred from the claim text.