diff options
23 files changed, 50 insertions, 21 deletions
diff --git a/libjava/classpath/ChangeLog b/libjava/classpath/ChangeLog index 985d959..0f68f91 100644 --- a/libjava/classpath/ChangeLog +++ b/libjava/classpath/ChangeLog @@ -1,3 +1,20 @@ +2007-03-16 Tom Tromey <tromey@redhat.com> + + * tools/gnu/classpath/tools/javah/JniStubPrinter.java + (printClass): Added filename argument. + * tools/gnu/classpath/tools/javah/JniIncludePrinter.java + (printClass): Added filename argument. + * tools/gnu/classpath/tools/javah/CniIncludePrinter.java + (printClass): Use user's file name. + * tools/gnu/classpath/tools/javah/CniStubPrinter.java + (printClass): Use user's file name. + * tools/gnu/classpath/tools/javah/Printer.java (printClass): Added + filename argument. + * tools/gnu/classpath/tools/javah/Main.java (getParser): Fix '-v' + argument order. + (writeHeaders): Use a HashMap. + (run): Put class name into HashMap for writeHeaders. + 2007-03-02 Mario Torre <neugens@limasoftware.net> PR classpath/31017: diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class Binary files differindex 13a0a99..08bcc36 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniIncludePrinter.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class Binary files differindex c3cf12d..8726cdd 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class Binary files differindex a89e0d2..690b2b9 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class Binary files differindex ad96207..a0f008d 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class Binary files differindex ef2f2cf..5937740 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$1.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class Binary files differindex 8c33dd3..ed0500f 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$10.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class Binary files differindex 7bebfc8..1eb1b1e 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$2.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class Binary files differindex b59e017..a798489 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$3.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class Binary files differindex db5582d..0811703 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$4.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class Binary files differindex ef70381..faa51e2 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$5.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class Binary files differindex e2e627d..10286fa 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$6.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class Binary files differindex 249ec5c..6da557c 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$7.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class Binary files differindex 001bfa0..16fe8a3 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$8.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class Binary files differindex aee9be7..f4393f5 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main$9.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class Binary files differindex 27c3b7e..66c3793 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class Binary files differindex 76b2cbe..94bc20c 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Printer.class diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java index fb007b1..445f902 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/CniIncludePrinter.java @@ -1,5 +1,5 @@ /* CniIncludePrinter.java - generate CNI header files - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -63,14 +63,14 @@ public class CniIncludePrinter return new PrintStream(fos); } - public void printClass(ClassWrapper klass) throws IOException + public void printClass(File filename, 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(klass.name + ".h", klass); + PrintStream ps = getPrintStream(filename + ".h", klass); if (ps == null) return; ps.println(); diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java index d91f367..3acec23 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java @@ -1,5 +1,5 @@ /* CniStubPrinter.java - Generate a CNI stub file - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -90,12 +90,12 @@ public class CniStubPrinter return new CniPrintStream(fos); } - public void printClass(ClassWrapper klass) throws IOException + public void printClass(File filename, ClassWrapper klass) throws IOException { if (! klass.hasNativeMethod()) return; String className = klass.name.replaceAll("/", "::"); - CniPrintStream out = (CniPrintStream) getPrintStream(klass.name + ".cc", + CniPrintStream out = (CniPrintStream) getPrintStream(filename + ".cc", klass); if (out == null) return; diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java index dc19af2..6c1a8e1 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java @@ -107,8 +107,9 @@ public class JniIncludePrinter return new JniPrintStream(classpath, fos, klass); } - public void printClass(ClassWrapper klass) throws IOException + public void printClass(File filename, 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", diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java index 758ec21..d4b34fc 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/JniStubPrinter.java @@ -1,5 +1,5 @@ /* JniStubPrinter.java - Generate JNI stub files - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -71,8 +71,9 @@ public class JniStubPrinter return new JniPrintStream(classpath, fos, klass); } - public void printClass(ClassWrapper klass) throws IOException + public void printClass(File filename, ClassWrapper klass) throws IOException { + // Note that we ignore the filename here. if (! klass.hasNativeMethod()) return; String xname = JniHelper.mangle(klass.name); diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java b/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java index 729af47..250844d 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java @@ -58,6 +58,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; import org.objectweb.asm.ClassReader; @@ -254,7 +255,7 @@ public class Main cni = true; } }); - result.add(new Option('v', "verbose", "Set verbose mode") + result.add(new Option("verbose", 'v', "Set verbose mode") { public void parsed(String arg0) throws OptionException { @@ -309,16 +310,18 @@ public class Main return result; } - private void writeHeaders(ArrayList klasses, Printer printer) + private void writeHeaders(HashMap klasses, Printer printer) throws IOException { - Iterator i = klasses.iterator(); + Iterator i = klasses.entrySet().iterator(); while (i.hasNext()) { - ClassWrapper klass = (ClassWrapper) i.next(); + Map.Entry e = (Map.Entry) i.next(); + File filename = (File) e.getKey(); + ClassWrapper klass = (ClassWrapper) e.getValue(); if (verbose) - System.err.println("[writing " + klass + "]"); - printer.printClass(klass); + System.err.println("[writing " + klass + " as " + filename + "]"); + printer.printClass(filename, klass); } } @@ -376,19 +379,21 @@ public class Main } Iterator i = klasses.iterator(); - ArrayList results = new ArrayList(); + HashMap results = new HashMap(); while (i.hasNext()) { // Let user specify either kind of class name or a // file name. Object item = i.next(); ClassWrapper klass; + File filename; if (item instanceof File) { // Load class from file. if (verbose) System.err.println("[reading file " + item + "]"); - klass = getClass((File) item); + filename = (File) item; + klass = getClass(filename); } else { @@ -396,9 +401,12 @@ public class Main String className = ((String) item).replace('.', '/'); if (verbose) System.err.println("[reading class " + className + "]"); + // Use the name the user specified, even if it is + // different from the ultimate class name. + filename = new File(className); klass = getClass(className); } - results.add(klass); + results.put(filename, klass); } writeHeaders(results, printer); @@ -436,7 +444,8 @@ public class Main String resource = name.replace('.', '/') + ".class"; URL url = loader.findResource(resource); if (url == null) - throw new IOException("can't find class file " + resource); + throw new IOException("can't find class file " + resource + + " in " + loader); InputStream is = url.openStream(); ClassWrapper result = readClass(is); classMap.put(name, result); diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java b/libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java index 9c4b48d..7a896cf 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/Printer.java @@ -1,5 +1,5 @@ /* Print.java - abstract base class for printing classes - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -95,7 +95,8 @@ public abstract class Printer this.force = force; } - public abstract void printClass(ClassWrapper klass) throws IOException; + public abstract void printClass(File filename, ClassWrapper klass) + throws IOException; protected abstract void writePreambleImpl(PrintStream ps); |