Share

JRefactory

Tracker: Bugs

5 NPE in PrettyPrinter when given invalid class decl - ID: 1674321
Last Update: Tracker Item Submitted ( mikebond )

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.


Michael Bond ( mikebond ) - 2007-03-05 19:40

5

Open

None

Mike Atkinson

Pretty Printer

None

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.