Method and system for detecting deprecated elements during runtime
Claim Score by NHIP
Abstract
A method for controlling access to deprecated methods of an implementation is provided. The method includes receiving a request to access a method that has been marked as deprecated and building a call stack for the request. Also included is inspecting the call stack to determine if the request is from an application outside of the implementation. The method further includes acting on the request in accordance with a control policy defined by a pluggable policy.

Term
Term ended
Projected expiry passed 17 February 2025, 1.6 years ago.
- Priority
- Filed
- Published
- Projected expiry
- Today
20 claims: 5 independent, 15 dependent
- 1Broadest claimClaim Score 90, very broad(NHIP)A method for controlling access to deprecated methods of an implementation, comprising:receiving a request to access a method that has been marked as deprecated;building a call stack for the request;inspecting the call stack to determine if the request is from an application outside of the implementation;and denying access to the method if the request is determined to be from the application outside of the implementation upon the inspection.
- 5A method for controlling access to deprecated methods of an implementation, comprising:receiving a request to access a method that has been marked as deprecated;building a call stack for the request;inspecting the call stack to determine if the request is from an application outside of the implementation;and acting on the request in accordance with a control policy defined by a pluggable policy.
- 10A method for allowing access to a deprecated element of a software implementation, the method comprising:invoking a deprecated element of the software implementation by a caller element;invoking an access controller, the access controller including a pluggable access control policy;and determining the accessibility of the deprecated element by the caller element using the pluggable access control policy, the determining including, granting access to the caller element if the caller element satisfies a criteria of the access control policy;and denying access to the caller element if the caller element fails to satisfy the criteria of the access control policy.
- 13A method for determining the accessibility of a caller element to a deprecated method of a software implementation, the method comprising:invoking an access controller, the access controller including a pluggable access control policy configured to deny access to a caller element having a domain different than the domain of the software implementation;and limiting access to the deprecated method using the access control policy.
- 18A system for limiting access to a deprecated method of a software implementation, the system comprising:an access controller code configured to include an access control policy, the access control policy configured to be used to determine an accessibility of a caller element to the deprecated method;and a call stack defining at least the caller element and the deprecated method, the call stack capable of being inspected to determine accessibility to the caller element.
Independent claims5
99 paragraphs in 6 sections, as filed
CROSS REFERENCE TO RELATED APPLICATIONS
[0001] This application claims priority from U.S. Provisional Patent Application No. 60/369,379 filed on Apr. 1, 2002 and entitled “Method and System for Detecting Deprecated Elements During Runtime,” which is incorporated herein by reference in its entirety.
COPYRIGHT AUTHORIZATION
[0002] A portion of the disclosure of this patent document contains material, which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
BACKGROUND OF THE INVENTION
[0003] 1. Field of the Invention
[0004] The present invention relates generally to software processing, and more particularly, to methods and systems for improving the detection of deprecated methods and classes implemented in computer software specifications.
[0005] 2. Description of the Related Art
[0006] As the use of computer software in carrying out daily tasks has been increasing rapidly, so has the constant demand to enhance computer software performance. Consistently, computer programmers and software developers have been creating new software applications or modifying the existing software applications to arrive at a new version, hoping to eliminate all existing deficiencies.
[0007] At times, creating a new version of the software requires adding of new lines of source code, while in others certain portions of the source code are deprecated in the new version of the code. As used herein, “deprecate,” means marking a portion of the source code as being no longer in use. By way of example, deprecating a portion of the source code may involve deprecating certain elements or attributes implemented in the software source code (e.g., a class, a method, a library, an object, an application programming interface (“API”), etc.) In such situation, the deprecated element or attribute is marked as such, by for example, including a comment in the source code, warning the programmers, developers, and users of the deprecated status of the element or attribute.
[0008] Ideally, software source code should not include any deprecated elements or attributes. That is, all elements and attributes marked as deprecated should be deleted. Although preferable, such solution is not feasible due to intricate internal dependencies of the elements and attributes in the software source code. For instance, deleting an element or attribute can render all internal elements and attributes dependent on the deprecated element nonfunctional.
[0009] As an alternative to deleting all deprecated methods, thus far, the deprecated elements and attributes or their use have been detected by compilers during the source code compilation. For instance, certain compilers have been designed to recognize and flag the deprecated elements and attributes thus warning the users of implementing a deprecated element or attribute. However, several problems can be associated with detection of deprecated elements and attributes during compile time.
[0010] First is the “legacy problem” wherein the source code is compiled using an old version of a library (a library in which the method has not been deprecated) and then is run on a newer version of the library (a library in which the method has been flagged deprecated). In such situation, the usage of the deprecated method during run time cannot be detected.
[0011] The second drawback is the “reflection problem” in which a method or a class is invoked during run time. An example of such problem is using of a “reflection method” in which a method or a class is invoked by name, using a string, during the running of a program. Class.forName( ), Class.newInstance( ), and Constructor.newInstance( ) are exemplary methods which create new instances of objects and Method.invoke( ) is an exemplary method which invokes a method in an object dynamically at runtime.
[0012] Third, is the “inheritance problem” in which a child method is deprecated while the method in the parent class is not. In such situation, some programming languages, such as JAVA, allow the method that depends on the object type (e.g., parent or child class) to get invoked at runtime. This is referred to as polymorphism in Object Oriented terminology.
[0013] Next is the problem of “user carelessness” in which users choose to ignore compiler warnings regarding the calling of a deprecated method. Furthermore, except generating a simple warning, the compilers and conventional computer systems are incapable of restricting access to deprecated elements and attributes.
[0014] One solution would be to manually search through the source code to find all references to deprecated elements (e.g., classes and methods) and physically remove them from the source code. However, this manual search is extremely time consuming and cost prohibitive. Besides, merely eighty percent of such deprecated elements and attributes can be located and removed through manual search of the source code. This occurs as some programming languages such as JAVA, classes and methods can be created and invoked at runtime (e.g., getting a method name as a string from the user, calling the method on an object, etc.). Such methods and classes cannot be detected by examining the source code, since the method to be invoked and detected is not known till the program is executed.
[0015] In view of the foregoing, there is a need for a flexible methodology and system for improving the detection and controlling access to deprecated elements and attributes in software specifications.
SUMMARY OF THE INVENTION
[0016] Broadly speaking, the present invention fills these needs by detecting deprecated methods and classes during run time. In one example, upon detecting the access to deprecated methods or classes, an access controller uses a pluggable access control policy to determine whether a caller element should be allowed access to the deprecated method. The caller element is allowed access to the deprecated method if the caller element is determined to be an internal caller or have a domain that is identical to the domain of the deprecated method (i.e., a system caller). However, access to the deprecated method is denied when the caller element is determined to be an external caller or have a domain that differs from the domain of the deprecated method (i.e., non-system caller).
[0017] It should be appreciated that the present invention can be implemented in numerous ways, including as a process, an apparatus, a system, a device, or a method. Several inventive embodiments of the present invention are described below.
[0018] In one embodiment, a method for controlling access to deprecated methods of an implementation is disclosed. The method includes receiving a request to access a method that has been marked as deprecated and building a call stack for the request. The method also includes inspecting the call stack to determine if the request is from an application outside of the implementation. Further included in the method is denying access to the method if the request is determined to be from the application outside of the implementation upon the inspection.
[0019] In another embodiment, a method for controlling access to deprecated methods of an implementation is disclosed. The method includes receiving a request to access a method that has been marked as deprecated and building a call stack for the request. Also included is inspecting the call stack to determine if the request is from an application outside of the implementation. The method further includes acting on the request in accordance with an access control policy that is pluggable.
[0020] In yet another embodiment, a method for allowing access to a deprecated element of a software implementation is disclosed. The method includes invoking a deprecated element of the software implementation by a caller element. The method also includes invoking an access controller. The access controller includes a pluggable access control policy. Further included in the method is determining the accessibility of the deprecated element by the caller element using the pluggable access control policy. The determining includes granting access to the caller element if the caller element satisfies a criteria of the access control policy and denying access to the caller element if the caller element fails to satisfy the criteria of the access control policy.
[0021] In still another embodiment, a method for determining the accessibility of a caller element to a deprecated method of a software implementation is disclosed. The method includes invoking an access controller, which includes a pluggable access control policy configured to deny access to a caller element having a domain different than the domain of the software implementation. The method further includes limiting access to the deprecated method using the access control policy.
[0022] In still another embodiment, a system for limiting access to a deprecated method of a software implementation is disclosed. The system includes an access controller code and a call stack. The access controller code includes an access control policy configured to be used to determine an accessibility of a caller element to the deprecated method. The call stack defines at least the caller element and the deprecated method and is capable of being inspected to determine accessibility to the caller element.
[0023] Other aspects and advantages of the invention will become apparent from the following detailed description, taken in conjunction with the accompanying drawings, illustrating by way of example the principles of the invention.
BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The present invention will be readily understood by the following detailed description in conjunction with the accompanying drawings, and like reference numerals designate like structural elements.
[0025]FIG. 1 is a block diagram of a computer system implementing the methods and systems of the present invention, in accordance with one embodiment of the present invention.
[0026]FIG. 2 is a block diagram illustrating the information and data stored in the main memory, in accordance with another embodiment of the present invention.
[0027]FIG. 3A-<b>1</b> is a block diagram illustrating the implementation of methods and classes of the library of a reference implementation to form a call stack, in accordance with yet another embodiment of the present invention.
[0028]FIG. 3A-<b>2</b> is a block diagram illustrating the implementation of methods and classes of the library of a reference implementation to form a full call stack, in accordance with yet another embodiment of the present invention.
[0029]FIG. 4A-<b>1</b> is a block diagram depicting a call stack wherein a deprecated method is called by a <system method>, in accordance with still another embodiment of the present invention.
[0030]FIG. 4A-<b>2</b> is a block diagram illustrating the calling of a deprecated method by a non-system (i.e., application) method, in accordance with yet another embodiment of the present invention.
[0031]FIG. 4A-<b>3</b> is a block diagram illustrating the calling of a deprecated method by a system method, in accordance with still another embodiment of the present invention.
[0032]FIG. 4A-<b>4</b> is a block diagram illustrating the calling of a deprecated method by a non-system method, in accordance with still another embodiment of the present invention.
[0033]FIG. 4B is a sequence diagram showing the communication sequence in determining accessibility to a deprecated method, in accordance with still another embodiment of the present invention.
[0034]FIG. 4C is a sequence diagram showing the communication sequence in determining accessibility to a deprecated method, in accordance with yet another embodiment of the present invention.
[0035]FIG. 5 is a block diagram of a computer system implementing the methods and systems of the present invention, in accordance with yet another embodiment of the present invention.
[0036]FIG. 6A is a block diagram illustrating the accessibility of a Test and Compatibility Kit (“TCK”) to a deprecated method in a Multimedia Home Platform (“MHP”), in accordance with yet another embodiment of the present invention.
[0037]FIG. 6B is a block diagram showing the pluggability of the access control policy of the embodiments of the present invention, in accordance with still another embodiment of the present invention.
[0038]FIG. 7 is a flow chart diagram illustrating the method operations performed in determining the accessibility of a calling method to a deprecated method, according to still another embodiment of the present invention.
[0039]FIG. 8 is a flow chart diagram of the method operations performed in denying a Test and Compatibility Kit (TCK) accessibility to a deprecated method, according to still another embodiment of the present invention.
[0040]FIG. 9 is a flow chart diagram of the method operations performed in allowing access to a deprecated method using a call stack, according to yet another embodiment of the present invention.
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0041] An invention for restricting use of deprecated elements or attributes in a computer software specification is disclosed. In one embodiment, the present invention detects the existence of deprecated elements and attributes during run time. In one embodiment, the deprecated element is a class or the deprecated attribute is a method.
[0042] In one implementation, an access controller selects one of a plurality of pluggable access control policies to determine accessibility to the deprecated method. By way of example, upon detecting the existence of the deprecated method, a set of criteria of the selected access control policy is implemented to determine whether a caller element should be allowed access to the deprecated method. In one aspect, the caller element is allowed access to the deprecated method if the caller element is determined to be an internal caller or have a domain that is identical to the domain of the deprecated method (i.e., a system caller). However, access to the deprecated method is denied when the caller element is determined to be an external caller or have a domain that differs from the domain of the deprecated method (i.e., non-system caller).
[0043] In one exemplary embodiment, a call stack having a plurality of stack frames is built using the caller element, the intervening methods and classes, and the deprecated method is examined to locate the caller element. For instance, where the call stack includes reflection methods, almost all the stack frames associated with the reflection methods are by passed so as to locate the caller element. Then, a determination is made as to whether the caller element is a system method or an application method.
[0044] As one embodiment of the present invention implements the JAVA programming language, an overview of JAVA is provided below. In operation, a user of a typical JAVA based system interacts with an application layer of a system generally written by a third party developer. The application layer generally provides the user interface for the system. A JAVA module is used to process commands received by the application layer. A JAVA virtual machine is used as an interpreter to provide portability to JAVA applications. In general, developers design JAVA applications as hardware independent software modules, which are executed JAVA virtual machines. The JAVA virtual machine layer is developed to operate in conjunction with the native operating system of a particular hardware, which represents the physical hardware on which the system operates or runs. In this manner, JAVA applications can be ported from one hardware device to another without requiring updating of the application code.
[0045] Unlike most programming languages, in which a program is compiled into machine-dependent, executable program code, JAVA classes are compiled into machine independent byte code class files which are executed by a machine-dependent virtual machine. The virtual machine provides a level of abstraction between the machine independence of the byte code classes and the machine-dependent instruction set of the underlying computer hardware. A class loader is responsible for loading the byte code class files as needed, and an interpreter or just-in-time compiler provides for the transformation of byte codes into machine code.
[0046] More specifically, JAVA is a programming language designed to generate applications that can run on all hardware platforms, small, medium and large, without modification. Developed by Sun, JAVA has been promoted and geared heavily for the Web, both for public Web sites and intranets. Generally, JAVA programs can be called from within HTML documents or launched standalone. When a JAVA program runs from a Web page, it is called a “JAVA applet,” and when run on a Web server, the application is called a “servlet.”
[0047] JAVA is an interpreted language. The source code of a JAVA program is compiled into an intermediate language called “byte code”. The byte code is then converted (interpreted) into machine code at runtime. Upon finding a JAVA applet, the Web browser invokes a JAVA interpreter (JAVA Virtual Machine), which translates the byte code into machine code and runs it. Thus, JAVA programs are not dependent on any specific hardware and will run in any computer with the JAVA Virtual Machine software. On the server side, JAVA programs can also be compiled into machine language for faster performance. However a compiled JAVA program loses hardware independence as a result.
[0048] Keeping this brief introduction to JAVA in mind, reference is made to a block diagram <b>100</b> of FIG. 1 illustrating a computer system <b>102</b> implementing the methods and system of the present invention, in accordance with one embodiment of the present invention. The computer system <b>102</b> includes a storage device <b>104</b>, a read only memory (ROM) <b>106</b>, a random access memory (RAM) <b>108</b>, a processor <b>114</b>, and a communication interface <b>112</b>, each of which is coupled to a communication bus <b>110</b>. In one example, the RAM memory <b>108</b> is the main memory or any other dynamic storage device configured to store information and instructions to be executed by the processor <b>114</b>. In a like manner, the ROM <b>106</b> can be any static storage device for storing the static information and instructions to be executed by the processor <b>114</b>. The storage device <b>104</b> can be a magnetic disk or optical disk configured to be used for storing information and instructions.
[0049] The communication interface <b>112</b> is coupled to the communication bus <b>110</b> and is configured to provide a two-way data communication connection to a network link <b>130</b> that may be connected to a local network <b>124</b>. For instance, in one embodiment, the communication interface <b>112</b> may be a modem configured to provide a data communication connection. In another embodiment, the communication interface <b>112</b> may be a local area network (“LAN”) card configured to provide a data communication connection to a compatible LAN. In one instance, wireless links may also be implemented. By way of example, the communication interface <b>112</b> may be configured to send and receive electrical, electromagnetic or optical signals that carry digital data streams representing various types of information.
[0050] In one implementation, the network link <b>130</b> provides data communication through one or more networks to other data devices. For instance, the network link <b>130</b> may provide a connection through local network <b>124</b> to a host computer <b>122</b> or to a wide area network (“WAN”) such as an Internet <b>126</b>. The local network <b>124</b> and the Internet <b>126</b> both use electric, electromagnetic or optical signals that carry digital data streams. The signals through the various networks and the signals on network link <b>130</b> and through communication interface <b>112</b>, which carry the digital data to and from computer system <b>100</b>, are exemplary forms of carrier waves transporting the information.
[0051] In one example, the communication bus <b>110</b> and thus the computer system <b>102</b> are connected to a display <b>120</b>, an input device <b>118</b>, and a cursor control <b>116</b> via a connector bus <b>111</b>. In one embodiment, the display <b>120</b> is a cathode ray tube (CRT), designed for displaying information to a computer user while the input device is a keyboard configured to communicate the information and commands to the processor <b>114</b>. In one instance, the cursor control <b>116</b> is a type of user input device, such as mouse, and is configured to be used to communicate with the processor <b>114</b> for controlling cursor movement on the display.
[0052]FIG. 2 is a block diagram illustrating the information and data stored in the main memory (e.g., RAM memory) <b>108</b>, in accordance with one embodiment of the present invention. In the embodiment of FIG. 2, the RAM Memory <b>108</b> stores a software application <b>132</b>, a reference implementation <b>134</b>, a JAVA virtual machine <b>142</b>, and an access controller <b>138</b>. In one example, the access controller <b>138</b>, the application <b>132</b>, and the reference implementation <b>134</b> are defined in the JAVA layer. In accordance to one embodiment, the reference implementation is a simulation of a real implementation and is distributed as JAVA source code.
[0053] As shown in the embodiment of FIG. 2, while the application <b>132</b> is running, the application <b>132</b> calls a deprecated method M<b>2</b> defined in a library <b>136</b>. After the method M<b>2</b> is called by the application <b>132</b>, the reference implementation <b>134</b> communicates with the access controller <b>138</b> so as to determine whether the application <b>132</b> is allowed access to the deprecated method M<b>2</b>. The access controller <b>138</b> then communicates with the JAVA virtual machine <b>142</b> requesting a call stack <b>144</b>. In one example, the call stack <b>144</b> is a collection of stack frames with each stack frame having an index, a class, and a method. In one example, the JAVA virtual machine <b>142</b> is configured to load two categories of classes:
[0054] System classes: In one instance, the system classes are loaded using the—bootclasspath option (e.g., -classes.zip, etc.); and
[0055] Application classes: In one example, the application classes are loaded using the—classpath option (e.g., -javatv.jar, etc.).
[0056] With a continued reference to FIG. 2, the call stack <b>144</b> is then retrieved by the access controller <b>138</b>, which then selects the proper access control policy for determining the accessibility of the deprecated method M<b>2</b> by the application <b>132</b>. In one embodiment, the call stack defines the caller element (caller method), the domain of the caller element (e.g., system call or non-system call), and the deprecated method. The call stack can be inspected so as to determine whether the caller element can access the deprecated method.
[0057] An exemplary access control policy is shown below in Table 1. <tables id="TABLE-US-00001" num="1"><table frame="none" colsep="0" rowsep="0" pgwide="1"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 1</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary Access Control Policy</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>void checkMethodAccess(VMStackFrame[] frames) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>dmf_index = get the index of the deprecated method frame in the call stack ;</entry></row><row><entry /><entry>if ( caller in frames[dmf_index+1]'s is not a system class )</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>throw new NoSuchMethodError();</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>/* the caller is a system class, check for reflective invocation */</entry></row><row><entry /><entry>if ( caller in frames[dmf_index+1]'s is Method.invoke() ∥</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="70PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>Constructor.newInstance() ∥</entry></row><row><entry /><entry>Class.newlnstance0() ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>dmf_index = index of the frame that called the reflection code ;</entry></row><row><entry /><entry>if ( caller in frames[dmf_index]'s is not a system class )</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>throw new NoSuchMethodError();</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry>return normally ; /* access granted */</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry namest="OFFSET" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0058] In one embodiment, two packages are configured to be added to the reference implementation <b>134</b>:
[0059] Sun.misc.stack package:
[0060] In one instance, this package serves as a helper package to implement the access control policy. In one embodiment, the Sun.misc.stack package provides two classes:
[0061] VMStack: In one embodiment, the VMStack abstracts the call stack and has a native method which returns an array of VMStackFrame objects that represent the call stack; and
[0062] VMSStackFrame: In one example, the VMStackFrame abstracts the stack frame.
[0063] By way of example, in accordance to one embodiment, the native method shown in Table 2 is defined in the VMStack and is used in the sun_misc_stack.c source. The method is linked to javai library and is implemented as a JNI method. <tables id="TABLE-US-00002" num="2"><table frame="none" colsep="0" rowsep="0"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 2</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary Native Method</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry>private native static VMStackFrame[] newStackFrames(byte, int,int)</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0064] In one instance, the sources shown in Table 3 are configured to be added. <tables id="TABLE-US-00003" num="3"><table frame="none" colsep="0" rowsep="0"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 3</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary Added Sources</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="49PT" align="left" /><colspec colname="1" colwidth="168PT" align="left" /><tbody valign="top"><row><entry /><entry>share/java/lang/sun_misc_stack.c</entry></row><row><entry /><entry namest="OFFSET" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0065] In one example, the package can be created by adding the sources shown in Table 4. <tables id="TABLE-US-00004" num="4"><table frame="none" colsep="0" rowsep="0"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 4</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary Added Sources</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="21PT" align="left" /><colspec colname="1" colwidth="196PT" align="left" /><tbody valign="top"><row><entry /><entry>a.. share/sun/sun/misc/stack/VMStack.java</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="35PT" align="left" /><colspec colname="1" colwidth="182PT" align="left" /><tbody valign="top"><row><entry /><entry>b.. share/sun/sun/misc/stack/VMStackFrame.java</entry></row><row><entry /><entry namest="OFFSET" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0066] Sun.misc.deprecation package:
[0067] The Sun.misc.deprecation package defines an interface AccessPolicy, which provides a method shown in Table 5, configured to be used by any policy object. <tables id="TABLE-US-00005" num="5"><table frame="none" colsep="0" rowsep="0"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 5</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary Access Control Method</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="21PT" align="left" /><colspec colname="1" colwidth="196PT" align="left" /><tbody valign="top"><row><entry /><entry>public void checkMethodAccess(VMStackFrame[] frames) ;</entry></row><row><entry /><entry namest="OFFSET" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0068] In one instance, a default access control policy implementation DefaultAccessPolicy is included in the package. An AccessController class is configured to define a static method checkMethodAccess( ) designed to be called by the deprecated method code. In one embodiment, the AccessController.checkMethodAccess( ) does not perform any operation by default. In one instance, the JAVA property shown in Table 6 is configured to be set prior to invoking the present invention. <tables id="TABLE-US-00006" num="6"><table frame="none" colsep="0" rowsep="0"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 6</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary JAVA Property to Be Set</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="21PT" align="left" /><colspec colname="1" colwidth="196PT" align="left" /><tbody valign="top"><row><entry /><entry>piava -Dsun.misc.deprecation.access.policy=default some-class</entry></row><row><entry /><entry namest="OFFSET" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0069] In one embodiment, the exemplary sources shown in Table 7 are configured to be added. <tables id="TABLE-US-00007" num="7"><table frame="none" colsep="0" rowsep="0"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 7</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary Sources Added</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="21PT" align="left" /><colspec colname="1" colwidth="196PT" align="left" /><tbody valign="top"><row><entry /><entry>a.. share/sun/sun/misc/deprecation/AccessController.java</entry></row><row><entry /><entry>b.. share/sun/sun/misc/deprecation/AccessPolicy.java</entry></row><row><entry /><entry namest="OFFSET" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0070]<tables id="TABLE-US-00008" num="8"><table frame="none" colsep="0" rowsep="0"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="217PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 8</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary Code to Use sun.misc.deprecation Package</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>public class DeprecatedClass {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="175PT" align="left" /><tbody valign="top"><row><entry /><entry>/**</entry></row><row><entry /><entry> * @deprecated this class is deprecated</entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>public DeprecatedClass() {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="161PT" align="left" /><tbody valign="top"><row><entry /><entry>AccessController.checkMethodAccess() ;</entry></row><row><entry /><entry>...</entry></row><row><entry /><entry>...</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="175PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry>public class DeprecatedMethod</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="175PT" align="left" /><tbody valign="top"><row><entry /><entry>/**</entry></row><row><entry /><entry> * @deprecated this method is deprecated</entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>public void deprecatedMethod() ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="161PT" align="left" /><tbody valign="top"><row><entry /><entry>AccessController.checkMethodAccess() ;</entry></row><row><entry /><entry>...</entry></row><row><entry /><entry>...</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="175PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry namest="OFFSET" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0071] In one embodiment, a software application of the present invention is called Tarsier. Table 9 shows an Exemplary JAVA code implemented in Tarsier. <tables id="TABLE-US-00009" num="9"><table frame="none" colsep="0" rowsep="0" pgwide="1"><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="center" /><thead><row><entry namest="1" nameend="1" align="center">TABLE 9</entry></row><row><entry /></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row><row><entry>Exemplary JAVA-based Tarsier Code</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></thead><tbody valign="top"><row><entry /></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry>/*</entry></row><row><entry> * @(#)AccessController.java</entry></row><row><entry> *</entry></row><row><entry>package sun.misc.deprecation ;</entry></row><row><entry>import java.lang.reflect.Method ;</entry></row><row><entry>import java.lang.reflect.Constructor ;</entry></row><row><entry>import java.lang.reflect.Member ;</entry></row><row><entry>import sun.misc.stack.VMStack ;</entry></row><row><entry>import sun.misc.stack.VMStackFrame ;</entry></row><row><entry>/**</entry></row><row><entry> * <code>AccessController</code> encapsulates methods to check if the</entry></row><row><entry> * caller has access to the deprecated methods and classes. In one example, this</entry></row><row><entry>defines static method and cannot be used to instantiate an object. This</entry></row><row><entry> * contains a <code>AccessPolicy</code> implementation, which gets</entry></row><row><entry> * delegated when access checks are made.</entry></row><row><entry> * <p></entry></row><row><entry> * The default behavior of<code>AccessController</code>check methods is</entry></row><row><entry> * nothing. The behavior can be changed to perform access checking by</entry></row><row><entry> * setting the system property</entry></row><row><entry> * <b>sun.misc.deprecation.access.policy</b>to either a fully qualified</entry></row><row><entry> * class name that implements <code>sun.misc.deprecation.AccessPolicy</code></entry></row><row><entry> * interface or the keyword <b>default</b> or <b>defaultDebug</b>.</entry></row><row><entry> * Setting it to <b>default</b>will create a default access policy</entry></row><row><entry> * implementation and <b>defaultDebug</b> will create a debug version of the</entry></row><row><entry> * default access policy implementation.</entry></row><row><entry> *</entry></row><row><entry>public final class AccessController {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>static AccessPolicy accessPolicy = null ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>/* create a AccessPolicy implementation depending on the property */</entry></row><row><entry /><entry>static {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>Class policy_class = null ;</entry></row><row><entry /><entry>String policy = null ;</entry></row><row><entry /><entry>policy = System.getProperty(“sun.misc.deprecation.access.policy”)</entry></row><row><entry /><entry>if ( policy !=null ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>if ( policy.equals(“default”))</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="70PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>policy_class = DefaultAccessPolicy.class ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>else</entry></row><row><entry /><entry>if ( policy.equals(“defaultDebug”) )</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="70PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>policy_class = DebugDefaultAccessPolicy.class ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>else {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="70PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>/* it should be a class that implements AccessPolicy */</entry></row><row><entry /><entry>try {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="84PT" align="left" /><colspec colname="1" colwidth="175PT" align="left" /><tbody valign="top"><row><entry /><entry>policy_class = Class.forName(policy) ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="70PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry>catch ( Exception ex ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="84PT" align="left" /><colspec colname="1" colwidth="175PT" align="left" /><tbody valign="top"><row><entry /><entry>System.err.println(AccessController.class+ “:“+ policy+</entry></row><row><entry /><entry>“ is not a valid policy class, using default policy<“+</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="112PT" align="left" /><colspec colname="1" colwidth="147PT" align="left" /><tbody valign="top"><row><entry /><entry>ex+“>”);</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="70PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>/* create the policy object */</entry></row><row><entry /><entry>if ( policy_class != null) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>try {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>accessPolicy = (AccessPolicy)policy_class.newInstance();</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry>catch ( Exception ex ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>System.err.println(AccessController.class+“:”+</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="112PT" align="left" /><colspec colname="1" colwidth="147PT" align="left" /><tbody valign="top"><row><entry /><entry>“cannot instantiate instance of”+</entry></row><row><entry /><entry>policy_class+“<”+ex+“>”) ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry>/**</entry></row><row><entry /><entry> * Checks if the caller's caller has access to the deprecated method.</entry></row><row><entry /><entry> * The caller of this method is assumed to be deprecated, since</entry></row><row><entry /><entry> * there is no API to verify that attribute. It is the responsibility</entry></row><row><entry /><entry> * of the caller to make sure that this method is invoked by</entry></row><row><entry /><entry> * deprecated methods</entry></row><row><entry /><entry> *</entry></row><row><entry /><entry> * @throws java.security.AccessControlException if access is not allowed</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="3"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="42PT" align="left" /><colspec colname="2" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry> *</entry><entry>else returns silently</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry> */</entry></row><row><entry /><entry>public static void checkMethodAccess() {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>/* This is how the stack would look like, when we make the call to</entry></row><row><entry /><entry> * get the stack frames. We are interested only in 4 frames starting</entry></row><row><entry /><entry> * from index 3 (the deprecated method)</entry></row><row><entry /><entry> * [0] sun.misc.stack.VMStack.newStackFrames()</entry></row><row><entry /><entry> * [1] sun.misc.stack.VMStack.getStackFrames()</entry></row><row><entry /><entry> * [2] sun.misc.deprecation.AccessController.checkMethodAccess()</entry></row><row><entry /><entry> * [3] << deprecated method >></entry></row><row><entry /><entry> * [4] << reflection method 1 >></entry></row><row><entry /><entry> * [5] << reflection method 2 (Class.newlnstance())>></entry></row><row><entry /><entry> * [6] << system method or non-system method >></entry></row><row><entry /><entry> * [7] ...</entry></row><row><entry /><entry> * [8] ...</entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>if ( accessPolicy != null ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>accessPolicy.checkMethodAccess(VMStack.getStackFrames(3,4)) ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry>}</entry></row><row><entry>/**</entry></row><row><entry> * <code>DefaultAccessPolicy</code> allows deprecated method access</entry></row><row><entry> * for system classes, other classes are not allowed access. The</entry></row><row><entry> * algorithm used by the check method is as follows</entry></row><row><entry> * <pre></entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="28PT" align="left" /><colspec colname="2" colwidth="231PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>if ( frames[caller_index]'s method is not a system class )</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="56PT" align="left" /><colspec colname="2" colwidth="203PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>throw new NoSuchMethodError();</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="28PT" align="left" /><colspec colname="2" colwidth="231PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>if ( frames[caller_index+1]'s method is Method.invoke() ∥</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="98PT" align="left" /><colspec colname="2" colwidth="161PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>Constructor.newInstance() ∥</entry></row><row><entry> *</entry><entry>Class.newInstance() ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="42PT" align="left" /><colspec colname="2" colwidth="217PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>caller_index = index of the frame that called the reflection code ;</entry></row><row><entry> *</entry><entry>if ( frames[caller_index]'s method is not a system class )</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="70PT" align="left" /><colspec colname="2" colwidth="189PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>throw new NoSuchMethodError() ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="28PT" align="left" /><colspec colname="2" colwidth="231PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>}</entry></row><row><entry> *</entry><entry>return normally</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry> * </pre></entry></row><row><entry> * The procedure to check for a system class is</entry></row><row><entry> * <pre></entry></row><row><entry> * (VMStackFrame.getCaller().getDeclaringClass().getProtectionDomain().</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="1" colwidth="56PT" align="left" /><colspec colname="2" colwidth="203PT" align="left" /><tbody valign="top"><row><entry> *</entry><entry>getCodeSource() == null)</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry> * </pre></entry></row><row><entry>*/</entry></row><row><entry>class DefaultAccessPolicy implements AccessPolicy {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>public void checkMethodAccess(VMStackErame[] f) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>int caller_index = 1 ; /* this points to the caller of the</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="84PT" align="left" /><colspec colname="1" colwidth="175PT" align="left" /><tbody valign="top"><row><entry /><entry>* deprecated method */</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>Member caller = f[caller_index].getCaller() ;</entry></row><row><entry /><entry>Class cclass = caller.getDeclaringClass() ; /* caller's class */</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="3"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="112PT" align="left" /><colspec colname="2" colwidth="119PT" align="left" /><tbody valign="top"><row><entry /><entry>String cmethod = caller.getName();</entry><entry>/* caller's method */</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>/*</entry></row><row><entry /><entry> * System classes's code source is “null”, where as non-system</entry></row><row><entry /><entry> * classes's code source is “non-null, so we check the code source</entry></row><row><entry /><entry> * of the caller who invoked the deprecated method to decide if</entry></row><row><entry /><entry> * we need allow access or not.</entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>if ( cclass.getProtectionDomain().getCodeSource() != null) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>throw new NoSuchMethodError(f[0].getCaller()+“ is deprecated”);</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry>/*</entry></row><row><entry /><entry> * The caller is a system class, so we check if it is part of the</entry></row><row><entry /><entry> * reflection system. If it is then we bump the “caller_index” to point</entry></row><row><entry /><entry> * to the caller of the reflective method.</entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>if ((cclass ==Method.class && cmethod.equals(“invoke”)) ∥</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>(cclass == Constructor.class && cmethod.equals(“newInstance”)) )</entry></row><row><entry /><entry>caller_index += 1; /* skip the reflection frame */</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>else</entry></row><row><entry /><entry>if ((cclass == Class.class && cmethod.equals(“newInstance0”)))</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>caller_index +=2 ; /* skip reflection frame +</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="98PT" align="left" /><colspec colname="1" colwidth="161PT" align="left" /><tbody valign="top"><row><entry /><entry>* java.lang.Class.newInstance frame */</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>else</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>return ; /* non-reflective system class, access granted */</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>/*</entry></row><row><entry /><entry> * Check if the caller of the reflection methods is a system class or</entry></row><row><entry /><entry> * a non-system class.</entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>caller = f[caller_index].getCaller()</entry></row><row><entry /><entry>cclass = caller.getDeclaringClass();</entry></row><row><entry /><entry>if ( cclass.getProtectionDomainO.getCodeSource() != null ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>throw new NoSuchMethodError(f[0].getCaller()+“ is deprecated”)</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry>}</entry></row><row><entry>/**</entry></row><row><entry> * Debug version of the default access policy object</entry></row><row><entry> */</entry></row><row><entry>class DebugDefaultAccessPolicy extends DefaultAccessPolicy {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>public void checkMethodAccess(VMStackFrame[] f) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="3"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="63PT" align="left" /><colspec colname="2" colwidth="168PT" align="left" /><tbody valign="top"><row><entry /><entry>Member caller</entry><entry>= null ;</entry></row><row><entry /><entry>String caller_type</entry><entry>= null ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>for (int i = 0 ; i < f.length ; i++ ) {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>caller = f[i].getCaller()</entry></row><row><entry /><entry>if ( caller.getDeclaringClass().getProtectionDomain().</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="70PT" align="left" /><colspec colname="1" colwidth="189PT" align="left" /><tbody valign="top"><row><entry /><entry>getCodeSource() != null )</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>caller_type = “ ”;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>else</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="56PT" align="left" /><colspec colname="1" colwidth="203PT" align="left" /><tbody valign="top"><row><entry /><entry>caller_type = “*”;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="42PT" align="left" /><colspec colname="1" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry>System.out.println(“[“+i+”] “+caller_type+caller) ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row><row><entry /><entry>super.checkMethodAccess(f);</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry>}</entry></row><row><entry>/*</entry></row><row><entry> * @(#)AccessPolicy.java</entry></row><row><entry>package sun.misc.deprecation;</entry></row><row><entry>import sun.misc.stack.VMStackFrame ;</entry></row><row><entry>/**</entry></row><row><entry> * <code>AccessPolicy</code>specifies the interface that should be</entry></row><row><entry> * implemented by any policy object. A default implementation of</entry></row><row><entry> * <code>AccessPolicy</code> is provided by <code>DefaultAccessPolicy</code>,</entry></row><row><entry> * which is package private.</entry></row><row><entry> *</entry></row><row><entry>public interface AccessPolicy {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>/**</entry></row><row><entry /><entry> * Checks if the caller have access to the deprecated method</entry></row><row><entry /><entry> *</entry></row><row><entry /><entry> * @param frames stack frames. The first frame will be that of the</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="3"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="14PT" align="left" /><colspec colname="2" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry> *</entry><entry>the deprecated method. There can be no more than 4 frames at</entry></row><row><entry /><entry> *</entry><entry>the maximum.</entry></row><row><entry /><entry> *</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry> * @throws java.security.AccessControlException if the caller does not</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="3"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="28PT" align="left" /><colspec colname="2" colwidth="217PT" align="left" /><tbody valign="top"><row><entry /><entry> *</entry><entry>have access to the deprecated method.</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry> */</entry></row><row><entry /><entry>public void checkMethodAccess(VMStackFrame[] frames)</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry>}</entry></row><row><entry>/*</entry></row><row><entry> * @(#)AccessPolicy.java</entry></row><row><entry> *</entry></row><row><entry>package sun.misc.deprecation;</entry></row><row><entry>import sun.misc.stack.VMStackFrame ;</entry></row><row><entry>/**</entry></row><row><entry> * <code>AccessPolicy</code> specifies the interface that should be</entry></row><row><entry> * implemented by any policy object. A default implementation of</entry></row><row><entry> * <code>AccessPolicy</code> is provided by <code>DefaultAccessPolicy</code>,</entry></row><row><entry> * which is package private.</entry></row><row><entry> */</entry></row><row><entry>public interface AccessPolicy {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>/**</entry></row><row><entry /><entry> * Checks if the caller have access to the deprecated method</entry></row><row><entry /><entry> *</entry></row><row><entry /><entry> * @param frames stack frames. The first frame will be that of the</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="3"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="14PT" align="left" /><colspec colname="2" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry> *</entry><entry>the deprecated method. There can be no more than 4 frames at</entry></row><row><entry /><entry> *</entry><entry>the maximum.</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry> *</entry></row><row><entry /><entry> * @throws java.security.AccessControlException if the caller does not</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="3"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="14PT" align="left" /><colspec colname="2" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry> *</entry><entry>have access to the deprecated method.</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry> */</entry></row><row><entry /><entry>public void checkMethodAccess(VMStackFrame[] frames);</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry>}</entry></row><row><entry>/*</entry></row><row><entry> * @(#)VMStackFrame.java</entry></row><row><entry> *</entry></row><row><entry>*/</entry></row><row><entry>package sun.misc.stack;</entry></row><row><entry>import java.lang.reflect.Member;</entry></row><row><entry>/**</entry></row><row><entry> * <code>VMStackFrame</code>encapsulates a stack frame within</entry></row><row><entry> * a call stack.</entry></row><row><entry> *</entry></row><row><entry> */</entry></row><row><entry>public final class VMStackFrame {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>Member caller ;</entry></row><row><entry /><entry>/**</entry></row><row><entry /><entry> * Only the native code can create an instance of</entry></row><row><entry /><entry> * <code>VMStackFrame</code></entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>private VMStackFrame() { }</entry></row><row><entry /><entry>/**</entry></row><row><entry /><entry> * Get the caller associated with the stack frame</entry></row><row><entry /><entry> *</entry></row><row><entry /><entry> * @return <code>java.lang.reflect.Member</code></entry></row><row><entry /><entry> */</entry></row><row><entry /><entry>public Member getCaller() {</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="28PT" align="left" /><colspec colname="1" colwidth="231PT" align="left" /><tbody valign="top"><row><entry /><entry>return caller ;</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="2"><colspec colname="OFFSET" colwidth="14PT" align="left" /><colspec colname="1" colwidth="245PT" align="left" /><tbody valign="top"><row><entry /><entry>}</entry></row></tbody></tgroup><tgroup align="left" colsep="0" rowsep="0" cols="1"><colspec colname="1" colwidth="259PT" align="left" /><tbody valign="top"><row><entry>}</entry></row><row><entry namest="1" nameend="1" align="center" rowsep="1" /></row></tbody></tgroup></table></tables>
[0072] Implementing the methods and classes of the library <b>136</b> of the reference implementation <b>134</b> to build the call stack <b>144</b> for the caller element can further be understood with respect to the embodiments in FIGS. <b>3</b>A-<b>1</b> through <b>3</b>A-<b>2</b>, in accordance with one embodiment of the present invention. In the embodiment of FIG. 3A-<b>1</b>, a call stack <b>144</b>-A includes a stack frame <b>144</b><i>b </i>revealing the calling of the M<b>1</b> method in a class A by a stack frame <b>144</b><i>a </i>showing the called method main ina class Main. As shown, a library <b>136</b><i>a </i>includes the source code wherein a method M<b>1</b> is called by the class A. Simply stated, the call stack <b>144</b>-A is built for the caller element.
[0073] Continuing to FIG. 3A-<b>2</b>, a call stack <b>144</b>-B formed in response to a source in the library <b>136</b><i>b </i>can further be understood. As shown, the library <b>136</b><i>b </i>includes the calling of the method M<b>1</b> of class A, and the calling of the deprecated method M<b>2</b> of class B. For ease of reference, the description of the deprecated method M<b>2</b> has been flagged using the term “deprecated. ” As further shown, a first line of the deprecated method M<b>2</b> is a call to “checkMethodAccess” method. In one instance, the “checkMethodAccess” method is included as a first line of each of the deprecated methods. In this manner, prior to running the deprecated method, a determination is made as to whether the caller of Method M<b>2</b> should be allowed access to the deprecated method. As shown, a corresponding call stack <b>144</b>-B includes three stack frames <b>144</b><i>a </i>through <b>144</b><i>c</i>, each respectively corresponding to the main method of the main class calling the method M<b>1</b> of the class A in turn calling the deprecated method M<b>2</b> of class B, respectively.
[0074] Reference is made to FIG. 4A-<b>1</b> illustrating a call stack <b>144</b>-C showing the calling of a deprecated method M<b>2</b> by a <system method>, in accordance with one embodiment of the present invention. As shown, the stack frames <b>144</b><i>a</i>-<b>144</b><i>d </i>of the call stack <b>144</b>-C illustrate an exemplary succession of the caller classes and caller methods. The plurality of depicted stack frames <b>144</b><i>a</i>-<b>144</b><i>d </i>have been indexed with the bottom most stack frame <b>144</b><i>a </i>having the index “0” and the top most stack frame <b>144</b><i>d </i>having the index “3. ” The stack frame <b>144</b><i>a </i>shows the calling of the main method of the main class followed by the calling of the method M<b>1</b> of class A, as illustrated in stack frame <b>144</b><i>b</i>. The stack frame <b>144</b><i>c </i>shows the calling of a <system method> of the <system> class followed by the calling of the deprecated method M<b>2</b> in the stack frame <b>144</b><i>d</i>. In one embodiment, the access controller <b>138</b> grants access to the deprecated method M<b>2</b>, as the caller method defined in the stack frame <b>144</b><i>c </i>below the stack frame <b>144</b><i>d </i>of the deprecated method M<b>2</b> contains a system method.
[0075] Referring to FIG. 4A-<b>2</b>, calling of a deprecated method M<b>2</b> by a reflection method “invoke( )” which in turn is called by a non-system (i.e., application) method can further be understood, in accordance with one embodiment of the present invention. A call stack <b>144</b>-C′ includes a plurality of stack frames <b>144</b><i>a</i>′-<b>144</b>-<i>d</i>′, indexed as “0” to “3,” respectively. As shown, the application method M<b>1</b> calls the reflection method “invoke( )” of a class “C. ” As illustrated, the reflection method “invoke( )” itself calls the deprecated method M<b>2</b>. In one embodiment, the access controller is configured to implement the proper access control policy to determine whether the deprecated method M<b>2</b> can be accessed. In doing so, the access controller determines that the method M<b>1</b>, the method is calling the reflection method “invoke( ),” is a non-system method. Upon making such determination, access is denied to the deprecated method M<b>2</b> and a noSuchMethodError is dispatched to the user.
[0076] In contrast, the deprecated method M<b>2</b> of stack frame <b>144</b><i>d </i>″ of FIG. 4A-<b>3</b> can be accessed by the <system method> of a stack frame <b>144</b><i>b</i>″, in accordance with one embodiment of the present invention. That is, in the embodiment of FIG. 4A-<b>3</b>, the access controller grants access to the deprecated method M<b>2</b> upon determining that the method calling the reflection method “invoke( ),” which in turn calls the deprecated method M<b>2</b>, is a <system method>.
[0077] Similarly, in the embodiment of FIG. 4A-<b>4</b>, a stack call <b>144</b>-C′″ includes a plurality of stack frames <b>144</b><i>a</i>′″-<b>144</b><i>e</i>′″, which have been indexed with the bottom most stack frame <b>144</b><i>a</i>′″ having the index “0” and the top most stack frame <b>144</b><i>e</i>′″ having the index “4. ” As shown, the stack frames <b>144</b><i>c</i>′″ and <b>144</b><i>d</i>′″ respectively include a <reflection method <b>1</b>> and a <reflection method <b>2</b>>. In one example, the <reflection method <b>1</b>>is the method “newInstance<b>0</b>( )” which in turn calls the <reflection method <b>2</b>>“newInstance( ). ” By way of example, access to the deprecated method M<b>2</b> is denied since the method M<b>1</b> (i.e., the caller method below the reflection methods) is an application method. In a different embodiment, access to the deprecated method would have been granted had the caller method (i.e., the method calling the first reflection method) was a system method.
[0078] The communication sequence in determining accessibility to a deprecated method can further be understood with respect to the sequence diagrams of FIGS. 4B and 4C, in accordance with one embodiment of the present invention. As illustrated in the embodiment of FIG. 4B, upon being called, a deprecated method <b>136</b><i>a </i>communicates a checkMethodAccess( ) method <b>148</b> to the access controller <b>138</b>. Then, the access controller <b>138</b> communicates a getStackframes( ) method <b>150</b> to the virtual machine <b>146</b>, which in turn communicates the stack frames <b>152</b> to the access controller. After receiving the stack frames <b>152</b>, the access controller <b>138</b> communicates a checkMethodAccess(frame) <b>154</b> with an access control policy implementation <b>140</b>. At this point, a determination is made as to whether the caller method is a system method or a non-system (i.e., application method). As illustrated in FIG. 4B, when it is determined that the caller method is an application method, the access control policy implementation <b>140</b> communicates a <fail> with the deprecated method, throwing a NoSuchMethodError( ) <b>156</b> error. On the contrary, as shown in the embodiment of FIG. 4C, if it is determined that the caller method is a system method, the access control policy implementation <b>140</b> communicates a <pass> with the deprecated method <b>136</b><i>a</i>, allowing the caller method access to the deprecated method.
[0079] In accordance with another embodiment of the present invention, allowing access to a deprecated method can further be understood with respect to the block diagram shown in FIG. 5. By way of the illustrated example, a software application <b>132</b>′, a reference implementation <b>134</b>′, a JAVA virtual machine <b>146</b> are stored in a RAM Memory <b>108</b>′. As illustrated, in one example, the JAVA virtual machine <b>146</b> can be configured to include an access controller <b>138</b>′, which in turn includes an access control policy <b>140</b>′. In one implementation, the application <b>132</b>′ calls the deprecated method M<b>2</b> in the library <b>136</b>′ during run time. Once the deprecated method has been called by the application <b>132</b>′, the reference implementation <b>134</b>′ communicates with the access controller <b>138</b>′ so as to determine whether the deprecated method M<b>2</b> can be accessed by the application <b>132</b>′. The access controller <b>138</b>′ then is configured to retrieve a call stack <b>144</b>′. The access controller <b>138</b>′ then selects the proper access control policy <b>140</b>′ to be implemented in determining the accessibility of the deprecated method M<b>2</b> by the application <b>132</b>′. Thus, in accordance with a different embodiment of the present invention, the access controller and access control policy of the present invention may be implemented in the JAVA virtual machine rather than the JAVA layer component.
[0080] Referring to FIG. 6A, the accessibility of a Test and Compatibility Kit (“TCK”) <b>160</b> to a deprecated method <b>136</b><i>a </i>in a Multimedia Home Platform (“MHP”) implementation can further be understood, in accordance with one embodiment of the present invention. In one instance, the TCK can be implemented to determine if the implementation of a particular JAVA technology is compliant with the specification for the particular JAVA technology. In one aspect, the TCK is a suite of tests, tools, and documentation that allows an implementer of a JAVA technology specification to determine if the implementation is compliant with the specification.
[0081] The TCK typically includes a Test Harness, defined as the applications and tools that are used for test execution and test suite management, and a TCK Test Suite, which is the composite of the actual test cases in the TCK that are executed to test an implementation. The TCK can also include documentation that includes the specific TCK usage procedures, and the compatibility testing requirements that apply to the related technology release (usually in the form of a TCK user's guide). Also, a description of the TCK appeals process can be included, as well as an audit process, which is used to better ensure the integrity of a consistent self-testing compatibility program.
[0082] By way of example, the MHP is a specification configured to implement a Digital Settop boxes. The MHP includes JAVA technology as the application platform for developing applications for the settop box. The JAVA technology specified by MHP is a subset of a Personal JAVA Specification.
[0083] As shown in FIG. 6A, upon being called by the TCK <b>160</b>, the deprecated method <b>136</b><i>a </i>communicates to the access controller <b>138</b> questioning whether the TCK <b>160</b> is allowed access to the deprecated method. In one example, this is achieved by including a checkMethodAccess( ) in the first line of the source code for the deprecated method <b>136</b><i>a</i>. The access controller <b>138</b> then uses a proper access control policy <b>140</b> to determine whether the TCK <b>160</b> should be allowed access to the deprecated method <b>136</b><i>a</i>. In one example, the access control policy <b>140</b> is configured to be a black and white access control policy in which access to the deprecated method <b>136</b><i>a </i>is denied since the calling method is not a system method (i.e., the calling method is a TCK method (a non-system call) and does not originate in MHP (a system call)).
[0084] The pluggability of the access control policy of the embodiments of the present invention can further be understood with respect to the block diagram shown in FIG. 6B, in accordance with one embodiment of the present invention. As shown, a plurality of access control policy <b>1</b> through access control policy<sub>n </sub><b>140</b><i>a</i>-<b>140</b><sub>n </sub>can be plugged into the access controller <b>138</b> using a selectable policy <b>164</b>. Thus, the pluggability of the access control policy enables the present invention to implement a diversity of access control policies.
[0085]FIG. 7 depicts a flow chart <b>700</b> illustrating the method operations performed in determining the accessibility of a calling method to a deprecated method, in accordance to one embodiment of the present invention. The method begins in operation <b>702</b> in which the execution of an application is initiated. In one example, the application is a JAVA-based application. Next, in operation <b>704</b>, the deprecated method of a reference implementation is called by the application. Thereafter, operation <b>706</b>, an access controller including an access control policy is invoked. In one example, the access control policy is a pluggable policy and is configured to include a set of criteria utilized to decide whether the calling method should be allowed access to the deprecated method.
[0086] Continuing to operation <b>708</b>, a determination is made as to whether the calling method of the application satisfies the access control policy criteria. In one example, the access control policy criteria may be that system methods can access deprecated methods whereas access should be denied to non-system methods. If in operation <b>708</b> a determination is made that the calling method satisfies the access control policy criteria, in operation <b>710</b>, the calling application is granted access to the deprecated method. In the alternative, in operation <b>712</b>, the calling application is denied access. The whole application is failed, or depending on the access control policy, a log file may be generated for future correction so as to avoid calling of the deprecated method by the calling application. In one embodiment, accessing exemplary classes, Class.forName( ), Class.newInstance( ), and Constructor.newInstance( ) and exemplary method, Method.invoke( ), can be detected during run time.
[0087] Referring to a flow chart <b>800</b> depicted in FIG. 8, the method operations performed in denying a Test and Compatibility Kit (TCK) accessibility to a deprecated method can further be understood, in accordance to one embodiment of the present invention. The method begins in operation <b>802</b> in which the execution of TCK is initiated. Next, in operation <b>804</b>, a deprecated method in a reference implementation is called. In one embodiment, the reference implementation is JAVA-based. Proceeding to operation <b>806</b>, an access controller including an access control policy is invoked. The access control policy denies non-system caller methods access to the deprecated method.
[0088] Continuing to operation <b>808</b>, a determination is made as to whether the caller method of the TCK is a system method. If it is determined that the caller method is a system method, access is granted to the deprecated method in operation <b>810</b>. However, since the TCK is an application (i.e., non-system), access to the deprecated method in the reference implementation is denied in operation <b>812</b>. In one example, the execution of TCK is halted when a deprecated method is called.
[0089]FIG. 9 shows a flow chart <b>900</b> illustrating the method operations performed in allowing access to a deprecated method using a call stack, in accordance to one embodiment of the present invention. The method begins in operation <b>902</b> in which the execution of an application is initiated followed by operation <b>904</b> in which a deprecated method in a reference implementation is called. Next, in operation <b>906</b>, an access controller that includes an access control policy is invoked. In one example, the access control policy is pluggable, which in one embodiment, halts the execution of the application upon calling of a deprecated method, while in a different embodiment creates a log of the deprecated method calls for future correction.
[0090] In operation <b>908</b>, a call stack is retrieved so as to examine the stack frames. In one instance, each stack frame corresponds to a class and a method. The call stack is filled gradually, as each method in a class is called, with the first class and method filling substantially the first stack frame and the last class and method filling the last stack frame.
[0091] Moving to operation <b>910</b>, a determination is made as to whether the stack frame immediately below the deprecated method stack frame is a system call. If the stack frame immediately below the deprecated method stack frame is not a system call, in operation <b>912</b>, access is denied. However, if the stack frame immediately below the deprecated method stack frame is a system call, the method continues to operation <b>914</b> in which it is determined whether the stack frame immediately below the deprecated method stack frame is a reflection method. In one example, the reflection method can be invoke( ). If it is determined that the stack frame immediately below the deprecated method stack frame is not a system call, in operation <b>916</b>, access is granted to the system call.
[0092] Alternatively, if it is determined that the stack frame immediately below the deprecated method stack frame is a reflection method, the operation continues to operation <b>918</b> in which it is decided whether the next stack frame down the stack frame immediately below the deprecated method stack frame is a system call. If it is determined that the next stack frame down is not a system method, in operation <b>920</b>, access is denied to the method. However, if it is determined that the next stack frame down is a system method, in operation <b>922</b>, a decision is made as to whether the next stack frame down is a reflection method. If it is not a reflection method, the access is granted in operation <b>924</b>. But, if the next stack frame down is a reflection method, the method continues to operation <b>926</b> in which a determination is made as to whether the next stack frame down the second reflection method is a system method. If the next stack frame down is a system method, in operation <b>928</b>, access is granted, otherwise in operation <b>930</b>, access is denied.
[0093] The advantages of the present invention are numerous. Most notably, in contrast to the prior art, the embodiments of the present invention are capable of detecting deprecated methods and classes during run time. In this manner, the embodiments of the present invention eliminate the problems of legacy, reflection, inheritance, and user careless associated with the prior art. Another advantage of the embodiments of the present invention is that the present invention implements an access controller to limit access to deprecated methods and classes in a reference implementation. Yet another advantage of the present invention is that the access controller limits access to the deprecated methods and classes using a set of criteria of an access control policy. Still another advantage of the present invention is that the access control policy of the present invention is pluggable, thus allowing the use of a diverse set of criteria in limiting access to the deprecated methods and classes.
[0094] With the above embodiments in mind, it should be understood that although in certain embodiment, the application has been disclosed to be the TCK, the embodiments of the present invention can be implemented to detect the accessibility of any application to a deprecated method or class (e.g., any JAVA application, etc.). Additionally, it must be understood, that although the embodiments of the present invention have been described using a reference implementation, in a different embodiment, any appropriate type of software including deprecated methods and elements can be implemented.
[0095] Furthermore, it should be understood that the invention may employ various computer-implemented operations involving data stored in computer systems. These operations are those requiring physical manipulation of physical quantities. Usually, though not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated. Further, the manipulations performed are often referred to in terms, such as producing, identifying, determining, or comparing.
[0096] Any of the operations described herein that form part of the invention are useful machine operations. The invention also relates to a device or an apparatus for performing these operations. The apparatus may be specially constructed for the required purposes, or it may be a general purpose computer selectively activated or configured by a computer program stored in the computer. In particular, various general purpose machines may be used with computer programs written in accordance with the teachings herein, or it may be more convenient to construct a more specialized apparatus to perform the required operations.
[0097] The invention can also be embodied as computer readable code on a computer readable medium. The computer readable medium is any data storage device that can store data, which can be thereafter, be read by a computer system. Examples of the computer readable medium include hard drives, network attached storage (NAS), read-only memory, random-access memory, CD-ROMs, CD-Rs, CD-RWs, magnetic tapes, and other optical and non-optical data storage devices. The computer readable medium can also be distributed over a network coupled computer systems so that the computer readable code is stored and executed in a distributed fashion.
[0098] Furthermore, although the present invention implements Java programming language, other programming languages may be used to implement the embodiments of the present invention (e.g., C, C<sub>++</sub>, any object oriented programming language, etc.).
[0099] Although the foregoing invention has been described in some detail for purposes of clarity of understanding, it will be apparent that certain changes and modifications may be practiced within the scope of the appended claims. Accordingly, the present embodiments are to be considered as illustrative and not restrictive, and the invention is not to be limited to the details given herein, but may be modified within the scope and equivalents of the appended claims.
Contents6
13 sheets
Sheet 1 Sheet 2 Sheet 3 Sheet 4 Sheet 5 Sheet 6 Sheet 7 Sheet 8 Sheet 9 Sheet 10 Sheet 11 Sheet 12 Sheet 13
Every citation, both ways
| Document | Relation | Office | Cited during |
|---|---|---|---|
| US10367822B2 | Cited by | United States of America | Applicant |
| US2017061148A1 | Cited by | United States of America | Pre-grant |
| US10089119B2 | Cited by | United States of America | Applicant |
| US9229790B2 | Cited by | United States of America | Applicant |
| US10158647B2 | Cited by | United States of America | Search report |
| US8924921B2 | Cited by | United States of America | Search report |
| US10635504B2 | Cited by | United States of America | Applicant |
| US10713025B2 | Cited by | United States of America | Applicant |
| US10394528B2 | Cited by | United States of America | Applicant |
| US9594904B1 | Cited by | United States of America | Search report |
| US2017063874A1 | Cited by | United States of America | Pre-grant |
| US2009183225A1 | Cited by | United States of America | Pre-grant |
| EP2118766A4 | Cited by | European Patent Office (EPO) | Search report |
| US2010269088A1 | Cited by | United States of America | Pre-grant |
| US8935663B2 | Cited by | United States of America | Search report |
| US2010241667A1 | Cited by | United States of America | Pre-grant |
| US8028276B1 | Cited by | United States of America | Search report |
| US10078497B2 | Cited by | United States of America | Applicant |
| US9830146B2 | Cited by | United States of America | Applicant |
| US10360008B2 | Cited by | United States of America | Applicant |
| US10459708B2 | Cited by | United States of America | Applicant |
| US10789047B2 | Cited by | United States of America | Applicant |
| US2004194063A1 | Cited by | United States of America | Pre-grant |
| US10387142B2 | Cited by | United States of America | Applicant |
| US10417024B2 | Cited by | United States of America | Applicant |
| US10104090B2 | Cited by | United States of America | Search report |
| US10282184B2 | Cited by | United States of America | Applicant |
| US10848410B2 | Cited by | United States of America | Applicant |
| EP2118766A2 | Cited by | European Patent Office (EPO) | Search report |
| US2013254745A1 | Cited by | United States of America | Pre-grant |
| US9563487B2 | Cited by | United States of America | Applicant |
| US2003101438A1 | Cites | United States of America | Pre-grant |
| US6138238A | Cites | United States of America | Pre-grant |
| US6658652B1 | Cites | United States of America | Pre-grant |
| US6823351B1 | Cites | United States of America | Pre-grant |
| US6941552B1 | Cites | United States of America | Pre-grant |
2 members in 1 office
Priority claims5
| Document | Office | Kind | Date |
|---|---|---|---|
| 36937902 | United States of America | P | |
| 35043603 | United States of America | A | |
| 60369379 | – | – | – |
| US20020369379P | – | – | – |
| US20030350436 | – | – | – |
Members2
| Document | Office | Kind | |
|---|---|---|---|
| US2003191864A1 | United States of America | A1 | |
| US7320123B2 | United States of America | B2 |
6 legal events, as the office reported them to INPADOC
Over the term
Point at a mark for the eventEvents
| Event | Code | |
|---|---|---|
| Maintenance fee paymentMAFP | MAFP | |
| AssignmentAS | AS | |
| Fee paymentFPAY | FPAY | |
| Fee paymentFPAY | FPAY | |
| Information on status: patent grantGrantedPATENTED CASESTCF | STCF | |
| AssignmentAS | AS |
Numbers
- Publication, DOCDB
- 2003191864
- Publication, EPODOC
- US2003191864
- Application
- 10350436
- Application, DOCDB
- 35043603
- Application, EPODOC
- US20030350436
Titles
- English
- Method and system for detecting deprecated elements during runtime
Classification
- CPC, 1
- G06F9/4484
- IPC, 3
- G06F9 00
- G06F9 54
- G06F15 163
- USPC, 2
- 719310000
- 712E09082