On Tue, 7 Jul 2009 12:02:27 -0700 (PDT), Sal <here@softcom.net> wrote,
quoted or indirectly quoted someone who said :
I have a very large number of precomputed hash values that I need to
use in a Java program. The problem is that since java won't accept
anything larger than 64k I can't initialize an array with the values.
I keep getting a "code too large" error. Any suggestions on how to
proceed?
Unfortunately, Java array initialisation is quite pedestrian. It
balloons the code. I don't think I have ever seen a language so
flat-footed.
Some kludges:
1. precompute your values at load time. static init.
2. store them in a resource, see
http://mindprod.com/jgloss/resource.html
You might use binary, text, or gzip format.
2. DataOutputStream the values, optionally with gzip then base64 them.
Then put the giant base 64 string in your program as a constant, and
decipher it at load time. See http://mindprod.com/jgloss/base64.hhtml
sixteen bits of packaging for a 267% space expansion ...
Or in other words, "Ugh." Stick with #1 or #2(A).