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

Eclipse 4.6.1 hangs during content assitent on static methods on not yet imported classes #234

Closed
wagnerma opened this issue Nov 28, 2016 · 24 comments

Comments

@wagnerma
Copy link

wagnerma commented Nov 28, 2016

Hi,

we can reproduce the hang during content assistent, it happens for us on a content assitent call on a helper class with CompileStatic that has some static methods. Entering the unkown class name and a valid static method name brings eclipse to freeze.
The plugin is the version: 2.9.2.xx-201611270046-e46

I have the following exceptions:

eclipse.buildId=4.6.1.M20160907-1200
java.version=1.8.0_112
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -clean

org.eclipse.jdt.core
Error
Mon Nov 28 16:06:43 CET 2016
Code assist internal error

java.lang.ArrayIndexOutOfBoundsException: 1059
	at org.eclipse.jdt.internal.compiler.lookup.TypeSystem.getDerivedTypes(TypeSystem.java:452)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotatableTypeSystem.getRawType(AnnotatableTypeSystem.java:141)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotatableTypeSystem.getRawType(AnnotatableTypeSystem.java:166)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createRawType(LookupEnvironment.java:1049)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToRawType(LookupEnvironment.java:570)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.toRawType(JDTClassNodeBuilder.java:139)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureParameterizedType(JDTClassNodeBuilder.java:350)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureType(JDTClassNodeBuilder.java:74)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.createJDTClassNode(JDTResolver.java:480)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.convertToClassNode(JDTResolver.java:459)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.initialize(JDTClassNode.java:221)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.lazyClassInit(JDTClassNode.java:163)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.initializeProperties(JDTClassNode.java:562)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.ensurePropertiesInitialized(JDTClassNode.java:556)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.getProperty(JDTClassNode.java:660)
	at org.eclipse.jdt.groovy.search.SimpleTypeLookup.findDeclaration(SimpleTypeLookup.java:564)
	at org.eclipse.jdt.groovy.search.SimpleTypeLookup.findTypeForNameWithKnownObjectExpression(SimpleTypeLookup.java:330)
	at org.eclipse.jdt.groovy.search.SimpleTypeLookup.findType(SimpleTypeLookup.java:225)
	at org.eclipse.jdt.groovy.search.SimpleTypeLookup.lookupType(SimpleTypeLookup.java:85)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.lookupExpressionType(TypeInferencingVisitorWithRequestor.java:2044)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:2013)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstantExpression(TypeInferencingVisitorWithRequestor.java:1435)
	at org.codehaus.groovy.ast.expr.ConstantExpression.visit(ConstantExpression.java:83)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1608)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBinaryExpression(TypeInferencingVisitorWithRequestor.java:998)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitDeclarationExpression(TypeInferencingVisitorWithRequestor.java:1462)
	at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:74)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:281)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitIfElse(CodeVisitorSupport.java:61)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitIfElse(ClassCodeVisitorSupport.java:291)
	at org.codehaus.groovy.ast.stmt.IfStatement.visit(IfStatement.java:43)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitIfElse(CodeVisitorSupport.java:61)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitIfElse(ClassCodeVisitorSupport.java:291)
	at org.codehaus.groovy.ast.stmt.IfStatement.visit(IfStatement.java:43)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTryCatchFinally(CodeVisitorSupport.java:87)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitTryCatchFinally(ClassCodeVisitorSupport.java:316)
	at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:44)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:148)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:159)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:816)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:567)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:397)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:352)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.selectASTNode(CodeSelectHelper.java:111)
	at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.initialize(GroovyOccurrencesFinder.java:221)
	at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1243)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$6.selectionChanged(JavaEditor.java:3364)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:182)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:158)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

and the follwing:

eclipse.buildId=4.6.1.M20160907-1200
java.version=1.8.0_112
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -clean

org.eclipse.jdt.core
Error
Mon Nov 28 16:12:44 CET 2016
Code assist internal error

