Home » Java » java.lang.StringIndexOutOfBoundsException while maven compilation

java.lang.StringIndexOutOfBoundsException while maven compilation

Posted by: admin July 12, 2018 Leave a comment

Questions:

I use Groovy in my project and after I merged two branches I got this exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project cf-backend-model: Compilation failure: Compilation failure:
[ERROR] /home/jarinel/source/cfN/model/src/main/java/com/mcb/creditfactory/util/form/mapper/annotation/Skip.java: 1. ERROR in /home/jarinel/source/cfN/model/src/main/java/com/mcb/creditfactory/util/form/mapper/annotation/Skip.java (at line 0)
[ERROR] package com.mcb.creditfactory.util.form.mapper.annotation;
[ERROR] ^
[ERROR] Internal compiler error: java.lang.Exception: java.lang.StringIndexOutOfBoundsException: String index out of range: -11 at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:169)

Both branches are compilable and working separately.
As for me, it looks like some kind of a bug in compiler due to negative index.

I use this compiler configuration:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.7.0</version>
    <configuration>
        <compilerId>groovy-eclipse-compiler</compilerId>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
    <extensions>true</extensions>

    <dependencies>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>1.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct-processor</artifactId>
            <version>1.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-compiler</artifactId>
            <version>2.9.2-04</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-batch</artifactId>
            <version>2.4.13-02</version>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>4.1.4</version>
            <classifier>jpa</classifier>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.google.collections</groupId>
            <artifactId>google-collections</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
</plugin>

Apache Maven 3.3.9, java version: 1.8.0_171. Thanks.

Skip.java

package com.mcb.creditfactory.util.form.mapper.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Skip {

}
Answers: