blob: b08d12ada3f8c5a8f30d4ee8be2caed868b279ed [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 Hughes40ef99e2011-08-11 17:44:34 -070011#include "class_linker.h"
Carl Shapiroea4dca82011-08-01 13:45:38 -070012#include "jni.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070013#include "logging.h"
Carl Shapiro9b9ba282011-08-14 15:30:39 -070014#include "object.h"
Carl Shapiro2ed144c2011-07-26 16:52:08 -070015#include "runtime.h"
Carl Shapirofc322c72011-07-27 00:20:01 -070016#include "scoped_ptr.h"
17#include "stringpiece.h"
Carl Shapiro2ed144c2011-07-26 16:52:08 -070018#include "thread.h"
Ian Rogersdf20fe02011-07-20 20:34:16 -070019
20namespace art {
21
Elliott Hughes0af55432011-08-17 18:37:28 -070022enum JNI_OnLoadState {
23 kPending = 0, /* initial state, must be zero */
24 kFailed,
25 kOkay,
26};
27
28struct SharedLibrary {
29 SharedLibrary() : jni_on_load_lock("JNI_OnLoad") {
30 }
31
32 // Path to library "/system/lib/libjni.so".
33 std::string path;
34
35 // The void* returned by dlopen(3).
36 void* handle;
37
38 // The ClassLoader this library is associated with.
39 Object* class_loader;
40
41 // Guards remaining items.
42 Mutex jni_on_load_lock;
43 // Wait for JNI_OnLoad in other thread.
44 pthread_cond_t jni_on_load_cond;
45 // Recursive invocation guard.
46 uint32_t jni_on_load_tid;
47 // Result of earlier JNI_OnLoad call.
48 JNI_OnLoadState jni_on_load_result;
49};
50
51/*
52 * Check the result of an earlier call to JNI_OnLoad on this library. If
53 * the call has not yet finished in another thread, wait for it.
54 */
55bool CheckOnLoadResult(JavaVMExt* vm, SharedLibrary* library) {
56 Thread* self = Thread::Current();
57 if (library->jni_on_load_tid == self->GetId()) {
58 // Check this so we don't end up waiting for ourselves. We need
59 // to return "true" so the caller can continue.
60 LOG(INFO) << *self << " recursive attempt to load library "
61 << "\"" << library->path << "\"";
62 return true;
63 }
64
65 UNIMPLEMENTED(ERROR) << "need to pthread_cond_wait!";
66 // MutexLock mu(&library->jni_on_load_lock);
67 while (library->jni_on_load_result == kPending) {
68 if (vm->verbose_jni) {
69 LOG(INFO) << "[" << *self << " waiting for \"" << library->path << "\" "
70 << "JNI_OnLoad...]";
71 }
72 Thread::State old_state = self->GetState();
73 self->SetState(Thread::kWaiting); // TODO: VMWAIT
74 // pthread_cond_wait(&library->jni_on_load_cond, &library->jni_on_load_lock);
75 self->SetState(old_state);
76 }
77
78 bool okay = (library->jni_on_load_result == kOkay);
79 if (vm->verbose_jni) {
80 LOG(INFO) << "[Earlier JNI_OnLoad for \"" << library->path << "\" "
81 << (okay ? "succeeded" : "failed") << "]";
82 }
83 return okay;
84}
85
86typedef int (*JNI_OnLoadFn)(JavaVM*, void*);
87
88/*
89 * Load native code from the specified absolute pathname. Per the spec,
90 * if we've already loaded a library with the specified pathname, we
91 * return without doing anything.
92 *
93 * TODO? for better results we should absolutify the pathname. For fully
94 * correct results we should stat to get the inode and compare that. The
95 * existing implementation is fine so long as everybody is using
96 * System.loadLibrary.
97 *
98 * The library will be associated with the specified class loader. The JNI
99 * spec says we can't load the same library into more than one class loader.
100 *
101 * Returns "true" on success. On failure, sets *detail to a
102 * human-readable description of the error or NULL if no detail is
103 * available; ownership of the string is transferred to the caller.
104 */
105bool JavaVMExt::LoadNativeLibrary(const std::string& path, Object* class_loader, char** detail) {
106 *detail = NULL;
107
108 // See if we've already loaded this library. If we have, and the class loader
109 // matches, return successfully without doing anything.
110 SharedLibrary* library = libraries[path];
111 if (library != NULL) {
112 if (library->class_loader != class_loader) {
113 LOG(WARNING) << "Shared library \"" << path << "\" already opened by "
114 << "ClassLoader " << library->class_loader << "; "
115 << "can't open in " << class_loader;
116 *detail = strdup("already opened by different ClassLoader");
117 return false;
118 }
119 if (verbose_jni) {
120 LOG(INFO) << "[Shared library \"" << path << "\" already loaded in "
121 << "ClassLoader " << class_loader << "]";
122 }
123 if (!CheckOnLoadResult(this, library)) {
124 *detail = strdup("JNI_OnLoad failed before");
125 return false;
126 }
127 return true;
128 }
129
130 // Open the shared library. Because we're using a full path, the system
131 // doesn't have to search through LD_LIBRARY_PATH. (It may do so to
132 // resolve this library's dependencies though.)
133
134 // Failures here are expected when java.library.path has several entries
135 // and we have to hunt for the lib.
136
137 // The current version of the dynamic linker prints detailed information
138 // about dlopen() failures. Some things to check if the message is
139 // cryptic:
140 // - make sure the library exists on the device
141 // - verify that the right path is being opened (the debug log message
142 // above can help with that)
143 // - check to see if the library is valid (e.g. not zero bytes long)
144 // - check config/prelink-linux-arm.map to ensure that the library
145 // is listed and is not being overrun by the previous entry (if
146 // loading suddenly stops working on a prelinked library, this is
147 // a good one to check)
148 // - write a trivial app that calls sleep() then dlopen(), attach
149 // to it with "strace -p <pid>" while it sleeps, and watch for
150 // attempts to open nonexistent dependent shared libs
151
152 // TODO: automate some of these checks!
153
154 if (verbose_jni) {
155 LOG(INFO) << "[calling dlopen(\"" << path << "\")...]";
156 }
157
158 // This can execute slowly for a large library on a busy system, so we
159 // want to switch from RUNNING to VMWAIT while it executes. This allows
160 // the GC to ignore us.
161 Thread* self = Thread::Current();
162 Thread::State old_state = self->GetState();
163 self->SetState(Thread::kWaiting); // TODO: VMWAIT
164 void* handle = dlopen(path.c_str(), RTLD_LAZY);
165 self->SetState(old_state);
166
167 if (verbose_jni) {
168 LOG(INFO) << "[dlopen(\"" << path << "\") returned " << handle << "]";
169 }
170
171 if (handle == NULL) {
172 *detail = strdup(dlerror());
173 return false;
174 }
175
176 // Create a new entry.
177 library = new SharedLibrary;
178 library->path = path;
179 library->handle = handle;
180 library->class_loader = class_loader;
181 UNIMPLEMENTED(ERROR) << "missing pthread_cond_init";
182 // pthread_cond_init(&library->onLoadCond, NULL);
183 library->jni_on_load_tid = self->GetId();
184
185 libraries[path] = library;
186
187// if (pNewEntry != pActualEntry) {
188// LOG(INFO) << "WOW: we lost a race to add a shared library (\"" << path << "\" ClassLoader=" << class_loader <<")";
189// freeSharedLibEntry(pNewEntry);
190// return CheckOnLoadResult(this, pActualEntry);
191// } else
192 {
193 if (verbose_jni) {
194 LOG(INFO) << "[Added shared library \"" << path << "\" for ClassLoader " << class_loader << "]";
195 }
196
197 bool result = true;
198 void* sym = dlsym(handle, "JNI_OnLoad");
199 if (sym == NULL) {
200 if (verbose_jni) {
201 LOG(INFO) << "[No JNI_OnLoad found in \"" << path << "\"]";
202 }
203 } else {
204 // Call JNI_OnLoad. We have to override the current class
205 // loader, which will always be "null" since the stuff at the
206 // top of the stack is around Runtime.loadLibrary(). (See
207 // the comments in the JNI FindClass function.)
208 UNIMPLEMENTED(WARNING) << "need to override current class loader";
209 JNI_OnLoadFn jni_on_load = reinterpret_cast<JNI_OnLoadFn>(sym);
210 //Object* prevOverride = self->classLoaderOverride;
211 //self->classLoaderOverride = classLoader;
212
213 old_state = self->GetState();
214 self->SetState(Thread::kNative);
215 if (verbose_jni) {
216 LOG(INFO) << "[Calling JNI_OnLoad in \"" << path << "\"]";
217 }
218 int version = (*jni_on_load)(reinterpret_cast<JavaVM*>(this), NULL);
219 self->SetState(old_state);
220
221 UNIMPLEMENTED(WARNING) << "need to restore current class loader";
222 //self->classLoaderOverride = prevOverride;
223
224 if (version != JNI_VERSION_1_2 &&
225 version != JNI_VERSION_1_4 &&
226 version != JNI_VERSION_1_6) {
227 LOG(WARNING) << "JNI_OnLoad in \"" << path << "\" returned "
228 << "bad version: " << version;
229 // It's unwise to call dlclose() here, but we can mark it
230 // as bad and ensure that future load attempts will fail.
231 // We don't know how far JNI_OnLoad got, so there could
232 // be some partially-initialized stuff accessible through
233 // newly-registered native method calls. We could try to
234 // unregister them, but that doesn't seem worthwhile.
235 result = false;
236 } else {
237 if (verbose_jni) {
238 LOG(INFO) << "[Returned from JNI_OnLoad in \"" << path << "\"]";
239 }
240 }
241 }
242
243 library->jni_on_load_result = result ? kOkay : kFailed;
244 library->jni_on_load_tid = 0;
245
246 // Broadcast a wakeup to anybody sleeping on the condition variable.
247 UNIMPLEMENTED(ERROR) << "missing pthread_cond_broadcast";
248 // MutexLock mu(&library->jni_on_load_lock);
249 // pthread_cond_broadcast(&library->jni_on_load_cond);
250 return result;
251 }
252}
253
Elliott Hughes22f40932011-08-12 13:06:37 -0700254// Entry/exit processing for all JNI calls.
255//
256// This performs the necessary thread state switching, lets us amortize the
257// cost of working out the current thread, and lets us check (and repair) apps
258// that are using a JNIEnv on the wrong thread.
259class ScopedJniThreadState {
260 public:
261 explicit ScopedJniThreadState(JNIEnv* env) {
Elliott Hughesb20a5542011-08-12 18:03:12 -0700262 self_ = ThreadForEnv(env);
Elliott Hughes22f40932011-08-12 13:06:37 -0700263 self_->SetState(Thread::kRunnable);
264 }
265
266 ~ScopedJniThreadState() {
267 self_->SetState(Thread::kNative);
268 }
269
Elliott Hughesb20a5542011-08-12 18:03:12 -0700270 Thread* Self() {
Elliott Hughes22f40932011-08-12 13:06:37 -0700271 return self_;
272 }
273
Elliott Hughesb20a5542011-08-12 18:03:12 -0700274 private:
275 static Thread* ThreadForEnv(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700276 // TODO: need replacement for gDvmJni.
277 bool workAroundAppJniBugs = true;
278 Thread* env_self = reinterpret_cast<JNIEnvExt*>(env)->self;
279 Thread* self = workAroundAppJniBugs ? Thread::Current() : env_self;
280 if (self != env_self) {
Elliott Hughes330304d2011-08-12 14:28:05 -0700281 LOG(ERROR) << "JNI ERROR: JNIEnv for " << *env_self
282 << " used on " << *self;
283 // TODO: dump stack
Elliott Hughes22f40932011-08-12 13:06:37 -0700284 }
285 return self;
286 }
287
Elliott Hughes22f40932011-08-12 13:06:37 -0700288 Thread* self_;
289 DISALLOW_COPY_AND_ASSIGN(ScopedJniThreadState);
290};
291
Elliott Hughes8a26c5c2011-08-15 18:35:43 -0700292template<typename T>
293T AddLocalReference(ScopedJniThreadState& ts, Object* obj) {
294 UNIMPLEMENTED(WARNING);
295 return reinterpret_cast<T>(obj);
296}
297
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700298void CreateInvokeStub(Assembler* assembler, Method* method);
299
300bool EnsureInvokeStub(Method* method) {
301 if (method->GetInvokeStub() != NULL) {
302 return true;
303 }
304 // TODO: use signature to find a matching stub
305 // TODO: failed, acquire a lock on the stub table
306 Assembler assembler;
307 CreateInvokeStub(&assembler, method);
308 // TODO: store native_entry in the stub table
309 int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
310 size_t length = assembler.CodeSize();
311 void* addr = mmap(NULL, length, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
312 if (addr == MAP_FAILED) {
313 PLOG(FATAL) << "mmap failed";
314 }
315 MemoryRegion region(addr, length);
316 assembler.FinalizeInstructions(region);
317 method->SetInvokeStub(reinterpret_cast<Method::InvokeStub*>(region.pointer()));
318 return true;
319}
320
Elliott Hughesd8ddfd52011-08-15 14:32:53 -0700321byte* CreateArgArray(Method* method, va_list ap) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700322 size_t num_bytes = method->NumArgArrayBytes();
323 scoped_array<byte> arg_array(new byte[num_bytes]);
324 const StringPiece& shorty = method->GetShorty();
Ian Rogers4dd71f12011-08-16 14:16:02 -0700325 for (int i = 1, offset = 0; i < shorty.size(); ++i) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700326 switch (shorty[i]) {
327 case 'Z':
328 case 'B':
329 case 'C':
330 case 'S':
331 case 'I':
332 *reinterpret_cast<int32_t*>(&arg_array[offset]) = va_arg(ap, jint);
333 offset += 4;
334 break;
335 case 'F':
336 *reinterpret_cast<float*>(&arg_array[offset]) = va_arg(ap, jdouble);
337 offset += 4;
338 break;
339 case 'L': {
Elliott Hughesf2682d52011-08-15 16:37:04 -0700340 // TODO: DecodeReference
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700341 Object* obj = reinterpret_cast<Object*>(va_arg(ap, jobject));
342 *reinterpret_cast<Object**>(&arg_array[offset]) = obj;
343 offset += sizeof(Object*);
344 break;
345 }
346 case 'D':
347 *reinterpret_cast<double*>(&arg_array[offset]) = va_arg(ap, jdouble);
348 offset += 8;
349 break;
350 case 'J':
351 *reinterpret_cast<int64_t*>(&arg_array[offset]) = va_arg(ap, jlong);
352 offset += 8;
353 break;
354 }
355 }
356 return arg_array.release();
357}
358
Elliott Hughesd8ddfd52011-08-15 14:32:53 -0700359byte* CreateArgArray(Method* method, jvalue* args) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700360 size_t num_bytes = method->NumArgArrayBytes();
361 scoped_array<byte> arg_array(new byte[num_bytes]);
362 const StringPiece& shorty = method->GetShorty();
Ian Rogers4dd71f12011-08-16 14:16:02 -0700363 for (int i = 1, offset = 0; i < shorty.size(); ++i) {
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700364 switch (shorty[i]) {
365 case 'Z':
366 case 'B':
367 case 'C':
368 case 'S':
369 case 'I':
370 *reinterpret_cast<uint32_t*>(&arg_array[offset]) = args[i - 1].i;
371 offset += 4;
372 break;
373 case 'F':
374 *reinterpret_cast<float*>(&arg_array[offset]) = args[i - 1].f;
375 offset += 4;
376 break;
377 case 'L': {
Elliott Hughesf2682d52011-08-15 16:37:04 -0700378 // TODO: DecodeReference
379 Object* obj = reinterpret_cast<Object*>(args[i - 1].l);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700380 *reinterpret_cast<Object**>(&arg_array[offset]) = obj;
381 offset += sizeof(Object*);
382 break;
383 }
384 case 'D':
385 *reinterpret_cast<double*>(&arg_array[offset]) = args[i - 1].d;
386 offset += 8;
387 break;
388 case 'J':
389 *reinterpret_cast<uint64_t*>(&arg_array[offset]) = args[i - 1].j;
390 offset += 8;
391 break;
392 }
393 }
394 return arg_array.release();
395}
396
Elliott Hughes3cd987f2011-08-15 10:39:47 -0700397JValue InvokeWithArgArray(Thread* self, Object* obj, jmethodID method_id,
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700398 byte* args) {
Elliott Hughesf2682d52011-08-15 16:37:04 -0700399 // TODO: DecodeReference
400 Method* method = reinterpret_cast<Method*>(method_id);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700401 // Call the invoke stub associated with the method
402 // Pass everything as arguments
403 const Method::InvokeStub* stub = method->GetInvokeStub();
404 CHECK(stub != NULL);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700405 JValue result;
Elliott Hughes3cd987f2011-08-15 10:39:47 -0700406 (*stub)(method, obj, self, args, &result);
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700407 return result;
408}
409
Elliott Hughes3cd987f2011-08-15 10:39:47 -0700410JValue InvokeWithJValues(Thread* self, Object* obj, jmethodID method_id,
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700411 jvalue* args) {
412 Method* method = reinterpret_cast<Method*>(method_id);
413 scoped_array<byte> arg_array(CreateArgArray(method, args));
Elliott Hughes3cd987f2011-08-15 10:39:47 -0700414 return InvokeWithArgArray(self, obj, method_id, arg_array.get());
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700415}
416
Elliott Hughes3cd987f2011-08-15 10:39:47 -0700417JValue InvokeWithVarArgs(Thread* self, Object* obj, jmethodID method_id,
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700418 va_list args) {
419 Method* method = reinterpret_cast<Method*>(method_id);
420 scoped_array<byte> arg_array(CreateArgArray(method, args));
Elliott Hughes3cd987f2011-08-15 10:39:47 -0700421 return InvokeWithArgArray(self, obj, method_id, arg_array.get());
Carl Shapiro9b9ba282011-08-14 15:30:39 -0700422}
423
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700424jint GetVersion(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700425 ScopedJniThreadState ts(env);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700426 return JNI_VERSION_1_6;
427}
428
Elliott Hughesb20a5542011-08-12 18:03:12 -0700429jclass DefineClass(JNIEnv* env, const char*, jobject, const jbyte*, jsize) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700430 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -0700431 LOG(WARNING) << "JNI DefineClass is not supported";
Carl Shapiroea4dca82011-08-01 13:45:38 -0700432 return NULL;
433}
434
Elliott Hughes6b436852011-08-12 10:16:44 -0700435// Section 12.3.2 of the JNI spec describes JNI class descriptors. They're
436// separated with slashes but aren't wrapped with "L;" like regular descriptors
437// (i.e. "a/b/C" rather than "La/b/C;"). Arrays of reference types are an
438// exception; there the "L;" must be present ("[La/b/C;"). Historically we've
439// supported names with dots too (such as "a.b.C").
440std::string NormalizeJniClassDescriptor(const char* name) {
441 std::string result;
442 // Add the missing "L;" if necessary.
443 if (name[0] == '[') {
444 result = name;
445 } else {
446 result += 'L';
447 result += name;
448 result += ';';
449 }
450 // Rewrite '.' as '/' for backwards compatibility.
Elliott Hughesa5b897e2011-08-16 11:33:06 -0700451 if (result.find('.') != std::string::npos) {
452 LOG(WARNING) << "Call to JNI FindClass with dots in name: "
453 << "\"" << name << "\"";
454 std::replace(result.begin(), result.end(), '.', '/');
Elliott Hughes6b436852011-08-12 10:16:44 -0700455 }
456 return result;
457}
458
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700459jclass FindClass(JNIEnv* env, const char* name) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700460 ScopedJniThreadState ts(env);
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700461 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Elliott Hughes6b436852011-08-12 10:16:44 -0700462 std::string descriptor(NormalizeJniClassDescriptor(name));
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700463 // TODO: need to get the appropriate ClassLoader.
Elliott Hughes6b436852011-08-12 10:16:44 -0700464 Class* c = class_linker->FindClass(descriptor, NULL);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -0700465 return AddLocalReference<jclass>(ts, c);
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700466}
467
468jmethodID FromReflectedMethod(JNIEnv* env, jobject method) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700469 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700470 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700471 return NULL;
472}
473
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700474jfieldID FromReflectedField(JNIEnv* env, jobject field) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700475 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700476 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700477 return NULL;
478}
479
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700480jobject ToReflectedMethod(JNIEnv* env, jclass cls,
481 jmethodID methodID, jboolean isStatic) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700482 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700483 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700484 return NULL;
485}
486
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700487jclass GetSuperclass(JNIEnv* env, jclass sub) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700488 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700489 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700490 return NULL;
491}
492
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700493jboolean IsAssignableFrom(JNIEnv* env, jclass sub, jclass sup) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700494 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700495 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700496 return JNI_FALSE;
497}
498
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700499jobject ToReflectedField(JNIEnv* env, jclass cls,
500 jfieldID fieldID, jboolean isStatic) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700501 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700502 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700503 return NULL;
504}
505
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700506jint Throw(JNIEnv* env, jthrowable obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700507 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700508 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700509 return 0;
510}
511
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700512jint ThrowNew(JNIEnv* env, jclass clazz, const char* msg) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700513 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700514 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700515 return 0;
516}
517
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700518jthrowable ExceptionOccurred(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700519 ScopedJniThreadState ts(env);
Ian Rogers4dd71f12011-08-16 14:16:02 -0700520 Object* exception = ts.Self()->GetException();
521 if (exception == NULL) {
522 return NULL;
523 } else {
524 // TODO: if adding a local reference failing causes the VM to abort
525 // then the following check will never occur.
526 jthrowable localException = AddLocalReference<jthrowable>(ts, exception);
527 if (localException == NULL) {
528 // We were unable to add a new local reference, and threw a new
529 // exception. We can't return "exception", because it's not a
530 // local reference. So we have to return NULL, indicating that
531 // there was no exception, even though it's pretty much raining
532 // exceptions in here.
533 LOG(WARNING) << "JNI WARNING: addLocal/exception combo";
534 }
535 return localException;
536 }
Carl Shapiroea4dca82011-08-01 13:45:38 -0700537}
538
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700539void ExceptionDescribe(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700540 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700541 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700542}
543
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700544void ExceptionClear(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700545 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -0700546 ts.Self()->ClearException();
Carl Shapiroea4dca82011-08-01 13:45:38 -0700547}
548
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700549void FatalError(JNIEnv* env, const char* msg) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700550 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -0700551 LOG(FATAL) << "JNI FatalError called: " << msg;
Carl Shapiroea4dca82011-08-01 13:45:38 -0700552}
553
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700554jint PushLocalFrame(JNIEnv* env, jint cap) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700555 ScopedJniThreadState ts(env);
Elliott Hughes0af55432011-08-17 18:37:28 -0700556 UNIMPLEMENTED(WARNING) << "ignoring PushLocalFrame(" << cap << ")";
557 return JNI_OK;
Carl Shapiroea4dca82011-08-01 13:45:38 -0700558}
559
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700560jobject PopLocalFrame(JNIEnv* env, jobject res) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700561 ScopedJniThreadState ts(env);
Elliott Hughes0af55432011-08-17 18:37:28 -0700562 UNIMPLEMENTED(WARNING) << "ignoring PopLocalFrame";
563 return res;
Carl Shapiroea4dca82011-08-01 13:45:38 -0700564}
565
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700566jobject NewGlobalRef(JNIEnv* env, jobject lobj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700567 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700568 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700569 return NULL;
570}
571
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700572void DeleteGlobalRef(JNIEnv* env, jobject gref) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700573 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700574 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700575}
576
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700577void DeleteLocalRef(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700578 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -0700579 UNIMPLEMENTED(WARNING);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700580}
581
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700582jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700583 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700584 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700585 return JNI_FALSE;
586}
587
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700588jobject NewLocalRef(JNIEnv* env, jobject ref) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700589 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700590 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700591 return NULL;
592}
593
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700594jint EnsureLocalCapacity(JNIEnv* env, jint) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700595 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700596 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700597 return 0;
598}
599
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700600jobject AllocObject(JNIEnv* env, jclass clazz) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700601 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700602 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700603 return NULL;
604}
605
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700606jobject NewObject(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700607 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700608 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700609 return NULL;
610}
611
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700612jobject NewObjectV(JNIEnv* env,
613 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700614 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700615 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700616 return NULL;
617}
618
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700619jobject NewObjectA(JNIEnv* env,
620 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700621 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700622 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700623 return NULL;
624}
625
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700626jclass GetObjectClass(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700627 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700628 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700629 return NULL;
630}
631
Ian Rogers4dd71f12011-08-16 14:16:02 -0700632jboolean IsInstanceOf(JNIEnv* env, jobject jobj, jclass clazz) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700633 ScopedJniThreadState ts(env);
Ian Rogers4dd71f12011-08-16 14:16:02 -0700634 CHECK_NE(static_cast<jclass>(NULL), clazz);
635 if (jobj == NULL) {
636 // NB. JNI is different from regular Java instanceof in this respect
637 return JNI_TRUE;
638 } else {
639 // TODO: retrieve handle value for object
640 Object* obj = reinterpret_cast<Object*>(jobj);
641 // TODO: retrieve handle value for class
642 Class* klass = reinterpret_cast<Class*>(clazz);
643 return Object::InstanceOf(obj, klass) ? JNI_TRUE : JNI_FALSE;
644 }
Carl Shapiroea4dca82011-08-01 13:45:38 -0700645}
646
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700647jmethodID GetMethodID(JNIEnv* env,
648 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700649 ScopedJniThreadState ts(env);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700650 // TODO: retrieve handle value for class
651 Class* klass = reinterpret_cast<Class*>(clazz);
652 if (!klass->IsInitialized()) {
653 // TODO: initialize the class
654 }
655 Method* method = klass->FindVirtualMethod(name, sig);
656 if (method == NULL) {
657 // No virtual method matching the signature. Search declared
658 // private methods and constructors.
659 method = klass->FindDeclaredDirectMethod(name, sig);
660 }
Ian Rogers4dd71f12011-08-16 14:16:02 -0700661 if (method == NULL) {
662 Thread* self = Thread::Current();
663 std::string class_name = klass->GetDescriptor().ToString();
664 // TODO: pretty print method names through a single routine
665 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
666 "no method \"%s.%s%s\"",
667 class_name.c_str(), name, sig);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700668 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -0700669 } else if (method->IsStatic()) {
670 Thread* self = Thread::Current();
671 std::string class_name = klass->GetDescriptor().ToString();
672 // TODO: pretty print method names through a single routine
673 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
674 "method \"%s.%s%s\" is static",
675 class_name.c_str(), name, sig);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700676 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -0700677 } else {
678 // TODO: create a JNI weak global reference for method
679 bool success = EnsureInvokeStub(method);
680 if (!success) {
681 // TODO: throw OutOfMemoryException
682 return NULL;
683 }
684 return reinterpret_cast<jmethodID>(method);
Carl Shapiro83ab4f32011-08-15 20:21:39 -0700685 }
Carl Shapiroea4dca82011-08-01 13:45:38 -0700686}
687
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700688jobject CallObjectMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700689 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700690 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700691 return NULL;
692}
693
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700694jobject CallObjectMethodV(JNIEnv* env,
695 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700696 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700697 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700698 return NULL;
699}
700
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700701jobject CallObjectMethodA(JNIEnv* env,
702 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700703 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700704 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700705 return NULL;
706}
707
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700708jboolean CallBooleanMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700709 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700710 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700711 return JNI_FALSE;
712}
713
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700714jboolean CallBooleanMethodV(JNIEnv* env,
715 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700716 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700717 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700718 return JNI_FALSE;
719}
720
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700721jboolean CallBooleanMethodA(JNIEnv* env,
722 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700723 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700724 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700725 return JNI_FALSE;
726}
727
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700728jbyte CallByteMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700729 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700730 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700731 return 0;
732}
733
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700734jbyte CallByteMethodV(JNIEnv* env,
735 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700736 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700737 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700738 return 0;
739}
740
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700741jbyte CallByteMethodA(JNIEnv* env,
742 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700743 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700744 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700745 return 0;
746}
747
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700748jchar CallCharMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700749 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700750 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700751 return 0;
752}
753
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700754jchar CallCharMethodV(JNIEnv* env,
755 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700756 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700757 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700758 return 0;
759}
760
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700761jchar CallCharMethodA(JNIEnv* env,
762 jobject obj, jmethodID methodID, jvalue* args) {
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 0;
766}
767
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700768jshort CallShortMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
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 -0700774jshort CallShortMethodV(JNIEnv* env,
775 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700776 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700777 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700778 return 0;
779}
780
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700781jshort CallShortMethodA(JNIEnv* env,
782 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700783 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700784 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700785 return 0;
786}
787
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700788jint CallIntMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700789 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700790 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700791 return 0;
792}
793
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700794jint CallIntMethodV(JNIEnv* env,
795 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700796 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700797 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700798 return 0;
799}
800
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700801jint CallIntMethodA(JNIEnv* env,
802 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700803 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700804 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700805 return 0;
806}
807
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700808jlong CallLongMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700809 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700810 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700811 return 0;
812}
813
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700814jlong CallLongMethodV(JNIEnv* env,
815 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700816 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700817 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700818 return 0;
819}
820
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700821jlong CallLongMethodA(JNIEnv* env,
822 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700823 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700824 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700825 return 0;
826}
827
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700828jfloat CallFloatMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700829 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700830 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700831 return 0;
832}
833
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700834jfloat CallFloatMethodV(JNIEnv* env,
835 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700836 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700837 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700838 return 0;
839}
840
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700841jfloat CallFloatMethodA(JNIEnv* env,
842 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700843 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700844 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700845 return 0;
846}
847
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700848jdouble CallDoubleMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700849 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700850 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700851 return 0;
852}
853
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700854jdouble CallDoubleMethodV(JNIEnv* env,
855 jobject obj, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700856 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700857 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700858 return 0;
859}
860
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700861jdouble CallDoubleMethodA(JNIEnv* env,
862 jobject obj, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700863 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700864 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700865 return 0;
866}
867
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700868void CallVoidMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700869 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700870 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700871}
872
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700873void CallVoidMethodV(JNIEnv* env, jobject obj,
874 jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700875 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700876 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700877}
878
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700879void CallVoidMethodA(JNIEnv* env, jobject obj,
880 jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700881 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700882 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700883}
884
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700885jobject CallNonvirtualObjectMethod(JNIEnv* env,
886 jobject obj, jclass clazz, jmethodID methodID, ...) {
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 NULL;
890}
891
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700892jobject CallNonvirtualObjectMethodV(JNIEnv* env,
893 jobject obj, jclass clazz, jmethodID methodID, va_list 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 NULL;
897}
898
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700899jobject CallNonvirtualObjectMethodA(JNIEnv* env,
900 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700901 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700902 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700903 return NULL;
904}
905
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700906jboolean CallNonvirtualBooleanMethod(JNIEnv* env,
907 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700908 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700909 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700910 return JNI_FALSE;
911}
912
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700913jboolean CallNonvirtualBooleanMethodV(JNIEnv* env,
914 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700915 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700916 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700917 return JNI_FALSE;
918}
919
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700920jboolean CallNonvirtualBooleanMethodA(JNIEnv* env,
921 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700922 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700923 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700924 return JNI_FALSE;
925}
926
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700927jbyte CallNonvirtualByteMethod(JNIEnv* env,
928 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700929 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700930 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700931 return 0;
932}
933
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700934jbyte CallNonvirtualByteMethodV(JNIEnv* env,
935 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700936 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700937 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700938 return 0;
939}
940
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700941jbyte CallNonvirtualByteMethodA(JNIEnv* env,
942 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700943 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700944 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700945 return 0;
946}
947
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700948jchar CallNonvirtualCharMethod(JNIEnv* env,
949 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700950 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700951 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700952 return 0;
953}
954
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700955jchar CallNonvirtualCharMethodV(JNIEnv* env,
956 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700957 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700958 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700959 return 0;
960}
961
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700962jchar CallNonvirtualCharMethodA(JNIEnv* env,
963 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700964 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700965 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700966 return 0;
967}
968
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700969jshort CallNonvirtualShortMethod(JNIEnv* env,
970 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700971 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700972 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700973 return 0;
974}
975
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700976jshort CallNonvirtualShortMethodV(JNIEnv* env,
977 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700978 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700979 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700980 return 0;
981}
982
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700983jshort CallNonvirtualShortMethodA(JNIEnv* env,
984 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700985 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700986 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700987 return 0;
988}
989
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700990jint CallNonvirtualIntMethod(JNIEnv* env,
991 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700992 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -0700993 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -0700994 return 0;
995}
996
Elliott Hughes40ef99e2011-08-11 17:44:34 -0700997jint CallNonvirtualIntMethodV(JNIEnv* env,
998 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -0700999 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001000 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001001 return 0;
1002}
1003
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001004jint CallNonvirtualIntMethodA(JNIEnv* env,
1005 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001006 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001007 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001008 return 0;
1009}
1010
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001011jlong CallNonvirtualLongMethod(JNIEnv* env,
1012 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001013 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001014 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001015 return 0;
1016}
1017
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001018jlong CallNonvirtualLongMethodV(JNIEnv* env,
1019 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
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 -07001025jlong CallNonvirtualLongMethodA(JNIEnv* env,
1026 jobject obj, jclass clazz, jmethodID methodID, jvalue* 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 -07001032jfloat CallNonvirtualFloatMethod(JNIEnv* env,
1033 jobject obj, jclass clazz, jmethodID methodID, ...) {
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 -07001039jfloat CallNonvirtualFloatMethodV(JNIEnv* env,
1040 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001041 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001042 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001043 return 0;
1044}
1045
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001046jfloat CallNonvirtualFloatMethodA(JNIEnv* env,
1047 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001048 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001049 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001050 return 0;
1051}
1052
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001053jdouble CallNonvirtualDoubleMethod(JNIEnv* env,
1054 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001055 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001056 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001057 return 0;
1058}
1059
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001060jdouble CallNonvirtualDoubleMethodV(JNIEnv* env,
1061 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001062 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001063 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001064 return 0;
1065}
1066
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001067jdouble CallNonvirtualDoubleMethodA(JNIEnv* env,
1068 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001069 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001070 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001071 return 0;
1072}
1073
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001074void CallNonvirtualVoidMethod(JNIEnv* env,
1075 jobject obj, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001076 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001077 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001078}
1079
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001080void CallNonvirtualVoidMethodV(JNIEnv* env,
1081 jobject obj, jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001082 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001083 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001084}
1085
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001086void CallNonvirtualVoidMethodA(JNIEnv* env,
1087 jobject obj, jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001088 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001089 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001090}
1091
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001092jfieldID GetFieldID(JNIEnv* env,
1093 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001094 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001095 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001096 return NULL;
1097}
1098
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001099jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID) {
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 NULL;
1103}
1104
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001105jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001106 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001107 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001108 return JNI_FALSE;
1109}
1110
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001111jbyte GetByteField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001112 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001113 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001114 return 0;
1115}
1116
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001117jchar GetCharField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001118 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001119 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001120 return 0;
1121}
1122
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001123jshort GetShortField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001124 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001125 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001126 return 0;
1127}
1128
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001129jint GetIntField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001130 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001131 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001132 return 0;
1133}
1134
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001135jlong GetLongField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001136 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001137 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001138 return 0;
1139}
1140
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001141jfloat GetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID) {
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 -07001147jdouble GetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001148 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001149 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001150 return 0;
1151}
1152
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001153void SetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID, jobject val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001154 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001155 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001156}
1157
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001158void SetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID, jboolean val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001159 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001160 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001161}
1162
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001163void SetByteField(JNIEnv* env, jobject obj, jfieldID fieldID, jbyte val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001164 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001165 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001166}
1167
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001168void SetCharField(JNIEnv* env, jobject obj, jfieldID fieldID, jchar val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001169 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001170 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001171}
1172
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001173void SetShortField(JNIEnv* env, jobject obj, jfieldID fieldID, jshort val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001174 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001175 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001176}
1177
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001178void SetIntField(JNIEnv* env, jobject obj, jfieldID fieldID, jint val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001179 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001180 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001181}
1182
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001183void SetLongField(JNIEnv* env, jobject obj, jfieldID fieldID, jlong val) {
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}
1187
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001188void SetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID, jfloat val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001189 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001190 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001191}
1192
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001193void SetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID, jdouble val) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001194 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001195 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001196}
1197
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001198jmethodID GetStaticMethodID(JNIEnv* env,
1199 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001200 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001201 // TODO: DecodeReference
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001202 Class* klass = reinterpret_cast<Class*>(clazz);
Carl Shapiro83ab4f32011-08-15 20:21:39 -07001203 if (!klass->IsInitialized()) {
1204 // TODO: initialize the class
1205 }
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001206 Method* method = klass->FindDirectMethod(name, sig);
Ian Rogers4dd71f12011-08-16 14:16:02 -07001207 if (method == NULL) {
1208 Thread* self = Thread::Current();
1209 std::string class_name = klass->GetDescriptor().ToString();
1210 // TODO: pretty print method names through a single routine
1211 // TODO: may want to FindVirtualMethod to give more informative error
1212 // message here
1213 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
1214 "no method \"%s.%s%s\"",
1215 class_name.c_str(), name, sig);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001216 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -07001217 } else if (!method->IsStatic()) {
1218 Thread* self = Thread::Current();
1219 std::string class_name = klass->GetDescriptor().ToString();
1220 // TODO: pretty print method names through a single routine
1221 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
1222 "method \"%s.%s%s\" is not static",
1223 class_name.c_str(), name, sig);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001224 return NULL;
Ian Rogers4dd71f12011-08-16 14:16:02 -07001225 } else {
1226 // TODO: create a JNI weak global reference for method
1227 bool success = EnsureInvokeStub(method);
1228 if (!success) {
1229 // TODO: throw OutOfMemoryException
1230 return NULL;
1231 }
1232 return reinterpret_cast<jmethodID>(method);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001233 }
Carl Shapiroea4dca82011-08-01 13:45:38 -07001234}
1235
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001236jobject CallStaticObjectMethod(JNIEnv* env,
1237 jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001238 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001239 va_list ap;
1240 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001241 JValue result = InvokeWithVarArgs(ts.Self(), NULL, methodID, ap);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001242 return AddLocalReference<jobject>(ts, result.l);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001243}
1244
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001245jobject CallStaticObjectMethodV(JNIEnv* env,
1246 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001247 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001248 JValue result = InvokeWithVarArgs(ts.Self(), NULL, methodID, args);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001249 return AddLocalReference<jobject>(ts, result.l);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001250}
1251
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001252jobject CallStaticObjectMethodA(JNIEnv* env,
1253 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001254 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001255 JValue result = InvokeWithJValues(ts.Self(), NULL, methodID, args);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001256 return AddLocalReference<jobject>(ts, result.l);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001257}
1258
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001259jboolean CallStaticBooleanMethod(JNIEnv* env,
1260 jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001261 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001262 va_list ap;
1263 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001264 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).z;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001265}
1266
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001267jboolean CallStaticBooleanMethodV(JNIEnv* env,
1268 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001269 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001270 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).z;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001271}
1272
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001273jboolean CallStaticBooleanMethodA(JNIEnv* env,
1274 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001275 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001276 return InvokeWithJValues(ts.Self(), NULL, methodID, args).z;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001277}
1278
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001279jbyte CallStaticByteMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001280 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001281 va_list ap;
1282 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001283 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).b;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001284}
1285
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001286jbyte CallStaticByteMethodV(JNIEnv* env,
1287 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001288 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001289 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).b;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001290}
1291
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001292jbyte CallStaticByteMethodA(JNIEnv* env,
1293 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001294 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001295 return InvokeWithJValues(ts.Self(), NULL, methodID, args).b;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001296}
1297
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001298jchar CallStaticCharMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001299 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001300 va_list ap;
1301 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001302 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).c;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001303}
1304
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001305jchar CallStaticCharMethodV(JNIEnv* env,
1306 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001307 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001308 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).c;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001309}
1310
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001311jchar CallStaticCharMethodA(JNIEnv* env,
1312 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001313 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001314 return InvokeWithJValues(ts.Self(), NULL, methodID, args).c;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001315}
1316
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001317jshort CallStaticShortMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001318 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001319 va_list ap;
1320 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001321 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).s;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001322}
1323
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001324jshort CallStaticShortMethodV(JNIEnv* env,
1325 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001326 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001327 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).s;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001328}
1329
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001330jshort CallStaticShortMethodA(JNIEnv* env,
1331 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001332 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001333 return InvokeWithJValues(ts.Self(), NULL, methodID, args).s;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001334}
1335
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001336jint CallStaticIntMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001337 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001338 va_list ap;
1339 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001340 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).i;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001341}
1342
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001343jint CallStaticIntMethodV(JNIEnv* env,
1344 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001345 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001346 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).i;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001347}
1348
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001349jint CallStaticIntMethodA(JNIEnv* env,
1350 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001351 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001352 return InvokeWithJValues(ts.Self(), NULL, methodID, args).i;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001353}
1354
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001355jlong CallStaticLongMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001356 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001357 va_list ap;
1358 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001359 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).j;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001360}
1361
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001362jlong CallStaticLongMethodV(JNIEnv* env,
1363 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001364 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001365 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).j;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001366}
1367
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001368jlong CallStaticLongMethodA(JNIEnv* env,
1369 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001370 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001371 return InvokeWithJValues(ts.Self(), NULL, methodID, args).j;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001372}
1373
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001374jfloat CallStaticFloatMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001375 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001376 va_list ap;
1377 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001378 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).f;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001379}
1380
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001381jfloat CallStaticFloatMethodV(JNIEnv* env,
1382 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001383 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001384 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).f;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001385}
1386
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001387jfloat CallStaticFloatMethodA(JNIEnv* env,
1388 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001389 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001390 return InvokeWithJValues(ts.Self(), NULL, methodID, args).f;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001391}
1392
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001393jdouble CallStaticDoubleMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001394 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001395 va_list ap;
1396 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001397 return InvokeWithVarArgs(ts.Self(), NULL, methodID, ap).d;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001398}
1399
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001400jdouble CallStaticDoubleMethodV(JNIEnv* env,
1401 jclass clazz, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001402 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001403 return InvokeWithVarArgs(ts.Self(), NULL, methodID, args).d;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001404}
1405
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001406jdouble CallStaticDoubleMethodA(JNIEnv* env,
1407 jclass clazz, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001408 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001409 return InvokeWithJValues(ts.Self(), NULL, methodID, args).d;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001410}
1411
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001412void CallStaticVoidMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001413 ScopedJniThreadState ts(env);
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001414 va_list ap;
1415 va_start(ap, methodID);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001416 InvokeWithVarArgs(ts.Self(), NULL, methodID, ap);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001417}
1418
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001419void CallStaticVoidMethodV(JNIEnv* env,
1420 jclass cls, jmethodID methodID, va_list args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001421 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001422 InvokeWithVarArgs(ts.Self(), NULL, methodID, args);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001423}
1424
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001425void CallStaticVoidMethodA(JNIEnv* env,
Carl Shapiro9b9ba282011-08-14 15:30:39 -07001426 jclass cls, jmethodID methodID, jvalue* args) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001427 ScopedJniThreadState ts(env);
Elliott Hughes3cd987f2011-08-15 10:39:47 -07001428 InvokeWithJValues(ts.Self(), NULL, methodID, args);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001429}
1430
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001431jfieldID GetStaticFieldID(JNIEnv* env,
1432 jclass clazz, const char* name, const char* sig) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001433 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001434 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001435 return 0;
1436}
1437
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001438jobject GetStaticObjectField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001439 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001440 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001441 return NULL;
1442}
1443
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001444jboolean GetStaticBooleanField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001445 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001446 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001447 return JNI_FALSE;
1448}
1449
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001450jbyte GetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001451 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001452 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001453 return 0;
1454}
1455
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001456jchar GetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001457 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001458 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001459 return 0;
1460}
1461
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001462jshort GetStaticShortField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001463 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001464 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001465 return 0;
1466}
1467
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001468jint GetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001469 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001470 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001471 return 0;
1472}
1473
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001474jlong GetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001475 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001476 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001477 return 0;
1478}
1479
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001480jfloat GetStaticFloatField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001481 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001482 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001483 return 0;
1484}
1485
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001486jdouble GetStaticDoubleField(JNIEnv* env, jclass clazz, jfieldID fieldID) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001487 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001488 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001489 return 0;
1490}
1491
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001492void SetStaticObjectField(JNIEnv* env,
1493 jclass clazz, jfieldID fieldID, jobject value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001494 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001495 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001496}
1497
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001498void SetStaticBooleanField(JNIEnv* env,
1499 jclass clazz, jfieldID fieldID, jboolean value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001500 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001501 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001502}
1503
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001504void SetStaticByteField(JNIEnv* env,
1505 jclass clazz, jfieldID fieldID, jbyte value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001506 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001507 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001508}
1509
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001510void SetStaticCharField(JNIEnv* env,
1511 jclass clazz, jfieldID fieldID, jchar value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001512 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001513 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001514}
1515
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001516void SetStaticShortField(JNIEnv* env,
1517 jclass clazz, jfieldID fieldID, jshort value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001518 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001519 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001520}
1521
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001522void SetStaticIntField(JNIEnv* env,
1523 jclass clazz, jfieldID fieldID, jint value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001524 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001525 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001526}
1527
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001528void SetStaticLongField(JNIEnv* env,
1529 jclass clazz, jfieldID fieldID, jlong value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001530 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001531 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001532}
1533
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001534void SetStaticFloatField(JNIEnv* env,
1535 jclass clazz, jfieldID fieldID, jfloat value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001536 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001537 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001538}
1539
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001540void SetStaticDoubleField(JNIEnv* env,
1541 jclass clazz, jfieldID fieldID, jdouble value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001542 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001543 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001544}
1545
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001546jstring NewString(JNIEnv* env, const jchar* unicode, jsize len) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001547 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001548 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001549 return NULL;
1550}
1551
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001552jsize GetStringLength(JNIEnv* env, jstring str) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001553 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001554 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001555 return 0;
1556}
1557
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001558const jchar* GetStringChars(JNIEnv* env, jstring str, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001559 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001560 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001561 return NULL;
1562}
1563
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001564void ReleaseStringChars(JNIEnv* env, jstring str, const jchar* chars) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001565 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001566 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001567}
1568
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001569jstring NewStringUTF(JNIEnv* env, const char* utf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001570 ScopedJniThreadState ts(env);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001571 if (utf == NULL) {
1572 return NULL;
1573 }
1574 size_t char_count = String::ModifiedUtf8Len(utf);
1575 String* result = String::AllocFromModifiedUtf8(char_count, utf);
1576 return AddLocalReference<jstring>(ts, result);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001577}
1578
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001579jsize GetStringUTFLength(JNIEnv* env, jstring str) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001580 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001581 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001582 return 0;
1583}
1584
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001585const char* GetStringUTFChars(JNIEnv* env, jstring str, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001586 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001587 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001588 return NULL;
1589}
1590
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001591void ReleaseStringUTFChars(JNIEnv* env, jstring str, const char* chars) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001592 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001593 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001594}
1595
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001596jsize GetArrayLength(JNIEnv* env, jarray array) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001597 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001598 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001599 return 0;
1600}
1601
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001602jobject GetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index) {
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 NULL;
1606}
1607
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001608void SetObjectArrayElement(JNIEnv* env,
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001609 jobjectArray java_array, jsize index, jobject java_value) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001610 ScopedJniThreadState ts(env);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001611 // TODO: DecodeReference
1612 ObjectArray<Object>* array = reinterpret_cast<ObjectArray<Object>*>(java_array);
1613 Object* value = reinterpret_cast<Object*>(java_value);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001614 array->Set(index, value);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001615}
1616
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001617template<typename JniT, typename ArtT>
1618JniT NewPrimitiveArray(ScopedJniThreadState& ts, jsize length) {
1619 CHECK_GE(length, 0); // TODO: ReportJniError
1620 ArtT* result = ArtT::Alloc(length);
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001621 return AddLocalReference<JniT>(ts, result);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001622}
1623
Elliott Hughesf2682d52011-08-15 16:37:04 -07001624jbooleanArray NewBooleanArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001625 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001626 return NewPrimitiveArray<jbooleanArray, BooleanArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001627}
1628
Elliott Hughesf2682d52011-08-15 16:37:04 -07001629jbyteArray NewByteArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001630 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001631 return NewPrimitiveArray<jbyteArray, ByteArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001632}
1633
Elliott Hughesf2682d52011-08-15 16:37:04 -07001634jcharArray NewCharArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001635 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001636 return NewPrimitiveArray<jcharArray, CharArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001637}
1638
Elliott Hughesf2682d52011-08-15 16:37:04 -07001639jdoubleArray NewDoubleArray(JNIEnv* env, jsize length) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001640 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001641 return NewPrimitiveArray<jdoubleArray, DoubleArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001642}
1643
Elliott Hughesf2682d52011-08-15 16:37:04 -07001644jfloatArray NewFloatArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001645 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001646 return NewPrimitiveArray<jfloatArray, FloatArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001647}
1648
Elliott Hughesf2682d52011-08-15 16:37:04 -07001649jintArray NewIntArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001650 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001651 return NewPrimitiveArray<jintArray, IntArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001652}
1653
Elliott Hughesf2682d52011-08-15 16:37:04 -07001654jlongArray NewLongArray(JNIEnv* env, jsize length) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001655 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001656 return NewPrimitiveArray<jlongArray, LongArray>(ts, length);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001657}
1658
Elliott Hughesf2682d52011-08-15 16:37:04 -07001659jobjectArray NewObjectArray(JNIEnv* env, jsize length, jclass element_jclass, jobject initial_element) {
Elliott Hughesd8ddfd52011-08-15 14:32:53 -07001660 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001661 CHECK_GE(length, 0); // TODO: ReportJniError
1662
1663 // Compute the array class corresponding to the given element class.
1664 // TODO: DecodeReference
1665 Class* element_class = reinterpret_cast<Class*>(element_jclass);
1666 std::string descriptor;
1667 descriptor += "[";
1668 descriptor += element_class->GetDescriptor().ToString();
1669
1670 // Find the class.
1671 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
1672 // TODO: need to get the appropriate ClassLoader.
1673 Class* array_class = class_linker->FindClass(descriptor, NULL);
1674 if (array_class == NULL) {
1675 return NULL;
1676 }
1677
1678 ObjectArray<Object>* result = ObjectArray<Object>::Alloc(array_class, length);
1679 CHECK(initial_element == NULL); // TODO: support initial_element
Elliott Hughes8a26c5c2011-08-15 18:35:43 -07001680 return AddLocalReference<jobjectArray>(ts, result);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001681}
1682
1683jshortArray NewShortArray(JNIEnv* env, jsize length) {
1684 ScopedJniThreadState ts(env);
1685 return NewPrimitiveArray<jshortArray, ShortArray>(ts, length);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001686}
1687
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001688jboolean* GetBooleanArrayElements(JNIEnv* env,
1689 jbooleanArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001690 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001691 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001692 return NULL;
1693}
1694
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001695jbyte* GetByteArrayElements(JNIEnv* env, jbyteArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001696 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001697 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001698 return NULL;
1699}
1700
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001701jchar* GetCharArrayElements(JNIEnv* env, jcharArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001702 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001703 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001704 return NULL;
1705}
1706
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001707jshort* GetShortArrayElements(JNIEnv* env,
1708 jshortArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001709 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001710 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001711 return NULL;
1712}
1713
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001714jint* GetIntArrayElements(JNIEnv* env, jintArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001715 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001716 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001717 return NULL;
1718}
1719
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001720jlong* GetLongArrayElements(JNIEnv* env, jlongArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001721 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001722 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001723 return NULL;
1724}
1725
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001726jfloat* GetFloatArrayElements(JNIEnv* env,
1727 jfloatArray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001728 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001729 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001730 return NULL;
1731}
1732
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001733jdouble* GetDoubleArrayElements(JNIEnv* env,
1734 jdoubleArray array, jboolean* isCopy) {
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 return NULL;
1738}
1739
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001740void ReleaseBooleanArrayElements(JNIEnv* env,
1741 jbooleanArray array, jboolean* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001742 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001743 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001744}
1745
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001746void ReleaseByteArrayElements(JNIEnv* env,
1747 jbyteArray array, jbyte* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001748 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001749 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001750}
1751
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001752void ReleaseCharArrayElements(JNIEnv* env,
1753 jcharArray array, jchar* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001754 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001755 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001756}
1757
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001758void ReleaseShortArrayElements(JNIEnv* env,
1759 jshortArray array, jshort* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001760 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001761 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001762}
1763
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001764void ReleaseIntArrayElements(JNIEnv* env,
1765 jintArray array, jint* elems, jint mode) {
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}
1769
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001770void ReleaseLongArrayElements(JNIEnv* env,
1771 jlongArray array, jlong* elems, jint mode) {
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}
1775
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001776void ReleaseFloatArrayElements(JNIEnv* env,
1777 jfloatArray array, jfloat* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001778 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001779 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001780}
1781
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001782void ReleaseDoubleArrayElements(JNIEnv* env,
1783 jdoubleArray array, jdouble* elems, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001784 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001785 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001786}
1787
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001788void GetBooleanArrayRegion(JNIEnv* env,
1789 jbooleanArray array, jsize start, jsize l, jboolean* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001790 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001791 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001792}
1793
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001794void GetByteArrayRegion(JNIEnv* env,
1795 jbyteArray array, jsize start, jsize len, jbyte* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001796 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001797 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001798}
1799
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001800void GetCharArrayRegion(JNIEnv* env,
1801 jcharArray array, jsize start, jsize len, jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001802 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001803 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001804}
1805
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001806void GetShortArrayRegion(JNIEnv* env,
1807 jshortArray array, jsize start, jsize len, jshort* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001808 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001809 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001810}
1811
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001812void GetIntArrayRegion(JNIEnv* env,
1813 jintArray array, jsize start, jsize len, jint* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001814 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001815 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001816}
1817
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001818void GetLongArrayRegion(JNIEnv* env,
1819 jlongArray array, jsize start, jsize len, jlong* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001820 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001821 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001822}
1823
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001824void GetFloatArrayRegion(JNIEnv* env,
1825 jfloatArray array, jsize start, jsize len, jfloat* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001826 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001827 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001828}
1829
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001830void GetDoubleArrayRegion(JNIEnv* env,
1831 jdoubleArray array, jsize start, jsize len, jdouble* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001832 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001833 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001834}
1835
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001836void SetBooleanArrayRegion(JNIEnv* env,
1837 jbooleanArray array, jsize start, jsize l, const jboolean* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001838 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001839 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001840}
1841
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001842void SetByteArrayRegion(JNIEnv* env,
1843 jbyteArray array, jsize start, jsize len, const jbyte* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001844 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001845 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001846}
1847
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001848void SetCharArrayRegion(JNIEnv* env,
1849 jcharArray array, jsize start, jsize len, const jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001850 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001851 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001852}
1853
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001854void SetShortArrayRegion(JNIEnv* env,
1855 jshortArray array, jsize start, jsize len, const jshort* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001856 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001857 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001858}
1859
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001860void SetIntArrayRegion(JNIEnv* env,
1861 jintArray array, jsize start, jsize len, const jint* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001862 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001863 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001864}
1865
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001866void SetLongArrayRegion(JNIEnv* env,
1867 jlongArray array, jsize start, jsize len, const jlong* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001868 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001869 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001870}
1871
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001872void SetFloatArrayRegion(JNIEnv* env,
1873 jfloatArray array, jsize start, jsize len, const jfloat* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001874 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001875 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001876}
1877
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001878void SetDoubleArrayRegion(JNIEnv* env,
1879 jdoubleArray array, jsize start, jsize len, const jdouble* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001880 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001881 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001882}
1883
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001884jint RegisterNatives(JNIEnv* env,
1885 jclass clazz, const JNINativeMethod* methods, jint nMethods) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001886 ScopedJniThreadState ts(env);
Ian Rogers4dd71f12011-08-16 14:16:02 -07001887 // TODO: retrieve handle value for class
1888 Class* klass = reinterpret_cast<Class*>(clazz);
1889 for(int i = 0; i < nMethods; i++) {
1890 const char* name = methods[i].name;
1891 const char* sig = methods[i].signature;
Elliott Hughes0af55432011-08-17 18:37:28 -07001892
1893 if (*sig == '!') {
1894 // TODO: fast jni. it's too noisy to log all these.
1895 ++sig;
1896 }
1897
Ian Rogers4dd71f12011-08-16 14:16:02 -07001898 Method* method = klass->FindDirectMethod(name, sig);
1899 if (method == NULL) {
1900 method = klass->FindVirtualMethod(name, sig);
1901 }
1902 if (method == NULL) {
1903 Thread* self = Thread::Current();
1904 std::string class_name = klass->GetDescriptor().ToString();
1905 // TODO: pretty print method names through a single routine
1906 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
1907 "no method \"%s.%s%s\"",
1908 class_name.c_str(), name, sig);
1909 return JNI_ERR;
1910 } else if (!method->IsNative()) {
1911 Thread* self = Thread::Current();
1912 std::string class_name = klass->GetDescriptor().ToString();
1913 // TODO: pretty print method names through a single routine
1914 self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
1915 "method \"%s.%s%s\" is not native",
1916 class_name.c_str(), name, sig);
1917 return JNI_ERR;
1918 }
1919 method->RegisterNative(methods[i].fnPtr);
1920 }
1921 return JNI_OK;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001922}
1923
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001924jint UnregisterNatives(JNIEnv* env, jclass clazz) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001925 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001926 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001927 return 0;
1928}
1929
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001930jint MonitorEnter(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001931 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001932 UNIMPLEMENTED(WARNING);
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001933 return 0;
1934}
1935
1936jint MonitorExit(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001937 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001938 UNIMPLEMENTED(WARNING);
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001939 return 0;
1940}
1941
Elliott Hughesb20a5542011-08-12 18:03:12 -07001942jint GetJavaVM(JNIEnv* env, JavaVM** vm) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001943 ScopedJniThreadState ts(env);
Elliott Hughesf2682d52011-08-15 16:37:04 -07001944 Runtime* runtime = Runtime::Current();
1945 if (runtime != NULL) {
Elliott Hughes0af55432011-08-17 18:37:28 -07001946 *vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Elliott Hughesf2682d52011-08-15 16:37:04 -07001947 } else {
1948 *vm = NULL;
1949 }
1950 return (*vm != NULL) ? JNI_OK : JNI_ERR;
Carl Shapiroea4dca82011-08-01 13:45:38 -07001951}
1952
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001953void GetStringRegion(JNIEnv* env,
1954 jstring str, jsize start, jsize len, jchar* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001955 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001956 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001957}
1958
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001959void GetStringUTFRegion(JNIEnv* env,
1960 jstring str, jsize start, jsize len, char* buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001961 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001962 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001963}
1964
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001965void* GetPrimitiveArrayCritical(JNIEnv* env,
1966 jarray array, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001967 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001968 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001969 return NULL;
1970}
1971
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001972void ReleasePrimitiveArrayCritical(JNIEnv* env,
1973 jarray array, void* carray, jint mode) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001974 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001975 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001976}
1977
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001978const jchar* GetStringCritical(JNIEnv* env, jstring s, jboolean* isCopy) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001979 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001980 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001981 return NULL;
1982}
1983
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001984void ReleaseStringCritical(JNIEnv* env, jstring s, const jchar* cstr) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001985 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001986 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001987}
1988
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001989jweak NewWeakGlobalRef(JNIEnv* env, jobject obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001990 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001991 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001992 return NULL;
1993}
1994
Elliott Hughes40ef99e2011-08-11 17:44:34 -07001995void DeleteWeakGlobalRef(JNIEnv* env, jweak obj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07001996 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07001997 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07001998}
1999
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002000jboolean ExceptionCheck(JNIEnv* env) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002001 ScopedJniThreadState ts(env);
Elliott Hughesb20a5542011-08-12 18:03:12 -07002002 return ts.Self()->IsExceptionPending() ? JNI_TRUE : JNI_FALSE;
Carl Shapiroea4dca82011-08-01 13:45:38 -07002003}
2004
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002005jobject NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002006 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002007 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002008 return NULL;
2009}
2010
2011
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002012void* GetDirectBufferAddress(JNIEnv* env, jobject buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002013 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002014 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002015 return NULL;
2016}
2017
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002018jlong GetDirectBufferCapacity(JNIEnv* env, jobject buf) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002019 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002020 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002021 return 0;
2022}
2023
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002024jobjectRefType GetObjectRefType(JNIEnv* env, jobject jobj) {
Elliott Hughes22f40932011-08-12 13:06:37 -07002025 ScopedJniThreadState ts(env);
Elliott Hughesc7ac37f2011-08-12 12:21:58 -07002026 UNIMPLEMENTED(FATAL);
Carl Shapiroea4dca82011-08-01 13:45:38 -07002027 return JNIInvalidRefType;
2028}
2029
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002030static const struct JNINativeInterface gNativeInterface = {
Carl Shapiroea4dca82011-08-01 13:45:38 -07002031 NULL, // reserved0.
2032 NULL, // reserved1.
2033 NULL, // reserved2.
2034 NULL, // reserved3.
2035 GetVersion,
2036 DefineClass,
2037 FindClass,
2038 FromReflectedMethod,
2039 FromReflectedField,
2040 ToReflectedMethod,
2041 GetSuperclass,
2042 IsAssignableFrom,
2043 ToReflectedField,
2044 Throw,
2045 ThrowNew,
2046 ExceptionOccurred,
2047 ExceptionDescribe,
2048 ExceptionClear,
2049 FatalError,
2050 PushLocalFrame,
2051 PopLocalFrame,
2052 NewGlobalRef,
2053 DeleteGlobalRef,
2054 DeleteLocalRef,
2055 IsSameObject,
2056 NewLocalRef,
2057 EnsureLocalCapacity,
2058 AllocObject,
2059 NewObject,
2060 NewObjectV,
2061 NewObjectA,
2062 GetObjectClass,
2063 IsInstanceOf,
2064 GetMethodID,
2065 CallObjectMethod,
2066 CallObjectMethodV,
2067 CallObjectMethodA,
2068 CallBooleanMethod,
2069 CallBooleanMethodV,
2070 CallBooleanMethodA,
2071 CallByteMethod,
2072 CallByteMethodV,
2073 CallByteMethodA,
2074 CallCharMethod,
2075 CallCharMethodV,
2076 CallCharMethodA,
2077 CallShortMethod,
2078 CallShortMethodV,
2079 CallShortMethodA,
2080 CallIntMethod,
2081 CallIntMethodV,
2082 CallIntMethodA,
2083 CallLongMethod,
2084 CallLongMethodV,
2085 CallLongMethodA,
2086 CallFloatMethod,
2087 CallFloatMethodV,
2088 CallFloatMethodA,
2089 CallDoubleMethod,
2090 CallDoubleMethodV,
2091 CallDoubleMethodA,
2092 CallVoidMethod,
2093 CallVoidMethodV,
2094 CallVoidMethodA,
2095 CallNonvirtualObjectMethod,
2096 CallNonvirtualObjectMethodV,
2097 CallNonvirtualObjectMethodA,
2098 CallNonvirtualBooleanMethod,
2099 CallNonvirtualBooleanMethodV,
2100 CallNonvirtualBooleanMethodA,
2101 CallNonvirtualByteMethod,
2102 CallNonvirtualByteMethodV,
2103 CallNonvirtualByteMethodA,
2104 CallNonvirtualCharMethod,
2105 CallNonvirtualCharMethodV,
2106 CallNonvirtualCharMethodA,
2107 CallNonvirtualShortMethod,
2108 CallNonvirtualShortMethodV,
2109 CallNonvirtualShortMethodA,
2110 CallNonvirtualIntMethod,
2111 CallNonvirtualIntMethodV,
2112 CallNonvirtualIntMethodA,
2113 CallNonvirtualLongMethod,
2114 CallNonvirtualLongMethodV,
2115 CallNonvirtualLongMethodA,
2116 CallNonvirtualFloatMethod,
2117 CallNonvirtualFloatMethodV,
2118 CallNonvirtualFloatMethodA,
2119 CallNonvirtualDoubleMethod,
2120 CallNonvirtualDoubleMethodV,
2121 CallNonvirtualDoubleMethodA,
2122 CallNonvirtualVoidMethod,
2123 CallNonvirtualVoidMethodV,
2124 CallNonvirtualVoidMethodA,
2125 GetFieldID,
2126 GetObjectField,
2127 GetBooleanField,
2128 GetByteField,
2129 GetCharField,
2130 GetShortField,
2131 GetIntField,
2132 GetLongField,
2133 GetFloatField,
2134 GetDoubleField,
2135 SetObjectField,
2136 SetBooleanField,
2137 SetByteField,
2138 SetCharField,
2139 SetShortField,
2140 SetIntField,
2141 SetLongField,
2142 SetFloatField,
2143 SetDoubleField,
2144 GetStaticMethodID,
2145 CallStaticObjectMethod,
2146 CallStaticObjectMethodV,
2147 CallStaticObjectMethodA,
2148 CallStaticBooleanMethod,
2149 CallStaticBooleanMethodV,
2150 CallStaticBooleanMethodA,
2151 CallStaticByteMethod,
2152 CallStaticByteMethodV,
2153 CallStaticByteMethodA,
2154 CallStaticCharMethod,
2155 CallStaticCharMethodV,
2156 CallStaticCharMethodA,
2157 CallStaticShortMethod,
2158 CallStaticShortMethodV,
2159 CallStaticShortMethodA,
2160 CallStaticIntMethod,
2161 CallStaticIntMethodV,
2162 CallStaticIntMethodA,
2163 CallStaticLongMethod,
2164 CallStaticLongMethodV,
2165 CallStaticLongMethodA,
2166 CallStaticFloatMethod,
2167 CallStaticFloatMethodV,
2168 CallStaticFloatMethodA,
2169 CallStaticDoubleMethod,
2170 CallStaticDoubleMethodV,
2171 CallStaticDoubleMethodA,
2172 CallStaticVoidMethod,
2173 CallStaticVoidMethodV,
2174 CallStaticVoidMethodA,
2175 GetStaticFieldID,
2176 GetStaticObjectField,
2177 GetStaticBooleanField,
2178 GetStaticByteField,
2179 GetStaticCharField,
2180 GetStaticShortField,
2181 GetStaticIntField,
2182 GetStaticLongField,
2183 GetStaticFloatField,
2184 GetStaticDoubleField,
2185 SetStaticObjectField,
2186 SetStaticBooleanField,
2187 SetStaticByteField,
2188 SetStaticCharField,
2189 SetStaticShortField,
2190 SetStaticIntField,
2191 SetStaticLongField,
2192 SetStaticFloatField,
2193 SetStaticDoubleField,
2194 NewString,
2195 GetStringLength,
2196 GetStringChars,
2197 ReleaseStringChars,
2198 NewStringUTF,
2199 GetStringUTFLength,
2200 GetStringUTFChars,
2201 ReleaseStringUTFChars,
2202 GetArrayLength,
2203 NewObjectArray,
2204 GetObjectArrayElement,
2205 SetObjectArrayElement,
2206 NewBooleanArray,
2207 NewByteArray,
2208 NewCharArray,
2209 NewShortArray,
2210 NewIntArray,
2211 NewLongArray,
2212 NewFloatArray,
2213 NewDoubleArray,
2214 GetBooleanArrayElements,
2215 GetByteArrayElements,
2216 GetCharArrayElements,
2217 GetShortArrayElements,
2218 GetIntArrayElements,
2219 GetLongArrayElements,
2220 GetFloatArrayElements,
2221 GetDoubleArrayElements,
2222 ReleaseBooleanArrayElements,
2223 ReleaseByteArrayElements,
2224 ReleaseCharArrayElements,
2225 ReleaseShortArrayElements,
2226 ReleaseIntArrayElements,
2227 ReleaseLongArrayElements,
2228 ReleaseFloatArrayElements,
2229 ReleaseDoubleArrayElements,
2230 GetBooleanArrayRegion,
2231 GetByteArrayRegion,
2232 GetCharArrayRegion,
2233 GetShortArrayRegion,
2234 GetIntArrayRegion,
2235 GetLongArrayRegion,
2236 GetFloatArrayRegion,
2237 GetDoubleArrayRegion,
2238 SetBooleanArrayRegion,
2239 SetByteArrayRegion,
2240 SetCharArrayRegion,
2241 SetShortArrayRegion,
2242 SetIntArrayRegion,
2243 SetLongArrayRegion,
2244 SetFloatArrayRegion,
2245 SetDoubleArrayRegion,
2246 RegisterNatives,
2247 UnregisterNatives,
2248 MonitorEnter,
2249 MonitorExit,
2250 GetJavaVM,
2251 GetStringRegion,
2252 GetStringUTFRegion,
2253 GetPrimitiveArrayCritical,
2254 ReleasePrimitiveArrayCritical,
2255 GetStringCritical,
2256 ReleaseStringCritical,
2257 NewWeakGlobalRef,
2258 DeleteWeakGlobalRef,
2259 ExceptionCheck,
2260 NewDirectByteBuffer,
2261 GetDirectBufferAddress,
2262 GetDirectBufferCapacity,
2263 GetObjectRefType,
2264};
2265
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002266static const size_t kMonitorsInitial = 32; // Arbitrary.
2267static const size_t kMonitorsMax = 4096; // Arbitrary sanity check.
2268
2269static const size_t kLocalsInitial = 64; // Arbitrary.
2270static const size_t kLocalsMax = 512; // Arbitrary sanity check.
Elliott Hughesbbd76712011-08-17 10:25:24 -07002271
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002272JNIEnvExt::JNIEnvExt(Thread* self, bool check_jni)
Elliott Hughesbbd76712011-08-17 10:25:24 -07002273 : fns(&gNativeInterface),
2274 self(self),
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002275 check_jni(check_jni),
Elliott Hughesbbd76712011-08-17 10:25:24 -07002276 critical(false),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002277 monitors("monitors", kMonitorsInitial, kMonitorsMax),
2278 locals(kLocalsInitial, kLocalsMax, kLocal) {
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002279}
2280
Carl Shapiroea4dca82011-08-01 13:45:38 -07002281// JNI Invocation interface.
2282
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002283extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, void** p_env, void* vm_args) {
2284 const JavaVMInitArgs* args = static_cast<JavaVMInitArgs*>(vm_args);
2285 if (args->version < JNI_VERSION_1_2) {
2286 return JNI_EVERSION;
2287 }
2288 Runtime::Options options;
2289 for (int i = 0; i < args->nOptions; ++i) {
2290 JavaVMOption* option = &args->options[i];
Carl Shapirofc322c72011-07-27 00:20:01 -07002291 options.push_back(std::make_pair(StringPiece(option->optionString),
2292 option->extraInfo));
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002293 }
2294 bool ignore_unrecognized = args->ignoreUnrecognized;
Elliott Hughesf2682d52011-08-15 16:37:04 -07002295 Runtime* runtime = Runtime::Create(options, ignore_unrecognized);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002296 if (runtime == NULL) {
2297 return JNI_ERR;
2298 } else {
2299 *p_env = reinterpret_cast<JNIEnv*>(Thread::Current()->GetJniEnv());
Elliott Hughes0af55432011-08-17 18:37:28 -07002300 *p_vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002301 return JNI_OK;
2302 }
2303}
2304
Elliott Hughesf2682d52011-08-15 16:37:04 -07002305extern "C" jint JNI_GetCreatedJavaVMs(JavaVM** vms, jsize, jsize* vm_count) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002306 Runtime* runtime = Runtime::Current();
2307 if (runtime == NULL) {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002308 *vm_count = 0;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002309 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002310 *vm_count = 1;
Elliott Hughes0af55432011-08-17 18:37:28 -07002311 vms[0] = reinterpret_cast<JavaVM*>(runtime->GetJavaVM());
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002312 }
2313 return JNI_OK;
2314}
2315
2316// Historically unsupported.
2317extern "C" jint JNI_GetDefaultJavaVMInitArgs(void* vm_args) {
2318 return JNI_ERR;
2319}
2320
Elliott Hughesf2682d52011-08-15 16:37:04 -07002321jint DestroyJavaVM(JavaVM* vm) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002322 if (vm == NULL) {
2323 return JNI_ERR;
2324 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002325 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2326 delete raw_vm->runtime;
2327 raw_vm->runtime = NULL;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002328 return JNI_OK;
2329 }
2330}
2331
Elliott Hughesf2682d52011-08-15 16:37:04 -07002332jint AttachCurrentThread(JavaVM* vm, JNIEnv** p_env, void* thr_args) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002333 if (vm == NULL || p_env == NULL) {
2334 return JNI_ERR;
2335 }
Elliott Hughesf2682d52011-08-15 16:37:04 -07002336 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2337 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002338 const char* name = NULL;
2339 if (thr_args != NULL) {
2340 // TODO: check version
2341 name = static_cast<JavaVMAttachArgs*>(thr_args)->name;
2342 // TODO: thread group
2343 }
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002344 bool success = runtime->AttachCurrentThread(name, p_env);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002345 if (!success) {
2346 return JNI_ERR;
2347 } else {
2348 return JNI_OK;
2349 }
2350}
2351
Elliott Hughesf2682d52011-08-15 16:37:04 -07002352jint DetachCurrentThread(JavaVM* vm) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002353 if (vm == NULL) {
2354 return JNI_ERR;
2355 } else {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002356 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2357 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002358 runtime->DetachCurrentThread();
2359 return JNI_OK;
2360 }
2361}
2362
Elliott Hughesf2682d52011-08-15 16:37:04 -07002363jint GetEnv(JavaVM* vm, void** env, jint version) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002364 if (version < JNI_VERSION_1_1 || version > JNI_VERSION_1_6) {
2365 return JNI_EVERSION;
2366 }
2367 if (vm == NULL || env == NULL) {
2368 return JNI_ERR;
2369 }
2370 Thread* thread = Thread::Current();
2371 if (thread == NULL) {
2372 *env = NULL;
2373 return JNI_EDETACHED;
2374 }
2375 *env = thread->GetJniEnv();
2376 return JNI_OK;
2377}
2378
Elliott Hughesf2682d52011-08-15 16:37:04 -07002379jint AttachCurrentThreadAsDaemon(JavaVM* vm, JNIEnv** p_env, void* thr_args) {
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002380 if (vm == NULL || p_env == NULL) {
2381 return JNI_ERR;
2382 }
Elliott Hughesf2682d52011-08-15 16:37:04 -07002383 JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
2384 Runtime* runtime = raw_vm->runtime;
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002385 const char* name = NULL;
2386 if (thr_args != NULL) {
2387 // TODO: check version
2388 name = static_cast<JavaVMAttachArgs*>(thr_args)->name;
2389 // TODO: thread group
2390 }
Elliott Hughes40ef99e2011-08-11 17:44:34 -07002391 bool success = runtime->AttachCurrentThreadAsDaemon(name, p_env);
Carl Shapiro2ed144c2011-07-26 16:52:08 -07002392 if (!success) {
2393 return JNI_ERR;
2394 } else {
2395 return JNI_OK;
2396 }
2397}
2398
Elliott Hughesf2682d52011-08-15 16:37:04 -07002399struct JNIInvokeInterface gInvokeInterface = {
Carl Shapiroea4dca82011-08-01 13:45:38 -07002400 NULL, // reserved0
2401 NULL, // reserved1
2402 NULL, // reserved2
2403 DestroyJavaVM,
2404 AttachCurrentThread,
2405 DetachCurrentThread,
2406 GetEnv,
2407 AttachCurrentThreadAsDaemon
2408};
2409
Elliott Hughesbbd76712011-08-17 10:25:24 -07002410static const size_t kPinTableInitialSize = 16;
2411static const size_t kPinTableMaxSize = 1024;
2412
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002413static const size_t kGlobalsInitial = 512; // Arbitrary.
2414static const size_t kGlobalsMax = 51200; // Arbitrary sanity check.
2415
2416static const size_t kWeakGlobalsInitial = 16; // Arbitrary.
2417static const size_t kWeakGlobalsMax = 51200; // Arbitrary sanity check.
2418
Elliott Hughes0af55432011-08-17 18:37:28 -07002419JavaVMExt::JavaVMExt(Runtime* runtime, bool check_jni, bool verbose_jni)
Elliott Hughesbbd76712011-08-17 10:25:24 -07002420 : fns(&gInvokeInterface),
2421 runtime(runtime),
Elliott Hughes515a5bc2011-08-17 11:08:34 -07002422 check_jni(check_jni),
Elliott Hughes0af55432011-08-17 18:37:28 -07002423 verbose_jni(verbose_jni),
Elliott Hughes6c1a3942011-08-17 15:00:06 -07002424 pin_table("pin table", kPinTableInitialSize, kPinTableMaxSize),
2425 globals(kGlobalsInitial, kGlobalsMax, kGlobal),
2426 weak_globals(kWeakGlobalsInitial, kWeakGlobalsMax, kWeakGlobal) {
Elliott Hughesf2682d52011-08-15 16:37:04 -07002427}
2428
Ian Rogersdf20fe02011-07-20 20:34:16 -07002429} // namespace art