Community
Participate
Working Groups
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)
Fix is trivial. Missing a null check.
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.
See bug 80970.
Verified in 200412141600