Skip to content

Instantly share code, notes, and snippets.

@robshep
Last active July 7, 2018 22:33
Show Gist options
  • Save robshep/7904bd75b69a7634bece9c347b917a3d to your computer and use it in GitHub Desktop.
Save robshep/7904bd75b69a7634bece9c347b917a3d to your computer and use it in GitHub Desktop.
Hotswap Agent for JVM on MacOS

DCEVM

A JVM patched with DCE hotswap capabilities.

https://github.com/dcevm/dcevm/releases

Download latest release - this pertains to a specific JVM release.

Specific JVM version

Java SE Development Kit E.g. 8u172

Current versions from: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Archived versions from: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html

Hotswap Agent

http://hotswapagent.org/

Download latest from: https://github.com/HotswapProjects/HotswapAgent/releases

Install

  1. Install JVM
  2. Run DCE installer as root: sudo java -jar DCEVM-8u172-installer.jar
  3. Find the jre directory for the JVM installed in step 1. /Library/Java/JavaVirtualMachines/jdk-1.8.0_172/Home/jre
  4. Install as alternate JVM
  5. Copy Hotswap agent jar to somewhere suitable E.g. $HOME/lib/hotswap-agent/hotswap-agent-1.3.0.jar
  6. make a symlink for $HOME/lib/hotswap-agent/hotswap-agent-current.jar
  7. Run applications using: -XXaltjvm=dcevm -javaagent:${HOME}/lib/hotswap-agent/hotswap-agent-current.jar
  8. Copy https://github.com/HotswapProjects/HotswapAgent/blob/master/hotswap-agent-core/src/main/resources/hotswap-agent.properties to src/main/resources/hotswap-agent.properties
  9. Edit hotswap-agent.properties autoHotSwap=true

More a. (spring-boot) use <jvmArguments> in the spring-boot maven plugin config to add the above VM arguments

Test installation

Run the following command line:

/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin/java \
    -XXaltjvm=dcevm \
    -javaagent:${HOME}/lib/hotswap-agent/hotswap-agent-current.jar \
    -version

And you should see the following output, look specifically for the Dynamic Code Evolution output.

HOTSWAP AGENT: 10:30:04.621 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent {1.3.0} - unlimited runtime class redefinition.
HOTSWAP AGENT: 10:30:05.475 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [Hotswapper, JdkPlugin, AnonymousClassPatch, ClassInitPlugin, WatchResources, Hibernate, Hibernate3JPA, Hibernate3, Spring, Jersey1, Jersey2, Jetty, Tomcat, ZK, Logback, Log4j2, MyFaces, Mojarra, Omnifaces, Seam, ELResolver, WildFlyELResolver, OsgiEquinox, Owb, Proxy, WebObjects, Weld, JBossModules, ResteasyRegistry, Deltaspike, GlassFish, Vaadin]
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Dynamic Code Evolution 64-Bit Server VM (build 25.71-b01-dcevmlight-14, mixed mode)
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-XXaltjvm=dcevm -javaagent:${user.home}/lib/hotswap-agent/hotswap-agent-current.jar -Dspring.profiles.active=dev</jvmArguments>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment