我们将模糊我们的项目,但不想失去远程调试和hotswapping的能力.
可能吗?哪些工具可以处理这个?我对简单的混淆感到满意 - 只需重命名类/方法/变量.
[已编辑]我们正在使用Intellij IDEA,但无法为此任务找到任何插件.
我在Java中编写了一个非常愚蠢的测试类:
public class Vector3 {
public double x,y,z ;
public Vector3(double x, double y, double z) {
this.x=x ; this.y=y ; this.z=z ;
}
public Vector3 subst(Vector3 v) {
return new Vector3(x-v.x,y-v.y,z-v.z) ;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我想看看Java Hotspot JIT(Client VM build 23.7-b01)生成的代码.我使用了"-XX:+ PrintAssembly"选项和来自http://classparser.blogspot.dk/2010/03/hsdis-i386dll.html的hsdis-i386.dll
这是生成代码的有趣部分(我已经跳过了新对象的初始化.编辑:subst方法的代码).显然,ebx是"this"指针,而edx是指向参数的指针.
lds edi,(bad)
sti
adc BYTE PTR [ebx+8],al ;*getfield x
mov edx,DWORD PTR [esp+56]
lds edi,(bad) ; implicit exception: dispatches to 0x02611f2d
sti
adc BYTE PTR [edx+8],cl ;*getfield x
lds edi,(bad)
sti
adc BYTE PTR [ebx+16],dl …Run Code Online (Sandbox Code Playgroud) 在 Linux 中,有两种不同的信号可用于暂停进程:SIGSTOP和SIGTSTP。两者都不由HotSpot 虚拟机处理,SIGSTOP 是因为无法捕获,SIGTSTP 是因为不由HotSpot处理。我想知道发送这两个信号是否安全,或者如果不安全,JVM 的哪些部分会受到影响(例如垃圾收集器)。请注意,我不关心 JVM 上运行的程序可能出现的问题,我对JVM的内部结构特别感兴趣。向JVM发送STOP/TSTP是否安全?
在使用 -XX:PrintSafePointStats 打印安全点统计信息时,我看到多次执行此 vm 操作。它有什么作用?
谷歌搜索这个关键字的多个变体,除了错误报告和核心转储之外什么也没给我。
我正在编写一个 Java 代理来检测目标类的目标方法。
\n\n我使用javassist库来做仪器。
\n\n因此java代理(命名为CnAgent.class)需要它的依赖项:javassist库才能运行。
\n\n目录层次结构是:
\n\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 META-INF\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 MANIFEST.MF\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 com\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 yet\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 another\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 agent\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 CnAgent.class\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 CnTransformer.class\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 lib\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 javassist-3.18.2-GA.jar\nRun Code Online (Sandbox Code Playgroud)\n\nMANIFEST.MF 文件内容是:
\n\nManifest-Version: 1.0\nClass-Path: lib/javassist-3.18.2-GA.jar .\nAgent-Class: com.yet.another.test.agent.CnAgent\nCreated-By: 1.8.0_11 (Oracle Corporation)\nCan-Retransform-Classes: true\nRun Code Online (Sandbox Code Playgroud)\n\n我通过以下命令创建 jar 球:
\n\njar cvfm CnAgent.jar META-INF/MENIFIEST.MF . lib\nRun Code Online (Sandbox Code Playgroud)\n\n当我使用 JVM 的 Attach API 加载代理时。\n错误打印:
\n\nerror when transform : javassist/ClassPool\njava.lang.NoClassDefFoundError: javassist/ClassPool\nRun Code Online (Sandbox Code Playgroud)\n\n这意味着代理代码无法找到 javassist 库。
\n\n所以我的问题是:
\n\n如何设置代理库的类路径让它找到依赖项?
为什么 MANIFEST.MF …
目前我有一个核心转储文件,我想提取堆转储。无论我尝试什么,我总是收到以下错误消息:
god@heaven:~$ sudo /opt/java-MyApp/bin/jmap -dump:format=b,file=my-file.hprof /opt/java-MyApp/bin/java /home/god/tmp/core
[sudo] password for god:
Attaching to core /home/god/tmp/my-app-core-dump from executable /opt/java-MyApp/bin/java, please wait...
Error attaching to core file: Doesn't appear to be a HotSpot VM (could not find symbol "gHotSpotVMTypes" in remote process)
sun.jvm.hotspot.debugger.DebuggerException: Doesn't appear to be a HotSpot VM (could not find symbol "gHotSpotVMTypes" in remote process)
at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:411)
at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305)
at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:156)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:191)
at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.tools.jmap.JMap.runTool(JMap.java:201)
at …Run Code Online (Sandbox Code Playgroud) 我在服务器上检测到 jvm safepoint.log 中的长安全点(> 10 秒!):
6534.953: no vm operation [ 353 0 4 ] [ 0 0 14179 0 0 ] 0
7241.410: RevokeBias [ 357 0 1 ] [ 0 0 14621 0 0 ] 0
8501.278: BulkRevokeBias [ 356 0 6 ] [ 0 0 13440 0 2 ] 0
9667.681: no vm operation [ 349 0 8 ] [ 0 0 15236 0 0 ] 0
12094.170: G1IncCollectionPause [ 350 0 4 ] [ 0 0 …Run Code Online (Sandbox Code Playgroud) 我正在研究java对象头的组成。
发现了一些文档和一些有趣的问题。
64位vm下,默认对象头如下(因为UseCompressedOops默认是开启的)
|------------------------------------------------- -------------------------------------------------- -----------|--------------------| | 对象头(96 位)| 状态 | |------------------------------------------------- -------------------------------|------------------- -----------|--------------------| | 标记字(64 位) | 类字(32 位) | | |------------------------------------------------- -------------------------------|------------------- -----------|--------------------| | 未使用:25 | identity_hashcode:31 | cms_free:1 | 年龄:4 | 偏向锁:1 | 锁:2 | OOP 到元数据对象 | 正常 | |------------------------------------------------- -------------------------------|------------------- -----------|--------------------| | 线程:54 | 时代:2 | cms_free:1 | 年龄:4 | 偏向锁:1 | 锁:2 | OOP 到元数据对象 | 有偏见 | |------------------------------------------------- -------------------------------|------------------- -----------|--------------------| | ptr_to_lock_record | 锁:2 | OOP 到元数据对象 | 轻量级锁定 | |------------------------------------------------- …
试图寻找这个,但我遇到的所有问题/答案都在谈论拥有 2 个幸存者空间的目的。我想了解一般来说拥有幸存者空间的目的。将物体从伊甸园移动到幸存者有什么好处?
在阅读有关 ZGC 的文章时,我注意到它吹嘘自己是“单代垃圾收集器”,但我很少看到有关该术语确切含义的任何详细信息。
我熟悉伊甸园、幸存者空间、托儿所、临终关怀、元空间、permgen、僵尸对象、诺亚方舟和老年之家,所以我不需要解释并发标记清除(CMS GC)或垃圾优先(G1 GC)算法有效。我的理解是,这些都是多代人的,我对此很满意。
就我个人而言,我一直喜欢能够通过 Java Mission Control 并查看对象经历了多少代 GC 周期。这对于解决内存泄漏或 GC 问题总是很有帮助。
那么“单代”垃圾收集器到底是什么?它与当前在 CMS 和 G1 中通过多个垃圾收集周期跟踪对象的方式有何不同?
java ×10
jvm-hotspot ×10
jvm ×8
assembly ×1
c++ ×1
coredump ×1
debugging ×1
disassembly ×1
heap-dump ×1
hotspot ×1
jit ×1
linux ×1
obfuscation ×1
signals ×1