+2007-02-21 Kyle Galloway <kgallowa@redhat.com>
+
+ * jvmti.cc (_Jv_JVMTI_GetArgumentsSize): New function.
+ * testsuite/libjava.jvmti/interp/getargssize.java: New test.
+ * testsuite/libjava.jvmti/interp/getargssize.h: Ditto.
+ * testsuite/libjava.jvmti/interp/getargssize.jar: Ditto.
+ * testsuite/libjava.jvmti/interp/getargssize.out: Ditto.
+ * testsuite/libjava.jvmti/interp/natgetargssize.cc: Ditto.
+
2007-02-21 Gary Benson <gbenson@redhat.com>
* java/util/GregorianCalendar.java: Removed.
return JVMTI_ERROR_NONE;
}
+static jvmtiError JNICALL
+_Jv_JVMTI_GetArgumentsSize (jvmtiEnv *env, jmethodID method, jint *size)
+{
+ REQUIRE_PHASE (env, JVMTI_PHASE_START | JVMTI_PHASE_LIVE);
+ NULL_CHECK (size);
+
+ CHECK_FOR_NATIVE_METHOD (method);
+
+ jvmtiError jerr;
+ char *sig;
+ jint num_slots = 0;
+
+ jerr = env->GetMethodName (method, NULL, &sig, NULL);
+ if (jerr != JVMTI_ERROR_NONE)
+ return jerr;
+
+ // If the method is non-static add a slot for the "this" pointer.
+ if ((method->accflags & java::lang::reflect::Modifier::STATIC) == 0)
+ num_slots++;
+
+ for (int i = 0; sig[i] != ')'; i++)
+ {
+ if (sig[i] == 'Z' || sig[i] == 'B' || sig[i] == 'C' || sig[i] == 'S'
+ || sig[i] == 'I' || sig[i] == 'F')
+ num_slots++;
+ else if (sig[i] == 'J' || sig[i] == 'D')
+ num_slots+=2;
+ else if (sig[i] == 'L')
+ {
+ num_slots++;
+ while (sig[i] != ';')
+ i++;
+ }
+ }
+
+ *size = num_slots;
+ return JVMTI_ERROR_NONE;
+}
+
static jvmtiError JNICALL
_Jv_JVMTI_GetMethodDeclaringClass (MAYBE_UNUSED jvmtiEnv *env,
jmethodID method,
_Jv_JVMTI_GetMethodModifiers, // GetMethodModifers
RESERVED, // reserved67
_Jv_JVMTI_GetMaxLocals, // GetMaxLocals
- UNIMPLEMENTED, // GetArgumentsSize
+ _Jv_JVMTI_GetArgumentsSize, // GetArgumentsSize
_Jv_JVMTI_GetLineNumberTable, // GetLineNumberTable
UNIMPLEMENTED, // GetMethodLocation
_Jv_JVMTI_GetLocalVariableTable, // GetLocalVariableTable
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __getargssize__
+#define __getargssize__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jint JNICALL Java_getargssize_do_1getargssize_1tests (JNIEnv *env, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __getargssize__ */
--- /dev/null
+public class getargssize
+{
+ static
+ {
+ System.loadLibrary("natgetargssize");
+ }
+
+ public int aMethod (float fone, int ione)
+ {
+ return 0;
+ }
+
+ public long bMethod (long lone, double done, int ione)
+ {
+ return 0;
+ }
+
+ public static boolean cMethod ()
+ {
+ return false;
+ }
+
+ public static Object dMethod (Object op)
+ {
+ return op;
+ }
+
+ public static native int do_getargssize_tests ();
+
+ public static void main (String[] args)
+ {
+ System.out.println ("JVMTI getargssize Interpreted Test");
+
+ do_getargssize_tests ();
+ }
+}
--- /dev/null
+JVMTI getargssize Interpreted Test
+Method 0 requires 3 slots for its arguments
+Method 1 requires 6 slots for its arguments
+Method 2 requires 0 slots for its arguments
+Method 3 requires 1 slots for its arguments
--- /dev/null
+#include <jni.h>
+
+#include <jvmti.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "getargssize.h"
+
+JNIEXPORT jint JNICALL Java_getargssize_do_1getargssize_1tests
+(JNIEnv *env, jclass klass)
+{
+ JavaVM *vm;
+ jint err = env->GetJavaVM (&vm);
+ if (err < 0)
+ {
+ fprintf (stderr, "error getting VM\n");
+ exit (1);
+ }
+
+ jvmtiEnv *jvmti = NULL;
+ vm->GetEnv ((void **) &jvmti, JVMTI_VERSION_1_0);
+
+ if (jvmti == NULL)
+ {
+ fprintf (stderr, "error getting jvmti environment\n");
+ exit (1);
+ }
+
+ jint args_size;
+
+ jvmtiError jerr;
+
+ jmethodID meth_ids[4];
+
+ meth_ids[0] = env->GetMethodID (klass, "aMethod", "(FI)I");
+ meth_ids[1] = env->GetMethodID (klass, "bMethod", "(JDI)J");
+ meth_ids[2] = env->GetStaticMethodID (klass, "cMethod", "()Z");
+ meth_ids[3] = env->GetStaticMethodID (klass, "dMethod",
+ "(Ljava/lang/Object;)Ljava/lang/Object;");
+ for (int i = 0; i < 4; i++)
+ {
+ jerr = jvmti->GetArgumentsSize (meth_ids[i], &args_size);
+ if (jerr != JVMTI_ERROR_NONE)
+ {
+ char *error_name;
+ jvmti->GetErrorName (jerr, &error_name);
+ fprintf (stderr, "JVMTI Error: %s\n", error_name);
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (error_name));
+ }
+ else
+ {
+ printf ("Method %d requires %d slots for its arguments\n", i,
+ args_size);
+ }
+ }
+
+ return 0;
+}