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

Remove custom array handling already covered by Class.forName() #4250

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

sormuras
Copy link
Member

@sormuras sormuras commented Jan 17, 2025

Overview

Class.forName() from java.base/java.lang has built-in support for array type names matching:

  • Primitive arrays such as "[I", "[[[[D", etc. and
  • Object arrays such as "[Ljava.lang.String;", etc.

This pull request deletes the redundant implementation from JUnit's internal ReflectionUtils helper.


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

`Class.forName()` from `java.base/java.lang` has
already built-in support for type names matching:
- _Primitive arrays such as "[I", "[[[[D", etc._ and
- _Object arrays such as "[Ljava.lang.String;", etc._

This commit deletes the redundant implementation
from JUnit's internal `ReflectionUtils` helper.
@sormuras sormuras requested a review from sbrannen January 17, 2025 18:09
@sormuras sormuras self-assigned this Jan 17, 2025
Copy link
Member

@marcphilipp marcphilipp left a comment

Choose a reason for hiding this comment

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

Nice find! 👍

@marcphilipp marcphilipp added this to the 5.12.0-M1 milestone Jan 17, 2025
@sbrannen
Copy link
Member

@sbrannen sbrannen changed the title Delete cases covered by Class.forName() Remove custom array handling already covered by Class.forName() Jan 19, 2025
sbrannen added a commit that referenced this pull request Jan 20, 2025
Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

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

Great catch!

It's good to know that Class.forName() handles array names out of the box (in contrast to ClassLoader.loadClass()). 👍

The PR looks good, and I committed 0fe36c7 to ensure we have the necessary test coverage in place.

@sbrannen
Copy link
Member

@sormuras
Copy link
Member Author

Thanks for the reviews and double/triple-checking.

@sormuras sormuras merged commit 2bae68b into main Jan 20, 2025
15 checks passed
@sormuras sormuras deleted the prune-reflection-utils branch January 20, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants