diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc')
-rw-r--r-- | libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc b/libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc new file mode 100644 index 000000000..326b5a68c --- /dev/null +++ b/libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc @@ -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; +} |