Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pattern for unmodifyable array

 
Gytis Jakutonis
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I need to define final static array (with file signature bytes in my case), ant I'm not sure how to protect array from modifications. If I use simple form:

then malicious code may change signature elements:


So I came up with this idea:

Maybe there is some pattern for this problem, or maybe new jdk 1.5 has some standard elements, which slolve the issue?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better than a pattern, the java.util.Collections class contains methods to mark collections as unmodifiable. Have a look at those.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic