Scala: pass -parameters to javac in joint compilation#7449
Merged
knutwannheden merged 1 commit intomainfrom Apr 22, 2026
Merged
Scala: pass -parameters to javac in joint compilation#7449knutwannheden merged 1 commit intomainfrom
-parameters to javac in joint compilation#7449knutwannheden merged 1 commit intomainfrom
Conversation
The build excludes **/*.java from compileJava and instead feeds Java sources into compileScala, which means the -parameters flag applied to JavaCompile by the java-base convention plugin never reaches javac for this module. Add -parameters to the ScalaCompile task's options.compilerArgs so Zinc forwards it during joint Java/Scala compilation, keeping method parameter names in the emitted bytecode.
0ce9154 to
c8937f2
Compare
-parameters to javac in joint compilation
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
The
rewrite-scalabuild excludes**/*.javafromcompileJavaand feeds Java sources intocompileScalafor Zinc joint compilation. As a result, the-parametersflag that thejava-baseconvention plugin applies toJavaCompiletasks never reachesjavacfor this module, so compiled.javaclasses lacked theMethodParametersattribute and lost their parameter names in bytecode.Summary
-parameterstocompileScala'soptions.compilerArgsso Zinc forwards it tojavacduring joint Java/Scala compilation.Test plan
./gradlew :rewrite-scala:clean :rewrite-scala:compileScalajavap -p -von compiled classes underrewrite-scala/build/classes/scala/main/shows theMethodParametersattribute with original source-level names (e.g.Assertions→before,spec,scalaSources;ScalaParser→sourceCode,sources,relativeTo,path) rather than syntheticarg0/arg1.