Skip to content

Scala: pass -parameters to javac in joint compilation#7449

Merged
knutwannheden merged 1 commit intomainfrom
claude/verify-scala-parameters-flag-z8ljh
Apr 22, 2026
Merged

Scala: pass -parameters to javac in joint compilation#7449
knutwannheden merged 1 commit intomainfrom
claude/verify-scala-parameters-flag-z8ljh

Conversation

@knutwannheden
Copy link
Copy Markdown
Contributor

@knutwannheden knutwannheden commented Apr 22, 2026

Motivation

The rewrite-scala build excludes **/*.java from compileJava and feeds Java sources into compileScala for Zinc joint compilation. As a result, the -parameters flag that the java-base convention plugin applies to JavaCompile tasks never reaches javac for this module, so compiled .java classes lacked the MethodParameters attribute and lost their parameter names in bytecode.

Summary

  • Add -parameters to compileScala's options.compilerArgs so Zinc forwards it to javac during joint Java/Scala compilation.

Test plan

  • ./gradlew :rewrite-scala:clean :rewrite-scala:compileScala
  • javap -p -v on compiled classes under rewrite-scala/build/classes/scala/main/ shows the MethodParameters attribute with original source-level names (e.g. Assertionsbefore, spec, scalaSources; ScalaParsersourceCode, sources, relativeTo, path) rather than synthetic arg0/arg1.

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.
@knutwannheden knutwannheden force-pushed the claude/verify-scala-parameters-flag-z8ljh branch from 0ce9154 to c8937f2 Compare April 22, 2026 06:14
@knutwannheden knutwannheden changed the title rewrite-scala: pass -parameters to javac in joint compilation Scala: pass -parameters to javac in joint compilation Apr 22, 2026
@knutwannheden knutwannheden merged commit f1c3611 into main Apr 22, 2026
1 check passed
@knutwannheden knutwannheden deleted the claude/verify-scala-parameters-flag-z8ljh branch April 22, 2026 06:15
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant