1 // natVMMethod.cc -- native support for VMMethod
3 /* Copyright (C) 2006, 2007 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
13 #include <java-interp.h>
15 #include "jvmti-int.h"
17 #include <gnu/classpath/jdwp/VMMethod.h>
18 #include <gnu/classpath/jdwp/exception/JdwpInternalErrorException.h>
19 #include <gnu/classpath/jdwp/util/LineTable.h>
20 #include <gnu/classpath/jdwp/util/VariableTable.h>
23 gnu::classpath::jdwp::VMMethod::getName ()
25 jvmtiEnv *env = _Jv_GetJDWP_JVMTIEnv ();
26 jmethodID method = reinterpret_cast<jmethodID> (_methodId);
28 env->GetMethodName (method, &name, NULL, NULL);
29 jstring string = JvNewStringUTF (name);
30 env->Deallocate (reinterpret_cast<unsigned char *> (name));
35 gnu::classpath::jdwp::VMMethod::getSignature ()
37 jvmtiEnv *env = _Jv_GetJDWP_JVMTIEnv ();
38 jmethodID method = reinterpret_cast<jmethodID> (_methodId);
40 env->GetMethodName (method, NULL, &signature, NULL);
41 jstring string = JvNewStringUTF (signature);
42 env->Deallocate (reinterpret_cast<unsigned char *> (signature));
47 gnu::classpath::jdwp::VMMethod::getModifiers ()
49 jvmtiEnv *env = _Jv_GetJDWP_JVMTIEnv ();
50 jmethodID method = reinterpret_cast<jmethodID> (_methodId);
52 env->GetMethodModifiers (method, &flags);
56 gnu::classpath::jdwp::util::LineTable *
57 gnu::classpath::jdwp::VMMethod::getLineTable ()
59 if (!_Jv_IsInterpretedClass (getDeclaringClass ()))
61 // this should not happen
62 ::java::lang::String *msg = JvNewStringLatin1 ("native class");
63 throw new exception::JdwpInternalErrorException (msg);
66 jmethodID desired_method = reinterpret_cast<jmethodID> (_methodId);
68 _Jv_MethodBase *theMethod
69 = _Jv_FindInterpreterMethod (getDeclaringClass (), desired_method);
71 if (theMethod == NULL)
73 // this should not happen
74 ::java::lang::String *msg
75 = JvNewStringLatin1 ("could not find method in class");
76 throw new exception::JdwpInternalErrorException (msg);
79 if (::java::lang::reflect::Modifier::isNative (desired_method->accflags))
81 jintArray lines = JvNewIntArray (0);
82 jlongArray indices = JvNewLongArray (0);
83 return new util::LineTable (-1, -1, lines, indices);
87 _Jv_InterpMethod *imeth = reinterpret_cast<_Jv_InterpMethod *> (theMethod);
92 imeth->get_line_table (start, end, lines, indices);
93 return new util::LineTable (start, end, lines, indices);
97 gnu::classpath::jdwp::util::VariableTable*
98 gnu::classpath::jdwp::VMMethod::getVariableTable ()