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

后端 未结 2 1542
佛祖请我去吃肉
佛祖请我去吃肉 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 07:07

    You can do this using the -Xbootclasspath/p option at JVM startup:

    -Xbootclasspath/p:/path/to/yourimpl.jar
    

    /p stands for "prepend".

    Note: -Xbootclasspath isn't a standard java option, so JVMs by different vendors may not support it.

提交回复
热议问题