Bug 480649 - [1.8] java.lang.ArrayIndexOutOfBoundsException: 2 at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.checkExpression
Summary: [1.8] java.lang.ArrayIndexOutOfBoundsException: 2 at org.eclipse.jdt.internal...
Status: CLOSED DUPLICATE of bug 461004
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.6 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-26 09:47 EDT by Jonas Wiklund CLA
Modified: 2015-10-26 17:54 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Wiklund CLA 2015-10-26 09:47:01 EDT
Getting ArrayIndexOutOfBoundsException from eclipse while building a Java8 maven project, this causes a build failed popup to occur every few seconds if the auto build option is enabled.

java.lang.ArrayIndexOutOfBoundsException: 2
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.checkExpression(InferenceContext18.java:759)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.moreSpecificMain(InferenceContext18.java:714)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.isMoreSpecificThan(InferenceContext18.java:662)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.mostSpecificMethodBinding(Scope.java:4324)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findDefaultAbstractMethod(Scope.java:1176)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1809)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1546)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getImplicitMethod(Scope.java:2506)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:897)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:712)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:667)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:619)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:667)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1020)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:641)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:309)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:551)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1188)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1301)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:590)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1215)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:692)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1190)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:812)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:535)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:528)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:471)
	at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:170)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:155)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Eclipse Platform

Version: Mars.1 (4.5.1)
Build id: M20150904-0015

I managed to minimize the cause to the following code (removing one of the overloaded versions seems to avoid the crash):


package example;

import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

public class Bind {
	public static void main(String[] args) {
		CompletableFuture<String> future = CompletableFuture.completedFuture("Hello");
		System.out.println(syncTransform(future, bind(new Bind()::handle, "World")).join());
	}

	private String handle(String s1, String s2) {
		return s1 + " " + s2;
	}

	private static <Z, A> CompletableFuture<Z> syncTransform(CompletableFuture<A> future, Function<A, Z> transform) {
		return future.thenApply(transform);
	}

	public interface Function1<Z, A, P> {
		Z apply(A a, P parameters);
	}

	public static <Z, A, P> Function<A, Z> bind(Function1<Z, A, P> callable, P parameters) {
		return (A a) -> callable.apply(a, parameters);
	}

	public interface Function2<Z, A, B, P> {
		Z apply(A a, B b, P parameters);
	}

	public static <Z, A, B, P> Function1<Z, A, B> bind(Function2<Z, A, B, P> callable, P parameters) {
		return (A a, B b) -> callable.apply(a, b, parameters);
	}
}
Comment 1 Stephan Herrmann CLA 2015-10-26 17:54:14 EDT
Thanks for the example. I can reproduce in 4.5.1.

Since 4.6 M1 it is fixed via bug 461004.

*** This bug has been marked as a duplicate of bug 461004 ***