From Fedora Project Wiki
(Created page with "<!-- Self Contained or System Wide Change Proposal? Use this guide to determine to which category your proposed change belongs to. Self Contained Changes are: * changes to isolated/leaf package without the impact on other packages/rest of the distribution * limited scope changes without the impact on other packages/rest of the distribution * coordinated effort within SIG with limited impact outside SIG functional area, accepted by the SIG System Wide Changes are: * cha...")
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<!-- Self Contained or System Wide Change Proposal?
= java-21-openjdk as the system JDK in F40 <!-- The name of your change proposal --> =
Use this guide to determine to which category your proposed change belongs to.
 
Self Contained Changes are:
* changes to isolated/leaf package without the impact on other packages/rest of the distribution
* limited scope changes without the impact on other packages/rest of the distribution
* coordinated effort within SIG with limited impact outside SIG functional area, accepted by the SIG
 
System Wide Changes are:
* changes that does not fit Self Contained Changes category touching
* changes that require coordination within the distribution (for example mass rebuilds, release engineering or other teams effort etc.)
* changing system defaults
 
For Self Contained Changes, sections marked as "REQUIRED FOR SYSTEM WIDE CHANGES" are OPTIONAL but FESCo/Wrangler can request more details (especially in case the change proposal category is improper or updated to System Wide category). For System Wide Changes all fields on this form are required for FESCo acceptance (when applies). 
 
We request that you maintain the same order of sections so that all of the change proposal pages are uniform.
-->
 
<!-- The actual name of your proposed change page should look something like: Changes/Your_Change_Proposal_Name.  This keeps all change proposals in the same namespace -->


= java-21-openjdk as the system JDK in F40 <!-- The name of your change proposal --> =


== Summary ==
== Summary ==
Line 40: Line 21:
* Product: java and java stack
* Product: java and java stack
* Responsible WG: java-sig (java and java-maint)(which no longer exists)
* Responsible WG: java-sig (java and java-maint)(which no longer exists)
* rcm ticket: [TBD]
* rcm ticket: https://pagure.io/releng/issue/11859
* named side tag ticket: TBD
* named side tag ticket: TBD


== Current status ==
== Current status ==
[[Category:SystemWideChange]]  
[[Category:SystemWideChange]]  
[[Category:ChangeAcceptedF40]]


