Skip to content

[Discussion] Increasing minimum supported JDK (and dropping support for JDK 11) #3803

Closed

Description

@cushon

Error Prone will eventually drop support for running on JDK 11. This bug is intended to collect input from the community on the timing of that decision. There aren't immediate plans to do this, but there are also reason to look forward to using Java > 11 language features in the implementation.

Note that using a newer JDK version to run javac during the build doesn't prevent building code that is deployed to earlier versions, the compiler just has to be configured with --release (or -source/-target/-bootclasspath). For example, it's supported to use the JDK 17 javac and pass --release 8 to compile Java 8 code that is deployed to a JDK 8 runtime.

Questions:

  • What would the next minimum supported version be? (I think a likely answer is 17, since it's the next LTS after 11.)

  • If you're currently running Error Prone on JDK 11, do you have a timeline for upgrading to a newer version?

Activity

  1. Stephan202 commented on Feb 28, 2023

    @Stephan202
    Contributor

    Great topic. Some n=1 feedback: all Picnic-internal code targets JDK 17. For Error Prone Support we kept the baseline at JDK 11, but that does impede the use of text blocks in unit tests which is a shame, because they would be a great quality of life improvement i.c.w. CompilationTestHelper and BugCheckerRefactoringTestHelper (PicnicSupermarket/error-prone-support#198). (Given Error Prone's reliance on JDK internals we do want to run the tests against all supported JDKs, so testing only on JDK 15+ doesn't seem appropriate.)

  2. RobertTheBlair commented on Mar 1, 2023

    @RobertTheBlair
    Contributor

    Dropping JDK 11 in 2023 would be premature. Where I work, we have not migrated everything off of JDK 8 yet. Any place that has a large codebase to maintain, especially libraries that are still in use by JDK 8 / 11 applications, will have a long road ahead of them to get to 17.
    Getting 95% of apps and libraries to 17 won't happen for us for 2+ years.

  3. cushon commented on Mar 1, 2023

    @cushon
    CollaboratorAuthor

    Thanks! That sort of input is why I opened the issue. When we eventually do start requiring JDK 17 to run Error Prone I don't want that to be too onerous. It'll still be possible to continue to use older versions of Error Prone to get compatibility with older JDK versions, but we also don't want to do that too soon and cause fragmentation.

    One thing to note is that using JDK 17 to run javac during the build doesn't prevent building code that is deployed to JDK 8, the compiler just has to be configured with --release 8 (or -source/-target/-bootclasspath).

    At Google we aren't using JDK 8 anymore, and are using the latest javac to build while still supporting deployments to JDK 11.

  4. RobertTheBlair commented on Mar 3, 2023

    @RobertTheBlair
    Contributor

    True about older versions. As long as it is a major version update to require min jdk 17, should be clear what to expect.

  5. ksilz commented on Mar 14, 2023

    @ksilz

    I think it's too early to drop support for Java 11. Even the upcoming version 3 of the Quarkus framework still has Java 11 as the baseline.

  6. pinned this issue on Aug 10, 2023
  7. alexec commented on Aug 15, 2023

    @alexec

    We use Java 11 extensively and would prefer support is retained until it is out of LTS (2026?).

  8. cushon commented on Sep 14, 2023

    @cushon
    CollaboratorAuthor

    We use Java 11 extensively and would prefer support is retained until it is out of LTS (2026?).

    @alexec do you know if using a newer javac version and passing --release 11 to target Java 11 would be an option for you (there's a note about that in #3803 (comment))? Or is that not something you're likely to do?

  9. remal commented on Sep 14, 2023

    @remal

    @cushon using --release doesn't prevent from using Java api of later versions. So, you also need to use --system. I wouldn't say it's convenient for Error Prone users

  10. alexec commented on Sep 14, 2023

    @alexec

    We have 1000s of applications on Java 11. It's not feasible to migrate them.

  11. cushon commented on Sep 14, 2023

    @cushon
    CollaboratorAuthor

    @cushon using --release doesn't prevent from using Java api of later versions. So, you also need to use --system. I wouldn't say it's convenient for Error Prone users

    That is not accurate, --release configures the language level and APIs, passing just --release 11 is equivalent to passing -source 11 -target 11 --system <path to JDK 11>.

    (There are some situations --release doesn't support, e.g. I think it still can't be used together with --add-exports=, so --system is necessary for compilations that rely on that.)

    We have 1000s of applications on Java 11. It's not feasible to migrate them.

    Understood, to be clear that is not what I was asking. It's possible to use a newer version of javac at compile-time and still use an older JDK version in production, javac has support for targeting old JDK versions. E.g.:

    $JAVA_17_HOME/bin/javac --release 11 Foo.java
    $JAVA_11_HOME/bin/java Foo
    
  12. remal commented on Sep 14, 2023

    @remal

    @cushon have you tried it yourself? I have, and in my case it didn't work without --system. Which is logical, as javac don't know the path of JDK 11. And it doesn't search it.

  13. cpovirk commented on Sep 14, 2023

    @cpovirk
    Member

    @remal I'm guessing that you're thinking of (e.g.) -source 8, which has exactly the problem you are describing. --release 8 was introduced largely because of that problem, as discussed in the Motivation section of JEP 247.

  14. cushon commented on Sep 14, 2023

    @cushon
    CollaboratorAuthor

    @cushon have you tried it yourself?

    Yes

    in my case it didn't work without --system

    Do you have an example of what didn't work?

    javac don't know the path of JDK 11. And it doesn't search it.

    It doesn't need a JDK 11, recent versions package data on the APIs for different JDK versions to allow cross-compilation.

    Demo:

    $ javac -fullversion
    javac full version "17.0.2+8-86"
    $ cat T.java
    import java.util.List;
    
    class T {
      List<Integer> xs = List.of(42);
    }
    

    Compilation with -source 8 -target 8 succeeds, even though the compilation is using an API that isn't available

    $ javac -source 8 -target 8 T.java
    warning: [options] bootstrap class path not set in conjunction with -source 8
    

    Compilation with --release 8 fails, because it also configures the corresponding API version

    $ javac --release 8 T.java
    T.java:4: error: cannot find symbol
      List<Integer> xs = List.of(42);
                             ^
      symbol:   method of(int)
      location: interface List
    1 error
    $ 
    
  15. msridhar commented on Sep 14, 2023

    @msridhar
    Contributor

    @cushon I think as a corner case one might not be 100% safe with --release if code uses JDK-internal APIs? See, e.g., the issues we ran into with Error Prone checkers and internal javac APIs changing in JDK 17 (#4026). Does --release catch these issues as well?

  16. 9 remaining items

  17. quijote commented on Dec 16, 2023

    @quijote

    We are currently using latest errorprone version to check code that targets Java 5, 6, and 7 (don't ask why).

    Java 5 code already requires some hacks (bumping --release to Java 6 as Java 5 is no longer supported by javac 11 (javac --help):

      --release <release>
            Compile for a specific VM version. Supported targets: 6, 7, 8, 9, 10, 11
    

    Switching to javac 17 would drop support for Java 6:

      --release <release>
            Compile for the specified Java SE release. Supported releases: 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
    

    Switching to javac 21 would drop support for Java 7:

      --release <release>
            Compile for the specified Java SE release.
            Supported releases:
                8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
    

    So switching to Java 17 could be a bit painful for those that are still stuck at Java 6. In our case I think applying the same hack (compiling all Java 5 and 6 code a second time with --release 7 for errorprone) should do the trick.

  18. cushon commented on Feb 15, 2024

    @cushon
    CollaboratorAuthor

    Thank you to everyone who has provided feedback so far!

    I reviewed some of the input provided on the timeline for this:

    I think it's too early to drop support for Java 11. Even the upcoming version 3 of the Quarkus framework still has Java 11 as the baseline.

    It looks like Quarkus 3.7 will use Java 17 as the minimum JDK: https://quarkus.io/blog/java-17/

    Currently, for us (Uber), the work to migrate to JDK 17 is planned for [2024]

    @lazaroclapp are you able to provide any updates on that migration?

  19. yuxincs commented on Feb 16, 2024

    @yuxincs

    @cushon

    We (Uber) have recently finished the migration of the build system from buck to bazel and some initial JDK 17 support is being rolled out. However, the mass migration will probably still take some time and likely won't finish before the end of this half.

  20. findepi commented on May 10, 2024

    @findepi
    Contributor
    • What would the next minimum supported version be? (I think a likely answer is 17, since it's the next LTS after 11.)

    We at Trino project (https://github.com/trinodb/trino) rely on error-prone for static code analysis.
    Trino currently requires Java 22 for compilation. From that perspective support for new Java language syntax is more important than supporting older versions. (Obviously this is not the only perspective that matters.)

  21. cushon commented on May 25, 2024

    @cushon
    CollaboratorAuthor

    As a general update here, I'm expecting Error Prone will not support running on JDK 11 after September 2024.

    (As before using Error Prone to compile code that is deployed to earlier versions will still be fully supported, it will just require using a newer JDK for compilation and setting --release or -source/-target/-bootclasspath.)

    From that perspective support for new Java language syntax is more important than supporting older versions.

    Thanks, that's something I expect to provide as well and is somewhat separate, we want Error Prone to be compatible with the latest available JDK versions and Java language features regardless of what the minimum supported JDK version is.

    A related point about Java language syntax is that raising the minimum supported JDK removes support for some older Java language versions, -source 6 -target 6 was removed in JDK 12 and so Error Prone effectively won't support Java 6 language features if we raise the minimum supported JDK from 11 to 17. (And -source 7 -target 7 was removed in JDK 20, so that will eventually go away the next time the minimum supported JDK is raised.)

  22. cushon commented on Sep 11, 2024

    @cushon
    CollaboratorAuthor

    Error Prone 2.32.0 has been released, which raises the minimum supported JDK version to JDK 17: https://github.com/google/error-prone/releases/tag/v2.32.0

  23. gemmellr commented on Sep 12, 2024

    @gemmellr

    Would be good to document the new requirement, i.e #4570

  24. unpinned this issue on Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions