Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8068749

Restrict javax.imageio.spi.ServiceRegistry to ImageIO types

    Details

      Backports

        Description


        The lookupProviders methods in javax.imageio.spi.ServiceRegistry are wrappers around ServiceLoader.load. This is problematic for modules because the ServiceLoader.load method look at their caller to check if the caller is in a module and if so, that the caller's module has the right "uses" in its module declaration. For now, then calling lookupProviders will cause ServiceLoader to check that ServiceRegistry's module (java.desktop) declares the "uses" and this will probably fail because the java.desktop module is unlikely to have it.

        One approach to addressing this is to change these methods to be @CallerSensitive, pick-up the caller, and create a ServiceLoader in a manner that makes it look like the caller of ServiceRegistry.lookupProviders is the caller.

        The alternative is to do nothing and just deprecate these methods. This option may not be too bad if we can establish that these methods are rarely, if ever, used outside of the JDK.

          Activity

          Hide
          alanb Alan Bateman added a comment - - edited
          I've removed "uses javax.imageio.spi.ImageReaderWriterSpi" from the module-info.java. I suspect my mistake when we initially added the uses for this API.

          Throwing IAE for non image I/O service types should be good.
          Show
          alanb Alan Bateman added a comment - - edited I've removed "uses javax.imageio.spi.ImageReaderWriterSpi" from the module-info.java. I suspect my mistake when we initially added the uses for this API. Throwing IAE for non image I/O service types should be good.
          Show
          smarks Stuart Marks added a comment - Review posted: http://mail.openjdk.java.net/pipermail/2d-dev/2015-July/005589.html Webrev: http://cr.openjdk.java.net/~smarks/reviews/8068749/webrev.0/
          Hide
          smarks Stuart Marks added a comment -
          Text for release notes:

          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.
          Show
          smarks Stuart Marks added a comment - Text for release notes: 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.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/baa9838343d8
          User: smarks
          Date: 2015-08-13 21:03:38 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/baa9838343d8 User: smarks Date: 2015-08-13 21:03:38 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/baa9838343d8
          User: lana
          Date: 2015-09-01 20:27:06 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/baa9838343d8 User: lana Date: 2015-09-01 20:27:06 +0000

            People

            • Assignee:
              smarks Stuart Marks
              Reporter:
              alanb Alan Bateman
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: