Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#20920 closed enhancement (fixed)

JEP 247: Compile for Older Platform Versions (javac --release 8)

Reported by: simon04 Owned by: simon04
Priority: normal Milestone: 21.05
Component: Core Version:
Keywords: javac Cc:

Description (last modified by simon04)

Currently, we compile JOSM using javac -source 1.8 -target 1.8 causing the following warning when using a newer JDK:

warning: [options] bootstrap class path not set in conjunction with -source 8

Starting with Java 9, javac --release 8 may be used: "Compiles against the public, supported and documented API for a specific VM version" thanks to JEP 247: Compile for Older Platform Versions

JEP 247 – Motivation
javac provides two command line options, -source and -target, which can be used to select the version of the Java language accepted by the compiler and the version of the class files it produces, respectively. By default, however, javac compiles against the most-recent version of the platform APIs. The compiled program can therefore accidentally use APIs only available in the current version of the platform. Such programs cannot run on older versions of the platform, regardless of the values passed to the -source and -target options. This is a long-term usability pain point, since users expect that by using these options they'll get class files that can run on the the platform version specified by -target.

Ant's <javac> supports release:

Specify the value for the --release switch.
When set and running on JDK 9+ the source and target attributes as well as the bootclasspath will be ignored. Since Ant 1.9.8.
Required: No, ignored when compiling on JDK 8 or earlier

[javac] Support for javac --release has been added in Java9 ignoring it

Interesting insights: The Anatomy of ct.sym — How javac Ensures Backwards Compatibility - Gunnar Morling

Attachments (0)

Change History (7)

comment:1 by simon04, 3 years ago

Description: modified (diff)

comment:2 by simon04, 3 years ago

Description: modified (diff)

comment:3 by simon04, 3 years ago

Resolution: fixed
Status: assignedclosed

In 17906/josm:

fix #20920 - javac --release 8

comment:4 by simon04, 3 years ago

Description: modified (diff)

comment:5 by simon04, 3 years ago

In 35765/osm:

see #20920 - javac --release 8 for plugins

comment:6 by Don-vip, 3 years ago

It broke the plugins that cannot be built with Java 8 such as http2:

compile:
     [echo] compiling sources for C:\SVN\josm\dist\http2.jar ...
    [javac] Compiling 2 source files to C:\SVN\josm\plugins\http2\build
    [javac] C:\SVN\josm\plugins\http2\src\org\openstreetmap\josm\plugins\http2\Http2Client.java:9: error: package java.net.http does not exist
    [javac] import java.net.http.HttpClient;
    [javac]                     ^
...
    [javac] 19 errors

BUILD FAILED

comment:7 by Don-vip, 3 years ago

In 35785/osm:

see #20920 - fix http2 plugin build, requires Java 11

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain simon04.
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.