Java 17 - IllegalAccessError with JAI RasterAccessor

Description

When upgrading a project to Java 17 i got following error while using the ImageAssert class from dependency org.geotools:gt-coverage:26.1. Ik tried upgrading to the latest version 26.2 but the same error occurred.

Error:

java.lang.IllegalAccessError: class javax.media.jai.RasterAccessor (in unnamed module @0x4ae3c1cd) cannot access class sun.awt.image.BytePackedRaster (in module java.desktop) because module java.desktop does not export sun.awt.image to unnamed module @0x4ae3c1cd at javax.media.jai.RasterAccessor.<init>(RasterAccessor.java:802) at com.sun.media.jai.opimage.CopyOpImage.computeRect(CopyOpImage.java:68) at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:969) at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904) at javax.media.jai.OpImage.getTile(OpImage.java:1129) at javax.media.jai.RenderedOp.getTile(RenderedOp.java:2257) at com.sun.media.jai.iterator.RandomIterFallback.makeCurrent(RandomIterFallback.java:108) at com.sun.media.jai.iterator.RandomIterFallback.getPixel(RandomIterFallback.java:141) at org.geotools.image.test.ImageComparator.computeDifference(ImageComparator.java:265) at org.geotools.image.test.ImageComparator.<init>(ImageComparator.java:227) at org.geotools.image.test.ImageAssert.assertEquals(ImageAssert.java:65)

It seems like the underlying sun.awt.image.BytePackedRaster is no more accessible (only to specific internal Java packages).

When inspecting the module-info.java file from the java.desktop module i found:

// Some comments here // qualified exports may be inserted at build time // see make/GensrcModuleInfo.gmk exports sun.awt to jdk.accessibility, jdk.unsupported.desktop;

are there others experiencing the same issue?

Environment

None

Activity

stefan borghys 
February 8, 2022 at 4:47 PM

@Andrea Aime thanks for the update. For the moment i found a replacement for the above functionality. It also didn’t impact the application to much. Thanks for looking into this issue.

Andrea Aime 
February 8, 2022 at 10:47 AM

Java 17 is currently supported in an experimental way. The GeoTools build adds all the necessary “opens” to make the build work.

The one you’re stumbling into is due to JAI, it will take a large, currently un-funded effort to switch from JAI to ImageN in order to get rid of it.

Details

Assignee

Reporter

Components

Affects versions

Priority

Created February 7, 2022 at 10:20 AM
Updated March 12, 2022 at 6:11 PM