java对象是怎么在jvm中new出来的,在内存中查看java对象成员变量字段属性值

java对象是怎么在jvm中new出来的

查看java对象字段属性在内存中的值

java 对象 创建 流程

附上java源码

java 复制代码
public class MiDept {

    private int innerFiled=999;

    public MiDept()  {
        System.out.println("new MiDept--------------");
    }

    public String show(int data) {
        System.out.println("mi--------------"+data);
        return "yym-invoke-method";
    }

    public int getInnerFiled() {
        return innerFiled;
    }

    public void setInnerFiled(int innerFiled) {
        this.innerFiled = innerFiled;
    }
}


public class GDBDebugJava {

    public static int static_field = 8888;
    MiDept miDept0=null;
    MiDept miDept1=null;
    MiDept miDept2=null;

    public static void main(String[] args) {
        GDBDebugJava gDBDebugJava = new GDBDebugJava();
        int i=0;
        try {
            TimeUnit.SECONDS.sleep(1);
            System.out.println("mi"+i++);
        }catch (Exception e) {
            e.printStackTrace();
        }
        Thread.currentThread().setName("yym");
        gDBDebugJava.miDept0 = new MiDept();
        gDBDebugJava.miDept0.setInnerFiled(666);
        System.out.println(gDBDebugJava.miDept0.show(123456));

    }


}

1、分配java对象内存 jvm源代码oop obj = klass->allocate_instance(CHECK);

2、打印java对象在内存中地址

3、使用gdb attach 28965 java进程 查看java对象int字段属性在内存中值

计算器转换10十进制数字

相关推荐
多恩Stone2 小时前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
BD_Marathon2 小时前
工厂方法模式
android·java·工厂方法模式
QQ4022054962 小时前
Python+django+vue3预制菜半成品配菜平台
开发语言·python·django
遥遥江上月3 小时前
Node.js + Stagehand + Python 部署
开发语言·python·node.js
玹外之音3 小时前
Spring AI MCP 无状态服务器实战:构建AI智能用户管理系统
java·后端
java干货3 小时前
Redis 的 ZipList 是什么?它是怎么解决内存碎片问题的?
java
失重外太空啦3 小时前
Tomcat
java·服务器·tomcat
屎到临头想搅便3 小时前
TOMCAT
java·tomcat
m0_531237173 小时前
C语言-数组练习进阶
c语言·开发语言·算法
Sylvia33.3 小时前
火星数据:解构斯诺克每一杆进攻背后的数字语言
java·前端·python·数据挖掘·数据分析