2006-05-01から1ヶ月間の記事一覧

The apt Command Line

-s dir Specify the directory root under which processor-generated source files will be placed; files are placed in subdirectories based on package namespace -nocompile Do not compile source files to class files. -print Print out textual re…

A Simple Sample Annotation Processor

import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; import java.util.Collection; import java.util.Set; import java.util.Arrays; import static java.util.Collections.*…

"-factory" option

Write an AnnotationProcessorFactory that in turn can create an AnnotationProcessor for the annotation type(s) of interest. Compile the processors and factories using javac with tools.jar on the classpath; tools.jar contains the com.sun.mir…

four packages

com.sun.mirror.apt: interfaces to interact with the tool com.sun.mirror.declaration: interfaces to model the source code declarations of fields, methods, classes, etc. com.sun.mirror.type: interfaces to model types found in the source code…

Annotation Processing Tool (apt)

apt is a command-line utility for annotation processing. It includes a set of reflective APIs and supporting infrastructure to process program annotations (JSR 175). These reflective APIs provide a build-time, source-based, read-only view …

features

Adaptive compiler - Applications are launched using a standard interpreter, but the code is then analyzed as it runs to detect performance bottlenecks, or "hot spots". The Java HotSpot VMs compile those performance-critical portions of the…

"OutOfMemoryError"

The Java HotSpot VM cannot expand its heap size if memory is completely allocated and no swap space is available. This can occur, for example, when several applications are running simultaneously. When this happens, the VM will exit after …

profiling heap usage

Try using -Xaprof to get a profile of the allocations (objects and sizes) of your application.You can also try -Xrunhprof:heap=all (or other option, try -Xrunhprof:help for a list)

file descriptors

Certain applications will use a lot of file descriptors. The only thing that you can do is to set the number of file descriptors allowed on the system higher. The hard limit default is 1024 and the soft limit default is 64. To set this hig…

tuning, Pause times

give -Xincgc a try: This uses the "Train" garbage collection algorithm, which attempts to collect a fraction of the heap instead of the entire thing at once. The train algorithm clusters objects that reference each other together, and coll…

difference between the -client and -server systems

These two systems are different binaries. They are essentially two different compilers (JITs) interfacing to the same runtime system. The client system is optimal for applications which need fast startup times or small footprints, the serv…

past enhancements

JDK 5.0 Class Data Sharing Server-Class Machine Detection Garbage Collection Ergonomics Thread Priority Changes J2SE 1.4.x doclink

DocLink

Spec FAQ

SE6 enhancement

Locale sensitive APIs ResourceBundle enhancements (control caching logic, life cycle) Normalizer API Japanese Calendar

functions

SpecLink

Unloading the VM

The JNI_DestroyJavaVM() function unloads a Java VM. As of JDK/JRE 1.1, only the main thread could unload the VM, by calling DestroyJavaVM. As of JDK/JRE 1.2, the restriction was removed, and any thread may call DestroyJavaVM to unload the …

Attaching to the VM

The JNI interface pointer (JNIEnv) is valid only in the current thread. Should another thread need to access the Java VM, it must first call AttachCurrentThread() to attach itself to the VM and obtain a JNI interface pointer. Once attached…

Creating the VM

The Invocation API allows software vendors to load the Java VM into an arbitrary native application. Vendors can deliver Java-enabled applications without having to link with the Java VM source code. The JNI_CreateJavaVM() function loads a…

functions

SpecLink

Modified UTF-8 Strings

The JNI uses modified UTF-8 strings to represent various string types. Modified UTF-8 strings are the same as those used by the Java VM. Modified UTF-8 strings are encoded so that character sequences that contain only non-null ASCII charac…

Type Signatures

Type Signature Java Type Z boolean B byte C char S short I int J long F float D double L fully-qualified-class ; fully-qualified-class [ type type[] ( arg-types ) ret-type method type

The Value Type

The jvalue union type is used as the element type in argument arrays. It is declared as follows:typedef union jvalue { jboolean z; jbyte b; jchar c; jshort s; jint i; jlong j; jfloat f; jdouble d; jobject l; } jvalue;

Field and Method IDs

Method and field IDs are regular C pointer types:struct _jfieldID; /* opaque structure */ typedef struct _jfieldID *jfieldID; /* field IDs */ struct _jmethodID; /* opaque structure */ typedef struct _jmethodID *jmethodID; /* method IDs */

Reference Types

GraphLink

Primitive Types

Java Type Native Type Description boolean jboolean unsigned 8 bits byte jbyte signed 8 bits char jchar unsigned 16 bits short jshort signed 16 bits int jint signed 32 bits long jlong signed 64 bits float jfloat 32 bits double jdouble 64 bi…

Native Method Arguments

The JNI interface pointer is the first argument to native methods. The JNI interface pointer is of type JNIEnv. The second argument differs depending on whether the native method is static or nonstatic. The second argument to a nonstatic n…

Resolving Names

Dynamic linkers resolve entries based on their names. A native method name is concatenated from the following components: the prefix Java_ a mangled fully-qualified class name an underscore (“_”) separator a mangled method name for overloa…

RegisterNatives()

The programmer can also call the JNI function RegisterNatives() to register the native methods associated with a class. The RegisterNatives() function is particularly useful with statically linked functions.

System.loadLibrary()

Native methods are loaded with the System.loadLibrary method. In the following example, the class initialization method loads a platform-specific native library in which the native method f is defined: package pkg; class Cls { native doubl…

interface pointer

Native code accesses Java VM features by calling JNI functions. JNI functions are available through an interface pointer. An interface pointer is a pointer to a pointer. This pointer points to an array of pointers, each of which points to …