hotspot/src/share/vm/classfile/systemDictionary.cpp
changeset 2332 5c7b6f4ce0a1
parent 2105 347008ce7984
child 2534 08dac9ce0cd7
equal deleted inserted replaced
2259:d3c946e7f127 2332:5c7b6f4ce0a1
  1962       return (BasicType)i;
  1962       return (BasicType)i;
  1963   }
  1963   }
  1964   return T_OBJECT;
  1964   return T_OBJECT;
  1965 }
  1965 }
  1966 
  1966 
       
  1967 KlassHandle SystemDictionaryHandles::box_klass(BasicType t) {
       
  1968   if (t >= T_BOOLEAN && t <= T_VOID)
       
  1969     return KlassHandle(&SystemDictionary::_box_klasses[t], true);
       
  1970   else
       
  1971     return KlassHandle();
       
  1972 }
       
  1973 
  1967 // Constraints on class loaders. The details of the algorithm can be
  1974 // Constraints on class loaders. The details of the algorithm can be
  1968 // found in the OOPSLA'98 paper "Dynamic Class Loading in the Java
  1975 // found in the OOPSLA'98 paper "Dynamic Class Loading in the Java
  1969 // Virtual Machine" by Sheng Liang and Gilad Bracha.  The basic idea is
  1976 // Virtual Machine" by Sheng Liang and Gilad Bracha.  The basic idea is
  1970 // that the system dictionary needs to maintain a set of contraints that
  1977 // that the system dictionary needs to maintain a set of contraints that
  1971 // must be satisfied by all classes in the dictionary.
  1978 // must be satisfied by all classes in the dictionary.
  2172     return (entry != NULL) ? entry->error() : (symbolOop)NULL;
  2179     return (entry != NULL) ? entry->error() : (symbolOop)NULL;
  2173   }
  2180   }
  2174 }
  2181 }
  2175 
  2182 
  2176 
  2183 
       
  2184 // Signature constraints ensure that callers and callees agree about
       
  2185 // the meaning of type names in their signatures.  This routine is the
       
  2186 // intake for constraints.  It collects them from several places:
       
  2187 //
       
  2188 //  * LinkResolver::resolve_method (if check_access is true) requires
       
  2189 //    that the resolving class (the caller) and the defining class of
       
  2190 //    the resolved method (the callee) agree on each type in the
       
  2191 //    method's signature.
       
  2192 //
       
  2193 //  * LinkResolver::resolve_interface_method performs exactly the same
       
  2194 //    checks.
       
  2195 //
       
  2196 //  * LinkResolver::resolve_field requires that the constant pool
       
  2197 //    attempting to link to a field agree with the field's defining
       
  2198 //    class about the type of the field signature.
       
  2199 //
       
  2200 //  * klassVtable::initialize_vtable requires that, when a class
       
  2201 //    overrides a vtable entry allocated by a superclass, that the
       
  2202 //    overriding method (i.e., the callee) agree with the superclass
       
  2203 //    on each type in the method's signature.
       
  2204 //
       
  2205 //  * klassItable::initialize_itable requires that, when a class fills
       
  2206 //    in its itables, for each non-abstract method installed in an
       
  2207 //    itable, the method (i.e., the callee) agree with the interface
       
  2208 //    on each type in the method's signature.
       
  2209 //
       
  2210 // All those methods have a boolean (check_access, checkconstraints)
       
  2211 // which turns off the checks.  This is used from specialized contexts
       
  2212 // such as bootstrapping, dumping, and debugging.
       
  2213 //
       
  2214 // No direct constraint is placed between the class and its
       
  2215 // supertypes.  Constraints are only placed along linked relations
       
  2216 // between callers and callees.  When a method overrides or implements
       
  2217 // an abstract method in a supertype (superclass or interface), the
       
  2218 // constraints are placed as if the supertype were the caller to the
       
  2219 // overriding method.  (This works well, since callers to the
       
  2220 // supertype have already established agreement between themselves and
       
  2221 // the supertype.)  As a result of all this, a class can disagree with
       
  2222 // its supertype about the meaning of a type name, as long as that
       
  2223 // class neither calls a relevant method of the supertype, nor is
       
  2224 // called (perhaps via an override) from the supertype.
       
  2225 //
       
  2226 //
       
  2227 // SystemDictionary::check_signature_loaders(sig, l1, l2)
       
  2228 //
  2177 // Make sure all class components (including arrays) in the given
  2229 // Make sure all class components (including arrays) in the given
  2178 // signature will be resolved to the same class in both loaders.
  2230 // signature will be resolved to the same class in both loaders.
  2179 // Returns the name of the type that failed a loader constraint check, or
  2231 // Returns the name of the type that failed a loader constraint check, or
  2180 // NULL if no constraint failed. The returned C string needs cleaning up
  2232 // NULL if no constraint failed. The returned C string needs cleaning up
  2181 // with a ResourceMark in the caller
  2233 // with a ResourceMark in the caller.  No exception except OOME is thrown.
  2182 char* SystemDictionary::check_signature_loaders(symbolHandle signature,
  2234 char* SystemDictionary::check_signature_loaders(symbolHandle signature,
  2183                                                Handle loader1, Handle loader2,
  2235                                                Handle loader1, Handle loader2,
  2184                                                bool is_method, TRAPS)  {
  2236                                                bool is_method, TRAPS)  {
  2185   // Nothing to do if loaders are the same.
  2237   // Nothing to do if loaders are the same.
  2186   if (loader1() == loader2()) {
  2238   if (loader1() == loader2()) {