You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2014/04/24 14:43:15 UTC

[jira] [Updated] (BCEL-22) JavaClass.getAllInterfaces() can throw NullPointerException when classpath is incomplete

     [ https://issues.apache.org/jira/browse/BCEL-22?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated BCEL-22:
-------------------------------

          Description: 
This bug affects revision 1.13 of JavaClass.java.

The org.apache.bcel.classfile.JavaClass.getAllInterfaces() method calls
JavaClass.getInterfaces(), which uses a Repository to look up the class's interfaces. If any of the interfaces are not found, then getInterfaces() returns null.  However, getAllInterfaces() tries to dereference this null reference, leading to the exception.

A simple fix would be to return a zero-length array from getInterfaces() in the case where a repository lookup fails.

A better fix would be to have getInterfaces() throw the ClassNotFoundException out of the method.  In general, I think repository lookup failures should be propagated as much as possible, so the program using BCEL can detect them. Right now there is a println() to System.err in getInterfaces(), which is not a very useful way to report the failure.

  was:
This bug affects revision 1.13 of JavaClass.java.

The org.apache.bcel.classfile.JavaClass.getAllInterfaces() method calls
JavaClass.getInterfaces(), which uses a Repository to look up the class's
interfaces.  If any of the interfaces are not found, then getInterfaces()
returns null.  However, getAllInterfaces() tries to dereference this null
reference, leading to the exception.

A simple fix would be to return a zero-length array from getInterfaces() in the
case where a repository lookup fails.

A better fix would be to have getInterfaces() throw the ClassNotFoundException
out of the method.  In general, I think repository lookup failures should be
propagated as much as possible, so the program using BCEL can detect them. 
Right now there is a println() to System.err in getInterfaces(), which is not a
very useful way to report the failure.

             Priority: Major
    Affects Version/s:     (was: unspecified)
        Fix Version/s: 5.2
             Priority:   (was: P3)
             Severity:   (was: normal)

> JavaClass.getAllInterfaces() can throw NullPointerException when classpath is incomplete
> ----------------------------------------------------------------------------------------
>
>                 Key: BCEL-22
>                 URL: https://issues.apache.org/jira/browse/BCEL-22
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>         Environment: Operating System: other
> Platform: All
>            Reporter: David Hovemeyer
>            Assignee: Apache Commons Developers
>             Fix For: 5.2
>
>
> This bug affects revision 1.13 of JavaClass.java.
> The org.apache.bcel.classfile.JavaClass.getAllInterfaces() method calls
> JavaClass.getInterfaces(), which uses a Repository to look up the class's interfaces. If any of the interfaces are not found, then getInterfaces() returns null.  However, getAllInterfaces() tries to dereference this null reference, leading to the exception.
> A simple fix would be to return a zero-length array from getInterfaces() in the case where a repository lookup fails.
> A better fix would be to have getInterfaces() throw the ClassNotFoundException out of the method.  In general, I think repository lookup failures should be propagated as much as possible, so the program using BCEL can detect them. Right now there is a println() to System.err in getInterfaces(), which is not a very useful way to report the failure.



--
This message was sent by Atlassian JIRA
(v6.2#6252)