135 // Condensed information from constant pool to use to resolve the method or field. 136 // resolved_klass = specified class (i.e., static receiver class) 137 // current_klass = sending method holder (i.e., class containing the method 138 // containing the call being resolved) 139 // current_method = sending method (relevant for field resolution) 140 class LinkInfo : public StackObj { 141 Symbol* _name; // extracted from JVM_CONSTANT_NameAndType 142 Symbol* _signature; 143 Klass* _resolved_klass; // class that the constant pool entry points to 144 Klass* _current_klass; // class that owns the constant pool 145 methodHandle _current_method; // sending method 146 bool _check_access; 147 constantTag _tag; 148 149 public: 150 enum AccessCheck { 151 needs_access_check, 152 skip_access_check 153 }; 154 155 LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS); 156 LinkInfo(const constantPoolHandle& pool, int index, TRAPS); 157 158 // Condensed information from other call sites within the vm. 159 LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, Klass* current_klass, 160 AccessCheck check_access = needs_access_check, 161 constantTag tag = JVM_CONSTANT_Invalid) : 162 _resolved_klass(resolved_klass), 163 _name(name), _signature(signature), _current_klass(current_klass), _current_method(methodHandle()), 164 _check_access(check_access == needs_access_check), _tag(tag) {} 165 166 LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, methodHandle current_method, 167 AccessCheck check_access = needs_access_check, 168 constantTag tag = JVM_CONSTANT_Invalid) : 169 _resolved_klass(resolved_klass), 170 _name(name), _signature(signature), _current_klass(current_method->method_holder()), _current_method(current_method), 171 _check_access(check_access == needs_access_check), _tag(tag) {} 172 173 // Case where we just find the method and don't check access against the current class 174 LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) : 175 _resolved_klass(resolved_klass), 176 _name(name), _signature(signature), _current_klass(NULL), _current_method(methodHandle()), 177 _check_access(false), _tag(JVM_CONSTANT_Invalid) {} 178 179 // accessors 180 Symbol* name() const { return _name; } 181 Symbol* signature() const { return _signature; } 182 Klass* resolved_klass() const { return _resolved_klass; } 183 Klass* current_klass() const { return _current_klass; } 184 methodHandle current_method() const { return _current_method; } 185 constantTag tag() const { return _tag; } 186 bool check_access() const { return _check_access; } 187 char* method_string() const; 188 189 void print() PRODUCT_RETURN; 190 }; 191 192 // Link information for getfield/putfield & getstatic/putstatic bytecodes 193 // is represented using a fieldDescriptor. 194 195 // The LinkResolver is used to resolve constant-pool references at run-time. 196 // It does all necessary link-time checks & throws exceptions if necessary. 197 198 class LinkResolver: AllStatic { 199 friend class klassVtable; 200 friend class klassItable; 201 202 private: 203 204 static methodHandle lookup_method_in_klasses(const LinkInfo& link_info, 205 bool checkpolymorphism, 206 bool in_imethod_resolve, TRAPS); 207 static methodHandle lookup_method_in_interfaces(const LinkInfo& link_info, TRAPS); 208 static methodHandle lookup_polymorphic_method(const LinkInfo& link_info, 209 Handle *appendix_result_or_null, 210 Handle *method_type_result, TRAPS); 211 JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod() 212 // Not Linktime so doesn't take LinkInfo 213 static methodHandle lookup_instance_method_in_klasses ( 214 Klass* klass, Symbol* name, Symbol* signature, TRAPS); 215 JVMCI_ONLY(private:) 216 217 // Similar loader constraint checking functions that throw 218 // LinkageError with descriptive message. 219 static void check_method_loader_constraints(const LinkInfo& link_info, 220 const methodHandle& resolved_method, 221 const char* method_type, TRAPS); 222 static void check_field_loader_constraints(Symbol* field, Symbol* sig, 223 Klass* current_klass, 224 Klass* sel_klass, TRAPS); 225 226 static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS); 227 static methodHandle resolve_method (const LinkInfo& link_info, Bytecodes::Code code, TRAPS); | 135 // Condensed information from constant pool to use to resolve the method or field. 136 // resolved_klass = specified class (i.e., static receiver class) 137 // current_klass = sending method holder (i.e., class containing the method 138 // containing the call being resolved) 139 // current_method = sending method (relevant for field resolution) 140 class LinkInfo : public StackObj { 141 Symbol* _name; // extracted from JVM_CONSTANT_NameAndType 142 Symbol* _signature; 143 Klass* _resolved_klass; // class that the constant pool entry points to 144 Klass* _current_klass; // class that owns the constant pool 145 methodHandle _current_method; // sending method 146 bool _check_access; 147 constantTag _tag; 148 149 public: 150 enum AccessCheck { 151 needs_access_check, 152 skip_access_check 153 }; 154 155 LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS); 156 LinkInfo(const constantPoolHandle& pool, int index, TRAPS); 157 158 // Condensed information from other call sites within the vm. 159 LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, Klass* current_klass, 160 AccessCheck check_access = needs_access_check, 161 constantTag tag = JVM_CONSTANT_Invalid) : 162 _resolved_klass(resolved_klass), 163 _name(name), _signature(signature), _current_klass(current_klass), _current_method(methodHandle()), 164 _check_access(check_access == needs_access_check), _tag(tag) {} 165 166 LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, const methodHandle& current_method, 167 AccessCheck check_access = needs_access_check, 168 constantTag tag = JVM_CONSTANT_Invalid) : 169 _resolved_klass(resolved_klass), 170 _name(name), _signature(signature), _current_klass(current_method->method_holder()), _current_method(current_method), 171 _check_access(check_access == needs_access_check), _tag(tag) {} 172 173 // Case where we just find the method and don't check access against the current class 174 LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) : 175 _resolved_klass(resolved_klass), 176 _name(name), _signature(signature), _current_klass(NULL), _current_method(methodHandle()), 177 _check_access(false), _tag(JVM_CONSTANT_Invalid) {} 178 179 // accessors 180 Symbol* name() const { return _name; } 181 Symbol* signature() const { return _signature; } 182 Klass* resolved_klass() const { return _resolved_klass; } 183 Klass* current_klass() const { return _current_klass; } 184 methodHandle current_method() const { return _current_method; } 185 constantTag tag() const { return _tag; } 186 bool check_access() const { return _check_access; } 187 char* method_string() const; 188 189 void print() PRODUCT_RETURN; 190 }; 191 192 // Link information for getfield/putfield & getstatic/putstatic bytecodes 193 // is represented using a fieldDescriptor. 194 195 // The LinkResolver is used to resolve constant-pool references at run-time. 196 // It does all necessary link-time checks & throws exceptions if necessary. 197 198 class LinkResolver: AllStatic { 199 friend class klassVtable; 200 friend class klassItable; 201 202 private: 203 204 static Method* lookup_method_in_klasses(const LinkInfo& link_info, 205 bool checkpolymorphism, 206 bool in_imethod_resolve); 207 static Method* lookup_method_in_interfaces(const LinkInfo& link_info); 208 209 static methodHandle lookup_polymorphic_method(const LinkInfo& link_info, 210 Handle *appendix_result_or_null, 211 Handle *method_type_result, TRAPS); 212 JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod() 213 // Not Linktime so doesn't take LinkInfo 214 static methodHandle lookup_instance_method_in_klasses ( 215 Klass* klass, Symbol* name, Symbol* signature, TRAPS); 216 JVMCI_ONLY(private:) 217 218 // Similar loader constraint checking functions that throw 219 // LinkageError with descriptive message. 220 static void check_method_loader_constraints(const LinkInfo& link_info, 221 const methodHandle& resolved_method, 222 const char* method_type, TRAPS); 223 static void check_field_loader_constraints(Symbol* field, Symbol* sig, 224 Klass* current_klass, 225 Klass* sel_klass, TRAPS); 226 227 static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS); 228 static methodHandle resolve_method (const LinkInfo& link_info, Bytecodes::Code code, TRAPS); |