System for modifying object oriented code
First Claim
1. A method implemented on one or more machines for modifying object oriented code, comprising the steps of:
- reading a rule defining a change to object code, said rule is in a machine readable format, said object code including a definition of an object oriented class;
searching said object code for an allocation of a first object based on a first class, said object code is in a machine readable format;
finding said allocation of said first object based on said first class;
modifying said object code based on said rule, said step of modifying includes changing said allocation of said first object based on said first class to an allocation of said first object based on a second class; and
storing said modified object code in a machine readable format, said steps of reading, searching, finding, modifying and storing are performed by said one or more machines.
3 Assignments
0 Petitions
Accused Products
Abstract
The system receives three sets of inputs: program class definitions, a set of rules, and additional class definitions to be merged with the program class definitions. There are three types of rules: the first rule is used to substitute the allocation of an object of a new class for the allocation of the object based on an original class; the second rule is used to change code that allocates an object of an original class to code that calls a static method that allocates the object of the original class; and the third rule is used to a replace a new static field for an original static field. The system separately reads each of the original class definitions into a class data structure and performs the modifications to the class data structure according to the set of rules. The resulting class data structure is written to an output stream.
-
Citations
65 Claims
-
1. A method implemented on one or more machines for modifying object oriented code, comprising the steps of:
-
reading a rule defining a change to object code, said rule is in a machine readable format, said object code including a definition of an object oriented class;
searching said object code for an allocation of a first object based on a first class, said object code is in a machine readable format;
finding said allocation of said first object based on said first class;
modifying said object code based on said rule, said step of modifying includes changing said allocation of said first object based on said first class to an allocation of said first object based on a second class; and
storing said modified object code in a machine readable format, said steps of reading, searching, finding, modifying and storing are performed by said one or more machines. - View Dependent Claims (2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)
said second class extends said first class.
-
-
3. A method according to claim 2, further including the step of:
merging said second class with said first class.
-
4. A method according to claim 2, wherein said step of modifying includes the steps of:
-
changing a first reference of a creation instruction to refer to said second class; and
changing a first instruction which invokes a constructor for said first class to a second instruction which invokes a constructor for said second class.
-
-
5. A method according to claim 4, further including the step of:
reading said object code into a data structure, said data structure includes a table of constant information, said step of changing said first reference changes an index into said table of constant information.
-
7. A method according to claim 1, wherein:
-
said object oriented class has a superclass;
said object code including an identification of said superclass; and
said step of modifying includes changing said identification of said superclass from an original class to a new class, said new class extends said original class.
-
-
8. A method according to claim 1, wherein said step of modifying further includes:
changing third code that allocates a third object of a third class to fourth code that invokes a static method that allocates said third object of said third class.
-
9. A method according to claim 8, wherein:
said third class is a final class.
-
10. A method according to claim 8, wherein said step of modifying includes the steps of
looking for a creation instruction which includes a first reference to said third class; - and
changing said creation instruction to a nop.
- and
-
11. A method according to claim 8, further including the step of:
-
reading said object code into a data structure, said data structure includes a table of constant information;
said step of modifying further includes the steps of;
searching said data structure for a reference to said third class, adding to said data structure a reference to a fourth class, searching said data structure for a first instruction that invokes a constructor of said third class, adding to said table a reference to said static method, and changing said first instruction to a second instruction, said second instruction invokes said static method.
-
-
12. A method according to claim 1, wherein said step of modifying further includes:
changing a reference to a first static field to a reference to a second static field.
-
13. A method according to claim 12, further including the step of:
reading said object code into a data structure, said data structure includes a table of constant information.
-
14. A method according to claim 13, wherein said step of changing a reference to a first static field includes the steps of:
-
searching said table for a first reference to said first static field;
adding to said table a second reference to said second static field; and
changing a third reference to a fourth reference, said third reference points to said first reference and said fourth reference points to said second reference.
-
-
15. A method according to claim 1, further including the step of:
reading said object code into a data structure, said step of modifying includes modifying said data structure.
-
16. A method according to claim 1, wherein:
said object code is Java object code.
-
17. A method according to claim 1, wherein:
-
said object code includes definitions of a plurality of object oriented classes; and
said steps of modifying and storing are performed for each of said object oriented classes.
-
-
18. A method according to claim 1, wherein:
-
said object oriented class has a superclass;
said Java object code including an identification of said superclass;
said step of modifying includes changing said identification of said superclass from an original class to a new class, said new class extends said original class;
said step of modifying further includes changing third code that allocates a third object of a third class to fourth code that invokes a static method that allocates said third object of said third class, said third class is a final class; and
said step of modifying further includes changing a reference to a first static field to a reference to a second static field.
-
-
19. A method according to claim 1, wherein:
said step of modifying includes changing a bytecode.
-
20. A method according to claim 1, wherein:
said step of modifying includes changing a reference to a constant pool, said reference is part of a set of bytecodes.
-
21. A method according to claim 1, wherein:
-
said step of searching includes searching for a new instruction; and
said step of modifying includes changing an index for said new instruction.
-
-
22. A method according to claim 21, wherein:
-
said step of searching includes searching for an invokespecial instruction; and
said step of modifying includes changing an index for said invokespecial instruction.
-
-
23. A method according to claim 1, wherein:
-
said second class extends said first class;
said step of searching includes searching for a new instruction in bytecode, said new instruction has an index into a constant pool, said index references said first class; and
said step of modifying includes changing said index to reference said second class.
-
-
24. A method according to claim 1, wherein:
said one or more machines include one or more computers programmed to perform the steps of reading, searching, finding, modifying and storing.
-
6. A method according to claim 6, wherein said step of modifying further includes the step of:
-
adding to said data structure a reference to said second class;
said step of changing said first reference changes an index which points to said reference to said first class to an index which points to said reference to said second class;
said step of changing said first instruction includes the step of adding a reference to said constructor for said second class, said second instruction including an index pointing to said reference to said constructor for said second class.
-
-
25. One or more processor readable storage devices having processor readable code embodied on said processor readable storage devices, said processor readable code for programming one or more processors to perform a method comprising the steps of:
-
reading a rule defining a change to object code, said object code defining an object oriented class;
searching said object code for an allocation of a first object based on a first class;
finding said allocation of said first object based on said first class;
modifying said object code based on said rule, said step of modifying includes changing said allocation of said first object based on said first class to an allocation of at least one object based on a second class. - View Dependent Claims (26, 27, 28, 29, 30, 31, 32, 33, 34)
changing a first reference for a creation instruction to refer to said second class; and
changing a first instruction which invokes a constructor for said first class to a second instruction which invokes a constructor for said second class.
-
-
27. One or more processor readable storage devices according to claim 25, wherein:
-
said object oriented class has a superclass;
said object code including an identification of said superclass; and
said step of modifying includes changing said identification of said superclass from an original class to a new class, said new class extends said original class.
-
-
28. One or more processor readable storage devices according to claim 25, wherein said step of modifying includes:
changing third code that allocates a third object of a third class to fourth code that calls a method that allocates at least one object of said third class, said third class is a final class.
-
29. One or more processor readable storage devices according to claim 25, wherein said step of modifying includes:
changing a reference to a first static field to a reference to a second static field.
-
30. One or more processor readable storage devices according to claim 25 wherein:
-
said object code is Java object code; and
said second class extends said first class.
-
-
31. One or more processor readable storage devices according to claim 25, wherein:
-
said second class extends said first class;
said step of searching includes searching for a new instruction in bytecode, said new instruction has an index into a constant pool, said index references said first class; and
said step of modifying includes changing said index to reference said second class.
-
-
32. One or more processor readable storage devices according to claim 25, wherein:
-
said step of searching includes searching for a new instruction; and
said step of modifying includes changing an index for said new instruction.
-
-
33. One or more processor readable storage devices according to claim 25, wherein:
-
said step of searching includes searching for an invokespecial instruction; and
said step of modifying includes changing an index for said invokespecial instruction.
-
-
34. One or more processor readable storage devices according to claim 33, wherein:
-
said step of searching includes searching for a new instruction; and
said step of modifying includes changing an index for said new instruction.
-
-
35. An apparatus capable of modifying Java code, comprising:
-
one or more input devices;
one or more output devices;
one or more processors in communication with said one or more input devices and said one or more output devices; and
one or more storage devices in communication with said one or more processors, said one or more storage devices store program code, said program code programs said one or more processors to perform the steps of;
reading a rule defining a change to Java object code, said Java object code defining an object oriented class;
searching said object code for an allocation of a first object based on a first class;
finding said allocation of said first object based on said first class;
modifying said Java object code based on said rule, said step of modifying includes changing said allocation of said first object based on said first class to an allocation of said first object based on a second class, said second class extends said first class. - View Dependent Claims (36, 37, 38, 39, 40)
said object oriented class has a superclass;
said Java object code including an identification of said superclass; and
said step of modifying includes changing said identification of said superclass from an original class to a new class, said new class extends said original class.
-
-
37. An apparatus according to claim 35, wherein said step of modifying includes:
changing third code that allocates a third object of a third class to fourth code that calls a static method that allocates said third object of said third class, said third class is a final class.
-
38. An apparatus according to claim 35, wherein said step of modifying includes:
changing a reference to a first static field to a reference to a second static field.
-
39. An apparatus according to claim 35, wherein:
-
said second class extends said first class;
said step of searching includes searching for a new instruction in bytecode, said new instruction has an index into a constant pool, said index references said first class; and
said step of modifying includes changing said index to reference said second class.
-
-
40. An apparatus according to claim 35, wherein:
-
said step of searching includes searching for an invokespecial instruction; and
said step of modifying includes changing an index for said invokespecial instruction.
-
-
41. A method implemented on one or more machines for modifying object oriented code, comprising the steps of:
-
reading a rule defining a change to object code, said object code including a definition of an object oriented class, said rule is in a machine readable format;
modifying said object code based on said rule, said step of modifying includes changing first code that allocates a first object of a first class to second code that invokes a method that allocates said first object of said first class; and
storing said modified object code in machine readable format, said steps of reading modifying and storing are performed by said one or more machines. - View Dependent Claims (42, 43, 44, 45, 46, 47, 48, 49, 50, 51)
looking for a creation instruction which includes a first reference to said first class; and
changing said creation instruction to a nop.
-
-
43. A method according to claim 41, wherein:
said first class is a final class.
-
44. A method according to claim 43, wherein:
said method is a static method.
-
45. A method according to claim 44, wherein:
-
said method further includes the steps of reading said object code into a data structure, said data structure includes a table of constant information;
said step of modifying further includes the steps of;
searching said data structure for a reference to said first class, adding to said data structure a reference to said second class if said step of searching finds said reference to said first class, searching said data structure for a first instruction that invokes a constructor of said first class, adding to said table a reference to said static method, and changing said first instruction to a second instruction, said second instruction invokes said static method.
-
-
46. A method according to claim 41, wherein:
said step of modifying includes removing a new instruction and an invokespecial instruction, and adding an invokestatic instruction.
-
47. A method according to claim 41, wherein:
said step of modifying includes replacing an invokespecial instruction with an invokestatic instruction.
-
48. A method according to claim 41, wherein:
said step of modifying includes changing bytecode.
-
49. A method according to claim 41, wherein:
-
said step of modifying includes changing a first instruction with a first index to a second instruction with a second index;
said second index refers to said method;
said method is a static method; and
said first class is a final class.
-
-
50. A method according to claim 41, further including the steps of:
-
searching said object code for said first code that allocates said first object at said first class; and
finding said first code.
-
-
51. A method according to claim 41, wherein:
said one or more machines include one or more computers programmed to perform said steps of reading, modifying and storing.
-
52. One or more processor readable storage devices having processor readable code embodied on said processor readable storage devices, said processor readable code for programming one or more processors to perform a method comprising the steps of:
-
reading a rule defining a change to object code, said object code including a definition of an object oriented class; and
modifying said object code based on said rule, said step of modifying includes changing first code that allocates a first object of a first class to second code that calls a static method that allocates said first object of said first class. - View Dependent Claims (53, 54, 55, 56, 57, 58)
looking for a creation instruction which includes a first reference to said first class; and
changing said creation instruction to a nop.
-
-
54. One or more processor readable storage devices according to claim 52, wherein:
-
said first class is a final class; and
said object code is Java object code.
-
-
55. One or more processor readable storage devices according to claim 54, wherein:
-
said method further includes the step of reading said object code into a data structure, said data structure includes a table of constant information;
said step of modifying further includes the steps of;
searching said data structure for a reference to said first class, adding to said data structure a reference to said second class if said step of searching finds said reference to said first class, searching said data structure for a first instruction that invokes a constructor of said first class, adding to said table a reference to said static method, and changing said first instruction to a second instruction, said second instruction invokes said static method.
-
-
56. One or more processor readable storage devices according to claim 52, wherein:
said step of modifying includes replacing an invoke special instruction with an invokestatic instruction.
-
57. One or more processor readable storage devices according to claim 52, wherein:
-
said step of modifying includes changing a first instruction with a first index to a second instruction with a second index;
said second index refers to said method;
said method is a static method; and
said first class is a final class.
-
-
58. One or more processor readable storage devices according to claim 52, wherein said method further comprises the steps of:
-
searching said object code for said first code that allocates said first object of said first class; and
finding said first code.
-
-
59. An apparatus capable of modifying object oriented code, comprising:
-
one or more input devices;
one or more output devices;
one or more processors in communication with said one or more input devices and said one or more output devices; and
one or more storage devices in communication with said one or more processors, said one or more storage devices adapted to store program code, said program code programs said one or more processor to perform the steps of;
reading a rule defining a change to Java object code, said Java object code defining an object oriented class, and modifying said Java object code based on said rule, said step of modifying includes changing first code that allocates a first object of a first class to second code that invokes a static method that allocates said first object of said first class. - View Dependent Claims (60, 61, 62, 63, 64)
said first class is a final class.
-
-
61. An apparatus according to claim 59, wherein:
said step of modifying includes replacing an invoke special instruction with an invoke static instruction.
-
62. An apparatus according to claim 59, wherein:
-
said step of modifying includes changing a first instruction with a first index to a second instruction with a second index;
said second index refers to said static method; and
said first class is a final class.
-
-
63. An apparatus according to claim 59, wherein:
-
said method further includes the steps of reading said object code into a data structure, said data structure includes a table of constant information;
said step of modifying includes the steps of;
searching said data structure for a reference to said first class, adding to said data structure a reference to said second class if said step of searching finds said reference to said first class, searching said data structure for a first instruction that invokes a constructor of said first class, adding to said table a reference to said static method, and changing said first instruction to a second instruction, said second instruction invokes said static method.
-
-
64. An apparatus according to claim 59, wherein said method further comprises the steps of:
-
searching said object code for said first code that allocates said first object of said first class; and
finding said first code.
-
-
65. An apparatus capable of modifying object oriented code, comprising:
-
one or more input devices;
one or more output devices;
a processor in communication with said one or more input devices and said one or more output devices; and
a storage device in communication with said processor, said storage device adapted to store program code, said program code programs said processor to perform the steps of;
reading a rule defining a change to Java object code, said Java object code defining an object oriented class, and modifying said Java object code based on said rule, said step of modifying includes changing a reference to a first static field to a reference to a second static field.
-
Specification