Java code changes how hot fixes resolve how to implement and debug

Java code changes how to solve? Hot fixes and debugging how to achieve? For the Java language, if it involves code changes, in general, will choose to restart the JVM to fix the problem. However, restarting the mean anomaly will take some time to repair, repair of heat occurs created the possibility for the realization of second-level recovery fault, then gave you explain.

 

Java code changes how hot fixes resolve how to implement and debug

 

 

Hot Fix Java

At present, more fire thermal rehabilitation program is broadly divided into two factions: Ali: DeXposed, andfix: start (C language) from the underlying binary; Tencent Department: tinker: Starting from Java loading mechanism. Today, mainly on Java-based loading mechanism to study the implementation of the hotfix.

Andrews class loader will load a class when the acquired Element start the array itself in DexPathList object (Element [] dexElements) corresponding to the class, after reload. In a for loop, first traversal out of the dex file, and then is to obtain class from dex file, so long as we make good repair class packaged into a dex file, put in the first element of the array Element, so to ensure that the class is the latest to get a good repair class.

Hot Fix implementation steps:

1 to give the dex format patch. Repaired in question Java files (you can modify the code according to the actual situation of the bug); compiles Java files into class files; packaged class files into dex file (dx instruction program).

2, load dex format patch.

3, loading jar, apk, zip format patch. Note that this type of compression package must be placed in a dex file, but also the name is required, must be classes.dex.

Java-debug

Java-debug-tool provides a number of trouble-shot command, but the killer command two, methodTrace and redefineClass.

methodTrace command for rapid problem discovery, can be done without pause JVM debugging methods to acquire information. The basic format:

mt -c -m

Optional parameters: -d -t -i -n -time -u and so on.

redefineClass command can be done without performing restart the JVM class bytecode Alternatively, implementation hot fix. When using the mt command to locate the problem, fix the code if you need rapid on-line, then you can use this command. Using the format command is:

rdf -p [className1:class1Path className1:class2Path]

findClass command, which can be found in the target JVM class you need, and tell your class specific information, such as whether the class is already loaded? If the load, then load the class classLoader which one and so on. This command allows you to not enter the fully qualified name of the class, and allows you to enter a regular expression to match the class.

Java engineers want to be well-paid, you need both theory and practical, and good knowledge base that you learn efficiently, put the premise of combat. If you want to better learning Java programming, you can choose professional learning.

Guess you like

Origin www.cnblogs.com/qianfengzz/p/11573316.html
Recommended