A null pointer exception occurs if you try to process a Java file that uses
an invalid class name:
public class Bug.java {
(It should be Bug instead of Bug.java)
It turns out this NPE occurs because ExceptionPrinter.getInstance() returns
ExceptionPrinter.singleton without checking if it's null. Since other
static methods in ExceptionPrinter first check if singleton is null (and
initialize it if so), I think a good fix is to have
ExceptionPrinter.getInstance() do the same.
Command line:
java PrettyPrinter Bug.java
Exception stack trace:
NullPointerException:
at
net.sourceforge.jrefactory.factory.ParserFactory.getAbstractSyntaxTree(Pars
erFactory.java:46)
at org.acm.seguin.pretty.PrettyPrintFile.apply(PrettyPrintFile.java:102)
at
org.acm.seguin.tools.builder.PrettyPrinter.visit(PrettyPrinter.java:77)
at
org.acm.seguin.io.DirectoryTreeTraversal.traverse(DirectoryTreeTraversal.ja
va:91)
at
org.acm.seguin.io.DirectoryTreeTraversal.run(DirectoryTreeTraversal.java:43
)
at
org.acm.seguin.tools.builder.PrettyPrinter.prettyPrinter(PrettyPrinter.java
:163)
at
org.acm.seguin.tools.builder.PrettyPrinter.main(PrettyPrinter.java:143)
at PrettyPrinter.main(PrettyPrinter.java:54)
Hope this helps. Please let me know if you'd like more info.
Mike Atkinson
Pretty Printer
None
Public