Features Roadmap |
The Java platform provides the JNI, Reflections, and Reference Objects APIs to provide a way to invoke native methods, get information on loaded classes, and have limited interactions with the garbage collector.Java Native Interface (JNI)
The Java Native Interface (JNI) defines a standard naming and calling convention so the Java VM can locate and invoke native methods. JNI also offers a set of standard interface functions to call from native code to do such things as access, manipulate, release, or create Java objects, or call Java methods. Finally, the JNI supports an Invocation to load, initialize, and invoke the Java VM.In JDK 1.2, there are a number of new methods to add functionality in the areas of library and version management, local reference management, weak global references, array operations, string operations, reflection support, and the Invocation APIs.
Reflection
The Reflection APIs let a Java program access information about the fields, methods and constructors of loaded classes, and use reflected Field, Method, and Constructor objects to operate within JDK 1.2 security restrictions on the fields, methods, and constructors in other objects. The Reflection API accommodates applications that need access to either the public members of a target object (based on its runtime class) or the members declared by a given class.Some clients such as the Serialization service, development tools, and debuggers need to bypass the default access controls built into the Java language when they use reflected members or constructors. These controls govern how Method and Contructor reflectives can access fields, invoke members, and create new class instances according to whether the field, method, or class is public, private, or protected.
In JDK 1.2, reflected Field, Method and Constructor objects extend a new base class (AccessibleObject) with a a flag field that can be set to bypass the default access controls. Flag values for this field are either True or False, and the default flag value is false. If the flag is True, access checks are bypassed and the requested operation proceeds. If the flag is False, normal access checks are in force.
Setting the flag is under the control of the JDK 1.2 security architecture. In addition to the AccessibleObject instance, which has the necessary state and methods to set the flag to true, a ReflectPermission object is needed. The ReflectPermission object has methods to grant the necessary permission in the policy file to allow the reflective access.
Reference Objects
The JDK 1.2 Reference Objects APIs let you maintain special references to objects that allow the program to interact with the garbage collector in limited ways. A program might, for example, use Reference objects to create a situation where the garbage collector reclaims some objects only when heap memory runs low, or notifies your program when an object is reachable only through Reference objects so the program can perform clean-up operations on related objects.
Features Roadmap |