扩展 jol 源码包 打印 Mark Word

参考: https://blog.csdn.net/qq_38505969/article/details/123446310

1、下载源码并进行方法扩展

2、pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <parent>
        <groupId>org.openjdk.jol</groupId>
        <artifactId>jol-parent</artifactId>
        <version>0.9</version>
    </parent>
    <!--自定义 jar 包名称-->
    <artifactId>jol-core-0.9-summer-extend</artifactId>
    <packaging>jar</packaging>
 
    <name>Java Object Layout: Core</name>
    <url>http://maven.apache.org</url>
 
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerVersion>1.8</compilerVersion>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
 
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

3、打包

扩展 toPrintableSimple() 方法代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 扩展方法
public String toPrintableSimple() {
    return toPrintableSimple(classData.instance());
}
 
public String toPrintableSimple(Object instance) {
    StringBuffer stringBuffer = new StringBuffer();
 
    if (instance != null) {
        VirtualMachine vm = VM.current();
        for (long off = 4; off >= 0; off -= 4) {
            int word = vm.getInt(instance, off);
            stringBuffer.append(toBinary((word >> 24)  & 0xFF) + " " + toBinary((word >> 16)  & 0xFF) + " " + toBinary((word >> 8) & 0xFF) + " " + toBinary((word >> 0) & 0xFF) + " ");
        }
    }
    return stringBuffer.toString();
}

扩展好的 jar 包下载链接:https://pan.baidu.com/s/1cr5R1OxwFU4WEtb3w1zpUw  提取码:i3qm

posted @   变体精灵  阅读(134)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示