* Targeted release: [[Releases/40 | Fedora 40 ]]  
* Targeted release: [[Releases/40 | Fedora 40 ]]  
Line 55: Line 37:
CLOSED as NEXTRELEASE -> change is completed and verified and will be delivered in next release under development
CLOSED as NEXTRELEASE -> change is completed and verified and will be delivered in next release under development
-->
-->
* TBD
* [https://lists.fedoraproject.org/archives/list/devel-announce@lists.fedoraproject.org/thread/P2RZLFY4MTDDQGFPEJ7TLKAXZLSYEUDP/ Discussion thread]
* FESCo issue: [TBD]
* [https://discussion.fedoraproject.org/t/f40-change-proposal-java-21-system-wide/101312 Announced]
* Tracker bug: [TBD]
* FESCo issue: [https://pagure.io/fesco/issue/3147 #3147]
* Release notes tracker: [TBD]
* Tracker bug: [https://bugzilla.redhat.com/show_bug.cgi?id=2262141 #2262141]
* Release notes tracker: [https://pagure.io/fedora-docs/release-notes/issue/1075 #1075]


=== Expected schedule ===
=== Expected schedule ===
Line 85: Line 68:


Major incompatibility is again (as we were bumping 8->11) encapsulation. What was hidden is now even more hidden and few more parts were hidden. Luckily, most of the projects, when shifted to 11, did it properly. Still few projects may hit usage of some  newly restricted APIs.
Major incompatibility is again (as we were bumping 8->11) encapsulation. What was hidden is now even more hidden and few more parts were hidden. Luckily, most of the projects, when shifted to 11, did it properly. Still few projects may hit usage of some  newly restricted APIs.
== Feedback ==
<!-- Summarize the feedback from the community and address why you chose not to accept proposed alternatives. This section is optional for all change proposals but is strongly suggested. Incorporating feedback here as it is raised gives FESCo a clearer view of your proposal and leaves a good record for the future. If you get no feedback, that is useful to note in this section as well. For innovative or possibly controversial ideas, consider collecting feedback before you file the change proposal. -->


== Benefit to Fedora ==
== Benefit to Fedora ==
Line 226: Line 212:


== Dependencies ==
== Dependencies ==
Around 2000 packages will need attendance (that is approximately 1/3 of time of jdk11 bump, but It seems, that 1100 packages remained on jdk8). Runtime dependencies:
Around 2000 packages will need attendance
  $ repoquery -q --whatrequires java-headless |wc -l
  $ repoquery -q --whatrequires java-headless |wc -l
  1007
  736
  $ repoquery -q --whatrequires java | wc -l
  $ repoquery -q --whatrequires java | wc -l
  53
  41
  $ repoquery -q --whatrequires java-devel | wc -l
  $ repoquery -q --whatrequires java-devel | wc -l
  28
  13
  $ repoquery -q --whatrequires java-1.8.0-openjdk-headless |wc -l
  $ repoquery -q --whatrequires java-1.8.0-openjdk-headless |wc -l
  1003
  653
  $ repoquery -q --whatrequires java-1.8.0-openjdk  | wc -l
  $ repoquery -q --whatrequires java-1.8.0-openjdk  | wc -l
  80
  8
  $ repoquery -q --whatrequires java-1.8.0-openjdk-devel  | wc -l
  $ repoquery -q --whatrequires java-1.8.0-openjdk-devel  | wc -l
  42
  4
  $ repoquery -q --whatrequires java-11-openjdk-headless |wc -l
  $ repoquery -q --whatrequires java-11-openjdk-headless |wc -l
  1030
  663
  $ repoquery -q --whatrequires java-11-openjdk  | wc -l
  $ repoquery -q --whatrequires java-11-openjdk  | wc -l
  78
  8
  $ repoquery -q --whatrequires java-11-openjdk-devel  | wc -l
  $ repoquery -q --whatrequires java-11-openjdk-devel  | wc -l
  36
  5
$ repoquery -q --whatrequires java-17-openjdk-headless |wc -l
757
$ repoquery -q --whatrequires java-17-openjdk |wc -l
55
$ repoquery -q --whatrequires java-17-openjdk-devel |wc -l
20


with src repos on, build time depndnecies:
with src repos on, build time depndnecies:
Line 277: Line 269:
  + repoquery --arch src -q --whatrequires java-11-openjdk-devel
  + repoquery --arch src -q --whatrequires java-11-openjdk-devel
  15
  15




Packages needing major work will be
Packages needing major work will be
* java-11-openjdk
* java-17-openjdk
* java-17-openjdk
* java-21-openjdk
* javapackages-tools
* javapackages-tools
* maybe maven base
* maybe maven base
Line 289: Line 280:


== Contingency Plan ==
== Contingency Plan ==
* If the mass rebuild, after the change application, breaks to much packages, or some important will be unfixable, jdk11 must be restored back to the position of system jdk.
* If the mass rebuild, after the changes are applied, breaks too many packages, or some crucial component will be unfixable, JDK 17 must be restored back to the position of system JDK.
<!-- If you cannot complete your feature by the final development freeze, what is the backup plan?  This might be as simple as "Revert the shipped configuration".  Or it might not (e.g. rebuilding a number of dependent packages).  If you feature is not completed in time we want to assure others that other parts of Fedora will not be in jeopardy.  -->
<!-- If you cannot complete your feature by the final development freeze, what is the backup plan?  This might be as simple as "Revert the shipped configuration".  Or it might not (e.g. rebuilding a number of dependent packages).  If you feature is not completed in time we want to assure others that other parts of Fedora will not be in jeopardy.  -->
* Contingency mechanism: Return jdk8 as system jdk and mass rebuild again. Note, that this may be very hard, because during build of packages by jdk8, by jdk11 built dependencies will be picekd up, so build will fail. Maybe several iterations of mass rebuild will be needed.  <!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
* Contingency mechanism: Return jdk8 as system jdk and mass rebuild again. Note, that this may be very hard, because during build of packages by jdk8, by jdk11 built dependencies will be picekd up, so build will fail. Maybe several iterations of mass rebuild will be needed.  <!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
Line 297: Line 288:
* Blocks release? Yes
* Blocks release? Yes
* Blocks product? N/A
* Blocks product? N/A
* Generally going back will be imho impossible. Once the decision is taken, javastack should be fixed, and where it can not be fixed, it had to migrate to compat packages, or bundled-dependencies pacages or be orphaned.
* In general, going back will be, in my opinion, impossible. Once the decision is taken, java stack should be fixed, and where it can not be fixed, it has to migrate to compat packages, or bundled-dependencies packages, or be orphaned.
=== side tag ===
=== side tag ===
https://fedoraproject.org/wiki/Package_update_HOWTO#Creating_a_side-tag
https://fedoraproject.org/wiki/Package_update_HOWTO#Creating_a_side-tag
* for this fedora have technology known as side tag
* for these changes, Fedora has technology known as side tag
* I do not have experience with it, but is making the contingency plan much smoother
* I do not have experience with it, but it is making the contingency plan much smoother
* it is a way, which will be done first
* it is an approach, which will be used first
=== copr preliminary rebuild ===
We run an preliminary mass rebuild of javastack in copr repo  https://copr.fedorainfracloud.org/coprs/jvanek/java17/builds/  on packages requiring java,javac, java-devel, maven-local, ant, ivy & comp for build. The first result will be: todo
 
* If there is "failed" but contains "- -" then it is probably orphan. If you wish to resurrect it, please ensure it runs against JDK17 (see lower)
* If there is "failed" but failed in "seconds", then those packages failed so quickly, that the build was in initial phases. That usually mean that you build with source/target lower then 1.8 JDK17 supports 1.7 and up. We recommend to bump the source/target to 1.8, to allow existence of compat 1.8 packages alongside main javastack
* If there is "failed", and its none of above, then your package simply failed. Very often the scary error may be fixed by bump to latest upstream version. JDK 17 is shortly. Please, try to fix the package. Don't hesitate to ask,. If you fix the fail, feel free to share your fix, it may help others.
==== Debugging  failures wiht help of this copr ====
The copr repo we maintain, contains builds of java-17-openjdk as system JDK, javapackages-tools honoring that, and java-11-openjdk as non system JDK. Also it contains successfully rebuilt packages. You can directly use this copr repo in several ways.
* first glance on error. On https://copr.fedorainfracloud.org/coprs/jvanek/java17/builds/ find yours build  (select "all" instead of "25" at the bottom),
** Click its number, select chroot (currently  fedora-rawhide-x86_64 ) and check the logs. Main log is build.log.gz.
* anything you push to rawhide, will automatically rebuild here in rawhide chroot (we have jdk in rawhide broken a bit currently)
** It is the best approach. If you can fix your package in rawhide directly, without breaking the rawhide to much, go for it
** If yo need to experiment, I have a mock config for you (generated from  <code>copr-cli mock-config jvanek/java17 > jvanek-java17-fedora-rawhide-x86_64.cfg</code>) which you can copy to your '''/etc/mock''' or '''~/.config/mock/''' and use - https://raw.githubusercontent.com/judovana/FedoraSystemJdkBump/main/scritps/spammer/exemplarResults/jvanek-java17-fedora-rawhide-x86_64.cfg .  Eg:
 
# as root, globally
sudo wget https://raw.githubusercontent.com/judovana/FedoraSystemJdkBump/main/scritps/spammer/exemplarResults/jvanek-java17-fedora-rawhide-x86_64.cfg -O /etc/mock/jvanek-java17-fedora-rawhide-x86_64.cfg
# or as user, locally (after creating  ~/.config/mock/)
wget https://raw.githubusercontent.com/judovana/FedoraSystemJdkBump/main/scritps/spammer/exemplarResults/jvanek-java17-fedora-rawhide-x86_64.cfg  -O ~/.config/mock/jvanek-java17-fedora-rawhide-x86_64.cfg
# change spec, bump sources, apply patches
fedpkg srpm
mock -r jvanek-java17-fedora-rawhide-x86_64  *.src.rpm
 
Or any other packaging workflow you use, and you can use against the copr repo.


== Documentation ==
== Documentation ==
<!-- Is there upstream documentation on this change, or notes you have written yourself?  Link to that material here so other interested developers can get involved. -->
<!-- Is there upstream documentation on this change, or notes you have written yourself?  Link to that material here so other interested developers can get involved. -->
* oracle17 release notes: https://www.oracle.com/java/technologies/javase/17-relnotes.html
* oracle 21 release notes: https://www.oracle.com/java/technologies/javase/21-relnote-issues.html
* openjdk17 jeps: https://openjdk.java.net/projects/jdk/17/ https://openjdk.java.net/projects/jdk/16/ https://openjdk.java.net/projects/jdk/15/ https://openjdk.java.net/projects/jdk/14/ https://openjdk.java.net/projects/jdk/13/ https://openjdk.java.net/projects/jdk/12/
* openjdk21 jeps: https://openjdk.java.net/projects/jdk/21/ https://openjdk.java.net/projects/jdk/20/ https://openjdk.java.net/projects/jdk/19/ https://openjdk.java.net/projects/jdk/18/
* oracle migration guide https://docs.oracle.com/en/java/javase/17/migrate/index.html
* oracle migration guide https://docs.oracle.com/en/java/javase/21/migrate/index.html
=== common issues packagers can face and gathered solutions ===
=== common issues packagers can face and gathered solutions ===
Contacts: ask on devel@lists.fedoraproject.org or java-devel@lists.fedoraproject.org or directly to me jvanek@redhat.com
Contacts: ask on devel@lists.fedoraproject.org or java-devel@lists.fedoraproject.org or directly to me pmikova@redhat.com
Threads of "F36 system wide change, java-17-openjdk as system jdk"
Threads of "F40 system wide change, java-21-openjdk as a system JDK"


Major database can be browsing of closed bugs of blockers of https://bugzilla.redhat.com/show_bug.cgi?id=TODO ; unluckily, when it was analysed, it was not summarised up (that would actually double the work)
Major database can be browsing of closed bugs of blockers of https://bugzilla.redhat.com/show_bug.cgi?id=TODO ; unluckily, when it was analysed, it was not summarised up (that would actually double the work)
==== My package can not work with jdk17 ====
==== My package can not work with JDK 21 ====
Generally it is not true. Generally, no program can say, that it do not support jdk17, because any javac/java application can be *hacked* to work with java17 - see https://jvanek.fedorapeople.org/devconf/2017/portingjavaInternalToJdk9/portingOfItwToJdk9-II.pdf (really all except package split over modules, which is impossible)
No program can say, that it does not support JDK 21, because any javac/java application can be remade to work with JDK 21 - see https://jvanek.fedorapeople.org/devconf/2017/portingjavaInternalToJdk9/portingOfItwToJdk9-II.pdf (really all except package split over modules, which is impossible)


Now above mentioned approaches are indeed *hacked*, and I discourage everybody to do so. The upstream should be moved to jdk17, and not much excuses are around to support to not to do so. If you package is really bound to jdk11, you can move to the version-full requires:  
Now above mentioned approaches are indeed *hacked*, and I discourage everybody to do so. The upstream should be moved to jdk21, and not much excuses are around to support to not to do so. If you package is really bound to JDK 17, you can move to the version-full requires:  
   BuildRequires: java-11-openjdk(-devel)  
   BuildRequires: java-17-openjdk(-devel)  
and
and
   Requires: java-11-openjdk(-headless).
   Requires: java-17-openjdk(-headless).


In addition, '''if  you work with maven/ant or simialr, you must set export JAVA_HOME=/usr/lib/jvm/java-11-openjdk before calling it.''' japckage tools and comp are made to accept it.
In addition, '''if  you work with maven/ant or similar builders, you must set export JAVA_HOME=/usr/lib/jvm/java-11-openjdk before calling it.''' javapackage-tools and comp are made to accept it.


However there is an trap - packages you depends on.  Once some of your dependencies will be compiled
However there is a trap - the packages you are depending on.  Once some of your dependencies will be compiled
with --target > 8, you are doomed, and you have to bundle it or create its compat version. By doing
with --target > 8, you are doomed, and you have to bundle it or create its compat version. By doing
so you can easily end in dependency hell.
so you can easily end up in dependency hell.


Please, try to avoid this as much as possible!
Please, try to avoid this as much as possible!
===== Intermediate step build with java-11-openjdk-devel and run with java (that means any sytem java, eg java-17-openjdk) =====
===== Intermediate step build with java-17-openjdk-devel and run with java (that means any sytem java, eg java-21-openjdk) =====
Some projects support JDK17 for runtime, but not for compile time.  
Some projects support JDK21 for runtime, but not for compile time.  
  Buildrequires: java-11-openjdk-devel
  Buildrequires: java-17-openjdk-devel
  ...
  ...
  Requires: java(-headless)
  Requires: java(-headless)
Line 360: Line 328:
  %build
  %build
  ...
  ...
   export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
   export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
  ...
  ...


Line 369: Line 337:
* You have very indirect BR on java.
* You have very indirect BR on java.
** Solution
** Solution
** Email me (jvanek@redhat.com) or ping me (jvanek), I will gladly add you package(s)
** Email me (pmikova@redhat.com) or ping me (pmikova), I will gladly add you package(s)
* You have exact requires on java-11-openjdk(-devel)
* You have exact requires on java-11-openjdk(-devel)
** Solution
** Solution
Line 377: Line 345:
==== Wrong source/target version ====
==== Wrong source/target version ====
maven
maven
  [ERROR] Source option 1.3 is no longer supported. Use 7 or later.
  [ERROR] Source option 1.7 is no longer supported. Use 8 or later.
  [ERROR] Target option 1.3 is no longer supported. Use 1.7 or later.
  [ERROR] Target option 7 is no longer supported. Use 1.8 or later.
ant
ant
  -do-compile:
  -do-compile:
     [mkdir] Created dir: /builddir/build/BUILD/jpanoramamaker-5/build/empty
     [mkdir] Created dir: /builddir/build/BUILD/jpanoramamaker-5/build/empty
     [javac] Compiling 45 source files to /builddir/build/BUILD/jpanoramamaker-5/build/classes
     [javac] Compiling 45 source files to /builddir/build/BUILD/jpanoramamaker-5/build/classes
     [javac] warning: [options] bootstrap class path not set in conjunction with -source 5
     [javac] warning: [options] bootstrap class path not set in conjunction with -source 7
     [javac] error: Source option 5 is no longer supported. Use 7 or later.
     [javac] error: Source option 7 is no longer supported. Use 8 or later.
     [javac] error: Target option 1.5 is no longer supported. Use 1.7 or later.
     [javac] error: Target option 1.7 is no longer supported. Use 1.8 or later.
  BUILD FAILED
  BUILD FAILED
* Solution
* Solution
** Your javac is run with wrong source/tag parameters. [https://duckduckgo.com/?t=ffsb&q=javac+source+target&ia=web net search will give you quick answer]
** Your javac is run with wrong source/tag parameters. [https://duckduckgo.com/?t=ffsb&q=javac+source+target&ia=web net search will give you quick answer]
** Fixes are:
** Fixes are eg:
*** [https://src.fedoraproject.org/rpms/CardManager/blob/2d6e0f1e3d23d864c1ed0b20f6076fa4c9a15c21/f/bumpJdk.patch example patch for netbeans generated ant]
*** https://src.fedoraproject.org/rpms/maven-shared-io/pull-request/3#_1__27
 
==== usage of sun.misc.Unsafe.defineClass ====
==== direct usage ====
* use public replacement, java.lang.invoke.MethodHandles.Lookup.defineClass
* eg https://src.fedoraproject.org/rpms/procyon/blob/master/f/lookupPatch.patch
* Note taht it is not 100% replacement, and you should consult upstream first
* Note that it is JDK8 incompatible change
==== library usage ====
  java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String [B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
at java.base/java.lang.Class.getMethod(Class.java:2227)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:201)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:197)


In this case, jaxb was old. Get new version of library
==== invalid entry in sources ====


==== package XYZ does not exists ... in javadoc generation! ====
`stdout: Invalid entry in sources file: ae177021dfa32281b3b052a6574e94b9  CardManager_sources3.zip`


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.1.1:aggregate (default-cli) on project  classloader-leak-test-framework: An error has occurred in Javadoc report generation:
Your package was not updated for ages, and thus have still sources in `MD5` sum format.
[ERROR] Exit code: 1 - /builddir/build/BUILD/classloader-leak-prevention-classloader-leak-test-framework-1.1.1/src/main/java/se/jiderhamn/classloader/leak/JUnitClassloaderRunner.java:9: error: package org.junit does not exist
[ERROR] import org.junit.Assert;


* '''solution''' is be to replace javadoc plugin by xmvn --javadoc:
Obtain/update/generate your sources, and `fedpkg new-sources` them.
**  https://src.fedoraproject.org/rpms/byteman/c/d145b9e4af8952b1a63432ec67d7109161f83617?branch=master
**  it is bug in fedora mavenjavadocplugin
* '''see this thread:  https://lists.fedoraproject.org/archives/list/java-devel@lists.fedoraproject.org/thread/UD7Q5DYAWI7YO4VW7UZPDWR644V7S462/'''


==== javah: No such file or directory ====
If your sources can no longer be obtained., you can check lookaside cache, egfor this case https://src.fedoraproject.org/repo/pkgs/CardManager/ - https://src.fedoraproject.org/rpms/CardManager/c/35ebf20a6370345947e0722186074487da6d620c?branch=rawhide


The '''javah''' command was retired and is no longer available in jdk11; you should switch the package to use '''javac -h''' instead. The new '''javac -h''' syntax works just fine with jdk8, so you can switch to this now without worrying about backwards compatibility.
==== encapsulated module ====


For example: https://src.fedoraproject.org/rpms/snappy-java/blob/2981aaa5b8a597129ad2f12cdf1f4617303a8425/f/javah-adaptation.patch
`
[ERROR] Errors:  
[ERROR]  com.fasterxml.jackson.dataformat.csv.deser.BasicParserTest#testMapsWithLinefeeds ClassCastException class com.fasterxml.jackson.core.io.IOContext cannot be cast to class com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext (com.fasterxml.jackson.core.io.IOContext and com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext are in unnamed module of loader 'app')
[ERROR]  com.fasterxml.jackson.dataformat.csv.deser.BasicParserTest#testSimpleExplicit ClassCastException class com.fasterxml.jackson.core.io.IOContext cannot be cast to class com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext (com.fasterxml.jackson.core.io.IOContext and com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext are in unnamed module of loader 'app')
...
`


==== replacing new Integer(string)/Double(string)/... by  Integer/Double../.valueOf(string)  ====
You have to open and export the modules
The string based constructor is no longer public (spot bugs wuld tell you years ago)
* https://src.fedoraproject.org/rpms/jmol/c/a7b84a1aeef5bdb5e71f3bc9a02163bc5010f790?branch=rawhide


=== yield keyword ===
==== no longer allowed security manager ====
* In java 13, "yield" keyword is added, so the previous qdbm rpm -46 showed the following
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/SecurityManager.html#set-security-manager
* https://src.fedoraproject.org/rpms/qdbm/c/d453fd67b83aafd251bbc529dc3265e0cc998f02?branch=rawhide


==== exemplar commits  ====
In jdk 21, is hard deprecation of SecurityManager. if you are using it, it will throw exception. You can allow it again: `-Djava.security.manager=allow`
* sed source/target in build files - https://src.fedoraproject.org/rpms/string-template-maven-plugin/c/32c6d9b221ea718d761d789e667b30426659bc6d?branch=rawhide
* set source/release by xpath in pom.xml - https://src.fedoraproject.org/rpms/jansi1/c/75892601c9c677b9cf5b29c98c778d4322818ad4?branch=rawhide
* workaround surefire  Forked test fails with InvocationTargetException: org.apache.commons.lang3.StringUtils  https://bugzilla.redhat.com/show_bug.cgi?id=1981486 - https://src.fedoraproject.org/rpms/jni-inchi/c/61948970da969724bfffc5e94d40d2053e74f6cf?branch=rawhide
* staying on jdk11 - bottom of: https://src.fedoraproject.org/rpms/jmol/c/a7b84a1aeef5bdb5e71f3bc9a02163bc5010f790?branch=rawhide
*


== Release Notes ==
== Release Notes ==

Revision as of 13:31, 5 March 2024

java-21-openjdk as the system JDK in F40

Summary

Update the system JDK in Fedora from java-17-openjdk to java-21-openjdk.

Owner

Current status

Expected schedule

  • During January 2024, we will create a new package, java-21-openjdk, which will be a clone of java-latest-openjdk, which contains STS versions of OpenJDK (currently 21) and will move to JDK 22 in February/March.
  • December 2023 I will do mass rebuild in copr
    • all maintainers will be informed about the results
  • January 2023 I will do second mass rebuild in copr
    • all maintainers will be informed about the results
  • February 2023 mass rebuild in rawhide - side tag
    • FTBFS bugs will be filed
  • February 2023 the sidetag will be merged
  • Change Checkpoint: 100% Code Complete Deadline TBD
    • hard deadline for feature completed

Detailed Description

Fedora currently ships:

  • java-1.8.0-openjdk (LTS)
  • java-11-openjdk (LTS)
  • java-17-openjdk (LTS), system JDK
  • java-latest-openjdk (currently JDK21)
  • java-21-openjdk will be cloned from java-latest-openjdk

Therefore, every package honoring the packaging rules and requiring java via java-headless or java-devel is built in koji using java-17-openjdk-devel and pulling java-17-openjdk during runtime (see java ). Also, javapackaging-tools are using java-11-openjdk as hardcoded runtime (see changes).

We were intentionally delaying jdk11 on-boarding for stability reasons. But there is reason for this approach with 21 (for recall, see https://fedoraproject.org/wiki/Changes/Java11)

Major incompatibility is again (as we were bumping 8->11) encapsulation. What was hidden is now even more hidden and few more parts were hidden. Luckily, most of the projects, when shifted to 11, did it properly. Still few projects may hit usage of some newly restricted APIs.

Feedback

Benefit to Fedora

JDK21 was released a while ago, but compatibility with JDK 17 is good enough and it is a stable release. Although we can expect some group of packages to use jdk8 forever, and some other (much smaller) group of packages stay on jdk11 for a while, the java stack should be able to use the JDK 21. Both JDK 8 and JDK 11 will remain part of Fedora as long as they are supported upstream, and there is a target audience in our OS.

Scope

To keep the java-17-openjdk (and lower versions of JDK), but to remove its java/javac versionless provides, make java-21-openjdk the provider of java, javac and other versionless provides, and keep java-latest-openjdk as rolling package for STS JDKs)

  • will guarantee fedora to be pure JDK21 distro.
  • will allow maintainers of JDK21 (or higher) incompatible packages to keep using JDK 17, JDK 11 and JDK 8
    • if any package depends on a package built by JDK 21, JDK 17, JDK 11 and JDK 8 may not be able to pick up that dependency.
    • this may lead to quite a lot of bundling or compat packages, but that may be acceptable
    • people developing JDK8 and JDK11 applications will very likely stay with fedora
    • we are bumping the system JDK every time a new JDK LTS comes up and it proved itself as a good practice

While quite a lot of users will rejoice, there may be cases where application is very hard to migrate to JDK11, so the contingency plan should be taken very serious.

Bytecode version

Workflow

Change owners

  • Feature will be implemented in side tag
    • --target f40-java21 is tag of choice
    • In its mass rebuild, approximately XYZ packages were built, and ABC failed. FTBFS bugs filled, most of them needs manual fix later
  • the JDK 17 and JDK 21 packages will be changed for this side tag
  • the mass rebuild of java stack will start
    • if necessary, several rounds of them
  • Failures will be gathered by me and few other volunteers
    • Most common issues and theirs fixes will be published
    • Package maintainers will be notified in case of failure via bugzilla
  • Depending on the fail rate, importance of failed packages and effort to fix them
    • the side tag will be merged to Fedora
    • or the contingency plan will be activated

Other developers

  • should fix their packages
    • this usually means to update to newer version, which supports jdk21
  • or to retire them if they appear non-fixable
  • or to base them on JDK11 without much warranty (as they will need to compat most of dependency chain)


Other

  • Proposal owners:
    • based on above, adapt jdk11 and jdk17 package provides
    • If necessary tune the build environment
  • Other developers:
    • based on selected approach to tune the main build tools
      • jpackage-tools and maven will affected
    • based on selected approach to tune the rpmbuild/macros
    • many java package maintainers will maybe need to adapt theirs packages
      • FTBFS bugs connected with this proposal, maybe with pagure ticket to allow discussion.
      • Solutions to most common errors should be gathered and published
  • Release engineering: TICKET_TBD (a check of an impact with Release Engineering is needed)
    • mass rebuild will be required for this change
  • Policies and guidelines: how to deal with build failures, eventually how to use some jdk17 specific build features will be provided
  • Trademark approval: N/A (not needed for this Change)

Upgrade/compatibility impact

Once the change is implemented properly, the update should be flawless and seamless

How To Test

  • only JDK 21 should remain the only system JDK after installing base javastack on clean system
  • the JDK 8, JDK 11, JDK 17, JDK 21 and java-latest-openjd can co-exist on one system
  • JDK 21 will be selected by default and will run most of the base java stack


User Experience

  • Standard user should be still be able to use java stack without even noticing the change.
  • Standard developer should still be able develop any java application comfortably
  • Standard packager will not suffer to much, and should be able to pack any java application for fedora

Dependencies

Around 2000 packages will need attendance

$ repoquery -q --whatrequires java-headless |wc -l
736
$ repoquery -q --whatrequires java | wc -l
41
$ repoquery -q --whatrequires java-devel | wc -l
13
$ repoquery -q --whatrequires java-1.8.0-openjdk-headless |wc -l
653
$ repoquery -q --whatrequires java-1.8.0-openjdk  | wc -l
8
$ repoquery -q --whatrequires java-1.8.0-openjdk-devel  | wc -l
4
$ repoquery -q --whatrequires java-11-openjdk-headless |wc -l
663
$ repoquery -q --whatrequires java-11-openjdk  | wc -l
8
$ repoquery -q --whatrequires java-11-openjdk-devel  | wc -l
5
$ repoquery -q --whatrequires java-17-openjdk-headless |wc -l
757
$ repoquery -q --whatrequires java-17-openjdk |wc -l
55
$ repoquery -q --whatrequires java-17-openjdk-devel |wc -l
20

with src repos on, build time depndnecies:

set +x ;echo "dont forget to enable all (correct fedora, fedotra-testing, fedora modules) SOURCE repos (sections in .repo files)!" ; for x in ant maven-local maven mvn xmvn java-headless java java-devel java-1.8.0-openjdk-headless java-1.8.0-openjdk java-1.8.0-openjdk-devel java-11-openjdk-headless   java-11-openjdk   java-11-openjdk-devel ; do for y in ""  "--arch src"  ;do set -x ; repoquery $y -q --whatrequires $x  |wc -l ; set +x ; done; done 
dont forget to enable all (correct fedora, fedotra-testing, fedora modules) SOURCE repos (sections in .repo files)
+ repoquery --arch src -q --whatrequires ant
152
+ repoquery --arch src -q --whatrequires maven-local
401
+ repoquery --arch src -q --whatrequires maven
4
+ repoquery --arch src -q --whatrequires mvn
0
+ repoquery --arch src -q --whatrequires xmvn
0
+ repoquery --arch src -q --whatrequires java-headless
5
+ repoquery --arch src -q --whatrequires java
0
+ repoquery --arch src -q --whatrequires java-devel
207
+ repoquery --arch src -q --whatrequires java-1.8.0-openjdk-headless
6
+ repoquery --arch src -q --whatrequires java-1.8.0-openjdk
0
+ repoquery --arch src -q --whatrequires java-1.8.0-openjdk-devel
19
+ repoquery --arch src -q --whatrequires java-11-openjdk-headless
0
+ repoquery --arch src -q --whatrequires java-11-openjdk
0
+ repoquery --arch src -q --whatrequires java-11-openjdk-devel
15


Packages needing major work will be

  • java-17-openjdk
  • java-21-openjdk
  • javapackages-tools
  • maybe maven base


Contingency Plan

  • If the mass rebuild, after the changes are applied, breaks too many packages, or some crucial component will be unfixable, JDK 17 must be restored back to the position of system JDK.
  • Contingency mechanism: Return jdk8 as system jdk and mass rebuild again. Note, that this may be very hard, because during build of packages by jdk8, by jdk11 built dependencies will be picekd up, so build will fail. Maybe several iterations of mass rebuild will be needed.
  • Contingency deadline: Announce release blocking deliverables Tue 2022-02-01 Tue 2022-02-01 0 (8days before branching, 22 before beta freeze)
  • Blocks release? Yes
  • Blocks product? N/A
  • In general, going back will be, in my opinion, impossible. Once the decision is taken, java stack should be fixed, and where it can not be fixed, it has to migrate to compat packages, or bundled-dependencies packages, or be orphaned.

side tag

https://fedoraproject.org/wiki/Package_update_HOWTO#Creating_a_side-tag

  • for these changes, Fedora has technology known as side tag
  • I do not have experience with it, but it is making the contingency plan much smoother
  • it is an approach, which will be used first

Documentation

common issues packagers can face and gathered solutions

Contacts: ask on devel@lists.fedoraproject.org or java-devel@lists.fedoraproject.org or directly to me pmikova@redhat.com Threads of "F40 system wide change, java-21-openjdk as a system JDK"

Major database can be browsing of closed bugs of blockers of https://bugzilla.redhat.com/show_bug.cgi?id=TODO ; unluckily, when it was analysed, it was not summarised up (that would actually double the work)

My package can not work with JDK 21

No program can say, that it does not support JDK 21, because any javac/java application can be remade to work with JDK 21 - see https://jvanek.fedorapeople.org/devconf/2017/portingjavaInternalToJdk9/portingOfItwToJdk9-II.pdf (really all except package split over modules, which is impossible)

Now above mentioned approaches are indeed *hacked*, and I discourage everybody to do so. The upstream should be moved to jdk21, and not much excuses are around to support to not to do so. If you package is really bound to JDK 17, you can move to the version-full requires:

 BuildRequires: java-17-openjdk(-devel) 

and

 Requires: java-17-openjdk(-headless).

In addition, if you work with maven/ant or similar builders, you must set export JAVA_HOME=/usr/lib/jvm/java-11-openjdk before calling it. javapackage-tools and comp are made to accept it.

However there is a trap - the packages you are depending on. Once some of your dependencies will be compiled with --target > 8, you are doomed, and you have to bundle it or create its compat version. By doing so you can easily end up in dependency hell.

Please, try to avoid this as much as possible!

Intermediate step build with java-17-openjdk-devel and run with java (that means any sytem java, eg java-21-openjdk)

Some projects support JDK21 for runtime, but not for compile time.

Buildrequires: java-17-openjdk-devel
...
Requires: java(-headless)
...
%build
...
 export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
...

Should work for a while. See the "My package can not work with jdk11" section

My package is not in your copr!

If your package is not listed in the copr rebuild repo, I can see two causes

  • You have very indirect BR on java.
    • Solution
    • Email me (pmikova@redhat.com) or ping me (pmikova), I will gladly add you package(s)
  • You have exact requires on java-11-openjdk(-devel)
    • Solution
    • Unless you have good reason, you are actually breaking packaging guidelines. Switch to java-devel. Once done, again let me know and I will gladly add your package
    • If you can't, then you most likely can not bump to jdk17, and you will live with jdk11 until it dies,

Wrong source/target version

maven

[ERROR] Source option 1.7 is no longer supported. Use 8 or later.
[ERROR] Target option 7 is no longer supported. Use 1.8 or later.

ant

-do-compile:
    [mkdir] Created dir: /builddir/build/BUILD/jpanoramamaker-5/build/empty
    [javac] Compiling 45 source files to /builddir/build/BUILD/jpanoramamaker-5/build/classes
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 7
    [javac] error: Source option 7 is no longer supported. Use 8 or later.
    [javac] error: Target option 1.7 is no longer supported. Use 1.8 or later.
BUILD FAILED

invalid entry in sources

stdout: Invalid entry in sources file: ae177021dfa32281b3b052a6574e94b9 CardManager_sources3.zip

Your package was not updated for ages, and thus have still sources in MD5 sum format.

Obtain/update/generate your sources, and fedpkg new-sources them.

If your sources can no longer be obtained., you can check lookaside cache, eg: for this case https://src.fedoraproject.org/repo/pkgs/CardManager/ - https://src.fedoraproject.org/rpms/CardManager/c/35ebf20a6370345947e0722186074487da6d620c?branch=rawhide

encapsulated module

[ERROR] Errors: [ERROR] com.fasterxml.jackson.dataformat.csv.deser.BasicParserTest#testMapsWithLinefeeds ClassCastException class com.fasterxml.jackson.core.io.IOContext cannot be cast to class com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext (com.fasterxml.jackson.core.io.IOContext and com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext are in unnamed module of loader 'app') [ERROR] com.fasterxml.jackson.dataformat.csv.deser.BasicParserTest#testSimpleExplicit ClassCastException class com.fasterxml.jackson.core.io.IOContext cannot be cast to class com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext (com.fasterxml.jackson.core.io.IOContext and com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext are in unnamed module of loader 'app') ...

You have to open and export the modules

no longer allowed security manager

https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/SecurityManager.html#set-security-manager

In jdk 21, is hard deprecation of SecurityManager. if you are using it, it will throw exception. You can allow it again: -Djava.security.manager=allow

Release Notes