• Post Reply Bookmark Topic Watch Topic
  • New Topic

May Expose Internal Representation by incorporating reference to mutable object  RSS feed

 
Gehan Fernando
Greenhorn
Posts: 11
Eclipse IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In My Code



Once I compile the code it gives the following error

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.

Please Help me to Fix these Kind Of Errors
 
Gehan Fernando
Greenhorn
Posts: 11
Eclipse IDE Oracle Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Marshal
Posts: 56595
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My, where did you find a tool which gives that sort of warnings?

For more explanation, go through this thread and find the discussion about defensive copies.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:My, where did you find a tool which gives that sort of warnings?

For more explanation, go through this thread and find the discussion about defensive copies.


It's a favourite of FindBugs.
 
Campbell Ritchie
Marshal
Posts: 56595
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FindBugs? What a useful feature
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FindBugs, Checkstyle and PMD...the other Three Horsemen of the Apocalypse.
;)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!