jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Hovemeyer <dav...@cs.umd.edu>
Subject bug in LineNumberTable.getSourceLine()
Date Mon, 02 Dec 2002 18:31:14 GMT
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.


View raw message