jdk/src/java.base/share/native/libjava/VM.c
changeset 29242 33423ec519fd
parent 28765 8878e8455f2a
child 34882 ce2a8ec851c1
equal deleted inserted replaced
29241:db804075e600 29242:33423ec519fd
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 #include <string.h>
       
    27 
       
    28 #include "jni.h"
    26 #include "jni.h"
    29 #include "jni_util.h"
    27 #include "jni_util.h"
    30 #include "jlong.h"
       
    31 #include "jvm.h"
    28 #include "jvm.h"
    32 #include "jdk_util.h"
    29 #include "jdk_util.h"
    33 
    30 
    34 #include "sun_misc_VM.h"
    31 #include "sun_misc_VM.h"
    35 
    32 
    41 JNIEXPORT jobject JNICALL
    38 JNIEXPORT jobject JNICALL
    42 Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
    39 Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
    43     return JVM_LatestUserDefinedLoader(env);
    40     return JVM_LatestUserDefinedLoader(env);
    44 }
    41 }
    45 
    42 
    46 typedef void (JNICALL *GetJvmVersionInfo_fp)(JNIEnv*, jvm_version_info*, size_t);
       
    47 
       
    48 JNIEXPORT void JNICALL
    43 JNIEXPORT void JNICALL
    49 Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
    44 Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
    50     GetJvmVersionInfo_fp func_p;
       
    51 
       
    52     if (!JDK_InitJvmHandle()) {
    45     if (!JDK_InitJvmHandle()) {
    53         JNU_ThrowInternalError(env, "Handle for JVM not found for symbol lookup");
    46         JNU_ThrowInternalError(env, "Handle for JVM not found for symbol lookup");
    54         return;
    47         return;
    55     }
    48     }
    56 
    49 
    59     // In particular, registers JVM_GetNanoTimeAdjustment as the implementation
    52     // In particular, registers JVM_GetNanoTimeAdjustment as the implementation
    60     // of the native sun.misc.VM.getNanoTimeAdjustment - avoiding the cost of
    53     // of the native sun.misc.VM.getNanoTimeAdjustment - avoiding the cost of
    61     // introducing a Java_sun_misc_VM_getNanoTimeAdjustment  wrapper
    54     // introducing a Java_sun_misc_VM_getNanoTimeAdjustment  wrapper
    62     (*env)->RegisterNatives(env, cls,
    55     (*env)->RegisterNatives(env, cls,
    63                             methods, sizeof(methods)/sizeof(methods[0]));
    56                             methods, sizeof(methods)/sizeof(methods[0]));
    64 
       
    65     func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo");
       
    66      if (func_p != NULL) {
       
    67         jvm_version_info info;
       
    68 
       
    69         memset(&info, 0, sizeof(info));
       
    70 
       
    71         /* obtain the JVM version info */
       
    72         (*func_p)(env, &info, sizeof(info));
       
    73     }
       
    74 }
    57 }
    75