Repository navigation
Add switchable Byte Buddy engine alongside Javassist - #18
Open
martinaldrin wants to merge 1 commit into
Open
martinaldrin wants to merge 1 commit into
martinaldrin wants to merge 1 commit into
Conversation
Proxy can now generate its proxies with either Javassist or Byte Buddy. Javassist stays the default and its code path is unchanged. Select the engine with -Dproxy.engine=javassist|bytebuddy, or at runtime with ProxyConfiguration.setEngine/setThreadEngine/callWithEngine. The public API is untouched: no existing test file was modified, and the whole suite now runs twice, once per engine, from a second surefire execution. 222 tests pass on both engines on JDK 11, 17, 21 and 26. Design notes: - The engine is behind a ProxyEngineFactory SPI, resolved lazily by ProxyEngineProvider, so byte-buddy classes are never loaded unless the byte-buddy engine is actually selected. - The earlier attempt at byte-buddy support used InvocationHandlerAdapter, which cannot reach the original implementation and therefore broke Invocation.invoke(). This uses MethodDelegation with @supermethod(nullIfImpossible = true) instead, which is the direct equivalent of javassist's proceed method. - Proxy classes are named into the proxied type's package and defined via MethodHandles.privateLookupIn, so package private types, interfaces and methods keep working. Class injection is only a fallback. - The per instance interceptor stack lives in a private synthetic field. It must not be public, or Util.isClassSafeFromPublicVariableProblems would silently refuse mdcLogging and recursiveIntercept on a proxy. - Generated classes are shared through a byte-buddy TypeCache keyed on type names only. Without it every proxy instance got its own class: 5000 proxies cost 3219 loaded classes, now it is 1218.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proxy can now generate its proxies with either Javassist or Byte Buddy. Javassist stays the default and its code path is unchanged.
Select the engine with -Dproxy.engine=javassist|bytebuddy, or at runtime with ProxyConfiguration.setEngine/setThreadEngine/callWithEngine.
The public API is untouched: no existing test file was modified, and the whole suite now runs twice, once per engine, from a second surefire execution. 222 tests pass on both engines on JDK 11, 17, 21 and 26.
Design notes: