Mercurial > hg > graal-compiler
comparison src/share/vm/prims/jvm.cpp @ 7482:989155e2d07a
Merge with hs25-b15.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Jan 2013 01:34:24 +0100 |
parents | 1baf7f1e3f23 ade95d680b42 |
children | 3ac7d10a6572 |
comparison
equal
deleted
inserted
replaced
7381:6761a8f854a4 | 7482:989155e2d07a |
---|---|
1515 | 1515 |
1516 return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(fd.annotations(), THREAD)); | 1516 return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(fd.annotations(), THREAD)); |
1517 JVM_END | 1517 JVM_END |
1518 | 1518 |
1519 | 1519 |
1520 static Method* jvm_get_method_common(jobject method, TRAPS) { | 1520 static Method* jvm_get_method_common(jobject method) { |
1521 // some of this code was adapted from from jni_FromReflectedMethod | 1521 // some of this code was adapted from from jni_FromReflectedMethod |
1522 | 1522 |
1523 oop reflected = JNIHandles::resolve_non_null(method); | 1523 oop reflected = JNIHandles::resolve_non_null(method); |
1524 oop mirror = NULL; | 1524 oop mirror = NULL; |
1525 int slot = 0; | 1525 int slot = 0; |
1533 mirror = java_lang_reflect_Method::clazz(reflected); | 1533 mirror = java_lang_reflect_Method::clazz(reflected); |
1534 slot = java_lang_reflect_Method::slot(reflected); | 1534 slot = java_lang_reflect_Method::slot(reflected); |
1535 } | 1535 } |
1536 Klass* k = java_lang_Class::as_Klass(mirror); | 1536 Klass* k = java_lang_Class::as_Klass(mirror); |
1537 | 1537 |
1538 KlassHandle kh(THREAD, k); | 1538 Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); |
1539 Method* m = InstanceKlass::cast(kh())->method_with_idnum(slot); | |
1540 if (m == NULL) { | 1539 if (m == NULL) { |
1541 assert(false, "cannot find method"); | 1540 assert(false, "cannot find method"); |
1542 return NULL; // robustness | 1541 return NULL; // robustness |
1543 } | 1542 } |
1544 | 1543 |
1548 | 1547 |
1549 JVM_ENTRY(jbyteArray, JVM_GetMethodAnnotations(JNIEnv *env, jobject method)) | 1548 JVM_ENTRY(jbyteArray, JVM_GetMethodAnnotations(JNIEnv *env, jobject method)) |
1550 JVMWrapper("JVM_GetMethodAnnotations"); | 1549 JVMWrapper("JVM_GetMethodAnnotations"); |
1551 | 1550 |
1552 // method is a handle to a java.lang.reflect.Method object | 1551 // method is a handle to a java.lang.reflect.Method object |
1553 Method* m = jvm_get_method_common(method, CHECK_NULL); | 1552 Method* m = jvm_get_method_common(method); |
1554 return (jbyteArray) JNIHandles::make_local(env, | 1553 return (jbyteArray) JNIHandles::make_local(env, |
1555 Annotations::make_java_array(m->annotations(), THREAD)); | 1554 Annotations::make_java_array(m->annotations(), THREAD)); |
1556 JVM_END | 1555 JVM_END |
1557 | 1556 |
1558 | 1557 |
1559 JVM_ENTRY(jbyteArray, JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)) | 1558 JVM_ENTRY(jbyteArray, JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)) |
1560 JVMWrapper("JVM_GetMethodDefaultAnnotationValue"); | 1559 JVMWrapper("JVM_GetMethodDefaultAnnotationValue"); |
1561 | 1560 |
1562 // method is a handle to a java.lang.reflect.Method object | 1561 // method is a handle to a java.lang.reflect.Method object |
1563 Method* m = jvm_get_method_common(method, CHECK_NULL); | 1562 Method* m = jvm_get_method_common(method); |
1564 return (jbyteArray) JNIHandles::make_local(env, | 1563 return (jbyteArray) JNIHandles::make_local(env, |
1565 Annotations::make_java_array(m->annotation_default(), THREAD)); | 1564 Annotations::make_java_array(m->annotation_default(), THREAD)); |
1566 JVM_END | 1565 JVM_END |
1567 | 1566 |
1568 | 1567 |
1569 JVM_ENTRY(jbyteArray, JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)) | 1568 JVM_ENTRY(jbyteArray, JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)) |
1570 JVMWrapper("JVM_GetMethodParameterAnnotations"); | 1569 JVMWrapper("JVM_GetMethodParameterAnnotations"); |
1571 | 1570 |
1572 // method is a handle to a java.lang.reflect.Method object | 1571 // method is a handle to a java.lang.reflect.Method object |
1573 Method* m = jvm_get_method_common(method, CHECK_NULL); | 1572 Method* m = jvm_get_method_common(method); |
1574 return (jbyteArray) JNIHandles::make_local(env, | 1573 return (jbyteArray) JNIHandles::make_local(env, |
1575 Annotations::make_java_array(m->parameter_annotations(), THREAD)); | 1574 Annotations::make_java_array(m->parameter_annotations(), THREAD)); |
1576 JVM_END | 1575 JVM_END |
1577 | 1576 |
1577 /* Type use annotations support (JDK 1.8) */ | |
1578 | |
1579 JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls)) | |
1580 assert (cls != NULL, "illegal class"); | |
1581 JVMWrapper("JVM_GetClassTypeAnnotations"); | |
1582 ResourceMark rm(THREAD); | |
1583 // Return null for arrays and primitives | |
1584 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { | |
1585 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); | |
1586 if (k->oop_is_instance()) { | |
1587 typeArrayOop a = Annotations::make_java_array(InstanceKlass::cast(k)->type_annotations()->class_annotations(), CHECK_NULL); | |
1588 return (jbyteArray) JNIHandles::make_local(env, a); | |
1589 } | |
1590 } | |
1591 return NULL; | |
1592 JVM_END | |
1593 | |
1594 JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method)) | |
1595 { | |
1596 JVMWrapper("JVM_GetMethodParameters"); | |
1597 // method is a handle to a java.lang.reflect.Method object | |
1598 Method* method_ptr = jvm_get_method_common(method); | |
1599 methodHandle mh (THREAD, method_ptr); | |
1600 Handle reflected_method (THREAD, JNIHandles::resolve_non_null(method)); | |
1601 const int num_params = mh->method_parameters_length(); | |
1602 | |
1603 if(0 != num_params) { | |
1604 objArrayOop result_oop = oopFactory::new_objArray(SystemDictionary::reflect_Parameter_klass(), num_params, CHECK_NULL); | |
1605 objArrayHandle result (THREAD, result_oop); | |
1606 | |
1607 for(int i = 0; i < num_params; i++) { | |
1608 MethodParametersElement* params = mh->method_parameters_start(); | |
1609 Symbol* const sym = mh->constants()->symbol_at(params[i].name_cp_index); | |
1610 oop param = Reflection::new_parameter(reflected_method, i, sym, | |
1611 params[i].flags, CHECK_NULL); | |
1612 result->obj_at_put(i, param); | |
1613 } | |
1614 return (jobjectArray)JNIHandles::make_local(env, result()); | |
1615 } else { | |
1616 return (jobjectArray)NULL; | |
1617 } | |
1618 } | |
1619 JVM_END | |
1578 | 1620 |
1579 // New (JDK 1.4) reflection implementation ///////////////////////////////////// | 1621 // New (JDK 1.4) reflection implementation ///////////////////////////////////// |
1580 | 1622 |
1581 JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)) | 1623 JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)) |
1582 { | 1624 { |