java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
	at java.util.ArrayList$Itr.next(Unknown Source)
	at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.FilteringPointcut.filterResult(FilteringPointcut.java:71)
	at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.FilteringPointcut.matches(FilteringPointcut.java:59)
	at org.codehaus.groovy.eclipse.dsl.pointcuts.AbstractPointcut.matchOnPointcutArgument(AbstractPointcut.java:119)
	at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.FilteringPointcut.matches(FilteringPointcut.java:57)
	at org.codehaus.groovy.eclipse.dsl.pointcuts.AbstractPointcut.matchOnPointcutArgument(AbstractPointcut.java:119)
	at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.CurrentTypePointcut.matches(CurrentTypePointcut.java:61)
	at org.codehaus.groovy.eclipse.dsl.DSLDStore.findContributions(DSLDStore.java:144)
	at org.codehaus.groovy.eclipse.dsl.lookup.DSLDTypeLookup.lookupTypeAndDeclaration(DSLDTypeLookup.java:84)
	at org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup.lookupType(AbstractSimplifiedTypeLookup.java:133)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.lookupExpressionType(TypeInferencingVisitorWithRequestor.java:2044)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:2013)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstantExpression(TypeInferencingVisitorWithRequestor.java:1435)
	at org.codehaus.groovy.ast.expr.ConstantExpression.visit(ConstantExpression.java:83)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitPropertyExpression(TypeInferencingVisitorWithRequestor.java:1764)
	at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:57)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitPropertyExpression(TypeInferencingVisitorWithRequestor.java:1739)
	at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:57)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitListOfExpressions(CodeVisitorSupport.java:278)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTupleExpression(CodeVisitorSupport.java:183)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitTupleExpression(TypeInferencingVisitorWithRequestor.java:1897)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitArgumentlistExpression(TypeInferencingVisitorWithRequestor.java:941)
	at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:76)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1627)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitReturnStatement(CodeVisitorSupport.java:78)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitReturnStatement(ClassCodeVisitorSupport.java:296)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitReturnStatement(TypeInferencingVisitorWithRequestor.java:1378)
	at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:49)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitClosureExpression(CodeVisitorSupport.java:179)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitClosureExpression(TypeInferencingVisitorWithRequestor.java:1280)
	at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:45)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitListOfExpressions(CodeVisitorSupport.java:278)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTupleExpression(CodeVisitorSupport.java:183)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitTupleExpression(TypeInferencingVisitorWithRequestor.java:1897)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitArgumentlistExpression(TypeInferencingVisitorWithRequestor.java:941)
	at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:76)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1627)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBinaryExpression(TypeInferencingVisitorWithRequestor.java:998)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitDeclarationExpression(TypeInferencingVisitorWithRequestor.java:1462)
	at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:74)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:281)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitIfElse(CodeVisitorSupport.java:61)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitIfElse(ClassCodeVisitorSupport.java:291)
	at org.codehaus.groovy.ast.stmt.IfStatement.visit(IfStatement.java:43)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitIfElse(CodeVisitorSupport.java:61)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitIfElse(ClassCodeVisitorSupport.java:291)
	at org.codehaus.groovy.ast.stmt.IfStatement.visit(IfStatement.java:43)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTryCatchFinally(CodeVisitorSupport.java:87)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitTryCatchFinally(ClassCodeVisitorSupport.java:316)
	at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:44)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:148)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:159)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:816)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:567)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:397)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:352)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.selectASTNode(CodeSelectHelper.java:111)
	at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.initialize(GroovyOccurrencesFinder.java:221)
	at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1243)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$6.selectionChanged(JavaEditor.java:3364)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:182)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:158)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Hope it helps to find the bug.

Cheers,
Marcel

@eric-milles
Copy link
Member

The issue in TypeSystem should not be contributing to the freeze...there are some patches in that class to help with the arrray OOB, but it is not a resolved issue as you can see.

