New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a version of HotSwapper that uses the Instrumentation package #119
Comments
This idea sounds interesting. The best way seems to include your RedefineClassAgent in the main source tree but, to do that, we need to resolve a copyright issue. Can you change the copyright notice into MPL/LGPL/Apache triple? If your organization does not allow it, I'll reimplement your class, though. I hope your organization does not care about looking at your code when I write my own. :-) |
Sure, no worries. You are half the reason I published this in the first place :) Though from what I gather, BSD 3-clause license is compatible with LGPL and Apache, and I believe MPL as well so you should be good to go as is. I'd rather have a short comment at the top instead of a complicated 500 line one :P I'll let you decide if including that file or writing one that more tightly integrates with javassist is best. I know that |
Thanks. The reason I asked to change the license is that some organizations (their lawyers) require the software explicitly states its license is Apache. I know BSD is compatible to LGPL/AP but some lawyers do not believe so. |
No problem. Just so I understand, would a simple Apache license be enough? Or does "triple license" mean all three? |
For consistency, triple license is preferable. I know it's ugly but this is a legal issue. |
I relicensed it. It's now MIT for general use (even less restrictive), but also can be used by the three licenses referenced in HotSwapper.java. For inclusion in javassist you have our permission to remove the reference to MIT and match the licensing of the rest of javassist. |
This I highly interesting and I can see several use cases for this.
Do you have any ideas how I could get something like this to work where instead of hotSwapping Strings with code that I could hotswap something like a MethodHandler on existing classes Use case:
(+points if it possible to achieve this without tools.jar, it not that different to ProxyFactory in javassist) |
I wrote javassist.util.HotSwapAgent.java, which is based on your RedefineClassAgent, and committed it (d5ea684) mainly for licensing and backward compatibility. Anyway thank you for your contribution! |
It looks great! Glad you found this useful :) |
Class bytecode redefinition at runtime is a very powerful concept. javassist's
HotSwapper
is a good way to accomplish this, but it has serious drawbacks. It works in our testing environment, but causes a JVM freeze in our production highly multithreaded high load environment. We suspect that this is because the debug agent thatHotSwapper
depends on has thread safety issues; in fact we have to disable it on some of our machines because we saw a problem in its class loading hooks.Java comes with
Instrumentation.redefineClasses
that can do the same job without involving the debug agent.This method works great in our production environment. I know it's not very well documented on the web, so I published a writeup and short class that implements the approach here: https://github.com/turn/RedefineClassAgent
This class already works well with javassist, but it might be handy for the javassist user base to have that approach bundled with javassist. Maybe a
HotSwapper2
?The text was updated successfully, but these errors were encountered: