< prev index next >

src/java.base/share/native/libjava/Class.c

Print this page




  35 #include "jni.h"
  36 #include "jni_util.h"
  37 #include "jvm.h"
  38 #include "java_lang_Class.h"
  39 
  40 /* defined in libverify.so/verify.dll (src file common/check_format.c) */
  41 extern jboolean VerifyClassname(char *utf_name, jboolean arrayAllowed);
  42 extern jboolean VerifyFixClassname(char *utf_name);
  43 
  44 #define OBJ "Ljava/lang/Object;"
  45 #define CLS "Ljava/lang/Class;"
  46 #define CPL "Ljdk/internal/reflect/ConstantPool;"
  47 #define STR "Ljava/lang/String;"
  48 #define FLD "Ljava/lang/reflect/Field;"
  49 #define MHD "Ljava/lang/reflect/Method;"
  50 #define CTR "Ljava/lang/reflect/Constructor;"
  51 #define PD  "Ljava/security/ProtectionDomain;"
  52 #define BA  "[B"
  53 
  54 static JNINativeMethod methods[] = {
  55     {"initClassName",    "()" STR,          (void *)&JVM_InitClassName},
  56     {"getSuperclass",    "()" CLS,          NULL},
  57     {"getInterfaces0",   "()[" CLS,         (void *)&JVM_GetClassInterfaces},
  58     {"isInterface",      "()Z",             (void *)&JVM_IsInterface},
  59     {"getSigners",       "()[" OBJ,         (void *)&JVM_GetClassSigners},
  60     {"setSigners",       "([" OBJ ")V",     (void *)&JVM_SetClassSigners},
  61     {"isArray",          "()Z",             (void *)&JVM_IsArrayClass},
  62     {"isPrimitive",      "()Z",             (void *)&JVM_IsPrimitiveClass},
  63     {"getModifiers",     "()I",             (void *)&JVM_GetClassModifiers},
  64     {"getDeclaredFields0","(Z)[" FLD,       (void *)&JVM_GetClassDeclaredFields},
  65     {"getDeclaredMethods0","(Z)[" MHD,      (void *)&JVM_GetClassDeclaredMethods},
  66     {"getDeclaredConstructors0","(Z)[" CTR, (void *)&JVM_GetClassDeclaredConstructors},
  67     {"getProtectionDomain0", "()" PD,       (void *)&JVM_GetProtectionDomain},
  68     {"getDeclaredClasses0",  "()[" CLS,     (void *)&JVM_GetDeclaredClasses},
  69     {"getDeclaringClass0",   "()" CLS,      (void *)&JVM_GetDeclaringClass},
  70     {"getSimpleBinaryName0", "()" STR,      (void *)&JVM_GetSimpleBinaryName},
  71     {"getGenericSignature0", "()" STR,      (void *)&JVM_GetClassSignature},
  72     {"getRawAnnotations",      "()" BA,     (void *)&JVM_GetClassAnnotations},
  73     {"getConstantPool",     "()" CPL,       (void *)&JVM_GetClassConstantPool},
  74     {"desiredAssertionStatus0","("CLS")Z",  (void *)&JVM_DesiredAssertionStatus},
  75     {"getEnclosingMethod0", "()[" OBJ,      (void *)&JVM_GetEnclosingMethodInfo},
  76     {"getRawTypeAnnotations", "()" BA,      (void *)&JVM_GetClassTypeAnnotations},
  77     {"getNestHost0",         "()" CLS,      (void *)&JVM_GetNestHost},
  78     {"getNestMembers0",      "()[" CLS,     (void *)&JVM_GetNestMembers},



  79 };
  80 
  81 #undef OBJ
  82 #undef CLS
  83 #undef STR
  84 #undef FLD
  85 #undef MHD
  86 #undef CTR
  87 #undef PD
  88 
  89 JNIEXPORT void JNICALL
  90 Java_java_lang_Class_registerNatives(JNIEnv *env, jclass cls)
  91 {
  92     methods[1].fnPtr = (void *)(*env)->GetSuperclass;
  93     (*env)->RegisterNatives(env, cls, methods,
  94                             sizeof(methods)/sizeof(JNINativeMethod));
  95 }
  96 
  97 JNIEXPORT jclass JNICALL
  98 Java_java_lang_Class_forName0(JNIEnv *env, jclass this, jstring classname,




  35 #include "jni.h"
  36 #include "jni_util.h"
  37 #include "jvm.h"
  38 #include "java_lang_Class.h"
  39 
  40 /* defined in libverify.so/verify.dll (src file common/check_format.c) */
  41 extern jboolean VerifyClassname(char *utf_name, jboolean arrayAllowed);
  42 extern jboolean VerifyFixClassname(char *utf_name);
  43 
  44 #define OBJ "Ljava/lang/Object;"
  45 #define CLS "Ljava/lang/Class;"
  46 #define CPL "Ljdk/internal/reflect/ConstantPool;"
  47 #define STR "Ljava/lang/String;"
  48 #define FLD "Ljava/lang/reflect/Field;"
  49 #define MHD "Ljava/lang/reflect/Method;"
  50 #define CTR "Ljava/lang/reflect/Constructor;"
  51 #define PD  "Ljava/security/ProtectionDomain;"
  52 #define BA  "[B"
  53 
  54 static JNINativeMethod methods[] = {
  55     {"initClassName",    "()" STR,              (void *)&JVM_InitClassName},
  56     {"getSuperclass",    "()" CLS,              NULL},
  57     {"getInterfaces0",   "()[" CLS,             (void *)&JVM_GetClassInterfaces},
  58     {"isInterface",      "()Z",                 (void *)&JVM_IsInterface},
  59     {"getSigners",       "()[" OBJ,             (void *)&JVM_GetClassSigners},
  60     {"setSigners",       "([" OBJ ")V",         (void *)&JVM_SetClassSigners},
  61     {"isArray",          "()Z",                 (void *)&JVM_IsArrayClass},
  62     {"isPrimitive",      "()Z",                 (void *)&JVM_IsPrimitiveClass},
  63     {"getModifiers",     "()I",                 (void *)&JVM_GetClassModifiers},
  64     {"getDeclaredFields0","(Z)[" FLD,           (void *)&JVM_GetClassDeclaredFields},
  65     {"getDeclaredMethods0","(Z)[" MHD,          (void *)&JVM_GetClassDeclaredMethods},
  66     {"getDeclaredConstructors0","(Z)[" CTR,     (void *)&JVM_GetClassDeclaredConstructors},
  67     {"getProtectionDomain0", "()" PD,           (void *)&JVM_GetProtectionDomain},
  68     {"getDeclaredClasses0",  "()[" CLS,         (void *)&JVM_GetDeclaredClasses},
  69     {"getDeclaringClass0",   "()" CLS,          (void *)&JVM_GetDeclaringClass},
  70     {"getSimpleBinaryName0", "()" STR,          (void *)&JVM_GetSimpleBinaryName},
  71     {"getGenericSignature0", "()" STR,          (void *)&JVM_GetClassSignature},
  72     {"getRawAnnotations",      "()" BA,         (void *)&JVM_GetClassAnnotations},
  73     {"getConstantPool",     "()" CPL,           (void *)&JVM_GetClassConstantPool},
  74     {"desiredAssertionStatus0","("CLS")Z",      (void *)&JVM_DesiredAssertionStatus},
  75     {"getEnclosingMethod0", "()[" OBJ,          (void *)&JVM_GetEnclosingMethodInfo},
  76     {"getRawTypeAnnotations", "()" BA,          (void *)&JVM_GetClassTypeAnnotations},
  77     {"getNestHost0",         "()" CLS,          (void *)&JVM_GetNestHost},
  78     {"getNestMembers0",      "()[" CLS,         (void *)&JVM_GetNestMembers},
  79     {"getPermittedSubtypes0", "()[" CLS,        (void *)&JVM_GetPermittedSubtypes},
  80     {"getRecordComponentNames0",  "()[" STR,    (void *)&JVM_GetRecordComponentNames},
  81     {"isRecord0",                 "()Z",        (void *)&JVM_IsRecord},
  82 };
  83 
  84 #undef OBJ
  85 #undef CLS
  86 #undef STR
  87 #undef FLD
  88 #undef MHD
  89 #undef CTR
  90 #undef PD
  91 
  92 JNIEXPORT void JNICALL
  93 Java_java_lang_Class_registerNatives(JNIEnv *env, jclass cls)
  94 {
  95     methods[1].fnPtr = (void *)(*env)->GetSuperclass;
  96     (*env)->RegisterNatives(env, cls, methods,
  97                             sizeof(methods)/sizeof(JNINativeMethod));
  98 }
  99 
 100 JNIEXPORT jclass JNICALL
 101 Java_java_lang_Class_forName0(JNIEnv *env, jclass this, jstring classname,


< prev index next >