[stringtemplate-interest] [ST4] Bug: ArrayIndexOutOfBoundsException in STRuntimeMessage.getSourceLocation
Udo Borkowski
ub at abego-software.de
Sun Aug 7 03:33:38 PDT 2011
When trying to inspect a main template of this group:
main(doit = true) ::= "<if(doit || other)><t(...)><endif>\"
t2() ::= "Hello"
t(x={<(t2())>}) ::= "<x>"
ST4 throws an ArrayIndexOutOfBoundsException in STRuntimeMessage.getSourceLocation.
Interestingly removing the "|| other" let you inspect the template.
Also making the default for x = {<t2()>} (i.e. use lazy evaluation) and keeping the "|| other" also works fine.
I added a test case to TestEarlyEvaluation and checked it in into Perforce.
Udo
P.S.: here the stack track
java.lang.ArrayIndexOutOfBoundsException: 17
at org.stringtemplate.v4.misc.STRuntimeMessage.getSourceLocation(STRuntimeMessage.java:70)
at org.stringtemplate.v4.misc.STRuntimeMessage.toString(STRuntimeMessage.java:81)
at javax.swing.DefaultListCellRenderer.getListCellRendererComponent(DefaultListCellRenderer.java:134)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1344)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1294)
at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:561)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
at javax.swing.JList.getPreferredScrollableViewportSize(JList.java:2412)
at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:75)
at java.awt.Container.preferredSize(Container.java:1599)
at java.awt.Container.getPreferredSize(Container.java:1584)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)
at javax.swing.ScrollPaneLayout.preferredLayoutSize(ScrollPaneLayout.java:475)
at java.awt.Container.preferredSize(Container.java:1599)
at java.awt.Container.getPreferredSize(Container.java:1584)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)
at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:1092)
at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:893)
at java.awt.GridBagLayout.preferredLayoutSize(GridBagLayout.java:713)
at java.awt.Container.preferredSize(Container.java:1599)
at java.awt.Container.getPreferredSize(Container.java:1584)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)
at javax.swing.JRootPane$RootLayout.preferredLayoutSize(JRootPane.java:907)
at java.awt.Container.preferredSize(Container.java:1599)
at java.awt.Container.getPreferredSize(Container.java:1584)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)
at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:702)
at java.awt.Container.preferredSize(Container.java:1599)
at java.awt.Container.getPreferredSize(Container.java:1584)
at java.awt.Window.pack(Window.java:706)
at org.stringtemplate.v4.gui.STViz.open(STViz.java:212)
at org.stringtemplate.v4.ST.inspect(ST.java:471)
at org.stringtemplate.v4.ST.inspect(ST.java:454)
at org.stringtemplate.v4.ST.inspect(ST.java:447)
at org.stringtemplate.v4.test.TestEarlyEvaluation.testBugArrayIndexOutOfBoundsExceptionInSTRuntimeMessage_getSourceLocation(TestEarlyEvaluation.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110807/be86baaa/attachment-0001.html
More information about the stringtemplate-interest
mailing list