Hello,
I just got back to using Javassist after some unsuccessful earlier attempts. I was hitting a strange NullPointerException during execution of some methods in classes I had instrumented with Javassist reflection.
The problem turned out to be some faulty logic in ClassMetaobject for determining the list of available methods; it was failing to see final methods defined by reflective superclasses - so the methods[] array had some null elements that should not have been null.
Here's my fix, based on the Javassist 3.0beta release code:
--- src/main/javassist/reflect/ClassMetaobject.java 1 Jul 2004 23:26:57 -0000 1.1.1.1
+++ src/main/javassist/reflect/ClassMetaobject.java 20 Aug 2004 18:20:53 -0000
@@ -246,7 +246,8 @@
methods = new Method[n];
for (int i = 0; i < n; ++i) {
Method m = allmethods[ i];
- if (m.getDeclaringClass() == baseclass) {
+ if (m.getDeclaringClass() == baseclass ||
+ Modifier.isFinal(m.getModifiers())) {
String mname = m.getName();
if (mname.startsWith(methodPrefix)) {
int k = 0;
Thank you!