Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safety check for tested / supported JDKs #5334

Open
devinrsmith opened this issue Apr 5, 2024 · 1 comment
Open

Add safety check for tested / supported JDKs #5334

devinrsmith opened this issue Apr 5, 2024 · 1 comment
Assignees
Labels
feature request New feature or request
Milestone

Comments

@devinrsmith
Copy link
Member

An at startup safety check framework was added as part of #5295. That PR at one point had a JDK end-of-life check based on the current timestamp, but it was removed to do the non-determinism of it (old versions of the software should continue to run as-is, and not fail one day once a timestamp threshold has been crossed).

To re-add this check, we can either use a deterministic timestamp (#3705), or we can use a fixed set of JDK versions that we know we have tested against (#5316).

@devinrsmith devinrsmith added the feature request New feature or request label Apr 5, 2024
@devinrsmith devinrsmith added this to the 5. Backlog milestone Apr 5, 2024
@devinrsmith devinrsmith self-assigned this Apr 5, 2024
@devinrsmith
Copy link
Member Author

For reference, the original safety check looked like this:

    /**
     * A safety check for end-of-life JDKs, see
     * <a href="https://www.oracle.com/java/technologies/java-se-support-roadmap.html">Oracle Java SE Support
     * Roadmap</a>. This will throw an exception when the {@link Runtime#version()} is 1 year past the EOL date.
     */
    public static final class JDK_END_OF_LIFE {

        private static final Map<Integer, LocalDate> EOL_DATES = Map.ofEntries(
                Map.entry(11, LocalDate.of(2032, Month.JANUARY, 31)),
                Map.entry(12, LocalDate.of(2019, Month.SEPTEMBER, 30)),
                Map.entry(13, LocalDate.of(2020, Month.MARCH, 31)),
                Map.entry(14, LocalDate.of(2020, Month.SEPTEMBER, 30)),
                Map.entry(15, LocalDate.of(2021, Month.MARCH, 31)),
                Map.entry(16, LocalDate.of(2021, Month.SEPTEMBER, 30)),
                Map.entry(17, LocalDate.of(2029, Month.SEPTEMBER, 30)),
                Map.entry(18, LocalDate.of(2022, Month.SEPTEMBER, 30)),
                Map.entry(19, LocalDate.of(2023, Month.MARCH, 31)),
                Map.entry(20, LocalDate.of(2023, Month.SEPTEMBER, 30)),
                Map.entry(21, LocalDate.of(2031, Month.SEPTEMBER, 30)),
                Map.entry(22, LocalDate.of(2024, Month.SEPTEMBER, 30)),
                Map.entry(23, LocalDate.of(2025, Month.MARCH, 31)),
                Map.entry(24, LocalDate.of(2025, Month.SEPTEMBER, 30)),
                Map.entry(25, LocalDate.of(2033, Month.SEPTEMBER, 30)));


        private static void check() {
            if (!isEnabled(JDK_END_OF_LIFE.class)) {
                return;
            }
            final Version version = Runtime.version();
            final LocalDate eolDate = EOL_DATES.get(version.feature());
            if (eolDate == null) {
                return;
            }
            if (LocalDate.now().isAfter(eolDate.plusYears(1))) {
                throw exception(JDK_END_OF_LIFE.class, String.format(
                        "The current JDK feature version %d is end-of-life as of %s. We recommend updating to a non end-of-life JDK.",
                        version.feature(), eolDate));
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant