This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "pattern for unmodifyable array" Watch "pattern for unmodifyable array" New topic

pattern for unmodifyable array

Gytis Jakutonis
Ranch Hand

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

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
I agree. Here's the link:
subject: pattern for unmodifyable array
Similar Threads
Audio format conversion problems
problem base64 encoding the 3 hex bytes E2 80 A9
Basic Authentication Servlet Redirect
How to validate a file to UTF-8 encoding
back and forth in a vector