You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by David Hovemeyer <da...@cs.umd.edu> on 2002/12/02 19:31:14 UTC

bug in LineNumberTable.getSourceLine()

There is a subtle bug in org.apache.bcel.classfile.LineNumberTable,
in the getSourceLine() method.  Specifically, the line number table
may start with an entry with a PC greater than the first actual bytecode
in the method.  For example, I encountered a method with the following
line number table, which consists of a single entry:

  Entry 0: pc=8, line=41

(In case you're interested, this line number table is from the
JavaMail library downloaded from http://java.sun.com/products/javamail/,
in the run() method of the "javax.mail.SecuritySupport12$2" class.)

When LineNumberTable.getSourceLine() is called asking for the
line number of pos == 0, it throws an ArrayIndexOutOfBoundsException
because it does not find any possible entry in the table that matches
the requested PC value.

Anyway, there is a very simple fix, which is to return -1 if no valid
entry was found in the line number table.  I've attached a small patch
which does this check.

I'm using BCEL 5.0, but I believe the same problem exists in the current
CVS code.

-Dave