Get True Hot Swap in Java with DCEVM and IntelliJ IDEA

Posted on by denis.zhdanov

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!

Comments below can no longer be edited.

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

  1. Tropper says:

    July 11, 2013

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

    • Edgar Garza says:

      January 13, 2015

      the fact that every year I need to repurchase software I already bought is frustrating. No other company does this. Usually you buy software once. If you opt in to upgrade – then you buy it again for full price (or maybe an upgrade price, depending on the company). But what you’re paying for then are NEW features – not the same features you already paid for. It would be like Apple or Microsoft disabling your computer each year until you paid for the OS again

      • Jul says:

        May 28, 2015

        I have the same opinion and that’s why I hate companies like those.

      • Julian says:

        May 30, 2015

        So true!

        • Simon S. says:

          May 6, 2016

          That’s obviously a very stupid notion and the last few years have proven that. Subscription models are awesome, and even JetBrains has wisely followed suit.

  2. Mike says:

    July 11, 2013

    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:

    July 11, 2013

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

  4. Mike Heath says:

    July 11, 2013

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

    • Ravshan says:

      February 3, 2014

      very true!

    • Daniel says:

      August 20, 2015

      What does DCEVM do that JRebel cannot? JRebel can do things that DCEVM cannot, but not the other way around.

  5. Alex says:

    July 11, 2013

    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:

    July 11, 2013

    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.

    • Sam says:

      November 4, 2013

      Hi Ivan Dubrov,

      Is DCEVM works with oracle JDK 7u45 64 bit on windows 64 bit?

    • Henrik says:

      December 9, 2013

      Ivan: Here’s how to compile and install: http://neu242.livejournal.com/52962.html

  7. Joerg says:

    July 11, 2013

    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:

    July 11, 2013

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

    How can I config it?

  9. Andrey Cheptsov says:

    July 12, 2013

    @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:

    July 12, 2013

    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:

    July 12, 2013

    How to change JRE in which Tomcat will run?

  12. Denis.Zhdanov says:

    July 12, 2013

    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:

    July 12, 2013

    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:

    July 12, 2013

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

    • rk says:

      September 17, 2013

      Hi,
      Can you please provide the direct download path for jre for mac os x 10.8

      Thanks

    • Johan Boulé says:

      December 1, 2018

      CentOS is linux!

  15. metyl says:

    July 12, 2013

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

  16. Denis.Zhdanov says:

    July 12, 2013

    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:

    July 12, 2013

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

  18. Denis.Zhdanov says:

    July 12, 2013

    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:

    July 12, 2013

    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:

    July 12, 2013

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

  21. mgrenonville says:

    July 12, 2013

    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:

    July 12, 2013

    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:

    July 12, 2013

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

  24. Fred says:

    July 12, 2013

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

  25. Christian says:

    July 12, 2013

    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:

    July 15, 2013

    @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:

    July 15, 2013

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

  28. Christian says:

    July 15, 2013

    @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:

    July 16, 2013

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

  30. Andreas Steffan says:

    July 18, 2013

    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:

    July 18, 2013

    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:

    July 19, 2013

    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:

    July 19, 2013

    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:

      September 17, 2013

      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:

    July 19, 2013

    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:

    July 22, 2013

    @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:

    July 26, 2013

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

  37. Fred says:

    July 28, 2013

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

  38. go green says:

    August 22, 2013

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

  39. Jamshid says:

    August 28, 2013

    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)

    • RUpesh Dhadiwal says:

      March 3, 2016

      After hotswapping spring controller i am also getting same issue with chaging method signature

  40. Michael Driscoll says:

    September 10, 2013

    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

    • Vladimir says:

      November 19, 2013

      Thank you Michael!

      • hadeser says:

        August 16, 2014

        don’t work for me. (idea 13)

  41. rk says:

    September 17, 2013

    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:

    November 19, 2013

    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:

      March 31, 2014

      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:

    November 19, 2013

    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:

    December 1, 2013

    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:

    February 24, 2014

    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:

    May 1, 2014

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

  47. Jason Winnebeck says:

    May 30, 2014

    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?

  48. Payam Rastogi says:

    January 5, 2015

    I had configured DCEVM on intellij, but I think the way I did it is wrong as when I made some change in the java file and ctrl + shift + f9, the tomcat is getting restarted. Can you please tell me the correct way to configure it.

  49. Jafar Sadik says:

    October 5, 2015

    From my experience DCEVM is just awesome and I hope that its functionality will be eventually introduced to standard JVM.

    How to use it:
    a. goto https://github.com/dcevm/dcevm, then click ‘releases’ and choose one that applies to your jdk

    b. run downloaded jar and install alternative jvm dll

    c. in debug mode (either local or remote) just add vm option: -XXaltjvm=dcevm

    You’ re now ready to hot swap most everything in your application.

    Develop with pleasure! 😀

    • zack says:

      September 8, 2016

      can mybatis‘ *mapper.xml be hotswap too?

  50. Anil says:

    December 14, 2015

    I used JRebel first and then DCEVM after my JRebel trial expired. I see JRebel was quick and loads modified class in no time, but when it comes to DCEVM its loading the whole application, spring config, other frameworks part of the application. Any setting we can do with DCEVM just swap class i modified?

  51. Ivan Lagunov says:

    October 20, 2016

    If you encounter the following error:
    Must use the serial GC in the Dynamic Code Evolution VM

    Then you should enable serial GC by:
    – adding the JVM argument -XX:-UseSerialGC
    – removing all ParallelGC JVM arguments

    • Amirtha Rajan says:

      July 2, 2017

      Hi,

      added+ Serial GC -XX:+UseSerialGC
      removed- Parallel GC -XX:-UseParNewGC -XX\:-UseConcMarkSweepGC

      And it worked for me

  52. dorrabuji says:

    June 1, 2017

    This has been the most helpful article I can find on majors! Java programming language is specifically designed to have as few implementation dependencies as possible.

Subscribe

Subscribe for updates