"Go" Java hot deployment, that is to see the change

Source: Internet
Author: User
Tags java web

When writing Java code Packaging deployment is a very headache, it is to crack down on the morale of writing code, DECVM use can be very good to improve the efficiency of the development of self-test, especially web class applications. A collection of Java middleware team and Alibaba team two blogs, for this use of the introduction, I hope to do Java Web development can use a bit hehe.

----------------------------------------------------------------------------------------

about HotSwap (the patch's URL http://ssw.jku.at/dcevm/)

HotSwap is a Java Virtual machine patch that allows unrestricted modification of the loading class file in Run state. The dynamic loading mechanism of the current Java Virtual machine only allows the method body of the class to be modified, but after the HotSwap patch, you can add, remove, and even change the parent class of the class.

The HotSwap patch is based on the GPL v2.0 open source protocol. You can download the HotSwap patch source or executable file via Windows,linux,mac os.

installation HotSwap

Warning : The patch is still in the experimental phase. When the patch is used to debug Java programs, it is fairly stable. However, we do not advocate the use of this patch in a production environment.

Now offers a bit, a bit of Windows virtual machine , the bit Mac OS (from here), and the patch for Linux virtual machines . All modifications are based on the jdk7-b102 version. setup dcevm-0.2-win.jar (5.6 MB) Dcevm-0.2-mac.jar (6.0 MB) Dcevm-0.2-linux.jar (5.8 MB)

The patch not only hits the Java7, but also works on Java 6.

In the Windows startup Installer, in the console, enter:
> Java-jar Dcevm-0.2-win.jar

Start the installer on Mac OS, terminal input:
$ sudo java-jar Dcevm-0.2-mac.jar

Start the installer on Mac OS, terminal input:
$ sudo java-jar Dcevm-0.2-linux.jar

The installer will replace the Java Bin/client/jvm.dll and Bin/server/jvm.dll, and then back up the Jvm.dll to the appropriate directory. Dcevm.jar will also be added to the lib/ext/directory.

Figure I: HotSwap patch installation interface.

After you execute the above command, you will find a diagram interface, select the Java directory where you want to install the patch, and click Install.

Ps: If your Linux does not have a graphical interface, you can download the already patched Java from here.

Use HotSwap Debugging Java program

Start the Java program in debug mode with the modified Java first. Connect to the Java process using eclipse (or you can start in debug directly in Eclipse) any modifications to the class file that are now under the Eclipse project will be reflected directly into the Java program.

HotSwap in Taobao

To our delight, Taobao developers have a strong interest in the technology, and currently have the following team to use the Patch: Mytaobao development team, TDDL (Rtools) development team, HSF development team, trading center and other teams.

------------------------------------------------------------------------------------------------

At present, the international station is still mainly in several applications, one application of more than three hundred thousand or four hundred thousand lines of code. Almost all of the product lines have code in this application, branching development, the code to be changed may have to check out the entire project code.

Such a large project, the impact of development efficiency is very large, compile for 10 minutes, start for 5 minutes. The agony of waiting is a waste of time, on the other hand, it interrupts the rhythm of development. In the development process, each modified a little content, it is necessary to compile the project, restart the application to verify. Every developer will have to restart frequently, and the amount of waste is huge.

Of course, the key to solving the big application is to split the small application according to the function, the international station is also actively in progress.

Hot swap allows changes to the source file to take effect immediately when debug, reducing the number of compilations and reboots, and saving development time waste.

The default hot swap mechanism for Java virtual machines only allows you to modify the method body of the class, which is too restrictive.

DCE (The Dynamic Code Evolution VM) is a Java Virtual machine patch that allows unrestricted modification of the loading class file in run state, namely, the enhancement of hot swap. After using DCE, you can add and remove properties of classes and methods to change the parent class of a class

Such a strengthening, fully meet the normal development needs. DCE is based on the GPL v2.0 open source protocol. You can download DCE source code or executable files through the Windows,linux,mac OS.

The following records the problems encountered in DCE and the resolution of DCE mentioned on the Internet. DCE Note

Under Linux, DCE currently supports only 32-bit JVMsand does not support 64-bit JVMs.

There is a compatibility issue with JDK 1.6 update 26, using JDK 1.6 update.

# See the official website Http://ssw.jku.at/dcevm/binaries/'s instructions.

problem and its solution method

The following is a summary and summary of the issues gathered and the solutions that were collected during the integration of DCE in an international station development environment.

1. The jar bundle conflict with ASM, cglib-related.

Abnormal:

caused by:java.lang.nosuchmethoderror:org.objectweb.asm.classwriter.<init> (Z) V at Net.sf.cglib.core.debuggingclasswriter.<init> (debuggingclasswriter.java:47) at Net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter (defaultgeneratorstrategy.java:30) at Net.sf.cglib.core.DefaultGeneratorStrategy.generate (defaultgeneratorstrategy.java:24) at Net.sf.cglib.core.AbstractClassGenerator.create (abstractclassgenerator.java:216) at Net.sf.cglib.core.KeyFactory $Generator. Create (keyfactory.java:145) at the Net.sf.cglib.core.KeyFactory.create (keyfactory.java:117) at Net.sf.cglib . Core. Keyfactory.create (keyfactory.java:108) at Net.sf.cglib.core.KeyFactory.create (keyfactory.java:104) at Net.sf.cglib . Proxy. Enhancer.<clinit> (enhancer.java:69) at Org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory (cgliblazyinitializer.java:117) at Org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate ( CGLIBPROXYFACTORY.JAVA:43)

See Jira Http://kenai.com/jira/browse/DCEVM-4 of DCE

Cause: The Dcevm.jar file contains an ASM class, the older version, and the first load. ( Agan finds this problem and gives a workaround for renaming the package name)

Workaround 1:

Rename the ASM package name in the Dcevm.jar file and rename it from Org.objectweb.asm to Dce.org.objectweb.asm.

# Rename the package name on the jar file using the tool: Jarjar (http://code.google.com/p/jarjar/).

Workaround 2:

ASM, Cglib replaced with a new version: asm-3.3.1. jar, cglib-nodep-2.2. Jar.

ASM, cglib each version match note points:

ASM 1.5.3.jar Matching Cglib-2.1.3.jar

Asm-2. X.jar Asm-3.x.jar Matching Cglib-nodep-2.1_3.jar

2. The dynamically added static property, such as private static String ATTRIB1 = "X", shows that ATTRIB1 is null when invoked.

3. In an ongoing cycle, the change may not be effective. For example:

public static void Main (string[] args) {for
       (int i = 0; i < 10000; i++) {
           test ();//sleep 1s and print somethi ng
       }
}

Modified to:

public static void Main (string[] args) {for
        (int i = 0; i < 10000; i++) {
            test ();
            SYSTEM.OUT.PRINTLN ("xxx");
        }

XXX is not able to output.

However, changes within the test method body can be effective. For example:

public static void Main (string[] args) {
        System.out.println ("xxx");
        for (int i = 0; i < 10000; i++) {
            test ();
        }
}

5. Crash When running MAVEN test goal with Jmockit

See Jira http://kenai.com/jira/browse/DCEVM-3 of DCE

6. DCEVM Start the error

Must use the serial GC in the Dynamic Code Evolution VM
could not create the Java virtual machine.

Delete the options for the concurrent GC in the Java startup parameters, such as:

-XX:+USECONCMARKSWEEPGC
-xx:+cmsincrementalmode
-xx:+cmsincrementalpacing
-xx: Cmsincrementaldutycyclemin=0
-xx:cmsincrementaldutycycle=10

In development mode, modifying these options does not have a functional impact.

Some reference materials DCE official website http://ssw.jku.at/dcevm/hotswap User manual – Taobao Java Middleware Team blog http://rdc.taobao.com/team/jm/archives/641 Hostswap dcevm– Use introduction http://www.cnblogs.com/redcreen/archive/2011/06/03/2071169.html Dynamic Code Evolution for Java DCEVM Principle http://www.cnblogs.com/redcreen/archive/2011/06/14/2080718.html The thermal deployment of the Java HotSpot DCEVM in debug mode http:// sjsky.iteye.com/blog/907606 Deep Java Debugging system Http://www.ibm.com/developerworks/cn/java/j-lo-jpda1/Java Platform Debugger architecturehttp://java.sun.com/javase/technologies/core/toolsapis/jpda/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.