의 내부 표현 노출 :객체의 필드 중 하나에 저장된 변경 가능한 객체 값에 대한 참조를 반환하는 다음 행에 대한 내 코드에 checkstyle을 실행할 때 나는이 오류를 받고 있어요 객체
@Override
public String[] getDescriptions() {
return DESCRIPTIONS;
}
을하지만, 설명 IS NOT
변경할 수 있습니다.
"Returning a reference to a mutable object value stored in one
of the object's fields exposes the internal representation of
the object. If instances are accessed by untrusted code, and
unchecked changes to the mutable object would compromise security
or other important properties, you will need to do something
different. Returning a new copy of the object is better approach
in many situations."
관련 질문 :
private static final String[] DESCRIPTIONS = new String[NUM_COLUMNS];
static {
// In a loop assign values to the array.
for (int i = 0; i < NUM_COLUMNS; ++i) {
DESCRIPTIONS[i] = "Some value";
}
}
이 전체 오류 메시지입니다 : 그것은이 정의되어 Link
항목은 변경할 수 있습니다. – bmargulies