Skip to content

fix(java): ignore non-Scala/Lombok-style default helper methods#3733

Open
mandrean wants to merge 2 commits into
apache:mainfrom
mandrean:mandrean/fix-lombok-default-methods
Open

fix(java): ignore non-Scala/Lombok-style default helper methods#3733
mandrean wants to merge 2 commits into
apache:mainfrom
mandrean:mandrean/fix-lombok-default-methods

Conversation

@mandrean
Copy link
Copy Markdown
Contributor

@mandrean mandrean commented Jun 2, 2026

Why?

When Scala is present on the runtime classpath, Java compatible serializers enable Scala default-value support globally. Plain Java classes generated with Lombok @Builder.Default can contain private helper methods named like $default$imageRelations(), which previously matched the broad Scala default-method scan and caused warning noise during deserialization.

What does this PR do?

  • Restricts Scala default-value method detection to known Scala constructor/apply helper prefixes with numeric parameter suffixes.
  • Ignores non-Scala/Lombok-style $default$ helper names and out-of-range parameter indexes without invoking them.
  • Keeps Scala case-class and regular-class constructor defaults working, including nested/default-value regression coverage.
  • Adds Java fixtures and Scala serializer tests covering Lombok-like helper methods.

Related issues

Closes #3720

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, my PR description includes the required ai_review summary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

N/A. This is a targeted default-method filtering fix and does not change serialization format or hot-path serialization logic.

Validation

  • mvn -T16 -pl fory-core -am install -DskipTests -Dmaven.javadoc.skip=true -Dmaven.source.skip=true
  • mvn -pl fory-core -Dtest=org.apache.fory.platform.AndroidSupportStaticCheckTest#testScalaDefaultValuesDoNotUseTrustedLookupOnAndroid test
  • sbt "+testOnly org.apache.fory.util.ScalaDefaultValueUtilsTest org.apache.fory.serializer.scala.ScalaDefaultValueTest"
  • sbt +test
  • mvn -T16 spotless:check checkstyle:check

@mandrean mandrean requested a review from chaokunyang as a code owner June 2, 2026 14:43
@mandrean mandrean changed the title fix(java): ignore Lombok default helper methods fix(java): Ignore non-Scala/Lombok-style default helper methods Jun 2, 2026
@mandrean mandrean changed the title fix(java): Ignore non-Scala/Lombok-style default helper methods fix(java): ignore non-Scala/Lombok-style default helper methods Jun 2, 2026
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Java] DefaultValueUtils warns on Lombok @Builder.Default classes when Scala is on classpath

2 participants