The branch, master has been updated via f493456a57042ba675656a695cf44ec495fe077f (commit) from 3b312031cd9b151a21d5d0ad3d7a35cd4a1fd4d3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit f493456a57042ba675656a695cf44ec495fe077f Author: Andrew Cagney <cagney@redhat.com> Date: Thu Apr 17 15:23:22 2008 -0400 New worker functions. frysk-sys/frysk/ChangeLog 2008-04-17 Andrew Cagney <cagney@redhat.com> * jni/exceptions.cxx: New. * jni/exceptions.hxx: New. ----------------------------------------------------------------------- Summary of changes: frysk-sys/frysk/ChangeLog | 5 ++ frysk-sys/frysk/jni/exceptions.cxx | 81 ++++++++++++++++++++++++++++++++++++ frysk-sys/frysk/jni/exceptions.hxx | 51 ++++++++++++++++++++++ 3 files changed, 137 insertions(+), 0 deletions(-) create mode 100644 frysk-sys/frysk/jni/exceptions.cxx create mode 100644 frysk-sys/frysk/jni/exceptions.hxx First 500 lines of diff: diff --git a/frysk-sys/frysk/ChangeLog b/frysk-sys/frysk/ChangeLog index d2b4ff3..0221e86 100644 --- a/frysk-sys/frysk/ChangeLog +++ b/frysk-sys/frysk/ChangeLog @@ -1,3 +1,8 @@ +2008-04-17 Andrew Cagney <cagney@redhat.com> + + * jni/exceptions.cxx: New. + * jni/exceptions.hxx: New. + 2008-04-16 Andrew Cagney <cagney@redhat.com> * jni/util.cxx: New. diff --git a/frysk-sys/frysk/jni/exceptions.cxx b/frysk-sys/frysk/jni/exceptions.cxx new file mode 100644 index 0000000..c1c8834 --- /dev/null +++ b/frysk-sys/frysk/jni/exceptions.cxx @@ -0,0 +1,81 @@ +// This file is part of the program FRYSK. +// +// Copyright 2008, Red Hat Inc. +// +// FRYSK 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; version 2 of the License. +// +// FRYSK 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 FRYSK; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// In addition, as a special exception, Red Hat, Inc. gives You the +// additional right to link the code of FRYSK with code not covered +// under the GNU General Public License ("Non-GPL Code") and to +// distribute linked combinations including the two, subject to the +// limitations in this paragraph. Non-GPL Code permitted under this +// exception must only link to the code of FRYSK through those well +// defined interfaces identified in the file named EXCEPTION found in +// the source code files (the "Approved Interfaces"). The files of +// Non-GPL Code may instantiate templates or use macros or inline +// functions from the Approved Interfaces without causing the +// resulting work to be covered by the GNU General Public +// License. Only Red Hat, Inc. may make changes or additions to the +// list of Approved Interfaces. You must obey the GNU General Public +// License in all respects for all of the FRYSK code and other code +// used in conjunction with FRYSK except the Non-GPL Code covered by +// this exception. If you modify this file, you may extend this +// exception to your version of the file, but you are not obligated to +// do so. If you do not wish to provide this exception without +// modification, you must delete this exception statement from your +// version and license this file solely under the GPL without +// exception. + +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +#include <jni.h> + +#include "frysk/jni/exceptions.hxx" + +void +errnoException(JNIEnv *env, int error, const char *prefix) { + // Hack; for moment just throw something. + runtimeException(env, "not implemented: %s#%d#%s", + __FILE__, __LINE__, __func__); +} + +void +errnoException(JNIEnv *env, int error, const char *prefix, + const char *fmt, ...) { + // Hack; for moment just throw something. + runtimeException(env, "not implemented: %s#%d#%s", + __FILE__, __LINE__, __func__); +} + +void +runtimeException(JNIEnv *env, const char *fmt, ...) { + jclass cls = env->FindClass("java/lang/RuntimeException"); + if (cls != NULL) { + va_list ap; + va_start(ap, fmt); + char *msg = NULL; + if (::vasprintf(&msg, fmt, ap) < 0) { + fprintf(stderr, "runtimeException: vasprintf failed: %s", + ::strerror(errno)); + env->ThrowNew(cls, "runtimeException: vasprintf failed"); + } + env->ThrowNew(cls, msg); + ::free(msg); + va_end(ap); + } +} diff --git a/frysk-sys/frysk/jni/exceptions.hxx b/frysk-sys/frysk/jni/exceptions.hxx new file mode 100644 index 0000000..06473d0 --- /dev/null +++ b/frysk-sys/frysk/jni/exceptions.hxx @@ -0,0 +1,51 @@ +// This file is part of the program FRYSK. +// +// Copyright 2008, Red Hat Inc. +// +// FRYSK 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; version 2 of the License. +// +// FRYSK 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 FRYSK; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// In addition, as a special exception, Red Hat, Inc. gives You the +// additional right to link the code of FRYSK with code not covered +// under the GNU General Public License ("Non-GPL Code") and to +// distribute linked combinations including the two, subject to the +// limitations in this paragraph. Non-GPL Code permitted under this +// exception must only link to the code of FRYSK through those well +// defined interfaces identified in the file named EXCEPTION found in +// the source code files (the "Approved Interfaces"). The files of +// Non-GPL Code may instantiate templates or use macros or inline +// functions from the Approved Interfaces without causing the +// resulting work to be covered by the GNU General Public +// License. Only Red Hat, Inc. may make changes or additions to the +// list of Approved Interfaces. You must obey the GNU General Public +// License in all respects for all of the FRYSK code and other code +// used in conjunction with FRYSK except the Non-GPL Code covered by +// this exception. If you modify this file, you may extend this +// exception to your version of the file, but you are not obligated to +// do so. If you do not wish to provide this exception without +// modification, you must delete this exception statement from your +// version and license this file solely under the GPL without +// exception. + +/** + * Creates various exceptions making them pending ready for the JNI + * code return. + */ + +extern void errnoException(JNIEnv *env, int error, const char *prefix); +extern void errnoException(JNIEnv *env, int error, const char *prefix, + const char *fmt, ...) + __attribute__((format (printf, 4, 5))); + +extern void runtimeException(JNIEnv *env, const char *fmt, ...) + __attribute__((format (printf, 2, 3))); hooks/post-receive -- frysk system monitor/debugger