For CNI headers, gjavah generates the name of bridge methods
by appending the name of the class and a "$" to the method name.
These are stored in methodNameMap, which is created as the union
of the entries for the class and all superclasses.

However, the current implementation doesn't populate methodNameMap
in printVtable so the methodNameMap received from the superclass
by the child class is always empty, and thus bridge methods from
the parent classes are only generated during printing against the
current class and are named wrongly.

This patch corrects this behaviour.

ChangeLog:

2008-09-02  Andrew John Hughes  <[EMAIL PROTECTED]>

        * tools/gnu/classpath/tools/javah/ClassWrapper.java:
        (makeVtable()): Populate methodNameMap.
        (printMethods(CniPrintStream)): Always use pre-populated
        methodNameMap for bridge targets.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: tools/gnu/classpath/tools/javah/ClassWrapper.java
===================================================================
RCS file: 
/sources/classpath/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java,v
retrieving revision 1.3
diff -u -u -r1.3 ClassWrapper.java
--- tools/gnu/classpath/tools/javah/ClassWrapper.java   19 Apr 2007 00:14:15 
-0000      1.3
+++ tools/gnu/classpath/tools/javah/ClassWrapper.java   2 Sep 2008 21:46:57 
-0000
@@ -217,7 +217,18 @@
         MethodNode m = (MethodNode) i.next();
         String desc = MethodHelper.getBridgeTarget(m);
         if (desc != null)
-          bridgeTargets.add(m.name + desc);
+         {
+           String sum = m.name + desc;
+           boolean newTarget = bridgeTargets.add(sum);
+           if (newTarget)
+             {
+               // Bridge target that is new in this class.
+               String cname = this.name;
+               int index = cname.lastIndexOf('/');
+               cname = cname.substring(index + 1);
+               methodNameMap.put(sum, cname + "$" + m.name);
+             }
+         }
       }
   }
 
@@ -247,18 +258,7 @@
        String nameToUse;
        String sum = m.name + m.desc;
        if (bridgeTargets.contains(sum))
-         {
-           if (methodNameMap.containsKey(sum))
-             nameToUse = (String) methodNameMap.get(sum);
-           else
-             {
-               // Bridge target that is new in this class.
-               String cname = this.name;
-               int index = cname.lastIndexOf('/');
-               cname = cname.substring(index + 1);
-               nameToUse = cname + "$" + m.name;
-             }
-         }
+         nameToUse = (String) methodNameMap.get(sum);
        else
          nameToUse = Keywords.getCxxName(m.name);
        methodNameMap.put(sum, nameToUse);

Reply via email to