blob: 586b5410c97f462cfb706d31eab568554061ae5b [file] [log] [blame]
Ian Rogersdf20fe02011-07-20 20:34:16 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07003#include "jni_internal.h"
Carl Shapiro2ed144c2011-07-26 16:52:08 -07004
Carl Shapiro9b9ba282011-08-14 15:30:39 -07005#include <cstdarg>
Elliott Hughes0af55432011-08-17 18:37:28 -07006#include <dlfcn.h>
Carl Shapiro9b9ba282011-08-14 15:30:39 -07007#include <sys/mman.h>
Elliott Hughes0af55432011-08-17 18:37:28 -07008#include <utility>
9#include <vector>
Carl Shapiro2ed144c2011-07-26 16:52:08 -070010
Elliott Hughes18c07532011-08-18 15:50:51 -070011#include "assembler.h"
Elliott Hughes40ef99e2011-08-11 17:44:34 -070012#include "class_linker.h"
Carl Shapiroea4dca82011-08-01 13:45:38 -070013#include "jni.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070014#include "logging.h"
Carl Shapiro9b9ba282011-08-14 15:30:39 -070015#include "object.h"
Carl Shapiro2ed144c2011-07-26 16:52:08 -070016#include "runtime.h"
Carl Shapirofc322c72011-07-27 00:20:01 -070017#include "scoped_ptr.h"
18#include "stringpiece.h"
Carl Shapiro2ed144c2011-07-26 16:52:08 -070019#include "thread.h"
Ian Rogersdf20fe02011-07-20 20:34:16 -070020
21namespace art {
22
Elliott Hughes0af55432011-08-17 18:37:28 -070023enum JNI_OnLoadState {
24 kPending = 0, /* initial state, must be zero */
25 kFailed,
26 kOkay,
27};
28
29struct SharedLibrary {
Elliott Hughes18c07532011-08-18 15:50:51 -070030 SharedLibrary() : jni_on_load_lock(Mutex::Create("JNI_OnLoad lock")) {
31 }
32
33 ~SharedLibrary() {
34 delete jni_on_load_lock;
Elliott Hughes0af55432011-08-17 18:37:28 -070035 }
36
37 // Path to library "/system/lib/libjni.so".
38 std::string path;
39
40 // The void* returned by dlopen(3).
41 void* handle;
42
43 // The ClassLoader this library is associated with.
44 Object* class_loader;
45
46 // Guards remaining items.
Elliott Hughes18c07532011-08-18 15:50:51 -070047 Mutex* jni_on_load_lock;
Elliott Hughes0af55432011-08-17 18:37:28 -070048 // Wait for JNI_OnLoad in other thread.
49 pthread_cond_t jni_on_load_cond;
50 // Recursive invocation guard.
51 uint32_t jni_on_load_tid;
52 // Result of earlier JNI_OnLoad call.
53 JNI_OnLoadState jni_on_load_result;
54};
55
56/*
57 * Check the result of an earlier call to JNI_OnLoad on this library. If
58 * the call has not yet finished in another thread, wait for it.
59 */
60bool CheckOnLoadResult(JavaVMExt* vm, SharedLibrary* library) {
61 Thread* self = Thread::Current();
62 if (library->jni_on_load_tid == self->GetId()) {
63 // Check this so we don't end up waiting for ourselves. We need
64 // to return "true" so the caller can continue.
65 LOG(INFO) << *self << " recursive attempt to load library "
66 << "\"" << library->path << "\"";
67 return true;
68 }
69
70 UNIMPLEMENTED(ERROR) << "need to pthread_cond_wait!";
Elliott Hughes18c07532011-08-18 15:50:51 -070071 // MutexLock mu(library->jni_on_load_lock);
Elliott Hughes0af55432011-08-17 18:37:28 -070072 while (library->jni_on_load_result == kPending) {
73 if (vm->verbose_jni) {
74 LOG(INFO) << "[" << *self << " waiting for \"" << library->path << "\" "
75 << "JNI_OnLoad...]";
76 }
77 Thread::State old_state = self->GetState();
78 self->SetState(Thread::kWaiting); // TODO: VMWAIT
79 // pthread_cond_wait(&library->jni_on_load_cond, &library->jni_on_load_lock);
80 self->SetState(old_state);
81 }
82
83 bool okay = (library->jni_on_load_result == kOkay);
84 if (vm->verbose_jni) {
85 LOG(INFO) << "[Earlier JNI_OnLoad for \"" << library->path << "\" "
86 << (okay ? "succeeded" : "failed") << "]";
87 }
88 return okay;
89}
90
91typedef int (*JNI_OnLoadFn)(JavaVM*, void*);
92
93/*
94 * Load native code from the specified absolute pathname. Per the spec,
95 * if we've already loaded a library with the specified pathname, we
96 * return without doing anything.
97 *
98 * TODO? for better results we should absolutify the pathname. For fully
99 * correct results we should stat to get the inode and compare that. The
100 * existing implementation is fine so long as everybody is using
101 * System.loadLibrary.
102 *
103 * The library will be associated with the specified class loader. The JNI
104 * spec says we can't load the same library into more than one class loader.
105 *
106 * Returns "true" on success. On failure, sets *detail to a
107 * human-readable description of the error or NULL if no detail is
108 * available; ownership of the string is transferred to the caller.
109 */
110bool JavaVMExt::LoadNativeLibrary(const std::string& path, Object* class_loader, char** detail) {
111 *detail = NULL;
112
113 // See if we've already loaded this library. If we have, and the class loader
114 // matches, return successfully without doing anything.
115 SharedLibrary* library = libraries[path];
116 if (library != NULL) {
117 if (library->class_loader != class_loader) {
118 LOG(WARNING) << "Shared library \"" << path << "\" already opened by "
119 << "ClassLoader " << library->class_loader << "; "
120 << "can't open in " << class_loader;
121 *detail = strdup("already opened by different ClassLoader");
122 return false;
123 }
124 if (verbose_jni) {
125 LOG(INFO) << "[Shared library \"" << path << "\" already loaded in "
126 << "ClassLoader " << class_loader << "]";
127 }
128 if (!CheckOnLoadResult(this, library)) {
129 *detail = strdup("JNI_OnLoad failed before");
130 return false;
131 }
132 return true;
133 }
134
135 // Open the shared library. Because we're using a full path, the system
136 // doesn't have to search through LD_LIBRARY_PATH. (It may do so to
137 // resolve this library's dependencies though.)
138
139 // Failures here are expected when java.library.path has several entries
140 // and we have to hunt for the lib.
141
142 // The current version of the dynamic linker prints detailed information
143 // about dlopen() failures. Some things to check if the message is
144 // cryptic:
145 // - make sure the library exists on the device
146 // - verify that the right path is being opened (the debug log message
147 // above can help with that)
148 // - check to see if the library is valid (e.g. not zero bytes long)
149 // - check config/prelink-linux-arm.map to ensure that the library
150 // is listed and is not being overrun by the previous entry (if
151 // loading suddenly stops working on a prelinked library, this is
152 // a good one to check)
153 // - write a trivial app that calls sleep() then dlopen(), attach
154 // to it with "strace -p <pid>" while it sleeps, and watch for
155 // attempts to open nonexistent dependent shared libs
156
157 // TODO: automate some of these checks!
158
Elliott Hughes0af55432011-08-17 18:37:28 -0700159 // This can execute slowly for a large library on a busy system, so we
160 // want to switch from RUNNING to VMWAIT while it executes. This allows
161 // the GC to ignore us.
162 Thread* self = Thread::Current();
163 Thread::State old_state = self->GetState();
164 self->SetState(Thread::kWaiting); // TODO: VMWAIT
165 void* handle = dlopen(path.c_str(), RTLD_LAZY);
166 self->SetState(old_state);
167
168 if (verbose_jni) {
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700169 LOG(INFO) << "[Call to dlopen(\"" << path << "\") returned " << handle << "]";
Elliott Hughes0af55432011-08-17 18:37:28 -0700170 }
171
172 if (handle == NULL) {
173 *detail = strdup(dlerror());
174 return false;
175 }
176
177 // Create a new entry.
178 library = new SharedLibrary;
179 library->path = path;
180 library->handle = handle;
181 library->class_loader = class_loader;
182 UNIMPLEMENTED(ERROR) << "missing pthread_cond_init";
183 // pthread_cond_init(&library->onLoadCond, NULL);
184 library->jni_on_load_tid = self->GetId();
185
186 libraries[path] = library;
187
188// if (pNewEntry != pActualEntry) {
189// LOG(INFO) << "WOW: we lost a race to add a shared library (\"" << path << "\" ClassLoader=" << class_loader <<")";
190// freeSharedLibEntry(pNewEntry);
191// return CheckOnLoadResult(this, pActualEntry);
192// } else
193 {
194 if (verbose_jni) {
195 LOG(INFO) << "[Added shared library \"" << path << "\" for ClassLoader " << class_loader << "]";
196 }
197
198 bool result = true;
199 void* sym = dlsym(handle, "JNI_OnLoad");
200 if (sym == NULL) {
201 if (verbose_jni) {
202 LOG(INFO) << "[No JNI_OnLoad found in \"" << path << "\"]";
203 }
204 } else {
205 // Call JNI_OnLoad. We have to override the current class
206 // loader, which will always be "null" since the stuff at the
207 // top of the stack is around Runtime.loadLibrary(). (See
208 // the comments in the JNI FindClass function.)
209 UNIMPLEMENTED(WARNING) << "need to override current class loader";
210 JNI_OnLoadFn jni_on_load = reinterpret_cast<JNI_OnLoadFn>(sym);
211 //Object* prevOverride = self->classLoaderOverride;
212 //self->classLoaderOverride = classLoader;
213
214 old_state = self->GetState();
215 self->SetState(Thread::kNative);
216 if (verbose_jni) {
217 LOG(INFO) << "[Calling JNI_OnLoad in \"" << path << "\"]";
218 }
219 int version = (*jni_on_load)(reinterpret_cast<JavaVM*>(this), NULL);
220 self->SetState(old_state);
221
222 UNIMPLEMENTED(WARNING) << "need to restore current class loader";
223 //self->classLoaderOverride = prevOverride;
224
225 if (version != JNI_VERSION_1_2 &&
226 version != JNI_VERSION_1_4 &&
227 version != JNI_VERSION_1_6) {
228 LOG(WARNING) << "JNI_OnLoad in \"" << path << "\" returned "
229 << "bad version: " << version;
230 // It's unwise to call dlclose() here, but we can mark it
231 // as bad and ensure that future load attempts will fail.
232 // We don't know how far JNI_OnLoad got, so there could
233 // be some partially-initialized stuff accessible through
234 // newly-registered native method calls. We could try to
235 // unregister them, but that doesn't seem worthwhile.
236 result = false;
237 } else {
238 if (verbose_jni) {
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700239 LOG(INFO) << "[Returned " << (result ? "successfully" : "failure")
240 << " from JNI_OnLoad in \"" << path << "\"]";
Elliott Hughes0af55432011-08-17 18:37:28 -0700241 }
242 }
243 }
244
245 library->jni_on_load_result = result ? kOkay : kFailed;
246 library->jni_on_load_tid = 0;
247
248 // Broadcast a wakeup to anybody sleeping on the condition variable.
249 UNIMPLEMENTED(ERROR) << "missing pthread_cond_broadcast";
Elliott Hughes18c07532011-08-18 15:50:51 -0700250 // MutexLock mu(library->jni_on_load_lock);
Elliott Hughes0af55432011-08-17 18:37:28 -0700251 // pthread_cond_broadcast(&library->jni_on_load_cond);
252 return result;
253 }
254}
255
Elliott Hughes22f40932011-08-12 13:06:37 -0700256// Entry/exit processing for all JNI calls.
257//
258// This performs the necessary thread state switching, lets us amortize the
259// cost of working out the current thread, and lets us check (and repair) apps
260// that are using a JNIEnv on the wrong thread.
261class ScopedJniThreadState {
262 public:
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700263 explicit ScopedJniThreadState(JNIEnv* env)
264 : env_(reinterpret_cast<JNIEnvExt*>(env)) {
Elliott Hughesb20a5542011-08-12 18:03:12 -0700265 self_ = ThreadForEnv(env);
Elliott Hughes22f40932011-08-12 13:06:37 -0700266 self_->SetState(Thread::kRunnable);
267 }
268
269 ~ScopedJniThreadState() {
270 self_->SetState(Thread::kNative);
271 }
272
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700273 JNIEnvExt* Env() {
274 return env_;
275 }
276
Elliott Hughesb20a5542011-08-12 18:03:12 -0700277 Thread* Self() {
Elliott Hughes22f40932011-08-12 13:06:37 -0700278 return self_;
279 }
280
Elliott Hughesb20a5542011-08-12 18:03:12 -0700281 private:
282 static Thread* ThreadForEnv(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700283 // TODO: need replacement for gDvmJni.
284 bool workAroundAppJniBugs = true;
285 Thread* env_self = reinterpret_cast<JNIEnvExt*>(env)->self;
286 Thread* self = workAroundAppJniBugs ? Thread::Current() : env_self;
287 if (self != env_self) {
Elliott Hughes330304d2011-08-12 14:28:05 -0700288 LOG(ERROR) << "JNI ERROR: JNIEnv for " << *env_self
289 << " used on " << *self;
290 // TODO: dump stack
Elliott Hughes22f40932011-08-12 13:06:37 -0700291 }
292 return self;
293 }
294
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700295 JNIEnvExt* env_;
Elliott Hughes22f40932011-08-12 13:06:37 -0700296 Thread* self_;
297 DISALLOW_COPY_AND_ASSIGN(ScopedJniThreadState);
298};
299
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700300/*
301 * Add a local reference for an object to the current stack frame. When
302 * the native function returns, the reference will be discarded.
303 *
304 * We need to allow the same reference to be added multiple times.
305 *
306 * This will be called on otherwise unreferenced objects. We cannot do
307 * GC allocations here, and it's best if we don't grab a mutex.
308 *
309 * Returns the local reference (currently just the same pointer that was
310 * passed in), or NULL on failure.
311 */
Elliott Hughes8a26c5c2011-08-15 18:35:43 -0700312template<typename T>
313T AddLocalReference(ScopedJniThreadState& ts, Object* obj) {
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700314 if (obj == NULL) {
315 return NULL;
316 }
317
318 IndirectReferenceTable& locals = ts.Env()->locals;
319
320 uint32_t cookie = IRT_FIRST_SEGMENT; // TODO
321 IndirectRef ref = locals.Add(cookie, obj);
322 if (ref == NULL) {
323 // TODO: just change Add's DCHECK to CHECK and lose this?
324 locals.Dump();
325 LOG(FATAL) << "Failed adding to JNI local reference table "
326 << "(has " << locals.Capacity() << " entries)";
327 // TODO: dvmDumpThread(dvmThreadSelf(), false);
328 }
329
330#if 0 // TODO: fix this to understand PushLocalFrame, so we can turn it on.
331 if (ts.Env()->check_jni) {
332 size_t entry_count = locals.Capacity();
333 if (entry_count > 16) {
334 std::string class_name(PrettyDescriptor(obj->GetClass()->GetDescriptor()));
335 LOG(WARNING) << "Warning: more than 16 JNI local references: "
336 << entry_count << " (most recent was a " << class_name << ")";
337 locals.Dump();
338 // TODO: dvmDumpThread(dvmThreadSelf(), false);
339 // dvmAbort();
340 }
341 }
342#endif
343
344 if (false /*gDvmJni.workAroundAppJniBugs*/) { // TODO
345 // Hand out direct pointers to support broken old apps.
346 return reinterpret_cast<T>(obj);
347 }
348
349 return reinterpret_cast<T>(ref);
350}
351
352template<typename T>
353T Decode(ScopedJniThreadState& ts, jobject obj) {
354 if (obj == NULL) {
355 return NULL;
356 }
357
358 IndirectRef ref = reinterpret_cast<IndirectRef>(obj);
359 IndirectRefKind kind = GetIndirectRefKind(ref);
360 Object* result;
361 switch (kind) {
362 case kLocal:
363 {
364 IndirectReferenceTable& locals = ts.Env()->locals;
365 result = locals.Get(ref);
366 break;
367 }
368 case kGlobal:
369 {
370 JavaVMExt* vm = Runtime::Current()->GetJavaVM();
371 IndirectReferenceTable& globals = vm->globals;
Elliott Hughes18c07532011-08-18 15:50:51 -0700372 MutexLock mu(vm->globals_lock);
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700373 result = globals.Get(ref);
374 break;
375 }
376 case kWeakGlobal:
377 {
378 JavaVMExt* vm = Runtime::Current()->GetJavaVM();
379 IndirectReferenceTable& weak_globals = vm->weak_globals;
Elliott Hughes18c07532011-08-18 15:50:51 -0700380 MutexLock mu(vm->weak_globals_lock);
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700381 result = weak_globals.Get(ref);
382 if (result == kClearedJniWeakGlobal) {
383 // This is a special case where it's okay to return NULL.
384 return NULL;
385 }
386 break;
387 }
388 case kInvalid:
389 default:
390 if (false /*gDvmJni.workAroundAppJniBugs*/) { // TODO
391 // Assume an invalid local reference is actually a direct pointer.
392 return reinterpret_cast<T>(obj);
393 }
394 LOG(FATAL) << "Invalid indirect reference " << obj;
395 return reinterpret_cast<T>(kInvalidIndirectRefObject);
396 }
397
398 if (result == NULL) {
399 LOG(FATAL) << "JNI ERROR (app bug): use of deleted " << kind << ": "
400 << obj;
401 }
402 return reinterpret_cast<T>(result);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -0700403}
404
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700405void CreateInvokeStub(Assembler* assembler, Method* method);
406
407bool EnsureInvokeStub(Method* method) {
408 if (method->GetInvokeStub() != NULL) {
409 return true;
410 }
411 // TODO: use signature to find a matching stub
412 // TODO: failed, acquire a lock on the stub table
413 Assembler assembler;
414 CreateInvokeStub(&assembler, method);
415 // TODO: store native_entry in the stub table
416 int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
417 size_t length = assembler.CodeSize();
418 void* addr = mmap(NULL, length, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
419 if (addr == MAP_FAILED) {
420 PLOG(FATAL) << "mmap failed";
421 }
422 MemoryRegion region(addr, length);
423 assembler.FinalizeInstructions(region);
424 method->SetInvokeStub(reinterpret_cast<Method::InvokeStub*>(region.pointer()));
425 return true;
426}
427
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700428byte* CreateArgArray(ScopedJniThreadState& ts, Method* method, va_list ap) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700429 size_t num_bytes = method->NumArgArrayBytes();
430 scoped_array<byte> arg_array(new byte[num_bytes]);
431 const StringPiece& shorty = method->GetShorty();
Ian Rogers4dd71f12011-08-16 14:16:02 -0700432 for (int i = 1, offset = 0; i < shorty.size(); ++i) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700433 switch (shorty[i]) {
434 case 'Z':
435 case 'B':
436 case 'C':
437 case 'S':
438 case 'I':
439 *reinterpret_cast<int32_t*>(&arg_array[offset]) = va_arg(ap, jint);
440 offset += 4;
441 break;
442 case 'F':
443 *reinterpret_cast<float*>(&arg_array[offset]) = va_arg(ap, jdouble);
444 offset += 4;
445 break;
446 case 'L': {
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700447 Object* obj = Decode<Object*>(ts, va_arg(ap, jobject));
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700448 *reinterpret_cast<Object**>(&arg_array[offset]) = obj;
449 offset += sizeof(Object*);
450 break;
451 }
452 case 'D':
453 *reinterpret_cast<double*>(&arg_array[offset]) = va_arg(ap, jdouble);
454 offset += 8;
455 break;
456 case 'J':
457 *reinterpret_cast<int64_t*>(&arg_array[offset]) = va_arg(ap, jlong);
458 offset += 8;
459 break;
460 }
461 }
462 return arg_array.release();
463}
464
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700465byte* CreateArgArray(ScopedJniThreadState& ts, Method* method, jvalue* args) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700466 size_t num_bytes = method->NumArgArrayBytes();
467 scoped_array<byte> arg_array(new byte[num_bytes]);
468 const StringPiece& shorty = method->GetShorty();
Ian Rogers4dd71f12011-08-16 14:16:02 -0700469 for (int i = 1, offset = 0; i < shorty.size(); ++i) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700470 switch (shorty[i]) {
471 case 'Z':
472 case 'B':
473 case 'C':
474 case 'S':
475 case 'I':
476 *reinterpret_cast<uint32_t*>(&arg_array[offset]) = args[i - 1].i;
477 offset += 4;
478 break;
479 case 'F':
480 *reinterpret_cast<float*>(&arg_array[offset]) = args[i - 1].f;
481 offset += 4;
482 break;
483 case 'L': {
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700484 Object* obj = Decode<Object*>(ts, args[i - 1].l);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700485 *reinterpret_cast<Object**>(&arg_array[offset]) = obj;
486 offset += sizeof(Object*);
487 break;
488 }
489 case 'D':
490 *reinterpret_cast<double*>(&arg_array[offset]) = args[i - 1].d;
491 offset += 8;
492 break;
493 case 'J':
494 *reinterpret_cast<uint64_t*>(&arg_array[offset]) = args[i - 1].j;
495 offset += 8;
496 break;
497 }
498 }
499 return arg_array.release();
500}
501
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700502JValue InvokeWithArgArray(ScopedJniThreadState& ts,
503 Object* obj, jmethodID method_id, byte* args) {
Elliott Hughesf2682d52011-08-15 16:37:04 -0700504 // TODO: DecodeReference
505 Method* method = reinterpret_cast<Method*>(method_id);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700506 // Call the invoke stub associated with the method
507 // Pass everything as arguments
508 const Method::InvokeStub* stub = method->GetInvokeStub();
509 CHECK(stub != NULL);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700510 JValue result;
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700511 (*stub)(method, obj, ts.Self(), args, &result);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700512 return result;
513}
514
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700515JValue InvokeWithJValues(ScopedJniThreadState& ts,
516 Object* obj, jmethodID method_id, jvalue* args) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700517 Method* method = reinterpret_cast<Method*>(method_id);
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700518 scoped_array<byte> arg_array(CreateArgArray(ts, method, args));
519 return InvokeWithArgArray(ts, obj, method_id, arg_array.get());
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700520}
521
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700522JValue InvokeWithVarArgs(ScopedJniThreadState& ts,
523 Object* obj, jmethodID method_id, va_list args) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700524 Method* method = reinterpret_cast<Method*>(method_id);
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700525 scoped_array<byte> arg_array(CreateArgArray(ts, method, args));
526 return InvokeWithArgArray(ts, obj, method_id, arg_array.get());
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700527}
528
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700529jint GetVersion(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700530 ScopedJniThreadState ts(env);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700531 return JNI_VERSION_1_6;
532}
533
Elliott Hughesb20a5542011-08-12 18:03:12 -0700534jclass DefineClass(JNIEnv* env, const char*, jobject, const jbyte*, jsize) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700535 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -0700536 LOG(WARNING) << "JNI DefineClass is not supported";
Carl Shapiroea4dca82011-08-01 13:45:38 -0700537 return NULL;
538}
539
Elliott Hughes6b436852011-08-12 10:16:44 -0700540// Section 12.3.2 of the JNI spec describes JNI class descriptors. They're
541// separated with slashes but aren't wrapped with "L;" like regular descriptors
542// (i.e. "a/b/C" rather than "La/b/C;"). Arrays of reference types are an
543// exception; there the "L;" must be present ("[La/b/C;"). Historically we've
544// supported names with dots too (such as "a.b.C").
545std::string NormalizeJniClassDescriptor(const char* name) {
546 std::string result;
547 // Add the missing "L;" if necessary.
548 if (name[0] == '[') {
549 result = name;
550 } else {
551 result += 'L';
552 result += name;
553 result += ';';
554 }
555 // Rewrite '.' as '/' for backwards compatibility.
Elliott Hughesa5b897e2011-08-16 11:33:06 -0700556 if (result.find('.') != std::string::npos) {
557 LOG(WARNING) << "Call to JNI FindClass with dots in name: "
558 << "\"" << name << "\"";
559 std::replace(result.begin(), result.end(), '.', '/');
Elliott Hughes6b436852011-08-12 10:16:44 -0700560 }
561 return result;
562}
563
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700564jclass FindClass(JNIEnv* env, const char* name) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700565 ScopedJniThreadState ts(env);
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700566 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Elliott Hughes6b436852011-08-12 10:16:44 -0700567 std::string descriptor(NormalizeJniClassDescriptor(name));
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700568 // TODO: need to get the appropriate ClassLoader.
Elliott Hughes6b436852011-08-12 10:16:44 -0700569 Class* c = class_linker->FindClass(descriptor, NULL);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -0700570 return AddLocalReference<jclass>(ts, c);
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700571}
572
573jmethodID FromReflectedMethod(JNIEnv* env, jobject method) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700574 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700575 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700576 return NULL;
577}
578
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700579jfieldID FromReflectedField(JNIEnv* env, jobject field) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700580 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700581 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700582 return NULL;
583}
584
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700585jobject ToReflectedMethod(JNIEnv* env, jclass cls,
586 jmethodID methodID, jboolean isStatic) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700587 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700588 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700589 return NULL;
590}
591
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700592jclass GetSuperclass(JNIEnv* env, jclass sub) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700593 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700594 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700595 return NULL;
596}
597
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700598jboolean IsAssignableFrom(JNIEnv* env, jclass sub, jclass sup) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700599 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700600 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700601 return JNI_FALSE;
602}
603
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700604jobject ToReflectedField(JNIEnv* env, jclass cls,
605 jfieldID fieldID, jboolean isStatic) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700606 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700607 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700608 return NULL;
609}
610
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700611jint Throw(JNIEnv* env, jthrowable obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700612 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700613 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700614 return 0;
615}
616
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700617jint ThrowNew(JNIEnv* env, jclass clazz, const char* msg) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700618 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700619 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700620 return 0;
621}
622
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700623jthrowable ExceptionOccurred(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700624 ScopedJniThreadState ts(env);
Ian Rogers4dd71f12011-08-16 14:16:02 -0700625 Object* exception = ts.Self()->GetException();
626 if (exception == NULL) {
627 return NULL;
628 } else {
629 // TODO: if adding a local reference failing causes the VM to abort
630 // then the following check will never occur.
631 jthrowable localException = AddLocalReference<jthrowable>(ts, exception);
632 if (localException == NULL) {
633 // We were unable to add a new local reference, and threw a new
634 // exception. We can't return "exception", because it's not a
635 // local reference. So we have to return NULL, indicating that
636 // there was no exception, even though it's pretty much raining
637 // exceptions in here.
638 LOG(WARNING) << "JNI WARNING: addLocal/exception combo";
639 }
640 return localException;
641 }
Carl Shapiroea4dca82011-08-01 13:45:38 -0700642}
643
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700644void ExceptionDescribe(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700645 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700646 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700647}
648
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700649void ExceptionClear(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700650 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -0700651 ts.Self()->ClearException();
Carl Shapiroea4dca82011-08-01 13:45:38 -0700652}
653
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700654void FatalError(JNIEnv* env, const char* msg) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700655 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -0700656 LOG(FATAL) << "JNI FatalError called: " << msg;
Carl Shapiroea4dca82011-08-01 13:45:38 -0700657}
658
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700659jint PushLocalFrame(JNIEnv* env, jint cap) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700660 ScopedJniThreadState ts(env);
Elliott Hughes0af55432011-08-17 18:37:28 -0700661 UNIMPLEMENTED(WARNING) << "ignoring PushLocalFrame(" << cap << ")";
662 return JNI_OK;
Carl Shapiroea4dca82011-08-01 13:45:38 -0700663}
664
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700665jobject PopLocalFrame(JNIEnv* env, jobject res) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700666 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700667 UNIMPLEMENTED(WARNING) << "ignoring PopLocalFrame " << res;
Elliott Hughes0af55432011-08-17 18:37:28 -0700668 return res;
Carl Shapiroea4dca82011-08-01 13:45:38 -0700669}
670
Elliott Hughes18c07532011-08-18 15:50:51 -0700671jobject NewGlobalRef(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700672 ScopedJniThreadState ts(env);
Elliott Hughes18c07532011-08-18 15:50:51 -0700673 if (obj == NULL) {
674 return NULL;
675 }
676
677 JavaVMExt* vm = Runtime::Current()->GetJavaVM();
678 IndirectReferenceTable& globals = vm->globals;
679 MutexLock mu(vm->globals_lock);
680 IndirectRef ref = globals.Add(IRT_FIRST_SEGMENT, Decode<Object*>(ts, obj));
681 return reinterpret_cast<jobject>(ref);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700682}
683
Elliott Hughes18c07532011-08-18 15:50:51 -0700684void DeleteGlobalRef(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700685 ScopedJniThreadState ts(env);
Elliott Hughes18c07532011-08-18 15:50:51 -0700686 if (obj == NULL) {
687 return;
688 }
689
690 JavaVMExt* vm = Runtime::Current()->GetJavaVM();
691 IndirectReferenceTable& globals = vm->globals;
692 MutexLock mu(vm->globals_lock);
693
694 if (!globals.Remove(IRT_FIRST_SEGMENT, obj)) {
695 LOG(WARNING) << "JNI WARNING: DeleteGlobalRef(" << obj << ") "
696 << "failed to find entry";
697 }
698}
699
700jweak NewWeakGlobalRef(JNIEnv* env, jobject obj) {
701 ScopedJniThreadState ts(env);
702 if (obj == NULL) {
703 return NULL;
704 }
705
706 JavaVMExt* vm = Runtime::Current()->GetJavaVM();
707 IndirectReferenceTable& weak_globals = vm->weak_globals;
708 MutexLock mu(vm->weak_globals_lock);
709 IndirectRef ref = weak_globals.Add(IRT_FIRST_SEGMENT, Decode<Object*>(ts, obj));
710 return reinterpret_cast<jobject>(ref);
711}
712
713void DeleteWeakGlobalRef(JNIEnv* env, jweak obj) {
714 ScopedJniThreadState ts(env);
715 if (obj == NULL) {
716 return;
717 }
718
719 JavaVMExt* vm = Runtime::Current()->GetJavaVM();
720 IndirectReferenceTable& weak_globals = vm->weak_globals;
721 MutexLock mu(vm->weak_globals_lock);
722
723 if (!weak_globals.Remove(IRT_FIRST_SEGMENT, obj)) {
724 LOG(WARNING) << "JNI WARNING: DeleteWeakGlobalRef(" << obj << ") "
725 << "failed to find entry";
726 }
727}
728
729jobject NewLocalRef(JNIEnv* env, jobject obj) {
730 ScopedJniThreadState ts(env);
731 if (obj == NULL) {
732 return NULL;
733 }
734
735 IndirectReferenceTable& locals = ts.Env()->locals;
736
737 uint32_t cookie = IRT_FIRST_SEGMENT; // TODO
738 IndirectRef ref = locals.Add(cookie, Decode<Object*>(ts, obj));
739 return reinterpret_cast<jobject>(ref);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700740}
741
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700742void DeleteLocalRef(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700743 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700744 if (obj == NULL) {
745 return;
746 }
747
748 IndirectReferenceTable& locals = ts.Env()->locals;
749
750 uint32_t cookie = IRT_FIRST_SEGMENT; // TODO
751 if (!locals.Remove(cookie, obj)) {
752 // Attempting to delete a local reference that is not in the
753 // topmost local reference frame is a no-op. DeleteLocalRef returns
754 // void and doesn't throw any exceptions, but we should probably
755 // complain about it so the user will notice that things aren't
756 // going quite the way they expect.
757 LOG(WARNING) << "JNI WARNING: DeleteLocalRef(" << obj << ") "
758 << "failed to find entry";
759 }
Carl Shapiroea4dca82011-08-01 13:45:38 -0700760}
761
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700762jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700763 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700764 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700765 return JNI_FALSE;
766}
767
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700768jint EnsureLocalCapacity(JNIEnv* env, jint) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700769 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700770 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700771 return 0;
772}
773
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700774jobject AllocObject(JNIEnv* env, jclass clazz) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700775 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700776 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700777 return NULL;
778}
779
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700780jobject NewObject(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700781 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700782 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700783 return NULL;
784}
785
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700786jobject NewObjectV(JNIEnv* env,
787 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700788 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700789 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700790 return NULL;
791}
792
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700793jobject NewObjectA(JNIEnv* env,
794 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700795 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700796 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700797 return NULL;
798}
799
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700800jclass GetObjectClass(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700801 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700802 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700803 return NULL;
804}
805
Ian Rogers4dd71f12011-08-16 14:16:02 -0700806jboolean IsInstanceOf(JNIEnv* env, jobject jobj, jclass clazz) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700807 ScopedJniThreadState ts(env);
Ian Rogers4dd71f12011-08-16 14:16:02 -0700808 CHECK_NE(static_cast<jclass>(NULL), clazz);
809 if (jobj == NULL) {
810 // NB. JNI is different from regular Java instanceof in this respect
811 return JNI_TRUE;
812 } else {
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700813 Object* obj = Decode<Object*>(ts, jobj);
814 Class* klass = Decode<Class*>(ts, clazz);
Ian Rogers4dd71f12011-08-16 14:16:02 -0700815 return Object::InstanceOf(obj, klass) ? JNI_TRUE : JNI_FALSE;
816 }
Carl Shapiroea4dca82011-08-01 13:45:38 -0700817}
818
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700819jmethodID GetMethodID(JNIEnv* env,
820 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700821 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -0700822 Class* klass = Decode<Class*>(ts, clazz);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700823 if (!klass->IsInitialized()) {
824 // TODO: initialize the class
825 }
826 Method* method = klass->FindVirtualMethod(name, sig);
827 if (method == NULL) {
828 // No virtual method matching the signature. Search declared
829 // private methods and constructors.
830 method = klass->FindDeclaredDirectMethod(name, sig);
831 }
Ian Rogers4dd71f12011-08-16 14:16:02 -0700832 if (method == NULL) {
833 Thread* self = Thread::Current();
834 std::string class_name = klass->GetDescriptor().ToString();
835 // TODO: pretty print method names through a single routine
836 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
837 "no method \"%s.%s%s\"",
838 class_name.c_str(), name, sig);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700839 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -0700840 } else if (method->IsStatic()) {
841 Thread* self = Thread::Current();
842 std::string class_name = klass->GetDescriptor().ToString();
843 // TODO: pretty print method names through a single routine
844 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
845 "method \"%s.%s%s\" is static",
846 class_name.c_str(), name, sig);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700847 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -0700848 } else {
849 // TODO: create a JNI weak global reference for method
850 bool success = EnsureInvokeStub(method);
851 if (!success) {
852 // TODO: throw OutOfMemoryException
853 return NULL;
854 }
855 return reinterpret_cast<jmethodID>(method);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700856 }
Carl Shapiroea4dca82011-08-01 13:45:38 -0700857}
858
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700859jobject CallObjectMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700860 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700861 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700862 return NULL;
863}
864
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700865jobject CallObjectMethodV(JNIEnv* env,
866 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700867 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700868 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700869 return NULL;
870}
871
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700872jobject CallObjectMethodA(JNIEnv* env,
873 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700874 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700875 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700876 return NULL;
877}
878
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700879jboolean CallBooleanMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700880 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700881 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700882 return JNI_FALSE;
883}
884
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700885jboolean CallBooleanMethodV(JNIEnv* env,
886 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700887 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700888 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700889 return JNI_FALSE;
890}
891
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700892jboolean CallBooleanMethodA(JNIEnv* env,
893 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700894 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700895 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700896 return JNI_FALSE;
897}
898
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700899jbyte CallByteMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700900 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700901 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700902 return 0;
903}
904
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700905jbyte CallByteMethodV(JNIEnv* env,
906 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700907 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700908 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700909 return 0;
910}
911
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700912jbyte CallByteMethodA(JNIEnv* env,
913 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700914 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700915 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700916 return 0;
917}
918
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700919jchar CallCharMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700920 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700921 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700922 return 0;
923}
924
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700925jchar CallCharMethodV(JNIEnv* env,
926 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700927 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700928 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700929 return 0;
930}
931
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700932jchar CallCharMethodA(JNIEnv* env,
933 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700934 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700935 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700936 return 0;
937}
938
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700939jshort CallShortMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700940 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700941 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700942 return 0;
943}
944
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700945jshort CallShortMethodV(JNIEnv* env,
946 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700947 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700948 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700949 return 0;
950}
951
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700952jshort CallShortMethodA(JNIEnv* env,
953 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700954 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700955 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700956 return 0;
957}
958
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700959jint CallIntMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700960 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700961 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700962 return 0;
963}
964
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700965jint CallIntMethodV(JNIEnv* env,
966 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700967 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700968 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700969 return 0;
970}
971
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700972jint CallIntMethodA(JNIEnv* env,
973 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700974 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700975 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700976 return 0;
977}
978
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700979jlong CallLongMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700980 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700981 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700982 return 0;
983}
984
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700985jlong CallLongMethodV(JNIEnv* env,
986 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700987 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700988 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700989 return 0;
990}
991
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700992jlong CallLongMethodA(JNIEnv* env,
993 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700994 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700995 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700996 return 0;
997}
998
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700999jfloat CallFloatMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001000 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001001 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001002 return 0;
1003}
1004
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001005jfloat CallFloatMethodV(JNIEnv* env,
1006 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001007 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001008 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001009 return 0;
1010}
1011
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001012jfloat CallFloatMethodA(JNIEnv* env,
1013 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001014 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001015 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001016 return 0;
1017}
1018
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001019jdouble CallDoubleMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001020 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001021 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001022 return 0;
1023}
1024
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001025jdouble CallDoubleMethodV(JNIEnv* env,
1026 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001027 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001028 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001029 return 0;
1030}
1031
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001032jdouble CallDoubleMethodA(JNIEnv* env,
1033 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001034 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001035 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001036 return 0;
1037}
1038
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001039void CallVoidMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001040 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001041 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001042}
1043
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001044void CallVoidMethodV(JNIEnv* env, jobject obj,
1045 jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001046 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001047 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001048}
1049
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001050void CallVoidMethodA(JNIEnv* env, jobject obj,
1051 jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001052 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001053 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001054}
1055
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001056jobject CallNonvirtualObjectMethod(JNIEnv* env,
1057 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001058 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001059 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001060 return NULL;
1061}
1062
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001063jobject CallNonvirtualObjectMethodV(JNIEnv* env,
1064 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001065 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001066 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001067 return NULL;
1068}
1069
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001070jobject CallNonvirtualObjectMethodA(JNIEnv* env,
1071 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001072 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001073 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001074 return NULL;
1075}
1076
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001077jboolean CallNonvirtualBooleanMethod(JNIEnv* env,
1078 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001079 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001080 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001081 return JNI_FALSE;
1082}
1083
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001084jboolean CallNonvirtualBooleanMethodV(JNIEnv* env,
1085 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001086 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001087 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001088 return JNI_FALSE;
1089}
1090
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001091jboolean CallNonvirtualBooleanMethodA(JNIEnv* env,
1092 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001093 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001094 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001095 return JNI_FALSE;
1096}
1097
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001098jbyte CallNonvirtualByteMethod(JNIEnv* env,
1099 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001100 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001101 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001102 return 0;
1103}
1104
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001105jbyte CallNonvirtualByteMethodV(JNIEnv* env,
1106 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001107 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001108 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001109 return 0;
1110}
1111
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001112jbyte CallNonvirtualByteMethodA(JNIEnv* env,
1113 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001114 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001115 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001116 return 0;
1117}
1118
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001119jchar CallNonvirtualCharMethod(JNIEnv* env,
1120 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001121 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001122 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001123 return 0;
1124}
1125
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001126jchar CallNonvirtualCharMethodV(JNIEnv* env,
1127 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001128 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001129 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001130 return 0;
1131}
1132
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001133jchar CallNonvirtualCharMethodA(JNIEnv* env,
1134 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001135 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001136 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001137 return 0;
1138}
1139
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001140jshort CallNonvirtualShortMethod(JNIEnv* env,
1141 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001142 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001143 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001144 return 0;
1145}
1146
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001147jshort CallNonvirtualShortMethodV(JNIEnv* env,
1148 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001149 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001150 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001151 return 0;
1152}
1153
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001154jshort CallNonvirtualShortMethodA(JNIEnv* env,
1155 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001156 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001157 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001158 return 0;
1159}
1160
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001161jint CallNonvirtualIntMethod(JNIEnv* env,
1162 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001163 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001164 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001165 return 0;
1166}
1167
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001168jint CallNonvirtualIntMethodV(JNIEnv* env,
1169 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001170 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001171 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001172 return 0;
1173}
1174
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001175jint CallNonvirtualIntMethodA(JNIEnv* env,
1176 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001177 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001178 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001179 return 0;
1180}
1181
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001182jlong CallNonvirtualLongMethod(JNIEnv* env,
1183 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001184 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001185 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001186 return 0;
1187}
1188
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001189jlong CallNonvirtualLongMethodV(JNIEnv* env,
1190 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001191 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001192 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001193 return 0;
1194}
1195
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001196jlong CallNonvirtualLongMethodA(JNIEnv* env,
1197 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001198 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001199 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001200 return 0;
1201}
1202
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001203jfloat CallNonvirtualFloatMethod(JNIEnv* env,
1204 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001205 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001206 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001207 return 0;
1208}
1209
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001210jfloat CallNonvirtualFloatMethodV(JNIEnv* env,
1211 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001212 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001213 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001214 return 0;
1215}
1216
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001217jfloat CallNonvirtualFloatMethodA(JNIEnv* env,
1218 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001219 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001220 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001221 return 0;
1222}
1223
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001224jdouble CallNonvirtualDoubleMethod(JNIEnv* env,
1225 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001226 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001227 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001228 return 0;
1229}
1230
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001231jdouble CallNonvirtualDoubleMethodV(JNIEnv* env,
1232 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001233 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001234 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001235 return 0;
1236}
1237
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001238jdouble CallNonvirtualDoubleMethodA(JNIEnv* env,
1239 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001240 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001241 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001242 return 0;
1243}
1244
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001245void CallNonvirtualVoidMethod(JNIEnv* env,
1246 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001247 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001248 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001249}
1250
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001251void CallNonvirtualVoidMethodV(JNIEnv* env,
1252 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001253 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001254 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001255}
1256
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001257void CallNonvirtualVoidMethodA(JNIEnv* env,
1258 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001259 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001260 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001261}
1262
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001263jfieldID GetFieldID(JNIEnv* env,
1264 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001265 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001266 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001267 return NULL;
1268}
1269
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001270jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001271 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001272 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001273 return NULL;
1274}
1275
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001276jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001277 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001278 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001279 return JNI_FALSE;
1280}
1281
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001282jbyte GetByteField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001283 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001284 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001285 return 0;
1286}
1287
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001288jchar GetCharField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001289 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001290 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001291 return 0;
1292}
1293
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001294jshort GetShortField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001295 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001296 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001297 return 0;
1298}
1299
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001300jint GetIntField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001301 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001302 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001303 return 0;
1304}
1305
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001306jlong GetLongField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001307 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001308 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001309 return 0;
1310}
1311
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001312jfloat GetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001313 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001314 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001315 return 0;
1316}
1317
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001318jdouble GetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001319 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001320 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001321 return 0;
1322}
1323
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001324void SetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID, jobject val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001325 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001326 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001327}
1328
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001329void SetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID, jboolean val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001330 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001331 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001332}
1333
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001334void SetByteField(JNIEnv* env, jobject obj, jfieldID fieldID, jbyte val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001335 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001336 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001337}
1338
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001339void SetCharField(JNIEnv* env, jobject obj, jfieldID fieldID, jchar val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001340 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001341 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001342}
1343
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001344void SetShortField(JNIEnv* env, jobject obj, jfieldID fieldID, jshort val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001345 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001346 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001347}
1348
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001349void SetIntField(JNIEnv* env, jobject obj, jfieldID fieldID, jint val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001350 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001351 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001352}
1353
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001354void SetLongField(JNIEnv* env, jobject obj, jfieldID fieldID, jlong val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001355 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001356 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001357}
1358
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001359void SetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID, jfloat val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001360 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001361 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001362}
1363
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001364void SetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID, jdouble val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001365 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001366 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001367}
1368
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001369jmethodID GetStaticMethodID(JNIEnv* env,
1370 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001371 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001372 Class* klass = Decode<Class*>(ts, clazz);
Carl Shapiro83ab4f32011-08-15 20:21:39 -07001373 if (!klass->IsInitialized()) {
1374 // TODO: initialize the class
1375 }
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001376 Method* method = klass->FindDirectMethod(name, sig);
Ian Rogers4dd71f12011-08-16 14:16:02 -07001377 if (method == NULL) {
1378 Thread* self = Thread::Current();
1379 std::string class_name = klass->GetDescriptor().ToString();
1380 // TODO: pretty print method names through a single routine
1381 // TODO: may want to FindVirtualMethod to give more informative error
1382 // message here
1383 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
1384 "no method \"%s.%s%s\"",
1385 class_name.c_str(), name, sig);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001386 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -07001387 } else if (!method->IsStatic()) {
1388 Thread* self = Thread::Current();
1389 std::string class_name = klass->GetDescriptor().ToString();
1390 // TODO: pretty print method names through a single routine
1391 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
1392 "method \"%s.%s%s\" is not static",
1393 class_name.c_str(), name, sig);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001394 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -07001395 } else {
1396 // TODO: create a JNI weak global reference for method
1397 bool success = EnsureInvokeStub(method);
1398 if (!success) {
1399 // TODO: throw OutOfMemoryException
1400 return NULL;
1401 }
1402 return reinterpret_cast<jmethodID>(method);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001403 }
Carl Shapiroea4dca82011-08-01 13:45:38 -07001404}
1405
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001406jobject CallStaticObjectMethod(JNIEnv* env,
1407 jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001408 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001409 va_list ap;
1410 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001411 JValue result = InvokeWithVarArgs(ts, NULL, methodID, ap);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001412 return AddLocalReference<jobject>(ts, result.l);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001413}
1414
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001415jobject CallStaticObjectMethodV(JNIEnv* env,
1416 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001417 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001418 JValue result = InvokeWithVarArgs(ts, NULL, methodID, args);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001419 return AddLocalReference<jobject>(ts, result.l);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001420}
1421
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001422jobject CallStaticObjectMethodA(JNIEnv* env,
1423 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001424 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001425 JValue result = InvokeWithJValues(ts, NULL, methodID, args);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001426 return AddLocalReference<jobject>(ts, result.l);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001427}
1428
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001429jboolean CallStaticBooleanMethod(JNIEnv* env,
1430 jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001431 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001432 va_list ap;
1433 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001434 return InvokeWithVarArgs(ts, NULL, methodID, ap).z;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001435}
1436
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001437jboolean CallStaticBooleanMethodV(JNIEnv* env,
1438 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001439 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001440 return InvokeWithVarArgs(ts, NULL, methodID, args).z;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001441}
1442
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001443jboolean CallStaticBooleanMethodA(JNIEnv* env,
1444 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001445 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001446 return InvokeWithJValues(ts, NULL, methodID, args).z;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001447}
1448
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001449jbyte CallStaticByteMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001450 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001451 va_list ap;
1452 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001453 return InvokeWithVarArgs(ts, NULL, methodID, ap).b;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001454}
1455
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001456jbyte CallStaticByteMethodV(JNIEnv* env,
1457 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001458 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001459 return InvokeWithVarArgs(ts, NULL, methodID, args).b;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001460}
1461
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001462jbyte CallStaticByteMethodA(JNIEnv* env,
1463 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001464 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001465 return InvokeWithJValues(ts, NULL, methodID, args).b;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001466}
1467
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001468jchar CallStaticCharMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001469 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001470 va_list ap;
1471 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001472 return InvokeWithVarArgs(ts, NULL, methodID, ap).c;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001473}
1474
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001475jchar CallStaticCharMethodV(JNIEnv* env,
1476 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001477 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001478 return InvokeWithVarArgs(ts, NULL, methodID, args).c;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001479}
1480
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001481jchar CallStaticCharMethodA(JNIEnv* env,
1482 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001483 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001484 return InvokeWithJValues(ts, NULL, methodID, args).c;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001485}
1486
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001487jshort CallStaticShortMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001488 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001489 va_list ap;
1490 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001491 return InvokeWithVarArgs(ts, NULL, methodID, ap).s;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001492}
1493
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001494jshort CallStaticShortMethodV(JNIEnv* env,
1495 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001496 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001497 return InvokeWithVarArgs(ts, NULL, methodID, args).s;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001498}
1499
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001500jshort CallStaticShortMethodA(JNIEnv* env,
1501 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001502 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001503 return InvokeWithJValues(ts, NULL, methodID, args).s;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001504}
1505
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001506jint CallStaticIntMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001507 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001508 va_list ap;
1509 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001510 return InvokeWithVarArgs(ts, NULL, methodID, ap).i;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001511}
1512
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001513jint CallStaticIntMethodV(JNIEnv* env,
1514 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001515 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001516 return InvokeWithVarArgs(ts, NULL, methodID, args).i;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001517}
1518
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001519jint CallStaticIntMethodA(JNIEnv* env,
1520 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001521 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001522 return InvokeWithJValues(ts, NULL, methodID, args).i;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001523}
1524
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001525jlong CallStaticLongMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001526 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001527 va_list ap;
1528 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001529 return InvokeWithVarArgs(ts, NULL, methodID, ap).j;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001530}
1531
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001532jlong CallStaticLongMethodV(JNIEnv* env,
1533 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001534 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001535 return InvokeWithVarArgs(ts, NULL, methodID, args).j;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001536}
1537
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001538jlong CallStaticLongMethodA(JNIEnv* env,
1539 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001540 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001541 return InvokeWithJValues(ts, NULL, methodID, args).j;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001542}
1543
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001544jfloat CallStaticFloatMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001545 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001546 va_list ap;
1547 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001548 return InvokeWithVarArgs(ts, NULL, methodID, ap).f;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001549}
1550
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001551jfloat CallStaticFloatMethodV(JNIEnv* env,
1552 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001553 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001554 return InvokeWithVarArgs(ts, NULL, methodID, args).f;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001555}
1556
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001557jfloat CallStaticFloatMethodA(JNIEnv* env,
1558 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001559 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001560 return InvokeWithJValues(ts, NULL, methodID, args).f;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001561}
1562
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001563jdouble CallStaticDoubleMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001564 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001565 va_list ap;
1566 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001567 return InvokeWithVarArgs(ts, NULL, methodID, ap).d;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001568}
1569
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001570jdouble CallStaticDoubleMethodV(JNIEnv* env,
1571 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001572 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001573 return InvokeWithVarArgs(ts, NULL, methodID, args).d;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001574}
1575
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001576jdouble CallStaticDoubleMethodA(JNIEnv* env,
1577 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001578 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001579 return InvokeWithJValues(ts, NULL, methodID, args).d;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001580}
1581
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001582void CallStaticVoidMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001583 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001584 va_list ap;
1585 va_start(ap, methodID);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001586 InvokeWithVarArgs(ts, NULL, methodID, ap);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001587}
1588
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001589void CallStaticVoidMethodV(JNIEnv* env,
1590 jclass cls, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001591 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001592 InvokeWithVarArgs(ts, NULL, methodID, args);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001593}
1594
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001595void CallStaticVoidMethodA(JNIEnv* env,
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001596 jclass cls, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001597 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001598 InvokeWithJValues(ts, NULL, methodID, args);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001599}
1600
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001601jfieldID GetStaticFieldID(JNIEnv* env,
1602 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001603 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001604 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001605 return 0;
1606}
1607
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001608jobject GetStaticObjectField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001609 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001610 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001611 return NULL;
1612}
1613
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001614jboolean GetStaticBooleanField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001615 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001616 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001617 return JNI_FALSE;
1618}
1619
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001620jbyte GetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001621 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001622 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001623 return 0;
1624}
1625
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001626jchar GetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001627 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001628 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001629 return 0;
1630}
1631
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001632jshort GetStaticShortField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001633 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001634 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001635 return 0;
1636}
1637
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001638jint GetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001639 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001640 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001641 return 0;
1642}
1643
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001644jlong GetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001645 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001646 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001647 return 0;
1648}
1649
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001650jfloat GetStaticFloatField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001651 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001652 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001653 return 0;
1654}
1655
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001656jdouble GetStaticDoubleField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001657 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001658 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001659 return 0;
1660}
1661
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001662void SetStaticObjectField(JNIEnv* env,
1663 jclass clazz, jfieldID fieldID, jobject value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001664 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001665 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001666}
1667
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001668void SetStaticBooleanField(JNIEnv* env,
1669 jclass clazz, jfieldID fieldID, jboolean value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001670 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001671 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001672}
1673
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001674void SetStaticByteField(JNIEnv* env,
1675 jclass clazz, jfieldID fieldID, jbyte value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001676 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001677 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001678}
1679
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001680void SetStaticCharField(JNIEnv* env,
1681 jclass clazz, jfieldID fieldID, jchar value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001682 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001683 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001684}
1685
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001686void SetStaticShortField(JNIEnv* env,
1687 jclass clazz, jfieldID fieldID, jshort value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001688 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001689 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001690}
1691
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001692void SetStaticIntField(JNIEnv* env,
1693 jclass clazz, jfieldID fieldID, jint value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001694 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001695 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001696}
1697
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001698void SetStaticLongField(JNIEnv* env,
1699 jclass clazz, jfieldID fieldID, jlong value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001700 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001701 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001702}
1703
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001704void SetStaticFloatField(JNIEnv* env,
1705 jclass clazz, jfieldID fieldID, jfloat value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001706 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001707 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001708}
1709
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001710void SetStaticDoubleField(JNIEnv* env,
1711 jclass clazz, jfieldID fieldID, jdouble value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001712 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001713 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001714}
1715
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001716jstring NewString(JNIEnv* env, const jchar* unicode, jsize len) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001717 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001718 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001719 return NULL;
1720}
1721
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001722jsize GetStringLength(JNIEnv* env, jstring str) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001723 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001724 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001725 return 0;
1726}
1727
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001728const jchar* GetStringChars(JNIEnv* env, jstring str, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001729 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001730 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001731 return NULL;
1732}
1733
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001734void ReleaseStringChars(JNIEnv* env, jstring str, const jchar* chars) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001735 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001736 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001737}
1738
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001739jstring NewStringUTF(JNIEnv* env, const char* utf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001740 ScopedJniThreadState ts(env);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001741 if (utf == NULL) {
1742 return NULL;
1743 }
1744 size_t char_count = String::ModifiedUtf8Len(utf);
1745 String* result = String::AllocFromModifiedUtf8(char_count, utf);
1746 return AddLocalReference<jstring>(ts, result);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001747}
1748
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001749jsize GetStringUTFLength(JNIEnv* env, jstring str) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001750 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001751 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001752 return 0;
1753}
1754
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001755const char* GetStringUTFChars(JNIEnv* env, jstring str, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001756 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001757 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001758 return NULL;
1759}
1760
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001761void ReleaseStringUTFChars(JNIEnv* env, jstring str, const char* chars) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001762 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001763 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001764}
1765
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001766jsize GetArrayLength(JNIEnv* env, jarray array) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001767 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001768 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001769 return 0;
1770}
1771
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001772jobject GetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001773 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001774 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001775 return NULL;
1776}
1777
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001778void SetObjectArrayElement(JNIEnv* env,
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001779 jobjectArray java_array, jsize index, jobject java_value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001780 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001781 ObjectArray<Object>* array = Decode<ObjectArray<Object>*>(ts, java_array);
1782 Object* value = Decode<Object*>(ts, java_value);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001783 array->Set(index, value);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001784}
1785
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001786template<typename JniT, typename ArtT>
1787JniT NewPrimitiveArray(ScopedJniThreadState& ts, jsize length) {
1788 CHECK_GE(length, 0); // TODO: ReportJniError
1789 ArtT* result = ArtT::Alloc(length);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001790 return AddLocalReference<JniT>(ts, result);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001791}
1792
Elliott Hughesf2682d52011-08-15 16:37:04 -07001793jbooleanArray NewBooleanArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001794 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001795 return NewPrimitiveArray<jbooleanArray, BooleanArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001796}
1797
Elliott Hughesf2682d52011-08-15 16:37:04 -07001798jbyteArray NewByteArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001799 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001800 return NewPrimitiveArray<jbyteArray, ByteArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001801}
1802
Elliott Hughesf2682d52011-08-15 16:37:04 -07001803jcharArray NewCharArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001804 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001805 return NewPrimitiveArray<jcharArray, CharArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001806}
1807
Elliott Hughesf2682d52011-08-15 16:37:04 -07001808jdoubleArray NewDoubleArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001809 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001810 return NewPrimitiveArray<jdoubleArray, DoubleArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001811}
1812
Elliott Hughesf2682d52011-08-15 16:37:04 -07001813jfloatArray NewFloatArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001814 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001815 return NewPrimitiveArray<jfloatArray, FloatArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001816}
1817
Elliott Hughesf2682d52011-08-15 16:37:04 -07001818jintArray NewIntArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001819 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001820 return NewPrimitiveArray<jintArray, IntArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001821}
1822
Elliott Hughesf2682d52011-08-15 16:37:04 -07001823jlongArray NewLongArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001824 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001825 return NewPrimitiveArray<jlongArray, LongArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001826}
1827
Elliott Hughesf2682d52011-08-15 16:37:04 -07001828jobjectArray NewObjectArray(JNIEnv* env, jsize length, jclass element_jclass, jobject initial_element) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001829 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001830 CHECK_GE(length, 0); // TODO: ReportJniError
1831
1832 // Compute the array class corresponding to the given element class.
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001833 Class* element_class = Decode<Class*>(ts, element_jclass);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001834 std::string descriptor;
1835 descriptor += "[";
1836 descriptor += element_class->GetDescriptor().ToString();
1837
1838 // Find the class.
1839 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
1840 // TODO: need to get the appropriate ClassLoader.
1841 Class* array_class = class_linker->FindClass(descriptor, NULL);
1842 if (array_class == NULL) {
1843 return NULL;
1844 }
1845
1846 ObjectArray<Object>* result = ObjectArray<Object>::Alloc(array_class, length);
1847 CHECK(initial_element == NULL); // TODO: support initial_element
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001848 return AddLocalReference<jobjectArray>(ts, result);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001849}
1850
1851jshortArray NewShortArray(JNIEnv* env, jsize length) {
1852 ScopedJniThreadState ts(env);
1853 return NewPrimitiveArray<jshortArray, ShortArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001854}
1855
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001856jboolean* GetBooleanArrayElements(JNIEnv* env,
1857 jbooleanArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001858 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001859 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001860 return NULL;
1861}
1862
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001863jbyte* GetByteArrayElements(JNIEnv* env, jbyteArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001864 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001865 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001866 return NULL;
1867}
1868
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001869jchar* GetCharArrayElements(JNIEnv* env, jcharArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001870 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001871 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001872 return NULL;
1873}
1874
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001875jshort* GetShortArrayElements(JNIEnv* env,
1876 jshortArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001877 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001878 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001879 return NULL;
1880}
1881
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001882jint* GetIntArrayElements(JNIEnv* env, jintArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001883 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001884 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001885 return NULL;
1886}
1887
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001888jlong* GetLongArrayElements(JNIEnv* env, jlongArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001889 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001890 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001891 return NULL;
1892}
1893
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001894jfloat* GetFloatArrayElements(JNIEnv* env,
1895 jfloatArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001896 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001897 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001898 return NULL;
1899}
1900
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001901jdouble* GetDoubleArrayElements(JNIEnv* env,
1902 jdoubleArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001903 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001904 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001905 return NULL;
1906}
1907
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001908void ReleaseBooleanArrayElements(JNIEnv* env,
1909 jbooleanArray array, jboolean* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001910 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001911 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001912}
1913
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001914void ReleaseByteArrayElements(JNIEnv* env,
1915 jbyteArray array, jbyte* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001916 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001917 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001918}
1919
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001920void ReleaseCharArrayElements(JNIEnv* env,
1921 jcharArray array, jchar* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001922 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001923 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001924}
1925
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001926void ReleaseShortArrayElements(JNIEnv* env,
1927 jshortArray array, jshort* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001928 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001929 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001930}
1931
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001932void ReleaseIntArrayElements(JNIEnv* env,
1933 jintArray array, jint* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001934 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001935 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001936}
1937
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001938void ReleaseLongArrayElements(JNIEnv* env,
1939 jlongArray array, jlong* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001940 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001941 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001942}
1943
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001944void ReleaseFloatArrayElements(JNIEnv* env,
1945 jfloatArray array, jfloat* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001946 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001947 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001948}
1949
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001950void ReleaseDoubleArrayElements(JNIEnv* env,
1951 jdoubleArray array, jdouble* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001952 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001953 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001954}
1955
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001956void GetBooleanArrayRegion(JNIEnv* env,
1957 jbooleanArray array, jsize start, jsize l, jboolean* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001958 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001959 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001960}
1961
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001962void GetByteArrayRegion(JNIEnv* env,
1963 jbyteArray array, jsize start, jsize len, jbyte* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001964 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001965 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001966}
1967
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001968void GetCharArrayRegion(JNIEnv* env,
1969 jcharArray array, jsize start, jsize len, jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001970 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001971 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001972}
1973
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001974void GetShortArrayRegion(JNIEnv* env,
1975 jshortArray array, jsize start, jsize len, jshort* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001976 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001977 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001978}
1979
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001980void GetIntArrayRegion(JNIEnv* env,
1981 jintArray array, jsize start, jsize len, jint* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001982 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001983 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001984}
1985
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001986void GetLongArrayRegion(JNIEnv* env,
1987 jlongArray array, jsize start, jsize len, jlong* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001988 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001989 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001990}
1991
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001992void GetFloatArrayRegion(JNIEnv* env,
1993 jfloatArray array, jsize start, jsize len, jfloat* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001994 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001995 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001996}
1997
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001998void GetDoubleArrayRegion(JNIEnv* env,
1999 jdoubleArray array, jsize start, jsize len, jdouble* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002000 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002001 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002002}
2003
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002004void SetBooleanArrayRegion(JNIEnv* env,
2005 jbooleanArray array, jsize start, jsize l, const jboolean* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002006 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002007 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002008}
2009
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002010void SetByteArrayRegion(JNIEnv* env,
2011 jbyteArray array, jsize start, jsize len, const jbyte* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002012 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002013 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002014}
2015
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002016void SetCharArrayRegion(JNIEnv* env,
2017 jcharArray array, jsize start, jsize len, const jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002018 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002019 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002020}
2021
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002022void SetShortArrayRegion(JNIEnv* env,
2023 jshortArray array, jsize start, jsize len, const jshort* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002024 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002025 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002026}
2027
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002028void SetIntArrayRegion(JNIEnv* env,
2029 jintArray array, jsize start, jsize len, const jint* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002030 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002031 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002032}
2033
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002034void SetLongArrayRegion(JNIEnv* env,
2035 jlongArray array, jsize start, jsize len, const jlong* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002036 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002037 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002038}
2039
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002040void SetFloatArrayRegion(JNIEnv* env,
2041 jfloatArray array, jsize start, jsize len, const jfloat* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002042 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002043 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002044}
2045
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002046void SetDoubleArrayRegion(JNIEnv* env,
2047 jdoubleArray array, jsize start, jsize len, const jdouble* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002048 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002049 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002050}
2051
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002052jint RegisterNatives(JNIEnv* env,
2053 jclass clazz, const JNINativeMethod* methods, jint nMethods) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002054 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07002055 Class* klass = Decode<Class*>(ts, clazz);
Ian Rogers4dd71f12011-08-16 14:16:02 -07002056 for(int i = 0; i < nMethods; i++) {
2057 const char* name = methods[i].name;
2058 const char* sig = methods[i].signature;
Elliott Hughes0af55432011-08-17 18:37:28 -07002059
2060 if (*sig == '!') {
2061 // TODO: fast jni. it's too noisy to log all these.
2062 ++sig;
2063 }
2064
Ian Rogers4dd71f12011-08-16 14:16:02 -07002065 Method* method = klass->FindDirectMethod(name, sig);
2066 if (method == NULL) {
2067 method = klass->FindVirtualMethod(name, sig);
2068 }
2069 if (method == NULL) {
2070 Thread* self = Thread::Current();
2071 std::string class_name = klass->GetDescriptor().ToString();
2072 // TODO: pretty print method names through a single routine
2073 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
2074 "no method \"%s.%s%s\"",
2075 class_name.c_str(), name, sig);
2076 return JNI_ERR;
2077 } else if (!method->IsNative()) {
2078 Thread* self = Thread::Current();
2079 std::string class_name = klass->GetDescriptor().ToString();
2080 // TODO: pretty print method names through a single routine
2081 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
2082 "method \"%s.%s%s\" is not native",
2083 class_name.c_str(), name, sig);
2084 return JNI_ERR;
2085 }
2086 method->RegisterNative(methods[i].fnPtr);
2087 }
2088 return JNI_OK;
Carl Shapiroea4dca82011-08-01 13:45:38 -07002089}
2090
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002091jint UnregisterNatives(JNIEnv* env, jclass clazz) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002092 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002093 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002094 return 0;
2095}
2096
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002097jint MonitorEnter(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002098 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002099 UNIMPLEMENTED(WARNING);
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002100 return 0;
2101}
2102
2103jint MonitorExit(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002104 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002105 UNIMPLEMENTED(WARNING);
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002106 return 0;
2107}
2108
Elliott Hughesb20a5542011-08-12 18:03:12 -07002109jint GetJavaVM(JNIEnv* env, JavaVM** vm) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002110 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07002111 Runtime* runtime = Runtime::Current();
2112 if (runtime != NULL) {
Elliott Hughes0af55432011-08-17 18:37:28 -07002113 *vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Elliott Hughesf2682d52011-08-15 16:37:04 -07002114 } else {
2115 *vm = NULL;
2116 }
2117 return (*vm != NULL) ? JNI_OK : JNI_ERR;
Carl Shapiroea4dca82011-08-01 13:45:38 -07002118}
2119
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002120void GetStringRegion(JNIEnv* env,
2121 jstring str, jsize start, jsize len, jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002122 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002123 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002124}
2125
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002126void GetStringUTFRegion(JNIEnv* env,
2127 jstring str, jsize start, jsize len, char* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002128 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002129 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002130}
2131
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002132void* GetPrimitiveArrayCritical(JNIEnv* env,
2133 jarray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002134 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002135 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002136 return NULL;
2137}
2138
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002139void ReleasePrimitiveArrayCritical(JNIEnv* env,
2140 jarray array, void* carray, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002141 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002142 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002143}
2144
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002145const jchar* GetStringCritical(JNIEnv* env, jstring s, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002146 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002147 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002148 return NULL;
2149}
2150
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002151void ReleaseStringCritical(JNIEnv* env, jstring s, const jchar* cstr) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002152 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002153 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002154}
2155
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002156jboolean ExceptionCheck(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002157 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -07002158 return ts.Self()->IsExceptionPending() ? JNI_TRUE : JNI_FALSE;
Carl Shapiroea4dca82011-08-01 13:45:38 -07002159}
2160
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002161jobject NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002162 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002163 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002164 return NULL;
2165}
2166
2167
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002168void* GetDirectBufferAddress(JNIEnv* env, jobject buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002169 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002170 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002171 return NULL;
2172}
2173
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002174jlong GetDirectBufferCapacity(JNIEnv* env, jobject buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002175 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002176 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002177 return 0;
2178}
2179
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002180jobjectRefType GetObjectRefType(JNIEnv* env, jobject jobj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002181 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002182 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002183 return JNIInvalidRefType;
2184}
2185
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002186static const struct JNINativeInterface gNativeInterface = {
Carl Shapiroea4dca82011-08-01 13:45:38 -07002187 NULL, // reserved0.
2188 NULL, // reserved1.
2189 NULL, // reserved2.
2190 NULL, // reserved3.
2191 GetVersion,
2192 DefineClass,
2193 FindClass,
2194 FromReflectedMethod,
2195 FromReflectedField,
2196 ToReflectedMethod,
2197 GetSuperclass,
2198 IsAssignableFrom,
2199 ToReflectedField,
2200 Throw,
2201 ThrowNew,
2202 ExceptionOccurred,
2203 ExceptionDescribe,
2204 ExceptionClear,
2205 FatalError,
2206 PushLocalFrame,
2207 PopLocalFrame,
2208 NewGlobalRef,
2209 DeleteGlobalRef,
2210 DeleteLocalRef,
2211 IsSameObject,
2212 NewLocalRef,
2213 EnsureLocalCapacity,
2214 AllocObject,
2215 NewObject,
2216 NewObjectV,
2217 NewObjectA,
2218 GetObjectClass,
2219 IsInstanceOf,
2220 GetMethodID,
2221 CallObjectMethod,
2222 CallObjectMethodV,
2223 CallObjectMethodA,
2224 CallBooleanMethod,
2225 CallBooleanMethodV,
2226 CallBooleanMethodA,
2227 CallByteMethod,
2228 CallByteMethodV,
2229 CallByteMethodA,
2230 CallCharMethod,
2231 CallCharMethodV,
2232 CallCharMethodA,
2233 CallShortMethod,
2234 CallShortMethodV,
2235 CallShortMethodA,
2236 CallIntMethod,
2237 CallIntMethodV,
2238 CallIntMethodA,
2239 CallLongMethod,
2240 CallLongMethodV,
2241 CallLongMethodA,
2242 CallFloatMethod,
2243 CallFloatMethodV,
2244 CallFloatMethodA,
2245 CallDoubleMethod,
2246 CallDoubleMethodV,
2247 CallDoubleMethodA,
2248 CallVoidMethod,
2249 CallVoidMethodV,
2250 CallVoidMethodA,
2251 CallNonvirtualObjectMethod,
2252 CallNonvirtualObjectMethodV,
2253 CallNonvirtualObjectMethodA,
2254 CallNonvirtualBooleanMethod,
2255 CallNonvirtualBooleanMethodV,
2256 CallNonvirtualBooleanMethodA,
2257 CallNonvirtualByteMethod,
2258 CallNonvirtualByteMethodV,
2259 CallNonvirtualByteMethodA,
2260 CallNonvirtualCharMethod,
2261 CallNonvirtualCharMethodV,
2262 CallNonvirtualCharMethodA,
2263 CallNonvirtualShortMethod,
2264 CallNonvirtualShortMethodV,
2265 CallNonvirtualShortMethodA,
2266 CallNonvirtualIntMethod,
2267 CallNonvirtualIntMethodV,
2268 CallNonvirtualIntMethodA,
2269 CallNonvirtualLongMethod,
2270 CallNonvirtualLongMethodV,
2271 CallNonvirtualLongMethodA,
2272 CallNonvirtualFloatMethod,
2273 CallNonvirtualFloatMethodV,
2274 CallNonvirtualFloatMethodA,
2275 CallNonvirtualDoubleMethod,
2276 CallNonvirtualDoubleMethodV,
2277 CallNonvirtualDoubleMethodA,
2278 CallNonvirtualVoidMethod,
2279 CallNonvirtualVoidMethodV,
2280 CallNonvirtualVoidMethodA,
2281 GetFieldID,
2282 GetObjectField,
2283 GetBooleanField,
2284 GetByteField,
2285 GetCharField,
2286 GetShortField,
2287 GetIntField,
2288 GetLongField,
2289 GetFloatField,
2290 GetDoubleField,
2291 SetObjectField,
2292 SetBooleanField,
2293 SetByteField,
2294 SetCharField,
2295 SetShortField,
2296 SetIntField,
2297 SetLongField,
2298 SetFloatField,
2299 SetDoubleField,
2300 GetStaticMethodID,
2301 CallStaticObjectMethod,
2302 CallStaticObjectMethodV,
2303 CallStaticObjectMethodA,
2304 CallStaticBooleanMethod,
2305 CallStaticBooleanMethodV,
2306 CallStaticBooleanMethodA,
2307 CallStaticByteMethod,
2308 CallStaticByteMethodV,
2309 CallStaticByteMethodA,
2310 CallStaticCharMethod,
2311 CallStaticCharMethodV,
2312 CallStaticCharMethodA,
2313 CallStaticShortMethod,
2314 CallStaticShortMethodV,
2315 CallStaticShortMethodA,
2316 CallStaticIntMethod,
2317 CallStaticIntMethodV,
2318 CallStaticIntMethodA,
2319 CallStaticLongMethod,
2320 CallStaticLongMethodV,
2321 CallStaticLongMethodA,
2322 CallStaticFloatMethod,
2323 CallStaticFloatMethodV,
2324 CallStaticFloatMethodA,
2325 CallStaticDoubleMethod,
2326 CallStaticDoubleMethodV,
2327 CallStaticDoubleMethodA,
2328 CallStaticVoidMethod,
2329 CallStaticVoidMethodV,
2330 CallStaticVoidMethodA,
2331 GetStaticFieldID,
2332 GetStaticObjectField,
2333 GetStaticBooleanField,
2334 GetStaticByteField,
2335 GetStaticCharField,
2336 GetStaticShortField,
2337 GetStaticIntField,
2338 GetStaticLongField,
2339 GetStaticFloatField,
2340 GetStaticDoubleField,
2341 SetStaticObjectField,
2342 SetStaticBooleanField,
2343 SetStaticByteField,
2344 SetStaticCharField,
2345 SetStaticShortField,
2346 SetStaticIntField,
2347 SetStaticLongField,
2348 SetStaticFloatField,
2349 SetStaticDoubleField,
2350 NewString,
2351 GetStringLength,
2352 GetStringChars,
2353 ReleaseStringChars,
2354 NewStringUTF,
2355 GetStringUTFLength,
2356 GetStringUTFChars,
2357 ReleaseStringUTFChars,
2358 GetArrayLength,
2359 NewObjectArray,
2360 GetObjectArrayElement,
2361 SetObjectArrayElement,
2362 NewBooleanArray,
2363 NewByteArray,
2364 NewCharArray,
2365 NewShortArray,
2366 NewIntArray,
2367 NewLongArray,
2368 NewFloatArray,
2369 NewDoubleArray,
2370 GetBooleanArrayElements,
2371 GetByteArrayElements,
2372 GetCharArrayElements,
2373 GetShortArrayElements,
2374 GetIntArrayElements,
2375 GetLongArrayElements,
2376 GetFloatArrayElements,
2377 GetDoubleArrayElements,
2378 ReleaseBooleanArrayElements,
2379 ReleaseByteArrayElements,
2380 ReleaseCharArrayElements,
2381 ReleaseShortArrayElements,
2382 ReleaseIntArrayElements,
2383 ReleaseLongArrayElements,
2384 ReleaseFloatArrayElements,
2385 ReleaseDoubleArrayElements,
2386 GetBooleanArrayRegion,
2387 GetByteArrayRegion,
2388 GetCharArrayRegion,
2389 GetShortArrayRegion,
2390 GetIntArrayRegion,
2391 GetLongArrayRegion,
2392 GetFloatArrayRegion,
2393 GetDoubleArrayRegion,
2394 SetBooleanArrayRegion,
2395 SetByteArrayRegion,
2396 SetCharArrayRegion,
2397 SetShortArrayRegion,
2398 SetIntArrayRegion,
2399 SetLongArrayRegion,
2400 SetFloatArrayRegion,
2401 SetDoubleArrayRegion,
2402 RegisterNatives,
2403 UnregisterNatives,
2404 MonitorEnter,
2405 MonitorExit,
2406 GetJavaVM,
2407 GetStringRegion,
2408 GetStringUTFRegion,
2409 GetPrimitiveArrayCritical,
2410 ReleasePrimitiveArrayCritical,
2411 GetStringCritical,
2412 ReleaseStringCritical,
2413 NewWeakGlobalRef,
2414 DeleteWeakGlobalRef,
2415 ExceptionCheck,
2416 NewDirectByteBuffer,
2417 GetDirectBufferAddress,
2418 GetDirectBufferCapacity,
2419 GetObjectRefType,
2420};
2421
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002422static const size_t kMonitorsInitial = 32; // Arbitrary.
2423static const size_t kMonitorsMax = 4096; // Arbitrary sanity check.
2424
2425static const size_t kLocalsInitial = 64; // Arbitrary.
2426static const size_t kLocalsMax = 512; // Arbitrary sanity check.
Elliott Hughesbbd76712011-08-17 10:25:24 -07002427
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002428JNIEnvExt::JNIEnvExt(Thread* self, bool check_jni)
Elliott Hughesbbd76712011-08-17 10:25:24 -07002429 : fns(&gNativeInterface),
2430 self(self),
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002431 check_jni(check_jni),
Elliott Hughesbbd76712011-08-17 10:25:24 -07002432 critical(false),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002433 monitors("monitors", kMonitorsInitial, kMonitorsMax),
2434 locals(kLocalsInitial, kLocalsMax, kLocal) {
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002435}
2436
Carl Shapiroea4dca82011-08-01 13:45:38 -07002437// JNI Invocation interface.
2438
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002439extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, void** p_env, void* vm_args) {
2440 const JavaVMInitArgs* args = static_cast<JavaVMInitArgs*>(vm_args);
2441 if (args->version < JNI_VERSION_1_2) {
2442 return JNI_EVERSION;
2443 }
2444 Runtime::Options options;
2445 for (int i = 0; i < args->nOptions; ++i) {
2446 JavaVMOption* option = &args->options[i];
Carl Shapirofc322c72011-07-27 00:20:01 -07002447 options.push_back(std::make_pair(StringPiece(option->optionString),
2448 option->extraInfo));
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002449 }
2450 bool ignore_unrecognized = args->ignoreUnrecognized;
Elliott Hughesf2682d52011-08-15 16:37:04 -07002451 Runtime* runtime = Runtime::Create(options, ignore_unrecognized);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002452 if (runtime == NULL) {
2453 return JNI_ERR;
2454 } else {
2455 *p_env = reinterpret_cast<JNIEnv*>(Thread::Current()->GetJniEnv());
Elliott Hughes0af55432011-08-17 18:37:28 -07002456 *p_vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002457 return JNI_OK;
2458 }
2459}
2460
Elliott Hughesf2682d52011-08-15 16:37:04 -07002461extern "C" jint JNI_GetCreatedJavaVMs(JavaVM** vms, jsize, jsize* vm_count) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002462 Runtime* runtime = Runtime::Current();
2463 if (runtime == NULL) {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002464 *vm_count = 0;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002465 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002466 *vm_count = 1;
Elliott Hughes0af55432011-08-17 18:37:28 -07002467 vms[0] = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002468 }
2469 return JNI_OK;
2470}
2471
2472// Historically unsupported.
2473extern "C" jint JNI_GetDefaultJavaVMInitArgs(void* vm_args) {
2474 return JNI_ERR;
2475}
2476
Elliott Hughesf2682d52011-08-15 16:37:04 -07002477jint DestroyJavaVM(JavaVM* vm) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002478 if (vm == NULL) {
2479 return JNI_ERR;
2480 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002481 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2482 delete raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002483 return JNI_OK;
2484 }
2485}
2486
Elliott Hughesf2682d52011-08-15 16:37:04 -07002487jint AttachCurrentThread(JavaVM* vm, JNIEnv** p_env, void* thr_args) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002488 if (vm == NULL || p_env == NULL) {
2489 return JNI_ERR;
2490 }
Elliott Hughesf2682d52011-08-15 16:37:04 -07002491 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2492 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002493 const char* name = NULL;
2494 if (thr_args != NULL) {
2495 // TODO: check version
2496 name = static_cast<JavaVMAttachArgs*>(thr_args)->name;
2497 // TODO: thread group
2498 }
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002499 bool success = runtime->AttachCurrentThread(name, p_env);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002500 if (!success) {
2501 return JNI_ERR;
2502 } else {
2503 return JNI_OK;
2504 }
2505}
2506
Elliott Hughesf2682d52011-08-15 16:37:04 -07002507jint DetachCurrentThread(JavaVM* vm) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002508 if (vm == NULL) {
2509 return JNI_ERR;
2510 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002511 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2512 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002513 runtime->DetachCurrentThread();
2514 return JNI_OK;
2515 }
2516}
2517
Elliott Hughesf2682d52011-08-15 16:37:04 -07002518jint GetEnv(JavaVM* vm, void** env, jint version) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002519 if (version < JNI_VERSION_1_1 || version > JNI_VERSION_1_6) {
2520 return JNI_EVERSION;
2521 }
2522 if (vm == NULL || env == NULL) {
2523 return JNI_ERR;
2524 }
2525 Thread* thread = Thread::Current();
2526 if (thread == NULL) {
2527 *env = NULL;
2528 return JNI_EDETACHED;
2529 }
2530 *env = thread->GetJniEnv();
2531 return JNI_OK;
2532}
2533
Elliott Hughesf2682d52011-08-15 16:37:04 -07002534jint AttachCurrentThreadAsDaemon(JavaVM* vm, JNIEnv** p_env, void* thr_args) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002535 if (vm == NULL || p_env == NULL) {
2536 return JNI_ERR;
2537 }
Elliott Hughesf2682d52011-08-15 16:37:04 -07002538 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2539 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002540 const char* name = NULL;
2541 if (thr_args != NULL) {
2542 // TODO: check version
2543 name = static_cast<JavaVMAttachArgs*>(thr_args)->name;
2544 // TODO: thread group
2545 }
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002546 bool success = runtime->AttachCurrentThreadAsDaemon(name, p_env);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002547 if (!success) {
2548 return JNI_ERR;
2549 } else {
2550 return JNI_OK;
2551 }
2552}
2553
Elliott Hughesf2682d52011-08-15 16:37:04 -07002554struct JNIInvokeInterface gInvokeInterface = {
Carl Shapiroea4dca82011-08-01 13:45:38 -07002555 NULL, // reserved0
2556 NULL, // reserved1
2557 NULL, // reserved2
2558 DestroyJavaVM,
2559 AttachCurrentThread,
2560 DetachCurrentThread,
2561 GetEnv,
2562 AttachCurrentThreadAsDaemon
2563};
2564
Elliott Hughesbbd76712011-08-17 10:25:24 -07002565static const size_t kPinTableInitialSize = 16;
2566static const size_t kPinTableMaxSize = 1024;
2567
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002568static const size_t kGlobalsInitial = 512; // Arbitrary.
2569static const size_t kGlobalsMax = 51200; // Arbitrary sanity check.
2570
2571static const size_t kWeakGlobalsInitial = 16; // Arbitrary.
2572static const size_t kWeakGlobalsMax = 51200; // Arbitrary sanity check.
2573
Elliott Hughes0af55432011-08-17 18:37:28 -07002574JavaVMExt::JavaVMExt(Runtime* runtime, bool check_jni, bool verbose_jni)
Elliott Hughesbbd76712011-08-17 10:25:24 -07002575 : fns(&gInvokeInterface),
2576 runtime(runtime),
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002577 check_jni(check_jni),
Elliott Hughes0af55432011-08-17 18:37:28 -07002578 verbose_jni(verbose_jni),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002579 pin_table("pin table", kPinTableInitialSize, kPinTableMaxSize),
Elliott Hughes18c07532011-08-18 15:50:51 -07002580 globals_lock(Mutex::Create("JNI global reference table lock")),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002581 globals(kGlobalsInitial, kGlobalsMax, kGlobal),
Elliott Hughes18c07532011-08-18 15:50:51 -07002582 weak_globals_lock(Mutex::Create("JNI weak global reference table lock")),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002583 weak_globals(kWeakGlobalsInitial, kWeakGlobalsMax, kWeakGlobal) {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002584}
2585
Elliott Hughesde69d7f2011-08-18 16:49:37 -07002586JavaVMExt::~JavaVMExt() {
2587 delete globals_lock;
2588 delete weak_globals_lock;
2589}
2590
Ian Rogersdf20fe02011-07-20 20:34:16 -07002591} // namespace art