1. 程式人生 > >findBugs Java類date屬性get,set方法報錯

findBugs Java類date屬性get,set方法報錯

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.

返回物件欄位之一中儲存的可變物件值的引用將公開該物件的內部表示形式。如果例項被不可信的程式碼訪問,並且對可變物件的未經檢查的更改會危及安全性或其他重要屬性,那麼您需要做一些不同的事情。在許多情況下返回物件的新副本是更好的方法。

This code stores a reference to an externally mutable object into 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. Storing a copy of the object is better approach in many situations.


此程式碼將對外部可變物件的引用儲存到物件的內部表示中。如果例項被不可信的程式碼訪問,並且對可變物件的未經檢查的更改會危及安全性或其他重要屬性,那麼您需要做一些不同的事情。在許多情況下儲存物件的副本是更好的方法。