Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 497195

Summary: NPE in ProblemReporter during creation of AST
Product: [Eclipse Project] JDT Reporter: Edward Poot <edwardmp>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: stephan.herrmann
Version: 4.4   
Target Milestone: 4.4.2   
Hardware: All   
OS: Linux   
Whiteboard:

Description Edward Poot CLA 2016-07-03 08:28:28 EDT
I couldn't select the right version in the dropdown, I am using this:
<dependency>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>org.eclipse.jdt.core</artifactId>
            <version>3.10.0</version>
</dependency>

There doesn't appear to be any 4.x version for this although 4.x is listed in the dropdown.

In some cases I encounter the following NPE:
SEVERE: Servlet.service() for servlet [Jersey Web Application] in context with path [/aevas] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.invalidMethod(ProblemReporter.java:4027)
        at org.eclipse.jdt.internal.compiler.ast.MessageSend.binding(MessageSend.java:1032)
        at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolvePolyExpressionArguments(ASTNode.java:712)
        at org.eclipse.jdt.internal.compiler.lookup.Scope.inferInvocationType(Scope.java:5153)
        at org.eclipse.jdt.internal.compiler.lookup.Scope.findDefaultAbstractMethod(Scope.java:1297)
        at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1767)
        at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1662)
        at org.eclipse.jdt.internal.compiler.lookup.Scope.getImplicitMethod(Scope.java:2621)
        at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:667)
        at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:250)
        at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:619)
        at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:299)
        at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:529)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1207)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1320)
        at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:587)
        at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:770)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1005)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:636)
        at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:990)
        at eu.sig.aevas.invokedlibrarymethods.java.InvokedLibraryMethodsExtractorJava.createASTForSourceFile(InvokedLibraryMethodsExtractorJava.java:57)

Platform is Linux research-edward 3.13.0-86-generic #131-Ubuntu SMP Thu May 12 23:33:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux.
Comment 1 Stephan Herrmann CLA 2016-07-03 09:44:33 EDT
(In reply to Edward Poot from comment #0)
> I couldn't select the right version in the dropdown, I am using this:
> <dependency>
>             <groupId>org.eclipse.jdt</groupId>
>             <artifactId>org.eclipse.jdt.core</artifactId>
>             <version>3.10.0</version>
> </dependency>
> 
> There doesn't appear to be any 4.x version for this although 4.x is listed
> in the dropdown.

JDT/Core 3.10.0 corresponds to Eclipse 4.4.0

This means you are two yearly versions behind. Can you try 3.12.0 ?
I don't know where you are getting jdt.core from. If it isn't available from your regular maven repos, please try repo.eclipse.org, in particular: https://repo.eclipse.org/content/groups/eclipse/


> In some cases I encounter the following NPE:

For us to analyse this problem, we'd need Java source code leading to this.
OTOH, chances are that the NPE has already been fixed, perhaps it's bug 444665. Seeing that fix back ported to 4.4.2, you could even try jdt.core 3.10.2 if upgrading to 3.12.0 is - for some unknown reasons - not an option for you.
Comment 2 Edward Poot CLA 2016-07-03 10:18:55 EDT
Thanks for the quick response. 3.10.0 is the latest version available through Maven Central Repository: http://mvnrepository.com/artifact/org.eclipse.jdt/org.eclipse.jdt.core

I will try using the newer version, but it would still be convenient if the latest version can just be include in the Maven Central Repository
Comment 3 Edward Poot CLA 2016-07-03 10:44:34 EDT
I also need the org.eclipse.core.runtime.Plugin package, do you happen to know in which repository I can find it?
Comment 4 Stephan Herrmann CLA 2016-07-03 10:56:38 EDT
repo.eclipse.org is a searchable nexus. But I admit, finding matching versions of different plugins is not trivial.

for jdt 3.10.2 you may try org.eclipse.core.runtime 3.10.0.v20140318-2214 (apparently no changes in the .2 release).

for jdt 3.12.0 it should be org.eclipse.core.runtime 3.12.0.v20160606-1342 but this one I don't see on repo.eclipse.org :(
OTOH, jdt.core claims to be compatible with any org.eclipse.core.runtime in [3.3.0,4.0.0), so you may want to try just the latest version of core.runtime that you can find in maven repos.
Comment 5 Edward Poot CLA 2016-07-03 11:01:00 EDT
Thanks. Yes it proves to be very difficult to find this stuff as an outsider.
I've got org.eclipse.core:org.eclipse.core.runtime:jar:3.9.0.v20130326-1255 but to compile I also need `org.osgi.framework.BundleContext`, and which one this is is opaque to me.
Comment 6 Stephan Herrmann CLA 2016-07-03 11:09:04 EDT
(In reply to Edward Poot from comment #5)
> Thanks. Yes it proves to be very difficult to find this stuff as an outsider.
> I've got org.eclipse.core:org.eclipse.core.runtime:jar:3.9.0.v20130326-1255
> but to compile I also need `org.osgi.framework.BundleContext`, and which one
> this is is opaque to me.

That class is from org.eclipse.osgi.

If the ripple continues, easiest way to see all the dependencies might be the following:

- install a JDT workspace using the eclipse installer (in "advanced" mode):
  - start with Eclipse IDE for Committers
  - under Eclipse Projects find "JDT" and sected only "JDT Core".
  This should automatically create an eclipse + workspace with jdt core
  projects checked out

- Here Open Type will find all the types you need, and when you enable
  Editor Breadcrumbs you immediately see the contributing plugin.

Alternatively to the 1. step, an empty plug-in project with dependency on jdt.core might also do the trick - if you have Eclipse IDE for Committers.
Comment 7 Stephan Herrmann CLA 2016-07-03 17:37:29 EDT
Tentatively marking as duplicate.

Please re-open if you can reproduce it using a recent build.

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