jdk/src/java.base/share/native/libjava/VM.c
changeset 28765 8878e8455f2a
parent 25859 3317bb8137f4
child 29242 33423ec519fd
equal deleted inserted replaced
28764:cdd5e4c034de 28765:8878e8455f2a
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    31 #include "jvm.h"
    31 #include "jvm.h"
    32 #include "jdk_util.h"
    32 #include "jdk_util.h"
    33 
    33 
    34 #include "sun_misc_VM.h"
    34 #include "sun_misc_VM.h"
    35 
    35 
       
    36 /* Only register the performance-critical methods */
       
    37 static JNINativeMethod methods[] = {
       
    38     {"getNanoTimeAdjustment", "(J)J", (void *)&JVM_GetNanoTimeAdjustment}
       
    39 };
       
    40 
    36 JNIEXPORT jobject JNICALL
    41 JNIEXPORT jobject JNICALL
    37 Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
    42 Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
    38     return JVM_LatestUserDefinedLoader(env);
    43     return JVM_LatestUserDefinedLoader(env);
    39 }
    44 }
    40 
    45 
    47     if (!JDK_InitJvmHandle()) {
    52     if (!JDK_InitJvmHandle()) {
    48         JNU_ThrowInternalError(env, "Handle for JVM not found for symbol lookup");
    53         JNU_ThrowInternalError(env, "Handle for JVM not found for symbol lookup");
    49         return;
    54         return;
    50     }
    55     }
    51 
    56 
       
    57     // Registers implementations of native methods described in methods[]
       
    58     // above.
       
    59     // In particular, registers JVM_GetNanoTimeAdjustment as the implementation
       
    60     // of the native sun.misc.VM.getNanoTimeAdjustment - avoiding the cost of
       
    61     // introducing a Java_sun_misc_VM_getNanoTimeAdjustment  wrapper
       
    62     (*env)->RegisterNatives(env, cls,
       
    63                             methods, sizeof(methods)/sizeof(methods[0]));
       
    64 
    52     func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo");
    65     func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo");
    53      if (func_p != NULL) {
    66      if (func_p != NULL) {
    54         jvm_version_info info;
    67         jvm_version_info info;
    55 
    68 
    56         memset(&info, 0, sizeof(info));
    69         memset(&info, 0, sizeof(info));