The concurrent mod exception is probably what is causing the freeze. Here are the relevant methods starting from DSLDStore and working up the stack. Best I can tell, there are no modifications of the lists created by FilteringPointcut.explodeObject. But there does appear to be two simultaneous iterations.

    /**
     * Find all contributions for this pattern and this declaring type.
     *
     * @param pattern The pattern to match against
     * @param disabledScripts The set of scripts that are disabled and should be ignored
     * @return The set of contributions applicable for the pattern
     */
    public List<IContributionElement> findContributions(GroovyDSLDContext pattern, Set<String> disabledScripts) {
        List<IContributionElement> elts = new ArrayList<IContributionElement>();
        synchronized (pointcutContributionMap) {
            for (Map.Entry<IPointcut, List<IContributionGroup>> entry : pointcutContributionMap.entrySet()) {
                IPointcut pointcut = entry.getKey();
                if (!disabledScripts.contains(DSLDStore.toUniqueString(pointcut.getContainerIdentifier()))) {
                    pattern.resetBinding();
144:                Collection<?> results = pointcut.matches(pattern, pattern.getCurrentType());
                    if (results != null) {
                        for (IContributionGroup group : entry.getValue()) {
                            elts.addAll(group.getContributions(pattern, pattern.getCurrentBinding()));
                        }
                    }
                }
            }
        }
        return elts;
    }

    @Override
    public Collection<?> matches(GroovyDSLDContext pattern, Object toMatch) {
        Object firstArgument = getFirstArgument();
        ClassNode currentType = pattern.getCurrentType();
        if (firstArgument instanceof String) {
            if (currentType.getName().equals(firstArgument)) {
                return Collections.singleton(currentType);
            } else {
                return null;
            }
        } else if (firstArgument instanceof Class<?>) {
            if (currentType.getName().equals(((Class<?>) firstArgument).getName())) {
                return Collections.singleton(currentType);
            } else {
                return null;
            }
        } else if (firstArgument != null) {
            // we know this is a pointcut argument
061:        return matchOnPointcutArgument((IPointcut) firstArgument, pattern, Collections.singleton(currentType));
        } else {
            // always match if there is no argument
            return Collections.singleton(currentType);
        }
    }

    protected Collection<?> matchOnPointcutArgument(IPointcut argument, GroovyDSLDContext pattern, Collection<?> allElementsToMatch) {
        if (allElementsToMatch == null) {
            return null;
        }
        Collection<Object> outerResults = new LinkedHashSet<Object>();
        for (Object toMatch : allElementsToMatch) {
119:        Collection<?> innerResults = argument.matches(pattern, toMatch);
            if (innerResults != null) {
                String bindingName = getArgumentName(argument);
                if (bindingName != null) {
                    pattern.addToBinding(bindingName, innerResults);
                }
                outerResults.add(toMatch);
            }
        }
        // return null if no matches found
        return outerResults.size() > 0 ? outerResults : null;
    }

    @Override
    public Collection<?> matches(GroovyDSLDContext pattern, Object toMatch) {
        Collection<T> explodedList = explodeObject(toMatch);
        if (explodedList == null || explodedList.size() == 0) {
            return null;
        }
        Object first = getFirstArgument();
        if (first instanceof IPointcut) {
            // pass the exploded list to the inner pointcut and match on each element of the list
057:        return matchOnPointcutArgument((IPointcut) first, pattern, explodedList);
        } else {
059:        Collection<?> filtered = filterResult(explodedList, pattern);
            if (filtered != null) {
                return filtered;
            }
            return null;
        }
    }

    protected Collection<?> filterResult(Collection<T> results, GroovyDSLDContext context) {
        Object o = getFirstArgument();
        String firstArg = asString(o);
        Collection<T> filtered = new ArrayList<T>(results.size());
071:    for (T obj : results) {
            T maybe = filterObject(obj, context, firstArg);
            if (maybe != null) {
                filtered.add(maybe);
            }
        }
        return reduce(filtered);
    }

    protected Collection<T> explodeObject(Object toMatch) {
        if (toMatch instanceof  Collection<?>) {
            List<T> objs = new ArrayList<T>();
            for (Object elt : (Collection<?>) toMatch) {
                if (filterBy.isInstance(elt)) {
                    objs.add((T) elt);
                }
            }
            if (objs.size() > 0) {
                return objs;
            }
        } else if (filterBy.isInstance(toMatch)) {
            return Collections.singletonList((T) toMatch);
        }
        return null;
    }

@eric-milles
Copy link
Member

One additional note, explodeObject is overridden by several sub-types of FilteringPointcut. That is likely where the con mod ex is coming from. Not all paths return a new collection.

@eric-milles
Copy link
Member

eric-milles commented Nov 28, 2016

Updated snapshot should be available. Could you recheck? I think one of the collections (fields, methods, properties) from the type is being lazily loaded as the DSL job is accessing them. I made sure any collection read under FilteringPointcut is a copy; that should reduce the chance for a concurrent mod exception.

@wagnerma
Copy link
Author

..well, the hang is still there, the concurrent modification exception is gone, but eclipse still hangs....
..we observed importing the missing class by hand, all seems fine, start the organize import and eclipse hangs..
we still have the following exception:

eclipse.buildId=4.6.1.M20160907-1200
java.version=1.8.0_112
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -data file:/C:/build/workbench2_workspace/ -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -clean

org.eclipse.jdt.core
Error
Wed Nov 30 09:23:09 CET 2016
Code assist internal error

