Repository navigation
Conversation
javac 21 writes nameless MethodParameters entries for synthetic and mandated parameters (JDK-8292275), which crash D8 older than 8.1 with a NullPointerException. Remove the attribute from the main Java classes of published modules after compiling, restoring the javac 17 output. Fixes #6355 Co-Authored-By: Claude Opus 5.5 <[email protected]>
📲 Install BuildsAndroid
|
|
Closing for now since the impact of the issue seems to be small |
|
PR shepherd — head
All 4 failing jobs run with the Actions: none. This needs a decision about the change itself (for example, keep the stripping limited to published or non-Spring modules), so I didn't re-run or push anything. |
📜 Description
Removes the
MethodParametersattribute from the Java classes of every published module, right afterJavaCompileruns. The newStripMethodParametersaction inbuild-logicuses ASM 9.9 (the version AGP already brings) to rewrite only the class files that have the attribute. TheJdkTargetConventionplugin attaches it to everyJavaCompiletask of modules that applycom.vanniktech.maven.publish, including the Androidcompile*JavaWithJavactasks.No published module compiles with
-parameters, so the attribute only holds the nameless entries javac 21 adds. Removing it loses nothing, and the output matches what javac 17 produced for 8.61.0. Kotlin output is unaffected.The publish gate is necessary: the action removes all entries, also the named ones that
-parameterswrites. The Spring Boot samples do apply the Spring Boot Gradle plugin, which adds-parameters, and Spring resolves handler and bean parameters by name at start-up. A commit on this branch that ran the action on every module broke the 4 kafka-profile Spring system tests, because the sample apps did not start. TheStripMethodParametersKDoc now records that constraint.💡 Motivation and Context
Since the move to a JDK 21 toolchain in #6242, javac writes
MethodParametersentries without a name for synthetic and mandated parameters, such as bridge methods (JDK-8292275). D8 older than 8.1 (AGP 8.0 and older) crashes on them withNullPointerException: Cannot invoke "String.length()", so release builds of those apps fail on 8.61.1. React Native reverted its bump in getsentry/sentry-react-native#6931 because of this.💚 How did you test it?
Built with a JDK 21 toolchain and checked the classes with
javap -v:MethodParameterssentry-8.61.1.jarsentryjar from this branchsentry-android-coreAAR from this branch--rerun), with configuration cache enabled.spotlessApply apiDumpproduced no changes to the.apifiles.ASM changes nothing else. The same pipeline was run twice over all 781 classes of
sentry-8.60.0.jar: once as the stripper, once as a pure round trip that keepsvisitParameter. Comparing sortedjavap -p -v -coutput of input and output, 5 of 781 classes differ, and only because ASM drops an emptyLocalVariableTablefrom synthetic switch-map initializers. Constant pool indices, code, frames, line numbers, signatures and annotations stay the same. The byte-level diff is larger, but that is attribute order only. On JDK 21 test classes (enum, inner class, bridge method, record), the stripper removes theMethodParametersblocks and nothing else.Published test code is safe. Published modules hold 6 Java test files (vendored gson tests and generated Apollo classes); the rest of the test sources are Kotlin.
:sentry-apollo:testand:sentry:test --tests "*vendor*"pass with the action attached to the test compile tasks.Samples keep their parameter names. After a clean rebuild,
sentry-samples-spring-boot-jakartaPersonControlleragain has itsMethodParametersblocks with the real names (personService,id).The
MethodParametersstring can stay in the constant pool of rewritten classes, because theClassWritercopies it from the reader. Check for the attribute withjavap -v, not grep.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
MethodParametersattribute again, or that dexes the artifacts with an old D8.build-logictest for the ASM round trip, so a future ASM upgrade cannot change bytecode unnoticed.🤖 Generated with Claude Code