diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java index 75e674ea7..f2b391865 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java @@ -130,8 +130,13 @@ class TreeWalker { mMessages.reset(); notifyBegin(aContents); - aAST.setParent(null); - process(aAST); + + // empty files are not flagged by javac, will yield aAST == null + if (aAST != null) { + aAST.setParent(null); + process(aAST); + } + notifyEnd(); }