src/share/vm/runtime/jniHandles.hpp

changeset 1890
d3562366cbfd
parent 1352
1760a1cbed36
child 1891
892898e961c5
equal deleted inserted replaced
1352:1760a1cbed36 1890:d3562366cbfd
1 /* 1 /*
2 * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 1998-2010 Sun Microsystems, Inc. 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.
61 // never reclaimed. The methods to which they refer, however, can be GC'ed away if the class 61 // never reclaimed. The methods to which they refer, however, can be GC'ed away if the class
62 // is unloaded or if the method is made obsolete or deleted -- in these cases, the jmethodID 62 // is unloaded or if the method is made obsolete or deleted -- in these cases, the jmethodID
63 // refers to NULL (as is the case for any weak reference). 63 // refers to NULL (as is the case for any weak reference).
64 static jmethodID make_jmethod_id(methodHandle mh); 64 static jmethodID make_jmethod_id(methodHandle mh);
65 static void destroy_jmethod_id(jmethodID mid); 65 static void destroy_jmethod_id(jmethodID mid);
66 // Use resolve_jmethod_id() in situations where the caller is expected
67 // to provide a valid jmethodID; the only sanity checks are in asserts;
68 // result guaranteed not to be NULL.
66 inline static methodOop resolve_jmethod_id(jmethodID mid); 69 inline static methodOop resolve_jmethod_id(jmethodID mid);
67 inline static methodOop checked_resolve_jmethod_id(jmethodID mid); // NULL on invalid jmethodID 70 // Use checked_resolve_jmethod_id() in situations where the caller
71 // should provide a valid jmethodID, but might not. NULL is returned
72 // when the jmethodID does not refer to a valid method.
73 inline static methodOop checked_resolve_jmethod_id(jmethodID mid);
68 static void change_method_associated_with_jmethod_id(jmethodID jmid, methodHandle mh); 74 static void change_method_associated_with_jmethod_id(jmethodID jmid, methodHandle mh);
69 75
70 // Sentinel marking deleted handles in block. Note that we cannot store NULL as 76 // Sentinel marking deleted handles in block. Note that we cannot store NULL as
71 // the sentinel, since clearing weak global JNI refs are done by storing NULL in 77 // the sentinel, since clearing weak global JNI refs are done by storing NULL in
72 // the handle. The handle may not be reused before destroy_weak_global is called. 78 // the handle. The handle may not be reused before destroy_weak_global is called.
194 inline methodOop JNIHandles::resolve_jmethod_id(jmethodID mid) { 200 inline methodOop JNIHandles::resolve_jmethod_id(jmethodID mid) {
195 return (methodOop) resolve_non_null((jobject)mid); 201 return (methodOop) resolve_non_null((jobject)mid);
196 }; 202 };
197 203
198 inline methodOop JNIHandles::checked_resolve_jmethod_id(jmethodID mid) { 204 inline methodOop JNIHandles::checked_resolve_jmethod_id(jmethodID mid) {
199 if (mid == NULL) { 205 oop o = resolve_external_guard((jobject) mid);
200 return (methodOop) NULL; 206 if (o == NULL || !o->is_method()) {
201 }
202
203 oop o = resolve_non_null((jobject) mid);
204 if (!o->is_method()) {
205 return (methodOop) NULL; 207 return (methodOop) NULL;
206 } 208 }
207 209
208 return (methodOop) o; 210 return (methodOop) o;
209 }; 211 };

mercurial