Modify

Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#21510 closed enhancement (fixed)

[PATCH] Enable Multi-Release Jars (MRJAR AKA JEP 238)

Reported by: taylor.smock Owned by: Don-vip
Priority: normal Milestone: 21.12
Component: Core Version:
Keywords: jep238 mrjar java9 Cc:

Description (last modified by Don-vip)

From comment:15:ticket:21498 and comment:16:ticket:21498, it would be useful to be able to use new Java features while still maintaining backwards compatibility with Java 8.

JEP 238 allows for this. Java 8 reads the class files from the traditional package directories (e.g., org/openstreetmap/.. while Java9+ attempts to read class files first from META-INF/versions/${version}, with ${version} starting at the java version (e.g., 11) and decrementing until it finds a class file or it reaches 8, at which point it reads it from the traditional package directory.

Pros:

Cons:

  • Testing -- each class file is essentially a duplicate, so we may have duplicated code when the class only has one or two methods that can or should be version specific
  • The source code layout we have right now isn't very good for this use case. I've worked around it in the attached patch for build.xml, but IDEs are going to take a bit more work.
    • We may want to move the Java 8 source directories to src/main/java to make things easier. I was originally trying to have the source for Java{version} in the same source directory, but that didn't work well.

What the attached patch does:

  • Creates new macros: call-javac-compile and call-javac-compile-mrjar (the latter calls the former with some additional checks)
  • Checks for Java 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, and 21 source directories. These are expected to be src/main/java-${version}. If that directory exists, it compiles the files in that directory using the release target. The mrjar also checks that the compiler can compile for that version (isJava@{version} is set).
    • I'll be attaching an additional patch without Java 9, 10, 12, 13, 14, 15, and 16, as all of those are no longer supported (OpenJDK) and are not LTS releases. While Java 18-21 are not yet released, they will remain as new features will be introduced in them. Java 18-20 should be removed as support is dropped for them.

EDIT: I tested that the build works by copying the Vector3D class and adding a Logging.error with a unique message for the non-JEP 238 class and one for the JEP 238 class.

Attachments (2)

21510.patch (14.7 KB ) - added by taylor.smock 3 years ago.
MRJAR support for all Java releases (Java 8 - Java 21)
21510.2.patch (14.0 KB ) - added by taylor.smock 3 years ago.
Same as attachment:21510.patch except without unsupported Java releases (still has future Java releases)

Download all attachments as: .zip

Change History (13)

by taylor.smock, 3 years ago

Attachment: 21510.patch added

MRJAR support for all Java releases (Java 8 - Java 21)

by taylor.smock, 3 years ago

Attachment: 21510.2.patch added

Same as attachment:21510.patch except without unsupported Java releases (still has future Java releases)

comment:1 by taylor.smock, 3 years ago

Description: modified (diff)

comment:2 by taylor.smock, 3 years ago

Description: modified (diff)

comment:3 by Don-vip, 3 years ago

Milestone: 21.11
Owner: changed from team to Don-vip
Status: newassigned

comment:4 by Don-vip, 3 years ago

Resolution: fixed
Status: assignedclosed

In 18308/josm:

fix #21510 - Enable Multi-Release Jars (MRJAR - JEP 238 - patch by taylor.smock)

comment:5 by Don-vip, 3 years ago

In 18309/josm:

see #21510 - fixup, forgot to delete one part (patch didn't apply nicely)

comment:6 by Don-vip, 3 years ago

Thanks! Agreed in the long term I'd like to switch to conventional tree src/main|test/java|resources too, but that's another story :)

in reply to:  6 comment:7 by taylor.smock, 3 years ago

Replying to Don-vip:

Thanks! Agreed in the long term I'd like to switch to conventional tree src/main|test/java|resources too, but that's another story :)

Yep. Looks at all the patches.

in reply to:  5 comment:8 by taylor.smock, 3 years ago

Replying to Don-vip:

In 18309/josm:

see #21510 - fixup, forgot to delete one part (patch didn't apply nicely)

Sorry about that -- I had some changes to build.xml for use with my gitlab ci (mostly for codeclimate/source navigation).

EDIT: See semanticdb sections.

Last edited 3 years ago by taylor.smock (previous) (diff)

comment:9 by Don-vip, 3 years ago

Milestone: 21.1121.12

Milestone renamed

comment:10 by Don-vip, 2 years ago

Description: modified (diff)

comment:11 by Don-vip, 2 years ago

I'm going to investigate MRJAR support for #2372, I'd like to implement GeoTIFF support without waiting for Java 11/17 migration.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Don-vip.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.