< prev index next >

src/share/vm/interpreter/linkResolver.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2015, 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  *


 118   // debugging
 119 #ifdef ASSERT
 120   bool         has_vtable_index() const          { return _call_index >= 0 && _call_kind != CallInfo::itable_call; }
 121   bool         is_statically_bound() const       { return _call_index == Method::nonvirtual_vtable_index; }
 122 #endif //ASSERT
 123   void         verify() PRODUCT_RETURN;
 124   void         print()  PRODUCT_RETURN;
 125 };
 126 
 127 
 128 // Condensed information from constant pool to use to resolve the method or field.
 129 //   resolved_klass = specified class (i.e., static receiver class)
 130 //   current_klass  = sending method holder (i.e., class containing the method
 131 //                    containing the call being resolved)
 132 class LinkInfo : public StackObj {
 133   Symbol*     _name;            // extracted from JVM_CONSTANT_NameAndType
 134   Symbol*     _signature;
 135   KlassHandle _resolved_klass;  // class that the constant pool entry points to
 136   KlassHandle _current_klass;   // class that owns the constant pool
 137   bool        _check_access;

 138  public:





 139   LinkInfo(const constantPoolHandle& pool, int index, TRAPS);

 140   // Condensed information from other call sites within the vm.
 141   LinkInfo(KlassHandle resolved_klass, Symbol* name, Symbol* signature,
 142            KlassHandle current_klass, bool check_access = true) :

 143     _resolved_klass(resolved_klass),
 144     _name(name), _signature(signature), _current_klass(current_klass),
 145     _check_access(check_access) {}






 146 
 147   // accessors
 148   Symbol* name() const               { return _name; }
 149   Symbol* signature() const          { return _signature; }
 150   KlassHandle resolved_klass() const { return _resolved_klass; }
 151   KlassHandle current_klass() const  { return _current_klass; }

 152   bool check_access() const          { return _check_access; }
 153   char* method_string() const;
 154 
 155   void         print()  PRODUCT_RETURN;
 156 };
 157 
 158 // Link information for getfield/putfield & getstatic/putstatic bytecodes
 159 // is represented using a fieldDescriptor.
 160 
 161 // The LinkResolver is used to resolve constant-pool references at run-time.
 162 // It does all necessary link-time checks & throws exceptions if necessary.
 163 
 164 class LinkResolver: AllStatic {
 165   friend class klassVtable;
 166   friend class klassItable;
 167 
 168  private:
 169 
 170   static methodHandle lookup_method_in_klasses(const LinkInfo& link_info,
 171                                                bool checkpolymorphism,


   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  *


 118   // debugging
 119 #ifdef ASSERT
 120   bool         has_vtable_index() const          { return _call_index >= 0 && _call_kind != CallInfo::itable_call; }
 121   bool         is_statically_bound() const       { return _call_index == Method::nonvirtual_vtable_index; }
 122 #endif //ASSERT
 123   void         verify() PRODUCT_RETURN;
 124   void         print()  PRODUCT_RETURN;
 125 };
 126 
 127 
 128 // Condensed information from constant pool to use to resolve the method or field.
 129 //   resolved_klass = specified class (i.e., static receiver class)
 130 //   current_klass  = sending method holder (i.e., class containing the method
 131 //                    containing the call being resolved)
 132 class LinkInfo : public StackObj {
 133   Symbol*     _name;            // extracted from JVM_CONSTANT_NameAndType
 134   Symbol*     _signature;
 135   KlassHandle _resolved_klass;  // class that the constant pool entry points to
 136   KlassHandle _current_klass;   // class that owns the constant pool
 137   bool        _check_access;
 138   constantTag _tag;
 139  public:
 140   enum AccessCheck {
 141      needs_access_check,
 142      skip_access_check
 143   };
 144 
 145   LinkInfo(const constantPoolHandle& pool, int index, TRAPS);
 146 
 147   // Condensed information from other call sites within the vm.
 148   LinkInfo(KlassHandle resolved_klass, Symbol* name, Symbol* signature, KlassHandle current_klass,
 149            AccessCheck check_access = needs_access_check,
 150            constantTag tag = JVM_CONSTANT_Invalid) :
 151     _resolved_klass(resolved_klass),
 152     _name(name), _signature(signature), _current_klass(current_klass),
 153     _check_access(check_access == needs_access_check && current_klass.not_null()), _tag(tag) {}
 154 
 155   // Case where we just find the method and don't check access against the current class
 156   LinkInfo(KlassHandle resolved_klass, Symbol*name, Symbol* signature) :
 157     _resolved_klass(resolved_klass),
 158     _name(name), _signature(signature), _current_klass(NULL),
 159     _check_access(false), _tag(JVM_CONSTANT_Invalid) {}
 160 
 161   // accessors
 162   Symbol* name() const               { return _name; }
 163   Symbol* signature() const          { return _signature; }
 164   KlassHandle resolved_klass() const { return _resolved_klass; }
 165   KlassHandle current_klass() const  { return _current_klass; }
 166   constantTag tag() const            { return _tag; }
 167   bool check_access() const          { return _check_access; }
 168   char* method_string() const;
 169 
 170   void         print()  PRODUCT_RETURN;
 171 };
 172 
 173 // Link information for getfield/putfield & getstatic/putstatic bytecodes
 174 // is represented using a fieldDescriptor.
 175 
 176 // The LinkResolver is used to resolve constant-pool references at run-time.
 177 // It does all necessary link-time checks & throws exceptions if necessary.
 178 
 179 class LinkResolver: AllStatic {
 180   friend class klassVtable;
 181   friend class klassItable;
 182 
 183  private:
 184 
 185   static methodHandle lookup_method_in_klasses(const LinkInfo& link_info,
 186                                                bool checkpolymorphism,


< prev index next >