Skip to content

refactor: use pattern matching instanceof (Java 16+)#3192

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:feature/java17-instanceof
Jun 26, 2026
Merged

refactor: use pattern matching instanceof (Java 16+)#3192
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:feature/java17-instanceof

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Migrate remaining old-style instanceof checks with explicit casts to Java 16+ pattern matching instanceof
  • 2 files updated: PingSerializerExampleTest (1 cast pattern), ActorDocTest (3 cast patterns)
  • Most of the codebase already uses pattern matching instanceof; remaining instanceof checks are pure boolean tests (no cast needed)

Test plan

  • Existing tests pass (behavior-preserving refactoring)
  • sbt javafmtAll passes with JDK 17

Motivation:
Java 16 introduced pattern matching for instanceof, eliminating the need
for explicit casts after type checks.

Modification:
Replace old-style instanceof checks with explicit casts in
PingSerializerExampleTest and ActorDocTest. Most of the codebase
already uses pattern matching instanceof.

Result:
Cleaner code without redundant cast expressions.

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@He-Pin He-Pin merged commit 51d64ff into apache:main Jun 26, 2026
9 checks passed
@He-Pin He-Pin deleted the feature/java17-instanceof branch June 26, 2026 08:23
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.

2 participants