Get True Hot Swap in Java with DCEVM and IntelliJ IDEA

Many developers can barely imagine daily work on large projects without hot-swapping Java classes from the IDE. However, as you know Java HotSwap™ VM has a serious limitation since no structural changes in classes are allowed. This means that you can’t, say, add a new method or a field to a class and perform the hot swapping. The only thing you can actually change during the hot swapping are the method bodies.

Luckily there is a way to improve the situation with the new open-source project Dynamic Code Evolution VM, a modification of Java HotSwap™ VM with unlimited support for reloading classes at runtime.

We have already tested the new virtual machine in a local environment for IntelliJ IDEA project development and can confirm that it delivers significant productivity gains.

The support for Dynamic Code Evolution VM in IntelliJ IDEA is available now for everyone via this new plugin so you can try the true hot swapping by yourself.

Follow these steps to get started with this plugin:

When you enable the plugin, the IDE will offer you to download DCEVM JRE for your environment.

Then, if you want to use this JRE for your run configurations, you have to choose it in the list of alternative JREs.

Now you can enjoy the enhanced hot swapping in your project.

It’s important to note that DCEVM is still a prototype project at the moment and it’s not ready for use in production servers. However, it is of excellent help during development. If DCEVM JEP has enough interest, it may be incorporated into the standard JVM distribution later.

Develop with Pleasure!

This entry was posted in New Features and tagged , . Bookmark the permalink.

