jvm.h revision 431
196N/A * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A// HotSpot integration note: 0N/A// This file and jvm.h used with the JDK are identical, 0N/A// except for the three includes removed below and the 0N/A// SUPPORT_OLD_REFLECTION sections cut out of the JDK's jvm.h. 0N/A * This file contains additional functions exported from the VM. 0N/A * These functions are complementary to the standard JNI support. 0N/A * There are three parts to this file: 0N/A * First, this file contains the VM-related functions needed by native 0N/A * libraries in the standard Java API. For example, the java.lang.Object 0N/A * class needs VM-level functions that wait for and notify monitors. 0N/A * Second, this file contains the functions and constant definitions 0N/A * needed by the byte code verifier and class file format checker. 0N/A * These functions allow the verifier and format checker to be written 0N/A * in a VM-independent way. 0N/A * Third, this file contains various I/O and nerwork operations needed 0N/A * by the standard Java I/O and network APIs. 0N/A * Bump the version number when either of the following happens: 0N/A * 1. There is a change in JVM_* functions. 0N/A * 2. There is a change in the contract between VM and Java classes. 0N/A * For example, if the VM relies on a new private field in Thread 0N/A/************************************************************************* 0N/A PART 1: Functions for Native Libraries 0N/A ************************************************************************/ 0N/A/* Returns the number of real-time milliseconds that have elapsed since the 0N/A * least-recently-inspected heap object was last inspected by the garbage 0N/A * For simple stop-the-world collectors this value is just the time 0N/A * since the most recent collection. For generational collectors it is the 0N/A * time since the oldest generation was most recently collected. Other 0N/A * collectors are free to return a pessimistic estimate of the elapsed time, or 0N/A * simply the time since the last full collection was performed. 0N/A * Note that in the presence of reference objects, a given object that is no 0N/A * longer strongly reachable may have to be inspected multiple times before it 0N/A * java.lang.Float and java.lang.Double 0N/A * java.lang.Throwable 0N/A * java.lang.Compiler 0N/A/* getStackTrace() and getAllStackTraces() method */ 0N/A * java.lang.SecurityManager 0N/A * java.io.ObjectInputStream 0N/A * This function has been deprecated and should not be considered 0N/A * part of the specified JVM interface. 0N/A * java.lang.reflect.Array 0N/A * java.lang.Class and java.lang.ClassLoader 0N/A * Returns the class in which the code invoking the native method 0N/A * Note that in JDK 1.1, native methods did not create a frame. 0N/A * In 1.2, they do. Therefore native methods like Class.forName 0N/A * can no longer look at the current frame for the caller class. 0N/A * Find primitive classes 0N/A * Find a class from a given class loader. Throw ClassNotFoundException 0N/A * or NoClassDefFoundError depending on the value of the last 226N/A * Find a class from a boot class loader. Throw ClassNotFoundException 226N/A * or NoClassDefFoundError depending on the value of the last 226N/A * argument. This is the same as FindClassFromClassLoader but provided 226N/A * as a convenience method exported correctly on all platforms for 226N/A * JSR 277 launcher class loading. 0N/A * Find a class from a given class. 0N/A/* Find a loaded class cached by the VM */ 0N/A/* Define a class with a source (added in JDK1.5) */ 431N/A/* Define a class with a source (MLVM) */ 431N/A // same args as JVM_DefineClassWithSource to this point 0N/A * Reflection support functions 0N/A/* Generics support (JDK 1.5) */ 0N/A/* Annotations support (JDK 1.5) */ 0N/A/* Annotations support (JDK 1.6) */ 0N/A// field is a handle to a java.lang.reflect.Field object 0N/A// method is a handle to a java.lang.reflect.Method object 0N/A// method is a handle to a java.lang.reflect.Method object 0N/A// method is a handle to a java.lang.reflect.Method object 0N/A * New (JDK 1.4) reflection implementation 0N/A/* Differs from JVM_GetClassModifiers in treatment of inner classes. 0N/A This returns the access flags for the class as specified in the 0N/A class file rather than searching the InnerClasses attribute (if 0N/A present) to find the source-level access flags. Only the values of 0N/A the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be 0N/A * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) 0N/A * Signal support, used to implement the shutdown sequence. Every VM must 0N/A * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts 0N/A * (^C) and the latter for external termination (kill, system shutdown, etc.). 0N/A * Other platform-dependent signal values may also be supported. 0N/A * Retrieve the assertion directives for the specified class. 0N/A * Retrieve the assertion directives from the VM. 0N/A * sun.misc.AtomicLong 116N/A * Structure to pass one probe description to JVM. 116N/A * The VM will overwrite the definition of the referenced method with 116N/A * code that will fire the probe. 116N/A * Encapsulates the stability ratings for a DTrace provider field 116N/A * Structure to pass one provider description to JVM 116N/A * Get the version number the JVM was built with 116N/A * Register new probe with given signature, return global handle 116N/A * The version passed in is the version that the library code was 116N/A * Check to see if DTrace is supported by OS 0N/A/************************************************************************* 0N/A PART 2: Support for the Verifier and Class File Format Checker 0N/A ************************************************************************/ 0N/A * Return the class name in UTF format. The result is valid 0N/A * until JVM_ReleaseUTf is called. 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the constant pool types in the buffer provided by "types." 0N/A * Returns the number of Constant Pool entries. 0N/A * Returns the number of *declared* fields or methods. 0N/A * Returns the CP indexes of exceptions raised by a given method. 0N/A * Places the result in the given buffer. 0N/A * The method is identified by method_index. 0N/A * Returns the number of exceptions raised by a given method. 0N/A * The method is identified by method_index. 0N/A * Returns the byte code sequence of a given method. 0N/A * Places the result in the given buffer. 0N/A * The method is identified by method_index. 0N/A * Returns the length of the byte code sequence of a given method. 0N/A * The method is identified by method_index. 0N/A * A structure used to a capture exception table entry in a Java method. 0N/A * Returns the exception table entry at entry_index of a given method. 0N/A * Places the result in the given buffer. 0N/A * The method is identified by method_index. 0N/A * Returns the length of the exception table of a given method. 0N/A * The method is identified by method_index. 0N/A * Returns the modifiers of a given field. 0N/A * The field is identified by field_index. 0N/A * Returns the modifiers of a given method. 0N/A * The method is identified by method_index. 0N/A * Returns the number of local variables of a given method. 0N/A * The method is identified by method_index. 0N/A * Returns the number of arguments (including this pointer) of a given method. 0N/A * The method is identified by method_index. 0N/A * Returns the maximum amount of stack (in words) used by a given method. 0N/A * The method is identified by method_index. 0N/A * Is a given method a constructor. 0N/A * The method is identified by method_index. 0N/A * Returns the name of a given method in UTF format. 0N/A * The result remains valid until JVM_ReleaseUTF is called. 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the signature of a given method in UTF format. 0N/A * The result remains valid until JVM_ReleaseUTF is called. 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the name of the field refered to at a given constant pool 0N/A * The result is in UTF format and remains valid until JVM_ReleaseUTF 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the name of the method refered to at a given constant pool 0N/A * The result is in UTF format and remains valid until JVM_ReleaseUTF 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the signature of the method refered to at a given constant pool 0N/A * The result is in UTF format and remains valid until JVM_ReleaseUTF 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the signature of the field refered to at a given constant pool 0N/A * The result is in UTF format and remains valid until JVM_ReleaseUTF 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the class name refered to at a given constant pool index. 0N/A * The result is in UTF format and remains valid until JVM_ReleaseUTF 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the class name refered to at a given constant pool index. 0N/A * The constant pool entry must refer to a CONSTANT_Fieldref. 0N/A * The result is in UTF format and remains valid until JVM_ReleaseUTF 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the class name refered to at a given constant pool index. 0N/A * The constant pool entry must refer to CONSTANT_Methodref or 0N/A * CONSTANT_InterfaceMethodref. 0N/A * The result is in UTF format and remains valid until JVM_ReleaseUTF 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns the modifiers of a field in calledClass. The field is 0N/A * referred to in class cb at constant pool entry index. 0N/A * The caller must treat the string as a constant and not modify it 0N/A * Returns -1 if the field does not exist in calledClass. 0N/A * Returns the modifiers of a method in calledClass. The method is 0N/A * referred to in class cb at constant pool entry index. 0N/A * Returns -1 if the method does not exist in calledClass. 0N/A * Releases the UTF string obtained from the VM. 0N/A * Compare if two classes are in the same package. 0N/A/* Constants in class files */ 0N/A/* Used in the newarray instruction. */ 0N/A/* JVM method signatures */ 0N/A * A function defined by the byte-code verifier and called by the VM. 0N/A * This is not a function implemented in the VM. 0N/A * Returns JNI_FALSE if verification fails. A detailed error message 0N/A * will be places in msg_buf, whose length is specified by buf_len. 0N/A * Support for a VM-independent class format checker. 0N/A unsigned long code;
/* byte code */ 0N/A unsigned long excs;
/* exceptions */ 0N/A unsigned long etab;
/* catch table */ 0N/A unsigned long lnum;
/* line number */ 0N/A unsigned long lvar;
/* local vars */ 0N/A unsigned int fields2;
/* number of static 2-word fields */ 0N/A * Functions defined in libjava.so to perform string conversions. 0N/A/* This is the function defined in libjava.so that performs class 0N/A * format checks. This functions fills in size information about 0N/A * the class file and returns: 0N/A * -3: unsupported version 0N/A * -4: bad class name 0N/A * This is the function defined in libjava.so to perform path 0N/A * canonicalization. VM call this function before opening jar files 0N/A * to load system classes. 0N/A/************************************************************************* 0N/A PART 3: I/O and Network Support 0N/A ************************************************************************/ 0N/A/* Note that the JVM IO functions are expected to return JVM_IO_ERR 0N/A * when there is any kind of error. The caller can then use the 0N/A * platform specific support (e.g., errno) to get the detailed 0N/A * error info. The JVM_GetLastErrorString procedure may also be used 0N/A * to obtain a descriptive error string. 0N/A/* For interruptible IO. Returning JVM_IO_INTR indicates that an IO 0N/A * operation has been disrupted by Thread.interrupt. There are a 0N/A * number of technical difficulties related to interruptible IO that 0N/A * need to be solved. For example, most existing programs do not handle 0N/A * InterruptedIOExceptions specially, they simply treat those as any 0N/A * IOExceptions, which typically indicate fatal errors. 0N/A * There are also two modes of operation for interruptible IO. In the 0N/A * resumption mode, an interrupted IO operation is guaranteed not to 0N/A * have any side-effects, and can be restarted. In the termination mode, 0N/A * an interrupted IO operation corrupts the underlying IO stream, so 0N/A * that the only reasonable operation on an interrupted stream is to 0N/A * close that stream. The resumption mode seems to be impossible to 0N/A * implement on Win32 and Solaris. Implementing the termination mode is 0N/A * easier, but it's not clear that's the right semantics. 0N/A * using a compile-time flag on Solaris. Third-party JVM ports do not 0N/A * need to implement interruptible IO. 0N/A/* Write a string into the given buffer, in the platform's local encoding, 0N/A * that describes the most recent system-level error to occur in this thread. 0N/A * Return the length of the string or zero if no error occurred. 0N/A * Convert a pathname into native format. This function does syntactic 0N/A * cleanup, such as removing redundant separator characters. It modifies 0N/A * the given pathname string in place. 0N/A * JVM I/O error codes 0N/A * Open a file descriptor. This function returns a negative error code 0N/A * on error, and a non-negative integer that is the file descriptor on 0N/A * Close a file descriptor. This function returns -1 on error, and 0 0N/A * fd the file descriptor to close. 0N/A * Read data from a file decriptor into a char array. 0N/A * fd the file descriptor to read from. 0N/A * buf the buffer where to put the read data. 0N/A * nbytes the number of bytes to read. 0N/A * This function returns -1 on error, and 0 on success. 0N/A * Write data from a char array to a file decriptor. 0N/A * fd the file descriptor to read from. 0N/A * buf the buffer from which to fetch the data. 0N/A * nbytes the number of bytes to write. 0N/A * This function returns -1 on error, and 0 on success. 0N/A * Returns the number of bytes available for reading from a given file 0N/A * Move the file descriptor pointer from whence by offset. 0N/A * fd the file descriptor to move. 0N/A * offset the number of bytes to move it by. 0N/A * whence the start from where to move it. 0N/A * This function returns the resulting pointer location. 0N/A * Set the length of the file associated with the given descriptor to the given 0N/A * length. If the new length is longer than the current length then the file 0N/A * is extended; the contents of the extended portion are not defined. The 0N/A * value of the file pointer is undefined after this procedure returns. 0N/A * Synchronize the file descriptor's in memory state with that of the 0N/A * physical device. Return of -1 is an error, 0 is OK. 0N/A * Networking library support 0N/A * These routines are only reentrant on Windows 0N/A#
endif /* _WINDOWS */ 0N/A * The standard printing functions supported by the Java VM. (Should they 0N/A * be renamed to JVM_* in the future? 0N/A * BE CAREFUL! The following functions do not implement the 0N/A * full feature set of standard C printf formats. 0N/A * Support for old native code-based (pre-JDK 1.4) reflection implementation. 0N/A * Disabled by default in the product build. 0N/A * reflecting fields and methods. 0N/A * which: 0 --- MEMBER_PUBLIC 0N/A * 1 --- MEMBER_DECLARED 0N/A * NOTE: absent in product build by default 0N/A * Implements Class.newInstance 0N/A * java.lang.reflect.Field 0N/A * java.lang.reflect.Method 0N/A * java.lang.reflect.Constructor 0N/A#
endif /* SUPPORT_OLD_REFLECTION */ 0N/A * java.lang.management support 0N/A * Initialize the agent properties with the properties maintained in the VM. 0N/A/* Generics reflection support. 0N/A * Returns information about the given class's EnclosingMethod 0N/A * attribute, if present, or null if the class had no enclosing 0N/A * If non-null, the returned array contains three elements. Element 0 0N/A * is the java.lang.Class of which the enclosing method is a member, 0N/A * and elements 1 and 2 are the java.lang.Strings for the enclosing 0N/A * method's name and descriptor, respectively. 0N/A * Java thread state support 0N/A * Returns an array of the threadStatus values representing the 0N/A * given Java thread state. Returns NULL if the VM version is 0N/A * incompatible with the JDK or doesn't support the given 0N/A * Java thread state. 0N/A * Returns an array of the substate names representing the 0N/A * given Java thread state. Returns NULL if the VM version is 0N/A * incompatible with the JDK or the VM doesn't support 0N/A * the given Java thread state. 0N/A * values must be the jintArray returned from JVM_GetThreadStateValues 0N/A * and javaThreadState. 0N/A/* ========================================================================= 0N/A * The following defines a private JVM interface that the JDK can query 0N/A * for the JVM version and capabilities. sun.misc.Version defines 0N/A * the methods for getting the VM version and its capabilities. 0N/A * When a new bit is added, the following should be updated to provide 0N/A * access to the new capability: 0N/A * HS: JVM_GetVersionInfo and Abstract_VM_Version class 0N/A * SDK: Version class 0N/A * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for 0N/A * JVM to query for the JDK version and capabilities. 0N/A * When a new bit is added, the following should be updated to provide 0N/A * access to the new capability: 0N/A * HS: JDK_Version class 0N/A * SDK: JDK_GetVersionInfo0 0N/A * ========================================================================== 0N/A /* HotSpot Express VM version string: 0N/A * <major>.<minor>-bxx[-<identifier>][-<debug_flavor>] 0N/A /* The following bits represents JVM supports that JDK has dependency on. 0N/A * JDK can use these bits to determine which JVM version 0N/A * and support it has to maintain runtime compatibility. 0N/A * When a new bit is added in a minor or update release, make sure 0N/A// Micro version is 0 in HotSpot Express VM (set in jvm.cpp). 0N/A/* Build number is available in all HotSpot Express VM builds. 0N/A // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx 0N/A unsigned int jdk_version;
/* Consists of major, minor, micro (n.n.n) */ 0N/A /* and build number (xx) */ 0N/A /* The following bits represents new JDK supports that VM has dependency on. 0N/A * VM implementation can use these bits to determine which JDK version 0N/A * and support it has to maintain runtime compatibility. 0N/A * When a new bit is added in a minor or update release, make sure 0N/A/* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN) 0N/A * It will be zero for internal builds. 0N/A * This is the function JDK_GetVersionInfo0 defined in libjava.so 0N/A * that is dynamically looked up by JVM. 0N/A * This structure is used by the launcher to get the default thread 0N/A * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a 0N/A * version of 1.1. As it is not supported otherwise, it has been removed 0N/A#
endif /* __cplusplus */ 0N/A#
endif /* !_JAVASOFT_JVM_H_ */