Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 3 | #include "jni_internal.h" |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 4 | |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 5 | #include <cstdarg> |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 6 | #include <dlfcn.h> |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 7 | #include <sys/mman.h> |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 8 | #include <utility> |
| 9 | #include <vector> |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 10 | |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 11 | #include "assembler.h" |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 12 | #include "class_linker.h" |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 13 | #include "jni.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 14 | #include "logging.h" |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 15 | #include "object.h" |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 16 | #include "runtime.h" |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 17 | #include "scoped_ptr.h" |
| 18 | #include "stringpiece.h" |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 19 | #include "thread.h" |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 20 | |
| 21 | namespace art { |
| 22 | |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 23 | enum JNI_OnLoadState { |
| 24 | kPending = 0, /* initial state, must be zero */ |
| 25 | kFailed, |
| 26 | kOkay, |
| 27 | }; |
| 28 | |
| 29 | struct SharedLibrary { |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 30 | SharedLibrary() : jni_on_load_lock(Mutex::Create("JNI_OnLoad lock")) { |
| 31 | } |
| 32 | |
| 33 | ~SharedLibrary() { |
| 34 | delete jni_on_load_lock; |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | // Path to library "/system/lib/libjni.so". |
| 38 | std::string path; |
| 39 | |
| 40 | // The void* returned by dlopen(3). |
| 41 | void* handle; |
| 42 | |
| 43 | // The ClassLoader this library is associated with. |
| 44 | Object* class_loader; |
| 45 | |
| 46 | // Guards remaining items. |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 47 | Mutex* jni_on_load_lock; |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 48 | // Wait for JNI_OnLoad in other thread. |
| 49 | pthread_cond_t jni_on_load_cond; |
| 50 | // Recursive invocation guard. |
| 51 | uint32_t jni_on_load_tid; |
| 52 | // Result of earlier JNI_OnLoad call. |
| 53 | JNI_OnLoadState jni_on_load_result; |
| 54 | }; |
| 55 | |
| 56 | /* |
| 57 | * Check the result of an earlier call to JNI_OnLoad on this library. If |
| 58 | * the call has not yet finished in another thread, wait for it. |
| 59 | */ |
| 60 | bool CheckOnLoadResult(JavaVMExt* vm, SharedLibrary* library) { |
| 61 | Thread* self = Thread::Current(); |
| 62 | if (library->jni_on_load_tid == self->GetId()) { |
| 63 | // Check this so we don't end up waiting for ourselves. We need |
| 64 | // to return "true" so the caller can continue. |
| 65 | LOG(INFO) << *self << " recursive attempt to load library " |
| 66 | << "\"" << library->path << "\""; |
| 67 | return true; |
| 68 | } |
| 69 | |
| 70 | UNIMPLEMENTED(ERROR) << "need to pthread_cond_wait!"; |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 71 | // MutexLock mu(library->jni_on_load_lock); |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 72 | while (library->jni_on_load_result == kPending) { |
| 73 | if (vm->verbose_jni) { |
| 74 | LOG(INFO) << "[" << *self << " waiting for \"" << library->path << "\" " |
| 75 | << "JNI_OnLoad...]"; |
| 76 | } |
| 77 | Thread::State old_state = self->GetState(); |
| 78 | self->SetState(Thread::kWaiting); // TODO: VMWAIT |
| 79 | // pthread_cond_wait(&library->jni_on_load_cond, &library->jni_on_load_lock); |
| 80 | self->SetState(old_state); |
| 81 | } |
| 82 | |
| 83 | bool okay = (library->jni_on_load_result == kOkay); |
| 84 | if (vm->verbose_jni) { |
| 85 | LOG(INFO) << "[Earlier JNI_OnLoad for \"" << library->path << "\" " |
| 86 | << (okay ? "succeeded" : "failed") << "]"; |
| 87 | } |
| 88 | return okay; |
| 89 | } |
| 90 | |
| 91 | typedef int (*JNI_OnLoadFn)(JavaVM*, void*); |
| 92 | |
| 93 | /* |
| 94 | * Load native code from the specified absolute pathname. Per the spec, |
| 95 | * if we've already loaded a library with the specified pathname, we |
| 96 | * return without doing anything. |
| 97 | * |
| 98 | * TODO? for better results we should absolutify the pathname. For fully |
| 99 | * correct results we should stat to get the inode and compare that. The |
| 100 | * existing implementation is fine so long as everybody is using |
| 101 | * System.loadLibrary. |
| 102 | * |
| 103 | * The library will be associated with the specified class loader. The JNI |
| 104 | * spec says we can't load the same library into more than one class loader. |
| 105 | * |
| 106 | * Returns "true" on success. On failure, sets *detail to a |
| 107 | * human-readable description of the error or NULL if no detail is |
| 108 | * available; ownership of the string is transferred to the caller. |
| 109 | */ |
| 110 | bool JavaVMExt::LoadNativeLibrary(const std::string& path, Object* class_loader, char** detail) { |
| 111 | *detail = NULL; |
| 112 | |
| 113 | // See if we've already loaded this library. If we have, and the class loader |
| 114 | // matches, return successfully without doing anything. |
| 115 | SharedLibrary* library = libraries[path]; |
| 116 | if (library != NULL) { |
| 117 | if (library->class_loader != class_loader) { |
| 118 | LOG(WARNING) << "Shared library \"" << path << "\" already opened by " |
| 119 | << "ClassLoader " << library->class_loader << "; " |
| 120 | << "can't open in " << class_loader; |
| 121 | *detail = strdup("already opened by different ClassLoader"); |
| 122 | return false; |
| 123 | } |
| 124 | if (verbose_jni) { |
| 125 | LOG(INFO) << "[Shared library \"" << path << "\" already loaded in " |
| 126 | << "ClassLoader " << class_loader << "]"; |
| 127 | } |
| 128 | if (!CheckOnLoadResult(this, library)) { |
| 129 | *detail = strdup("JNI_OnLoad failed before"); |
| 130 | return false; |
| 131 | } |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | // Open the shared library. Because we're using a full path, the system |
| 136 | // doesn't have to search through LD_LIBRARY_PATH. (It may do so to |
| 137 | // resolve this library's dependencies though.) |
| 138 | |
| 139 | // Failures here are expected when java.library.path has several entries |
| 140 | // and we have to hunt for the lib. |
| 141 | |
| 142 | // The current version of the dynamic linker prints detailed information |
| 143 | // about dlopen() failures. Some things to check if the message is |
| 144 | // cryptic: |
| 145 | // - make sure the library exists on the device |
| 146 | // - verify that the right path is being opened (the debug log message |
| 147 | // above can help with that) |
| 148 | // - check to see if the library is valid (e.g. not zero bytes long) |
| 149 | // - check config/prelink-linux-arm.map to ensure that the library |
| 150 | // is listed and is not being overrun by the previous entry (if |
| 151 | // loading suddenly stops working on a prelinked library, this is |
| 152 | // a good one to check) |
| 153 | // - write a trivial app that calls sleep() then dlopen(), attach |
| 154 | // to it with "strace -p <pid>" while it sleeps, and watch for |
| 155 | // attempts to open nonexistent dependent shared libs |
| 156 | |
| 157 | // TODO: automate some of these checks! |
| 158 | |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 159 | // This can execute slowly for a large library on a busy system, so we |
| 160 | // want to switch from RUNNING to VMWAIT while it executes. This allows |
| 161 | // the GC to ignore us. |
| 162 | Thread* self = Thread::Current(); |
| 163 | Thread::State old_state = self->GetState(); |
| 164 | self->SetState(Thread::kWaiting); // TODO: VMWAIT |
| 165 | void* handle = dlopen(path.c_str(), RTLD_LAZY); |
| 166 | self->SetState(old_state); |
| 167 | |
| 168 | if (verbose_jni) { |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 169 | LOG(INFO) << "[Call to dlopen(\"" << path << "\") returned " << handle << "]"; |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | if (handle == NULL) { |
| 173 | *detail = strdup(dlerror()); |
| 174 | return false; |
| 175 | } |
| 176 | |
| 177 | // Create a new entry. |
| 178 | library = new SharedLibrary; |
| 179 | library->path = path; |
| 180 | library->handle = handle; |
| 181 | library->class_loader = class_loader; |
| 182 | UNIMPLEMENTED(ERROR) << "missing pthread_cond_init"; |
| 183 | // pthread_cond_init(&library->onLoadCond, NULL); |
| 184 | library->jni_on_load_tid = self->GetId(); |
| 185 | |
| 186 | libraries[path] = library; |
| 187 | |
| 188 | // if (pNewEntry != pActualEntry) { |
| 189 | // LOG(INFO) << "WOW: we lost a race to add a shared library (\"" << path << "\" ClassLoader=" << class_loader <<")"; |
| 190 | // freeSharedLibEntry(pNewEntry); |
| 191 | // return CheckOnLoadResult(this, pActualEntry); |
| 192 | // } else |
| 193 | { |
| 194 | if (verbose_jni) { |
| 195 | LOG(INFO) << "[Added shared library \"" << path << "\" for ClassLoader " << class_loader << "]"; |
| 196 | } |
| 197 | |
| 198 | bool result = true; |
| 199 | void* sym = dlsym(handle, "JNI_OnLoad"); |
| 200 | if (sym == NULL) { |
| 201 | if (verbose_jni) { |
| 202 | LOG(INFO) << "[No JNI_OnLoad found in \"" << path << "\"]"; |
| 203 | } |
| 204 | } else { |
| 205 | // Call JNI_OnLoad. We have to override the current class |
| 206 | // loader, which will always be "null" since the stuff at the |
| 207 | // top of the stack is around Runtime.loadLibrary(). (See |
| 208 | // the comments in the JNI FindClass function.) |
| 209 | UNIMPLEMENTED(WARNING) << "need to override current class loader"; |
| 210 | JNI_OnLoadFn jni_on_load = reinterpret_cast<JNI_OnLoadFn>(sym); |
| 211 | //Object* prevOverride = self->classLoaderOverride; |
| 212 | //self->classLoaderOverride = classLoader; |
| 213 | |
| 214 | old_state = self->GetState(); |
| 215 | self->SetState(Thread::kNative); |
| 216 | if (verbose_jni) { |
| 217 | LOG(INFO) << "[Calling JNI_OnLoad in \"" << path << "\"]"; |
| 218 | } |
| 219 | int version = (*jni_on_load)(reinterpret_cast<JavaVM*>(this), NULL); |
| 220 | self->SetState(old_state); |
| 221 | |
| 222 | UNIMPLEMENTED(WARNING) << "need to restore current class loader"; |
| 223 | //self->classLoaderOverride = prevOverride; |
| 224 | |
| 225 | if (version != JNI_VERSION_1_2 && |
| 226 | version != JNI_VERSION_1_4 && |
| 227 | version != JNI_VERSION_1_6) { |
| 228 | LOG(WARNING) << "JNI_OnLoad in \"" << path << "\" returned " |
| 229 | << "bad version: " << version; |
| 230 | // It's unwise to call dlclose() here, but we can mark it |
| 231 | // as bad and ensure that future load attempts will fail. |
| 232 | // We don't know how far JNI_OnLoad got, so there could |
| 233 | // be some partially-initialized stuff accessible through |
| 234 | // newly-registered native method calls. We could try to |
| 235 | // unregister them, but that doesn't seem worthwhile. |
| 236 | result = false; |
| 237 | } else { |
| 238 | if (verbose_jni) { |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 239 | LOG(INFO) << "[Returned " << (result ? "successfully" : "failure") |
| 240 | << " from JNI_OnLoad in \"" << path << "\"]"; |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | library->jni_on_load_result = result ? kOkay : kFailed; |
| 246 | library->jni_on_load_tid = 0; |
| 247 | |
| 248 | // Broadcast a wakeup to anybody sleeping on the condition variable. |
| 249 | UNIMPLEMENTED(ERROR) << "missing pthread_cond_broadcast"; |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 250 | // MutexLock mu(library->jni_on_load_lock); |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 251 | // pthread_cond_broadcast(&library->jni_on_load_cond); |
| 252 | return result; |
| 253 | } |
| 254 | } |
| 255 | |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 256 | // Entry/exit processing for all JNI calls. |
| 257 | // |
| 258 | // This performs the necessary thread state switching, lets us amortize the |
| 259 | // cost of working out the current thread, and lets us check (and repair) apps |
| 260 | // that are using a JNIEnv on the wrong thread. |
| 261 | class ScopedJniThreadState { |
| 262 | public: |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 263 | explicit ScopedJniThreadState(JNIEnv* env) |
| 264 | : env_(reinterpret_cast<JNIEnvExt*>(env)) { |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 265 | self_ = ThreadForEnv(env); |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 266 | self_->SetState(Thread::kRunnable); |
| 267 | } |
| 268 | |
| 269 | ~ScopedJniThreadState() { |
| 270 | self_->SetState(Thread::kNative); |
| 271 | } |
| 272 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 273 | JNIEnvExt* Env() { |
| 274 | return env_; |
| 275 | } |
| 276 | |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 277 | Thread* Self() { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 278 | return self_; |
| 279 | } |
| 280 | |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 281 | private: |
| 282 | static Thread* ThreadForEnv(JNIEnv* env) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 283 | // TODO: need replacement for gDvmJni. |
| 284 | bool workAroundAppJniBugs = true; |
| 285 | Thread* env_self = reinterpret_cast<JNIEnvExt*>(env)->self; |
| 286 | Thread* self = workAroundAppJniBugs ? Thread::Current() : env_self; |
| 287 | if (self != env_self) { |
Elliott Hughes | 330304d | 2011-08-12 14:28:05 -0700 | [diff] [blame] | 288 | LOG(ERROR) << "JNI ERROR: JNIEnv for " << *env_self |
| 289 | << " used on " << *self; |
| 290 | // TODO: dump stack |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 291 | } |
| 292 | return self; |
| 293 | } |
| 294 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 295 | JNIEnvExt* env_; |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 296 | Thread* self_; |
| 297 | DISALLOW_COPY_AND_ASSIGN(ScopedJniThreadState); |
| 298 | }; |
| 299 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 300 | /* |
| 301 | * Add a local reference for an object to the current stack frame. When |
| 302 | * the native function returns, the reference will be discarded. |
| 303 | * |
| 304 | * We need to allow the same reference to be added multiple times. |
| 305 | * |
| 306 | * This will be called on otherwise unreferenced objects. We cannot do |
| 307 | * GC allocations here, and it's best if we don't grab a mutex. |
| 308 | * |
| 309 | * Returns the local reference (currently just the same pointer that was |
| 310 | * passed in), or NULL on failure. |
| 311 | */ |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 312 | template<typename T> |
| 313 | T AddLocalReference(ScopedJniThreadState& ts, Object* obj) { |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 314 | if (obj == NULL) { |
| 315 | return NULL; |
| 316 | } |
| 317 | |
| 318 | IndirectReferenceTable& locals = ts.Env()->locals; |
| 319 | |
| 320 | uint32_t cookie = IRT_FIRST_SEGMENT; // TODO |
| 321 | IndirectRef ref = locals.Add(cookie, obj); |
| 322 | if (ref == NULL) { |
| 323 | // TODO: just change Add's DCHECK to CHECK and lose this? |
| 324 | locals.Dump(); |
| 325 | LOG(FATAL) << "Failed adding to JNI local reference table " |
| 326 | << "(has " << locals.Capacity() << " entries)"; |
| 327 | // TODO: dvmDumpThread(dvmThreadSelf(), false); |
| 328 | } |
| 329 | |
| 330 | #if 0 // TODO: fix this to understand PushLocalFrame, so we can turn it on. |
| 331 | if (ts.Env()->check_jni) { |
| 332 | size_t entry_count = locals.Capacity(); |
| 333 | if (entry_count > 16) { |
| 334 | std::string class_name(PrettyDescriptor(obj->GetClass()->GetDescriptor())); |
| 335 | LOG(WARNING) << "Warning: more than 16 JNI local references: " |
| 336 | << entry_count << " (most recent was a " << class_name << ")"; |
| 337 | locals.Dump(); |
| 338 | // TODO: dvmDumpThread(dvmThreadSelf(), false); |
| 339 | // dvmAbort(); |
| 340 | } |
| 341 | } |
| 342 | #endif |
| 343 | |
| 344 | if (false /*gDvmJni.workAroundAppJniBugs*/) { // TODO |
| 345 | // Hand out direct pointers to support broken old apps. |
| 346 | return reinterpret_cast<T>(obj); |
| 347 | } |
| 348 | |
| 349 | return reinterpret_cast<T>(ref); |
| 350 | } |
| 351 | |
| 352 | template<typename T> |
| 353 | T Decode(ScopedJniThreadState& ts, jobject obj) { |
| 354 | if (obj == NULL) { |
| 355 | return NULL; |
| 356 | } |
| 357 | |
| 358 | IndirectRef ref = reinterpret_cast<IndirectRef>(obj); |
| 359 | IndirectRefKind kind = GetIndirectRefKind(ref); |
| 360 | Object* result; |
| 361 | switch (kind) { |
| 362 | case kLocal: |
| 363 | { |
| 364 | IndirectReferenceTable& locals = ts.Env()->locals; |
| 365 | result = locals.Get(ref); |
| 366 | break; |
| 367 | } |
| 368 | case kGlobal: |
| 369 | { |
| 370 | JavaVMExt* vm = Runtime::Current()->GetJavaVM(); |
| 371 | IndirectReferenceTable& globals = vm->globals; |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 372 | MutexLock mu(vm->globals_lock); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 373 | result = globals.Get(ref); |
| 374 | break; |
| 375 | } |
| 376 | case kWeakGlobal: |
| 377 | { |
| 378 | JavaVMExt* vm = Runtime::Current()->GetJavaVM(); |
| 379 | IndirectReferenceTable& weak_globals = vm->weak_globals; |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 380 | MutexLock mu(vm->weak_globals_lock); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 381 | result = weak_globals.Get(ref); |
| 382 | if (result == kClearedJniWeakGlobal) { |
| 383 | // This is a special case where it's okay to return NULL. |
| 384 | return NULL; |
| 385 | } |
| 386 | break; |
| 387 | } |
| 388 | case kInvalid: |
| 389 | default: |
| 390 | if (false /*gDvmJni.workAroundAppJniBugs*/) { // TODO |
| 391 | // Assume an invalid local reference is actually a direct pointer. |
| 392 | return reinterpret_cast<T>(obj); |
| 393 | } |
| 394 | LOG(FATAL) << "Invalid indirect reference " << obj; |
| 395 | return reinterpret_cast<T>(kInvalidIndirectRefObject); |
| 396 | } |
| 397 | |
| 398 | if (result == NULL) { |
| 399 | LOG(FATAL) << "JNI ERROR (app bug): use of deleted " << kind << ": " |
| 400 | << obj; |
| 401 | } |
| 402 | return reinterpret_cast<T>(result); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 405 | void CreateInvokeStub(Assembler* assembler, Method* method); |
| 406 | |
| 407 | bool EnsureInvokeStub(Method* method) { |
| 408 | if (method->GetInvokeStub() != NULL) { |
| 409 | return true; |
| 410 | } |
| 411 | // TODO: use signature to find a matching stub |
| 412 | // TODO: failed, acquire a lock on the stub table |
| 413 | Assembler assembler; |
| 414 | CreateInvokeStub(&assembler, method); |
| 415 | // TODO: store native_entry in the stub table |
| 416 | int prot = PROT_READ | PROT_WRITE | PROT_EXEC; |
| 417 | size_t length = assembler.CodeSize(); |
| 418 | void* addr = mmap(NULL, length, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
| 419 | if (addr == MAP_FAILED) { |
| 420 | PLOG(FATAL) << "mmap failed"; |
| 421 | } |
| 422 | MemoryRegion region(addr, length); |
| 423 | assembler.FinalizeInstructions(region); |
| 424 | method->SetInvokeStub(reinterpret_cast<Method::InvokeStub*>(region.pointer())); |
| 425 | return true; |
| 426 | } |
| 427 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 428 | byte* CreateArgArray(ScopedJniThreadState& ts, Method* method, va_list ap) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 429 | size_t num_bytes = method->NumArgArrayBytes(); |
| 430 | scoped_array<byte> arg_array(new byte[num_bytes]); |
| 431 | const StringPiece& shorty = method->GetShorty(); |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 432 | for (int i = 1, offset = 0; i < shorty.size(); ++i) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 433 | switch (shorty[i]) { |
| 434 | case 'Z': |
| 435 | case 'B': |
| 436 | case 'C': |
| 437 | case 'S': |
| 438 | case 'I': |
| 439 | *reinterpret_cast<int32_t*>(&arg_array[offset]) = va_arg(ap, jint); |
| 440 | offset += 4; |
| 441 | break; |
| 442 | case 'F': |
| 443 | *reinterpret_cast<float*>(&arg_array[offset]) = va_arg(ap, jdouble); |
| 444 | offset += 4; |
| 445 | break; |
| 446 | case 'L': { |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 447 | Object* obj = Decode<Object*>(ts, va_arg(ap, jobject)); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 448 | *reinterpret_cast<Object**>(&arg_array[offset]) = obj; |
| 449 | offset += sizeof(Object*); |
| 450 | break; |
| 451 | } |
| 452 | case 'D': |
| 453 | *reinterpret_cast<double*>(&arg_array[offset]) = va_arg(ap, jdouble); |
| 454 | offset += 8; |
| 455 | break; |
| 456 | case 'J': |
| 457 | *reinterpret_cast<int64_t*>(&arg_array[offset]) = va_arg(ap, jlong); |
| 458 | offset += 8; |
| 459 | break; |
| 460 | } |
| 461 | } |
| 462 | return arg_array.release(); |
| 463 | } |
| 464 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 465 | byte* CreateArgArray(ScopedJniThreadState& ts, Method* method, jvalue* args) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 466 | size_t num_bytes = method->NumArgArrayBytes(); |
| 467 | scoped_array<byte> arg_array(new byte[num_bytes]); |
| 468 | const StringPiece& shorty = method->GetShorty(); |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 469 | for (int i = 1, offset = 0; i < shorty.size(); ++i) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 470 | switch (shorty[i]) { |
| 471 | case 'Z': |
| 472 | case 'B': |
| 473 | case 'C': |
| 474 | case 'S': |
| 475 | case 'I': |
| 476 | *reinterpret_cast<uint32_t*>(&arg_array[offset]) = args[i - 1].i; |
| 477 | offset += 4; |
| 478 | break; |
| 479 | case 'F': |
| 480 | *reinterpret_cast<float*>(&arg_array[offset]) = args[i - 1].f; |
| 481 | offset += 4; |
| 482 | break; |
| 483 | case 'L': { |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 484 | Object* obj = Decode<Object*>(ts, args[i - 1].l); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 485 | *reinterpret_cast<Object**>(&arg_array[offset]) = obj; |
| 486 | offset += sizeof(Object*); |
| 487 | break; |
| 488 | } |
| 489 | case 'D': |
| 490 | *reinterpret_cast<double*>(&arg_array[offset]) = args[i - 1].d; |
| 491 | offset += 8; |
| 492 | break; |
| 493 | case 'J': |
| 494 | *reinterpret_cast<uint64_t*>(&arg_array[offset]) = args[i - 1].j; |
| 495 | offset += 8; |
| 496 | break; |
| 497 | } |
| 498 | } |
| 499 | return arg_array.release(); |
| 500 | } |
| 501 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 502 | JValue InvokeWithArgArray(ScopedJniThreadState& ts, |
| 503 | Object* obj, jmethodID method_id, byte* args) { |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 504 | // TODO: DecodeReference |
| 505 | Method* method = reinterpret_cast<Method*>(method_id); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 506 | // Call the invoke stub associated with the method |
| 507 | // Pass everything as arguments |
| 508 | const Method::InvokeStub* stub = method->GetInvokeStub(); |
| 509 | CHECK(stub != NULL); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 510 | JValue result; |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 511 | (*stub)(method, obj, ts.Self(), args, &result); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 512 | return result; |
| 513 | } |
| 514 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 515 | JValue InvokeWithJValues(ScopedJniThreadState& ts, |
| 516 | Object* obj, jmethodID method_id, jvalue* args) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 517 | Method* method = reinterpret_cast<Method*>(method_id); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 518 | scoped_array<byte> arg_array(CreateArgArray(ts, method, args)); |
| 519 | return InvokeWithArgArray(ts, obj, method_id, arg_array.get()); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 520 | } |
| 521 | |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 522 | JValue InvokeWithVarArgs(ScopedJniThreadState& ts, |
| 523 | Object* obj, jmethodID method_id, va_list args) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 524 | Method* method = reinterpret_cast<Method*>(method_id); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 525 | scoped_array<byte> arg_array(CreateArgArray(ts, method, args)); |
| 526 | return InvokeWithArgArray(ts, obj, method_id, arg_array.get()); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 527 | } |
| 528 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 529 | jint GetVersion(JNIEnv* env) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 530 | ScopedJniThreadState ts(env); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 531 | return JNI_VERSION_1_6; |
| 532 | } |
| 533 | |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 534 | jclass DefineClass(JNIEnv* env, const char*, jobject, const jbyte*, jsize) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 535 | ScopedJniThreadState ts(env); |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 536 | LOG(WARNING) << "JNI DefineClass is not supported"; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 537 | return NULL; |
| 538 | } |
| 539 | |
Elliott Hughes | 6b43685 | 2011-08-12 10:16:44 -0700 | [diff] [blame] | 540 | // Section 12.3.2 of the JNI spec describes JNI class descriptors. They're |
| 541 | // separated with slashes but aren't wrapped with "L;" like regular descriptors |
| 542 | // (i.e. "a/b/C" rather than "La/b/C;"). Arrays of reference types are an |
| 543 | // exception; there the "L;" must be present ("[La/b/C;"). Historically we've |
| 544 | // supported names with dots too (such as "a.b.C"). |
| 545 | std::string NormalizeJniClassDescriptor(const char* name) { |
| 546 | std::string result; |
| 547 | // Add the missing "L;" if necessary. |
| 548 | if (name[0] == '[') { |
| 549 | result = name; |
| 550 | } else { |
| 551 | result += 'L'; |
| 552 | result += name; |
| 553 | result += ';'; |
| 554 | } |
| 555 | // Rewrite '.' as '/' for backwards compatibility. |
Elliott Hughes | a5b897e | 2011-08-16 11:33:06 -0700 | [diff] [blame] | 556 | if (result.find('.') != std::string::npos) { |
| 557 | LOG(WARNING) << "Call to JNI FindClass with dots in name: " |
| 558 | << "\"" << name << "\""; |
| 559 | std::replace(result.begin(), result.end(), '.', '/'); |
Elliott Hughes | 6b43685 | 2011-08-12 10:16:44 -0700 | [diff] [blame] | 560 | } |
| 561 | return result; |
| 562 | } |
| 563 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 564 | jclass FindClass(JNIEnv* env, const char* name) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 565 | ScopedJniThreadState ts(env); |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 566 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Elliott Hughes | 6b43685 | 2011-08-12 10:16:44 -0700 | [diff] [blame] | 567 | std::string descriptor(NormalizeJniClassDescriptor(name)); |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 568 | // TODO: need to get the appropriate ClassLoader. |
Elliott Hughes | 6b43685 | 2011-08-12 10:16:44 -0700 | [diff] [blame] | 569 | Class* c = class_linker->FindClass(descriptor, NULL); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 570 | return AddLocalReference<jclass>(ts, c); |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | jmethodID FromReflectedMethod(JNIEnv* env, jobject method) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 574 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 575 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 576 | return NULL; |
| 577 | } |
| 578 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 579 | jfieldID FromReflectedField(JNIEnv* env, jobject field) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 580 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 581 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 582 | return NULL; |
| 583 | } |
| 584 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 585 | jobject ToReflectedMethod(JNIEnv* env, jclass cls, |
| 586 | jmethodID methodID, jboolean isStatic) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 587 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 588 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 589 | return NULL; |
| 590 | } |
| 591 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 592 | jclass GetSuperclass(JNIEnv* env, jclass sub) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 593 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 594 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 595 | return NULL; |
| 596 | } |
| 597 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 598 | jboolean IsAssignableFrom(JNIEnv* env, jclass sub, jclass sup) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 599 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 600 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 601 | return JNI_FALSE; |
| 602 | } |
| 603 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 604 | jobject ToReflectedField(JNIEnv* env, jclass cls, |
| 605 | jfieldID fieldID, jboolean isStatic) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 606 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 607 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 608 | return NULL; |
| 609 | } |
| 610 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 611 | jint Throw(JNIEnv* env, jthrowable obj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 612 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 613 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 614 | return 0; |
| 615 | } |
| 616 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 617 | jint ThrowNew(JNIEnv* env, jclass clazz, const char* msg) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 618 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 619 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 620 | return 0; |
| 621 | } |
| 622 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 623 | jthrowable ExceptionOccurred(JNIEnv* env) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 624 | ScopedJniThreadState ts(env); |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 625 | Object* exception = ts.Self()->GetException(); |
| 626 | if (exception == NULL) { |
| 627 | return NULL; |
| 628 | } else { |
| 629 | // TODO: if adding a local reference failing causes the VM to abort |
| 630 | // then the following check will never occur. |
| 631 | jthrowable localException = AddLocalReference<jthrowable>(ts, exception); |
| 632 | if (localException == NULL) { |
| 633 | // We were unable to add a new local reference, and threw a new |
| 634 | // exception. We can't return "exception", because it's not a |
| 635 | // local reference. So we have to return NULL, indicating that |
| 636 | // there was no exception, even though it's pretty much raining |
| 637 | // exceptions in here. |
| 638 | LOG(WARNING) << "JNI WARNING: addLocal/exception combo"; |
| 639 | } |
| 640 | return localException; |
| 641 | } |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 642 | } |
| 643 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 644 | void ExceptionDescribe(JNIEnv* env) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 645 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 646 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 647 | } |
| 648 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 649 | void ExceptionClear(JNIEnv* env) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 650 | ScopedJniThreadState ts(env); |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 651 | ts.Self()->ClearException(); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 652 | } |
| 653 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 654 | void FatalError(JNIEnv* env, const char* msg) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 655 | ScopedJniThreadState ts(env); |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 656 | LOG(FATAL) << "JNI FatalError called: " << msg; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 657 | } |
| 658 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 659 | jint PushLocalFrame(JNIEnv* env, jint cap) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 660 | ScopedJniThreadState ts(env); |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 661 | UNIMPLEMENTED(WARNING) << "ignoring PushLocalFrame(" << cap << ")"; |
| 662 | return JNI_OK; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 663 | } |
| 664 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 665 | jobject PopLocalFrame(JNIEnv* env, jobject res) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 666 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 667 | UNIMPLEMENTED(WARNING) << "ignoring PopLocalFrame " << res; |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 668 | return res; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 669 | } |
| 670 | |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 671 | jobject NewGlobalRef(JNIEnv* env, jobject obj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 672 | ScopedJniThreadState ts(env); |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 673 | if (obj == NULL) { |
| 674 | return NULL; |
| 675 | } |
| 676 | |
| 677 | JavaVMExt* vm = Runtime::Current()->GetJavaVM(); |
| 678 | IndirectReferenceTable& globals = vm->globals; |
| 679 | MutexLock mu(vm->globals_lock); |
| 680 | IndirectRef ref = globals.Add(IRT_FIRST_SEGMENT, Decode<Object*>(ts, obj)); |
| 681 | return reinterpret_cast<jobject>(ref); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 682 | } |
| 683 | |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 684 | void DeleteGlobalRef(JNIEnv* env, jobject obj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 685 | ScopedJniThreadState ts(env); |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 686 | if (obj == NULL) { |
| 687 | return; |
| 688 | } |
| 689 | |
| 690 | JavaVMExt* vm = Runtime::Current()->GetJavaVM(); |
| 691 | IndirectReferenceTable& globals = vm->globals; |
| 692 | MutexLock mu(vm->globals_lock); |
| 693 | |
| 694 | if (!globals.Remove(IRT_FIRST_SEGMENT, obj)) { |
| 695 | LOG(WARNING) << "JNI WARNING: DeleteGlobalRef(" << obj << ") " |
| 696 | << "failed to find entry"; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | jweak NewWeakGlobalRef(JNIEnv* env, jobject obj) { |
| 701 | ScopedJniThreadState ts(env); |
| 702 | if (obj == NULL) { |
| 703 | return NULL; |
| 704 | } |
| 705 | |
| 706 | JavaVMExt* vm = Runtime::Current()->GetJavaVM(); |
| 707 | IndirectReferenceTable& weak_globals = vm->weak_globals; |
| 708 | MutexLock mu(vm->weak_globals_lock); |
| 709 | IndirectRef ref = weak_globals.Add(IRT_FIRST_SEGMENT, Decode<Object*>(ts, obj)); |
| 710 | return reinterpret_cast<jobject>(ref); |
| 711 | } |
| 712 | |
| 713 | void DeleteWeakGlobalRef(JNIEnv* env, jweak obj) { |
| 714 | ScopedJniThreadState ts(env); |
| 715 | if (obj == NULL) { |
| 716 | return; |
| 717 | } |
| 718 | |
| 719 | JavaVMExt* vm = Runtime::Current()->GetJavaVM(); |
| 720 | IndirectReferenceTable& weak_globals = vm->weak_globals; |
| 721 | MutexLock mu(vm->weak_globals_lock); |
| 722 | |
| 723 | if (!weak_globals.Remove(IRT_FIRST_SEGMENT, obj)) { |
| 724 | LOG(WARNING) << "JNI WARNING: DeleteWeakGlobalRef(" << obj << ") " |
| 725 | << "failed to find entry"; |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | jobject NewLocalRef(JNIEnv* env, jobject obj) { |
| 730 | ScopedJniThreadState ts(env); |
| 731 | if (obj == NULL) { |
| 732 | return NULL; |
| 733 | } |
| 734 | |
| 735 | IndirectReferenceTable& locals = ts.Env()->locals; |
| 736 | |
| 737 | uint32_t cookie = IRT_FIRST_SEGMENT; // TODO |
| 738 | IndirectRef ref = locals.Add(cookie, Decode<Object*>(ts, obj)); |
| 739 | return reinterpret_cast<jobject>(ref); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 740 | } |
| 741 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 742 | void DeleteLocalRef(JNIEnv* env, jobject obj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 743 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 744 | if (obj == NULL) { |
| 745 | return; |
| 746 | } |
| 747 | |
| 748 | IndirectReferenceTable& locals = ts.Env()->locals; |
| 749 | |
| 750 | uint32_t cookie = IRT_FIRST_SEGMENT; // TODO |
| 751 | if (!locals.Remove(cookie, obj)) { |
| 752 | // Attempting to delete a local reference that is not in the |
| 753 | // topmost local reference frame is a no-op. DeleteLocalRef returns |
| 754 | // void and doesn't throw any exceptions, but we should probably |
| 755 | // complain about it so the user will notice that things aren't |
| 756 | // going quite the way they expect. |
| 757 | LOG(WARNING) << "JNI WARNING: DeleteLocalRef(" << obj << ") " |
| 758 | << "failed to find entry"; |
| 759 | } |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 760 | } |
| 761 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 762 | jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 763 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 764 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 765 | return JNI_FALSE; |
| 766 | } |
| 767 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 768 | jint EnsureLocalCapacity(JNIEnv* env, jint) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 769 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 770 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 771 | return 0; |
| 772 | } |
| 773 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 774 | jobject AllocObject(JNIEnv* env, jclass clazz) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 775 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 776 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 777 | return NULL; |
| 778 | } |
| 779 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 780 | jobject NewObject(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 781 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 782 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 783 | return NULL; |
| 784 | } |
| 785 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 786 | jobject NewObjectV(JNIEnv* env, |
| 787 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 788 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 789 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 790 | return NULL; |
| 791 | } |
| 792 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 793 | jobject NewObjectA(JNIEnv* env, |
| 794 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 795 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 796 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 797 | return NULL; |
| 798 | } |
| 799 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 800 | jclass GetObjectClass(JNIEnv* env, jobject obj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 801 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 802 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 803 | return NULL; |
| 804 | } |
| 805 | |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 806 | jboolean IsInstanceOf(JNIEnv* env, jobject jobj, jclass clazz) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 807 | ScopedJniThreadState ts(env); |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 808 | CHECK_NE(static_cast<jclass>(NULL), clazz); |
| 809 | if (jobj == NULL) { |
| 810 | // NB. JNI is different from regular Java instanceof in this respect |
| 811 | return JNI_TRUE; |
| 812 | } else { |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 813 | Object* obj = Decode<Object*>(ts, jobj); |
| 814 | Class* klass = Decode<Class*>(ts, clazz); |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 815 | return Object::InstanceOf(obj, klass) ? JNI_TRUE : JNI_FALSE; |
| 816 | } |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 817 | } |
| 818 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 819 | jmethodID GetMethodID(JNIEnv* env, |
| 820 | jclass clazz, const char* name, const char* sig) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 821 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 822 | Class* klass = Decode<Class*>(ts, clazz); |
Carl Shapiro | 83ab4f3 | 2011-08-15 20:21:39 -0700 | [diff] [blame] | 823 | if (!klass->IsInitialized()) { |
| 824 | // TODO: initialize the class |
| 825 | } |
| 826 | Method* method = klass->FindVirtualMethod(name, sig); |
| 827 | if (method == NULL) { |
| 828 | // No virtual method matching the signature. Search declared |
| 829 | // private methods and constructors. |
| 830 | method = klass->FindDeclaredDirectMethod(name, sig); |
| 831 | } |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 832 | if (method == NULL) { |
| 833 | Thread* self = Thread::Current(); |
| 834 | std::string class_name = klass->GetDescriptor().ToString(); |
| 835 | // TODO: pretty print method names through a single routine |
| 836 | self->ThrowNewException("Ljava/lang/NoSuchMethodError;", |
| 837 | "no method \"%s.%s%s\"", |
| 838 | class_name.c_str(), name, sig); |
Carl Shapiro | 83ab4f3 | 2011-08-15 20:21:39 -0700 | [diff] [blame] | 839 | return NULL; |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 840 | } else if (method->IsStatic()) { |
| 841 | Thread* self = Thread::Current(); |
| 842 | std::string class_name = klass->GetDescriptor().ToString(); |
| 843 | // TODO: pretty print method names through a single routine |
| 844 | self->ThrowNewException("Ljava/lang/NoSuchMethodError;", |
| 845 | "method \"%s.%s%s\" is static", |
| 846 | class_name.c_str(), name, sig); |
Carl Shapiro | 83ab4f3 | 2011-08-15 20:21:39 -0700 | [diff] [blame] | 847 | return NULL; |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 848 | } else { |
| 849 | // TODO: create a JNI weak global reference for method |
| 850 | bool success = EnsureInvokeStub(method); |
| 851 | if (!success) { |
| 852 | // TODO: throw OutOfMemoryException |
| 853 | return NULL; |
| 854 | } |
| 855 | return reinterpret_cast<jmethodID>(method); |
Carl Shapiro | 83ab4f3 | 2011-08-15 20:21:39 -0700 | [diff] [blame] | 856 | } |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 857 | } |
| 858 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 859 | jobject CallObjectMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 860 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 861 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 862 | return NULL; |
| 863 | } |
| 864 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 865 | jobject CallObjectMethodV(JNIEnv* env, |
| 866 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 867 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 868 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 869 | return NULL; |
| 870 | } |
| 871 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 872 | jobject CallObjectMethodA(JNIEnv* env, |
| 873 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 874 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 875 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 876 | return NULL; |
| 877 | } |
| 878 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 879 | jboolean CallBooleanMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 880 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 881 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 882 | return JNI_FALSE; |
| 883 | } |
| 884 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 885 | jboolean CallBooleanMethodV(JNIEnv* env, |
| 886 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 887 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 888 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 889 | return JNI_FALSE; |
| 890 | } |
| 891 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 892 | jboolean CallBooleanMethodA(JNIEnv* env, |
| 893 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 894 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 895 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 896 | return JNI_FALSE; |
| 897 | } |
| 898 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 899 | jbyte CallByteMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 900 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 901 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 902 | return 0; |
| 903 | } |
| 904 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 905 | jbyte CallByteMethodV(JNIEnv* env, |
| 906 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 907 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 908 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 909 | return 0; |
| 910 | } |
| 911 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 912 | jbyte CallByteMethodA(JNIEnv* env, |
| 913 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 914 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 915 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 916 | return 0; |
| 917 | } |
| 918 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 919 | jchar CallCharMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 920 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 921 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 922 | return 0; |
| 923 | } |
| 924 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 925 | jchar CallCharMethodV(JNIEnv* env, |
| 926 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 927 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 928 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 929 | return 0; |
| 930 | } |
| 931 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 932 | jchar CallCharMethodA(JNIEnv* env, |
| 933 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 934 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 935 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 936 | return 0; |
| 937 | } |
| 938 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 939 | jshort CallShortMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 940 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 941 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 942 | return 0; |
| 943 | } |
| 944 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 945 | jshort CallShortMethodV(JNIEnv* env, |
| 946 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 947 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 948 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 949 | return 0; |
| 950 | } |
| 951 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 952 | jshort CallShortMethodA(JNIEnv* env, |
| 953 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 954 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 955 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 956 | return 0; |
| 957 | } |
| 958 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 959 | jint CallIntMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 960 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 961 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 962 | return 0; |
| 963 | } |
| 964 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 965 | jint CallIntMethodV(JNIEnv* env, |
| 966 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 967 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 968 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 969 | return 0; |
| 970 | } |
| 971 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 972 | jint CallIntMethodA(JNIEnv* env, |
| 973 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 974 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 975 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 976 | return 0; |
| 977 | } |
| 978 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 979 | jlong CallLongMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 980 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 981 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 982 | return 0; |
| 983 | } |
| 984 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 985 | jlong CallLongMethodV(JNIEnv* env, |
| 986 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 987 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 988 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 989 | return 0; |
| 990 | } |
| 991 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 992 | jlong CallLongMethodA(JNIEnv* env, |
| 993 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 994 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 995 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 996 | return 0; |
| 997 | } |
| 998 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 999 | jfloat CallFloatMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1000 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1001 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1002 | return 0; |
| 1003 | } |
| 1004 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1005 | jfloat CallFloatMethodV(JNIEnv* env, |
| 1006 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1007 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1008 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1009 | return 0; |
| 1010 | } |
| 1011 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1012 | jfloat CallFloatMethodA(JNIEnv* env, |
| 1013 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1014 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1015 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1016 | return 0; |
| 1017 | } |
| 1018 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1019 | jdouble CallDoubleMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1020 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1021 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1022 | return 0; |
| 1023 | } |
| 1024 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1025 | jdouble CallDoubleMethodV(JNIEnv* env, |
| 1026 | jobject obj, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1027 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1028 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1029 | return 0; |
| 1030 | } |
| 1031 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1032 | jdouble CallDoubleMethodA(JNIEnv* env, |
| 1033 | jobject obj, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1034 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1035 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1036 | return 0; |
| 1037 | } |
| 1038 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1039 | void CallVoidMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1040 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1041 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1042 | } |
| 1043 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1044 | void CallVoidMethodV(JNIEnv* env, jobject obj, |
| 1045 | jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1046 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1047 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1048 | } |
| 1049 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1050 | void CallVoidMethodA(JNIEnv* env, jobject obj, |
| 1051 | jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1052 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1053 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1056 | jobject CallNonvirtualObjectMethod(JNIEnv* env, |
| 1057 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1058 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1059 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1060 | return NULL; |
| 1061 | } |
| 1062 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1063 | jobject CallNonvirtualObjectMethodV(JNIEnv* env, |
| 1064 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1065 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1066 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1067 | return NULL; |
| 1068 | } |
| 1069 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1070 | jobject CallNonvirtualObjectMethodA(JNIEnv* env, |
| 1071 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1072 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1073 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1074 | return NULL; |
| 1075 | } |
| 1076 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1077 | jboolean CallNonvirtualBooleanMethod(JNIEnv* env, |
| 1078 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1079 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1080 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1081 | return JNI_FALSE; |
| 1082 | } |
| 1083 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1084 | jboolean CallNonvirtualBooleanMethodV(JNIEnv* env, |
| 1085 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1086 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1087 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1088 | return JNI_FALSE; |
| 1089 | } |
| 1090 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1091 | jboolean CallNonvirtualBooleanMethodA(JNIEnv* env, |
| 1092 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1093 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1094 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1095 | return JNI_FALSE; |
| 1096 | } |
| 1097 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1098 | jbyte CallNonvirtualByteMethod(JNIEnv* env, |
| 1099 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1100 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1101 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1102 | return 0; |
| 1103 | } |
| 1104 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1105 | jbyte CallNonvirtualByteMethodV(JNIEnv* env, |
| 1106 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1107 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1108 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1109 | return 0; |
| 1110 | } |
| 1111 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1112 | jbyte CallNonvirtualByteMethodA(JNIEnv* env, |
| 1113 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1114 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1115 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1116 | return 0; |
| 1117 | } |
| 1118 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1119 | jchar CallNonvirtualCharMethod(JNIEnv* env, |
| 1120 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1121 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1122 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1123 | return 0; |
| 1124 | } |
| 1125 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1126 | jchar CallNonvirtualCharMethodV(JNIEnv* env, |
| 1127 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1128 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1129 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1130 | return 0; |
| 1131 | } |
| 1132 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1133 | jchar CallNonvirtualCharMethodA(JNIEnv* env, |
| 1134 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1135 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1136 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1137 | return 0; |
| 1138 | } |
| 1139 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1140 | jshort CallNonvirtualShortMethod(JNIEnv* env, |
| 1141 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1142 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1143 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1144 | return 0; |
| 1145 | } |
| 1146 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1147 | jshort CallNonvirtualShortMethodV(JNIEnv* env, |
| 1148 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1149 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1150 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1151 | return 0; |
| 1152 | } |
| 1153 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1154 | jshort CallNonvirtualShortMethodA(JNIEnv* env, |
| 1155 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1156 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1157 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1158 | return 0; |
| 1159 | } |
| 1160 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1161 | jint CallNonvirtualIntMethod(JNIEnv* env, |
| 1162 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1163 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1164 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1165 | return 0; |
| 1166 | } |
| 1167 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1168 | jint CallNonvirtualIntMethodV(JNIEnv* env, |
| 1169 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1170 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1171 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1172 | return 0; |
| 1173 | } |
| 1174 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1175 | jint CallNonvirtualIntMethodA(JNIEnv* env, |
| 1176 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1177 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1178 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1179 | return 0; |
| 1180 | } |
| 1181 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1182 | jlong CallNonvirtualLongMethod(JNIEnv* env, |
| 1183 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1184 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1185 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1186 | return 0; |
| 1187 | } |
| 1188 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1189 | jlong CallNonvirtualLongMethodV(JNIEnv* env, |
| 1190 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1191 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1192 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1193 | return 0; |
| 1194 | } |
| 1195 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1196 | jlong CallNonvirtualLongMethodA(JNIEnv* env, |
| 1197 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1198 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1199 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1200 | return 0; |
| 1201 | } |
| 1202 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1203 | jfloat CallNonvirtualFloatMethod(JNIEnv* env, |
| 1204 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1205 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1206 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1207 | return 0; |
| 1208 | } |
| 1209 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1210 | jfloat CallNonvirtualFloatMethodV(JNIEnv* env, |
| 1211 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1212 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1213 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1214 | return 0; |
| 1215 | } |
| 1216 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1217 | jfloat CallNonvirtualFloatMethodA(JNIEnv* env, |
| 1218 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1219 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1220 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1221 | return 0; |
| 1222 | } |
| 1223 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1224 | jdouble CallNonvirtualDoubleMethod(JNIEnv* env, |
| 1225 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1226 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1227 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1228 | return 0; |
| 1229 | } |
| 1230 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1231 | jdouble CallNonvirtualDoubleMethodV(JNIEnv* env, |
| 1232 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1233 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1234 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1235 | return 0; |
| 1236 | } |
| 1237 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1238 | jdouble CallNonvirtualDoubleMethodA(JNIEnv* env, |
| 1239 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1240 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1241 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1242 | return 0; |
| 1243 | } |
| 1244 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1245 | void CallNonvirtualVoidMethod(JNIEnv* env, |
| 1246 | jobject obj, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1247 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1248 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1251 | void CallNonvirtualVoidMethodV(JNIEnv* env, |
| 1252 | jobject obj, jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1253 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1254 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1255 | } |
| 1256 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1257 | void CallNonvirtualVoidMethodA(JNIEnv* env, |
| 1258 | jobject obj, jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1259 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1260 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1261 | } |
| 1262 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1263 | jfieldID GetFieldID(JNIEnv* env, |
| 1264 | jclass clazz, const char* name, const char* sig) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1265 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1266 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1267 | return NULL; |
| 1268 | } |
| 1269 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1270 | jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1271 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1272 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1273 | return NULL; |
| 1274 | } |
| 1275 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1276 | jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1277 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1278 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1279 | return JNI_FALSE; |
| 1280 | } |
| 1281 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1282 | jbyte GetByteField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1283 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1284 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1285 | return 0; |
| 1286 | } |
| 1287 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1288 | jchar GetCharField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1289 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1290 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1291 | return 0; |
| 1292 | } |
| 1293 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1294 | jshort GetShortField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1295 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1296 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1297 | return 0; |
| 1298 | } |
| 1299 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1300 | jint GetIntField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1301 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1302 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1303 | return 0; |
| 1304 | } |
| 1305 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1306 | jlong GetLongField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1307 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1308 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1309 | return 0; |
| 1310 | } |
| 1311 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1312 | jfloat GetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1313 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1314 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1315 | return 0; |
| 1316 | } |
| 1317 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1318 | jdouble GetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1319 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1320 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1321 | return 0; |
| 1322 | } |
| 1323 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1324 | void SetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID, jobject val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1325 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1326 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1327 | } |
| 1328 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1329 | void SetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID, jboolean val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1330 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1331 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1332 | } |
| 1333 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1334 | void SetByteField(JNIEnv* env, jobject obj, jfieldID fieldID, jbyte val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1335 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1336 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1337 | } |
| 1338 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1339 | void SetCharField(JNIEnv* env, jobject obj, jfieldID fieldID, jchar val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1340 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1341 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1342 | } |
| 1343 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1344 | void SetShortField(JNIEnv* env, jobject obj, jfieldID fieldID, jshort val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1345 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1346 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1349 | void SetIntField(JNIEnv* env, jobject obj, jfieldID fieldID, jint val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1350 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1351 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1354 | void SetLongField(JNIEnv* env, jobject obj, jfieldID fieldID, jlong val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1355 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1356 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1357 | } |
| 1358 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1359 | void SetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID, jfloat val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1360 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1361 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1362 | } |
| 1363 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1364 | void SetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID, jdouble val) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1365 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1366 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1367 | } |
| 1368 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1369 | jmethodID GetStaticMethodID(JNIEnv* env, |
| 1370 | jclass clazz, const char* name, const char* sig) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1371 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1372 | Class* klass = Decode<Class*>(ts, clazz); |
Carl Shapiro | 83ab4f3 | 2011-08-15 20:21:39 -0700 | [diff] [blame] | 1373 | if (!klass->IsInitialized()) { |
| 1374 | // TODO: initialize the class |
| 1375 | } |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1376 | Method* method = klass->FindDirectMethod(name, sig); |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 1377 | if (method == NULL) { |
| 1378 | Thread* self = Thread::Current(); |
| 1379 | std::string class_name = klass->GetDescriptor().ToString(); |
| 1380 | // TODO: pretty print method names through a single routine |
| 1381 | // TODO: may want to FindVirtualMethod to give more informative error |
| 1382 | // message here |
| 1383 | self->ThrowNewException("Ljava/lang/NoSuchMethodError;", |
| 1384 | "no method \"%s.%s%s\"", |
| 1385 | class_name.c_str(), name, sig); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1386 | return NULL; |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 1387 | } else if (!method->IsStatic()) { |
| 1388 | Thread* self = Thread::Current(); |
| 1389 | std::string class_name = klass->GetDescriptor().ToString(); |
| 1390 | // TODO: pretty print method names through a single routine |
| 1391 | self->ThrowNewException("Ljava/lang/NoSuchMethodError;", |
| 1392 | "method \"%s.%s%s\" is not static", |
| 1393 | class_name.c_str(), name, sig); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1394 | return NULL; |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 1395 | } else { |
| 1396 | // TODO: create a JNI weak global reference for method |
| 1397 | bool success = EnsureInvokeStub(method); |
| 1398 | if (!success) { |
| 1399 | // TODO: throw OutOfMemoryException |
| 1400 | return NULL; |
| 1401 | } |
| 1402 | return reinterpret_cast<jmethodID>(method); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1403 | } |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1404 | } |
| 1405 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1406 | jobject CallStaticObjectMethod(JNIEnv* env, |
| 1407 | jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1408 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1409 | va_list ap; |
| 1410 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1411 | JValue result = InvokeWithVarArgs(ts, NULL, methodID, ap); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1412 | return AddLocalReference<jobject>(ts, result.l); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1413 | } |
| 1414 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1415 | jobject CallStaticObjectMethodV(JNIEnv* env, |
| 1416 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1417 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1418 | JValue result = InvokeWithVarArgs(ts, NULL, methodID, args); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1419 | return AddLocalReference<jobject>(ts, result.l); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1420 | } |
| 1421 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1422 | jobject CallStaticObjectMethodA(JNIEnv* env, |
| 1423 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1424 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1425 | JValue result = InvokeWithJValues(ts, NULL, methodID, args); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1426 | return AddLocalReference<jobject>(ts, result.l); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1427 | } |
| 1428 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1429 | jboolean CallStaticBooleanMethod(JNIEnv* env, |
| 1430 | jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1431 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1432 | va_list ap; |
| 1433 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1434 | return InvokeWithVarArgs(ts, NULL, methodID, ap).z; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1435 | } |
| 1436 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1437 | jboolean CallStaticBooleanMethodV(JNIEnv* env, |
| 1438 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1439 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1440 | return InvokeWithVarArgs(ts, NULL, methodID, args).z; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1441 | } |
| 1442 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1443 | jboolean CallStaticBooleanMethodA(JNIEnv* env, |
| 1444 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1445 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1446 | return InvokeWithJValues(ts, NULL, methodID, args).z; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1447 | } |
| 1448 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1449 | jbyte CallStaticByteMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1450 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1451 | va_list ap; |
| 1452 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1453 | return InvokeWithVarArgs(ts, NULL, methodID, ap).b; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1454 | } |
| 1455 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1456 | jbyte CallStaticByteMethodV(JNIEnv* env, |
| 1457 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1458 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1459 | return InvokeWithVarArgs(ts, NULL, methodID, args).b; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1460 | } |
| 1461 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1462 | jbyte CallStaticByteMethodA(JNIEnv* env, |
| 1463 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1464 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1465 | return InvokeWithJValues(ts, NULL, methodID, args).b; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1466 | } |
| 1467 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1468 | jchar CallStaticCharMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1469 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1470 | va_list ap; |
| 1471 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1472 | return InvokeWithVarArgs(ts, NULL, methodID, ap).c; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1473 | } |
| 1474 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1475 | jchar CallStaticCharMethodV(JNIEnv* env, |
| 1476 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1477 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1478 | return InvokeWithVarArgs(ts, NULL, methodID, args).c; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1479 | } |
| 1480 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1481 | jchar CallStaticCharMethodA(JNIEnv* env, |
| 1482 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1483 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1484 | return InvokeWithJValues(ts, NULL, methodID, args).c; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1485 | } |
| 1486 | |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1487 | jshort CallStaticShortMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1488 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1489 | va_list ap; |
| 1490 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1491 | return InvokeWithVarArgs(ts, NULL, methodID, ap).s; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1492 | } |
| 1493 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1494 | jshort CallStaticShortMethodV(JNIEnv* env, |
| 1495 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1496 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1497 | return InvokeWithVarArgs(ts, NULL, methodID, args).s; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1498 | } |
| 1499 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1500 | jshort CallStaticShortMethodA(JNIEnv* env, |
| 1501 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1502 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1503 | return InvokeWithJValues(ts, NULL, methodID, args).s; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1504 | } |
| 1505 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1506 | jint CallStaticIntMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1507 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1508 | va_list ap; |
| 1509 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1510 | return InvokeWithVarArgs(ts, NULL, methodID, ap).i; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1511 | } |
| 1512 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1513 | jint CallStaticIntMethodV(JNIEnv* env, |
| 1514 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1515 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1516 | return InvokeWithVarArgs(ts, NULL, methodID, args).i; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1517 | } |
| 1518 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1519 | jint CallStaticIntMethodA(JNIEnv* env, |
| 1520 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1521 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1522 | return InvokeWithJValues(ts, NULL, methodID, args).i; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1523 | } |
| 1524 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1525 | jlong CallStaticLongMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1526 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1527 | va_list ap; |
| 1528 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1529 | return InvokeWithVarArgs(ts, NULL, methodID, ap).j; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1530 | } |
| 1531 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1532 | jlong CallStaticLongMethodV(JNIEnv* env, |
| 1533 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1534 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1535 | return InvokeWithVarArgs(ts, NULL, methodID, args).j; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1536 | } |
| 1537 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1538 | jlong CallStaticLongMethodA(JNIEnv* env, |
| 1539 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1540 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1541 | return InvokeWithJValues(ts, NULL, methodID, args).j; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1542 | } |
| 1543 | |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1544 | jfloat CallStaticFloatMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1545 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1546 | va_list ap; |
| 1547 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1548 | return InvokeWithVarArgs(ts, NULL, methodID, ap).f; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1549 | } |
| 1550 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1551 | jfloat CallStaticFloatMethodV(JNIEnv* env, |
| 1552 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1553 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1554 | return InvokeWithVarArgs(ts, NULL, methodID, args).f; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1555 | } |
| 1556 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1557 | jfloat CallStaticFloatMethodA(JNIEnv* env, |
| 1558 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1559 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1560 | return InvokeWithJValues(ts, NULL, methodID, args).f; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1561 | } |
| 1562 | |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1563 | jdouble CallStaticDoubleMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1564 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1565 | va_list ap; |
| 1566 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1567 | return InvokeWithVarArgs(ts, NULL, methodID, ap).d; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1568 | } |
| 1569 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1570 | jdouble CallStaticDoubleMethodV(JNIEnv* env, |
| 1571 | jclass clazz, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1572 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1573 | return InvokeWithVarArgs(ts, NULL, methodID, args).d; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1574 | } |
| 1575 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1576 | jdouble CallStaticDoubleMethodA(JNIEnv* env, |
| 1577 | jclass clazz, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1578 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1579 | return InvokeWithJValues(ts, NULL, methodID, args).d; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1580 | } |
| 1581 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1582 | void CallStaticVoidMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1583 | ScopedJniThreadState ts(env); |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1584 | va_list ap; |
| 1585 | va_start(ap, methodID); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1586 | InvokeWithVarArgs(ts, NULL, methodID, ap); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1587 | } |
| 1588 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1589 | void CallStaticVoidMethodV(JNIEnv* env, |
| 1590 | jclass cls, jmethodID methodID, va_list args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1591 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1592 | InvokeWithVarArgs(ts, NULL, methodID, args); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1593 | } |
| 1594 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1595 | void CallStaticVoidMethodA(JNIEnv* env, |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1596 | jclass cls, jmethodID methodID, jvalue* args) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1597 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1598 | InvokeWithJValues(ts, NULL, methodID, args); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1599 | } |
| 1600 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1601 | jfieldID GetStaticFieldID(JNIEnv* env, |
| 1602 | jclass clazz, const char* name, const char* sig) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1603 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1604 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1605 | return 0; |
| 1606 | } |
| 1607 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1608 | jobject GetStaticObjectField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1609 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1610 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1611 | return NULL; |
| 1612 | } |
| 1613 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1614 | jboolean GetStaticBooleanField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1615 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1616 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1617 | return JNI_FALSE; |
| 1618 | } |
| 1619 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1620 | jbyte GetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1621 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1622 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1623 | return 0; |
| 1624 | } |
| 1625 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1626 | jchar GetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1627 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1628 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1629 | return 0; |
| 1630 | } |
| 1631 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1632 | jshort GetStaticShortField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1633 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1634 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1635 | return 0; |
| 1636 | } |
| 1637 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1638 | jint GetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1639 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1640 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1641 | return 0; |
| 1642 | } |
| 1643 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1644 | jlong GetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1645 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1646 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1647 | return 0; |
| 1648 | } |
| 1649 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1650 | jfloat GetStaticFloatField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1651 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1652 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1653 | return 0; |
| 1654 | } |
| 1655 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1656 | jdouble GetStaticDoubleField(JNIEnv* env, jclass clazz, jfieldID fieldID) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1657 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1658 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1659 | return 0; |
| 1660 | } |
| 1661 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1662 | void SetStaticObjectField(JNIEnv* env, |
| 1663 | jclass clazz, jfieldID fieldID, jobject value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1664 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1665 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1666 | } |
| 1667 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1668 | void SetStaticBooleanField(JNIEnv* env, |
| 1669 | jclass clazz, jfieldID fieldID, jboolean value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1670 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1671 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1672 | } |
| 1673 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1674 | void SetStaticByteField(JNIEnv* env, |
| 1675 | jclass clazz, jfieldID fieldID, jbyte value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1676 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1677 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1678 | } |
| 1679 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1680 | void SetStaticCharField(JNIEnv* env, |
| 1681 | jclass clazz, jfieldID fieldID, jchar value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1682 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1683 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1684 | } |
| 1685 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1686 | void SetStaticShortField(JNIEnv* env, |
| 1687 | jclass clazz, jfieldID fieldID, jshort value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1688 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1689 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1690 | } |
| 1691 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1692 | void SetStaticIntField(JNIEnv* env, |
| 1693 | jclass clazz, jfieldID fieldID, jint value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1694 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1695 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1696 | } |
| 1697 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1698 | void SetStaticLongField(JNIEnv* env, |
| 1699 | jclass clazz, jfieldID fieldID, jlong value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1700 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1701 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1702 | } |
| 1703 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1704 | void SetStaticFloatField(JNIEnv* env, |
| 1705 | jclass clazz, jfieldID fieldID, jfloat value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1706 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1707 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1710 | void SetStaticDoubleField(JNIEnv* env, |
| 1711 | jclass clazz, jfieldID fieldID, jdouble value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1712 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1713 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1714 | } |
| 1715 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1716 | jstring NewString(JNIEnv* env, const jchar* unicode, jsize len) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1717 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1718 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1719 | return NULL; |
| 1720 | } |
| 1721 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1722 | jsize GetStringLength(JNIEnv* env, jstring str) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1723 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1724 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1725 | return 0; |
| 1726 | } |
| 1727 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1728 | const jchar* GetStringChars(JNIEnv* env, jstring str, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1729 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1730 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1731 | return NULL; |
| 1732 | } |
| 1733 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1734 | void ReleaseStringChars(JNIEnv* env, jstring str, const jchar* chars) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1735 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1736 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1737 | } |
| 1738 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1739 | jstring NewStringUTF(JNIEnv* env, const char* utf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1740 | ScopedJniThreadState ts(env); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1741 | if (utf == NULL) { |
| 1742 | return NULL; |
| 1743 | } |
| 1744 | size_t char_count = String::ModifiedUtf8Len(utf); |
| 1745 | String* result = String::AllocFromModifiedUtf8(char_count, utf); |
| 1746 | return AddLocalReference<jstring>(ts, result); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1747 | } |
| 1748 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1749 | jsize GetStringUTFLength(JNIEnv* env, jstring str) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1750 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1751 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1752 | return 0; |
| 1753 | } |
| 1754 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1755 | const char* GetStringUTFChars(JNIEnv* env, jstring str, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1756 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1757 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1758 | return NULL; |
| 1759 | } |
| 1760 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1761 | void ReleaseStringUTFChars(JNIEnv* env, jstring str, const char* chars) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1762 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1763 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1764 | } |
| 1765 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1766 | jsize GetArrayLength(JNIEnv* env, jarray array) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1767 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1768 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1769 | return 0; |
| 1770 | } |
| 1771 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1772 | jobject GetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1773 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1774 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1775 | return NULL; |
| 1776 | } |
| 1777 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1778 | void SetObjectArrayElement(JNIEnv* env, |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1779 | jobjectArray java_array, jsize index, jobject java_value) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1780 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1781 | ObjectArray<Object>* array = Decode<ObjectArray<Object>*>(ts, java_array); |
| 1782 | Object* value = Decode<Object*>(ts, java_value); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1783 | array->Set(index, value); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1784 | } |
| 1785 | |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1786 | template<typename JniT, typename ArtT> |
| 1787 | JniT NewPrimitiveArray(ScopedJniThreadState& ts, jsize length) { |
| 1788 | CHECK_GE(length, 0); // TODO: ReportJniError |
| 1789 | ArtT* result = ArtT::Alloc(length); |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1790 | return AddLocalReference<JniT>(ts, result); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1791 | } |
| 1792 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1793 | jbooleanArray NewBooleanArray(JNIEnv* env, jsize length) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1794 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1795 | return NewPrimitiveArray<jbooleanArray, BooleanArray>(ts, length); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1796 | } |
| 1797 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1798 | jbyteArray NewByteArray(JNIEnv* env, jsize length) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1799 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1800 | return NewPrimitiveArray<jbyteArray, ByteArray>(ts, length); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1801 | } |
| 1802 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1803 | jcharArray NewCharArray(JNIEnv* env, jsize length) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1804 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1805 | return NewPrimitiveArray<jcharArray, CharArray>(ts, length); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1806 | } |
| 1807 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1808 | jdoubleArray NewDoubleArray(JNIEnv* env, jsize length) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1809 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1810 | return NewPrimitiveArray<jdoubleArray, DoubleArray>(ts, length); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1811 | } |
| 1812 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1813 | jfloatArray NewFloatArray(JNIEnv* env, jsize length) { |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1814 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1815 | return NewPrimitiveArray<jfloatArray, FloatArray>(ts, length); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1816 | } |
| 1817 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1818 | jintArray NewIntArray(JNIEnv* env, jsize length) { |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1819 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1820 | return NewPrimitiveArray<jintArray, IntArray>(ts, length); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1821 | } |
| 1822 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1823 | jlongArray NewLongArray(JNIEnv* env, jsize length) { |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1824 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1825 | return NewPrimitiveArray<jlongArray, LongArray>(ts, length); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1826 | } |
| 1827 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1828 | jobjectArray NewObjectArray(JNIEnv* env, jsize length, jclass element_jclass, jobject initial_element) { |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 1829 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1830 | CHECK_GE(length, 0); // TODO: ReportJniError |
| 1831 | |
| 1832 | // Compute the array class corresponding to the given element class. |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 1833 | Class* element_class = Decode<Class*>(ts, element_jclass); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1834 | std::string descriptor; |
| 1835 | descriptor += "["; |
| 1836 | descriptor += element_class->GetDescriptor().ToString(); |
| 1837 | |
| 1838 | // Find the class. |
| 1839 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 1840 | // TODO: need to get the appropriate ClassLoader. |
| 1841 | Class* array_class = class_linker->FindClass(descriptor, NULL); |
| 1842 | if (array_class == NULL) { |
| 1843 | return NULL; |
| 1844 | } |
| 1845 | |
| 1846 | ObjectArray<Object>* result = ObjectArray<Object>::Alloc(array_class, length); |
| 1847 | CHECK(initial_element == NULL); // TODO: support initial_element |
Elliott Hughes | 8a26c5c | 2011-08-15 18:35:43 -0700 | [diff] [blame] | 1848 | return AddLocalReference<jobjectArray>(ts, result); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | jshortArray NewShortArray(JNIEnv* env, jsize length) { |
| 1852 | ScopedJniThreadState ts(env); |
| 1853 | return NewPrimitiveArray<jshortArray, ShortArray>(ts, length); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1854 | } |
| 1855 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1856 | jboolean* GetBooleanArrayElements(JNIEnv* env, |
| 1857 | jbooleanArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1858 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1859 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1860 | return NULL; |
| 1861 | } |
| 1862 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1863 | jbyte* GetByteArrayElements(JNIEnv* env, jbyteArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1864 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1865 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1866 | return NULL; |
| 1867 | } |
| 1868 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1869 | jchar* GetCharArrayElements(JNIEnv* env, jcharArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1870 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1871 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1872 | return NULL; |
| 1873 | } |
| 1874 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1875 | jshort* GetShortArrayElements(JNIEnv* env, |
| 1876 | jshortArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1877 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1878 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1879 | return NULL; |
| 1880 | } |
| 1881 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1882 | jint* GetIntArrayElements(JNIEnv* env, jintArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1883 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1884 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1885 | return NULL; |
| 1886 | } |
| 1887 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1888 | jlong* GetLongArrayElements(JNIEnv* env, jlongArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1889 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1890 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1891 | return NULL; |
| 1892 | } |
| 1893 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1894 | jfloat* GetFloatArrayElements(JNIEnv* env, |
| 1895 | jfloatArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1896 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1897 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1898 | return NULL; |
| 1899 | } |
| 1900 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1901 | jdouble* GetDoubleArrayElements(JNIEnv* env, |
| 1902 | jdoubleArray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1903 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1904 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1905 | return NULL; |
| 1906 | } |
| 1907 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1908 | void ReleaseBooleanArrayElements(JNIEnv* env, |
| 1909 | jbooleanArray array, jboolean* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1910 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1911 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1912 | } |
| 1913 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1914 | void ReleaseByteArrayElements(JNIEnv* env, |
| 1915 | jbyteArray array, jbyte* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1916 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1917 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1918 | } |
| 1919 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1920 | void ReleaseCharArrayElements(JNIEnv* env, |
| 1921 | jcharArray array, jchar* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1922 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1923 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1924 | } |
| 1925 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1926 | void ReleaseShortArrayElements(JNIEnv* env, |
| 1927 | jshortArray array, jshort* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1928 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1929 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1930 | } |
| 1931 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1932 | void ReleaseIntArrayElements(JNIEnv* env, |
| 1933 | jintArray array, jint* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1934 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1935 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1936 | } |
| 1937 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1938 | void ReleaseLongArrayElements(JNIEnv* env, |
| 1939 | jlongArray array, jlong* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1940 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1941 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1942 | } |
| 1943 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1944 | void ReleaseFloatArrayElements(JNIEnv* env, |
| 1945 | jfloatArray array, jfloat* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1946 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1947 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1948 | } |
| 1949 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1950 | void ReleaseDoubleArrayElements(JNIEnv* env, |
| 1951 | jdoubleArray array, jdouble* elems, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1952 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1953 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1954 | } |
| 1955 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1956 | void GetBooleanArrayRegion(JNIEnv* env, |
| 1957 | jbooleanArray array, jsize start, jsize l, jboolean* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1958 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1959 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1960 | } |
| 1961 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1962 | void GetByteArrayRegion(JNIEnv* env, |
| 1963 | jbyteArray array, jsize start, jsize len, jbyte* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1964 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1965 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1966 | } |
| 1967 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1968 | void GetCharArrayRegion(JNIEnv* env, |
| 1969 | jcharArray array, jsize start, jsize len, jchar* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1970 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1971 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1972 | } |
| 1973 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1974 | void GetShortArrayRegion(JNIEnv* env, |
| 1975 | jshortArray array, jsize start, jsize len, jshort* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1976 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1977 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1978 | } |
| 1979 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1980 | void GetIntArrayRegion(JNIEnv* env, |
| 1981 | jintArray array, jsize start, jsize len, jint* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1982 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1983 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1984 | } |
| 1985 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1986 | void GetLongArrayRegion(JNIEnv* env, |
| 1987 | jlongArray array, jsize start, jsize len, jlong* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1988 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1989 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1990 | } |
| 1991 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1992 | void GetFloatArrayRegion(JNIEnv* env, |
| 1993 | jfloatArray array, jsize start, jsize len, jfloat* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 1994 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 1995 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 1996 | } |
| 1997 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 1998 | void GetDoubleArrayRegion(JNIEnv* env, |
| 1999 | jdoubleArray array, jsize start, jsize len, jdouble* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2000 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2001 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2002 | } |
| 2003 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2004 | void SetBooleanArrayRegion(JNIEnv* env, |
| 2005 | jbooleanArray array, jsize start, jsize l, const jboolean* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2006 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2007 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2008 | } |
| 2009 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2010 | void SetByteArrayRegion(JNIEnv* env, |
| 2011 | jbyteArray array, jsize start, jsize len, const jbyte* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2012 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2013 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2014 | } |
| 2015 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2016 | void SetCharArrayRegion(JNIEnv* env, |
| 2017 | jcharArray array, jsize start, jsize len, const jchar* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2018 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2019 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2020 | } |
| 2021 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2022 | void SetShortArrayRegion(JNIEnv* env, |
| 2023 | jshortArray array, jsize start, jsize len, const jshort* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2024 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2025 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2026 | } |
| 2027 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2028 | void SetIntArrayRegion(JNIEnv* env, |
| 2029 | jintArray array, jsize start, jsize len, const jint* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2030 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2031 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2032 | } |
| 2033 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2034 | void SetLongArrayRegion(JNIEnv* env, |
| 2035 | jlongArray array, jsize start, jsize len, const jlong* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2036 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2037 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2038 | } |
| 2039 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2040 | void SetFloatArrayRegion(JNIEnv* env, |
| 2041 | jfloatArray array, jsize start, jsize len, const jfloat* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2042 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2043 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2044 | } |
| 2045 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2046 | void SetDoubleArrayRegion(JNIEnv* env, |
| 2047 | jdoubleArray array, jsize start, jsize len, const jdouble* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2048 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2049 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2050 | } |
| 2051 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2052 | jint RegisterNatives(JNIEnv* env, |
| 2053 | jclass clazz, const JNINativeMethod* methods, jint nMethods) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2054 | ScopedJniThreadState ts(env); |
Elliott Hughes | c5f7c91 | 2011-08-18 14:00:42 -0700 | [diff] [blame] | 2055 | Class* klass = Decode<Class*>(ts, clazz); |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 2056 | for(int i = 0; i < nMethods; i++) { |
| 2057 | const char* name = methods[i].name; |
| 2058 | const char* sig = methods[i].signature; |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 2059 | |
| 2060 | if (*sig == '!') { |
| 2061 | // TODO: fast jni. it's too noisy to log all these. |
| 2062 | ++sig; |
| 2063 | } |
| 2064 | |
Ian Rogers | 4dd71f1 | 2011-08-16 14:16:02 -0700 | [diff] [blame] | 2065 | Method* method = klass->FindDirectMethod(name, sig); |
| 2066 | if (method == NULL) { |
| 2067 | method = klass->FindVirtualMethod(name, sig); |
| 2068 | } |
| 2069 | if (method == NULL) { |
| 2070 | Thread* self = Thread::Current(); |
| 2071 | std::string class_name = klass->GetDescriptor().ToString(); |
| 2072 | // TODO: pretty print method names through a single routine |
| 2073 | self->ThrowNewException("Ljava/lang/NoSuchMethodError;", |
| 2074 | "no method \"%s.%s%s\"", |
| 2075 | class_name.c_str(), name, sig); |
| 2076 | return JNI_ERR; |
| 2077 | } else if (!method->IsNative()) { |
| 2078 | Thread* self = Thread::Current(); |
| 2079 | std::string class_name = klass->GetDescriptor().ToString(); |
| 2080 | // TODO: pretty print method names through a single routine |
| 2081 | self->ThrowNewException("Ljava/lang/NoSuchMethodError;", |
| 2082 | "method \"%s.%s%s\" is not native", |
| 2083 | class_name.c_str(), name, sig); |
| 2084 | return JNI_ERR; |
| 2085 | } |
| 2086 | method->RegisterNative(methods[i].fnPtr); |
| 2087 | } |
| 2088 | return JNI_OK; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2089 | } |
| 2090 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2091 | jint UnregisterNatives(JNIEnv* env, jclass clazz) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2092 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2093 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2094 | return 0; |
| 2095 | } |
| 2096 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2097 | jint MonitorEnter(JNIEnv* env, jobject obj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2098 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2099 | UNIMPLEMENTED(WARNING); |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2100 | return 0; |
| 2101 | } |
| 2102 | |
| 2103 | jint MonitorExit(JNIEnv* env, jobject obj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2104 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2105 | UNIMPLEMENTED(WARNING); |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2106 | return 0; |
| 2107 | } |
| 2108 | |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 2109 | jint GetJavaVM(JNIEnv* env, JavaVM** vm) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2110 | ScopedJniThreadState ts(env); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2111 | Runtime* runtime = Runtime::Current(); |
| 2112 | if (runtime != NULL) { |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 2113 | *vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM()); |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2114 | } else { |
| 2115 | *vm = NULL; |
| 2116 | } |
| 2117 | return (*vm != NULL) ? JNI_OK : JNI_ERR; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2118 | } |
| 2119 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2120 | void GetStringRegion(JNIEnv* env, |
| 2121 | jstring str, jsize start, jsize len, jchar* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2122 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2123 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2124 | } |
| 2125 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2126 | void GetStringUTFRegion(JNIEnv* env, |
| 2127 | jstring str, jsize start, jsize len, char* buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2128 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2129 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2130 | } |
| 2131 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2132 | void* GetPrimitiveArrayCritical(JNIEnv* env, |
| 2133 | jarray array, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2134 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2135 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2136 | return NULL; |
| 2137 | } |
| 2138 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2139 | void ReleasePrimitiveArrayCritical(JNIEnv* env, |
| 2140 | jarray array, void* carray, jint mode) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2141 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2142 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2143 | } |
| 2144 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2145 | const jchar* GetStringCritical(JNIEnv* env, jstring s, jboolean* isCopy) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2146 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2147 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2148 | return NULL; |
| 2149 | } |
| 2150 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2151 | void ReleaseStringCritical(JNIEnv* env, jstring s, const jchar* cstr) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2152 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2153 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2154 | } |
| 2155 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2156 | jboolean ExceptionCheck(JNIEnv* env) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2157 | ScopedJniThreadState ts(env); |
Elliott Hughes | b20a554 | 2011-08-12 18:03:12 -0700 | [diff] [blame] | 2158 | return ts.Self()->IsExceptionPending() ? JNI_TRUE : JNI_FALSE; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2159 | } |
| 2160 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2161 | jobject NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2162 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2163 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2164 | return NULL; |
| 2165 | } |
| 2166 | |
| 2167 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2168 | void* GetDirectBufferAddress(JNIEnv* env, jobject buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2169 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2170 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2171 | return NULL; |
| 2172 | } |
| 2173 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2174 | jlong GetDirectBufferCapacity(JNIEnv* env, jobject buf) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2175 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2176 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2177 | return 0; |
| 2178 | } |
| 2179 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2180 | jobjectRefType GetObjectRefType(JNIEnv* env, jobject jobj) { |
Elliott Hughes | 22f4093 | 2011-08-12 13:06:37 -0700 | [diff] [blame] | 2181 | ScopedJniThreadState ts(env); |
Elliott Hughes | c7ac37f | 2011-08-12 12:21:58 -0700 | [diff] [blame] | 2182 | UNIMPLEMENTED(FATAL); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2183 | return JNIInvalidRefType; |
| 2184 | } |
| 2185 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2186 | static const struct JNINativeInterface gNativeInterface = { |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2187 | NULL, // reserved0. |
| 2188 | NULL, // reserved1. |
| 2189 | NULL, // reserved2. |
| 2190 | NULL, // reserved3. |
| 2191 | GetVersion, |
| 2192 | DefineClass, |
| 2193 | FindClass, |
| 2194 | FromReflectedMethod, |
| 2195 | FromReflectedField, |
| 2196 | ToReflectedMethod, |
| 2197 | GetSuperclass, |
| 2198 | IsAssignableFrom, |
| 2199 | ToReflectedField, |
| 2200 | Throw, |
| 2201 | ThrowNew, |
| 2202 | ExceptionOccurred, |
| 2203 | ExceptionDescribe, |
| 2204 | ExceptionClear, |
| 2205 | FatalError, |
| 2206 | PushLocalFrame, |
| 2207 | PopLocalFrame, |
| 2208 | NewGlobalRef, |
| 2209 | DeleteGlobalRef, |
| 2210 | DeleteLocalRef, |
| 2211 | IsSameObject, |
| 2212 | NewLocalRef, |
| 2213 | EnsureLocalCapacity, |
| 2214 | AllocObject, |
| 2215 | NewObject, |
| 2216 | NewObjectV, |
| 2217 | NewObjectA, |
| 2218 | GetObjectClass, |
| 2219 | IsInstanceOf, |
| 2220 | GetMethodID, |
| 2221 | CallObjectMethod, |
| 2222 | CallObjectMethodV, |
| 2223 | CallObjectMethodA, |
| 2224 | CallBooleanMethod, |
| 2225 | CallBooleanMethodV, |
| 2226 | CallBooleanMethodA, |
| 2227 | CallByteMethod, |
| 2228 | CallByteMethodV, |
| 2229 | CallByteMethodA, |
| 2230 | CallCharMethod, |
| 2231 | CallCharMethodV, |
| 2232 | CallCharMethodA, |
| 2233 | CallShortMethod, |
| 2234 | CallShortMethodV, |
| 2235 | CallShortMethodA, |
| 2236 | CallIntMethod, |
| 2237 | CallIntMethodV, |
| 2238 | CallIntMethodA, |
| 2239 | CallLongMethod, |
| 2240 | CallLongMethodV, |
| 2241 | CallLongMethodA, |
| 2242 | CallFloatMethod, |
| 2243 | CallFloatMethodV, |
| 2244 | CallFloatMethodA, |
| 2245 | CallDoubleMethod, |
| 2246 | CallDoubleMethodV, |
| 2247 | CallDoubleMethodA, |
| 2248 | CallVoidMethod, |
| 2249 | CallVoidMethodV, |
| 2250 | CallVoidMethodA, |
| 2251 | CallNonvirtualObjectMethod, |
| 2252 | CallNonvirtualObjectMethodV, |
| 2253 | CallNonvirtualObjectMethodA, |
| 2254 | CallNonvirtualBooleanMethod, |
| 2255 | CallNonvirtualBooleanMethodV, |
| 2256 | CallNonvirtualBooleanMethodA, |
| 2257 | CallNonvirtualByteMethod, |
| 2258 | CallNonvirtualByteMethodV, |
| 2259 | CallNonvirtualByteMethodA, |
| 2260 | CallNonvirtualCharMethod, |
| 2261 | CallNonvirtualCharMethodV, |
| 2262 | CallNonvirtualCharMethodA, |
| 2263 | CallNonvirtualShortMethod, |
| 2264 | CallNonvirtualShortMethodV, |
| 2265 | CallNonvirtualShortMethodA, |
| 2266 | CallNonvirtualIntMethod, |
| 2267 | CallNonvirtualIntMethodV, |
| 2268 | CallNonvirtualIntMethodA, |
| 2269 | CallNonvirtualLongMethod, |
| 2270 | CallNonvirtualLongMethodV, |
| 2271 | CallNonvirtualLongMethodA, |
| 2272 | CallNonvirtualFloatMethod, |
| 2273 | CallNonvirtualFloatMethodV, |
| 2274 | CallNonvirtualFloatMethodA, |
| 2275 | CallNonvirtualDoubleMethod, |
| 2276 | CallNonvirtualDoubleMethodV, |
| 2277 | CallNonvirtualDoubleMethodA, |
| 2278 | CallNonvirtualVoidMethod, |
| 2279 | CallNonvirtualVoidMethodV, |
| 2280 | CallNonvirtualVoidMethodA, |
| 2281 | GetFieldID, |
| 2282 | GetObjectField, |
| 2283 | GetBooleanField, |
| 2284 | GetByteField, |
| 2285 | GetCharField, |
| 2286 | GetShortField, |
| 2287 | GetIntField, |
| 2288 | GetLongField, |
| 2289 | GetFloatField, |
| 2290 | GetDoubleField, |
| 2291 | SetObjectField, |
| 2292 | SetBooleanField, |
| 2293 | SetByteField, |
| 2294 | SetCharField, |
| 2295 | SetShortField, |
| 2296 | SetIntField, |
| 2297 | SetLongField, |
| 2298 | SetFloatField, |
| 2299 | SetDoubleField, |
| 2300 | GetStaticMethodID, |
| 2301 | CallStaticObjectMethod, |
| 2302 | CallStaticObjectMethodV, |
| 2303 | CallStaticObjectMethodA, |
| 2304 | CallStaticBooleanMethod, |
| 2305 | CallStaticBooleanMethodV, |
| 2306 | CallStaticBooleanMethodA, |
| 2307 | CallStaticByteMethod, |
| 2308 | CallStaticByteMethodV, |
| 2309 | CallStaticByteMethodA, |
| 2310 | CallStaticCharMethod, |
| 2311 | CallStaticCharMethodV, |
| 2312 | CallStaticCharMethodA, |
| 2313 | CallStaticShortMethod, |
| 2314 | CallStaticShortMethodV, |
| 2315 | CallStaticShortMethodA, |
| 2316 | CallStaticIntMethod, |
| 2317 | CallStaticIntMethodV, |
| 2318 | CallStaticIntMethodA, |
| 2319 | CallStaticLongMethod, |
| 2320 | CallStaticLongMethodV, |
| 2321 | CallStaticLongMethodA, |
| 2322 | CallStaticFloatMethod, |
| 2323 | CallStaticFloatMethodV, |
| 2324 | CallStaticFloatMethodA, |
| 2325 | CallStaticDoubleMethod, |
| 2326 | CallStaticDoubleMethodV, |
| 2327 | CallStaticDoubleMethodA, |
| 2328 | CallStaticVoidMethod, |
| 2329 | CallStaticVoidMethodV, |
| 2330 | CallStaticVoidMethodA, |
| 2331 | GetStaticFieldID, |
| 2332 | GetStaticObjectField, |
| 2333 | GetStaticBooleanField, |
| 2334 | GetStaticByteField, |
| 2335 | GetStaticCharField, |
| 2336 | GetStaticShortField, |
| 2337 | GetStaticIntField, |
| 2338 | GetStaticLongField, |
| 2339 | GetStaticFloatField, |
| 2340 | GetStaticDoubleField, |
| 2341 | SetStaticObjectField, |
| 2342 | SetStaticBooleanField, |
| 2343 | SetStaticByteField, |
| 2344 | SetStaticCharField, |
| 2345 | SetStaticShortField, |
| 2346 | SetStaticIntField, |
| 2347 | SetStaticLongField, |
| 2348 | SetStaticFloatField, |
| 2349 | SetStaticDoubleField, |
| 2350 | NewString, |
| 2351 | GetStringLength, |
| 2352 | GetStringChars, |
| 2353 | ReleaseStringChars, |
| 2354 | NewStringUTF, |
| 2355 | GetStringUTFLength, |
| 2356 | GetStringUTFChars, |
| 2357 | ReleaseStringUTFChars, |
| 2358 | GetArrayLength, |
| 2359 | NewObjectArray, |
| 2360 | GetObjectArrayElement, |
| 2361 | SetObjectArrayElement, |
| 2362 | NewBooleanArray, |
| 2363 | NewByteArray, |
| 2364 | NewCharArray, |
| 2365 | NewShortArray, |
| 2366 | NewIntArray, |
| 2367 | NewLongArray, |
| 2368 | NewFloatArray, |
| 2369 | NewDoubleArray, |
| 2370 | GetBooleanArrayElements, |
| 2371 | GetByteArrayElements, |
| 2372 | GetCharArrayElements, |
| 2373 | GetShortArrayElements, |
| 2374 | GetIntArrayElements, |
| 2375 | GetLongArrayElements, |
| 2376 | GetFloatArrayElements, |
| 2377 | GetDoubleArrayElements, |
| 2378 | ReleaseBooleanArrayElements, |
| 2379 | ReleaseByteArrayElements, |
| 2380 | ReleaseCharArrayElements, |
| 2381 | ReleaseShortArrayElements, |
| 2382 | ReleaseIntArrayElements, |
| 2383 | ReleaseLongArrayElements, |
| 2384 | ReleaseFloatArrayElements, |
| 2385 | ReleaseDoubleArrayElements, |
| 2386 | GetBooleanArrayRegion, |
| 2387 | GetByteArrayRegion, |
| 2388 | GetCharArrayRegion, |
| 2389 | GetShortArrayRegion, |
| 2390 | GetIntArrayRegion, |
| 2391 | GetLongArrayRegion, |
| 2392 | GetFloatArrayRegion, |
| 2393 | GetDoubleArrayRegion, |
| 2394 | SetBooleanArrayRegion, |
| 2395 | SetByteArrayRegion, |
| 2396 | SetCharArrayRegion, |
| 2397 | SetShortArrayRegion, |
| 2398 | SetIntArrayRegion, |
| 2399 | SetLongArrayRegion, |
| 2400 | SetFloatArrayRegion, |
| 2401 | SetDoubleArrayRegion, |
| 2402 | RegisterNatives, |
| 2403 | UnregisterNatives, |
| 2404 | MonitorEnter, |
| 2405 | MonitorExit, |
| 2406 | GetJavaVM, |
| 2407 | GetStringRegion, |
| 2408 | GetStringUTFRegion, |
| 2409 | GetPrimitiveArrayCritical, |
| 2410 | ReleasePrimitiveArrayCritical, |
| 2411 | GetStringCritical, |
| 2412 | ReleaseStringCritical, |
| 2413 | NewWeakGlobalRef, |
| 2414 | DeleteWeakGlobalRef, |
| 2415 | ExceptionCheck, |
| 2416 | NewDirectByteBuffer, |
| 2417 | GetDirectBufferAddress, |
| 2418 | GetDirectBufferCapacity, |
| 2419 | GetObjectRefType, |
| 2420 | }; |
| 2421 | |
Elliott Hughes | 6c1a394 | 2011-08-17 15:00:06 -0700 | [diff] [blame] | 2422 | static const size_t kMonitorsInitial = 32; // Arbitrary. |
| 2423 | static const size_t kMonitorsMax = 4096; // Arbitrary sanity check. |
| 2424 | |
| 2425 | static const size_t kLocalsInitial = 64; // Arbitrary. |
| 2426 | static const size_t kLocalsMax = 512; // Arbitrary sanity check. |
Elliott Hughes | bbd7671 | 2011-08-17 10:25:24 -0700 | [diff] [blame] | 2427 | |
Elliott Hughes | 515a5bc | 2011-08-17 11:08:34 -0700 | [diff] [blame] | 2428 | JNIEnvExt::JNIEnvExt(Thread* self, bool check_jni) |
Elliott Hughes | bbd7671 | 2011-08-17 10:25:24 -0700 | [diff] [blame] | 2429 | : fns(&gNativeInterface), |
| 2430 | self(self), |
Elliott Hughes | 515a5bc | 2011-08-17 11:08:34 -0700 | [diff] [blame] | 2431 | check_jni(check_jni), |
Elliott Hughes | bbd7671 | 2011-08-17 10:25:24 -0700 | [diff] [blame] | 2432 | critical(false), |
Elliott Hughes | 6c1a394 | 2011-08-17 15:00:06 -0700 | [diff] [blame] | 2433 | monitors("monitors", kMonitorsInitial, kMonitorsMax), |
| 2434 | locals(kLocalsInitial, kLocalsMax, kLocal) { |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2435 | } |
| 2436 | |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2437 | // JNI Invocation interface. |
| 2438 | |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2439 | extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, void** p_env, void* vm_args) { |
| 2440 | const JavaVMInitArgs* args = static_cast<JavaVMInitArgs*>(vm_args); |
| 2441 | if (args->version < JNI_VERSION_1_2) { |
| 2442 | return JNI_EVERSION; |
| 2443 | } |
| 2444 | Runtime::Options options; |
| 2445 | for (int i = 0; i < args->nOptions; ++i) { |
| 2446 | JavaVMOption* option = &args->options[i]; |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 2447 | options.push_back(std::make_pair(StringPiece(option->optionString), |
| 2448 | option->extraInfo)); |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2449 | } |
| 2450 | bool ignore_unrecognized = args->ignoreUnrecognized; |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2451 | Runtime* runtime = Runtime::Create(options, ignore_unrecognized); |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2452 | if (runtime == NULL) { |
| 2453 | return JNI_ERR; |
| 2454 | } else { |
| 2455 | *p_env = reinterpret_cast<JNIEnv*>(Thread::Current()->GetJniEnv()); |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 2456 | *p_vm = reinterpret_cast<JavaVM*>(runtime->GetJavaVM()); |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2457 | return JNI_OK; |
| 2458 | } |
| 2459 | } |
| 2460 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2461 | extern "C" jint JNI_GetCreatedJavaVMs(JavaVM** vms, jsize, jsize* vm_count) { |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2462 | Runtime* runtime = Runtime::Current(); |
| 2463 | if (runtime == NULL) { |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2464 | *vm_count = 0; |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2465 | } else { |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2466 | *vm_count = 1; |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 2467 | vms[0] = reinterpret_cast<JavaVM*>(runtime->GetJavaVM()); |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2468 | } |
| 2469 | return JNI_OK; |
| 2470 | } |
| 2471 | |
| 2472 | // Historically unsupported. |
| 2473 | extern "C" jint JNI_GetDefaultJavaVMInitArgs(void* vm_args) { |
| 2474 | return JNI_ERR; |
| 2475 | } |
| 2476 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2477 | jint DestroyJavaVM(JavaVM* vm) { |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2478 | if (vm == NULL) { |
| 2479 | return JNI_ERR; |
| 2480 | } else { |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2481 | JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm); |
| 2482 | delete raw_vm->runtime; |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2483 | return JNI_OK; |
| 2484 | } |
| 2485 | } |
| 2486 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2487 | jint AttachCurrentThread(JavaVM* vm, JNIEnv** p_env, void* thr_args) { |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2488 | if (vm == NULL || p_env == NULL) { |
| 2489 | return JNI_ERR; |
| 2490 | } |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2491 | JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm); |
| 2492 | Runtime* runtime = raw_vm->runtime; |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2493 | const char* name = NULL; |
| 2494 | if (thr_args != NULL) { |
| 2495 | // TODO: check version |
| 2496 | name = static_cast<JavaVMAttachArgs*>(thr_args)->name; |
| 2497 | // TODO: thread group |
| 2498 | } |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2499 | bool success = runtime->AttachCurrentThread(name, p_env); |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2500 | if (!success) { |
| 2501 | return JNI_ERR; |
| 2502 | } else { |
| 2503 | return JNI_OK; |
| 2504 | } |
| 2505 | } |
| 2506 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2507 | jint DetachCurrentThread(JavaVM* vm) { |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2508 | if (vm == NULL) { |
| 2509 | return JNI_ERR; |
| 2510 | } else { |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2511 | JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm); |
| 2512 | Runtime* runtime = raw_vm->runtime; |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2513 | runtime->DetachCurrentThread(); |
| 2514 | return JNI_OK; |
| 2515 | } |
| 2516 | } |
| 2517 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2518 | jint GetEnv(JavaVM* vm, void** env, jint version) { |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2519 | if (version < JNI_VERSION_1_1 || version > JNI_VERSION_1_6) { |
| 2520 | return JNI_EVERSION; |
| 2521 | } |
| 2522 | if (vm == NULL || env == NULL) { |
| 2523 | return JNI_ERR; |
| 2524 | } |
| 2525 | Thread* thread = Thread::Current(); |
| 2526 | if (thread == NULL) { |
| 2527 | *env = NULL; |
| 2528 | return JNI_EDETACHED; |
| 2529 | } |
| 2530 | *env = thread->GetJniEnv(); |
| 2531 | return JNI_OK; |
| 2532 | } |
| 2533 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2534 | jint AttachCurrentThreadAsDaemon(JavaVM* vm, JNIEnv** p_env, void* thr_args) { |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2535 | if (vm == NULL || p_env == NULL) { |
| 2536 | return JNI_ERR; |
| 2537 | } |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2538 | JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm); |
| 2539 | Runtime* runtime = raw_vm->runtime; |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2540 | const char* name = NULL; |
| 2541 | if (thr_args != NULL) { |
| 2542 | // TODO: check version |
| 2543 | name = static_cast<JavaVMAttachArgs*>(thr_args)->name; |
| 2544 | // TODO: thread group |
| 2545 | } |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame] | 2546 | bool success = runtime->AttachCurrentThreadAsDaemon(name, p_env); |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 2547 | if (!success) { |
| 2548 | return JNI_ERR; |
| 2549 | } else { |
| 2550 | return JNI_OK; |
| 2551 | } |
| 2552 | } |
| 2553 | |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2554 | struct JNIInvokeInterface gInvokeInterface = { |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 2555 | NULL, // reserved0 |
| 2556 | NULL, // reserved1 |
| 2557 | NULL, // reserved2 |
| 2558 | DestroyJavaVM, |
| 2559 | AttachCurrentThread, |
| 2560 | DetachCurrentThread, |
| 2561 | GetEnv, |
| 2562 | AttachCurrentThreadAsDaemon |
| 2563 | }; |
| 2564 | |
Elliott Hughes | bbd7671 | 2011-08-17 10:25:24 -0700 | [diff] [blame] | 2565 | static const size_t kPinTableInitialSize = 16; |
| 2566 | static const size_t kPinTableMaxSize = 1024; |
| 2567 | |
Elliott Hughes | 6c1a394 | 2011-08-17 15:00:06 -0700 | [diff] [blame] | 2568 | static const size_t kGlobalsInitial = 512; // Arbitrary. |
| 2569 | static const size_t kGlobalsMax = 51200; // Arbitrary sanity check. |
| 2570 | |
| 2571 | static const size_t kWeakGlobalsInitial = 16; // Arbitrary. |
| 2572 | static const size_t kWeakGlobalsMax = 51200; // Arbitrary sanity check. |
| 2573 | |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 2574 | JavaVMExt::JavaVMExt(Runtime* runtime, bool check_jni, bool verbose_jni) |
Elliott Hughes | bbd7671 | 2011-08-17 10:25:24 -0700 | [diff] [blame] | 2575 | : fns(&gInvokeInterface), |
| 2576 | runtime(runtime), |
Elliott Hughes | 515a5bc | 2011-08-17 11:08:34 -0700 | [diff] [blame] | 2577 | check_jni(check_jni), |
Elliott Hughes | 0af5543 | 2011-08-17 18:37:28 -0700 | [diff] [blame] | 2578 | verbose_jni(verbose_jni), |
Elliott Hughes | 6c1a394 | 2011-08-17 15:00:06 -0700 | [diff] [blame] | 2579 | pin_table("pin table", kPinTableInitialSize, kPinTableMaxSize), |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 2580 | globals_lock(Mutex::Create("JNI global reference table lock")), |
Elliott Hughes | 6c1a394 | 2011-08-17 15:00:06 -0700 | [diff] [blame] | 2581 | globals(kGlobalsInitial, kGlobalsMax, kGlobal), |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame^] | 2582 | weak_globals_lock(Mutex::Create("JNI weak global reference table lock")), |
Elliott Hughes | 6c1a394 | 2011-08-17 15:00:06 -0700 | [diff] [blame] | 2583 | weak_globals(kWeakGlobalsInitial, kWeakGlobalsMax, kWeakGlobal) { |
Elliott Hughes | f2682d5 | 2011-08-15 16:37:04 -0700 | [diff] [blame] | 2584 | } |
| 2585 | |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 2586 | } // namespace art |