Frage

I have a 2.5 GB file that I am trying to parse with Antlr in Java. First I had an out of memory exception, so I increased the maximum heap size. It then failed with this stack trace:

Exception in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException
    at java.util.Arrays.copyOf(Arrays.java:2882)
    at org.antlr.v4.runtime.ANTLRInputStream.load(ANTLRInputStream.java:123)
    at org.antlr.v4.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:86)
    at org.antlr.v4.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:78)
    at MyClass.runAntlr(MyClass.java)

My guess is that some index variable overflowed.

Is there an input stream that can handle an arbitrarily large file? Or larger files that ANTLRInputStream?

War es hilfreich?

Lösung

That's funny. I noticed the exact same thing myself the other day. The indexes are all integers instead along. Sam and I plan to integrate a fix for this at some point; if you look at branch, you can play with it now

https://github.com/parrt/antlr4/tree/long-intervals

Ter

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top