Bug 502807 - ArrayIndexOutOfBoundsException compiling stream
Summary: ArrayIndexOutOfBoundsException compiling stream
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: 1.8.10   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-29 19:35 EDT by Jay Rutten CLA
Modified: 2016-11-07 15:10 EST (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 Jay Rutten CLA 2016-09-29 19:35:21 EDT
The following is generated on neon.1:

java.lang.ArrayIndexOutOfBoundsException
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.addConstraintsToC(InferenceContext18.java:467)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.addConstraintsToC_OneExpr(InferenceContext18.java:546)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.addConstraintsToC(InferenceContext18.java:470)
at org.aspectj.org.eclipse.jdt ... run(GlobalBuildAction.java:177)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Compile error: ArrayIndexOutOfBoundsException thrown: -1


The following class triggers this exception:

import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

public class TestCollectors {
    Set<Integer> ids;

    public TestCollectors(Set<Inner> inners) {
        ids = inners.stream().collect(Collectors.toList(Inner::getId));
    }

    public static void main() {
        Set<Inner> inners = new HashSet<>();
        inners.add(new Inner(1, "a"));
        inners.add(new Inner(1, "a"));

        new TestCollectors(inners);
    }


    public static class Inner {
        private int id;
        private String name;

        public Inner(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() { return id; }

        public String getName() { return name; }
    }
}

I believe it is triggered by compiling the inner.stream()...
Comment 1 Andrew Clement CLA 2016-11-07 15:10:33 EST
Thanks so much for the testcase. I can confirm that after upgrading AspectJ to the latest Eclipse JDT this problem is fixed.