feat: @ExternalType adapter generator for provided-style extensions#831
Open
jbachorik wants to merge 14 commits intojb/configurationsfrom
Open
feat: @ExternalType adapter generator for provided-style extensions#831jbachorik wants to merge 14 commits intojb/configurationsfrom
jbachorik wants to merge 14 commits intojb/configurationsfrom
Conversation
- integration-tests/.../RuntimeTest.java:802 — remove duplicate 1s Thread.sleep after the flush sleep (second block had no independent purpose and only added dead time). - docs/README.md — normalize Markdown links to the actual on-disk PascalCase filenames (GettingStarted, OnelinerGuide, QuickReference, BTraceTutorial, Troubleshooting, FAQ) so they resolve on case-sensitive filesystems; fix the "pattern-1-method-entrye xit-timing" anchor typo to "pattern-1-method-entryexit-timing". - btrace-client/.../Client.java — fail-fast with IllegalArgumentException when pass-through system-property values (btrace.feature.manifestLibs, btrace.system.appendJar, btrace.allowExternalLibs, btrace.test.skipLibs) contain ',' rather than letting the comma-delimited agentArgs silently split the value into stray args. Co-Authored-By: muse <muse@noreply>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cessor Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…apter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… stubs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ethods Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cation Add RunnableResult + compileAndLoad() to CompileTestHarness so compiled classes can be loaded and invoked; add generatedAdapterInvokesRealMethod test that exercises the full findVirtual + MethodHandle.invoke pipeline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… api source set Wire btrace-extension-processor as an automatic apiAnnotationProcessor dependency in BTraceExtensionPlugin so extension authors get adapter generation for free. In-tree builds use the sibling project reference; external consumers resolve the published Maven artifact by version. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…atestSupported Apply Types#erasure() to return and parameter types in buildSpec() so that parameterized types like List<String> produce raw-type literals (List.class) in generated adapter source instead of the invalid List<String>.class form. Replace @SupportedSourceVersion(RELEASE_8) with getSupportedSourceVersion() returning SourceVersion.latestSupported() to eliminate the javac warning on JDK 11+. Adds a test covering both parameterized-type cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Rationale
Provided-style extension impls (introduced in #791) currently reach into application types via hand-written
MethodHandleCacheadapters. That works but has three ergonomic costs:mh.findVirtual(cls, "jobId", int.class)is not refactor-safe and IDE tooling can't check it.static final MethodHandlefields fail extension init if the target class isn't yet visible on TCCL.try/catch, type wiring, and cache plumbing.Solution
@ExternalType("com.example.app.Real")on an interface + a build-time annotation processor → generated$Extadapter with typed static dispatchers, per-method lazyvolatile MethodHandleresolution, and no cache lookup on the warm path.Quick Start
Declare the interface in the extension's
apisource set:Use the generated adapter from the impl:
The
org.openjdk.btrace.extensionGradle plugin auto-registers the processor on theapisource set — no extra wiring needed.See the migrated
btrace-sparkexample (btrace-extensions/examples/btrace-spark/src/impl/java/.../SparkApiImpl.java) for a before/after in a real extension.Scope
In v1:
@ExternalType.Staticfor statics)MethodTypeliteralsNot in v1 (use
ClassLoadingUtil/MethodHandleCachedirectly):instanceof/checkcaston external types@ExternalTypereferencesTest Plan
@Statictargeting (ExternalTypeAnnotationTest)ExternalTypeProcessorTest.generatesAdapterForAnnotatedInterface)generatedAdapterContainsDispatchersForEachMethod)virtualDispatcherUsesLazyMethodHandle)staticDispatcherUsesTccl)generatedAdapterInvokesRealMethod)rejectsAnnotationOnClass,rejectsEmptyValue)generatedAdapterHandlesParameterizedTypes)MethodHandleCacheto@ExternalType— builds end-to-end through the Gradle plugin🤖 Generated with Claude Code
This change is