Can't make automatic hotswap work with JRuby

85 views
Skip to first unread message

Matias Käkelä

unread,
Dec 10, 2014, 4:34:21 AM12/10/14
to hotswa...@googlegroups.com
Hi,

For some reason I can't find a way to make automatic hotswap to work (or alternatively I understand the feature wrong). 

I have autoHotswap=true, autoHotswap.port=8000 and I'm passing -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 from CLI to JVM.

Now, when I go edit & compile a normal Java class no changes become visible. However, when I connect my IDE directly to 8000 and use its debugger-based Hotswap method, changes are seen.

I also see that DCEVM is loaded: jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Dynamic Code Evolution 64-Bit Server VM 1.7.0_71-b14 [darwin-x86_64]

FWIW, as you can see, we are using JRuby. 

During app boot some errors are displayed, though I'm not sure if they are really connected to this at all:

HOTSWAP AGENT: 11:15:28.540 DEBUG (org.hotswap.agent.command.impl.SchedulerImpl) - Executing executeCommand: initClassLoader(org.jruby.util.ClassCache$OneShotClassLoader@73364146)
Exception in thread "Thread-1" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.remove(HashMap.java:940)
at org.hotswap.agent.command.impl.SchedulerImpl.processCommands(SchedulerImpl.java:84)
at org.hotswap.agent.command.impl.SchedulerImpl.access$100(SchedulerImpl.java:16)
at org.hotswap.agent.command.impl.SchedulerImpl$2.run(SchedulerImpl.java:119)

Then again, I'm seeing hotswapper and WatchHandler starting ok:

HOTSWAP AGENT: 11:26:28.357 DEBUG (org.hotswap.agent.annotation.handler.WatchHandler) - Registering resource listener on classpath URI file: [REDACTED]
...
HOTSWAP AGENT: 11:26:48.019 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.hotswapper.HotswapperPlugin' initialized in ClassLoader 'sun.misc.Launcher$AppClassLoader@7756c69c'.

Any ideas how to proceed?

Thanks!




Matias Käkelä

unread,
Dec 11, 2014, 3:16:58 AM12/11/14
to hotswa...@googlegroups.com
After some experimenting and tracing I managed to find out that the stack trace above was indeed the culprit. I managed to "fix" it by changing synchronizedMap into a ConcurrentHashMap in SchedulerImpl. However, I have no idea does that create other problems. So far it seems that everything is working okay.

Jiří Bubník

unread,
Dec 30, 2014, 4:47:53 AM12/30/14
to Matias Käkelä, hotswa...@googlegroups.com

Hi,

 

Thank you for the info. I really can’t see from the source code how the ConcurrentModificationException may occur. The only access to scheduledCommands is from the same class and is always in synchronized block. Your change should work fine though, the only problem may be that instead of concurrent exception, command is not mearged and is executed twice. I have added the change to master branch. Still - there remains some issue I don’t understand.

 

Regarding your setup – autoHotswap.port=true should be sufficient for normal setup (Internally this uses java Instrumentation API and not the JPDA). You need to use autoHotswap.port=8000 only for special use case.

 

Jiri

--
You received this message because you are subscribed to the Google Groups "HotswapAgent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hotswapagent...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages