forked from phoedos/pmd
#1355 NullPointerException in a java file having a single comment line
This commit is contained in:
@ -47,8 +47,11 @@ public class ASTCompilationUnit extends AbstractJavaTypeNode implements RootNode
|
||||
}
|
||||
|
||||
public ASTPackageDeclaration getPackageDeclaration() {
|
||||
Node n = jjtGetChild(0);
|
||||
return n instanceof ASTPackageDeclaration ? (ASTPackageDeclaration) n : null;
|
||||
if (jjtGetNumChildren() > 0) {
|
||||
Node n = jjtGetChild(0);
|
||||
return n instanceof ASTPackageDeclaration ? (ASTPackageDeclaration) n : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ClassTypeResolver getClassTypeResolver() {
|
||||
|
@ -79,6 +79,14 @@ public class ParserCornersTest extends ParserTst {
|
||||
+ " private void deleteDirectory(String path) {\n" + " LOG.debug(path);\n" + " }\n" + "}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for https://sourceforge.net/p/pmd/bugs/1355/
|
||||
*/
|
||||
@Test
|
||||
public void emptyFileJustComment() {
|
||||
parseJava18("// just a comment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleExceptionCatching() {
|
||||
String code = "public class Foo { public void bar() { "
|
||||
|
@ -19,5 +19,6 @@
|
||||
* [#1345](https://sourceforge.net/p/pmd/bugs/1345/): UseCollectionIsEmpty throws NullPointerException
|
||||
* [#1353](https://sourceforge.net/p/pmd/bugs/1353/): False positive "Only One Return" with lambda
|
||||
* [#1354](https://sourceforge.net/p/pmd/bugs/1354/): Complex FieldDeclarationsShouldBeAtStartOfClass false positive with Spring annotations
|
||||
* [#1355](https://sourceforge.net/p/pmd/bugs/1355/): NullPointerException in a java file having a single comment line
|
||||
|
||||
**API Changes:**
|
||||
|
Reference in New Issue
Block a user