754
755 if (IgnoreUnverifiableClassesDuringDump) {
756 // This is useful when running JCK or SQE tests. You should not
757 // enable this when running real apps.
758 SystemDictionary::remove_classes_in_error_state();
759 } else {
760 tty->print_cr("Please remove the unverifiable classes from your class list and try again");
761 exit(1);
762 }
763 }
764 }
765
766 void MetaspaceShared::prepare_for_dumping() {
767 ClassLoader::initialize_shared_path();
768 FileMapInfo::allocate_classpath_entry_table();
769 }
770
771 // Preload classes from a list, populate the shared spaces and dump to a
772 // file.
773 void MetaspaceShared::preload_and_dump(TRAPS) {
774 TraceTime timer("Dump Shared Spaces", TraceStartupTime);
775 ResourceMark rm;
776 char class_list_path_str[JVM_MAXPATHLEN];
777
778 tty->print_cr("Allocated shared space: " SIZE_FORMAT " bytes at " PTR_FORMAT,
779 MetaspaceShared::shared_rs()->size(),
780 p2i(MetaspaceShared::shared_rs()->base()));
781
782 // Preload classes to be shared.
783 // Should use some os:: method rather than fopen() here. aB.
784 const char* class_list_path;
785 if (SharedClassListFile == NULL) {
786 // Construct the path to the class list (in jre/lib)
787 // Walk up two directories from the location of the VM and
788 // optionally tack on "lib" (depending on platform)
789 os::jvm_path(class_list_path_str, sizeof(class_list_path_str));
790 for (int i = 0; i < 3; i++) {
791 char *end = strrchr(class_list_path_str, *os::file_separator());
792 if (end != NULL) *end = '\0';
793 }
794 int class_list_path_len = (int)strlen(class_list_path_str);
795 if (class_list_path_len >= 3) {
836 class_count += preload_and_dump(ExtraSharedClassListFile, class_promote_order,
837 THREAD);
838 }
839 tty->print_cr("Loading classes to share: done.");
840
841 if (PrintSharedSpaces) {
842 tty->print_cr("Shared spaces: preloaded %d classes", class_count);
843 }
844
845 // Rewrite and link classes
846 tty->print_cr("Rewriting and linking classes ...");
847
848 // Link any classes which got missed. This would happen if we have loaded classes that
849 // were not explicitly specified in the classlist. E.g., if an interface implemented by class K
850 // fails verification, all other interfaces that were not specified in the classlist but
851 // are implemented by K are not verified.
852 link_and_cleanup_shared_classes(CATCH);
853 tty->print_cr("Rewriting and linking classes: done");
854
855 VMThread::execute(&op);
856 // Since various initialization steps have been undone by this process,
857 // it is not reasonable to continue running a java process.
858 exit(0);
859 }
860
861
862 int MetaspaceShared::preload_and_dump(const char* class_list_path,
863 GrowableArray<Klass*>* class_promote_order,
864 TRAPS) {
865 ClassListParser parser(class_list_path);
866 int class_count = 0;
867
868 while (parser.parse_one_line()) {
869 Klass* klass = ClassLoaderExt::load_one_class(&parser, THREAD);
870
871 CLEAR_PENDING_EXCEPTION;
872 if (klass != NULL) {
873 if (PrintSharedSpaces && Verbose && WizardMode) {
874 ResourceMark rm;
875 tty->print_cr("Shared spaces preloaded: %s", klass->external_name());
|
754
755 if (IgnoreUnverifiableClassesDuringDump) {
756 // This is useful when running JCK or SQE tests. You should not
757 // enable this when running real apps.
758 SystemDictionary::remove_classes_in_error_state();
759 } else {
760 tty->print_cr("Please remove the unverifiable classes from your class list and try again");
761 exit(1);
762 }
763 }
764 }
765
766 void MetaspaceShared::prepare_for_dumping() {
767 ClassLoader::initialize_shared_path();
768 FileMapInfo::allocate_classpath_entry_table();
769 }
770
771 // Preload classes from a list, populate the shared spaces and dump to a
772 // file.
773 void MetaspaceShared::preload_and_dump(TRAPS) {
774 { ResourceMark rm;
775 TraceTime timer("Dump Shared Spaces",
776 log_is_enabled(Info, startuptime),
777 LogTag::_startuptime);
778
779 char class_list_path_str[JVM_MAXPATHLEN];
780
781 tty->print_cr("Allocated shared space: " SIZE_FORMAT " bytes at " PTR_FORMAT,
782 MetaspaceShared::shared_rs()->size(),
783 p2i(MetaspaceShared::shared_rs()->base()));
784
785 // Preload classes to be shared.
786 // Should use some os:: method rather than fopen() here. aB.
787 const char* class_list_path;
788 if (SharedClassListFile == NULL) {
789 // Construct the path to the class list (in jre/lib)
790 // Walk up two directories from the location of the VM and
791 // optionally tack on "lib" (depending on platform)
792 os::jvm_path(class_list_path_str, sizeof(class_list_path_str));
793 for (int i = 0; i < 3; i++) {
794 char *end = strrchr(class_list_path_str, *os::file_separator());
795 if (end != NULL) *end = '\0';
796 }
797 int class_list_path_len = (int)strlen(class_list_path_str);
798 if (class_list_path_len >= 3) {
839 class_count += preload_and_dump(ExtraSharedClassListFile, class_promote_order,
840 THREAD);
841 }
842 tty->print_cr("Loading classes to share: done.");
843
844 if (PrintSharedSpaces) {
845 tty->print_cr("Shared spaces: preloaded %d classes", class_count);
846 }
847
848 // Rewrite and link classes
849 tty->print_cr("Rewriting and linking classes ...");
850
851 // Link any classes which got missed. This would happen if we have loaded classes that
852 // were not explicitly specified in the classlist. E.g., if an interface implemented by class K
853 // fails verification, all other interfaces that were not specified in the classlist but
854 // are implemented by K are not verified.
855 link_and_cleanup_shared_classes(CATCH);
856 tty->print_cr("Rewriting and linking classes: done");
857
858 VMThread::execute(&op);
859 }
860 // Since various initialization steps have been undone by this process,
861 // it is not reasonable to continue running a java process.
862 exit(0);
863 }
864
865
866 int MetaspaceShared::preload_and_dump(const char* class_list_path,
867 GrowableArray<Klass*>* class_promote_order,
868 TRAPS) {
869 ClassListParser parser(class_list_path);
870 int class_count = 0;
871
872 while (parser.parse_one_line()) {
873 Klass* klass = ClassLoaderExt::load_one_class(&parser, THREAD);
874
875 CLEAR_PENDING_EXCEPTION;
876 if (klass != NULL) {
877 if (PrintSharedSpaces && Verbose && WizardMode) {
878 ResourceMark rm;
879 tty->print_cr("Shared spaces preloaded: %s", klass->external_name());
|