partha-das / jsdt-jquery

Automatically exported from code.google.com/p/jsdt-jquery
0 stars 0 forks source link

NPE in isDeferredConstructorCall(IExpression expression) during type inferencing #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Clone the angular-phonecat project from GitHub and switch it to the tag 
'step-12':
> git clone https://github.com/angular/angular-phonecat.git
> cd angular-phonecat
> git checkout step-12
2. Import the project and configure it as JavaScript project
3. Add jQuery Library (by jsdt-jquery)
4. After the issue 
https://code.google.com/a/eclipselabs.org/p/jsdt-jquery/issues/detail?id=14 is 
fixed, see the following NPE happens while inferring types for 
angular-phonecat/app/lib/angular/angular.js javascript:

!ENTRY org.eclipse.wst.jsdt.core 4 4 2015-03-20 17:15:52.765
!MESSAGE error during type inferencing
!STACK 0
java.lang.NullPointerException
    at org.eclipselabs.jsdt.jquery.api.infer.QueryDeferredInferrer.isDeferredConstructorCall(QueryDeferredInferrer.java:59)
    at org.eclipselabs.jsdt.jquery.api.infer.QueryDeferredInferrer.visit(QueryDeferredInferrer.java:43)
    at org.eclipse.wst.jsdt.internal.compiler.DelegateASTVisitor.visit(DelegateASTVisitor.java:713)
    at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.traverseLocal(LocalDeclaration.java:282)
    at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:275)
    at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:164)
    at org.eclipse.wst.jsdt.internal.compiler.ast.FunctionExpression.traverse(FunctionExpression.java:48)
    at org.eclipse.wst.jsdt.internal.compiler.ast.Assignment.traverse(Assignment.java:242)
    at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.traverseLocal(LocalDeclaration.java:289)
    at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:275)
    at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:627)
    at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:607)
    at org.eclipselabs.jsdt.jquery.api.infer.JQueryInferEngine.doInfer(JQueryInferEngine.java:44)
    at org.eclipse.wst.jsdt.internal.compiler.parser.Parser.inferTypes(Parser.java:7108)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:144)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.core.infer.InferredType.resolveType(InferredType.java:492)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:218)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:184)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFunctions(SourceTypeBinding.java:596)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:259)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:195)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:246)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:516)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MultipleTypeBinding.<init>(MultipleTypeBinding.java:30)
    at org.eclipse.wst.jsdt.core.infer.InferredType.resolveType(InferredType.java:489)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor(SourceTypeBinding.java:1744)
    at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:347)
    at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:488)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.findMethod(MethodScope.java:492)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getFieldOrMethod(Scope.java:1510)
    at org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference.resolveType(FieldReference.java:212)
    at org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference.resolveType(FieldReference.java:138)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFields(SourceTypeBinding.java:396)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:260)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:195)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:246)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:516)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope.connectMixins(ClassScope.java:508)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:541)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:859)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:512)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.core.infer.InferredType.resolveType(InferredType.java:492)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFields(SourceTypeBinding.java:365)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:260)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:195)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:246)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:516)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.core.infer.InferredType.resolveType(InferredType.java:492)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:218)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:184)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFunctions(SourceTypeBinding.java:596)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:259)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:195)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:246)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:516)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.addUnitsContainingBindings(LookupEnvironment.java:184)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:417)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:343)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:323)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:687)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:575)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyBuilder.buildSupertypes(HierarchyBuilder.java:126)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.build(IndexBasedHierarchyBuilder.java:182)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.TypeHierarchy.compute(TypeHierarchy.java:306)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1026)
    at org.eclipse.wst.jsdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:90)
    at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:742)
    at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
    at org.eclipse.wst.jsdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:624)
    at org.eclipse.wst.jsdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:599)
    at org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:119)
    at org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:79)
    at org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache.getMethodOverrideTester(SuperTypeHierarchyCache.java:88)
    at org.eclipse.wst.jsdt.ui.OverrideIndicatorLabelDecorator.getOverrideIndicators(OverrideIndicatorLabelDecorator.java:158)
    at org.eclipse.wst.jsdt.ui.OverrideIndicatorLabelDecorator.computeAdornmentFlags(OverrideIndicatorLabelDecorator.java:126)
    at org.eclipse.wst.jsdt.ui.OverrideIndicatorLabelDecorator.decorate(OverrideIndicatorLabelDecorator.java:221)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:273)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:83)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:367)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:349)
    at org.eclipse.ui.internal.decorators.DecorationScheduler$1.ensureResultCached(DecorationScheduler.java:372)
    at org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:332)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

What is the expected output? What do you see instead?

- no exceptions in Error Log

What version of the product are you using? On what operating system?

Eclipse Mars + WTP 3.7

Please provide any additional information below.

NPE happens for multiple local declarations during the type inference, the 
following code snippet demonstrates the local declaration that has expression 
== null:

var message, i;

Original issue reported on code.google.com by victor.r...@gmail.com on 20 Mar 2015 at 2:37

GoogleCodeExporter commented 9 years ago
The fix could be in adding an additional null-check for expression value.

See jsdt-jquery-issue15.diff patch attached

Original comment by victor.r...@gmail.com on 20 Mar 2015 at 2:38

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in 1.8.0

Original comment by philippe...@gmail.com on 10 Apr 2015 at 11:48

GoogleCodeExporter commented 9 years ago
Issue 12 has been merged into this issue.

Original comment by philippe...@gmail.com on 10 Apr 2015 at 1:14