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
--- LineNumberTable.java.orig 2002-12-02 13:07:31.000000000 -0500
+++ LineNumberTable.java 2002-12-02 13:07:37.000000000 -0500
@@ -213,6 +213,12 @@
}
} while(l <= r);
+ /* It's possible that we did not find any valid entry for the bytecode
+ * offset we were looking for.
+ */
+ if (min_index < 0)
+ return -1;
+
return line_number_table[min_index].getLineNumber();
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>