hotspot/src/share/vm/runtime/reflection.cpp
changeset 14391 df0a1573d5bd
parent 14385 959bbcc16725
child 14488 ab48109f7d1b
equal deleted inserted replaced
14390:bd0d881cf1c5 14391:df0a1573d5bd
    54   JavaThread* jthread = JavaThread::current();
    54   JavaThread* jthread = JavaThread::current();
    55   if (jthread->has_last_Java_frame()) {
    55   if (jthread->has_last_Java_frame()) {
    56     vframeStream vfst(jthread);
    56     vframeStream vfst(jthread);
    57     // skip over any frames belonging to java.lang.Class
    57     // skip over any frames belonging to java.lang.Class
    58     while (!vfst.at_end() &&
    58     while (!vfst.at_end() &&
    59            InstanceKlass::cast(vfst.method()->method_holder())->name() == vmSymbols::java_lang_Class()) {
    59            vfst.method()->method_holder()->name() == vmSymbols::java_lang_Class()) {
    60       vfst.next();
    60       vfst.next();
    61     }
    61     }
    62     if (!vfst.at_end()) {
    62     if (!vfst.at_end()) {
    63       // this frame is a likely suspect
    63       // this frame is a likely suspect
    64       caller = vfst.method()->method_holder();
    64       caller = vfst.method()->method_holder();
    65       line_number = vfst.method()->line_number_from_bci(vfst.bci());
    65       line_number = vfst.method()->line_number_from_bci(vfst.bci());
    66       Symbol* s = InstanceKlass::cast(vfst.method()->method_holder())->source_file_name();
    66       Symbol* s = vfst.method()->method_holder()->source_file_name();
    67       if (s != NULL) {
    67       if (s != NULL) {
    68         source_file = s->as_C_string();
    68         source_file = s->as_C_string();
    69       }
    69       }
    70     }
    70     }
    71   }
    71   }
   640       assert(ss->type() != T_VOID || ss->at_return_type(), "T_VOID should only appear as return type");
   640       assert(ss->type() != T_VOID || ss->at_return_type(), "T_VOID should only appear as return type");
   641       return java_lang_Class::primitive_mirror(ss->type());
   641       return java_lang_Class::primitive_mirror(ss->type());
   642     case T_OBJECT:
   642     case T_OBJECT:
   643     case T_ARRAY:
   643     case T_ARRAY:
   644       Symbol* name        = ss->as_symbol(CHECK_NULL);
   644       Symbol* name        = ss->as_symbol(CHECK_NULL);
   645       oop loader            = InstanceKlass::cast(method->method_holder())->class_loader();
   645       oop loader            = method->method_holder()->class_loader();
   646       oop protection_domain = InstanceKlass::cast(method->method_holder())->protection_domain();
   646       oop protection_domain = method->method_holder()->protection_domain();
   647       Klass* k = SystemDictionary::resolve_or_fail(
   647       Klass* k = SystemDictionary::resolve_or_fail(
   648                                        name,
   648                                        name,
   649                                        Handle(THREAD, loader),
   649                                        Handle(THREAD, loader),
   650                                        Handle(THREAD, protection_domain),
   650                                        Handle(THREAD, protection_domain),
   651                                        true, CHECK_NULL);
   651                                        true, CHECK_NULL);
   712   // In jdk1.2.x, getMethods on an interface erroneously includes <clinit>, thus the complicated assert.
   712   // In jdk1.2.x, getMethods on an interface erroneously includes <clinit>, thus the complicated assert.
   713   // Also allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
   713   // Also allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
   714   assert(!method()->is_initializer() ||
   714   assert(!method()->is_initializer() ||
   715          (for_constant_pool_access && method()->is_static()) ||
   715          (for_constant_pool_access && method()->is_static()) ||
   716          (method()->name() == vmSymbols::class_initializer_name()
   716          (method()->name() == vmSymbols::class_initializer_name()
   717     && Klass::cast(method()->method_holder())->is_interface() && JDK_Version::is_jdk12x_version()), "should call new_constructor instead");
   717     && method()->method_holder()->is_interface() && JDK_Version::is_jdk12x_version()), "should call new_constructor instead");
   718   instanceKlassHandle holder (THREAD, method->method_holder());
   718   instanceKlassHandle holder (THREAD, method->method_holder());
   719   int slot = method->method_idnum();
   719   int slot = method->method_idnum();
   720 
   720 
   721   Symbol*  signature  = method->signature();
   721   Symbol*  signature  = method->signature();
   722   int parameter_count = ArgumentCount(signature).size();
   722   int parameter_count = ArgumentCount(signature).size();
   830   Symbol*  signature  = fd->signature();
   830   Symbol*  signature  = fd->signature();
   831   instanceKlassHandle  holder    (THREAD, fd->field_holder());
   831   instanceKlassHandle  holder    (THREAD, fd->field_holder());
   832   Handle type = new_type(signature, holder, CHECK_NULL);
   832   Handle type = new_type(signature, holder, CHECK_NULL);
   833   Handle rh  = java_lang_reflect_Field::create(CHECK_NULL);
   833   Handle rh  = java_lang_reflect_Field::create(CHECK_NULL);
   834 
   834 
   835   java_lang_reflect_Field::set_clazz(rh(), Klass::cast(fd->field_holder())->java_mirror());
   835   java_lang_reflect_Field::set_clazz(rh(), fd->field_holder()->java_mirror());
   836   java_lang_reflect_Field::set_slot(rh(), fd->index());
   836   java_lang_reflect_Field::set_slot(rh(), fd->index());
   837   java_lang_reflect_Field::set_name(rh(), name());
   837   java_lang_reflect_Field::set_name(rh(), name());
   838   java_lang_reflect_Field::set_type(rh(), type());
   838   java_lang_reflect_Field::set_type(rh(), type());
   839   // Note the ACC_ANNOTATION bit, which is a per-class access flag, is never set here.
   839   // Note the ACC_ANNOTATION bit, which is a per-class access flag, is never set here.
   840   java_lang_reflect_Field::set_modifiers(rh(), fd->access_flags().as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS);
   840   java_lang_reflect_Field::set_modifiers(rh(), fd->access_flags().as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS);
   898     // no need to resolve if method is private or <init>
   898     // no need to resolve if method is private or <init>
   899     if (reflected_method->is_private() || reflected_method->name() == vmSymbols::object_initializer_name()) {
   899     if (reflected_method->is_private() || reflected_method->name() == vmSymbols::object_initializer_name()) {
   900       method = reflected_method;
   900       method = reflected_method;
   901     } else {
   901     } else {
   902       // resolve based on the receiver
   902       // resolve based on the receiver
   903       if (InstanceKlass::cast(reflected_method->method_holder())->is_interface()) {
   903       if (reflected_method->method_holder()->is_interface()) {
   904         // resolve interface call
   904         // resolve interface call
   905         if (ReflectionWrapResolutionErrors) {
   905         if (ReflectionWrapResolutionErrors) {
   906           // new default: 6531596
   906           // new default: 6531596
   907           // Match resolution errors with those thrown due to reflection inlining
   907           // Match resolution errors with those thrown due to reflection inlining
   908           // Linktime resolution & IllegalAccessCheck already done by Class.getMethod()
   908           // Linktime resolution & IllegalAccessCheck already done by Class.getMethod()