[antlr-interest] Java and static arrays: a serious joke

O.E. Dragon dragonoe at mcmaster.ca
Fri Jun 2 18:44:03 PDT 2006


On Fri, 2 Jun 2006 15:41:59 -0700
 Terence Parr <parrt at cs.usfca.edu> wrote:
> But that doesn't solve the issue that you still have to get it to FIT
>  into a single class.

So your static array won't fit into a single class? I'm confused...

> AH HA!  Just looked at JFLex..they store them as strings, which are
>  UTF8 in the class file.
> 
> public class T {
>          static final String duh = "\1\2\3";
> }
> 
> generates everything directly in the classfile constant pool!
>   Hooray!  Now I have to encode, decode, but it's doable!  Thanks,
> JFlex!

And this is faster...? I'm not clear on what you're looking for.

What if you do

   static short[] array = new array[2];
   array[0] = 10;
   array[1] = 20;

Or what if you don't make the array static? I mean this is all
generated by the codegen no? It's not pretty to look at but at least
you don't have to type it everytime.

-Olivier


More information about the antlr-interest mailing list