java.lang.ArrayIndexOutOfBoundsException: 522
	at org.eclipse.jdt.internal.compiler.lookup.TypeSystem.getDerivedTypes(TypeSystem.java:452)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotatableTypeSystem.getRawType(AnnotatableTypeSystem.java:141)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotatableTypeSystem.getRawType(AnnotatableTypeSystem.java:166)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createRawType(LookupEnvironment.java:1049)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.convertToRawType(LookupEnvironment.java:570)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.toRawType(JDTClassNodeBuilder.java:139)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureParameterizedType(JDTClassNodeBuilder.java:350)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureType(JDTClassNodeBuilder.java:74)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.build(JDTClassNodeBuilder.java:57)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.makeClassNode(JDTClassNode.java:419)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.makeParameter(JDTClassNode.java:399)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.makeParameters(JDTClassNode.java:386)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.methodBindingToMethodNode(JDTClassNode.java:359)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.initializeMembers(JDTClassNode.java:276)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.initialize(JDTClassNode.java:232)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.lazyClassInit(JDTClassNode.java:163)
	at org.codehaus.groovy.ast.ClassNode.getInterfaces(ClassNode.java:452)
	at org.eclipse.jdt.groovy.search.VariableScope.cloneInternal(VariableScope.java:693)
	at org.eclipse.jdt.groovy.search.VariableScope.clone(VariableScope.java:643)
	at org.eclipse.jdt.groovy.search.VariableScope.extractElementType(VariableScope.java:972)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.findImplicitParamType(TypeInferencingVisitorWithRequestor.java:1307)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitClosureExpression(TypeInferencingVisitorWithRequestor.java:1214)
	at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:45)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitListOfExpressions(CodeVisitorSupport.java:278)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTupleExpression(CodeVisitorSupport.java:183)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitTupleExpression(TypeInferencingVisitorWithRequestor.java:1897)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitArgumentlistExpression(TypeInferencingVisitorWithRequestor.java:941)
	at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:76)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1627)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBinaryExpression(TypeInferencingVisitorWithRequestor.java:998)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitDeclarationExpression(TypeInferencingVisitorWithRequestor.java:1462)
	at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:74)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:281)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTryCatchFinally(CodeVisitorSupport.java:87)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitTryCatchFinally(ClassCodeVisitorSupport.java:316)
	at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:44)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1369)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:148)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:159)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:816)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:567)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:397)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:352)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.selectASTNode(CodeSelectHelper.java:111)
	at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.initialize(GroovyOccurrencesFinder.java:221)
	at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1243)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$6.selectionChanged(JavaEditor.java:3364)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:182)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:158)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

@wagnerma
Copy link
Author

wagnerma commented Dec 1, 2016

I try to isolate the problem, but without luck at the moment, I got a new exception:

eclipse.buildId=4.6.1.M20160907-1200
java.version=1.8.0_112
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.core.jobs
Error
Thu Dec 01 22:14:24 CET 2016
An internal error occurred during: "Requesting Java AST from selection".

BUG! Tried to overwrite existing meta data de.effectivecompany.app.mat.serviceimpl.Test.
	at org.codehaus.groovy.ast.ASTNode.setNodeMetaData(ASTNode.java:179)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder.readClassDeclaration(ASTNodeFinder.java:566)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder.checkSupers(ASTNodeFinder.java:446)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder.visitClass(ASTNodeFinder.java:120)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder.doVisit(ASTNodeFinder.java:79)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.findNodeForRegion(CodeSelectHelper.java:172)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.selectASTNode(CodeSelectHelper.java:100)
	at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.initialize(GroovyOccurrencesFinder.java:221)
	at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1243)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$6.selectionChanged(JavaEditor.java:3364)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:182)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:158)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

@eric-milles
Copy link
Member

Thanks for catching that. There must be more than one thread trying to put a value. setNodeMetaData checks that the value was null in the map; putNodeMetaData can be used instead.

@eric-milles
Copy link
Member

Can you retest with the latest snapshot?

@wagnerma
Copy link
Author

wagnerma commented Dec 5, 2016

...well, the exceptions are gone, but we still have the eclipse hang during QuickFix/organize import/moving the mouse pointer over the unkown class,...in the profiler we see it hangs somewhere in:

GroovyQuickFixProcessor.getCorrections()
-> AddMissingGrovvyImportsResolver.getQuickFixProposals()
-> AddMissingGrovvyImportsResolver.getImportTypeSuggestions()
-> TypeSearch.searchForNames()
-> SearchEngine.searchAllTypeNames()
-> BasicSearchEngine.searchAllTypeNames()
-> JobManager.performConcurrentJob()

...I try to checkout the grovvy plugin source code to debug...

@eric-milles
Copy link
Member

If you wait, does the content assist ever return? I have found that the first type search on an un-indexed project can take at least 8 seconds.

@wagnerma
Copy link
Author

wagnerma commented Dec 5, 2016

Well not so easy to say. On my slow notebook, I can't reproduce it so good. On a fast PC, there we can reproduce it always. If you click somewhere in eclipse, then it is over. Moving the pointer out of the eclipse window, it could happen, that it returns and all is fine...strange and without an exception a difficult bug

@wagnerma
Copy link
Author

wagnerma commented Dec 6, 2016

