aspose file tools*
The moose likes Java in General and the fly likes pattern for unmodifyable array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "pattern for unmodifyable array" Watch "pattern for unmodifyable array" New topic
Author

pattern for unmodifyable array

Gytis Jakutonis
Ranch Hand

Joined: Feb 02, 2004
Posts: 76
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

Joined: Apr 14, 2004
Posts: 10336

Better than a pattern, the java.util.Collections class contains methods to mark collections as unmodifiable. Have a look at those.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
 
subject: pattern for unmodifyable array