blob: fd66d73bcb31f92adc3ebec03a0ed9d566e2c14e [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 }
Elliott Hughesbfaadc82011-08-18 17:36:58 -07001744 String* result = String::AllocFromModifiedUtf8(utf);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001745 return AddLocalReference<jstring>(ts, result);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001746}
1747
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001748jsize GetStringUTFLength(JNIEnv* env, jstring str) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001749 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001750 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001751 return 0;
1752}
1753
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001754const char* GetStringUTFChars(JNIEnv* env, jstring str, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001755 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001756 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001757 return NULL;
1758}
1759
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001760void ReleaseStringUTFChars(JNIEnv* env, jstring str, const char* chars) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001761 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001762 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001763}
1764
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001765jsize GetArrayLength(JNIEnv* env, jarray array) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001766 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001767 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001768 return 0;
1769}
1770
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001771jobject GetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001772 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001773 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001774 return NULL;
1775}
1776
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001777void SetObjectArrayElement(JNIEnv* env,
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001778 jobjectArray java_array, jsize index, jobject java_value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001779 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001780 ObjectArray<Object>* array = Decode<ObjectArray<Object>*>(ts, java_array);
1781 Object* value = Decode<Object*>(ts, java_value);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001782 array->Set(index, value);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001783}
1784
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001785template<typename JniT, typename ArtT>
1786JniT NewPrimitiveArray(ScopedJniThreadState& ts, jsize length) {
1787 CHECK_GE(length, 0); // TODO: ReportJniError
1788 ArtT* result = ArtT::Alloc(length);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001789 return AddLocalReference<JniT>(ts, result);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001790}
1791
Elliott Hughesf2682d52011-08-15 16:37:04 -07001792jbooleanArray NewBooleanArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001793 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001794 return NewPrimitiveArray<jbooleanArray, BooleanArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001795}
1796
Elliott Hughesf2682d52011-08-15 16:37:04 -07001797jbyteArray NewByteArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001798 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001799 return NewPrimitiveArray<jbyteArray, ByteArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001800}
1801
Elliott Hughesf2682d52011-08-15 16:37:04 -07001802jcharArray NewCharArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001803 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001804 return NewPrimitiveArray<jcharArray, CharArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001805}
1806
Elliott Hughesf2682d52011-08-15 16:37:04 -07001807jdoubleArray NewDoubleArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001808 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001809 return NewPrimitiveArray<jdoubleArray, DoubleArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001810}
1811
Elliott Hughesf2682d52011-08-15 16:37:04 -07001812jfloatArray NewFloatArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001813 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001814 return NewPrimitiveArray<jfloatArray, FloatArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001815}
1816
Elliott Hughesf2682d52011-08-15 16:37:04 -07001817jintArray NewIntArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001818 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001819 return NewPrimitiveArray<jintArray, IntArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001820}
1821
Elliott Hughesf2682d52011-08-15 16:37:04 -07001822jlongArray NewLongArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001823 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001824 return NewPrimitiveArray<jlongArray, LongArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001825}
1826
Elliott Hughesf2682d52011-08-15 16:37:04 -07001827jobjectArray NewObjectArray(JNIEnv* env, jsize length, jclass element_jclass, jobject initial_element) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001828 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001829 CHECK_GE(length, 0); // TODO: ReportJniError
1830
1831 // Compute the array class corresponding to the given element class.
Elliott Hughesc5f7c912011-08-18 14:00:42 -07001832 Class* element_class = Decode<Class*>(ts, element_jclass);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001833 std::string descriptor;
1834 descriptor += "[";
1835 descriptor += element_class->GetDescriptor().ToString();
1836
1837 // Find the class.
1838 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
1839 // TODO: need to get the appropriate ClassLoader.
1840 Class* array_class = class_linker->FindClass(descriptor, NULL);
1841 if (array_class == NULL) {
1842 return NULL;
1843 }
1844
1845 ObjectArray<Object>* result = ObjectArray<Object>::Alloc(array_class, length);
1846 CHECK(initial_element == NULL); // TODO: support initial_element
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001847 return AddLocalReference<jobjectArray>(ts, result);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001848}
1849
1850jshortArray NewShortArray(JNIEnv* env, jsize length) {
1851 ScopedJniThreadState ts(env);
1852 return NewPrimitiveArray<jshortArray, ShortArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001853}
1854
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001855jboolean* GetBooleanArrayElements(JNIEnv* env,
1856 jbooleanArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001857 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001858 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001859 return NULL;
1860}
1861
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001862jbyte* GetByteArrayElements(JNIEnv* env, jbyteArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001863 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001864 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001865 return NULL;
1866}
1867
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001868jchar* GetCharArrayElements(JNIEnv* env, jcharArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001869 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001870 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001871 return NULL;
1872}
1873
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001874jshort* GetShortArrayElements(JNIEnv* env,
1875 jshortArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001876 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001877 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001878 return NULL;
1879}
1880
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001881jint* GetIntArrayElements(JNIEnv* env, jintArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001882 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001883 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001884 return NULL;
1885}
1886
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001887jlong* GetLongArrayElements(JNIEnv* env, jlongArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001888 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001889 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001890 return NULL;
1891}
1892
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001893jfloat* GetFloatArrayElements(JNIEnv* env,
1894 jfloatArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001895 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001896 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001897 return NULL;
1898}
1899
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001900jdouble* GetDoubleArrayElements(JNIEnv* env,
1901 jdoubleArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001902 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001903 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001904 return NULL;
1905}
1906
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001907void ReleaseBooleanArrayElements(JNIEnv* env,
1908 jbooleanArray array, jboolean* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001909 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001910 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001911}
1912
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001913void ReleaseByteArrayElements(JNIEnv* env,
1914 jbyteArray array, jbyte* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001915 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001916 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001917}
1918
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001919void ReleaseCharArrayElements(JNIEnv* env,
1920 jcharArray array, jchar* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001921 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001922 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001923}
1924
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001925void ReleaseShortArrayElements(JNIEnv* env,
1926 jshortArray array, jshort* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001927 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001928 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001929}
1930
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001931void ReleaseIntArrayElements(JNIEnv* env,
1932 jintArray array, jint* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001933 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001934 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001935}
1936
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001937void ReleaseLongArrayElements(JNIEnv* env,
1938 jlongArray array, jlong* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001939 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001940 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001941}
1942
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001943void ReleaseFloatArrayElements(JNIEnv* env,
1944 jfloatArray array, jfloat* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001945 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001946 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001947}
1948
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001949void ReleaseDoubleArrayElements(JNIEnv* env,
1950 jdoubleArray array, jdouble* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001951 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001952 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001953}
1954
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001955void GetBooleanArrayRegion(JNIEnv* env,
1956 jbooleanArray array, jsize start, jsize l, jboolean* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001957 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001958 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001959}
1960
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001961void GetByteArrayRegion(JNIEnv* env,
1962 jbyteArray array, jsize start, jsize len, jbyte* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001963 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001964 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001965}
1966
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001967void GetCharArrayRegion(JNIEnv* env,
1968 jcharArray array, jsize start, jsize len, jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001969 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001970 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001971}
1972
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001973void GetShortArrayRegion(JNIEnv* env,
1974 jshortArray array, jsize start, jsize len, jshort* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001975 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001976 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001977}
1978
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001979void GetIntArrayRegion(JNIEnv* env,
1980 jintArray array, jsize start, jsize len, jint* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001981 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001982 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001983}
1984
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001985void GetLongArrayRegion(JNIEnv* env,
1986 jlongArray array, jsize start, jsize len, jlong* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001987 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001988 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001989}
1990
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001991void GetFloatArrayRegion(JNIEnv* env,
1992 jfloatArray array, jsize start, jsize len, jfloat* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001993 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001994 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001995}
1996
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001997void GetDoubleArrayRegion(JNIEnv* env,
1998 jdoubleArray array, jsize start, jsize len, jdouble* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001999 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002000 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002001}
2002
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002003void SetBooleanArrayRegion(JNIEnv* env,
2004 jbooleanArray array, jsize start, jsize l, const jboolean* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002005 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002006 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002007}
2008
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002009void SetByteArrayRegion(JNIEnv* env,
2010 jbyteArray array, jsize start, jsize len, const jbyte* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002011 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002012 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002013}
2014
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002015void SetCharArrayRegion(JNIEnv* env,
2016 jcharArray array, jsize start, jsize len, const jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002017 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002018 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002019}
2020
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002021void SetShortArrayRegion(JNIEnv* env,
2022 jshortArray array, jsize start, jsize len, const jshort* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002023 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002024 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002025}
2026
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002027void SetIntArrayRegion(JNIEnv* env,
2028 jintArray array, jsize start, jsize len, const jint* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002029 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002030 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002031}
2032
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002033void SetLongArrayRegion(JNIEnv* env,
2034 jlongArray array, jsize start, jsize len, const jlong* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002035 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002036 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002037}
2038
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002039void SetFloatArrayRegion(JNIEnv* env,
2040 jfloatArray array, jsize start, jsize len, const jfloat* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002041 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002042 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002043}
2044
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002045void SetDoubleArrayRegion(JNIEnv* env,
2046 jdoubleArray array, jsize start, jsize len, const jdouble* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002047 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002048 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002049}
2050
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002051jint RegisterNatives(JNIEnv* env,
2052 jclass clazz, const JNINativeMethod* methods, jint nMethods) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002053 ScopedJniThreadState ts(env);
Elliott Hughesc5f7c912011-08-18 14:00:42 -07002054 Class* klass = Decode<Class*>(ts, clazz);
Ian Rogers4dd71f12011-08-16 14:16:02 -07002055 for(int i = 0; i < nMethods; i++) {
2056 const char* name = methods[i].name;
2057 const char* sig = methods[i].signature;
Elliott Hughes0af55432011-08-17 18:37:28 -07002058
2059 if (*sig == '!') {
2060 // TODO: fast jni. it's too noisy to log all these.
2061 ++sig;
2062 }
2063
Ian Rogers4dd71f12011-08-16 14:16:02 -07002064 Method* method = klass->FindDirectMethod(name, sig);
2065 if (method == NULL) {
2066 method = klass->FindVirtualMethod(name, sig);
2067 }
2068 if (method == NULL) {
2069 Thread* self = Thread::Current();
2070 std::string class_name = klass->GetDescriptor().ToString();
2071 // TODO: pretty print method names through a single routine
2072 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
2073 "no method \"%s.%s%s\"",
2074 class_name.c_str(), name, sig);
2075 return JNI_ERR;
2076 } else if (!method->IsNative()) {
2077 Thread* self = Thread::Current();
2078 std::string class_name = klass->GetDescriptor().ToString();
2079 // TODO: pretty print method names through a single routine
2080 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
2081 "method \"%s.%s%s\" is not native",
2082 class_name.c_str(), name, sig);
2083 return JNI_ERR;
2084 }
2085 method->RegisterNative(methods[i].fnPtr);
2086 }
2087 return JNI_OK;
Carl Shapiroea4dca82011-08-01 13:45:38 -07002088}
2089
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002090jint UnregisterNatives(JNIEnv* env, jclass clazz) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002091 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002092 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002093 return 0;
2094}
2095
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002096jint MonitorEnter(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002097 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002098 UNIMPLEMENTED(WARNING);
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002099 return 0;
2100}
2101
2102jint MonitorExit(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002103 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002104 UNIMPLEMENTED(WARNING);
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002105 return 0;
2106}
2107
Elliott Hughesb20a5542011-08-12 18:03:12 -07002108jint GetJavaVM(JNIEnv* env, JavaVM** vm) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002109 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07002110 Runtime* runtime = Runtime::Current();
2111 if (runtime != NULL) {
Elliott Hughes0af55432011-08-17 18:37:28 -07002112 *vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Elliott Hughesf2682d52011-08-15 16:37:04 -07002113 } else {
2114 *vm = NULL;
2115 }
2116 return (*vm != NULL) ? JNI_OK : JNI_ERR;
Carl Shapiroea4dca82011-08-01 13:45:38 -07002117}
2118
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002119void GetStringRegion(JNIEnv* env,
2120 jstring str, jsize start, jsize len, jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002121 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002122 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002123}
2124
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002125void GetStringUTFRegion(JNIEnv* env,
2126 jstring str, jsize start, jsize len, char* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002127 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002128 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002129}
2130
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002131void* GetPrimitiveArrayCritical(JNIEnv* env,
2132 jarray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002133 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002134 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002135 return NULL;
2136}
2137
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002138void ReleasePrimitiveArrayCritical(JNIEnv* env,
2139 jarray array, void* carray, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002140 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002141 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002142}
2143
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002144const jchar* GetStringCritical(JNIEnv* env, jstring s, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002145 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002146 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002147 return NULL;
2148}
2149
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002150void ReleaseStringCritical(JNIEnv* env, jstring s, const jchar* cstr) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002151 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002152 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002153}
2154
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002155jboolean ExceptionCheck(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002156 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -07002157 return ts.Self()->IsExceptionPending() ? JNI_TRUE : JNI_FALSE;
Carl Shapiroea4dca82011-08-01 13:45:38 -07002158}
2159
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002160jobject NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002161 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002162 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002163 return NULL;
2164}
2165
2166
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002167void* GetDirectBufferAddress(JNIEnv* env, jobject buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002168 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002169 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002170 return NULL;
2171}
2172
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002173jlong GetDirectBufferCapacity(JNIEnv* env, jobject buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002174 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002175 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002176 return 0;
2177}
2178
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002179jobjectRefType GetObjectRefType(JNIEnv* env, jobject jobj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002180 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002181 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002182 return JNIInvalidRefType;
2183}
2184
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002185static const struct JNINativeInterface gNativeInterface = {
Carl Shapiroea4dca82011-08-01 13:45:38 -07002186 NULL, // reserved0.
2187 NULL, // reserved1.
2188 NULL, // reserved2.
2189 NULL, // reserved3.
2190 GetVersion,
2191 DefineClass,
2192 FindClass,
2193 FromReflectedMethod,
2194 FromReflectedField,
2195 ToReflectedMethod,
2196 GetSuperclass,
2197 IsAssignableFrom,
2198 ToReflectedField,
2199 Throw,
2200 ThrowNew,
2201 ExceptionOccurred,
2202 ExceptionDescribe,
2203 ExceptionClear,
2204 FatalError,
2205 PushLocalFrame,
2206 PopLocalFrame,
2207 NewGlobalRef,
2208 DeleteGlobalRef,
2209 DeleteLocalRef,
2210 IsSameObject,
2211 NewLocalRef,
2212 EnsureLocalCapacity,
2213 AllocObject,
2214 NewObject,
2215 NewObjectV,
2216 NewObjectA,
2217 GetObjectClass,
2218 IsInstanceOf,
2219 GetMethodID,
2220 CallObjectMethod,
2221 CallObjectMethodV,
2222 CallObjectMethodA,
2223 CallBooleanMethod,
2224 CallBooleanMethodV,
2225 CallBooleanMethodA,
2226 CallByteMethod,
2227 CallByteMethodV,
2228 CallByteMethodA,
2229 CallCharMethod,
2230 CallCharMethodV,
2231 CallCharMethodA,
2232 CallShortMethod,
2233 CallShortMethodV,
2234 CallShortMethodA,
2235 CallIntMethod,
2236 CallIntMethodV,
2237 CallIntMethodA,
2238 CallLongMethod,
2239 CallLongMethodV,
2240 CallLongMethodA,
2241 CallFloatMethod,
2242 CallFloatMethodV,
2243 CallFloatMethodA,
2244 CallDoubleMethod,
2245 CallDoubleMethodV,
2246 CallDoubleMethodA,
2247 CallVoidMethod,
2248 CallVoidMethodV,
2249 CallVoidMethodA,
2250 CallNonvirtualObjectMethod,
2251 CallNonvirtualObjectMethodV,
2252 CallNonvirtualObjectMethodA,
2253 CallNonvirtualBooleanMethod,
2254 CallNonvirtualBooleanMethodV,
2255 CallNonvirtualBooleanMethodA,
2256 CallNonvirtualByteMethod,
2257 CallNonvirtualByteMethodV,
2258 CallNonvirtualByteMethodA,
2259 CallNonvirtualCharMethod,
2260 CallNonvirtualCharMethodV,
2261 CallNonvirtualCharMethodA,
2262 CallNonvirtualShortMethod,
2263 CallNonvirtualShortMethodV,
2264 CallNonvirtualShortMethodA,
2265 CallNonvirtualIntMethod,
2266 CallNonvirtualIntMethodV,
2267 CallNonvirtualIntMethodA,
2268 CallNonvirtualLongMethod,
2269 CallNonvirtualLongMethodV,
2270 CallNonvirtualLongMethodA,
2271 CallNonvirtualFloatMethod,
2272 CallNonvirtualFloatMethodV,
2273 CallNonvirtualFloatMethodA,
2274 CallNonvirtualDoubleMethod,
2275 CallNonvirtualDoubleMethodV,
2276 CallNonvirtualDoubleMethodA,
2277 CallNonvirtualVoidMethod,
2278 CallNonvirtualVoidMethodV,
2279 CallNonvirtualVoidMethodA,
2280 GetFieldID,
2281 GetObjectField,
2282 GetBooleanField,
2283 GetByteField,
2284 GetCharField,
2285 GetShortField,
2286 GetIntField,
2287 GetLongField,
2288 GetFloatField,
2289 GetDoubleField,
2290 SetObjectField,
2291 SetBooleanField,
2292 SetByteField,
2293 SetCharField,
2294 SetShortField,
2295 SetIntField,
2296 SetLongField,
2297 SetFloatField,
2298 SetDoubleField,
2299 GetStaticMethodID,
2300 CallStaticObjectMethod,
2301 CallStaticObjectMethodV,
2302 CallStaticObjectMethodA,
2303 CallStaticBooleanMethod,
2304 CallStaticBooleanMethodV,
2305 CallStaticBooleanMethodA,
2306 CallStaticByteMethod,
2307 CallStaticByteMethodV,
2308 CallStaticByteMethodA,
2309 CallStaticCharMethod,
2310 CallStaticCharMethodV,
2311 CallStaticCharMethodA,
2312 CallStaticShortMethod,
2313 CallStaticShortMethodV,
2314 CallStaticShortMethodA,
2315 CallStaticIntMethod,
2316 CallStaticIntMethodV,
2317 CallStaticIntMethodA,
2318 CallStaticLongMethod,
2319 CallStaticLongMethodV,
2320 CallStaticLongMethodA,
2321 CallStaticFloatMethod,
2322 CallStaticFloatMethodV,
2323 CallStaticFloatMethodA,
2324 CallStaticDoubleMethod,
2325 CallStaticDoubleMethodV,
2326 CallStaticDoubleMethodA,
2327 CallStaticVoidMethod,
2328 CallStaticVoidMethodV,
2329 CallStaticVoidMethodA,
2330 GetStaticFieldID,
2331 GetStaticObjectField,
2332 GetStaticBooleanField,
2333 GetStaticByteField,
2334 GetStaticCharField,
2335 GetStaticShortField,
2336 GetStaticIntField,
2337 GetStaticLongField,
2338 GetStaticFloatField,
2339 GetStaticDoubleField,
2340 SetStaticObjectField,
2341 SetStaticBooleanField,
2342 SetStaticByteField,
2343 SetStaticCharField,
2344 SetStaticShortField,
2345 SetStaticIntField,
2346 SetStaticLongField,
2347 SetStaticFloatField,
2348 SetStaticDoubleField,
2349 NewString,
2350 GetStringLength,
2351 GetStringChars,
2352 ReleaseStringChars,
2353 NewStringUTF,
2354 GetStringUTFLength,
2355 GetStringUTFChars,
2356 ReleaseStringUTFChars,
2357 GetArrayLength,
2358 NewObjectArray,
2359 GetObjectArrayElement,
2360 SetObjectArrayElement,
2361 NewBooleanArray,
2362 NewByteArray,
2363 NewCharArray,
2364 NewShortArray,
2365 NewIntArray,
2366 NewLongArray,
2367 NewFloatArray,
2368 NewDoubleArray,
2369 GetBooleanArrayElements,
2370 GetByteArrayElements,
2371 GetCharArrayElements,
2372 GetShortArrayElements,
2373 GetIntArrayElements,
2374 GetLongArrayElements,
2375 GetFloatArrayElements,
2376 GetDoubleArrayElements,
2377 ReleaseBooleanArrayElements,
2378 ReleaseByteArrayElements,
2379 ReleaseCharArrayElements,
2380 ReleaseShortArrayElements,
2381 ReleaseIntArrayElements,
2382 ReleaseLongArrayElements,
2383 ReleaseFloatArrayElements,
2384 ReleaseDoubleArrayElements,
2385 GetBooleanArrayRegion,
2386 GetByteArrayRegion,
2387 GetCharArrayRegion,
2388 GetShortArrayRegion,
2389 GetIntArrayRegion,
2390 GetLongArrayRegion,
2391 GetFloatArrayRegion,
2392 GetDoubleArrayRegion,
2393 SetBooleanArrayRegion,
2394 SetByteArrayRegion,
2395 SetCharArrayRegion,
2396 SetShortArrayRegion,
2397 SetIntArrayRegion,
2398 SetLongArrayRegion,
2399 SetFloatArrayRegion,
2400 SetDoubleArrayRegion,
2401 RegisterNatives,
2402 UnregisterNatives,
2403 MonitorEnter,
2404 MonitorExit,
2405 GetJavaVM,
2406 GetStringRegion,
2407 GetStringUTFRegion,
2408 GetPrimitiveArrayCritical,
2409 ReleasePrimitiveArrayCritical,
2410 GetStringCritical,
2411 ReleaseStringCritical,
2412 NewWeakGlobalRef,
2413 DeleteWeakGlobalRef,
2414 ExceptionCheck,
2415 NewDirectByteBuffer,
2416 GetDirectBufferAddress,
2417 GetDirectBufferCapacity,
2418 GetObjectRefType,
2419};
2420
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002421static const size_t kMonitorsInitial = 32; // Arbitrary.
2422static const size_t kMonitorsMax = 4096; // Arbitrary sanity check.
2423
2424static const size_t kLocalsInitial = 64; // Arbitrary.
2425static const size_t kLocalsMax = 512; // Arbitrary sanity check.
Elliott Hughesbbd76712011-08-17 10:25:24 -07002426
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002427JNIEnvExt::JNIEnvExt(Thread* self, bool check_jni)
Elliott Hughesbbd76712011-08-17 10:25:24 -07002428 : fns(&gNativeInterface),
2429 self(self),
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002430 check_jni(check_jni),
Elliott Hughesbbd76712011-08-17 10:25:24 -07002431 critical(false),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002432 monitors("monitors", kMonitorsInitial, kMonitorsMax),
2433 locals(kLocalsInitial, kLocalsMax, kLocal) {
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002434}
2435
Carl Shapiroea4dca82011-08-01 13:45:38 -07002436// JNI Invocation interface.
2437
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002438extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, void** p_env, void* vm_args) {
2439 const JavaVMInitArgs* args = static_cast<JavaVMInitArgs*>(vm_args);
2440 if (args->version < JNI_VERSION_1_2) {
2441 return JNI_EVERSION;
2442 }
2443 Runtime::Options options;
2444 for (int i = 0; i < args->nOptions; ++i) {
2445 JavaVMOption* option = &args->options[i];
Carl Shapirofc322c72011-07-27 00:20:01 -07002446 options.push_back(std::make_pair(StringPiece(option->optionString),
2447 option->extraInfo));
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002448 }
2449 bool ignore_unrecognized = args->ignoreUnrecognized;
Elliott Hughesf2682d52011-08-15 16:37:04 -07002450 Runtime* runtime = Runtime::Create(options, ignore_unrecognized);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002451 if (runtime == NULL) {
2452 return JNI_ERR;
2453 } else {
2454 *p_env = reinterpret_cast<JNIEnv*>(Thread::Current()->GetJniEnv());
Elliott Hughes0af55432011-08-17 18:37:28 -07002455 *p_vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002456 return JNI_OK;
2457 }
2458}
2459
Elliott Hughesf2682d52011-08-15 16:37:04 -07002460extern "C" jint JNI_GetCreatedJavaVMs(JavaVM** vms, jsize, jsize* vm_count) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002461 Runtime* runtime = Runtime::Current();
2462 if (runtime == NULL) {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002463 *vm_count = 0;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002464 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002465 *vm_count = 1;
Elliott Hughes0af55432011-08-17 18:37:28 -07002466 vms[0] = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002467 }
2468 return JNI_OK;
2469}
2470
2471// Historically unsupported.
2472extern "C" jint JNI_GetDefaultJavaVMInitArgs(void* vm_args) {
2473 return JNI_ERR;
2474}
2475
Elliott Hughesf2682d52011-08-15 16:37:04 -07002476jint DestroyJavaVM(JavaVM* vm) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002477 if (vm == NULL) {
2478 return JNI_ERR;
2479 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002480 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2481 delete raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002482 return JNI_OK;
2483 }
2484}
2485
Elliott Hughesf2682d52011-08-15 16:37:04 -07002486jint AttachCurrentThread(JavaVM* vm, JNIEnv** p_env, void* thr_args) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002487 if (vm == NULL || p_env == NULL) {
2488 return JNI_ERR;
2489 }
Elliott Hughesf2682d52011-08-15 16:37:04 -07002490 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2491 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002492 const char* name = NULL;
2493 if (thr_args != NULL) {
2494 // TODO: check version
2495 name = static_cast<JavaVMAttachArgs*>(thr_args)->name;
2496 // TODO: thread group
2497 }
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002498 bool success = runtime->AttachCurrentThread(name, p_env);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002499 if (!success) {
2500 return JNI_ERR;
2501 } else {
2502 return JNI_OK;
2503 }
2504}
2505
Elliott Hughesf2682d52011-08-15 16:37:04 -07002506jint DetachCurrentThread(JavaVM* vm) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002507 if (vm == NULL) {
2508 return JNI_ERR;
2509 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002510 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2511 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002512 runtime->DetachCurrentThread();
2513 return JNI_OK;
2514 }
2515}
2516
Elliott Hughesf2682d52011-08-15 16:37:04 -07002517jint GetEnv(JavaVM* vm, void** env, jint version) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002518 if (version < JNI_VERSION_1_1 || version > JNI_VERSION_1_6) {
2519 return JNI_EVERSION;
2520 }
2521 if (vm == NULL || env == NULL) {
2522 return JNI_ERR;
2523 }
2524 Thread* thread = Thread::Current();
2525 if (thread == NULL) {
2526 *env = NULL;
2527 return JNI_EDETACHED;
2528 }
2529 *env = thread->GetJniEnv();
2530 return JNI_OK;
2531}
2532
Elliott Hughesf2682d52011-08-15 16:37:04 -07002533jint AttachCurrentThreadAsDaemon(JavaVM* vm, JNIEnv** p_env, void* thr_args) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002534 if (vm == NULL || p_env == NULL) {
2535 return JNI_ERR;
2536 }
Elliott Hughesf2682d52011-08-15 16:37:04 -07002537 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2538 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002539 const char* name = NULL;
2540 if (thr_args != NULL) {
2541 // TODO: check version
2542 name = static_cast<JavaVMAttachArgs*>(thr_args)->name;
2543 // TODO: thread group
2544 }
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002545 bool success = runtime->AttachCurrentThreadAsDaemon(name, p_env);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002546 if (!success) {
2547 return JNI_ERR;
2548 } else {
2549 return JNI_OK;
2550 }
2551}
2552
Elliott Hughesf2682d52011-08-15 16:37:04 -07002553struct JNIInvokeInterface gInvokeInterface = {
Carl Shapiroea4dca82011-08-01 13:45:38 -07002554 NULL, // reserved0
2555 NULL, // reserved1
2556 NULL, // reserved2
2557 DestroyJavaVM,
2558 AttachCurrentThread,
2559 DetachCurrentThread,
2560 GetEnv,
2561 AttachCurrentThreadAsDaemon
2562};
2563
Elliott Hughesbbd76712011-08-17 10:25:24 -07002564static const size_t kPinTableInitialSize = 16;
2565static const size_t kPinTableMaxSize = 1024;
2566
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002567static const size_t kGlobalsInitial = 512; // Arbitrary.
2568static const size_t kGlobalsMax = 51200; // Arbitrary sanity check.
2569
2570static const size_t kWeakGlobalsInitial = 16; // Arbitrary.
2571static const size_t kWeakGlobalsMax = 51200; // Arbitrary sanity check.
2572
Elliott Hughes0af55432011-08-17 18:37:28 -07002573JavaVMExt::JavaVMExt(Runtime* runtime, bool check_jni, bool verbose_jni)
Elliott Hughesbbd76712011-08-17 10:25:24 -07002574 : fns(&gInvokeInterface),
2575 runtime(runtime),
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002576 check_jni(check_jni),
Elliott Hughes0af55432011-08-17 18:37:28 -07002577 verbose_jni(verbose_jni),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002578 pin_table("pin table", kPinTableInitialSize, kPinTableMaxSize),
Elliott Hughes18c07532011-08-18 15:50:51 -07002579 globals_lock(Mutex::Create("JNI global reference table lock")),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002580 globals(kGlobalsInitial, kGlobalsMax, kGlobal),
Elliott Hughes18c07532011-08-18 15:50:51 -07002581 weak_globals_lock(Mutex::Create("JNI weak global reference table lock")),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002582 weak_globals(kWeakGlobalsInitial, kWeakGlobalsMax, kWeakGlobal) {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002583}
2584
Elliott Hughesde69d7f2011-08-18 16:49:37 -07002585JavaVMExt::~JavaVMExt() {
2586 delete globals_lock;
2587 delete weak_globals_lock;
2588}
2589
Ian Rogersdf20fe02011-07-20 20:34:16 -07002590} // namespace art