java.lang.ArrayIndexOutOfBoundsException during parsing
See original GitHub issueHi! I tried to parse a very simple file:
class Sample (private val propertyA: String)
using the code from example
fun main() {
val source = AstSource.File(
"src/jvmMain/kotlin/sample/Sample.kt"
)
val kotlinFile = KotlinGrammarAntlrKotlinParser.parseKotlinFile(source)
kotlinFile.summary()
.onSuccess { astList ->
astList.forEach(Ast::print)
}.onFailure { errors ->
errors.forEach(::println)
}
}
And got such error
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 170
at kotlinx.ast.parser.antlr.kotlin.AntlrKotlinAstParserImpl.toAstTerminal(AntlrKotlinAstParserImpl.kt:27)
at kotlinx.ast.parser.antlr.kotlin.AntlrKotlinAstParserImpl.parse(AntlrKotlinAstParserImpl.kt:82)
at kotlinx.ast.parser.antlr.kotlin.AntlrKotlinAstParserImpl.parse(AntlrKotlinAstParserImpl.kt:75)
at kotlinx.ast.parser.antlr.kotlin.AntlrKotlinAstParserImplKt.antlrKotlinParser(AntlrKotlinAstParserImpl.kt:138)
at kotlinx.ast.parser.antlr.kotlin.AntlrKotlinAstParserImplKt.antlrKotlinParser(AntlrKotlinAstParserImpl.kt:98)
at kotlinx.ast.parser.antlr.kotlin.AntlrKotlinParser.parse(AntlrKotlinParser.kt:20)
at kotlinx.ast.grammar.kotlin.common.KotlinGrammarParser$DefaultImpls.parseKotlinFile(KotlinGrammarParser.kt:9)
at kotlinx.ast.grammar.kotlin.target.antlr.kotlin.KotlinGrammarAntlrKotlinParser.parseKotlinFile(KotlinGrammarAntlrKotlinParser.kt:10)
at sample.MainKt.main(Main.kt:14)
at sample.MainKt.main(Main.kt)
Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top Results From Across the Web
java.lang.ArrayIndexOutOfBoundsException during parsing · Issue ...
Describe the bug this grammar: module Tijs import IO; layout WS = [\ \t\r\n]* ; import ParseTree; start syntax Stmt = "if" "("...
Read more >ArrayIndexOutOfBoundsException - when parsing a csv file
You want j < line.length and not <= . If there are 10 elements in an Array then there is not an item...
Read more >AN ARRAYINDEXOUTOFBOUNDSEXCEPTION MAY BE ...
While the XML parser is handling data via the multiple buffers in which it stores data in, a java.lang.ArrayIndexOutOfBoundsException may be thrown due...
Read more >3 Tips to solve and Avoid java.lang ... - Javarevisited
The error ArrayIndexOutOfBoundsException: 1 means index 1 is invalid and it's out of bounding i.e. more than the length of the array. Since...
Read more >ERROR: "java.lang.ArrayIndexOutOfBoundsException
The scenario of this issue: Source Object parameterized & Field Mapping is set to Automatic in Structure/Hierarchy Parser. As the Field mapping ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @VitaSokolova, sorry for the late answer. The build of
antlr-kotlin
was broken, the version was missing so that the default version was added to gradle metadata. That caused the build ofkotlinx.ast
to fail. I fixed thekotlinx.ast
build here: https://github.com/drieks/antlr-kotlin/commit/b09d76328f7d8c38417174d5621bbdfb52b6405e and the build ofkotlinx.ast
here: https://github.com/kotlinx/ast/commit/5db757217c18432c65533b943ef36aba650639ccWhen you replace this line:
with:
your project should work now.
Hi @VitaSokolova,
your project works fine for me when running in Intellij Idea.
I added a “shadow jar” task to gradle: https://github.com/VitaSokolova/ImpactAnalysisProject/pull/1 (A shadow jar contains all dependencies required to run program)
I also added this to gradle (I don’t know why it is required, it is releated to gradle metadata and should normally be automatically included):
You can now run “gradle clean buildJar” from the command line, or by using the “gradle” tab in Idea, you can click on “ImpactAnalysisProject / Tasks / other / buildJar”. The jar will be created as build/libs/ImpactAnalysisProject.jar.
Please try to run this jar:
This will create this output for me:
If this does not work, please copy the jar into the root folder of the repository and just commit it, I will look into the jar to find the problem.