FIX: Add static methods to replace the mutable static final fields#954
Open
uhm0311 wants to merge 1 commit intonaver:developfrom
Open
FIX: Add static methods to replace the mutable static final fields#954uhm0311 wants to merge 1 commit intonaver:developfrom
uhm0311 wants to merge 1 commit intonaver:developfrom
Conversation
jhpark816
reviewed
Sep 2, 2025
| (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, | ||
| (byte) 255, (byte) 255, (byte) 255, (byte) 255 | ||
| }; | ||
| } |
Collaborator
There was a problem hiding this comment.
@uhm0311 @oliviarla @brido4125
매번 객체를 생성하여 사용하고 GC 하는 것 보다, 기존 코드가 나아 보입니다.
Collaborator
Author
There was a problem hiding this comment.
매번 객체를 생성하지 않는 점이 문제가 되는 코드입니다.
AS-IS
ByteArrayBKey.MIN[0] = 10;
System.out.println(ByteArrayBKey.MIN[0]); // 10TO-BE
ByteArrayBKey.getMin()[0] = 10;
System.out.println(ByteArrayBKey.getMin()[0]); // 0
Collaborator
|
@oliviarla @brido4125 추가 리뷰어 지정하니, 리뷰 바랍니다. |
oliviarla
approved these changes
Sep 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
https://rules.sonarsource.com/java/RSPEC-2386/
There is no good reason to have a mutable object as the public (by default), static member of an interface. Such variables should be moved into classes and their visibility lowered.
Similarly, mutable static members of classes and enumerations which are accessed directly, rather than through getters and setters, should be protected to the degree possible. That can be done by reducing visibility or making the field final if appropriate.
Note that making a mutable field, such as an array, final will keep the variable from being reassigned, but doing so has no effect on the mutability of the internal state of the array (i.e. it doesn’t accomplish the goal).
This rule raises issues for public static array, Collection, Date, and awt.Point members.
Noncompliant code example
⌨️ What I did
@Deprecated처리합니다.