]> source.dussan.org Git - javassist.git/commitdiff
fixed a bug in CodeConverter#replaceFieldRead/Write() on field shadowing
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 5 Oct 2006 15:43:49 +0000 (15:43 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 5 Oct 2006 15:43:49 +0000 (15:43 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@323 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

Readme.html
src/main/javassist/convert/TransformReadField.java

index b988a78124315a07a49aa20a9e0b51eb55da10a0..ff1324cff466bb26df557cdefd165042d1645048 100644 (file)
@@ -281,6 +281,12 @@ see javassist.Dump.
 
 <h2>Changes</h2>
 
+<p>-version 3.4
+<ul>
+       <li>A bug in CodeConverter#replaceFieldRead() and CodeConverter#replaceFieldWrite()
+       was fixed. <a href="http://jira.jboss.com/jira/browse/JBAOP-284">JBAOP-284</a>.
+</ul>
+
 <p>-version 3.3 on August 17, 2006
 <ul>
     <li>CtClass#toClass() and ClassPool#toClass() were modified to accept a
index ad490f88597bd0d3c8022ff7de79f953e0afb58d..af6a4631e856e02ee0b760a97a5c31cb4619c356 100644 (file)
@@ -46,13 +46,25 @@ public class TransformReadField extends Transformer {
 
         try {
             CtClass c = pool.get(cp.getFieldrefClassName(index));
-            if (is_private ? c == fclass : c.subclassOf(fclass))
+            if (c == fclass || (!is_private && isFieldInSuper(c, fclass, fname)))
                 return cp.getFieldrefType(index);
         }
         catch (NotFoundException e) {}
         return null;
     }
 
+    static boolean isFieldInSuper(CtClass clazz, CtClass fclass, String fname) {
+        if (!clazz.subclassOf(fclass))
+            return false;
+
+        try {
+            CtField f = clazz.getField(fname);
+            return f.getDeclaringClass() == fclass;
+        }
+        catch (NotFoundException e) {}
+        return false;
+    }
+
     public int transform(CtClass tclazz, int pos, CodeIterator iterator,
                          ConstPool cp) throws BadBytecode
     {