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

Terence Parr parrt at cs.usfca.edu
Fri Jun 2 18:48:03 PDT 2006


On Jun 2, 2006, at 6:44 PM, O.E. Dragon wrote:

> 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...

Nope...bloats the constant pool and the code blocks.

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

No but makes it possible.

> What if you do
>
>    static short[] array = new array[2];
>    array[0] = 10;
>    array[1] = 20;

Quickly count in your head how many bytecodes per a[0]=10.  You'll  
see that it's many bytes for each int you want to store.  How big can  
a method be?  64k.  That doesn't leave much room for lots of state  
tables.

> Or what if you don't make the array static?

no diff.

> 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.

won't compile.  Look carefully at the example in my email (and the  
link if still unclear).

Ter



More information about the antlr-interest mailing list