源码中对于枚举类型WKID的使用

  static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);
static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {
int limit = (int)end_id + 1;
initialize_wk_klasses_until((WKID) limit, start_id, THREAD);

这个是宏定义,类似于以下简码

int main() {
enum EM{
day1,b1=day1,
day2,b2=day2, }; std::cout << "day2的值为:" << std::endl;
std::cout << EM::day2 << std::endl;
std::cout << "b1 的值为:" << std::endl;
std::cout << EM::b1 << std::endl;
return 0;
}
打印结果
day2的值为:
1
b1 的值为:
0

能看出来,这个枚举非常特殊,

那么看WKID

enum WKID {
NO_WKID = 0,
/* well-known classes */
Object_klass_knum, java_lang_Object_knum = Object_klass_knum,
String_klass_knum, java_lang_String_knum = String_klass_knum,
Class_klass_knum, java_lang_Class_knum = Class_klass_knum,
Cloneable_klass_knum, java_lang_Cloneable_knum = Cloneable_klass_knum,
ClassLoader_klass_knum, java_lang_ClassLoader_knum = Cloneable_klass_knum,
Serializable_klass_knum, java_io_Serializable_knum = Serializable_klass_knum,
System_klass_knum, java_lang_System_knum = System_klass_knum,
Throwable_klass_knum, java_lang_Throwable_knum = Throwable_klass_knum,
Error_klass_knum, java_lang_Error_knum = Error_klass_knum,
ThreadDeath_klass_knum, java_lang_ThreadDeath_knum = ThreadDeath_klass_knum,
Exception_klass_knum, java_lang_Exception_knum = Exception_klass_knum,,
RuntimeException_klass_knum, java_lang_RuntimeException_knum = RuntimeException_klass_knum,
SecurityManager_klass_knum, java_lang_SecurityManager_knum = SecurityManager_klass_knum,
ProtectionDomain_klass_knum, java_security_ProtectionDomain_knum = ProtectionDomain_klass_knum,
AccessControlContext_klass_knum, java_security_AccessControlContext_knum = AccessControlContext_klass_knum,
ClassNotFoundException_klass_knum, java_lang_ClassNotFoundException_knum = ClassNotFoundException_klass_knum,
NoClassDefFoundError_klass_knum, java_lang_NoClassDefFoundError_knum = NoClassDefFoundError_klass_knum,
LinkageError_klass_knum, java_lang_LinkageError_knum = LinkageError_klass_knum,
ClassCastException_klass_knum, java_lang_ClassCastException_knum = ClassCastException_klass_knum,
ArrayStoreException_klass_knum, java_lang_ArrayStoreException_knum = ArrayStoreException_klass_knum,
VirtualMachineError_klass_knum, java_lang_VirtualMachineError_knum = VirtualMachineError_klass_knum,
OutOfMemoryError_klass_knum, java_lang_OutOfMemoryError_knum = OutOfMemoryError_klass_knum,
StackOverflowError_klass_knum, java_lang_StackOverflowError_knum = StackOverflowError_klass_knum,
IllegalMonitorStateException_klass_knum, java_lang_IllegalMonitorStateException_knum = IllegalMonitorStateException_klass_knum,
Reference_klass_knum, java_lang_ref_Reference_knum = Reference_klass_knum, /* load ref klasses and set reference types */
SoftReference_klass_knum, java_lang_ref_SoftReference_knum = SoftReference_klass_knum,
WeakReference_klass_knum, java_lang_ref_WeakReference_knum = WeakReference_klass_knum,
FinalReference_klass_knum, java_lang_ref_FinalReference_knum = FinalReference_klass_knum,
PhantomReference_klass_knum, java_lang_ref_PhantomReference_knum = PhantomReference_klass_knum,
Finalizer_klass_knum, java_lang_ref_Finalizer_knum = Finalizer_klass_knum, Thread_klass_knum, java_lang_Thread_knum = Thread_klass_knum,
ThreadGroup_klass_knum, java_lang_ThreadGroup_knum = ThreadGroup_klass_knum,
Properties_klass_knum, java_util_Properties_knum = Properties_klass_knum,
reflect_AccessibleObject_klass_knum, java_lang_reflect_AccessibleObject_knum = reflect_AccessibleObject_klass_knum,
reflect_Field_klass_knum, java_lang_reflect_Field_knum = reflect_Field_klass_knum,
reflect_Parameter_klass_knum, java_lang_reflect_Parameter_knum = reflect_Parameter_klass_knum,
reflect_Method_klass_knum, java_lang_reflect_Method_knum = reflect_Method_klass_knum,
reflect_Constructor_klass_knum, java_lang_reflect_Constructor_knum = reflect_Constructor_klass_knum, /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */
/* Universe::is_gte_jdk14x_version( is not set up by this point. */
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */
reflect_MagicAccessorImpl_klass_knum, sun_reflect_MagicAccessorImpl_knum = reflect_MagicAccessorImpl_klass_knum,
reflect_MethodAccessorImpl_klass_knum, sun_reflect_MethodAccessorImpl_knum = reflect_MethodAccessorImpl_klass_knum,
reflect_ConstructorAccessorImpl_klass_knum, sun_reflect_ConstructorAccessorImpl_knum = reflect_ConstructorAccessorImpl_klass_knum,
reflect_DelegatingClassLoader_klass_knum, sun_reflect_DelegatingClassLoader_knum = reflect_DelegatingClassLoader_klass_knum,
reflect_ConstantPool_klass_knum, sun_reflect_ConstantPool_knum = reflect_ConstantPool_klass_knum,
reflect_UnsafeStaticFieldAccessorImpl_klass_knum, sun_reflect_UnsafeStaticFieldAccessorImpl_knum = reflect_UnsafeStaticFieldAccessorImpl_klass_knum,
reflect_CallerSensitive_klass_knum, sun_reflect_CallerSensitive_knum = reflect_CallerSensitive_klass_knum, /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */
DirectMethodHandle_klass_knum, java_lang_invoke_DirectMethodHandle_knum = DirectMethodHandle_klass_knum,
MethodHandle_klass_knum, java_lang_invoke_MethodHandle_knum = MethodHandle_klass_knum,
MemberName_klass_knum, java_lang_invoke_MemberName_knum = MemberName_klass_knum,
MethodHandleNatives_klass_knum, java_lang_invoke_MethodHandleNatives_knum = MethodHandleNatives_klass_knum,
LambdaForm_klass_knum, java_lang_invoke_LambdaForm_knum = LambdaForm_klass_knum,
MethodType_klass_knum, java_lang_invoke_MethodType_knum = MethodType_klass_knum,
BootstrapMethodError_klass_knum, java_lang_BootstrapMethodError_knum = BootstrapMethodError_klass_knum,
CallSite_klass_knum, java_lang_invoke_CallSite_knum = CallSite_klass_knum,
ConstantCallSite_klass_knum, java_lang_invoke_ConstantCallSite_knum = ConstantCallSite_klass_knum,
MutableCallSite_klass_knum, java_lang_invoke_MutableCallSite_knum = MutableCallSite_klass_knum,
VolatileCallSite_klass_knum, java_lang_invoke_VolatileCallSite_knum = VolatileCallSite_klass_knum,
/* Note: MethodHandle must be first, and VolatileCallSite last in group */ StringBuffer_klass_knum, java_lang_StringBuffer_knum = StringBuffer_klass_knum,
StringBuilder_klass_knum, java_lang_StringBuilder_knum = StringBuilder_klass_knum,
misc_Unsafe_klass_knum, sun_misc_Unsafe_knum = misc_Unsafe_klass_knum, /* It's NULL in non-1.4 JDKs. */
StackTraceElement_klass_knum, java_lang_StackTraceElement_knum = StackTraceElement_klass_knum,
/* Universe::is_gte_jdk14x_version( is not set up by this point. */
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */
nio_Buffer_klass_knum, java_nio_Buffer_knum = nio_Buffer_klass_knum, /* load boxing klasses */
Boolean_klass_knum, java_lang_Boolean_knum = Boolean_klass_knum,
Character_klass_knum, java_lang_Character_knum = Character_klass_knum,
Float_klass_knum, java_lang_Float_knum = Float_klass_knum,
Double_klass_knum, java_lang_Double_knum = Double_klass_knum,
Byte_klass_knum, java_lang_Byte_knum = Byte_klass_knum,
Short_klass_knum, java_lang_Short_knum = Short_klass_knum,
Integer_klass_knum, java_lang_Integer_knum = Integer_klass_knum,
Long_klass_knum, java_lang_Long_knum = Long_klass_knum, //68
/*end*/
WKID_LIMIT, //69 FIRST_WKID = NO_WKID + 1
};

这个宏是之前是看不懂的,今天顺利的解决了,通过clion的replace R 功能,替换,先将代码写道一个cpp文件中,全部替换就行了

 public:
enum WKID {
NO_WKID = 0, #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
WK_KLASSES_DO(WK_KLASS_ENUM)
#undef WK_KLASS_ENUM WKID_LIMIT, FIRST_WKID = NO_WKID + 1
};

这里非常重要的是

#define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
//

这个一行看成两部分,用  空格作为区分

jvm源码解读--10 enum WKID 枚举的更多相关文章

  1. JVM 源码解读之 CMS 何时会进行 Full GC

    t点击上方"涤生的博客",关注我 转载请注明原创出处,谢谢!如果读完觉得有收获的话,欢迎点赞加关注. 前言 本文内容是基于 JDK 8 在文章 JVM 源码解读之 CMS GC 触 ...

  2. jvm源码解读--17 Java的wait()、notify()学习

    write and debug by 张艳涛 wait()和notify()的通常用法 A线程取得锁,执行wait(),释放锁; B线程取得锁,完成业务后执行notify(),再释放锁; B线程释放锁 ...

  3. jvm源码解读--08 创建oop对象,将static静态变量放置在oop的96 offset处

    之前分析的已经加载的.Class文件中都没有Static 静态变量,所以也就没这部分的解析,自己也是不懂hotspot 将静态变量放哪里去了,追踪源码之后,看清楚了整个套路,总体上来说,可以举例来说对 ...

  4. jvm源码解读--16 cas 用法解析

    CAS的意思是campare and sweep比较交换 这个如果不用代码会比较抽象,那么在源码中进行解释 void ATTR ObjectMonitor::enter(TRAPS) { // The ...

  5. jvm源码解读--13 gc_root中的栈中oop的mark 和copy 过程分析

    粘贴源码 package com.test; import java.util.Random; public class Test { static int number=12; private in ...

  6. jvm源码解读--11 ldc指令的解读

    写一个java文件 public static void main(String[] args) { String str1="abc"; String str2 ="a ...

  7. jvm源码解读--12 invokspecial指令的解读

    先看代码 package com.zyt.jvmbook; public class Girl extends Person{ public Girl() { int a; } @Override p ...

  8. jvm源码解读--06 Method 方法解析

    进入 // Methods bool has_final_method = false; AccessFlags promoted_flags; promoted_flags.set_flags(0) ...

  9. jvm源码解读--16 锁_开头

    现在不太清楚, public static void main(String[] args) { Object object=new Object(); System.out.println(&quo ...

随机推荐

  1. 管中窥豹-ssh链接过多的问题分析及复盘

    缘起 某一天,产品侧同事联系过来,反馈话单传输程序报错,现象如下: 实际上,该节点仅提供了一个sftp服务,供产品侧传输话单过来进行临时存储,由计费部门取走而已. 分析 于是找运维同事上服务器看了下情 ...

  2. Pandas高级教程之:处理text数据

    目录 简介 创建text的DF String 的方法 columns的String操作 分割和替换String String的连接 使用 .str来index extract extractall c ...

  3. Linux shell是什么

    shell概念: shell是一个命令行解释器,它为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序,用户可以用shell启动,挂起,停止甚至编写一些程序. shell还是一个功能强 ...

  4. vue中使用element-ui出现Couldn't find preset "es2015" relative to directory

    这是因为没有安装ES 标准 使用 npm install babel-preset-es2015 -d 安装之后就好了

  5. external-provisioner源码分析(1)-主体处理逻辑分析

    更多ceph-csi其他源码分析,请查看下面这篇博文:kubernetes ceph-csi分析目录导航 概述 接下来将对external-provisioner组件进行源码分析. 在external ...

  6. 3.QT屏幕分辨率适配

    需求:qt的窗口.组件.字体需要适配屏幕分辨率. 思路:qt是根据显示器的物理长度或者宽度于分辨率的关系来计算dpi 实现: #if(QT_VERSION >= QT_VERSION_CHECK ...

  7. 【译】GO语言:管理多个错误

    原文:https://medium.com/a-journey-with-go/go-multiple-errors-management-a67477628cf1 ​ 关于开发者使用Go遇到的最大挑 ...

  8. nexus AD 集成配置

    nexus AD 集成配置 管理用户登录 点击设置图标-->LDAP-->Create connection 进入AD 集成配置页面 Connection配置 User and group ...

  9. Centos 8 上定时备份Gitlab ,脚本实现定时备份,备份恢复

    定时备份 要求 为了能够备份和恢复,请确保你的系统上安装了Rsync yum install rsync -y 配置备份目标机器免密认证 执行ssh-keygen -t rsa 生成私钥和公钥 ssh ...

  10. [Kick Start] 2021 Round B

    题目:Kick Start 2021 Round-B . Increasing Substring 输出字符串中每个字符的最长 Increasing Substring 的长度,非常简单的动态规划问题 ...