Bug 10898 - DOM/AST: NullPointerException
Summary: DOM/AST: NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows NT
: P2 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-06 15:39 EST by Luc Bourlier CLA
Modified: 2002-03-07 11:16 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luc Bourlier CLA 2002-03-06 15:39:23 EST
The following code generates a NullPointerException. It seems to be because the
method has no return type.

public class Test {
  public static void main(String[] args) {
    String source = "public class Foo { bar() {}}";
    CompilationUnit unit = AST.parseCompilationUnit(source.toCharArray());
  }
}

java.lang.NullPointerException
  at org.eclipse.jdt.core.dom.ASTConverter.convertType(ASTConverter.java:457)
  at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:545)
  at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:163)
  at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:70)
  at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:310)
  at Test.main(Test.java:17)
Exception in thread "main"
Comment 1 Olivier Thomann CLA 2002-03-07 11:16:40 EST
The return type of the method declaration is null and I am trying to convert a null type. This led to a 
NPE. Now I ignore the conversion of the return type if it is null. This means that the return type of 
the method will be void if you asked for it.
If you asked for binding, then you will get an error 
reported in the compilation unit's messages collection. The message is "Return type for the 
method is missing". I think this is perfectly acceptable.
Fixed and released in HEAD.