zoukankan      html  css  js  c++  java
  • hsdis反汇编java源码工具的使用方法

    下载地址:
    hsdis
    linux下将hsdis.so拷贝到 /usr/lib/jvm/java-11-openjdk-11.0.7.10-4.el7_8.x86_64/lib/server 目录下(相对应于你的jdk目录lib/server下)
    window好像也差不多

    可以先测试下是否成功

    java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -version
    

    如果成功你会看到汇编指令, 如果失败可能会出现很多类似Immutable的字符

    接着就是测试你想要查看的代码

    java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly VolatileDemo > 1.log
    java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -Xcomp -XX:CompileCommand=compileonly,VolatileDemo > 1.log
    
    public class VolatileDemo {
    	private static boolean flag = false;
    	// private static int i = 0;
    	// (3)
    	private static Integer i = 0;
    	// (4)
    	// private volatile static int i = 0;
    	
    	public static void main(String[] args) throws InterruptedException {
    		new Thread(() -> {
    			// try {
    			// 	TimeUnit.MILLISECONDS.sleep(100);
    				flag = true;
    				// System.out.println("flag 被修改成 true");
    			// } catch (InterruptedException e) {
    			// 	e.printStackTrace();
    			// }
    		}).start();
    		while (!flag) {
    			add111();
    			// (1)
    			// System.out.println("flag标识 = " + flag);
    			// (2)
    			// try {
    			// 	TimeUnit.MILLISECONDS.sleep(10);
    			// } catch (InterruptedException e) {
    			// 	e.printStackTrace();
    			// }
    		}
    		System.out.println("程序结束,i=" + i);
    	}
    	
    	public static void add111() {
    		i++;
    	}
    	
    }
    
  • 相关阅读:
    Advanced Configuration Tricks
    Reviewing the Blog Module
    Editing and Deleting Data
    Making Use of Forms and Fieldsets
    Understanding the Router
    SQL Abstraction and Object Hydration
    Preparing for Different Databases
    Java学习理解路线图
    Openstack学习历程_1_视频
    CentOS安装Nginx负载
  • 原文地址:https://www.cnblogs.com/bangiao/p/13191247.html
Copyright © 2011-2022 走看看