641 } else { |
641 } else { |
642 (*func)(&info, sizeof(info)); |
642 (*func)(&info, sizeof(info)); |
643 |
643 |
644 int major = JDK_VERSION_MAJOR(info.jdk_version); |
644 int major = JDK_VERSION_MAJOR(info.jdk_version); |
645 int minor = JDK_VERSION_MINOR(info.jdk_version); |
645 int minor = JDK_VERSION_MINOR(info.jdk_version); |
646 int micro = JDK_VERSION_MICRO(info.jdk_version); |
646 int security = JDK_VERSION_SECURITY(info.jdk_version); |
647 int build = JDK_VERSION_BUILD(info.jdk_version); |
647 int build = JDK_VERSION_BUILD(info.jdk_version); |
648 if (major == 1 && minor > 4) { |
648 |
649 // We represent "1.5.0" as "5.0", but 1.4.2 as itself. |
|
650 major = minor; |
|
651 minor = micro; |
|
652 micro = 0; |
|
653 } |
|
654 // Incompatible with pre-4243978 JDK. |
649 // Incompatible with pre-4243978 JDK. |
655 if (info.pending_list_uses_discovered_field == 0) { |
650 if (info.pending_list_uses_discovered_field == 0) { |
656 vm_exit_during_initialization( |
651 vm_exit_during_initialization( |
657 "Incompatible JDK is not using Reference.discovered field for pending list"); |
652 "Incompatible JDK is not using Reference.discovered field for pending list"); |
658 } |
653 } |
659 _current = JDK_Version(major, minor, micro, info.update_version, |
654 _current = JDK_Version(major, minor, security, info.update_version, |
660 info.special_update_version, build, |
655 info.special_update_version, build, |
661 info.thread_park_blocker == 1, |
656 info.thread_park_blocker == 1, |
662 info.post_vm_init_hook_enabled == 1); |
657 info.post_vm_init_hook_enabled == 1); |
663 } |
658 } |
664 } |
659 } |
665 |
660 |
666 void JDK_Version::fully_initialize( |
661 void JDK_Version::fully_initialize( |
667 uint8_t major, uint8_t minor, uint8_t micro, uint8_t update) { |
662 uint8_t major, uint8_t minor, uint8_t security, uint8_t update) { |
668 // This is only called when current is less than 1.6 and we've gotten |
663 // This is only called when current is less than 1.6 and we've gotten |
669 // far enough in the initialization to determine the exact version. |
664 // far enough in the initialization to determine the exact version. |
670 assert(major < 6, "not needed for JDK version >= 6"); |
665 assert(major < 6, "not needed for JDK version >= 6"); |
671 assert(is_partially_initialized(), "must not initialize"); |
666 assert(is_partially_initialized(), "must not initialize"); |
672 if (major < 5) { |
667 if (major < 5) { |
673 // JDK verison sequence: 1.2.x, 1.3.x, 1.4.x, 5.0.x, 6.0.x, etc. |
668 // JDK verison sequence: 1.2.x, 1.3.x, 1.4.x, 5.0.x, 6.0.x, etc. |
674 micro = minor; |
669 security = minor; |
675 minor = major; |
670 minor = major; |
676 major = 1; |
671 major = 1; |
677 } |
672 } |
678 _current = JDK_Version(major, minor, micro, update); |
673 _current = JDK_Version(major, minor, security, update); |
679 } |
674 } |
680 |
675 |
681 void JDK_Version_init() { |
676 void JDK_Version_init() { |
682 JDK_Version::initialize(); |
677 JDK_Version::initialize(); |
683 } |
678 } |
684 |
679 |
685 static int64_t encode_jdk_version(const JDK_Version& v) { |
680 static int64_t encode_jdk_version(const JDK_Version& v) { |
686 return |
681 return |
687 ((int64_t)v.major_version() << (BitsPerByte * 5)) | |
682 ((int64_t)v.major_version() << (BitsPerByte * 5)) | |
688 ((int64_t)v.minor_version() << (BitsPerByte * 4)) | |
683 ((int64_t)v.minor_version() << (BitsPerByte * 4)) | |
689 ((int64_t)v.micro_version() << (BitsPerByte * 3)) | |
684 ((int64_t)v.security_version() << (BitsPerByte * 3)) | |
690 ((int64_t)v.update_version() << (BitsPerByte * 2)) | |
685 ((int64_t)v.update_version() << (BitsPerByte * 2)) | |
691 ((int64_t)v.special_update_version() << (BitsPerByte * 1)) | |
686 ((int64_t)v.special_update_version() << (BitsPerByte * 1)) | |
692 ((int64_t)v.build_number() << (BitsPerByte * 0)); |
687 ((int64_t)v.build_number() << (BitsPerByte * 0)); |
693 } |
688 } |
694 |
689 |
720 } else { |
715 } else { |
721 int rc = jio_snprintf( |
716 int rc = jio_snprintf( |
722 &buffer[index], buflen - index, "%d.%d", _major, _minor); |
717 &buffer[index], buflen - index, "%d.%d", _major, _minor); |
723 if (rc == -1) return; |
718 if (rc == -1) return; |
724 index += rc; |
719 index += rc; |
725 if (_micro > 0) { |
720 if (_security > 0) { |
726 rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _micro); |
721 rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _security); |
727 } |
722 } |
728 if (_update > 0) { |
723 if (_update > 0) { |
729 rc = jio_snprintf(&buffer[index], buflen - index, "_%02d", _update); |
724 rc = jio_snprintf(&buffer[index], buflen - index, "_%02d", _update); |
730 if (rc == -1) return; |
725 if (rc == -1) return; |
731 index += rc; |
726 index += rc; |