* jvmti.cc (_Jv_JVMTI_GetErrorName): New function.
authorkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Sep 2006 16:56:53 +0000 (16:56 +0000)
committerkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Sep 2006 16:56:53 +0000 (16:56 +0000)
        (_Jv_JVMTI_Interface): Define GetErrorName member.
        * testsuite/libjava.jvmti/geterrorname.java: New file.
        * testsuite/libjava.jvmti/geterrorname.out: New file.
        * testsuite/libjava.jvmti/natgeterrorname.cc: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117086 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/jvmti.cc
libjava/testsuite/libjava.jvmti/geterrorname.java [new file with mode: 0644]
libjava/testsuite/libjava.jvmti/geterrorname.out [new file with mode: 0644]
libjava/testsuite/libjava.jvmti/natgeterrorname.cc [new file with mode: 0644]

index 0afedde..e22d26a 100644 (file)
@@ -1,3 +1,11 @@
+2006-09-20  Keith Seitz  <keiths@redhat.com>
+
+       * jvmti.cc (_Jv_JVMTI_GetErrorName): New function.
+       (_Jv_JVMTI_Interface): Define GetErrorName member.
+       * testsuite/libjava.jvmti/geterrorname.java: New file.
+       * testsuite/libjava.jvmti/geterrorname.out: New file.
+       * testsuite/libjava.jvmti/natgeterrorname.cc: New file.
+
 2006-09-20  Gary Benson  <gbenson@redhat.com>
 
        * java/net/InetAddress.java: Mostly merged with Classpath.
index a522374..b18ac68 100644 (file)
@@ -651,6 +651,219 @@ _Jv_JVMTI_GetObjectSize (MAYBE_UNUSED jvmtiEnv *env, jobject object,
   return JVMTI_ERROR_NONE;
 }
 
+jvmtiError
+_Jv_JVMTI_GetErrorName (MAYBE_UNUSED jvmtiEnv *env, jvmtiError error,
+                       char **name_ptr)
+{
+  NULL_CHECK (name_ptr);
+
+  const char *name;
+  switch (error)
+    {
+    case JVMTI_ERROR_NONE:
+      name = "none";
+      break;
+
+    case JVMTI_ERROR_NULL_POINTER:
+      name = "null pointer";
+      break;
+
+    case JVMTI_ERROR_OUT_OF_MEMORY:
+      name = "out of memory";
+      break;
+
+    case JVMTI_ERROR_ACCESS_DENIED:
+      name = "access denied";
+      break;
+
+    case JVMTI_ERROR_WRONG_PHASE:
+      name = "wrong phase";
+      break;
+
+    case JVMTI_ERROR_INTERNAL:
+      name = "internal error";
+      break;
+
+    case JVMTI_ERROR_UNATTACHED_THREAD:
+      name = "unattached thread";
+      break;
+
+    case JVMTI_ERROR_INVALID_ENVIRONMENT:
+      name = "invalid environment";
+      break;
+
+    case JVMTI_ERROR_INVALID_PRIORITY:
+      name = "invalid priority";
+      break;
+
+    case JVMTI_ERROR_THREAD_NOT_SUSPENDED:
+      name = "thread not suspended";
+      break;
+
+    case JVMTI_ERROR_THREAD_SUSPENDED:
+      name = "thread suspended";
+      break;
+
+    case JVMTI_ERROR_THREAD_NOT_ALIVE:
+      name = "thread not alive";
+      break;
+
+    case JVMTI_ERROR_CLASS_NOT_PREPARED:
+      name = "class not prepared";
+      break;
+
+    case JVMTI_ERROR_NO_MORE_FRAMES:
+      name = "no more frames";
+      break;
+
+    case JVMTI_ERROR_OPAQUE_FRAME:
+      name = "opaque frame";
+      break;
+
+    case JVMTI_ERROR_DUPLICATE:
+      name = "duplicate";
+      break;
+
+    case JVMTI_ERROR_NOT_FOUND:
+      name = "not found";
+      break;
+
+    case JVMTI_ERROR_NOT_MONITOR_OWNER:
+      name = "not monitor owner";
+      break;
+
+    case JVMTI_ERROR_INTERRUPT:
+      name = "interrupted";
+      break;
+
+    case JVMTI_ERROR_UNMODIFIABLE_CLASS:
+      name = "unmodifiable class";
+      break;
+
+    case JVMTI_ERROR_NOT_AVAILABLE:
+      name = "not available";
+      break;
+
+    case JVMTI_ERROR_ABSENT_INFORMATION:
+      name = "absent information";
+      break;
+
+    case JVMTI_ERROR_INVALID_EVENT_TYPE:
+      name = "invalid event type";
+      break;
+
+    case JVMTI_ERROR_NATIVE_METHOD:
+      name = "native method";
+      break;
+
+    case JVMTI_ERROR_INVALID_THREAD:
+      name = "invalid thread";
+      break;
+
+    case JVMTI_ERROR_INVALID_THREAD_GROUP:
+      name = "invalid thread group";
+      break;
+
+    case JVMTI_ERROR_INVALID_OBJECT:
+      name = "invalid object";
+      break;
+
+    case JVMTI_ERROR_INVALID_CLASS:
+      name = "invalid class";
+      break;
+
+    case JVMTI_ERROR_INVALID_METHODID:
+      name = "invalid method ID";
+      break;
+
+    case JVMTI_ERROR_INVALID_LOCATION:
+      name = "invalid location";
+      break;
+
+    case JVMTI_ERROR_INVALID_FIELDID:
+      name = "invalid field ID";
+      break;
+
+    case JVMTI_ERROR_TYPE_MISMATCH:
+      name = "type mismatch";
+      break;
+
+    case JVMTI_ERROR_INVALID_SLOT:
+      name = "invalid slot";
+      break;
+
+    case JVMTI_ERROR_INVALID_MONITOR:
+      name = "invalid monitor";
+      break;
+
+    case JVMTI_ERROR_INVALID_CLASS_FORMAT:
+      name = "invalid class format";
+      break;
+
+    case JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION:
+      name = "circular class definition";
+      break;
+
+    case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED:
+      name = "unsupported redefinition: method added";
+      break;
+
+    case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED:
+      name = "unsupported redefinition: schema changed";
+      break;
+
+    case JVMTI_ERROR_INVALID_TYPESTATE:
+      name = "invalid type state";
+      break;
+
+    case JVMTI_ERROR_FAILS_VERIFICATION:
+      name = "fails verification";
+      break;
+
+    case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED:
+      name = "unsupported redefinition: hierarchy changed";
+      break;
+
+    case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED:
+      name = "unsupported redefinition: method deleted";
+      break;
+
+    case JVMTI_ERROR_UNSUPPORTED_VERSION:
+      name = "unsupported version";
+      break;
+
+    case JVMTI_ERROR_NAMES_DONT_MATCH:
+      name = "names do not match";
+      break;
+
+    case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED:
+      name = "unsupported redefinition: class modifiers changed";
+      break;
+
+    case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED:
+      name = "unsupported redefinition: method modifiers changed";
+      break;
+
+    case JVMTI_ERROR_MUST_POSSESS_CAPABILITY:
+      name = "must possess capability";
+      break;
+
+    case JVMTI_ERROR_ILLEGAL_ARGUMENT:
+      name = "illegal argument";
+      break;
+
+    default:
+      return JVMTI_ERROR_ILLEGAL_ARGUMENT;
+    }
+
+  *name_ptr = (char *) _Jv_MallocUnchecked (strlen (name) + 1);
+  if (*name_ptr == NULL)
+    return JVMTI_ERROR_OUT_OF_MEMORY;
+
+  strcpy (*name_ptr, name);
+  return JVMTI_ERROR_NONE;
+}
+
 #define RESERVED NULL
 #define UNIMPLEMENTED NULL
 
