jvmti.cc (_Jv_JVMTI_GetArgumentsSize): New function.

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.

From-SVN: r122201
This commit is contained in:
Kyle Galloway
2007-02-21 18:09:24 +00:00
committed by Kyle Galloway
parent 21af5cdfe2
commit 532e9fe7d3
7 changed files with 167 additions and 1 deletions
@@ -0,0 +1,19 @@
/* 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__ */
@@ -0,0 +1,36 @@
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 ();
}
}
@@ -0,0 +1,5 @@
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
@@ -0,0 +1,58 @@
#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;
}