Oracle8i Java Developer's Guide Release 3 (8.1.7) Part Number A83728-01 |
|
The Java language was designed for a platform-independent, secure development model. To accomplish these goals, some execution performance was sacrificed. Translating Java bytecodes into machine instructions degrades performance. To regain some of the performance loss, you may choose to natively compile certain classes. For example, you may decide to natively compile code with CPU intensive classes.
Without native compilation, the Java code you load to the server is interpreted and the underlying core classes upon which your code relies (java.lang.*
) are natively compiled.
Native compilation provides a speed increase ranging from two to ten times the speed of the bytecode interpretation. The exact speed increase is dependent on several factors, including:
Because Java bytecodes were designed to be compact, natively compiled code can be considerably larger than the original bytecode. However, because the native code is stored in a shared library, it is shared among all users of the database.
Most JVMs use Just-In-Time compilers that convert the Java bytecodes to native machine instructions when methods are invoked. The JServer Accelerator uses an Ahead-Of-Time approach to recompiling the Java classes.
This static compilation approach provides a large, consistent performance gain, regardless of the number of users or the code paths they traverse on the server. After compilation, the tool loads the statically compiled libraries into JServer, which are then shared between users, processes, and sessions.
Most Ahead-Of-Time native compilers compile directly into a platform-dependent language. For portability requirements, this was not feasible. As shown in Figure 6-1, the JServer Accelerator translates the Java classes into a version of C that is platform-independent. This C code is compiled and linked to supply the final platform-dependent, natively compiled shared libraries or DLLs.
Given a JAR file, the JServer Accelerator performs the following:
JServer Accelerator translates, compiles, and links the retrieved classes on the client. For this reason, you must natively compile on the intended platform environment that this application will be deployed to. The result is a single deployment JAR file for all classes within the project.
$ORACLE_HOME/javavm/admin
directory.
All core Java class libraries and Oracle-provided Java code within JServer is natively compiled for greater execution speed. Java classes exist as shared libraries in $ORACLE_HOME/javavm/admin
, where each shared library corresponds to a Java package. For example, orajox8java_lang.so
on Solaris and orajox8java_lang.dll
on Windows NT hold java.lang
classes. Specifics of packaging and naming can vary by platform. The Aurora JVM uses natively compiled Java files internally and opens them, as necessary, at runtime.
The JServer Accelerator can be used by Java application products that need an performance increase and are deployed on JServer. The JServer Accelerator command-line tool, ncomp
, natively compiles your code and loads it in JServer. However, in order to use ncomp
, you must first provide some initial setup.
You must install the following before invoking JServer Accelerator:
ncomp
.
System*.properties
file located in the $ORACLE_HOME/javavm/jahome
directory. Since the compiler and linker information is platform-specific, the configuration for these items is detailed in the README for your platform.
ncomp
the following role and security permissions:
JAVA_DEPLOY
: The user must be assigned to the JAVA_DEPLOY
role in order to be able to deploy the shared libraries on the server, which both the ncomp
and deploync
utilities perform. For example, the role is assigned to DAVE, as follows:
SQL> GRANT JAVA_DEPLOY TO DAVE;
FilePermission
: JServer Accelerator stores the shared libraries with the natively compiled code on the server. In order for JServer Accelerator to store these libraries, the user must be granted FilePermission
for read and write access to directories and files under $ORACLE_HOME
on the server. One method for granting FilePermission
for all desired directories is to grant the user the JAVASYSPRIV role, as follows:
SQL> GRANT JAVASYSPRIV TO DAVE;
See the Security chapter in the Oracle8i Java Developer's Guide for more information JAVASYSPRIV and granting FilePermission
.
The following sections show how to do basic native compilation using JServer Accelerator. All ncomp
options are fully described in the Oracle8i Java Tools Reference.
All of the Java classes contained within a JAR file must already be loaded within the database. Execute the ncomp
tool to instruct JServer Accelerator to natively compile all of these classes. The following natively compiles all classes within the pubProject.JAR
file:
ncomp -user scott/tiger pubProject.JAR
If you change any of the classes within this JAR file, JServer Accelerator recompiles the shared library for the package that contains the changed classes. It will not recompile all shared libraries. However, if you want all classes within a JAR file to be recompiled--regardless of whether they were previously natively compiled--you execute ncomp
with the -force
option, as follows:
ncomp -user scott/tiger -force pubProject.JAR
For more options, see the Oracle8i Java Tools Reference.
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|