OK, I debug a little bit, and during the first start of the project I could reproduce it a little bit, the second start all was fine. It seems it has something to do with the paralell indexing. I stopped in the debugger and the two threads working and perhaps blocking each other are:

Thread.sleep(long) line: not available [native method]	
IndexManager(JobManager).performConcurrentJob(IJob, int, IProgressMonitor) line: 251	
BasicSearchEngine.searchAllTypeNames(char[][], char[][], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor) line: 2062	
SearchEngine.searchAllTypeNames(char[][], char[][], IJavaSearchScope, TypeNameMatchRequestor, int, IProgressMonitor) line: 1230	
TypeSearch.searchForTypes(GroovyCompilationUnit, Map<String,UnresolvedTypeData>) line: 88	
AddMissingGroovyImportsResolver.getImportTypeSuggestions() line: 132	
AddMissingGroovyImportsResolver.getQuickFixProposals() line: 208	
GroovyQuickFixProcessor.getCorrections(IInvocationContext, IProblemLocation[]) line: 73	
JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(ContributedProcessorDescriptor) line: 384	
JavaCorrectionProcessor$SafeCorrectionCollector(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).run() line: 344	
SafeRunner.run(ISafeRunnable) line: 42	
JavaCorrectionProcessor$SafeCorrectionCollector(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).process(ContributedProcessorDescriptor) line: 339	
JavaCorrectionProcessor.collectCorrections(IInvocationContext, IProblemLocation[], Collection<IJavaCompletionProposal>) line: 474	
ProblemHover$ProblemInfo.getJavaAnnotationFixes(IJavaAnnotation) line: 102	
ProblemHover$ProblemInfo.getCompletionProposals() line: 76	
AbstractAnnotationHover$HoverControlCreator$1(AbstractAnnotationHover$AnnotationInformationControl).deferredCreateContent() line: 287	
AbstractAnnotationHover$HoverControlCreator$1(AbstractAnnotationHover$AnnotationInformationControl).setInput(Object) line: 187	
TextViewerHoverManager(AbstractInformationControlManager).internalShowInformationControl(Rectangle, Object) line: 1194	
TextViewerHoverManager(AbstractInformationControlManager).presentInformation() line: 1163	
TextViewerHoverManager(AbstractHoverInformationControlManager).presentInformation() line: 894	
TextViewerHoverManager.doPresentInformation() line: 244	
TextViewerHoverManager$5.run() line: 234	
RunnableLock.run() line: 35	
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 182	
Display.runAsyncMessages(boolean) line: 4203	
Display.readAndDispatch() line: 3819	
PartRenderingEngine$4.run() line: 1121	
Realm.runWithDefault(Realm, Runnable) line: 336	
PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1022	
E4Workbench.createAndRunUI(MApplicationElement) line: 150	
Workbench$5.run() line: 687	
Realm.runWithDefault(Realm, Runnable) line: 336	
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 604	
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 148	
IDEApplication.start(IApplicationContext) line: 138	
EclipseAppHandle.run(Object) line: 196	
EclipseAppLauncher.runApplication(Object) line: 134	
EclipseAppLauncher.start(Object) line: 104	
EclipseStarter.run(Object) line: 388	
EclipseStarter.run(String[], Runnable) line: 243	
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
Method.invoke(Object, Object...) line: not available	
Main.invokeFramework(String[], URL[]) line: 673	
Main.basicRun(String[]) line: 610	
Main.run(String[]) line: 1519	
Main.main(String[]) line: 1492	

and the other one:

Daemon Thread [Java indexing] (Suspended)	
	GroovyRecognizer(Parser).match(int) line: 211	
	GroovyRecognizer.nlsWarn() line: 8717	
	GroovyRecognizer.variableDefinitions(AST, AST) line: 2735	
	GroovyRecognizer.declaration() line: 2512	
	GroovyRecognizer.classField() line: 6251	
	GroovyRecognizer.classBlock() line: 5527	
	GroovyRecognizer.classDefinition(AST) line: 2222	
	GroovyRecognizer.typeDefinitionInternal(AST) line: 2075	
	GroovyRecognizer.statement(int) line: 1460	
	GroovyRecognizer.compilationUnit() line: 874	
	ErrorRecoveredCSTParserPlugin.transformCSTIntoAST(SourceUnit, Reader, SourceBuffer) line: 65	
	ErrorRecoveredCSTParserPlugin(AntlrParserPlugin).parseCST(SourceUnit, Reader) line: 113	
	EclipseSourceUnit(SourceUnit).parse() line: 248	
	CompilationUnit$8.call(SourceUnit) line: 191	
	CompilationUnit.applyToSourceUnits(CompilationUnit$SourceUnitOperation) line: 1017	
	CompilationUnit.doPhaseOperation(Object) line: 655	
	CompilationUnit.processPhaseOperations(int) line: 631	
	CompilationUnit.compile(int) line: 608	
	GroovyCompilationUnitDeclaration.processToPhase(int) line: 214	
	GroovyParser.dietParse(ICompilationUnit, CompilationResult) line: 407	
	MultiplexingIndexingParser.parseCompilationUnit(ICompilationUnit, boolean, IProgressMonitor) line: 75	
	SourceIndexer.indexDocument() line: 108	
	JavaSearchParticipant.indexDocument(SearchDocument, IPath) line: 76	
	IndexManager.indexDocument(SearchDocument, SearchParticipant, Index, IPath) line: 519	
	IndexManager$1.execute(IProgressMonitor) line: 999	
	IndexManager(JobManager).run() line: 394	
	Thread.run() line: not available	

