Method for identifying calls in java packages whose targets are guaranteed to belong to the same package
First Claim
1. A method for identifying calls in a Java sealed package whose targets are guaranteed to belong to said sealed package, comprising the steps of:
- (a) verifying that a Java package is sealed and signed;
(b) obtaining a class hierarchy graph for classes and interfaces of said package;
(c) obtaining access permissions of respective components in said package; and
(d) using the class hierarchy graph and access permissions in combination with a knowledge that said package is sealed and signed to determine whether all the targets of the calls are guaranteed to belong to said package.
1 Assignment
0 Petitions
Accused Products
Abstract
A method and system for identifying calls in a Java package whose targets are guaranteed to belong to the package. According to the method an inheritance graph and access permissions of respective components in the package are determined, both of which are used in combination with the knowledge that the package is seared and signed to determine whether all the targets of a call are guaranteed to belong to the package. The identification of calls according to the invention can be performed at the time the package is sealed and signed or as a separate phase thereafter and allows for better compiler optimization.
-
Citations
30 Claims
-
1. A method for identifying calls in a Java sealed package whose targets are guaranteed to belong to said sealed package, comprising the steps of:
-
(a) verifying that a Java package is sealed and signed;
(b) obtaining a class hierarchy graph for classes and interfaces of said package;
(c) obtaining access permissions of respective components in said package; and
(d) using the class hierarchy graph and access permissions in combination with a knowledge that said package is sealed and signed to determine whether all the targets of the calls are guaranteed to belong to said package. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
i) determining whether a called method can be directly overridden or implemented by a method from outside said package; and
ii) if so, identifying the call as one whose targets are not all guaranteed to belong to a common Java package.
-
-
3. The method according to claim 2, further including the steps of:
-
iii) determining whether a called method can be overridden or implemented directly or indirectly within said package and thereby be indirectly overridden or implemented by a method outside said package; and
iv) if so, identifying the call as one whose targets are not all guaranteed to belong to a common Java package.
-
-
4. The method according to claim 3, wherein step (i) comprises the steps of:
-
(a) traversing the class hierarchy graph starting from the class or interface of said called method;
(b) searching for a public non-final subclass that declares the called method as non-final public or protected or inherits such a declaration from a parent of said class or interface; and
(c) if such a subclass is found then identifying the call as one whose targets are not all guaranteed to belong to a common Java package.
-
-
5. The method according to claim 4, further including the steps of:
-
(a) determining whether said class can be subclassed by, and pass said called method to, classes of another inheritance tree via one or more classes from outside said package; and
, if so, then(b) applying the called method according to claim 4 to the classes of said other inheritance tree as well when considering methods of said class.
-
-
6. The method according to claim 5, including:
-
(d) checking whether a method of an interface can be implemented by an external class method of an “
external”
class from outside said package via an “
internal”
class within said package that implements the interface and inherits the implementation of the external class method from the external class;
(e) checking whether such an internal class can be instantiated; and
(f) if such a class or subclass is found then identifying the call as one whose targets are not all guaranteed to belong to said package.
-
-
7. The method according to claim 6, further including:
(g) if the call has not been identified as one whose targets are not all guaranteed to belong to a common Java package, then identifying the call as one whose targets are all guaranteed to belong to said Java sealed package.
-
8. The method according to claim 7, further including:
(h) determining a set of possible targets for calls whose targets are all guaranteed to belong to said Java sealed package.
-
9. The method according to claim 8, further including:
(i) performing inter-procedural program analysis and/or optimization of a Java sealed package using information on calls whose targets are all guaranteed to belong to said sealed package.
-
10. The method according to claim 7, including the step of embedding inside the Java sealed package an indication of calls whose targets are all guaranteed to belong to said Java sealed package as well as said targets.
-
11. The method according to claim 1, being performed at substantially the same time as said package is sealed and signed.
-
12. The method according to claim 1, being performed after the Java sealed package has been sealed and signed.
-
13. The method according to claim 12, being performed prior to program analysis and/or optimization.
-
14. The method according to claim 12, being performed substantially together with program analysis and/or optimization.
-
15. A computer system for identifying calls in a Java sealed package whose targets are guaranteed to belong to said sealed package, said computer system comprising:
-
a verification unit for verifying whether a Java package is already sealed and signed or is to be sealed and signed; and
a target processor coupled to the verification unit, being responsive to a previously derived inheritance graph and previously derived access permissions in combination with a knowledge that said package is sealed and signed for determining whether all the targets of calls are guaranteed to belong to said sealed package. - View Dependent Claims (16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26)
a Class Hierarchy Graph (CHG) unit for building an inheritance graph of classes and interfaces of said package; and
an access permission unit for determining access permissions and related modifiers of respective components in said package;
the target processor being coupled to the CHG unit and the access permission unit for receiving therefrom the previously derived inheritance graph and previously derived access permissions.
-
-
17. The system according to claim 15, wherein the target processor includes:
a direct overriding unit for determining whether a called method can be directly overridden or implemented by a method from outside said package, and if so identifying the call as one whose targets are not all guaranteed to belong to said package.
-
18. The system according to claim 15, wherein the target processor includes:
an indirect overriding unit for determining whether a called method belonging to a class and an interface can be overridden or implemented directly or indirectly by a method within said package and thereby be indirectly overridden or implemented by a method outside said package, and if so identifying the call as one whose targets are not all guaranteed to belong to said package.
-
19. The system according to claim 18, wherein the indirect overriding unit includes:
a subclass examination unit for traversing the previously derived inheritance graph starting from the class or interface of the called method and determining whether there exists a public non-final subclass that declares the called method as non-final public or protected or inherits such a declaration from a parent of said class or interface, and if so identifying the call as one whose targets are not all guaranteed to belong to said package.
-
20. The system according to claim 18, wherein the indirect overriding unit includes:
a multiple tree analysis unit for determining whether the class of the called method can be subclassed by, and pass the called method to, classes of another inheritance tree via one or more classes from outside the sealed package, and if so, using the subclass examination unit in respect of each such inheritance tree.
-
21. The system according to claim 18, wherein the indirect overriding unit includes:
a superclass examination unit for checking whether the interface of the called method can be implemented by a method of an “
external”
class from outside said package via an “
internal”
class within said package that implements the interface and inherits the implementation of the called method from the external class, such that the internal class can be instantiated, and if so identifying the call as one whose targets are not all guaranteed to belong to said package.
-
22. The system according to claim 18, wherein the target processor further includes:
a possible targets unit for determining a set of possible targets for calls whose targets are all guaranteed to belong to said package.
-
23. The system according to claim 15, further including a program analysis unit coupled to the target processor for performing inter-procedural program analysis of a Java package using information about calls whose targets are all guaranteed to belong to said package.
-
24. The system according to claim 15, further including an optimization unit coupled to the target processor for performing inter-procedural optimization of a Java package using information about calls whose targets are all guaranteed to belong to said package.
-
25. The system according to claim 24, further including a storage medium coupled to the optimization unit for storing optimized program data generated by the optimization unit.
-
26. The system according to claim 15, further including a storage unit coupled to the target processor for storing, inside or outside the package, information about calls whose targets are all guaranteed to belong to said package.
-
27. A program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps for identifying calls in a Java sealed package whose targets are guaranteed to belong to said package, comprising the steps of:
-
(a) verifying that a Java package is sealed and signed, (b) obtaining a class hierarchy graph for classes and interfaces of said package, (c) obtaining access permissions of respective components in said package, and (d) using the class hierarchy graph and access permissions in combination with a knowledge that said package is sealed and signed to determine whether all the targets of the calls are guaranteed to belong to said package. - View Dependent Claims (28)
(e) performing inter-procedural program analysis and/or optimization of a Java sealed package using information on calls whose targets are all guaranteed to belong to said package.
-
-
29. A computer program product comprising a computer useable medium having computer readable program code embodied therein for identifying calls in a Java sealed package whose targets are guaranteed to belong to said package, the computer program product comprising:
-
computer readable program code for causing the computer to verify that a Java package is sealed and signed;
computer readable program code for causing the computer to obtain a class hierarchy graph for classes and interfaces of said package;
computer readable program code for causing the computer to obtain access permissions of respective components in said package; and
computer readable program code for causing the computer to use the class hierarchy graph and access permissions in combination with a knowledge that said package is sealed and signed to determine whether all the targets of the calls are guaranteed to belong to said package. - View Dependent Claims (30)
computer readable program code for causing the computer to perform inter-procedural program analysis and/or optimization of a Java sealed package using information on calls whose targets are all guaranteed to belong to said package.
-
Specification