Hi list. A couple of simple patches for consideration for cp-tools.
The first is to remove gjavah from cp-tools since a javah tool is now in Classpath so gjavah in cp-tools is no longer needed. 2008-07-12 Paul Jenner <[EMAIL PROTECTED]> * bin/gjavah.in, * configure.ac, * Makefile.am, * src/gnu/classpath/tools/javah/GnuByteCodeJavah.java, * src/gnu/classpath/tools/javah/Javah.java, * src/gnu/classpath/tools/javah/JavahMain.java: Removed gjavah. The second is to correct the classpath in the gjavap wrapper script - it points to cptools.zip instead of cptools.jar which is what is built. 2008-07-12 Paul Jenner <[EMAIL PROTECTED]> * bin/gjavap.in: Corrected cptools.jar classpath. If acceptable, could someone with access commit these? Hope this helps, Paul -- Paul Jenner <[EMAIL PROTECTED]>
diff -Naur cp-tools/bin/gjavah.in cp-tools-psj/bin/gjavah.in --- cp-tools/bin/gjavah.in 2008-07-12 16:08:00.000000000 +0100 +++ cp-tools-psj/bin/gjavah.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,48 +0,0 @@ -#!/bin/sh - -## Copyright (C) 2008 Free Software Foundation, Inc. -## -## This file is a part of GNU Classpath. -## -## GNU Classpath is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or (at -## your option) any later version. -## -## GNU Classpath is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with GNU Classpath; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -## USA. -## -## Linking this library statically or dynamically with other modules is -## making a combined work based on this library. Thus, the terms and -## conditions of the GNU General Public License cover the whole -## combination. -## -## As a special exception, the copyright holders of this library give you -## permission to link this library with independent modules to produce an -## executable, regardless of the license terms of these independent -## modules, and to copy and distribute the resulting executable under -## terms of your choice, provided that you also meet, for each linked -## independent module, the terms and conditions of the license of that -## module. An independent module is a module which is not derived from -## or based on this library. If you modify this library, you may extend -## this exception to your version of the library, but you are not -## obligated to do so. If you do not wish to do so, delete this -## exception statement from your version. -## -## -## A simple shell script to launch the GNU Classpath javah tool. -## - [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@/@PACKAGE@ -tools_cp=${tools_dir}/cptools.zip - -exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.javah.JavahMain "$@" diff -Naur cp-tools/configure.ac cp-tools-psj/configure.ac --- cp-tools/configure.ac 2008-07-12 16:08:00.000000000 +0100 +++ cp-tools-psj/configure.ac 2008-07-12 21:06:54.000000000 +0100 @@ -110,9 +110,8 @@ AC_CONFIG_COMMANDS([supplementgen],[chmod 755 bin/supplementgen]) if test "x${with_gnubytecode}" = xyes then - AC_CONFIG_FILES([bin/gjavap bin/gjavah]) + AC_CONFIG_FILES([bin/gjavap]) AC_CONFIG_COMMANDS([gjavap], [chmod 755 bin/gjavap]) - AC_CONFIG_COMMANDS([gjavah], [chmod 755 bin/gjavah]) fi fi AC_OUTPUT diff -Naur cp-tools/Makefile.am cp-tools-psj/Makefile.am --- cp-tools/Makefile.am 2008-07-12 16:08:00.000000000 +0100 +++ cp-tools-psj/Makefile.am 2008-07-12 21:10:23.000000000 +0100 @@ -22,7 +22,7 @@ bin_PROGRAMS = localegen supplementgen lib_LTLIBRARIES = libcpgenerators.la if USE_GNUBYTECODE -bin_PROGRAMS += gjavap gjavah +bin_PROGRAMS += gjavap lib_LTLIBRARIES += libcptools.la libbytecode.la libbytecode_la_LINK = $(GCJLINK) nodist_libbytecode_la_SOURCES = $(BYTECODE_JAR) @@ -32,7 +32,7 @@ data_JARS = cpgenerators-$(VERSION).jar BUILT_SOURCES = $(data_JARS) if USE_GNUBYTECODE -bin_SCRIPTS += bin/gjavap bin/gjavah +bin_SCRIPTS += bin/gjavap data_JARS += cptools-$(VERSION).jar endif endif @@ -45,13 +45,6 @@ gjavap_LDADD += libbytecode.la gjavap_LDFLAGS = --main=gnu.classpath.tools.javap.JavapMain \ -Dgnu.gcj.runtime.VMClassLoader.library_control=never - -gjavah_SOURCES = -gjavah_LINK = $(GCJLINK) -gjavah_LDADD = libcptools.la -gjavah_LDADD += libbytecode.la -gjavah_LDFLAGS = --main=gnu.classpath.tools.javah.JavahMain \ - -Dgnu.gcj.runtime.VMClassLoader.library_control=never endif localegen_SOURCES = @@ -69,7 +62,6 @@ else gjavap: $(srcdir)/bin/gjavap.in -gjavah: $(srcdir)/bin/gjavah.in localegen: $(srcdir)/bin/localegen.in supplementgen: $(srcdir)/bin/supplementgen.in @@ -77,12 +69,9 @@ if USE_GNUBYTECODE cptools_jar_SOURCES = \ - src/gnu/classpath/tools/javah/JavahMain.java \ - src/gnu/classpath/tools/javah/Javah.java \ src/gnu/classpath/tools/javap/JavapMain.java \ src/gnu/classpath/tools/javap/Javap.java \ src/gnu/classpath/tools/Util.java \ - src/gnu/classpath/tools/javah/GnuByteCodeJavah.java \ src/gnu/classpath/tools/javap/GnuByteCodeJavap.java if ENABLE_GCJ_BINARY diff -Naur cp-tools/src/gnu/classpath/tools/javah/GnuByteCodeJavah.java cp-tools-psj/src/gnu/classpath/tools/javah/GnuByteCodeJavah.java --- cp-tools/src/gnu/classpath/tools/javah/GnuByteCodeJavah.java 2008-07-12 16:08:00.000000000 +0100 +++ cp-tools-psj/src/gnu/classpath/tools/javah/GnuByteCodeJavah.java 1970-01-01 01:00:00.000000000 +0100 @@ -1,368 +0,0 @@ -/* gnu.classpath.tools.javah.GnuByteCodeJavah - Copyright (C) 2005 Free Software Foundation, Inc. - - This file is part of GNU Classpath. - - GNU Classpath is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GNU Classpath is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Classpath; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ -package gnu.classpath.tools.javah; - -import gnu.bytecode.Access; -import gnu.bytecode.Attribute; -import gnu.bytecode.ClassFileInput; -import gnu.bytecode.ClassType; -import gnu.bytecode.ConstantValueAttr; -import gnu.bytecode.Field; -import gnu.bytecode.Method; -import gnu.bytecode.Type; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.io.RandomAccessFile; - -/** - * - * @author C. Brian Jones ([EMAIL PROTECTED]) - */ -public class GnuByteCodeJavah extends Javah -{ - - private String getJNIMethodName(ClassType classType, Method m) - { - StringBuffer result = new StringBuffer(); - String classname = classType.getName(); - classname = classname.replace('.', '_'); - result.append("Java_"); - result.append(classname); - result.append("_"); - Method method = classType.getMethods(); - int overload = 0; - while (method != null) - { - int flags = method.getModifiers(); - if ((flags & Access.NATIVE) != 0) - { - if (method.getName().equals(m.getName())) - overload++; - } - method = method.getNext(); - } - String methodname = getUnicodeName(m.getName()); - methodname = escapeUnderscore(methodname); - methodname = escapeUnicode(methodname); - result.append(methodname); - if (overload > 1) - { - result.append("__"); - StringBuffer sig = new StringBuffer(m.getSignature()); - String signature = sig.toString(); - int idx = signature.indexOf('('); - if (idx != -1) - sig.deleteCharAt(idx); - signature = sig.toString(); - idx = signature.indexOf(')'); - if (idx != -1) - sig.delete(idx, sig.length()); - signature = sig.toString(); - signature = escapeUnderscore(signature); - signature = escapeSemicolon(signature); - signature = escapeArray(signature); - signature = signature.replace('/', '_'); - result.append(signature); - } - return result.toString(); - } - /** - * @see gnu.classpath.tools.javah.Javah#printClassFile(java.lang.String, - * java.io.PrintStream) - */ - public void printClassFile(String className, PrintStream out) - { - StringBuffer buf; - ClassType classType = null; - if (isOutputVerbose()) - { - buf = new StringBuffer(); - buf.append("[Search path = "); - String path = getSearchPath(); - buf.append(path); - buf.append("]"); - out.println(buf.toString()); - } - try - { - InputStream is = findClass(className); - classType = ClassFileInput.readClassType(is); - } - catch (Throwable t) - { - out.println("Error: Class " + className + " could not be found."); - return; - } - if (getOutputDirectory() != null) - { - String filename = className.replace('.', '_'); - filename = filename.replace('$', '_'); - filename = filename + ".h"; - File dir = new File(getOutputDirectory()); - // fatal error - if (!dir.exists()) - return; - File f = new File(dir, className); - if (f.exists()) - if (!f.delete()) - { - System.err.println("Error: The file " + f.getPath() - + " could not be deleted."); - return; - } - if (isOutputVerbose()) - { - buf = new StringBuffer(); - buf.append("[Creating "); - buf.append(f.getPath()); - buf.append("]"); - out.println(buf.toString()); - } - writeHeader(classType, f); - } - else if (getOutputFile() != null) - { - File f = new File(getOutputFile()); - if (isOutputVerbose()) - { - buf = new StringBuffer(); - buf.append("[Creating "); - buf.append(f.getPath()); - buf.append("]"); - out.println(buf.toString()); - } - writeHeader(classType, f); - } - } - - private void writeHeader(ClassType classType, File f) - { - StringBuffer buf; - String linesep = System.getProperty("line.separator"); - boolean newfile = f.exists(); - try - { - RandomAccessFile raf = new RandomAccessFile(f, "rw"); - raf.seek(raf.length()); - FileWriter writer = new FileWriter(raf.getFD()); - if (!newfile) - { - buf = new StringBuffer(); - buf.append("/* DO NOT EDIT THIS FILE - it is machine generated */"); - buf.append(linesep); - buf.append("#include <jni.h>"); - buf.append(linesep); - writer.write(buf.toString()); - } - buf = new StringBuffer(); - buf.append("/* Header for class "); - String className = classType.getName(); - className = getUnicodeName(className); - className = escapeUnicode(className); - className = className.replace('$', '_'); - buf.append(className.replace('.', '_')); - buf.append(" */"); - buf.append(linesep); - buf.append(linesep); - writer.write(buf.toString()); - String includedef = "_Included_" + className.replace('.', '_'); - buf = new StringBuffer(); - buf.append("#ifndef "); - buf.append(includedef); - buf.append(linesep); - buf.append("#define "); - buf.append(includedef); - buf.append(linesep); - buf.append("#ifdef __cplusplus"); - buf.append(linesep); - buf.append("extern \"C\" {"); - buf.append(linesep); - buf.append("#endif"); - buf.append(linesep); - writer.write(buf.toString()); - // write any static fields - Field field = classType.getFields(); - while (field != null) - { - int flags = field.getModifiers(); - if ((flags & Access.STATIC) != 0) - { - buf = new StringBuffer(); - String fieldname = field.getSourceName(); - fieldname = getUnicodeName(fieldname); - fieldname = escapeUnicode(fieldname); - if ((flags & Access.FINAL) != 0) - { - ConstantValueAttr constval = (ConstantValueAttr) Attribute - .get(field, "ConstantValue"); - if (constval == null) - { - // System.out.println ("DBG1: " + fieldname); - buf.append("/* Inaccessible static: "); - buf.append(escapeUnicodeInner(fieldname)); - buf.append(" */"); - buf.append(linesep); - writer.write(buf.toString()); - field = field.getNext(); - continue; - } - Object val = constval.getValue(classType.getConstants()); - if (val instanceof String) - { - System.out.println("DBG2: " + fieldname); - field = field.getNext(); - continue; - } - fieldname = className.replace('.', '_') + "_" + fieldname; - buf.append("#undef "); - buf.append(escapeUnicodeInner(fieldname)); - buf.append(linesep); - buf.append("#define "); - buf.append(fieldname); - buf.append(" "); - if (val instanceof Integer) - { - Integer valint = (Integer) val; - buf.append(valint.toString()); - buf.append("L"); - } - else if (val instanceof Long) - { - Long vallong = (Long) val; - buf.append(vallong.toString()); - buf.append("LL"); - } - else if (val instanceof Float) - { - Float valfloat = (Float) val; - buf.append(valfloat.toString()); - buf.append("f"); - } - else if (val instanceof Double) - { - Double valdouble = (Double) val; - buf.append(valdouble.toString()); - buf.append("D"); - } - else - System.err.println("Unknown constant value " + val); - buf.append(linesep); - } - else - { - buf.append("/* Inaccessible static: "); - buf.append(escapeUnicodeInner(fieldname)); - buf.append(" */"); - buf.append(linesep); - } - writer.write(buf.toString()); - } - field = field.getNext(); - } - // write any native methods out - Method method = classType.getMethods(); - while (method != null) - { - int flags = method.getModifiers(); - if ((flags & Access.NATIVE) != 0) - { - buf = new StringBuffer(); - buf.append("/*"); - buf.append(linesep); - buf.append(" * Class: "); - buf.append(className.replace('.', '_')); - buf.append(linesep); - buf.append(" * Method: "); - String methodname = getUnicodeName(method.getName()); - methodname = escapeUnderscore(methodname); - methodname = escapeUnicode(methodname); - buf.append(methodname); - buf.append(linesep); - buf.append(" * Signature: "); - buf.append(method.getSignature()); - buf.append(linesep); - buf.append(" */"); - buf.append(linesep); - buf.append("JNIEXPORT "); - String returnval = getJNIType(method.getReturnType().getName()); - buf.append(returnval); - buf.append(" JNICALL "); - String methodname2 = getJNIMethodName(classType, method); - methodname2 = escapeUnicodeInner(methodname2); - buf.append(methodname2); - buf.append(linesep); - writer.write(buf.toString()); - // begin printing JNI arguments - buf = new StringBuffer(); - buf.append(" (JNIEnv *, "); - if ((flags & Access.STATIC) != 0) - buf.append("jclass"); - else - buf.append("jobject"); - // if there are arguments, include those - Type[] paramTypes = method.getParameterTypes(); - if (paramTypes.length > 0) - buf.append(", "); - for (int i = 0; i < paramTypes.length; i++) - { - String jniname = getJNIType(paramTypes[i].getName()); - if (buf.length() + jniname.length() > 76) - { - buf.append(linesep); - writer.write(buf.toString()); - buf = new StringBuffer(); - buf.append(" "); - } - buf.append(jniname); - if ((i + 1) < paramTypes.length) - buf.append(", "); - } - buf.append(");"); - buf.append(linesep); - buf.append(linesep); - writer.write(buf.toString()); - } - method = method.getNext(); - } - buf = new StringBuffer(); - buf.append("#ifdef __cplusplus"); - buf.append(linesep); - buf.append("}"); - buf.append(linesep); - buf.append("#endif"); - buf.append(linesep); - buf.append("#endif"); - buf.append(linesep); - writer.write(buf.toString()); - writer.close(); - raf.close(); - } - catch (IOException ioe) - { - System.err - .println("Error: Can't recover from an I/O error with the following message: " - + ioe.getMessage()); - return; - } - } -} \ No newline at end of file diff -Naur cp-tools/src/gnu/classpath/tools/javah/Javah.java cp-tools-psj/src/gnu/classpath/tools/javah/Javah.java --- cp-tools/src/gnu/classpath/tools/javah/Javah.java 2008-07-12 16:08:00.000000000 +0100 +++ cp-tools-psj/src/gnu/classpath/tools/javah/Javah.java 1970-01-01 01:00:00.000000000 +0100 @@ -1,285 +0,0 @@ -/* gnu.classpath.tools.javah.Javah - Copyright (C) 2005 Free Software Foundation, Inc. - - This file is part of GNU Classpath. - - GNU Classpath is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GNU Classpath is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Classpath; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ -package gnu.classpath.tools.javah; - -import gnu.classpath.tools.Util; -import java.io.InputStream; -import java.io.PrintStream; - -/** - * - * @author C. Brian Jones ([EMAIL PROTECTED]) - */ -public abstract class Javah -{ - private static final String JAVAH_IMPL = "gnu.classpath.tools.javah"; - - public final static Javah getInstance() throws ClassNotFoundException - { - String impl = "gnu.classpath.tools.javah.GnuByteCodeJavah"; - String userImpl = System.getProperty(JAVAH_IMPL); - if (userImpl != null) - impl = userImpl; - Class implClass = Class.forName(impl); - try - { - Object obj = implClass.newInstance(); - if (obj instanceof Javah) - return (Javah) obj; - } - catch (Throwable t) - { - } - throw new ClassNotFoundException("Unable to create instance of " + impl); - } - private String output_directory = null; - private String output_file = null; - private boolean output_jni = false; - private boolean output_stubs = false; - private boolean output_verbose = false; - private Util util = new Util(); - - /** - * Escapes the '[' character with '_3'. Useful only for descriptors, as in - * method signatures - */ - public final String escapeArray(String s) - { - StringBuffer buf = new StringBuffer(s); - int start = -1; - while ((start = s.indexOf('[', start + 1)) != -1) - { - buf.replace(start, start + 1, "_3"); - s = buf.toString(); - } - s = buf.toString(); - return s; - } - - /** - * Escapes the ';' character with '_2'. Useful only for descriptors, as in - * method signatures. - */ - public final String escapeSemicolon(String s) - { - StringBuffer buf = new StringBuffer(s); - int start = -1; - while ((start = s.indexOf(';', start + 1)) != -1) - { - buf.replace(start, start + 1, "_2"); - s = buf.toString(); - } - s = buf.toString(); - return s; - } - - /** - * Escapes any '_' character with '_1' - */ - public final String escapeUnderscore(String s) - { - StringBuffer buf = new StringBuffer(s); - int start = -1; - while ((start = s.indexOf('_', start + 1)) != -1) - { - buf.replace(start, start + 1, "_1"); - s = buf.toString(); - } - s = buf.toString(); - return s; - } - - /** - * Escapes any Unicode character XXXX with '_0XXXX' - */ - public final String escapeUnicode(String s) - { - StringBuffer buf = new StringBuffer(s); - int start = -1; - while ((start = s.indexOf("\\u", start + 1)) != -1) - { - if (s.length() > start + 5) - { - buf.replace(start, start + 2, "_0"); - s = buf.toString(); - } - } - s = buf.toString(); - return s; - } - - /** - * Escapes any '$' with _00024 - */ - public final String escapeUnicodeInner(String s) - { - StringBuffer buf = new StringBuffer(s); - int start = -1; - while ((start = s.indexOf("$", start + 1)) != -1) - { - buf.replace(start, start + 1, "_00024"); - s = buf.toString(); - } - s = buf.toString(); - return s; - } - - public InputStream findClass(String className) throws ClassNotFoundException - { - return util.findClass(className); - } - - public final String getJNIType(String jtype) - { - String ntype = null; - boolean isArray = false; - if (jtype.indexOf("[]") != -1) - { - jtype = jtype.substring(0, jtype.indexOf("[]")); - isArray = true; - } - if (jtype.equals("void")) - ntype = "void"; - else if (jtype.equals("boolean")) - ntype = "jboolean"; - else if (jtype.equals("byte")) - ntype = "jbyte"; - else if (jtype.equals("char")) - ntype = "jchar"; - else if (jtype.equals("short")) - ntype = "jshort"; - else if (jtype.equals("int")) - ntype = "jint"; - else if (jtype.equals("long")) - ntype = "jlong"; - else if (jtype.equals("float")) - ntype = "jfloat"; - else if (jtype.equals("double")) - ntype = "jdouble"; - if (isArray) - { - if (ntype == null) - ntype = "jobject"; - ntype = ntype + "Array"; - } - if (ntype != null) - return ntype; - ntype = "jobject"; - if (jtype.equals("java.lang.String")) - ntype = "jstring"; - else if (jtype.equals("java.lang.Throwable")) - ntype = "jthrowable"; - else if (jtype.equals("java.lang.Class")) - ntype = "jclass"; - return ntype; - } - - public final String getOutputDirectory() - { - return output_directory; - } - - public final String getOutputFile() - { - return output_file; - } - - public final String getSearchPath() - { - return util.getSearchPath(); - } - - /** - * Copied largely from gnu.bytecode.ClassTypeWriter - */ - public final String getUnicodeName(String s) - { - StringBuffer namebuf = new StringBuffer(); - int len = s.length(); - for (int i = 0; i < len; i++) - { - char ch = s.charAt(i); - if (ch >= ' ' && ch < 127) - namebuf.append(ch); - else - { - namebuf.append("\\u"); - for (int j = 4; --j >= 0;) - namebuf.append(Character.forDigit((ch >> (j * 4)) & 15, 16)); - } - } - return namebuf.toString(); - } - - public final boolean isOutputJNI() - { - return output_jni; - } - - public final boolean isOutputStubs() - { - return output_stubs; - } - - public final boolean isOutputVerbose() - { - return output_verbose; - } - - /** - * Providers will implement this method to appropriately print the given class - * to the provided output stream in javah format. This format depends upon the - * command line options specified. - * - * @param className The name of the class that would be examined - * @param out The output stream to write to - */ - public abstract void printClassFile(String className, PrintStream out); - - public final void setClasspath(String path) - { - util.setClasspath(path); - } - - public final void setOutputDirectory(String output_directory) - { - this.output_directory = output_directory; - } - - public final void setOutputFile(String output_file) - { - this.output_file = output_file; - } - - public final void setOutputJNI(boolean output_jni) - { - this.output_jni = output_jni; - } - - public final void setOutputStubs(boolean output_stubs) - { - this.output_stubs = output_stubs; - } - - public final void setOutputVerbose(boolean output_verbose) - { - this.output_verbose = output_verbose; - } -} \ No newline at end of file diff -Naur cp-tools/src/gnu/classpath/tools/javah/JavahMain.java cp-tools-psj/src/gnu/classpath/tools/javah/JavahMain.java --- cp-tools/src/gnu/classpath/tools/javah/JavahMain.java 2008-07-12 16:08:00.000000000 +0100 +++ cp-tools-psj/src/gnu/classpath/tools/javah/JavahMain.java 1970-01-01 01:00:00.000000000 +0100 @@ -1,101 +0,0 @@ -/* - * gnu.classpath.tools.JavahMain Copyright (C) 2001 Free Software Foundation, - * Inc. - * - * This file is part of GNU Classpath. - * - * GNU Classpath is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2, or (at your option) any later version. - * - * GNU Classpath is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * GNU Classpath; see the file COPYING. If not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -package gnu.classpath.tools.javah; - -public class JavahMain -{ - public static void main(String argv[]) - { - Javah p = parseArguments(argv); - System.exit(0); - } - - /** - * Parses the arguments to determine what this program should do. - */ - private static Javah parseArguments(String s[]) - { - Javah p = null; - try - { - p = Javah.getInstance(); - } - catch (ClassNotFoundException e) - { - System.err.println(e.getMessage()); - return null; - } - if (s.length == 0) - usage(); - boolean processArguments = true; - int i = 0; - while (processArguments) - { - if (s[i].equals("-classpath")) - p.setClasspath(s[++i]); - else if (s[i].equals("-d")) - p.setOutputDirectory(s[++i]); - else if (s[i].equals("-help")) - usage(); - else if (s[i].equals("-jni")) - p.setOutputJNI(true); - else if (s[i].equals("-o")) - p.setOutputFile(s[++i]); - else if (s[i].equals("-verbose")) - p.setOutputVerbose(true); - else if (s[i].startsWith("-")) - { - System.err.println("Invalid flag: " + s[i]); - usage(); - } - else - break; - i++; - } - if ((s.length - i) == 0) - usage(); - for (int j = i; j < s.length; j++) - p.printClassFile(s[j], System.out); - return p; - } - - /** - * Prints generic usage message to System.out. - */ - private static void usage() - { - System.out.println("Usage: javah [OPTION]... [CLASS]..."); - System.out.println("Generate header files for the given classes."); - System.out.println(""); - System.out - .println(" -classpath PATH Specify where to find user class files"); - System.out - .println(" -d DIR Specify an output directory"); - System.out.println(" -help Print this usage message"); - System.out - .println(" -jni Generate JNI header file (default)"); - System.out - .println(" -o FILE Specify an output file, cannot be used with -d"); - System.out - .println(" -stubs Generate an implementation stub file"); - System.out.println(" -verbose Enable verbose output"); - System.exit(0); - } -} \ No newline at end of file
diff -Naur cp-tools/bin/gjavap.in cp-tools-psj/bin/gjavap.in --- cp-tools/bin/gjavap.in 2008-07-12 16:08:00.000000000 +0100 +++ cp-tools-psj/bin/gjavap.in 2008-07-12 21:32:12.000000000 +0100 @@ -43,6 +43,6 @@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@/@PACKAGE@ -tools_cp=${tools_dir}/cptools.zip +tools_cp=${tools_dir}/cptools.jar exec @JAVA@ -classpath "${tools_cp}" gnu.classpath.tools.javap.JavapMain "$@"