@eric-milles
Copy link
Member

The second thread you list is an indexer thread. The other thread is waiting for the indexer to complete so it can suggest missing imports. Do you find that the indexer thread is not making progress?

@wagnerma
Copy link
Author

I debugged a little more, yes the indexer thread is not making progress and blocks the UI. It seems working infinite in the add/rehash Method of SimpleWordSet. I my case, after a size of 1769469 it seems looping/working infinite.

Daemon Thread [Java indexing] (Suspended)	
	SimpleWordSet.add(char[]) line: 35	
	MemoryIndex.addIndexEntry(char[], char[], String) line: 63	
	Index.addIndexEntry(char[], char[], String) line: 100	
	JavaSearchDocument(SearchDocument).addIndexEntry(char[], char[]) line: 56	
	BinaryIndexer(AbstractIndexer).addIndexEntry(char[], char[]) line: 147	
	BinaryIndexer(AbstractIndexer).addMethodDeclaration(char[], char[], char[], int, char[], char[][], char[][], char[], int, char[], int, char[][], int) line: 178	
	BinaryIndexer.indexDocument() line: 763	
	JavaSearchParticipant.indexDocument(SearchDocument, IPath) line: 78	
	IndexManager.indexDocument(SearchDocument, SearchParticipant, Index, IPath) line: 519	
	AddJarFileToIndex.execute(IProgressMonitor) line: 236	
	IndexManager(JobManager).run() line: 394	
	Thread.run() line: not available	

@eric-milles
Copy link
Member

Can you see what document is being parsed by BinaryIndexer/JavaSearchDocument? And can you say what jar is being precessed by AddJarFileToIndex?

@wagnerma
Copy link
Author

Yep, it is the jar file containing our database Layer, a very big one, but the indexer never comes back. I have uploaded the jar, so you can debug the process hopefully better. Without the Groovy Plugin installed, the indexer has no problems.

Downlod link for the problem jar

@eric-milles
Copy link
Member

Thanks for doing some extra digging. Would you mind creating a very simple project that recreates your issue? That way I could load it into my workspace and try the same steps as you.

Also, have you tried the new Eclipse 4.7rc3 release? There is a new form of indexing and I am curious if the problem persists under the new indexing scheme.

@eric-milles
Copy link
Member

So here's what I did and had no issues. Hovering on the unresolved type gives me one completion immediately.

efc_dao

@wagnerma
Copy link
Author

wagnerma commented Jan 2, 2017

Well, the problem seems not isolatable. Bad. I get an infinite loop/hang with the new plugin..I retried Eclipse 4.5/4.6 and even 4.7M4, I always get the hang:

https://drive.google.com/uc?id=0B1EIYV0ihMjCZFVPMjBUWmQzdWs