55 Responses to Get True Hot Swap in Java with DCEVM and IntelliJ IDEA

  1. Tropper says:

    Or you could buy JRebel. Granted, it’s not cheap – but it’s awesome! :-)

  2. Mike says:

    Would like to see how it compares to JRebel. I can’t really live without JRebel, not sure how I coded in Java so long without it.

  3. Jan says:

    JRebel also does other kinds of hotswapping: Spring, Thymeleaf, …

  4. Mike Heath says:

    In my experience DCEVM runs circles around JRebel. DCEVM modifies the JVM so it does a lot of things that JRebel can’t do.

  5. Alex says:

    How it is better than just downloading, unpacking and running DCEVM jar once to patch the JMV(s)?
    what problem does this plugin solve?

  6. Ivan Dubrov says:

    Where did you guys get your DCEVM binary? It seems like it is based on some version of 1.7, but I can’t see which version exactly. Did you build it yourself or downloaded binary somewhere else?

    Some time ago I had to fork and update DCEVM (both light version and full version) for the company I am working for (there was no version available for the latest Java 7 JDK at the time, plus there were some issues I had to fix), which I currently published at https://github.com/idubrov/DCEVM . Basically, it’s the same sources as in DCEVM Mercurial repository plus bunch of stability related fixes.

  7. Joerg says:

    Is it possible to setup Plugin-dev project with this ?
    The usual “Intellij Platform Pluign SDK” setup only suggests standard JDKs, DCEVM is not listed after installation.

    Can it be achieved by putting e.g. community-version in the classpath and running with DCEVM ?

    Best, J

  8. smart says:

    Dos it support hot swap in Tomcat when using Spring MVC?

    How can I config it?

  9. Andrey Cheptsov says:

    @Alex All problems are handled by DCEVM, the plugin does nothing special except downloading the JRE and it’s setup of run configurations.

  10. Alexander Malfait says:

    Have been using DCEVM for years, it’s a marvel of a thing. I must have saved a hundred hours on restarts by now. It’s very reliable too, 100% recommended!

    Thanks for spreading awareness JetBrains.

  11. Maciej says:

    How to change JRE in which Tomcat will run?

  12. Denis.Zhdanov says:

    Gents,

    Couple of words about DCEVM and IJ DCEVM plugin:
    1. JRebel vs DCEVM – JRebel is a solid commercial tool which is backed by a team of professionals. It provides not only HotSwap alternatives but j2ee containers-specific HotSwap as well. DCEVM is a prototype of a JVM with improved HotSwap. It is created by a single person and doesn’t cover all the cases which arise even during normal j2se HotSwap. That means that JRebel provides more features and is more stable (at least at the moment). However, it’s important to understand that they use very different approaches – JRebel constantly modifies byte code of loaded classes in order to make it eligible for further regular ‘old HotSwap’ but DCEVM patches HotSwap at the JVM level. That means that JRebel approach works with every JVM but is much more complex (it’s necessary to support stuff like reflection and debugging when resulting byte code is very much not the same as the one created by compiler) and more slow. HowSwap patching is fast and efficient but is available only at special JVM at the moment. From my point of view, it’s better to have better HotSwap at JVM level and container-specific hot swapping tools;
    2. The DCEVM binaries provided by the plugin have been built by ourselves from public DCEVM repo. The plugin just eases it’s IJ integration, i.e. a user can just click ‘Download’ link and have the things done automatically;
    3. AFAIK DCEVM repo is not bound to any specific OpenJDK branch and its tags are not bound to OpenJDK repo tags. DCEVM repo has been cloned from java7 branch but I’m not sure about exact details;
    4. @Ivan: I think it’s better to offer your fixes to the DCEVM’s author (Thomas Wuerthinger). He is a very good and easy to deal with guy and I have no doubt that he would accept the fixes;

  13. natros says:

    Not working on CentOS 6.4 64bit :(
    plugins/DCEVM_JRE/bin/java: /lib64/libc.so.6: version `GLIBC_2.14′ not found

  14. Denis.Zhdanov says:

    Sorry, we didn’t test it under CentOS, only windows, mac and linux

  15. metyl says:

    How to use it with app. server eg. tomcat install as normal jre and configure tomcat to use it?

  16. Denis.Zhdanov says:

    We haven’t tested it under servers and, as far as I know, hot swapping is often server-specific. That means that there is a possible case that DCEVM won’t help with them. However, you can try to check it and yes, you just need to configure server process to use that alternative jvm then.

  17. metyl says:

    Denis but how to provide new clasess to DCEVM will IJ do it?

  18. Denis.Zhdanov says:

    DCEVM is a jvm with enhanced HotSwap, that means that no additional setup is required for tools which already know how to work with regular HotSwap. Talking about IJ, you just need to ensure that ‘project settings | debugger | hotswap | reload classes after compilation’ is set to ‘always’ or ‘ask’. Then the ide will do the job each time when you start an application under debug, modify sources and recompile them.

  19. Gauthier JACQUES says:

    Hi Denis,

    I can’t start a plugin run configuration with it. It fails with a ClassNotFoundException on com.intellij.idea.Main

    Any idea why ?

    Thanks

  20. Denis.Zhdanov says:

    I’ve created a small screencast which illustrates DCEVM in action – https://dl.dropboxusercontent.com/u/1648086/video/hotswap.m4v

  21. mgrenonville says:

    Hello !

    First, very nice tool, thanks a lot !
    I patched my JVM with the DCEVM tool, and also use the plugin, but I am unable to remove a super class (or interface) from a class, but i can add parents like a charm.

    Since it’s not a common case for me, it’s ok, but i was wondering if it is normal.

    Thank you !

  22. klikh says:

    I’ve been using DCEVM for IJ run configurations for a while, and I confirm that it really is a time-saver. I think publishing this plugin is a right move which would let DCEVM gain popularity among Java developers. Thanks!

  23. metyl says:

    Thx Denis, now the only feature that we all need is ‘Make project automatically’ working also during run/debug sessions.

  24. Fred says:

    Is it planed to make it work with Intellij Pluign Run/Debug Conf ?

  25. Christian says:

    When trying to use this with a Maven project the DCEVM option doesn’t show up as an available JRE. Is there something that would prevent this from working for Maven projects? Otherwise it works fine with “Application” projects :-)

  26. Denis.Zhdanov says:

    @mgrenonville: ‘Since it’s not a common case for me, it’s ok, but i was wondering if it is normal.’ – well, I’m afraid I don’t have enough information to answer this question but tending to say that that is an expected behavior since DCEVM is a prototype VM which doesn’t cover all the cases.

    @Christian: do you mean that no DCEVM is available at maven IJ run configuration or at Application run configuration at maven-aware IJ project?

  27. Denis.Zhdanov says:

    @Fred: ‘Is it planed to make it work with Intellij Pluign Run/Debug Conf ?’ – we’ll check that use-case shortly

  28. Christian says:

    @Denis.Zhdanov: DCEVM isn’t available at Maven run configuration.
    Just thought I’d give it a try with a “maven based” project I have :-)

  29. Denis.Zhdanov says:

    That’s true, we didn’t add maven run configuration support. Will check that use-case as well

  30. Andreas Steffan says:

    Hallo everybody,

    I have to say I am amazed to realize dcevm efforts are still underway. Even better this beast even seems very helpful today. Last time I checked it seems pretty dead. IMHO it still does when you work your way from the dcevm homepage.

    Anyways, reality seems different. (Un-)fortunatly, the demand for the plugin obviously was high enough for dropbox to disable public links. Try

    https://dl.dropboxusercontent.com/u/62224416/j2re-dcevm-linux64.zip

    Fails with 509 “This account’s public links are generating too much traffic and have been temporarily disabled!” for me.

    Hence, I wondered where to find a decent built for linux64. Googling suggested I might want to try the one at https://github.com/sweetybanana/DCEVM/tree/master/lib ;)

    Will try try that out now setting up things manually.

    cheers
    Andreas

  31. Denis.Zhdanov says:

    Guys,

    Couple of questions about expanding DCEVM support for run configurations over than ‘Application’:
    *) plugin – it’s not possible to make ‘Plugin’ run configuration DCEVM-aware at the moment due to it’s design specifics. We can create corresponding feature request and, if/when it’s proved to be of IJ community interest corresponding changes can be made;
    *) maven – it’s not clear what use-case do you point with maven run configurations – jvm which is used to start maven process? jvm used by maven to launch nested process? something else?

  32. Pavel Arnost says:

    Hi Denis,

    DCEVM JRE for Windows 64-bit (https://dl.dropboxusercontent.com/u/62224416/j2re-dcevm-win64.zip) cannot be downloaded (dropbox says “This account’s public links are generating too much traffic and have been temporarily disabled!”). Can you uploaded it once more please?

    Thanks,
    Regards
    Pavel

  33. Shane Witbeck says:

    When I try downloading from popup event I get:

    DCEVM
    Can’t download DCEVM because of server error

    Any suggestions for a workaround?

    I’m using build 129.961 on Mac 10.8.4

    • rk says:

      Hi,

      Were you able to get a workaround to download the dcevm jre in Mac ?
      I am getting the same error.

      Can’t download DCEVM because of server error ”
      using latest Version:
      12.1.4
      Build:
      129.713

  34. Rob Leland says:

    Will DCEVM work with the OracleJDK ? When I tried it with 1.7u25 IntelliJ indicated that the JDK was corrupt. I am having difficulty finding a recent build of OpenJDK for windows. So far I only see the RI release from 2011.
    Rob

  35. Denis.Zhdanov says:

    @Rob: what do you mean under ‘DCEVM works with OracleJDK’? DCEVM is an OpenJDK repo fork and AFAIK it’s not synced with OpenJDK repo too often

  36. Christian says:

    @Denis.Zhdanov: To launch the developed application. If that requires maven to be started with the same process, so be it. :-)

  37. Fred says:

    can you get DCEVM working with JDK 1.7 64 bits under windows ?

  38. go green says:

    Upon clicking on the download link:
    DCEVM: Can’t download DCEVM because of server error

  39. Jamshid says:

    I tried DCEVM with Spring based Tomcat project, I changed method signature and it is throwing reflection exception:

    java.lang.reflect.GenericSignatureFormatError
    at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:103)
    at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:233)
    at sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:359)
    at sun.reflect.generics.parser.SignatureParser.parseTypeSig(SignatureParser.java:157)
    at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:367)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:181)
    at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations2(AnnotationParser.java:133)
    at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations(AnnotationParser.java:110)
    at java.lang.reflect.Method.getParameterAnnotations(Method.java:751)
    at org.springframework.core.MethodParameter.getParameterAnnotations(MethodParameter.java:283)

  40. To run DCEVM with Tomcat, go to Edit Configurations -> Tomcat -> Startup/Connection -> Debug -> Pass environment variables -> JAVA_HOME = /Users/{you}/Library/Application Support/IntelliJIdea12/DCEVM_JRE

  41. rk says:

    Hi,

    Was any alternative location put for the dcevm jre builds ?
    I am still getting the same error in mac.

    Can’t download DCEVM because of server error ”
    using latest Version:
    12.1.4
    Build:
    129.713

  42. Ben says:

    I’m trying to run DCEVM with Tomcat and get this warning:
    Dynamic Code Evolution 64-Bit Server VM warning: JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable.

    Does anyone know where to set these options?

    • Juan says:

      Bean, i have same error:
      Dynamic Code Evolution 64-Bit Server VM warning: JSR 292 is disabled in this JVM

      anyone could solve it ?

  43. Peter Alexis says:

    Would be great if we can get maven run configuration support. It would help to get jetty:run or tomcat7:run in hotswap mode and I believe web development in Java will be more fun and productive.

  44. Lordmau5 says:

    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    Must use the serial GC in the Dynamic Code Evolution VM

    Process finished with exit code 1

    How to fix this :(?

  45. Jiri Bubnik says:

    Take a look at Hotswap Agent:

    – Framework support – Spring, Hibernate, Logback, Jetty, Tomcat, JSF, …
    – Documentation how to setup DCEVM and precompiled binaries for Java 1.7
    – Load classes and resources from various location (allow reload of classes from dependent project]
    – Open source and free

  46. Claude says:

    See here for latest version https://dcevm.github.io/

  47. I’m trying to use DCEVM with IntelliJ as a replacement for JRebel, and it works very well except one problem — I’m running with Weblogic with exploded war. Problem is that DCEVM can reload whatever I throw at it. But if I ADD a class, then Weblogic cannot load it because class is not copied to exploded war artifact. OK, so I do a make and rebuild artifact. Problem is that this causes Weblogic to do a redeploy of the application, which defeats the whole point of using DCEVM. Compounding this is that I am developing with Groovy, and each closure is a class, so it’s easy to write a line of code and introduce several new .class files. Anyone know a solution to this problem? Either is it possible for IDEA to use hotswap to ADD a class (probably not possible due to how classloaders work), or get Weblogic to be able to load new classes without triggering a whole redeploy?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">