Opened 9 years ago

Last modified 6 years ago

#11924 closed enhancement

Add compatibility with Java 9 — at Version 76

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 ==> fixed
  6. JEP 272 removes com.apple.eawt package ==> need to update PlatformHookOsx ==> partially fixed, nedd more tests about deprecated methods, full screen, dock image
  7. javabug:6850612 deprecates Class.newInstance ==> replace it by Class.getConstructor().newInstance() ==> fixed
  8. javabug:8154801 deprecates java.util.Observer / java.util.Observable ==> replace it by javax.swing.ChangeListener ==> fixed
  9. Ant does not work anymore ==> Bug created + workaround done in r10259
  10. javabug:8152912 deprecates XMLReaderFactory ==> fixed
  11. Groovy bug: https://issues.apache.org/jira/browse/GROOVY-7879

Unit tests:

  1. jacoco has problems with nashorn: Method jdk.dynalink.linker.LinkerServices.$jacocoInit()[Z must be InterfaceMethodref constant log ==> See #13150 for fix
    1. Could not initialize class org.openstreetmap.josm.data.validation.tests.OpeningHourTest and Could not initialize class org.openstreetmap.josm.data.validation.OsmValidator (they are shomehow destroyed by a combination of jacoco + nashorn)
  2. EqualsVerifier fails in 2 unit tests
  3. Projections seem to be off by the last digit. log

Plugins:

  1. Geotools does not work ==> https://osgeo-org.atlassian.net/browse/GEOT-5289
  2. Apache Commons does not compile ==> https://issues.apache.org/jira/browse/COLLECTIONS-593

Change History (76)

comment:2 by Don-vip, 9 years ago

Description: modified (diff)

comment:3 by Don-vip, 9 years ago

Description: modified (diff)

comment:4 by Don-vip, 9 years ago

Description: modified (diff)

comment:5 by Don-vip, 9 years ago

Description: modified (diff)

comment:6 by Don-vip, 9 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, 9 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, 9 years ago

Description: modified (diff)

comment:9 by Don-vip, 9 years ago

In 8843/josm:

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

comment:10 by Don-vip, 9 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, 9 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, 9 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, 9 years ago

In 9202/josm:

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

comment:15 by mdk, 9 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, 9 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, 9 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, 9 years ago

Description: modified (diff)

comment:20 by Don-vip, 9 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, 9 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, 9 years ago

In 9344/josm:

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

comment:23 by Don-vip, 9 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, 9 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, 9 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, 9 years ago

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

comment:27 by Don-vip, 9 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, 9 years ago

In 10049/josm:

see #11924 - remove tab

comment:29 by Don-vip, 9 years ago

In 10052/josm:

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

comment:30 by Don-vip, 9 years ago

In 10056/josm:

see #11924 - use correct "if" syntax

comment:31 by Don-vip, 9 years ago

In 10057/josm:

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

comment:32 by Don-vip, 9 years ago

In 10058/josm:

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

comment:33 by Don-vip, 9 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, 9 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, 9 years ago

In 10061/josm:

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

comment:36 by Don-vip, 9 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, 9 years ago

In 10065/josm:

see #11924 - rework projection regression test for java 9

comment:38 by Don-vip, 9 years ago

Description: modified (diff)

comment:39 by Don-vip, 9 years ago

In 10178/josm:

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

comment:40 by Don-vip, 9 years ago

Description: modified (diff)

comment:41 by Don-vip, 9 years ago

Description: modified (diff)

comment:42 by Don-vip, 9 years ago

Description: modified (diff)

comment:43 by Don-vip, 9 years ago

In 10208/josm:

see #11924 - Java 9 - JDK-6850612 deprecates Class.newInstance() ==> replace it by Class.getConstructor().newInstance()

comment:44 by Don-vip, 9 years ago

Description: modified (diff)

comment:45 by Don-vip, 9 years ago

In 10209/josm:

see #11924 - Java 9 - fixes more deprecation warnings

comment:46 by Don-vip, 9 years ago

In 10210/josm:

see #11924 - Java 9 - replace calls to deprecated classes java.util.Observable / java.util.Observer by a new class ChangeNotifier + swing's ChangeListener

comment:47 by Don-vip, 9 years ago

Description: modified (diff)

comment:48 by Don-vip, 9 years ago

Description: modified (diff)

comment:51 by Don-vip, 8 years ago

In 10259/josm:

see #11924 - JVM args ignored when same JVM is used

comment:52 by Don-vip, 8 years ago

In 10260/josm:

see #11924 - use the new -XaddExports syntax specified in JEP 261

comment:53 by Don-vip, 8 years ago

In 10262/josm:

see #11924 - add -XaddExports to access javax.xml.bind.DatatypeConverter used in JMapViewer

comment:54 by Don-vip, 8 years ago

Description: modified (diff)

comment:55 by Don-vip, 8 years ago

In 10264/josm:

see #11924 - add -addmods to access javax.xml.bind module used in JMapViewer

comment:56 by Don-vip, 8 years ago

In 10265/josm:

see #11924 - use correct syntax

comment:57 by Don-vip, 8 years ago

In 10267/josm:

see #11924 - use correct module

comment:58 by Don-vip, 8 years ago

In 10269/josm:

see #11924 - remove unneeded addmods option

comment:59 by Don-vip, 8 years ago

In 10270/josm:

see #11924 - update to Jacoco 0.7.7-20160523.090959-28 snapshot to add java 9 bytecode compatibility

comment:60 by Don-vip, 8 years ago

In 10276/josm:

see #11924 - should be the minimal and correct addmods option

comment:61 by Don-vip, 8 years ago

In 10289/josm:

see #12881, see #11924 - force generics to avoid Java 9 compilation error

comment:62 by Don-vip, 8 years ago

In 10348/josm:

see #11924 - update to FindBugs 3.1.0_preview1 to add Java 9 support

comment:63 by Don-vip, 8 years ago

In 10425/josm:

see #11924 - update to FindBugs 3.1.0_preview2

comment:64 by Don-vip, 8 years ago

Core works relatively fine with Java 9. I have started to look at plugins, as expected they don't even compile. First error lies in Apache Commons code: https://issues.apache.org/jira/browse/COLLECTIONS-593

comment:65 by Don-vip, 8 years ago

Description: modified (diff)

comment:66 by Don-vip, 8 years ago

Description: modified (diff)

comment:67 by michael2402, 8 years ago

Description: modified (diff)

I found some more problems in the unit tests.

comment:68 by michael2402, 8 years ago

Description: modified (diff)

comment:69 by Don-vip, 8 years ago

In 10546/josm:

fix #13150, see #11924 - exclude nashorn classes from jacoco coverage to avoid lot of unit test failures (patch by michael2402)

comment:70 by Don-vip, 8 years ago

In 10631/josm:

see #11924 - use jacoco-0.7.8-20160724.185238-10 snapshot to include https://github.com/jacoco/jacoco/pull/428 to fix failing unit tests since https://bugs.openjdk.java.net/browse/JDK-8145148

comment:71 by Don-vip, 8 years ago

In 10741/josm:

see #11924 - XMLReaderFactory has been deprecated in Java 9, see https://bugs.openjdk.java.net/browse/JDK-8152912

comment:72 by Don-vip, 8 years ago

Description: modified (diff)

comment:73 by Don-vip, 8 years ago

In 10746/josm:

see #11390, see #11924 - replace javax.xml.bind.DatatypeConverter (not visible by default in Java 9) by java.util.Base64 (new in Java 8)

comment:74 by Don-vip, 8 years ago

In 10821/josm:

see #11924 - update to jacoco-0.7.8-20160816.021912-12 (contains fix for https://github.com/jacoco/jacoco/pull/434 required for Java 9)

comment:75 by Don-vip, 8 years ago

Description: modified (diff)

comment:76 by Don-vip, 8 years ago

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