IP Library Granted Patent US 8,352,925
Granted Patent B2
US 8,352,925 · App. 11/654,234 · Granted Jan 8, 2013

Mechanism for enabling a set of code intended for a first platform to be executed on a second platform

Assignee: Oracle America, Inc.
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 8,352,925
App. No.
11/654,234
Granted
Jan 8, 2013
Kind
B2
Abstract

A mechanism is disclosed for enabling a set of code intended to be executed on a first platform (intended platform) to be executed on another platform (target platform). In one implementation, this mechanism takes a significantly different approach than that taken by current techniques. Rather than duplicating, augmenting, or changing a platform to accommodate the set of code, this mechanism alters the set of code to accommodate the platform. By altering the set of code, the mechanism causes the set of code to compensate for the difference(s) between the intended platform and the target platform. By compensating for the difference(s) in the two platforms, the set of code, when executed on the target platform, is able to produce the same result or results as it would have produced had it been executed on the intended platform. Thus, the set of code is able to execute properly on the target platform.

Claims (86)

1. A machine implemented method for enabling a set of code intended to be executed on a first platform to be executed on a second and different platform, comprising:

determining that a first portion of the set of code comprises an invocation of a first functionality that is provided by both the first and the second platforms,

wherein invocation of the first functionality on the first platform results in a first behavior, and

wherein invocation of the first functionality on the second platform results in a second behavior;

in response to a determination that the first portion of the set of code comprises the invocation of the first functionality, altering the first portion of the set of code by:

identifying a first helper functionality which, when invoked on the second platform, is configured to result in the first behavior,

altering the invocation of the first functionality with an invocation of the first helper functionality to obtain a first altered portion of the set of code by:

inserting the invocation of the first helper functionality into the first portion of the set of code at a position that is after the invocation of the first functionality,

wherein the first functionality is configured to produce a result, and

wherein the first helper functionality, when invoked, processes the result produced by the first functionality,

wherein the first altered portion of the set of code, when executed on the second platform, produces the same result as the first portion of the set of code when executed unaltered on the first platform;

determining that a second portion of the set of code comprises a reference to a class, wherein the class is replaced with a substitute class; and

in response to a determination that the second portion of the set of code comprises the reference, altering the second portion of the set of code to replace the reference to the class with a reference to the substitute class.

2. The method of claim 1 , further comprising:

determining that the second portion of the set of code comprises a reference to a first class,

wherein the first class is supported by the second platform, and

wherein the first class is not supported by the first platform; and

in response to the determination that the second portion of the set of code comprises the reference, altering the second portion of the set of code by replacing the reference to the first class with a reference to a second class,

wherein the second class is known to not be supported by the second platform.

3. The method of claim 1 , further comprising:

determining that the second portion of the set of code comprises an invocation of a second functionality,

wherein the second functionality is available on the second platform, and

wherein the second functionality is not available on the first platform; and

in response to the determination that the second portion of the set of code comprises the invocation, altering the second portion of the set of code by replacing the invocation of the second functionality with an invocation of a third functionality that is known to not be available to the second platform.

4. The method of claim 1 , further comprising:

determining that the second portion of the set of code comprises a reference to a particular field, wherein the particular field is accessible on the second platform, and wherein the particular field is inaccessible on the first platform; and

in response to the determination that the second portion of the set of code comprises the reference to the particular field, altering the second portion of the set of code by replacing the reference to the particular field with a reference to a field that is known to be inaccessible on the second platform.

5. The method of claim 1 , further comprising:

determining that the second portion of the set of code comprises a reference to a constructor, wherein the constructor is accessible on the second platform, and wherein the constructor is inaccessible on the first platform; and

in response to the determination that the second portion of the set of code comprises the reference to the constructor, altering the second portion of the set of code by inserting, at a position that precedes the invocation of the constructor, an invocation of a second helper functionality which, when executed, causes an error to be raised.

6. The method of claim 1 , further comprising:

determining that the set of code comprises a subclass of a superclass having a particular method that is specified in the first platform to be an abstract method and not specified in the second platform to be an abstract method; and

in response to the determination that the set of code comprises the subclass of the superclass:

replacing, in the set of code, each reference to the particular method of the superclass with a reference to a helper method, wherein the helper method, when executed, causes an error to be raised.

7. The method of claim 6 , wherein the following operations are further performed in response to the determination that the set of code comprises a subclass of a superclass having a particular method that is specified in the first platform to be an abstract method but not specified in the second platform to be an abstract method:

determining whether the subclass provides an implementation for, and hence, overrides the particular method; and

in response to the determination that the subclass does not override the particular method for, and hence, does not override the particular method, inserting into the subclass an implementation for the particular method, wherein the implementation, when invoked, invokes the helper method, thereby causing the error to be raised.

8. The method of claim 1 , further comprising:

determining that the second portion of the set of code attempts to override a first method that is specified in the first platform to be final, and is not specified in the second platform to be final; and

in response to the determination that the second portion of the set of code attempts to override the first method, altering the second portion of the set of code by inserting therein one or more instructions to override a second method that is specified in the second platform to be final.

9. The method of claim 1 , further comprising:

determining that the second portion of the set of code comprises an invocation of a second functionality that is accessible to a particular class in the second platform, and is not accessible to the particular class in the first platform; and

in response to the determination that the second portion of the set of code comprises the invocation of the second functionality, altering the second portion of the set of code by inserting therein an invocation of a helper functionality which, when executed, causes an error to be raised.