With Eclipse 4.7M4 the same hang in SimpleWordSet (but I installed the 4.6 plugin, which perhaps don't use the new indexing?):

Daemon Thread [Java indexing] (Suspended)	
	SimpleWordSet.add(char[]) line: 35	
	SimpleWordSet.rehash() line: 62	
	SimpleWordSet.add(char[]) line: 42	
	MemoryIndex.addIndexEntry(char[], char[], String) line: 63	
	Index.addIndexEntry(char[], char[], String) line: 100	
	JavaSearchDocument(SearchDocument).addIndexEntry(char[], char[]) line: 56	
	BinaryIndexer(AbstractIndexer).addIndexEntry(char[], char[]) line: 147	
	BinaryIndexer(AbstractIndexer).addMethodDeclaration(char[], char[], char[], int, char[], char[][], char[][], char[], int, char[], int, char[][], int) line: 178	
	BinaryIndexer.indexDocument() line: 762	
	JavaSearchParticipant.indexDocument(SearchDocument, IPath) line: 78	
	IndexManager.indexDocument(SearchDocument, SearchParticipant, Index, IPath) line: 519	
	AddJarFileToIndex.execute(IProgressMonitor) line: 236	
	IndexManager(JobManager).run() line: 394	
	Thread.run() line: not available	

It seems I have to add debug output to see, what is happening... ;-(

@wagnerma
Copy link
Author

wagnerma commented Jan 6, 2017

Well, I think the problem exists, if the Eclipse index get trashed and needed to be completely rebuilded, e.g. upgrading to a new Eclipse version or deleting in the workspace the directory ".metadata\.plugins\org.eclipse.jdt.core". For large projects, like ours, this could be really time consuming. My workspace need 45 minutes for the index to build up. And the groovy quick fix then blocks the main eclipse thread:

Thread [main] (Suspended)	
	Thread.sleep(long) line: not available [native method]	
	IndexManager(JobManager).performConcurrentJob(IJob, int, IProgressMonitor) line: 251	
	BasicSearchEngine.searchAllTypeNames(char[][], char[][], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor) line: 2062	
	SearchEngine.searchAllTypeNames(char[][], char[][], IJavaSearchScope, TypeNameMatchRequestor, int, IProgressMonitor) line: 1230	
	TypeSearch.searchForTypes(GroovyCompilationUnit, Map<String,UnresolvedTypeData>) line: 88	
	AddMissingGroovyImportsResolver.getImportTypeSuggestions() line: 132	
	AddMissingGroovyImportsResolver.getQuickFixProposals() line: 208	
	GroovyQuickFixProcessor.getCorrections(IInvocationContext, IProblemLocation[]) line: 73	
	JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(ContributedProcessorDescriptor) line: 384	
	JavaCorrectionProcessor$SafeCorrectionCollector(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).run() line: 344	
	SafeRunner.run(ISafeRunnable) line: 42	
	JavaCorrectionProcessor$SafeCorrectionCollector(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).process(ContributedProcessorDescriptor) line: 339	
	JavaCorrectionProcessor.collectCorrections(IInvocationContext, IProblemLocation[], Collection<IJavaCompletionProposal>) line: 474	
	ProblemHover$ProblemInfo.getJavaAnnotationFixes(IJavaAnnotation) line: 102	
	ProblemHover$ProblemInfo.getCompletionProposals() line: 76	
	AbstractAnnotationHover$HoverControlCreator$1(AbstractAnnotationHover$AnnotationInformationControl).deferredCreateContent() line: 287	
	AbstractAnnotationHover$HoverControlCreator$1(AbstractAnnotationHover$AnnotationInformationControl).setInput(Object) line: 187	
	TextViewerHoverManager(AbstractInformationControlManager).internalShowInformationControl(Rectangle, Object) line: 1194	
	TextViewerHoverManager(AbstractInformationControlManager).presentInformation() line: 1163	
	TextViewerHoverManager(AbstractHoverInformationControlManager).presentInformation() line: 894	
	TextViewerHoverManager.doPresentInformation() line: 244	
	TextViewerHoverManager$5.run() line: 234	
	RunnableLock.run() line: 35	
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 182	
	Display.runAsyncMessages(boolean) line: 4203	
	Display.readAndDispatch() line: 3819	
	PartRenderingEngine$4.run() line: 1121	
	Realm.runWithDefault(Realm, Runnable) line: 336	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1022	
	E4Workbench.createAndRunUI(MApplicationElement) line: 150	
	Workbench$5.run() line: 687	
	Realm.runWithDefault(Realm, Runnable) line: 336	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 604	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 148	
	IDEApplication.start(IApplicationContext) line: 138	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 134	
	EclipseAppLauncher.start(Object) line: 104	
	EclipseStarter.run(Object) line: 388	
	EclipseStarter.run(String[], Runnable) line: 243	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	Method.invoke(Object, Object...) line: not available	
	Main.invokeFramework(String[], URL[]) line: 673	
	Main.basicRun(String[]) line: 610	
	Main.run(String[]) line: 1519	
	Main.main(String[]) line: 1492	

The problem seems in the class TypeSearch method searchForTypes running in the Eclipse main thread. There is the line
new SearchEngine().searchAllTypeNames(null, allTypes, scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);

The WAIT_UNTIL_READY_TO_SEARCH seems the problem, for me it is 45 minutes, and also the eclipse main thread is blocked. It would be better to stop the quick fix and tell the user it is not available at the moment because the index is build in the background. try it later. After 45 minutes all work fine, no eclipse hangs ;-)

@eric-milles
Copy link
Member

That seems sensible. I can see about tying the TypeSearch request into the progress monitor of the content assist and then you should get a progress dialog after a couple seconds with the option to cancel.

@wagnerma
Copy link
Author

wagnerma commented Jan 6, 2017

OK, this would be helpfull. At the moment it is not usable for us, when the complete index is rebuilded.

@eric-milles
Copy link
Member

Could you try with the latest snapshot?

@wagnerma
Copy link
Author

wagnerma commented Jan 7, 2017

Nope, eclipse is really strange. It still hangs:

Thread [main] (Suspended)	
	Object.wait(long) line: not available [native method]	
	ReadWriteMonitor(Object).wait() line: not available	
	ReadWriteMonitor.enterRead() line: 32	
	PatternSearchJob.search(Index, IProgressMonitor) line: 102	
	PatternSearchJob.execute(IProgressMonitor) line: 65	
	IndexManager(JobManager).performConcurrentJob(IJob, int, IProgressMonitor) line: 187	
	BasicSearchEngine.searchAllTypeNames(char[][], char[][], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor) line: 2062	
	SearchEngine.searchAllTypeNames(char[][], char[][], IJavaSearchScope, TypeNameMatchRequestor, int, IProgressMonitor) line: 1238	
	TypeSearch.searchForTypes(GroovyCompilationUnit, Map<String,UnresolvedTypeData>, IProgressMonitor) line: 91	
	AddMissingGroovyImportsResolver.getImportTypeSuggestions() line: 127	
	AddMissingGroovyImportsResolver.getQuickFixProposals() line: 198	
	GroovyQuickFixProcessor.getCorrections(IInvocationContext, IProblemLocation[]) line: 58	
	JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(ContributedProcessorDescriptor) line: 384	
	JavaCorrectionProcessor$SafeCorrectionCollector(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).run() line: 344	
	SafeRunner.run(ISafeRunnable) line: 42	
	JavaCorrectionProcessor$SafeCorrectionCollector(JavaCorrectionProcessor$SafeCorrectionProcessorAccess).process(ContributedProcessorDescriptor) line: 339	
	JavaCorrectionProcessor.collectCorrections(IInvocationContext, IProblemLocation[], Collection<IJavaCompletionProposal>) line: 474	
	ProblemHover$ProblemInfo.getJavaAnnotationFixes(IJavaAnnotation) line: 102	
	ProblemHover$ProblemInfo.getCompletionProposals() line: 76	
	AbstractAnnotationHover$HoverControlCreator$1(AbstractAnnotationHover$AnnotationInformationControl).deferredCreateContent() line: 287	
	AbstractAnnotationHover$HoverControlCreator$1(AbstractAnnotationHover$AnnotationInformationControl).setInput(Object) line: 187	
	TextViewerHoverManager(AbstractInformationControlManager).internalShowInformationControl(Rectangle, Object) line: 1194	
	TextViewerHoverManager(AbstractInformationControlManager).presentInformation() line: 1163	
	TextViewerHoverManager(AbstractHoverInformationControlManager).presentInformation() line: 894	
	TextViewerHoverManager.doPresentInformation() line: 244	
	TextViewerHoverManager$5.run() line: 234	
	RunnableLock.run() line: 35	
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 182	
	Display.runAsyncMessages(boolean) line: 4203	
	Display.readAndDispatch() line: 3819	
	PartRenderingEngine$4.run() line: 1121	
	Realm.runWithDefault(Realm, Runnable) line: 336	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1022	
	E4Workbench.createAndRunUI(MApplicationElement) line: 150	
	Workbench$5.run() line: 687	
	Realm.runWithDefault(Realm, Runnable) line: 336	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 604	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 148	
	IDEApplication.start(IApplicationContext) line: 138	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 134	
	EclipseAppLauncher.start(Object) line: 104	
	EclipseStarter.run(Object) line: 388	
	EclipseStarter.run(String[], Runnable) line: 243	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	Method.invoke(Object, Object...) line: not available	
	Main.invokeFramework(String[], URL[]) line: 673	
	Main.basicRun(String[]) line: 610	
	Main.run(String[]) line: 1519	
	Main.main(String[]) line: 1492	

Your code change to FORCE_IMMEDIATE_SEARCH is also blocked by eclipse in the class ReadWriteMonitor and method enterRead, wich is asked if a read is allowed in the curent state. It seems it is not, so it is blocked. Changing to policy IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH fixes the problem for me.

@wagnerma
Copy link
Author

wagnerma commented Jan 8, 2017

Thanks a lot, now we can finally use it. Any user info, that the quick fix and the full content assistent will be available when the indexer is ready would be helpfull. At the moment the user has no quick fix and only the default groovy methods are shown in the content assistent when the indexer is running. But that's an improvement, the blocking was the important one!

@wagnerma wagnerma closed this as completed Jan 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants