Opened 8 years ago

Last modified 6 years ago

#11924 closed enhancement

Add compatibility with Java 9 — at Version 40

Reported by: Don-vip Owned by: team
Priority: major Milestone: 17.08
Component: Core Version:
Keywords: java9 jigsaw javabug Cc:

Description (last modified by Don-vip)

Java 9 is well advanced in its development, early builds are now available. Jigsaw project is now merged into main tree.

I have added basic Java 9 support in r8777:8778, r8793, r8795, r8796:8797 but making JOSM work with Jigsaw is another challenge.

This ticket aims to list all problems encountered.

  1. xmltask does not work ==> cannot build OSX package ==> fork created
  2. Proguard does not work ==> cannot build optimized jar
  3. Groovy does not work ==> cannot run some tests + cannot build taginfo files ==> fixed
  4. ResourceBundle.getBundle("sun.awt.resources.awt") results in an internal error ==> bug reported to Oracle ==> fixed
  5. Findbugs does not recognize new version string ==> bug and PR created
  6. JEP 272 removes com.apple.eawt package ==> need to update PlatformHookOsx

1; javabug:8154801 deprecates java.util.Observer / java.util.Observable ==> need to replace it by something from java.beans package

Change History (40)

comment:2 by Don-vip, 8 years ago

Description: modified (diff)

comment:3 by Don-vip, 8 years ago

Description: modified (diff)

comment:4 by Don-vip, 8 years ago

Description: modified (diff)

comment:5 by Don-vip, 8 years ago

Description: modified (diff)

comment:6 by Don-vip, 8 years ago

In 8817/josm:

see #11924 - JDK9 Jigsaw: do not run code in headless environment (for jenkins unit tests)

comment:7 by Don-vip, 8 years ago

In 8826/josm:

see #11924 - update xmltask to a new modern version built from https://github.com/don-vip/xmltask

comment:8 by Don-vip, 8 years ago

Description: modified (diff)

comment:9 by Don-vip, 8 years ago

In 8843/josm:

see #11924 - allow openjdk-9-jre in Debian control file

comment:10 by Don-vip, 8 years ago

All plugins load fine with Java 9 except ImportImagePlugin, which relies on geotools:

23:45:31.948 [main] FATAL org.openstreetmap.josm.plugins.ImportImagePlugin.ImportImagePlugin - Error while loading plugin
java.lang.IllegalArgumentException: org.opengis.referencing.datum.DatumFactory is not an ImageIO SPI class
	at javax.imageio.spi.ServiceRegistry.checkClassAllowed(ServiceRegistry.java:733) ~[?:?]
	at javax.imageio.spi.ServiceRegistry.<init>(ServiceRegistry.java:138) ~[?:?]
	at org.geotools.factory.FactoryRegistry.<init>(FactoryRegistry.java:155) ~[geotools.jar:?]
	at org.geotools.factory.FactoryRegistry.<init>(FactoryRegistry.java:146) ~[geotools.jar:?]
	at org.geotools.factory.FactoryCreator.<init>(FactoryCreator.java:82) ~[geotools.jar:?]
	at org.geotools.referencing.ReferencingFactoryFinder.getServiceRegistry(ReferencingFactoryFinder.java:115) ~[geotools.jar:?]
	at org.geotools.referencing.ReferencingFactoryFinder.getFactories(ReferencingFactoryFinder.java:180) ~[geotools.jar:?]
	at org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactories(ReferencingFactoryFinder.java:455) ~[geotools.jar:?]
	at org.geotools.referencing.DefaultAuthorityFactory.getSupportedCodes(DefaultAuthorityFactory.java:125) ~[geotools.jar:?]
	at org.geotools.referencing.CRS.getSupportedCodes(CRS.java:396) ~[geotools.jar:?]
	at org.openstreetmap.josm.plugins.ImportImagePlugin.PluginOperations.loadCRSData(PluginOperations.java:366) ~[ImportImagePlugin.jar:?]
	at org.openstreetmap.josm.plugins.ImportImagePlugin.ImportImagePlugin.<init>(ImportImagePlugin.java:88) [ImportImagePlugin.jar:?]

I have no idea what's the problem yet. Maybe linked to JEP 262.

comment:11 by Don-vip, 8 years ago

Found it, it's a change of behaviour from javabug:8068749:

Java SE has been changed so that javax.imageio.spi.ServiceRegistry no longer allows service providers of other than Image I/O service types to be loaded. This is a behavioral change. Existing application binaries that attempt to use ServiceRegistry for non-Image-I/O services will cause IllegalArgumentException to be thrown at runtime. Such applications should be migrated to use java.util.ServiceLoader instead of javax.imageio.spi.ServiceRegistry.

