changeset in /hg/icepick: Add exec support and remove old scripts
Andrew John Hughes
gnu_andrew at member.fsf.org
Fri Jan 18 06:30:23 PST 2008
changeset 46216729b691 in /hg/icepick
details: http://icedtea.classpath.org/hg/icepick?cmd=changeset;node=46216729b691
description:
Add exec support and remove old scripts
diffstat:
12 files changed, 240 insertions(+), 256 deletions(-)
ChangeLog | 27 ++++++++
Makefile.am | 7 --
autogen.sh | 2
configure.ac | 15 +---
tools/apt.in | 30 ---------
tools/javac.in | 30 ---------
tools/javadoc.in | 30 ---------
tools/javah.in | 29 ---------
tools/javap.in | 29 ---------
tools/library.c | 91 -----------------------------
tools/wrapper.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/wrapper.h | 39 ++++++++++++
diffs (truncated from 584 to 500 lines):
diff -r e7085e31026c -r 46216729b691 ChangeLog
--- a/ChangeLog Tue Jan 15 23:06:41 2008 +0000
+++ b/ChangeLog Fri Jan 18 14:26:17 2008 +0000
@@ -1,3 +1,30 @@ 2008-01-15 Andrew John Hughes <gnu_and
+2008-01-18 Andrew John Hughes <gnu_andrew at member.fsf.org>
+
+ * Makefile.am:
+ Add tools subdirectory and remove old
+ script templates.
+ * tools/apt.in,
+ * tools/javac.in,
+ * tools/javadoc.in,
+ * tools/javah.in,
+ * tools/javap.in:
+ Removed.
+ * tools/library.c:
+ Moved to wrapper.c
+ * tools/wrapper.c:
+ Added exec support, and #ifdefed out
+ incomplete JNI support.
+ * tools/wrapper.h:
+ Function prototypes.
+ * autogen.sh:
+ Check for wrapper.c rather than
+ javadoc.in.
+ * configure.ac:
+ Likewise, and also generate
+ tools/Makefile as opposed to old
+ script files and check for a C
+ compiler.
+
2008-01-15 Andrew John Hughes <gnu_andrew at member.fsf.org>
* Makefile.am:
diff -r e7085e31026c -r 46216729b691 Makefile.am
--- a/Makefile.am Tue Jan 15 23:06:41 2008 +0000
+++ b/Makefile.am Fri Jan 18 14:26:17 2008 +0000
@@ -1,6 +1,8 @@
## Input file for automake to generate the Makefile.in used by configure
ACLOCAL_AMFLAGS = -I m4 ${LOCAL_AUTORECONF_FLAGS}
+
+SUBDIRS = tools
# version info for generated compiler
@@ -16,11 +18,6 @@ else
else
JCOMPILER = echo "No compiler found" 1>&2; exit 1
endif
-
-bin_SCRIPTS = tools/apt tools/javac tools/javah tools/javadoc tools/javap
-bin_PROGRAMS =
-
-EXTRA_DIST = tools/apt.in tools/javac.in tools/javah.in tools/javadoc.in tools/javap.in
# All our example java source files
OPENJDK_CLASSES = $(LANGTOOLS_SRC_DIR)/src/share/classes
diff -r e7085e31026c -r 46216729b691 autogen.sh
--- a/autogen.sh Tue Jan 15 23:06:41 2008 +0000
+++ b/autogen.sh Fri Jan 18 14:26:17 2008 +0000
@@ -8,7 +8,7 @@ cd $srcdir
cd $srcdir
PROJECT=classpath
TEST_TYPE=-f
-FILE=tools/javadoc.in
+FILE=tools/wrapper.c
DIE=0
diff -r e7085e31026c -r 46216729b691 configure.ac
--- a/configure.ac Tue Jan 15 23:06:41 2008 +0000
+++ b/configure.ac Fri Jan 18 14:26:17 2008 +0000
@@ -7,13 +7,15 @@ dnl define([AC_CACHE_SAVE], )dnl
dnl define([AC_CACHE_SAVE], )dnl
AC_INIT([IcePick],[0.01],[distro-pkg-dev at openjdk.java.net],[icepick])
-AC_CONFIG_SRCDIR(tools/javadoc.in)
+AC_CONFIG_SRCDIR(tools/wrapper.c)
AC_CANONICAL_TARGET
AC_PREREQ(2.59)
AM_INIT_AUTOMAKE([1.9.0 gnu std-options tar-ustar -Wno-portability])
AC_PREFIX_DEFAULT(/usr/local/icepick)
+
+AC_PROG_CC
dnl -----------------------------------------------------------
dnl Sets the VM name for use in tool wrapper scripts
@@ -64,15 +66,6 @@ dnl output files
dnl output files
dnl -----------------------------------------------------------
AC_CONFIG_FILES([Makefile
-tools/apt
-tools/javac
-tools/javah
-tools/javap
-tools/javadoc])
+tools/Makefile])
-AC_CONFIG_COMMANDS([apt],[chmod 755 tools/apt])
-AC_CONFIG_COMMANDS([javac],[chmod 755 tools/javac])
-AC_CONFIG_COMMANDS([javah],[chmod 755 tools/javah])
-AC_CONFIG_COMMANDS([javap],[chmod 755 tools/javap])
-AC_CONFIG_COMMANDS([javadoc],[chmod 755 tools/javadoc])
AC_OUTPUT
diff -r e7085e31026c -r 46216729b691 tools/apt.in
--- a/tools/apt.in Tue Jan 15 23:06:41 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-## Copyright (C) 2007 Andrew John Hughes
-##
-## This file is a part of IcePick.
-##
-## IcePick 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.
-##
-## IcePick 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 IcePick; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-## USA.
-##
-## A simple shell script to launch the APT tool.
-##
-
-prefix=@prefix@
-datarootdir=@datarootdir@
-tools_dir=${prefix}/lib
-tools_cp=${tools_dir}/tools.jar
-
-exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" com.sun.tools.apt.Main "$@"
diff -r e7085e31026c -r 46216729b691 tools/javac.in
--- a/tools/javac.in Tue Jan 15 23:06:41 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-## Copyright (C) 2007 Andrew John Hughes
-##
-## This file is a part of IcePick.
-##
-## IcePick 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.
-##
-## IcePick 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 IcePick; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-## USA.
-##
-## A simple shell script to launch the javac tool.
-##
-
-prefix=@prefix@
-datarootdir=@datarootdir@
-tools_dir=${prefix}/lib
-tools_cp=${tools_dir}/tools.jar
-
-exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" com.sun.tools.javac.Main "$@"
diff -r e7085e31026c -r 46216729b691 tools/javadoc.in
--- a/tools/javadoc.in Tue Jan 15 23:06:41 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-## Copyright (C) 2007 Andrew John Hughes
-##
-## This file is a part of IcePick.
-##
-## IcePick 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.
-##
-## IcePick 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 IcePick; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-## USA.
-##
-## A simple shell script to launch the javadoc tool.
-##
-
-prefix=@prefix@
-datarootdir=@datarootdir@
-tools_dir=${prefix}/lib
-tools_cp=${tools_dir}/tools.jar
-
-exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" com.sun.tools.javadoc.Main "$@"
diff -r e7085e31026c -r 46216729b691 tools/javah.in
--- a/tools/javah.in Tue Jan 15 23:06:41 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-## Copyright (C) 2007 Andrew John Hughes
-##
-## This file is a part of IcePick.
-##
-## IcePick 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.
-##
-## IcePick 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 IcePick; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-## USA.
-##
-## A simple shell script to launch the javah tool.
-
-prefix=@prefix@
-datarootdir=@datarootdir@
-tools_dir=${prefix}/lib
-tools_cp=${tools_dir}/tools.jar
-
-exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" com.sun.tools.javah.Main "$@"
diff -r e7085e31026c -r 46216729b691 tools/javap.in
--- a/tools/javap.in Tue Jan 15 23:06:41 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-## Copyright (C) 2007 Andrew John Hughes
-##
-## This file is a part of IcePick.
-##
-## IcePick 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.
-##
-## IcePick 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 IcePick; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-## USA.
-##
-## A simple shell script to launch the javap tool.
-
-prefix=@prefix@
-datarootdir=@datarootdir@
-tools_dir=${prefix}/lib
-tools_cp=${tools_dir}/tools.jar
-
-exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" sun.tools.javap.Main "$@"
diff -r e7085e31026c -r 46216729b691 tools/library.c
--- a/tools/library.c Tue Jan 15 23:06:41 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-#include <jni.h>
-#include <string.h>
-#include <stdlib.h>
-
-int main(int argc, char** argv)
-{
- JNIEnv *env;
- JavaVM *vm;
- JavaVMInitArgs vm_args;
- JavaVMOption options[argc-1];
- char** read_pos;
- char** write_pos;
- int a;
- jint vm_count;
- jint main_count;
- jint res;
- jclass cls;
- jmethodID main_method;
- jclass string_class;
- jobjectArray args;
-
- vm_args.version = JNI_VERSION_1_2;
- vm_args.ignoreUnrecognized = JNI_TRUE;
- read_pos = argv + 1;
- write_pos = argv;
- for (a = 0; a < argc - 1; ++a)
- {
- if (strncmp(*read_pos, "-J", (size_t)2) == 0)
- {
- options[vm_count].optionString = *read_pos + 2;
- ++vm_count;
- }
- else
- {
- *write_pos = *read_pos;
- ++write_pos;
- ++main_count;
- }
- ++read_pos;
- }
- for (a = 0; a < main_count; ++a)
- printf("main option %d: %s\n", a, argv[a]);
- for (a = 0; a < vm_count; ++a)
- printf("vm option %d: %s\n", a, options[a].optionString);
- vm_args.options = options;
- vm_args.nOptions = vm_count;
-
- res = JNI_CreateJavaVM(&vm, (void**)&env, &vm_args);
- if (res < 0)
- {
- fprintf(stderr, "Couldn't create Java VM\n");
- exit(-1);
- }
- cls = (*env)->FindClass(env, "CLASS_NAME");
- if (cls == NULL) {
- goto destroy;
- }
-
- main_method = (*env)->GetStaticMethodID(env, cls, "main",
- "([Ljava/lang/String;)V");
- if (main_method == NULL) {
- goto destroy;
- }
-
- string_class = (*env)->FindClass(env, "java/lang/String");
- args = (*env)->NewObjectArray(env, main_count, string_class, NULL);
- if (args == NULL) {
- goto destroy;
- }
-
- for (a = 0; a < main_count; ++a)
- {
- jstring jstr;
-
- jstr = (*env)->NewStringUTF(env, *argv);
- if (jstr == NULL)
- goto destroy;
- ++argv;
- (*env)->SetObjectArrayElement(env, args, a, jstr);
- }
-
- (*env)->CallStaticVoidMethod(env, cls, main_method, args);
-
- destroy:
- if ((*env)->ExceptionOccurred(env))
- (*env)->ExceptionDescribe(env);
- (*vm)->DestroyJavaVM(vm);
-
- return 0;
-}
-
diff -r e7085e31026c -r 46216729b691 tools/wrapper.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/wrapper.c Fri Jan 18 14:26:17 2008 +0000
@@ -0,0 +1,167 @@
+/* wrapper.c - IcePick tools wrapper
+ Copyright (C) 2008 Andrew John Hughes
+
+This file is part of IcePick.
+
+IcePick 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.
+
+IcePick 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 IcePick; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+#include "wrapper.h"
+
+#ifdef USE_JNI
+int invoke_via_jni(char** vm_options, int vm_count,
+ char** main_options, int main_count)
+{
+ JNIEnv *env;
+ JavaVM *vm;
+ JavaVMInitArgs vm_args;
+ JavaVMOption options[vm_count];
+ jint res;
+ jclass cls;
+ jmethodID main_method;
+ jclass string_class;
+ jobjectArray args;
+ int a;
+
+ for (a = 0; a < vm_count; ++a)
+ options[a].optionString = *vm_options++;
+#ifdef DEBUG
+ for (a = 0; a < vm_count; ++a)
+ printf("vm option %d: %s\n", a, options[a].optionString);
+#endif
+
+ vm_args.version = JNI_VERSION_1_2;
+ vm_args.ignoreUnrecognized = JNI_TRUE;
+ vm_args.options = options;
+ vm_args.nOptions = vm_count;
+
+ res = JNI_CreateJavaVM(&vm, (void**)&env, &vm_args);
+ if (res < 0)
+ {
+ fprintf(stderr, "Couldn't create Java VM\n");
+ exit(-1);
+ }
+ cls = (*env)->FindClass(env, "CLASS_NAME");
+ if (cls == NULL) {
+ goto destroy;
+ }
+
+ main_method = (*env)->GetStaticMethodID(env, cls, "main",
+ "([Ljava/lang/String;)V");
+ if (main_method == NULL) {
+ goto destroy;
+ }
+
+ string_class = (*env)->FindClass(env, "java/lang/String");
+ args = (*env)->NewObjectArray(env, main_count, string_class, NULL);
+ if (args == NULL) {
+ goto destroy;
+ }
+
+ for (a = 0; a < main_count; ++a)
+ {
+ jstring jstr;
+
+ jstr = (*env)->NewStringUTF(env, *argv);
+ if (jstr == NULL)
+ goto destroy;
+ ++argv;
+ (*env)->SetObjectArrayElement(env, args, a, jstr);
+ }
+
+ (*env)->CallStaticVoidMethod(env, cls, main_method, args);
+
+ destroy:
+ if ((*env)->ExceptionOccurred(env))
+ (*env)->ExceptionDescribe(env);
+ return (*vm)->DestroyJavaVM(vm);
+}
+#endif
+
+int invoke_via_exec(char** vm_options, int vm_count,
+ char** main_options, int main_count)
+{
+ char* argv[vm_count + main_count + 5];
+ char** argv_pos;
+ int a;
+
+ argv_pos = argv;
+ *argv_pos++ = (char*) VM_BINARY;
+ *argv_pos++ = (char*) "-classpath";
+ *argv_pos++ = (char*) TOOLS_CP;
+
+ for (a = 0; a < vm_count; ++a)
+ *argv_pos++ = *vm_options++;
+
+ *argv_pos++ = (char*) MAIN_METHOD;
+
+ for (a = 0; a < main_count; ++a)
+ *argv_pos++ = *main_options++;
+
+#ifdef DEBUG
+ for (a = 0; a < vm_count + main_count + 4; ++a)
+ printf("cmd line option %d: %s\n", a, argv[a]);
+#endif
+
+ *argv_pos++ = NULL;
+
+ int res = execvp(VM_BINARY, argv);
+ if (res)
+ perror("Error invoking VM");
+ return res;
+}
+
More information about the distro-pkg-dev
mailing list