Parent-delegate AnnotationMatcher in RecipeClassLoader - #8438
Merged
Conversation
`AnnotationService#matches` names `AnnotationMatcher` in its descriptor. Since #8427 shared `org.openrewrite.java.service` with the parent, a recipe-side caller and the host-loaded service resolved that parameter to different classes, so the JVM raised a loader constraint violation on the call.
…d adjusted order.
timtebeek
approved these changes
Aug 10, 2026
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.
Motivation
A recipe run on 8.88.3 fails with a
LinkageErrorthe first timeMissingOverrideAnnotationreachesAnnotationService#matches:AnnotationService#matchesnamesAnnotationMatcherin its descriptor. Share Java service interfaces across the recipe classloader boundary #8427 addedorg.openrewrite.java.servicetoPARENT_DELEGATED_PREFIXES, which moved the service to the host loader whileAnnotationMatcherstayed child-loadable — and a recipe bundle shippingrewrite-javadefines its own copy as soon as the recipe constructs a matcher. The JVM checks that both loaders agree on every type in a method's descriptor at resolution time, finds twoAnnotationMatcherclasses, and refuses the call. Before Share Java service interfaces across the recipe classloader boundary #8427 the service was child-first, so caller and callee shared one copy and nothing broke.MethodMatcheris already in the list for the same reason;AnnotationMatcheris the same shape and was simply missed. It is the only such gap: every other type in aorg.openrewrite.java.servicepublic signature (JavaVisitor,Tree,SourceFile,Cursor,ExecutionContext,J,JContainer,JRightPadded,Span,trait.Comments.Placement,internal.CommentService/NamingService) is already delegated, and no language module subclassesAnnotationService.Summary
org.openrewrite.java.AnnotationMatcherjoinsMethodMatcherandTypeNameMatcherinPARENT_DELEGATED_PREFIXES.Test plan
RecipeClassLoaderTest#matcherTypesInSharedSignaturesShouldDelegateToParentgives both loaders a copy ofAnnotationMatcherandMethodMatcherand asserts each resolves to the parent; verified failing onAnnotationMatcherbefore the fix (MethodMatcheralready passed) and passing after../gradlew :rewrite-core:test --tests "org.openrewrite.marketplace.RecipeClassLoaderTest"passes, 11 tests.Release note
This is a regression introduced in 8.88.3 and affects any recipe reaching
AnnotationService#matchesfrom a recipe bundle, which includesMissingOverrideAnnotation. The Moderne CLI resolves rewrite aslatest.release, so it needs a rebuild once this ships.