jni_util.h revision 0
3020N/A * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved. 3020N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3020N/A * This code is free software; you can redistribute it and/or modify it 3020N/A * under the terms of the GNU General Public License version 2 only, as 3020N/A * published by the Free Software Foundation. Sun designates this 3020N/A * particular file as subject to the "Classpath" exception as provided 3020N/A * by Sun in the LICENSE file that accompanied this code. 3020N/A * This code is distributed in the hope that it will be useful, but WITHOUT 3020N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3020N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3020N/A * version 2 for more details (a copy is included in the LICENSE file that 3020N/A * You should have received a copy of the GNU General Public License version 3020N/A * 2 along with this work; if not, write to the Free Software Foundation, 3020N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3020N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 3020N/A * CA 95054 USA or visit www.sun.com if you need additional information or 3020N/A * This file contains utility functions that can be implemented in pure JNI. 3020N/A * Caution: Callers of functions declared in this file should be 3020N/A * particularly aware of the fact that these functions are convenience 3020N/A * functions, and as such are often compound operations, each one of 3020N/A * which may throw an exception. Therefore, the functions this file 3020N/A * will often return silently if an exception has occured, and callers 3020N/A * must check for exception themselves. 3020N/A/* Throw a Java exception by name. Similar to SignalError. */ 3020N/A/* Throw common exceptions */ 3020N/A/* Throw an exception by name, using the string returned by 3020N/A * JVM_LastErrorString for the detail string. If the last-error 3020N/A * string is NULL, use the given default detail string. 3020N/A/* Throw an IOException, using the last-error string for the detail 3020N/A * string. If the last-error string is NULL, use the given default 3020N/A/* Convert between Java strings and i18n C strings */ 3020N/A/* Copy count number of arguments from src to dst. Array bounds 3020N/A * and ArrayStoreException are checked. 3020N/A/* Invoke a object-returning static method, based on class name, 3020N/A * method name, and signature string. 3020N/A * The caller should check for exceptions by setting hasException 3020N/A * argument. If the caller is not interested in whether an exception 3020N/A * has occurred, pass in NULL. 3020N/A/* Invoke an instance method by name. /* Construct a new object of class, specifying the class by name, * and specififying which constructor to run and what arguments to * The method will return an initialized instance if successful. * It will return NULL if an error has occured (for example if * it ran out of memory) and the appropriate Java exception will * 0: object is not an instance of the class named by classname. * 1: object is an instance of the class named by classname. * -1: the class named by classname cannot be found. An exception /* Get or set class and instance fields. * Note that set functions take a variable number of arguments, * but only one argument of the appropriate type can be passed. * For example, to set an integer field i to 100: * JNU_SetFieldByName(env, &exc, obj, "i", "I", 100); * To set a float field f to 12.3: * JNU_SetFieldByName(env, &exc, obj, "f", "F", 12.3); * The caller should check for exceptions by setting hasException * argument. If the caller is not interested in whether an exception * has occurred, pass in NULL. * Calls the .equals method. /************************************************************************ * Convenience thread-related calls on the java.lang.Object class. /************************************************************************ * Miscellaneous utilities used by the class libraries /************************************************************************ * Package shorthand for use by native libraries * Check if the current thread is attached to the VM, and returns * the JNIEnv of the specified version if the thread is attached. * If the current thread is not attached, this function returns 0. * If the current thread is attached, this function returns the * JNI environment, or returns (void *)JNI_ERR if the specified * version is not supported. * Warning free access to pointers stored in Java long fields.