Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] latest NPN and start.jar

Hi,

On Fri, Sep 13, 2013 at 1:22 PM, Eirik Bjørsnøs <eirbjo@xxxxxxxxx> wrote:
>
> Simone,
>
> Just an idea:
>
> How hard would it be to go from the source code patching we do today into a
> runtime byte code weaving approach?

Very very very hard.
I say so because I started exactly with this approach. The first NPN
implementation used ASM to weave the changes in, and I have done
bytecode weaving in the past with ASM, so I'm not a newbie.
It had many disadvantages:
1) very difficult to maintain - ASM code can be pretty obscure.
2) requires a runtime option to the JVM (-javaagent) anyway, so it is
equivalent to specify -Xbootclasspath
3) for some reason, bytecode stack maps where recomputed wrongly by
ASM. This lead to the VM thread going beserk and many JVM crashes.

The moment I switched to the current model, all problems were gone.
Not going back :)

> I'm aware it might take a while before the JDK guys will be able to
> implement standard APIs on which NPN could be implemented.
>
> But how about we asked them to make some minor refactoring in the
> implementation classes which would make weaving in our changes easier for
> us?
>
> I'm finding 16 NPN_CHANGES_BEGIN in the current NPN sources. A lot (most?)
> of these seem to be simple adding of methods and fields or injecting source
> code  at method boundaries.
>
> If Oracle could help us by providing hook methods for the remaining changes,
> then maybe runtime weaving could be possible and we could avoid the
> keeping-in-sync with the JDK madness?

Been there, done that.
The answer from the OpenJDK leaders was that this was not possible before JDK 9.
So we're stuck with what we have.

I am all for improving, and likely your suggestion of using the Attach
API will be implemented, but the current solution is the lesser of all
evils, AFAICT.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top