Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser issue: StringIndexOutOfBounds #564

Closed
traceyyoshima opened this issue Dec 21, 2023 · 4 comments
Closed

Parser issue: StringIndexOutOfBounds #564

traceyyoshima opened this issue Dec 21, 2023 · 4 comments
Labels
bug Something isn't working parser-kotlin

Comments

@traceyyoshima
Copy link
Contributor

"java.lang.StringIndexOutOfBoundsException: Range [1, 0) out of bounds for length 1
  java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
  java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
  java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
  java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
  java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
  java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
  java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
  java.base/java.lang.String.checkBoundsBeginEnd(String.java:4861)
  ..."

There is no information in the parse error result, this occurs on hypercube1024/firefly

@traceyyoshima traceyyoshima added bug Something isn't working parser-kotlin labels Dec 21, 2023
@kunli2
Copy link
Contributor

kunli2 commented Jan 3, 2024

I saw a similar StringIndexOutOfBoundsException from this test

    @Test
    void scalaImport() {
        rewriteRun(
          kotlin(
            """
              import my.org.`x$`

              fun main() {

              }
              """
          )
        );
    }
Caused by: java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 1
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
	at java.base/java.lang.String.substring(String.java:2709)
	at org.openrewrite.java.tree.TypeTree.build(TypeTree.java:77)
	at org.openrewrite.kotlin.internal.KotlinTreeParserVisitor.visitImportDirective(KotlinTreeParserVisitor.java:2540)
	at org.openrewrite.kotlin.internal.KotlinTreeParserVisitor.visitImportDirective(KotlinTreeParserVisitor.java:75)
	at org.jetbrains.kotlin.psi.KtImportDirective.accept(KtImportDirective.java:45)
	at org.openrewrite.kotlin.internal.KotlinTreeParserVisitor.visitKtFile(KotlinTreeParserVisitor.java:1676)
	at org.openrewrite.kotlin.internal.KotlinTreeParserVisitor.parse(KotlinTreeParserVisitor.java:110)
	at org.openrewrite.kotlin.KotlinParser.lambda$parseInputs$4(KotlinParser.java:187)
	... 18 more

maybe this is related to #559

knutwannheden added a commit that referenced this issue Jan 22, 2024
@knutwannheden
Copy link
Contributor

The problematic code in hypercube1024/firefly are some import statements (like https://github.com/hypercube1024/firefly/blob/628cfb219a48bdfa104c180d3f96a4690ec46ca4/firefly-example/src/main/kotlin/com/fireflysource/example/HttpServerPathParamDemo.kt#L3):

import com.fireflysource.`$`

@knutwannheden
Copy link
Contributor

This is in fact the same as in

import my.org.`x$`

@knutwannheden
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser-kotlin
Projects
Archived in project
Development

No branches or pull requests

3 participants