comparison src/share/vm/runtime/jniHandles.hpp @ 7066:7d815d842ee0

Merge.
author Christian Haeubl <haeubl@ssw.jku.at>
date Fri, 23 Nov 2012 11:50:27 +0100
parents da91efe96a93
children 63a4eb8bcd23
comparison
equal deleted inserted replaced
7065:cfacf5d5bade 7066:7d815d842ee0
1 /* 1 /*
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
59 static void destroy_global(jobject handle); 59 static void destroy_global(jobject handle);
60 60
61 // Weak global handles 61 // Weak global handles
62 static jobject make_weak_global(Handle obj); 62 static jobject make_weak_global(Handle obj);
63 static void destroy_weak_global(jobject handle); 63 static void destroy_weak_global(jobject handle);
64
65 // jmethodID handling (as Weak global handles).
66 // Because the useful life-span of a jmethodID cannot be determined, once created they are
67 // never reclaimed. The methods to which they refer, however, can be GC'ed away if the class
68 // is unloaded or if the method is made obsolete or deleted -- in these cases, the jmethodID
69 // refers to NULL (as is the case for any weak reference).
70 static jmethodID make_jmethod_id(methodHandle mh);
71 static void destroy_jmethod_id(jmethodID mid);
72 // Use resolve_jmethod_id() in situations where the caller is expected
73 // to provide a valid jmethodID; the only sanity checks are in asserts;
74 // result guaranteed not to be NULL.
75 inline static methodOop resolve_jmethod_id(jmethodID mid);
76 // Use checked_resolve_jmethod_id() in situations where the caller
77 // should provide a valid jmethodID, but might not. NULL is returned
78 // when the jmethodID does not refer to a valid method.
79 inline static methodOop checked_resolve_jmethod_id(jmethodID mid);
80 static void change_method_associated_with_jmethod_id(jmethodID jmid, methodHandle mh);
81 64
82 // Sentinel marking deleted handles in block. Note that we cannot store NULL as 65 // Sentinel marking deleted handles in block. Note that we cannot store NULL as
83 // the sentinel, since clearing weak global JNI refs are done by storing NULL in 66 // the sentinel, since clearing weak global JNI refs are done by storing NULL in
84 // the handle. The handle may not be reused before destroy_weak_global is called. 67 // the handle. The handle may not be reused before destroy_weak_global is called.
85 static oop deleted_handle() { return _deleted_handle; } 68 static oop deleted_handle() { return _deleted_handle; }
205 // Don't let that private _deleted_handle object escape into the wild. 188 // Don't let that private _deleted_handle object escape into the wild.
206 assert(result != deleted_handle(), "Used a deleted global handle."); 189 assert(result != deleted_handle(), "Used a deleted global handle.");
207 return result; 190 return result;
208 }; 191 };
209 192
210 inline methodOop JNIHandles::resolve_jmethod_id(jmethodID mid) {
211 return (methodOop) resolve_non_null((jobject)mid);
212 };
213
214 inline methodOop JNIHandles::checked_resolve_jmethod_id(jmethodID mid) {
215 oop o = resolve_external_guard((jobject) mid);
216 if (o == NULL || !o->is_method()) {
217 return (methodOop) NULL;
218 }
219
220 return (methodOop) o;
221 };
222
223
224 inline void JNIHandles::destroy_local(jobject handle) { 193 inline void JNIHandles::destroy_local(jobject handle) {
225 if (handle != NULL) { 194 if (handle != NULL) {
226 *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it 195 *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
227 } 196 }
228 } 197 }