#6 NullPointerException during report generation

closed-out-of-date
Ant Task (2)
5
2006-03-16
2005-12-11
Curt Arnold
No

I've been adding a clirr target to the log4j build file
and have been encountering a NullPointerException when
attempting to generate a compatibility report.

The kludgy patch attached fix the problem for me, but
doesn't explain why BCEL was throwing a NPE. The
underlying problem may be in BCEL.

Stack trace as follows:

C:\workspace\trunk\build.xml:804:
java.lang.NullPointerException
at org.apache.tools.ant.Task.perform(Task.java:373)
at org.apache.tools.ant.Target.execute(Target.java:341)
at
org.apache.tools.ant.Target.performTasks(Target.java:369)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.NullPointerException
at
org.apache.bcel.classfile.JavaClass.getAllInterfaces(JavaClass.java:808)
at
net.sf.clirr.core.internal.bcel.BcelJavaType.getAllInterfaces(BcelJavaType.java:78)
at
net.sf.clirr.core.internal.checks.InterfaceSetCheck.check(InterfaceSetCheck.java:58)
at
net.sf.clirr.core.Checker.runClassChecks(Checker.java:190)
at net.sf.clirr.core.Checker.reportDiffs(Checker.java:136)
at net.sf.clirr.ant.AntTask.execute(AntTask.java:303)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
... 10 more
--- Nested Exception ---
java.lang.NullPointerException
at
org.apache.bcel.classfile.JavaClass.getAllInterfaces(JavaClass.java:808)
at
net.sf.clirr.core.internal.bcel.BcelJavaType.getAllInterfaces(BcelJavaType.java:78)
at
net.sf.clirr.core.internal.checks.InterfaceSetCheck.check(InterfaceSetCheck.java:58)
at
net.sf.clirr.core.Checker.runClassChecks(Checker.java:190)
at net.sf.clirr.core.Checker.reportDiffs(Checker.java:136)
at net.sf.clirr.ant.AntTask.execute(AntTask.java:303)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at
org.apache.tools.ant.Target.performTasks(Target.java:369)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

Total time: 2 seconds

Discussion

  • Curt Arnold

    Curt Arnold - 2005-12-11

    Kludgy patch

     
  • Lars Kühne

    Lars Kühne - 2005-12-28

    Logged In: YES
    user_id=401384

    Thanks for the patch, but that just hides the problem
    instead of fixing it.

    I had a quick look at the code in BCEL, and I guess the
    problem is this lovely error handling code for a
    ClassNotFoundException in BCEL's
    org.apache.bcel.classfile.JavaClass:

    public JavaClass[] getInterfaces() {
    // ...
    try {
    // ...
    }
    } catch(ClassNotFoundException e) {
    System.err.println(e);
    return null; // <---- lk: lovely
    }
    //...
    }

    public JavaClass[] getAllInterfaces() {
    // ...
    while(...) {
    // ...
    JavaClass[] interfaces = clazz.getInterfaces();
    //...
    for(int i = 0; i < interfaces.length; i++) { // <--
    lk: boom
    //...
    }
    }
    }

    You might want to check your classpath setup instead of
    using your workaround, but I guess we really need to replace
    BCEL with a more mature alternative to fix this.

     
  • Curt Arnold

    Curt Arnold - 2005-12-28

    Logged In: YES
    user_id=27193

    I guess I forgot to do a follow up on this. The bug is in BCEL and had already
    been resolved in the SVN HEAD. So using clirr-0.6.jar and a built from the SVN
    version of BCEL will avoid the problem.

     
  • Lars Kühne

    Lars Kühne - 2005-12-29

    Logged In: YES
    user_id=401384

    Thanks for the follow up, and indeed the BCEL code looks
    much better now (even though this is a source incompatible
    change, as getAllInterfcaes now throws a checked exception).

    I'll upgrade BCEL as soon as a bugfix release becomes available.

    Leaving this bug open as a reminder.

     
  • Lars Kühne

    Lars Kühne - 2006-03-16
    • status: open --> closed-out-of-date
     
  • Lars Kühne

    Lars Kühne - 2006-03-16

    Logged In: YES
    user_id=401384

    Clirr now uses ASM instead of BCEL.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks