GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-1214

NullPointerException in JDTResolver.recordDependency

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.0.Release
    • Component/s: Compiler Integration
    • Labels:
      None
    • Environment:
      Version 2.5.2.xx-20111007-1500-e36
    • Number of attachments :
      0

      Description

      If I have a Java class called "org.acme.Foo", then the script file named "org/acme/Foo/xyz.groovy" loses DSLD content assist support.

      Looking at the Groovy event console, I see a NullPointerException as below.

      The problem appears to be related to the fact that the directory name collides with another Java class, as Groovy files placed elsewhere do not get this problem. Note however that this xyz.groovy file doesn't have a package declaration.

      See GRECLIPSE-1076 for a package/class conflict related issue that may or may not be related.

      java.lang.NullPointerException
      	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.recordDependency(JDTResolver.java:316)
      	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.resolveFromCompileUnit(JDTResolver.java:155)
      	at org.codehaus.groovy.control.ResolveVisitor.resolveNestedClass(ResolveVisitor.java:331)
      	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:304)
      	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.resolve(JDTResolver.java:292)
      	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:261)
      	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.resolve(JDTResolver.java:303)
      	at org.codehaus.groovy.eclipse.dsl.lookup.ResolverCache.resolve(ResolverCache.java:62)
      	at org.codehaus.groovy.eclipse.dsl.contributions.DSLContributionGroup.delegatesTo(DSLContributionGroup.java:249)
      	at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:362)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
      	at eclipse$_run_closure1.doCall(eclipse.dsld:8)
      	at sun.reflect.GeneratedMethodAccessor123.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
      	at eclipse$_run_closure1.doCall(eclipse.dsld)
      	at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      	at groovy.lang.Closure.call(Closure.java:282)
      	at groovy.lang.Closure.call(Closure.java:277)
      	at org.codehaus.groovy.eclipse.dsl.contributions.DSLContributionGroup.getContributions(DSLContributionGroup.java:102)
      	at org.codehaus.groovy.eclipse.dsl.DSLDStore.findContributions(DSLDStore.java:132)
      	at org.codehaus.groovy.eclipse.dsl.lookup.DSLDTypeLookup.lookupTypeAndDeclaration(DSLDTypeLookup.java:58)
      	at org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup.lookupType(AbstractSimplifiedTypeLookup.java:81)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleExpression(TypeInferencingVisitorWithRequestor.java:763)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstantExpression(TypeInferencingVisitorWithRequestor.java:1321)
      	at org.codehaus.groovy.ast.expr.ConstantExpression.visit(ConstantExpression.java:55)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1406)
      	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:75)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:209)
      	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:179)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1252)
      	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitClosureExpression(CodeVisitorSupport.java:174)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitClosureExpression(TypeInferencingVisitorWithRequestor.java:1085)
      	at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:45)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitListOfExpressions(CodeVisitorSupport.java:280)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTupleExpression(CodeVisitorSupport.java:178)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitTupleExpression(TypeInferencingVisitorWithRequestor.java:1620)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitArgumentlistExpression(CodeVisitorSupport.java:290)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitArgumentlistExpression(TypeInferencingVisitorWithRequestor.java:907)
      	at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:73)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1426)
      	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:75)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:209)
      	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
      	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:179)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1252)
      	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:102)
      	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:113)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:646)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:390)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:236)
      	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:191)
      	at org.codehaus.groovy.eclipse.editor.highlighting.GatherSemanticReferences.findSemanticHighlightingReferences(GatherSemanticReferences.java:52)
      	at org.codehaus.groovy.eclipse.editor.highlighting.GroovySemanticReconciler.reconciled(GroovySemanticReconciler.java:149)
      	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.reconciled(CompilationUnitEditor.java:1632)
      	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconciled(JavaReconcilingStrategy.java:212)
      	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconciled(JavaCompositeReconcilingStrategy.java:161)
      	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:110)
      	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
      	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
      

        Activity

        Hide
        Andrew Eisenberg added a comment -

        As a work around, can you try right clicking on the script -> Build Path -> Exclude? Does that at least prevent the NPEs from happening?

        Show
        Andrew Eisenberg added a comment - As a work around, can you try right clicking on the script -> Build Path -> Exclude? Does that at least prevent the NPEs from happening?
        Hide
        Kohsuke Kawaguchi added a comment -

        I tried that but it doesn't seem to make any difference, AFAICT.

        Show
        Kohsuke Kawaguchi added a comment - I tried that but it doesn't seem to make any difference, AFAICT.
        Hide
        Andy Clement added a comment -

        I was just going to put in a guard for the NPE, but have had second thoughts, it'll just be hiding something else if I do. The assertion that the scope has been set (other code than simple recordDependency relies on the scope being set correctly).

        It may well be related to GRECLIPSE-1076. However in a rudimentary attempt to create the problem scenario here, I don't get that NPE shown above, I get a somewhat related but different variant:

        Ignoring GroovyBugError since it is likely caused by earlier issues.  Ignored problem is 'BUG! exception in phase 'semantic analysis' in source unit '/Users/aclement/workspaces/grdev_37/JP/src/com/acme/Foo/xyz.groovy' commencingResolution failed: declaration found, but unexpectedly found no scope for com.acme.Foo.xyz'
        org.codehaus.jdt.groovy.internal.compiler.ast.GroovyEclipseBug: commencingResolution failed: declaration found, but unexpectedly found no scope for com.acme.Foo.xyz
        	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.commencingResolution(JDTResolver.java:578)
        	at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1331)
        	at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:165)
        	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.startResolving(JDTResolver.java:626)
        	at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:654)
        	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:915)
        	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:589)
        	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538)
        	at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:168)
        	at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1523)
        	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:979)
        	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1018)
        	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody0(CompilationUnitProblemFinder.java:218)
        	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody1$advice(CompilationUnitProblemFinder.java:244)
        	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:1)
        	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:284)
        	at org.codehaus.jdt.groovy.model.GroovyReconcileWorkingCopyOperation.makeConsistent(GroovyReconcileWorkingCopyOperation.java:80)
        	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
        	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
        	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
        	at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:410)
        	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126)
        	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108)
        	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89)
        	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
        	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87)
        	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151)
        	at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
        	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:104)
        

        (which is the same 'no scope' problem but this time caught in time rather than NPE'd upon).

        Show
        Andy Clement added a comment - I was just going to put in a guard for the NPE, but have had second thoughts, it'll just be hiding something else if I do. The assertion that the scope has been set (other code than simple recordDependency relies on the scope being set correctly). It may well be related to GRECLIPSE-1076 . However in a rudimentary attempt to create the problem scenario here, I don't get that NPE shown above, I get a somewhat related but different variant: Ignoring GroovyBugError since it is likely caused by earlier issues. Ignored problem is 'BUG! exception in phase 'semantic analysis' in source unit '/Users/aclement/workspaces/grdev_37/JP/src/com/acme/Foo/xyz.groovy' commencingResolution failed: declaration found, but unexpectedly found no scope for com.acme.Foo.xyz' org.codehaus.jdt.groovy.internal.compiler.ast.GroovyEclipseBug: commencingResolution failed: declaration found, but unexpectedly found no scope for com.acme.Foo.xyz at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.commencingResolution(JDTResolver.java:578) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1331) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:165) at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.startResolving(JDTResolver.java:626) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:654) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:915) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:589) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:168) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1523) at org.eclipse.jdt.internal.compiler. Compiler .resolve( Compiler .java:979) at org.eclipse.jdt.internal.compiler. Compiler .resolve( Compiler .java:1018) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody0(CompilationUnitProblemFinder.java:218) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody1$advice(CompilationUnitProblemFinder.java:244) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:1) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:284) at org.codehaus.jdt.groovy.model.GroovyReconcileWorkingCopyOperation.makeConsistent(GroovyReconcileWorkingCopyOperation.java:80) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788) at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:410) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:104) (which is the same 'no scope' problem but this time caught in time rather than NPE'd upon).
        Hide
        Andy Clement added a comment -

        I found a situation where this kind of setup can lead to the missing scope, that is now fixed, should be in a dev build tomorrow. It may alleviate the exceptions shown in this bug. It is a variant of GRECLIPSE-1076 but that one is much more difficult to solve nicely because the script has a package name. Here with no package name we just have to allow the script to be as if declared in the default package.

        Show
        Andy Clement added a comment - I found a situation where this kind of setup can lead to the missing scope, that is now fixed, should be in a dev build tomorrow. It may alleviate the exceptions shown in this bug. It is a variant of GRECLIPSE-1076 but that one is much more difficult to solve nicely because the script has a package name. Here with no package name we just have to allow the script to be as if declared in the default package.
        Hide
        Andrew Eisenberg added a comment -

        Fixed now.

        Show
        Andrew Eisenberg added a comment - Fixed now.

          People

          • Assignee:
            Andy Clement
            Reporter:
            Kohsuke Kawaguchi
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: