How to implement a method in Java replacement or hot replacement rt.jar?

public class Main{
    public staic void main(String[] args){
        System.out.println(Class.forName("a.b.old.C"));
    }
}

Class.forName needs to be changed due to some special requirements, and when using this method, if the package name of the passed class contains a certain path, it will be replaced with another path. For example, the class obtained by Class.forName ("a.b.old.XXX") will be "a.b.new.XXX".

ask me how to achieve the appeal effect, and can not modify the rt.jar

Apr.05,2021

do not use class.forname, use a custom classloader


can be outsourced at Class.forName.

  

first of all, you can't put rt.jar in java_home. If rt.jar can't move, change the environment variable java_home, so that bootstrap classloader can't find rt.jar. Then register a custom classloader to load all the jar packages in java_home. By the way, tamper with rt.jar

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3885f-2c118.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3885f-2c118.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?