4752 (is_protected && is_private)); |
4752 (is_protected && is_private)); |
4753 } |
4753 } |
4754 |
4754 |
4755 // A legal major_version.minor_version must be one of the following: |
4755 // A legal major_version.minor_version must be one of the following: |
4756 // |
4756 // |
4757 // Major_version = 45, any minor_version. |
4757 // Major_version >= 45 and major_version < 56, any minor_version. |
4758 // Major_version >= 46 and major_version <= current_major_version and minor_version = 0. |
4758 // Major_version >= 56 and major_version <= JVM_CLASSFILE_MAJOR_VERSION and minor_version = 0. |
4759 // Major_version = current_major_version and minor_version = 65535 and --enable-preview is present. |
4759 // Major_version = JVM_CLASSFILE_MAJOR_VERSION and minor_version = 65535 and --enable-preview is present. |
4760 // |
4760 // |
4761 static void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS){ |
4761 static void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS){ |
|
4762 ResourceMark rm(THREAD); |
4762 const u2 max_version = JVM_CLASSFILE_MAJOR_VERSION; |
4763 const u2 max_version = JVM_CLASSFILE_MAJOR_VERSION; |
4763 if (major != JAVA_MIN_SUPPORTED_VERSION) { // All 45.* are ok including 45.65535 |
4764 if (major < JAVA_MIN_SUPPORTED_VERSION) { |
4764 if (minor == JAVA_PREVIEW_MINOR_VERSION) { |
4765 Exceptions::fthrow( |
4765 if (major != max_version) { |
4766 THREAD_AND_LOCATION, |
4766 ResourceMark rm(THREAD); |
4767 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4767 Exceptions::fthrow( |
4768 "%s (class file version %u.%u) was compiled with an invalid major version", |
4768 THREAD_AND_LOCATION, |
4769 class_name->as_C_string(), major, minor); |
4769 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4770 return; |
4770 "%s (class file version %u.%u) was compiled with preview features that are unsupported. " |
4771 } |
4771 "This version of the Java Runtime only recognizes preview features for class file version %u.%u", |
4772 |
4772 class_name->as_C_string(), major, minor, JVM_CLASSFILE_MAJOR_VERSION, JAVA_PREVIEW_MINOR_VERSION); |
4773 if (major > max_version) { |
4773 return; |
4774 Exceptions::fthrow( |
4774 } |
4775 THREAD_AND_LOCATION, |
4775 |
4776 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4776 if (!Arguments::enable_preview()) { |
4777 "%s has been compiled by a more recent version of the Java Runtime (class file version %u.%u), " |
4777 ResourceMark rm(THREAD); |
4778 "this version of the Java Runtime only recognizes class file versions up to %u.0", |
4778 Exceptions::fthrow( |
4779 class_name->as_C_string(), major, minor, JVM_CLASSFILE_MAJOR_VERSION); |
4779 THREAD_AND_LOCATION, |
4780 return; |
4780 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4781 } |
4781 "Preview features are not enabled for %s (class file version %u.%u). Try running with '--enable-preview'", |
4782 |
4782 class_name->as_C_string(), major, minor); |
4783 if (major < JAVA_12_VERSION || minor == 0) { |
4783 return; |
4784 return; |
4784 } |
4785 } |
4785 |
4786 |
4786 } else { // minor != JAVA_PREVIEW_MINOR_VERSION |
4787 if (minor == JAVA_PREVIEW_MINOR_VERSION) { |
4787 if (major > max_version) { |
4788 if (major != max_version) { |
4788 ResourceMark rm(THREAD); |
4789 Exceptions::fthrow( |
4789 Exceptions::fthrow( |
4790 THREAD_AND_LOCATION, |
4790 THREAD_AND_LOCATION, |
4791 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4791 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4792 "%s (class file version %u.%u) was compiled with preview features that are unsupported. " |
4792 "%s has been compiled by a more recent version of the Java Runtime (class file version %u.%u), " |
4793 "This version of the Java Runtime only recognizes preview features for class file version %u.%u", |
4793 "this version of the Java Runtime only recognizes class file versions up to %u.0", |
4794 class_name->as_C_string(), major, minor, JVM_CLASSFILE_MAJOR_VERSION, JAVA_PREVIEW_MINOR_VERSION); |
4794 class_name->as_C_string(), major, minor, JVM_CLASSFILE_MAJOR_VERSION); |
4795 return; |
4795 } else if (major < JAVA_MIN_SUPPORTED_VERSION) { |
4796 } |
4796 ResourceMark rm(THREAD); |
4797 |
4797 Exceptions::fthrow( |
4798 if (!Arguments::enable_preview()) { |
4798 THREAD_AND_LOCATION, |
4799 Exceptions::fthrow( |
4799 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4800 THREAD_AND_LOCATION, |
4800 "%s (class file version %u.%u) was compiled with an invalid major version", |
4801 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4801 class_name->as_C_string(), major, minor); |
4802 "Preview features are not enabled for %s (class file version %u.%u). Try running with '--enable-preview'", |
4802 } else if (minor != 0) { |
4803 class_name->as_C_string(), major, minor); |
4803 ResourceMark rm(THREAD); |
4804 return; |
4804 Exceptions::fthrow( |
4805 } |
4805 THREAD_AND_LOCATION, |
4806 |
4806 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4807 } else { // minor != JAVA_PREVIEW_MINOR_VERSION |
4807 "%s (class file version %u.%u) was compiled with an invalid non-zero minor version", |
4808 Exceptions::fthrow( |
4808 class_name->as_C_string(), major, minor); |
4809 THREAD_AND_LOCATION, |
4809 } |
4810 vmSymbols::java_lang_UnsupportedClassVersionError(), |
4810 } |
4811 "%s (class file version %u.%u) was compiled with an invalid non-zero minor version", |
|
4812 class_name->as_C_string(), major, minor); |
4811 } |
4813 } |
4812 } |
4814 } |
4813 |
4815 |
4814 void ClassFileParser::verify_legal_field_modifiers(jint flags, |
4816 void ClassFileParser::verify_legal_field_modifiers(jint flags, |
4815 bool is_interface, |
4817 bool is_interface, |
5639 const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string(); |
5641 const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string(); |
5640 ik->print_class_load_logging(_loader_data, module_name, _stream); |
5642 ik->print_class_load_logging(_loader_data, module_name, _stream); |
5641 } |
5643 } |
5642 |
5644 |
5643 if (ik->minor_version() == JAVA_PREVIEW_MINOR_VERSION && |
5645 if (ik->minor_version() == JAVA_PREVIEW_MINOR_VERSION && |
5644 ik->major_version() != JAVA_MIN_SUPPORTED_VERSION && |
5646 ik->major_version() == JVM_CLASSFILE_MAJOR_VERSION && |
5645 log_is_enabled(Info, class, preview)) { |
5647 log_is_enabled(Info, class, preview)) { |
5646 ResourceMark rm; |
5648 ResourceMark rm; |
5647 log_info(class, preview)("Loading class %s that depends on preview features (class file version %d.65535)", |
5649 log_info(class, preview)("Loading class %s that depends on preview features (class file version %d.65535)", |
5648 ik->external_name(), ik->major_version()); |
5650 ik->external_name(), JVM_CLASSFILE_MAJOR_VERSION); |
5649 } |
5651 } |
5650 |
5652 |
5651 if (log_is_enabled(Debug, class, resolve)) { |
5653 if (log_is_enabled(Debug, class, resolve)) { |
5652 ResourceMark rm; |
5654 ResourceMark rm; |
5653 // print out the superclass. |
5655 // print out the superclass. |