@@ -783,7 +996,7 @@ struct _Jv_jvmtiEnv _Jv_JVMTI_Interface =
   UNIMPLEMENTED,               // GetExtensionEvents
   UNIMPLEMENTED,               // SetExtensionEventCallback
   _Jv_JVMTI_DisposeEnvironment,        // DisposeEnvironment
-  UNIMPLEMENTED,               // GetErrorName
+  _Jv_JVMTI_GetErrorName,      // GetErrorName
   UNIMPLEMENTED,               // GetJLocationFormat
   UNIMPLEMENTED,               // GetSystemProperties
   _Jv_JVMTI_GetSystemProperty, // GetSystemProperty
diff --git a/libjava/testsuite/libjava.jvmti/geterrorname.java b/libjava/testsuite/libjava.jvmti/geterrorname.java
new file mode 100644 (file)
index 0000000..b809b22
--- /dev/null
@@ -0,0 +1,12 @@
+// Test JVMTI GetErrorName
+
+public class geterrorname
+{
+  public static native void do_errorname_tests ();
+
+  public static void main (String[] args)
+  {
+    System.out.println ("JVMTI GetErrorName tests");
+    do_errorname_tests ();
+  }
+}
diff --git a/libjava/testsuite/libjava.jvmti/geterrorname.out b/libjava/testsuite/libjava.jvmti/geterrorname.out
new file mode 100644 (file)
index 0000000..3b993d3
--- /dev/null
@@ -0,0 +1,49 @@
+JVMTI GetErrorName tests
+none
+null pointer
+out of memory
+access denied
+wrong phase
+internal error
+unattached thread
+invalid environment
+invalid priority
+thread not suspended
+thread suspended
+thread not alive
+class not prepared
+no more frames
+opaque frame
+duplicate
+not found
+not monitor owner
+interrupted
+unmodifiable class
+not available
+absent information
+invalid event type
+native method
+invalid thread
+invalid thread group
+invalid object
+invalid class
+invalid method ID
+invalid location
+invalid field ID
+type mismatch
+invalid slot
+invalid monitor
+invalid class format
+circular class definition
+unsupported redefinition: method added
+unsupported redefinition: schema changed
+invalid type state
+fails verification
+unsupported redefinition: hierarchy changed
+unsupported redefinition: method deleted
+unsupported version
+names do not match
+unsupported redefinition: class modifiers changed
+unsupported redefinition: method modifiers changed
+must possess capability
+illegal argument
diff --git a/libjava/testsuite/libjava.jvmti/natgeterrorname.cc b/libjava/testsuite/libjava.jvmti/natgeterrorname.cc
new file mode 100644 (file)
index 0000000..46e2590
--- /dev/null
@@ -0,0 +1,76 @@
+#include <gcj/cni.h>
+
+#include <jvm.h>
+#include <jvmti.h>
+#include <stdio.h>
+
+#include "jvmti-int.h"
+#include "geterrorname.h"
+
+static void
+get_error (jvmtiEnv *env, jvmtiError err)
+{
+  char *s;
+  env->GetErrorName (err, &s);
+  printf ("%s\n", s);
+  env->Deallocate (reinterpret_cast<unsigned char *> (s));
+}
+
+void
+geterrorname::do_errorname_tests ()
+{
+  jvmtiEnv *env;
+  JavaVM *vm = _Jv_GetJavaVM ();
+  vm->GetEnv (reinterpret_cast<void **> (&env), JVMTI_VERSION_1_0);
+
+  get_error (env, JVMTI_ERROR_NONE);
+  get_error (env, JVMTI_ERROR_NULL_POINTER);
+  get_error (env, JVMTI_ERROR_OUT_OF_MEMORY);
+  get_error (env, JVMTI_ERROR_ACCESS_DENIED);
+  get_error (env, JVMTI_ERROR_WRONG_PHASE);
+  get_error (env, JVMTI_ERROR_INTERNAL);
+  get_error (env, JVMTI_ERROR_UNATTACHED_THREAD);
+  get_error (env, JVMTI_ERROR_INVALID_ENVIRONMENT);
+  get_error (env, JVMTI_ERROR_INVALID_PRIORITY);
+  get_error (env, JVMTI_ERROR_THREAD_NOT_SUSPENDED);
+  get_error (env, JVMTI_ERROR_THREAD_SUSPENDED);
+  get_error (env, JVMTI_ERROR_THREAD_NOT_ALIVE);
+  get_error (env, JVMTI_ERROR_CLASS_NOT_PREPARED);
+  get_error (env, JVMTI_ERROR_NO_MORE_FRAMES);
+  get_error (env, JVMTI_ERROR_OPAQUE_FRAME);
+  get_error (env, JVMTI_ERROR_DUPLICATE);
+  get_error (env, JVMTI_ERROR_NOT_FOUND);
+  get_error (env, JVMTI_ERROR_NOT_MONITOR_OWNER);
+  get_error (env, JVMTI_ERROR_INTERRUPT);
+  get_error (env, JVMTI_ERROR_UNMODIFIABLE_CLASS);
+  get_error (env, JVMTI_ERROR_NOT_AVAILABLE);
+  get_error (env, JVMTI_ERROR_ABSENT_INFORMATION);
+  get_error (env, JVMTI_ERROR_INVALID_EVENT_TYPE);
+  get_error (env, JVMTI_ERROR_NATIVE_METHOD);
+  get_error (env, JVMTI_ERROR_INVALID_THREAD);
+  get_error (env, JVMTI_ERROR_INVALID_THREAD_GROUP);
+  get_error (env, JVMTI_ERROR_INVALID_OBJECT);
+  get_error (env, JVMTI_ERROR_INVALID_CLASS);
+  get_error (env, JVMTI_ERROR_INVALID_METHODID);
+  get_error (env, JVMTI_ERROR_INVALID_LOCATION);
+  get_error (env, JVMTI_ERROR_INVALID_FIELDID);
+  get_error (env, JVMTI_ERROR_TYPE_MISMATCH);
+  get_error (env, JVMTI_ERROR_INVALID_SLOT);
+  get_error (env, JVMTI_ERROR_INVALID_MONITOR);
+  get_error (env, JVMTI_ERROR_INVALID_CLASS_FORMAT);
+  get_error (env, JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION);
+  get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED);
+  get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
+  get_error (env, JVMTI_ERROR_INVALID_TYPESTATE);
+  get_error (env, JVMTI_ERROR_FAILS_VERIFICATION);
+  get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
+  get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED);
+  get_error (env, JVMTI_ERROR_UNSUPPORTED_VERSION);
+  get_error (env, JVMTI_ERROR_NAMES_DONT_MATCH);
+  get_error (env,
+            JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
+  get_error (env,
+            JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
+  get_error (env, JVMTI_ERROR_MUST_POSSESS_CAPABILITY);
+  get_error (env, JVMTI_ERROR_ILLEGAL_ARGUMENT);
+}