31 #include "classfile/javaClasses.inline.hpp"
32 #include "classfile/moduleEntry.hpp"
33 #include "classfile/modules.hpp"
34 #include "classfile/packageEntry.hpp"
35 #include "classfile/stringTable.hpp"
36 #include "classfile/symbolTable.hpp"
37 #include "classfile/systemDictionary.hpp"
38 #include "classfile/vmSymbols.hpp"
39 #include "gc/shared/collectedHeap.inline.hpp"
40 #include "interpreter/bytecode.hpp"
41 #include "interpreter/bytecodeUtils.hpp"
42 #include "jfr/jfrEvents.hpp"
43 #include "logging/log.hpp"
44 #include "memory/heapShared.hpp"
45 #include "memory/oopFactory.hpp"
46 #include "memory/referenceType.hpp"
47 #include "memory/resourceArea.hpp"
48 #include "memory/universe.hpp"
49 #include "oops/access.inline.hpp"
50 #include "oops/constantPool.hpp"
51 #include "oops/fieldStreams.hpp"
52 #include "oops/instanceKlass.hpp"
53 #include "oops/method.hpp"
54 #include "oops/objArrayKlass.hpp"
55 #include "oops/objArrayOop.inline.hpp"
56 #include "oops/oop.inline.hpp"
57 #include "prims/jvm_misc.hpp"
58 #include "prims/jvmtiExport.hpp"
59 #include "prims/jvmtiThreadState.hpp"
60 #include "prims/nativeLookup.hpp"
61 #include "prims/stackwalk.hpp"
62 #include "runtime/arguments.hpp"
63 #include "runtime/atomic.hpp"
64 #include "runtime/handles.inline.hpp"
65 #include "runtime/init.hpp"
66 #include "runtime/interfaceSupport.inline.hpp"
67 #include "runtime/deoptimization.hpp"
68 #include "runtime/handshake.hpp"
69 #include "runtime/java.hpp"
70 #include "runtime/javaCalls.hpp"
71 #include "runtime/jfieldIDWorkaround.hpp"
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 (num_params < 0) {
1604 // A -1 return value from method_parameters_length means there is no
1605 // parameter data. Return null to indicate this to the reflection
1606 // API.
1607 assert(num_params == -1, "num_params should be -1 if it is less than zero");
1608 return (jobjectArray)NULL;
1609 } else {
1610 // Otherwise, we return something up to reflection, even if it is
1611 // a zero-length array. Why? Because in some cases this can
1612 // trigger a MalformedParametersException.
1613
1614 // make sure all the symbols are properly formatted
1615 for (int i = 0; i < num_params; i++) {
1616 MethodParametersElement* params = mh->method_parameters_start();
1617 int index = params[i].name_cp_index;
1618 bounds_check(mh->constants(), index, CHECK_NULL);
1619
1620 if (0 != index && !mh->constants()->tag_at(index).is_utf8()) {
1621 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
1622 "Wrong type at constant pool index");
1623 }
1624
1625 }
1626
1627 objArrayOop result_oop = oopFactory::new_objArray(SystemDictionary::reflect_Parameter_klass(), num_params, CHECK_NULL);
1628 objArrayHandle result (THREAD, result_oop);
1629
1630 for (int i = 0; i < num_params; i++) {
1631 MethodParametersElement* params = mh->method_parameters_start();
1632 // For a 0 index, give a NULL symbol
1633 Symbol* sym = 0 != params[i].name_cp_index ?
1634 mh->constants()->symbol_at(params[i].name_cp_index) : NULL;
1635 int flags = params[i].flags;
1636 oop param = Reflection::new_parameter(reflected_method, i, sym,
1637 flags, CHECK_NULL);
1638 result->obj_at_put(i, param);
|
31 #include "classfile/javaClasses.inline.hpp"
32 #include "classfile/moduleEntry.hpp"
33 #include "classfile/modules.hpp"
34 #include "classfile/packageEntry.hpp"
35 #include "classfile/stringTable.hpp"
36 #include "classfile/symbolTable.hpp"
37 #include "classfile/systemDictionary.hpp"
38 #include "classfile/vmSymbols.hpp"
39 #include "gc/shared/collectedHeap.inline.hpp"
40 #include "interpreter/bytecode.hpp"
41 #include "interpreter/bytecodeUtils.hpp"
42 #include "jfr/jfrEvents.hpp"
43 #include "logging/log.hpp"
44 #include "memory/heapShared.hpp"
45 #include "memory/oopFactory.hpp"
46 #include "memory/referenceType.hpp"
47 #include "memory/resourceArea.hpp"
48 #include "memory/universe.hpp"
49 #include "oops/access.inline.hpp"
50 #include "oops/constantPool.hpp"
51 #include "oops/fieldStreams.inline.hpp"
52 #include "oops/instanceKlass.hpp"
53 #include "oops/method.hpp"
54 #include "oops/objArrayKlass.hpp"
55 #include "oops/objArrayOop.inline.hpp"
56 #include "oops/oop.inline.hpp"
57 #include "prims/jvm_misc.hpp"
58 #include "prims/jvmtiExport.hpp"
59 #include "prims/jvmtiThreadState.hpp"
60 #include "prims/nativeLookup.hpp"
61 #include "prims/stackwalk.hpp"
62 #include "runtime/arguments.hpp"
63 #include "runtime/atomic.hpp"
64 #include "runtime/handles.inline.hpp"
65 #include "runtime/init.hpp"
66 #include "runtime/interfaceSupport.inline.hpp"
67 #include "runtime/deoptimization.hpp"
68 #include "runtime/handshake.hpp"
69 #include "runtime/java.hpp"
70 #include "runtime/javaCalls.hpp"
71 #include "runtime/jfieldIDWorkaround.hpp"
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 (num_params < 0) {
1604 // A -1 return value from method_parameters_length means there is no
1605 // parameter data. Return null to indicate this to the reflection
1606 // API.
1607 assert(num_params == -1, "num_params should be -1 if it is less than zero");
1608 return (jobjectArray)NULL;
1609 } else {
1610 // Otherwise, we return something up to reflection, even if it is
1611 // a zero-length array. Why? Because in some cases this can
1612 // trigger a MalformedParametersException.
1613
1614 // make sure all the symbols are properly formatted
1615 for (int i = 0; i < num_params; i++) {
1616 MethodParametersElement* params = mh->method_parameters_start();
1617 int index = params[i].name_cp_index;
1618 constantPoolHandle cp(THREAD, mh->constants());
1619 bounds_check(cp, index, CHECK_NULL);
1620
1621 if (0 != index && !mh->constants()->tag_at(index).is_utf8()) {
1622 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
1623 "Wrong type at constant pool index");
1624 }
1625
1626 }
1627
1628 objArrayOop result_oop = oopFactory::new_objArray(SystemDictionary::reflect_Parameter_klass(), num_params, CHECK_NULL);
1629 objArrayHandle result (THREAD, result_oop);
1630
1631 for (int i = 0; i < num_params; i++) {
1632 MethodParametersElement* params = mh->method_parameters_start();
1633 // For a 0 index, give a NULL symbol
1634 Symbol* sym = 0 != params[i].name_cp_index ?
1635 mh->constants()->symbol_at(params[i].name_cp_index) : NULL;
1636 int flags = params[i].flags;
1637 oop param = Reflection::new_parameter(reflected_method, i, sym,
1638 flags, CHECK_NULL);
1639 result->obj_at_put(i, param);
|