< prev index next >

src/hotspot/share/classfile/vmClasses.cpp

Print this page

  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  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "cds/archiveHeapLoader.hpp"

 27 #include "classfile/classLoader.hpp"
 28 #include "classfile/classLoaderData.hpp"
 29 #include "classfile/dictionary.hpp"
 30 #include "classfile/javaClasses.hpp"
 31 #include "classfile/systemDictionary.hpp"
 32 #include "classfile/vmClasses.hpp"
 33 #include "classfile/vmSymbols.hpp"
 34 #include "gc/shared/collectedHeap.hpp"
 35 #include "memory/metaspaceClosure.hpp"
 36 #include "memory/universe.hpp"
 37 #include "oops/instanceKlass.hpp"
 38 #include "oops/instanceRefKlass.hpp"
 39 #include "oops/instanceStackChunkKlass.hpp"
 40 #include "prims/jvmtiExport.hpp"
 41 #include "runtime/globals.hpp"
 42 
 43 InstanceKlass* vmClasses::_klasses[static_cast<int>(vmClassID::LIMIT)]
 44                                                  =  { nullptr /*, nullptr...*/ };
 45 InstanceKlass* vmClasses::_box_klasses[T_VOID+1] =  { nullptr /*, nullptr...*/ };
 46 

202   _box_klasses[T_DOUBLE]  = vmClasses::Double_klass();
203   _box_klasses[T_BYTE]    = vmClasses::Byte_klass();
204   _box_klasses[T_SHORT]   = vmClasses::Short_klass();
205   _box_klasses[T_INT]     = vmClasses::Integer_klass();
206   _box_klasses[T_LONG]    = vmClasses::Long_klass();
207   //_box_klasses[T_OBJECT]  = vmClasses::object_klass();
208   //_box_klasses[T_ARRAY]   = vmClasses::object_klass();
209 
210 #ifdef ASSERT
211   if (UseSharedSpaces) {
212     JVMTI_ONLY(assert(JvmtiExport::is_early_phase(),
213                       "All well known classes must be resolved in JVMTI early phase"));
214     for (auto id : EnumRange<vmClassID>{}) {
215       InstanceKlass* k = _klasses[as_int(id)];
216       assert(k->is_shared(), "must not be replaced by JVMTI class file load hook");
217     }
218   }
219 #endif
220 
221   InstanceStackChunkKlass::init_offset_of_stack();

222 }
223 
224 #if INCLUDE_CDS
225 
226 void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) {
227   assert(!Universe::is_fully_initialized(), "We can make short cuts only during VM initialization");
228   assert(klass->is_shared(), "Must be shared class");
229   if (klass->class_loader_data() != nullptr) {
230     return;
231   }
232 
233   // add super and interfaces first
234   Klass* super = klass->super();
235   if (super != nullptr && super->class_loader_data() == nullptr) {
236     assert(super->is_instance_klass(), "Super should be instance klass");
237     resolve_shared_class(InstanceKlass::cast(super), loader_data, domain, CHECK);
238   }
239 
240   Array<InstanceKlass*>* ifs = klass->local_interfaces();
241   for (int i = 0; i < ifs->length(); i++) {

  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  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "cds/archiveHeapLoader.hpp"
 27 #include "cds/classPreloader.hpp"
 28 #include "classfile/classLoader.hpp"
 29 #include "classfile/classLoaderData.hpp"
 30 #include "classfile/dictionary.hpp"
 31 #include "classfile/javaClasses.hpp"
 32 #include "classfile/systemDictionary.hpp"
 33 #include "classfile/vmClasses.hpp"
 34 #include "classfile/vmSymbols.hpp"
 35 #include "gc/shared/collectedHeap.hpp"
 36 #include "memory/metaspaceClosure.hpp"
 37 #include "memory/universe.hpp"
 38 #include "oops/instanceKlass.hpp"
 39 #include "oops/instanceRefKlass.hpp"
 40 #include "oops/instanceStackChunkKlass.hpp"
 41 #include "prims/jvmtiExport.hpp"
 42 #include "runtime/globals.hpp"
 43 
 44 InstanceKlass* vmClasses::_klasses[static_cast<int>(vmClassID::LIMIT)]
 45                                                  =  { nullptr /*, nullptr...*/ };
 46 InstanceKlass* vmClasses::_box_klasses[T_VOID+1] =  { nullptr /*, nullptr...*/ };
 47 

203   _box_klasses[T_DOUBLE]  = vmClasses::Double_klass();
204   _box_klasses[T_BYTE]    = vmClasses::Byte_klass();
205   _box_klasses[T_SHORT]   = vmClasses::Short_klass();
206   _box_klasses[T_INT]     = vmClasses::Integer_klass();
207   _box_klasses[T_LONG]    = vmClasses::Long_klass();
208   //_box_klasses[T_OBJECT]  = vmClasses::object_klass();
209   //_box_klasses[T_ARRAY]   = vmClasses::object_klass();
210 
211 #ifdef ASSERT
212   if (UseSharedSpaces) {
213     JVMTI_ONLY(assert(JvmtiExport::is_early_phase(),
214                       "All well known classes must be resolved in JVMTI early phase"));
215     for (auto id : EnumRange<vmClassID>{}) {
216       InstanceKlass* k = _klasses[as_int(id)];
217       assert(k->is_shared(), "must not be replaced by JVMTI class file load hook");
218     }
219   }
220 #endif
221 
222   InstanceStackChunkKlass::init_offset_of_stack();
223   ClassPreloader::runtime_preload(THREAD, Handle()); // load only java.base classes
224 }
225 
226 #if INCLUDE_CDS
227 
228 void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) {
229   assert(!Universe::is_fully_initialized(), "We can make short cuts only during VM initialization");
230   assert(klass->is_shared(), "Must be shared class");
231   if (klass->class_loader_data() != nullptr) {
232     return;
233   }
234 
235   // add super and interfaces first
236   Klass* super = klass->super();
237   if (super != nullptr && super->class_loader_data() == nullptr) {
238     assert(super->is_instance_klass(), "Super should be instance klass");
239     resolve_shared_class(InstanceKlass::cast(super), loader_data, domain, CHECK);
240   }
241 
242   Array<InstanceKlass*>* ifs = klass->local_interfaces();
243   for (int i = 0; i < ifs->length(); i++) {
< prev index next >