10. A non-transitory machine readable medium comprising instructions which, when executed by one or more processors, cause the one or more processors to implement a method for enabling a set of code intended to be executed on a first platform to be executed on a second and different platform, the method comprising:

determining that a first portion of the set of code comprises an invocation of a first functionality that is provided by both the first and the second platforms,

wherein invocation of the first functionality on the first platform results in a first behavior, and

wherein invocation of the first functionality on the second platform results in a second behavior;

in response to a determination that the first portion of the set of code comprises an invocation of the first functionality, altering the first portion of the set of code by:

identifying a first helper functionality which, when invoked on the second platform, is configured to result in the first behavior,

altering the invocation of the first functionality with an invocation of the first helper functionality to obtain a first altered portion of the set of code by:

inserting the invocation of the first helper functionality into the first portion of the set of code at a position that is after the invocation of the first functionality,

wherein the first functionality is configured to produce a result, and

wherein the first helper functionality, when invoked, processes the result produced by the first functionality,

wherein the first altered portion of the set of code, when executed on the second platform, produces the same result as the first portion of the set of code when executed unaltered on the first platform;

determining that a second portion of the set of code comprises a reference to a class, wherein the class is replaced with a substitute class; and

in response to a determination that the second portion of the set of code comprises the reference, altering the second portion of the set of code to replace the reference to the class with a reference to a substitute class.

11. The non-transitory machine readable medium of claim 10 , further comprising:

determining that the second portion of the set of code comprises a reference to a first class,

wherein the first class is supported by the second platform, and

wherein the first class is not supported by the first platform; and

in response to the determination that the second portion of the set of code comprises the reference, altering the second portion of the set of code by replacing the reference to the first class with a reference to a second class,

wherein the second class is known to not be supported by the second platform.

12. The non-transitory machine readable medium of claim 10 , further comprising:

determining that second portion of the set of code comprises an invocation of a second functionality,

wherein the second functionality is available on the second platform, and

wherein the second functionality is not available on the first platform; and

in response to the determination that the second portion of the set of code comprises the invocation, altering the second portion of the set of code by replacing the invocation of the second functionality with an invocation of a third functionality that is known to not be available to the second platform.

13. The non-transitory machine readable medium of claim 10 , further comprising:

determining that the second portion of the set of code comprises a reference to a particular field, wherein the particular field is accessible on the second platform, and wherein the particular field is inaccessible on the first platform; and

in response to the determination that the second portion of the set of code comprises the reference to the particular field, altering the second portion of the set of code by replacing the reference to the particular field with a reference to a field that is known to be inaccessible on the second platform.

14. The non-transitory machine readable medium of claim 10 , further comprising:

determining that the second portion of the set of code comprises a reference to a constructor, wherein the constructor is accessible on the second platform, and wherein the constructor is inaccessible on the first platform; and

in response to the determination that the second portion of the set of code comprises the reference to the constructor, altering the second portion of the set of code by inserting, at a position that precedes the invocation of the constructor, an invocation of a second helper functionality which, when executed, causes an error to be raised.

15. The non-transitory machine readable medium of claim 10 , further comprising:

determining that the set of code comprises a subclass of a superclass having a particular method that is specified in the first platform to be an abstract method and not specified in the second platform to be an abstract method; and

in response to the determination that the set of code comprises the subclass of the superclass:

replacing, in the set of code, each reference to the particular method of the superclass with a reference to a helper method, wherein the helper method, when executed, causes an error to be raised.

16. The non-transitory machine readable medium of claim 15 , wherein the following operations are further performed in response to a determination that the set of code comprises a subclass of a superclass having a particular method that is specified in the first platform to be an abstract method but not specified in the second platform to be an abstract method:

determining whether the subclass provides an implementation for, and hence, overrides the particular method; and

in response to the determination that the subclass does not override the particular method for, and hence, does not override the particular method, inserting into the subclass an implementation for the particular method, wherein the implementation, when invoked, invokes the helper method, thereby causing the error to be raised.

17. The non-transitory machine readable medium of claim 10 , further comprising:

determining that the second portion of the set of code attempts to override a first method that is specified in the first platform to be final, and is not specified in the second platform to be final; and

in response to the determination that the second portion of the set of code attempts to override the first method, altering the second portion of the set of code by inserting therein one or more instructions to override a second method that is specified in the second platform to be final.

18. The non-transitory machine readable medium of claim 10 , further comprising:

determining that the second portion of the set of code comprises an invocation of a second functionality that is accessible to a particular class in the second platform, and is not accessible to the particular class in the first platform; and

in response to a determination that the second portion of the set of code comprises the invocation of the second functionality, altering the second portion of the set of code by inserting therein an invocation of a helper functionality which, when executed, causes an error to be raised.

Assignments (2)
MERGER AND CHANGE OF NAME Recorded Dec 16, 2015
From: ORACLE USA, INC.; SUN MICROSYSTEMS, INC.; ORACLE AMERICA, INC.
To: ORACLE AMERICA, INC.
Reel/Frame 037311/0195 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 16, 2007
From: RUSSELL, KENNETH B.; WYANT, IRA A.
To: SUN MICROSYSTEMS, INC.
Reel/Frame 018807/0548 →
Continuity (1)
Related Publication 20080172658A1 · Jul 17, 2008