Lew said:
Not entirely seriously, but now I'm curious about the implications...
If some attribute is "trademarked", it may not have its usual meaning
You explicitly list 65,536 literal short values? You've
actually done this?
Even 32768 constant fields per class are too many, since
each consumes two slots in the constant pool: name and value,
plus there are some more things that also must fit in there.
Out of curiosity, I created (automatically, from a small tcl script)
such a class with 32760 (8 less) constants. It then was compileable.
I then created a small class User, that did the "import static",
and it worked (of course), even though it took considerably more
time to compile (3.7secs) than without that crap (1.24secs).
So, it definitely doesn't pay for the full short-range.
Doing it for the byte-range and perhaps for a sufficiently
small group of shorts, that may (due to domain-specifics
of some particular problem-space) be very frequently used
as immediates to methods taking shorts, ...
may even be feasible.
I am just shaking my head in incredulity.
holder.foo( (short) 8191 );
Depends on how many such lines are at stake...
I find "(short)" visually quite disturbing, so probably
my critical number would be lower than yours.