Uploaded image for project: 'GeoTools'
  1. GEOT-5289

Use java.util.ServiceLoader instead of javax.imageio.spi.ServiceRegistry

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Highest
    • Resolution: Fixed
    • Affects Version/s: 14.0, 15.0, 16.0, 17.0, 18.0
    • Fix Version/s: 19-beta
    • Component/s: referencing
    • Labels:
      None
    • Environment:

      Java 9 Early Access, build 81:

      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b81)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b81, mixed mode)

      Description

      GeoTools does not work with Java 9 (build 80 and later) because a change of behavior introduced in JDK-8068749:
      https://bugs.openjdk.java.net/browse/JDK-8068749

      The future release notes of Java 9 will mention:
      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.

      The class org.geotools.factory.FactoryRegistry must be rewritten to not rely anymore on javax.imageio.spi.ServiceRegistry.

      Initializing GeoTools with Java 9 in our application, JOSM, currently leads to the following exception:

      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:?]
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                jody.garnett jody.garnett
                Reporter:
                Don-vip Vincent Privat
              • Votes:
                4 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: