< prev index next >

src/hotspot/share/prims/jvm.cpp

Print this page

        

*** 51,60 **** --- 51,61 ---- #include "oops/instanceKlass.hpp" #include "oops/method.hpp" #include "oops/objArrayKlass.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" + #include "oops/valueArrayKlass.hpp" #include "prims/jvm_misc.hpp" #include "prims/jvmtiExport.hpp" #include "prims/jvmtiThreadState.hpp" #include "prims/nativeLookup.hpp" #include "prims/stackwalk.hpp"
*** 673,682 **** --- 674,684 ---- // Check if class of obj supports the Cloneable interface. // All arrays are considered to be cloneable (See JLS 20.1.5). // All j.l.r.Reference classes are considered non-cloneable. if (!klass->is_cloneable() || + klass->is_value() || (klass->is_instance_klass() && InstanceKlass::cast(klass)->reference_type() != REF_NONE)) { ResourceMark rm(THREAD); THROW_MSG_0(vmSymbols::java_lang_CloneNotSupportedException(), klass->external_name()); }
*** 760,770 **** JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)) JVMWrapper("JVM_FindPrimitiveClass"); oop mirror = NULL; BasicType t = name2type(utf); ! if (t != T_ILLEGAL && t != T_OBJECT && t != T_ARRAY) { mirror = Universe::java_mirror(t); } if (mirror == NULL) { THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf); } else { --- 762,772 ---- JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)) JVMWrapper("JVM_FindPrimitiveClass"); oop mirror = NULL; BasicType t = name2type(utf); ! if (t != T_ILLEGAL && t != T_OBJECT && t != T_ARRAY && t != T_VALUETYPE) { mirror = Universe::java_mirror(t); } if (mirror == NULL) { THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf); } else {
*** 1659,1672 **** return (jobjectArray) JNIHandles::make_local(env, result()); } JVM_END static bool select_method(const methodHandle& method, bool want_constructor) { if (want_constructor) { ! return (method->is_initializer() && !method->is_static()); } else { ! return (!method->is_initializer() && !method->is_overpass()); } } static jobjectArray get_class_declared_methods_helper( JNIEnv *env, --- 1661,1678 ---- return (jobjectArray) JNIHandles::make_local(env, result()); } JVM_END static bool select_method(const methodHandle& method, bool want_constructor) { + bool is_ctor = (method->is_object_constructor() || + method->is_static_init_factory()); if (want_constructor) { ! return is_ctor; } else { ! return (!is_ctor && ! !method->is_class_initializer() && ! !method->is_overpass()); } } static jobjectArray get_class_declared_methods_helper( JNIEnv *env,
*** 1724,1733 **** --- 1730,1741 ---- // Otherwise should probably put a method that throws NSME result->obj_at_put(i, NULL); } else { oop m; if (want_constructor) { + assert(method->is_object_constructor() || + method->is_static_init_factory(), "must be"); m = Reflection::new_constructor(method, CHECK_NULL); } else { m = Reflection::new_method(method, false, CHECK_NULL); } result->obj_at_put(i, m);
*** 1940,1953 **** methodHandle m (THREAD, k->find_method(name, sig)); if (m.is_null()) { THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); } oop method; ! if (!m->is_initializer() || m->is_static()) { ! method = Reflection::new_method(m, true, CHECK_NULL); ! } else { method = Reflection::new_constructor(m, CHECK_NULL); } return JNIHandles::make_local(method); } JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject obj, jobject unused, jint index)) --- 1948,1961 ---- methodHandle m (THREAD, k->find_method(name, sig)); if (m.is_null()) { THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); } oop method; ! if (m->is_object_constructor()) { method = Reflection::new_constructor(m, CHECK_NULL); + } else { + method = Reflection::new_method(m, true, CHECK_NULL); } return JNIHandles::make_local(method); } JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject obj, jobject unused, jint index))
*** 2231,2240 **** --- 2239,2290 ---- JvmtiVMObjectAllocEventCollector oam; oop asd = JavaAssertions::createAssertionStatusDirectives(CHECK_NULL); return JNIHandles::make_local(env, asd); JVM_END + // Arrays support ///////////////////////////////////////////////////////////// + + JVM_ENTRY(jboolean, JVM_ArrayIsAccessAtomic(JNIEnv *env, jclass unused, jobject array)) + JVMWrapper("JVM_ArrayIsAccessAtomic"); + oop o = JNIHandles::resolve(array); + Klass* k = o->klass(); + if ((o == NULL) || (!k->is_array_klass())) { + THROW_0(vmSymbols::java_lang_IllegalArgumentException()); + } + if (k->is_valueArray_klass()) { + return ValueArrayKlass::cast(k)->is_atomic(); + } + return true; + JVM_END + + JVM_ENTRY(jobject, JVM_ArrayEnsureAccessAtomic(JNIEnv *env, jclass unused, jobject array)) + JVMWrapper("JVM_ArrayEnsureAccessAtomic"); + oop o = JNIHandles::resolve(array); + Klass* k = o->klass(); + if ((o == NULL) || (!k->is_array_klass())) { + THROW_0(vmSymbols::java_lang_IllegalArgumentException()); + } + if (k->is_valueArray_klass()) { + ValueArrayKlass* vk = ValueArrayKlass::cast(k); + if (!vk->is_atomic()) { + /** + * Need to decide how to implement: + * + * 1) Change to objArrayOop layout, therefore oop->klass() differs so + * then "<atomic>[Qfoo;" klass needs to subclass "[Qfoo;" to pass through + * "checkcast" & "instanceof" + * + * 2) Use extra header in the valueArrayOop to flag atomicity required and + * possibly per instance lock structure. Said info, could be placed in + * "trailer" rather than disturb the current arrayOop + */ + Unimplemented(); + } + } + return array; + JVM_END + // Verification //////////////////////////////////////////////////////////////////////////////// // Reflection for the verifier ///////////////////////////////////////////////////////////////// // RedefineClasses support: bug 6214132 caused verification to fail.
*** 2261,2271 **** // (length is determined by call to JVM_GetClassCPEntriesCount) if (k->is_instance_klass()) { ConstantPool* cp = InstanceKlass::cast(k)->constants(); for (int index = cp->length() - 1; index >= 0; index--) { constantTag tag = cp->tag_at(index); ! types[index] = (tag.is_unresolved_klass()) ? JVM_CONSTANT_Class : tag.value(); } } JVM_END --- 2311,2321 ---- // (length is determined by call to JVM_GetClassCPEntriesCount) if (k->is_instance_klass()) { ConstantPool* cp = InstanceKlass::cast(k)->constants(); for (int index = cp->length() - 1; index >= 0; index--) { constantTag tag = cp->tag_at(index); ! types[index] = tag.is_unresolved_klass() ? JVM_CONSTANT_Class : tag.value(); } } JVM_END
*** 2410,2420 **** JVMWrapper("JVM_IsConstructorIx"); ResourceMark rm(THREAD); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); Method* method = InstanceKlass::cast(k)->methods()->at(method_index); ! return method->name() == vmSymbols::object_initializer_name(); JVM_END JVM_QUICK_ENTRY(jboolean, JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cls, int method_index)) JVMWrapper("JVM_IsVMGeneratedMethodIx"); --- 2460,2470 ---- JVMWrapper("JVM_IsConstructorIx"); ResourceMark rm(THREAD); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); Method* method = InstanceKlass::cast(k)->methods()->at(method_index); ! return method->is_object_constructor(); JVM_END JVM_QUICK_ENTRY(jboolean, JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cls, int method_index)) JVMWrapper("JVM_IsVMGeneratedMethodIx");
*** 3448,3458 **** JVMWrapper("JVM_InvokeMethod"); Handle method_handle; if (thread->stack_available((address) &method_handle) >= JVMInvokeMethodSlack) { method_handle = Handle(THREAD, JNIHandles::resolve(method)); Handle receiver(THREAD, JNIHandles::resolve(obj)); ! objArrayHandle args(THREAD, objArrayOop(JNIHandles::resolve(args0))); oop result = Reflection::invoke_method(method_handle(), receiver, args, CHECK_NULL); jobject res = JNIHandles::make_local(env, result); if (JvmtiExport::should_post_vm_object_alloc()) { oop ret_type = java_lang_reflect_Method::return_type(method_handle()); assert(ret_type != NULL, "sanity check: ret_type oop must not be NULL!"); --- 3498,3508 ---- JVMWrapper("JVM_InvokeMethod"); Handle method_handle; if (thread->stack_available((address) &method_handle) >= JVMInvokeMethodSlack) { method_handle = Handle(THREAD, JNIHandles::resolve(method)); Handle receiver(THREAD, JNIHandles::resolve(obj)); ! objArrayHandle args = oopFactory::ensure_objArray(JNIHandles::resolve(args0), CHECK_NULL); oop result = Reflection::invoke_method(method_handle(), receiver, args, CHECK_NULL); jobject res = JNIHandles::make_local(env, result); if (JvmtiExport::should_post_vm_object_alloc()) { oop ret_type = java_lang_reflect_Method::return_type(method_handle()); assert(ret_type != NULL, "sanity check: ret_type oop must not be NULL!");
*** 3469,3480 **** JVM_END JVM_ENTRY(jobject, JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0)) JVMWrapper("JVM_NewInstanceFromConstructor"); oop constructor_mirror = JNIHandles::resolve(c); - objArrayHandle args(THREAD, objArrayOop(JNIHandles::resolve(args0))); oop result = Reflection::invoke_constructor(constructor_mirror, args, CHECK_NULL); jobject res = JNIHandles::make_local(env, result); if (JvmtiExport::should_post_vm_object_alloc()) { JvmtiExport::post_vm_object_alloc(JavaThread::current(), result); } --- 3519,3530 ---- JVM_END JVM_ENTRY(jobject, JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0)) JVMWrapper("JVM_NewInstanceFromConstructor"); + objArrayHandle args = oopFactory::ensure_objArray(JNIHandles::resolve(args0), CHECK_NULL); oop constructor_mirror = JNIHandles::resolve(c); oop result = Reflection::invoke_constructor(constructor_mirror, args, CHECK_NULL); jobject res = JNIHandles::make_local(env, result); if (JvmtiExport::should_post_vm_object_alloc()) { JvmtiExport::post_vm_object_alloc(JavaThread::current(), result); }
< prev index next >