45 #define NATIVE_METHODS_COUNT sizeof(methods) / sizeof(JNINativeMethod)
48 #define NATIVE_LIBRARY_PREFIX "lib"
50 #if defined(__DARWIN__)
51 # define NATIVE_LIBRARY_SUFFIX ".dylib"
53 # define NATIVE_LIBRARY_SUFFIX ".so"
56 #if defined(ENABLE_DL)
88 typedef std::multimap<classloader_t*, NativeLibrary>
MAP;
93 class comparator :
public std::binary_function<std::pair<classloader_t*, NativeLibrary>, Utf8String, bool> {
97 return (args.second.get_filename() == filename);
139 class comparator :
public std::binary_function<std::pair<classloader_t*, NativeLibrary>, Utf8String, bool> {
143 return (args.second.get_filename() == filename);
154 #if defined(ENABLE_JVMTI)
164 NativeAgent(
char* library,
char* options) : _library(library), _options(options) {}
166 char* get_library()
const {
return _library; }
167 char* get_options()
const {
return _options; }
176 std::vector<NativeAgent> _agents;
179 void register_agent_library(
char* library,
char* options);
180 void register_agent_path(
char* path,
char* options);
182 bool unload_agents();
191 #endif // NATIVE_HPP_
Utf8String _classname
Class name.
Utf8String get_filename() const
void * open()
Open this native library.
Table containing all native methods registered with the VM.
void register_methods(Utf8String classname, const JNINativeMethod *methods, size_t count)
Register native methods with the VM.
classloader_t * get_classloader() const
void * get_handle() const
void close()
Close this native library.
void * resolve_symbol(Utf8String symbolname, classloader_t *classloader)
Try to find a symbol with the given name in all loaded native libraries defined by classloader...
bool operator()(std::pair< classloader_t *, NativeLibrary > args, Utf8String filename) const
bool operator()(std::pair< classloader_t *, NativeLibrary > args, Utf8String filename) const
Dummy implementation of a mutex.
JNIEnv jclass jobject const char * name
Utf8String _name
Method name.
friend bool operator<(const NativeMethod &first, const NativeMethod &second)
bool load(JNIEnv *env)
Load this native library and initialize it, if possible.
std::set< NativeMethod > _methods
bool is_loaded()
Checks if this native library is loaded.
std::multimap< classloader_t *, NativeLibrary > MAP
static JNINativeMethod methods[]
NativeMethod(methodinfo *m)
classloader_t * _classloader
Defining classloader.
bool is_loaded(NativeLibrary &library)
Checks if the given native library is loaded.
void * _handle
Filesystem handle.
Represents a native library.
void add(NativeLibrary &library)
Add the given native library to the native libraries table.
NativeLibrary(Utf8String filename, classloader_t *classloader=0, void *handle=0)
Utf8String _descriptor
Method signature.
void * find_registered_method(methodinfo *m)
Try to find the given method in the native methods registered with the VM.
void * resolve_method(methodinfo *m)
Resolves a native method, maybe from a dynamic library.
void * _function
Pointer to the native function.
java_handle_t * native_new_and_init(classinfo *c)
Registers a new native agent by specified by it's library name and with an optional options string...
Utf8String _filename
Name of the native library.
Mutex _mutex
Mutex to make the container thread-safe.
NativeLibrary(void *handle)
void * get_function() const
NativeMethod(Utf8String classname, Utf8String name, Utf8String signature, void *function)
Table containing all loaded native libraries.
java_handle_t * native_new_and_init_string(classinfo *c, java_handle_t *s)
void * resolve_symbol(Utf8String symbolname) const
Resolve the given symbol in this native library.
Represents a native method.