Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

any method to change/instrument class loaded in bootclassloader in latest sun jre

Tags:

java

needs: we need to hack one class in plugin.jar, in detail, change one class's non static method's detail implementation. as in latest jre , -Xbootclasspath/p doesn't work and only -Xbootclasspath/a works. also we don't want to change whole jre.

We know our last solution is to change the plugin.jar file directly. But want to know if there is some better solution which don't need to change the jar file directly.

for example, don't know if things like JVMTI or JVMPI will work? OR somehow change JVM's imple in an easy way?

like image 319
Ben Xu Avatar asked Apr 03 '13 09:04

Ben Xu


1 Answers

depends on your class, but you could probably use a javaagent to inject a custom ClassFileTransformer that loads a different class, if queried... (simple example on javaagents). But this only works, if the class was not loaded before...

like image 111
wrm Avatar answered Sep 21 '22 07:09

wrm