How to make the jvm load my java.lang.String instead of the one in rt.jar

后端 未结 2 1541
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 06:37

I studied java classloader rencently. Now I want to write a class that has the same package name and class name as one of class in rt.jar. For example, write a java.lang.Str

2条回答
  •  北海茫月
    2020-12-18 06:58

    Have a look at the java.lang.instrumentation API: you can implement a ClassFileTransformer which ignores the passed-in byte array and returns a bute array containing your own implementation of java.lang.String instead.

    Better make sure that it's completely binary compatible with the original though or you will not get very far.

提交回复
热议问题