Hi!

I was sick of renaming java_lang_ClassLoader$NativeLibrary.h all the
time when building openjdk, so I wrote this small patch.  I think it's
correct, but I'm not an expert.

I also renamed filename to file, as I think it's more appropriate.  I
could remove that renaming if not wanted.

Is this ok to commit?

- twisti

---

Index: tools/gnu/classpath/tools/javah/CniIncludePrinter.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java,v
retrieving revision 1.3
diff -u -3 -p -r1.3 CniIncludePrinter.java
--- tools/gnu/classpath/tools/javah/CniIncludePrinter.java      16 Mar 2007 
22:42:43 -0000      1.3
+++ tools/gnu/classpath/tools/javah/CniIncludePrinter.java      29 Jun 2007 
11:28:19 -0000
@@ -63,14 +63,14 @@ public class CniIncludePrinter
     return new PrintStream(fos);
   }
 
-  public void printClass(File filename, ClassWrapper klass) throws IOException
+  public void printClass(File file, ClassWrapper klass) throws IOException
   {
     // Never write Object or Class. This is a hack, maybe
     // the user would like to see what they look like...
     if (klass.name.equals("java/lang/Object")
         || klass.name.equals("java/lang/Class"))
       return;
-    PrintStream ps = getPrintStream(filename + ".h", klass);
+    PrintStream ps = getPrintStream(file + ".h", klass);
     if (ps == null)
       return;
     ps.println();
Index: tools/gnu/classpath/tools/javah/JniIncludePrinter.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java,v
retrieving revision 1.7
--- tools/gnu/classpath/tools/javah/JniIncludePrinter.java      16 Mar 2007 
22:42:43 -0000      1.7
+++ tools/gnu/classpath/tools/javah/JniIncludePrinter.java      29 Jun 2007 
11:50:44 -0000
@@ -107,15 +107,23 @@ public class JniIncludePrinter
     return new JniPrintStream(classpath, fos, klass);
   }
 
-  public void printClass(File filename, ClassWrapper klass) throws IOException
+  public void printClass(File file, ClassWrapper klass) throws IOException
   {
     // Note that we ignore the filename here.
     String xname = JniHelper.mangle(klass.name);
-    JniPrintStream out 
-      = (JniPrintStream) getPrintStream(klass.name.replace('/', '_') + ".h", 
-                                       klass);
+
+    // mangle the filename a bit
+    String filename = klass.name;
+
+    filename = filename.replace('/', '_');
+    filename = filename.replace('$', '_');
+    filename = filename + ".h";
+
+    JniPrintStream out = (JniPrintStream) getPrintStream(filename, klass);
+
     if (out == null)
       return;
+
     out.println();
     out.print("#ifndef __");
     out.print(xname);
Index: tools/gnu/classpath/tools/javah/Main.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/javah/Main.java,v
retrieving revision 1.9
diff -u -3 -p -r1.9 Main.java
--- tools/gnu/classpath/tools/javah/Main.java   26 Mar 2007 22:10:12 -0000      
1.9
+++ tools/gnu/classpath/tools/javah/Main.java   29 Jun 2007 11:28:19 -0000
@@ -324,11 +324,11 @@ public class Main
     while (i.hasNext())
       {
        Map.Entry e = (Map.Entry) i.next();
-       File filename = (File) e.getKey();
+       File file = (File) e.getKey();
         ClassWrapper klass = (ClassWrapper) e.getValue();
         if (verbose)
-          System.err.println("[writing " + klass + " as " + filename + "]");
-        printer.printClass(filename, klass);
+          System.err.println("[writing " + klass + " as " + file + "]");
+        printer.printClass(file, klass);
       }
   }
 



Reply via email to