Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Pattern Matching for instanceof in AnnotationWriter #32550

Conversation

alidandach
Copy link
Contributor

This enhancement leverages Java 16's pattern matching for instanceof to streamline and improve the readability of type checking and casting within the annotation processing method. By replacing explicit casting after instanceof checks with pattern variables, the code becomes more concise, readable, and less prone to errors.

Key Changes:

  • Utilize pattern matching for instanceof to eliminate the need for manual casting of array types (e.g., byte[], boolean[], short[], char[], int[], long[], float[], double[]).
  • Enhance code maintainability and readability by reducing boilerplate and leveraging Java's type inference within control flow blocks.
  • Ensure backward compatibility by maintaining the logic and functionality of the annotation processing while adopting modern language features for better code quality.

This update not only adopts the latest Java language features for better development practices but also sets a precedent for future code enhancements and refactoring efforts, promoting a more modern and efficient coding style within the project.

@alidandach alidandach changed the title Implement Pattern Matching for instanceof in Annotation Processing Implement Pattern Matching for instanceof in AnnotationWriter Mar 28, 2024
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 28, 2024
@snicoll
Copy link
Member

snicoll commented Mar 29, 2024

@alidandach going forward, please refrain from submitting PRs that are about stylistic changes as I've shared already with you we prefer to do those ourselves. The class you've changed is part of ASM, and the following is our policy on such classes.

Please refrain from modifying classes under org.springframework.asm, org.springframework.cglib, and org.springframework.objenesis. Those include repackaged forks of the third-party libraries ASM, CGLIB, and Objenesis. Any refactoring to those classes should take place upstream in the originating repository. The Spring Framework will then pick up the changes when syncing with official updates of the forked third-party libraries.

@snicoll snicoll closed this Mar 29, 2024
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 29, 2024
@alidandach alidandach deleted the enhancement/pattern-matching-instanceof branch April 9, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants