< prev index next >

src/share/vm/interpreter/linkResolver.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 258 char* LinkInfo::method_string() const {
 259   return Method::name_and_sig_as_C_string(_resolved_klass(), _name, _signature);
 260 }
 261 
 262 #ifndef PRODUCT
 263 void LinkInfo::print() {
 264   ResourceMark rm;
 265   tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s",
 266                 _resolved_klass->name()->as_C_string(),
 267                 _name->as_C_string(),
 268                 _signature->as_C_string(),
 269                 _current_klass.is_null() ? "(none)" : _current_klass->name()->as_C_string(),
 270                 _check_access ? "true" : "false");
 271 }
 272 #endif // PRODUCT
 273 //------------------------------------------------------------------------------------------------------------------------
 274 // Klass resolution
 275 
 276 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) {
 277   Reflection::VerifyClassAccessResults vca_result =
 278     Reflection::verify_class_access(ref_klass(), sel_klass(), true);
 279   if (vca_result != Reflection::ACCESS_OK) {
 280     ResourceMark rm(THREAD);
 281     char* msg = Reflection::verify_class_access_msg(ref_klass(), sel_klass(), vca_result);


 282     if (msg == NULL) {
 283       Exceptions::fthrow(
 284         THREAD_AND_LOCATION,
 285         vmSymbols::java_lang_IllegalAccessError(),
 286         "failed to access class %s from class %s",
 287         sel_klass->external_name(),
 288         ref_klass->external_name());
 289     } else {
 290       // Use module specific message returned by verify_class_access_msg().
 291       Exceptions::fthrow(
 292         THREAD_AND_LOCATION,
 293         vmSymbols::java_lang_IllegalAccessError(),
 294         "%s", msg);
 295     }
 296   }
 297 }
 298 
 299 //------------------------------------------------------------------------------------------------------------------------
 300 // Method resolution
 301 //


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 258 char* LinkInfo::method_string() const {
 259   return Method::name_and_sig_as_C_string(_resolved_klass(), _name, _signature);
 260 }
 261 
 262 #ifndef PRODUCT
 263 void LinkInfo::print() {
 264   ResourceMark rm;
 265   tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s",
 266                 _resolved_klass->name()->as_C_string(),
 267                 _name->as_C_string(),
 268                 _signature->as_C_string(),
 269                 _current_klass.is_null() ? "(none)" : _current_klass->name()->as_C_string(),
 270                 _check_access ? "true" : "false");
 271 }
 272 #endif // PRODUCT
 273 //------------------------------------------------------------------------------------------------------------------------
 274 // Klass resolution
 275 
 276 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) {
 277   Reflection::VerifyClassAccessResults vca_result =
 278     Reflection::verify_class_access(ref_klass(), InstanceKlass::cast(sel_klass()), true);
 279   if (vca_result != Reflection::ACCESS_OK) {
 280     ResourceMark rm(THREAD);
 281     char* msg = Reflection::verify_class_access_msg(ref_klass(),
 282                                                     InstanceKlass::cast(sel_klass()),
 283                                                     vca_result);
 284     if (msg == NULL) {
 285       Exceptions::fthrow(
 286         THREAD_AND_LOCATION,
 287         vmSymbols::java_lang_IllegalAccessError(),
 288         "failed to access class %s from class %s",
 289         sel_klass->external_name(),
 290         ref_klass->external_name());
 291     } else {
 292       // Use module specific message returned by verify_class_access_msg().
 293       Exceptions::fthrow(
 294         THREAD_AND_LOCATION,
 295         vmSymbols::java_lang_IllegalAccessError(),
 296         "%s", msg);
 297     }
 298   }
 299 }
 300 
 301 //------------------------------------------------------------------------------------------------------------------------
 302 // Method resolution
 303 //


< prev index next >