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
You can do this using the -Xbootclasspath/p option at JVM startup:
-Xbootclasspath/p
-Xbootclasspath/p:/path/to/yourimpl.jar
/p stands for "prepend".
/p
Note: -Xbootclasspath isn't a standard java option, so JVMs by different vendors may not support it.
-Xbootclasspath