Bug 80960 - [dom] NPE in ASTConverter#convert(...)
Summary: [dom] NPE in ASTConverter#convert(...)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-14 13:03 EST by Jerome Lanneluc CLA
Modified: 2004-12-14 23:33 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 Jerome Lanneluc CLA 2004-12-14 13:03:19 EST
I20041214-0800

The following CU causes a NPE in ASTConverter#convert
import java.util.*;
public class X {
  public enum Rank { DEUCE, THREE, FOUR, FIVE, SIX,
    SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE }

  //public enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }
  public enum Suit{

  private X(int rank, int suit) {  
  }
  
  private static final List<X> protoDeck = new ArrayList<X>();
  
  public static ArrayList<X> newDeck() {
      return new ArrayList<X>(protoDeck); // Return copy of prototype deck
  }
}

The stack trace is:
java.lang.NullPointerException
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1314)
        at
org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:238)
        at
org.eclipse.jdt.core.dom.ASTConverter.convertToEnumDeclaration(ASTConverter.java:2607)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2356)
        at
org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:180)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2419)
        at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1159)
        at
org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:220)
        at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:729)
        at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:574)
        at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:563)
        at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:494)
        at
org.eclipse.jdt.internal.ui.text.java.hover.NLSStringHover.getHoverInfo(NLSStringHover.java:84)
        at
org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
        at
org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
        at
org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:160)
Comment 1 Olivier Thomann CLA 2004-12-14 13:27:50 EST
Fix is trivial.
Missing a null check.
Comment 2 Olivier Thomann CLA 2004-12-14 13:45:06 EST
Adding null check.
Fixed and released in HEAD.
Added test092 in ASTConverter15Test.
I will open a new PR for improving the error recovery in this case.
Comment 3 Olivier Thomann CLA 2004-12-14 13:50:06 EST
See bug 80970.
Comment 4 Olivier Thomann CLA 2004-12-14 23:33:18 EST
Verified in 200412141600