comment:13 by Don-vip, 8 years ago

In 9199/josm:

see #11924 - add compatibility with new Java 9 version scheme (MAJOR.MINOR.SECURITY, see JEP 223)

comment:14 by Don-vip, 8 years ago

In 9202/josm:

see #11924 - add robustness for short versions "9" and "9-ea"

comment:15 by mdk, 8 years ago

  1. Groovy does not work ==> cannot run some tests + cannot build taginfo files

As far as I could see, this problem is fixed in Groovy v2.4.6.

comment:16 by mdk, 8 years ago

  1. ResourceBundle.getBundle("sun.awt.resources.awt") results in an internal error ==> bug reported to Oracle

Also this problem seems to be fixed since 2015-11-10 (see https://bugs.openjdk.java.net/browse/JDK-8136804)

comment:17 by Don-vip, 8 years ago

Yes, The Oracle bug is fixed in latest JDK9/Jigsaw builds. However Groovy 2.4.6 is not released yet.

comment:19 by Don-vip, 8 years ago

Description: modified (diff)

comment:20 by Don-vip, 8 years ago

In 9332/josm:

see #11924 - if available, use java.runtime.version instead of java.version in status report to get build number (useful for Early Access builds)

comment:21 by Don-vip, 8 years ago

In 9333/josm:

see #12186, #11924 - update projection regression test file for Java 9

generated on Windows with:

java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+99-2015-12-23-183325.javare.4146.nc)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+99-2015-12-23-183325.javare.4146.nc, mixed mode)

comment:22 by Don-vip, 8 years ago

In 9344/josm:

see #11924 - fix one javadoc warning with JDK9, add more unit tests

comment:23 by Don-vip, 8 years ago

In 9599/josm:

see #11924 - add assertions to check if java.locale.providers enables CLDR as default because of JEP 252 in Java 9 (unit tests depending on default Java date formatting are failing)

comment:24 by Don-vip, 8 years ago

In 9605/josm:

see #11924 - use ISO date format in unit tests to avoid differences between JDK7/8 and 9

comment:25 by Don-vip, 8 years ago

In 9908/josm:

see #12186, #11924 - update projection regression test file for Java 9

generated on Windows with:

java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+107-2016-02-24-182456.javare.4520.nc)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+107-2016-02-24-182456.javare.4520.nc, mixed mode)

comment:26 by Don-vip, 8 years ago

Description: modified (diff)
Summary: Add compatibility with Java 9 / JigsawAdd compatibility with Java 9

comment:27 by Don-vip, 8 years ago

In 10048/josm:

see #11924 - add -XaddExports:java.base/sun.security.x509=ALL-UNNAMED JVM option for JDK9 tests (see http://mreinhold.org/blog/jigsaw-module-system). Requires Ant 1.9.1 or later

comment:28 by Don-vip, 8 years ago

In 10049/josm:

see #11924 - remove tab

comment:29 by Don-vip, 8 years ago

In 10052/josm:

see #11924 - reduce double precision in unit tests to avoid tiny differences with JDK9

comment:30 by Don-vip, 8 years ago

In 10056/josm:

see #11924 - use correct "if" syntax

comment:31 by Don-vip, 8 years ago

In 10057/josm:

see #11924 - add -XaddExports:java.base/sun.security.util=ALL-UNNAMED

comment:32 by Don-vip, 8 years ago

In 10058/josm:

see #11924 - Package.getPackage is deprecated in Java 9

comment:33 by Don-vip, 8 years ago

In 10059/josm:

see #11924 - write proper html code to see it it resolves unit test failing only with jdk9

comment:34 by Don-vip, 8 years ago

In 10060/josm:

see #11924 - remove deprecated code, reduce double precision in unit tests to avoid tiny differences with JDK9

comment:35 by Don-vip, 8 years ago

In 10061/josm:

see #11924 - reduce double precision in unit tests to avoid tiny differences with JDK9

comment:36 by Don-vip, 8 years ago

In 10064/josm:

see #12652, see #11924 - re-add a unit test in BugReportExceptionHandler, empty test class causes an error with Java 9

comment:37 by Don-vip, 8 years ago

In 10065/josm:

see #11924 - rework projection regression test for java 9

comment:38 by Don-vip, 8 years ago

Description: modified (diff)

comment:39 by Don-vip, 8 years ago

In 10178/josm:

see #11924 - add compatibility with JEP 272 for Java 9 on OSX

comment:40 by Don-vip, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.