Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalAccessError: sun.awt.image.SurfaceManager$ImageAccessor (in module java.desktop / Java 16) #399

Closed
don-vip opened this issue Feb 22, 2021 · 2 comments
Labels

Comments

@don-vip
Copy link
Contributor

don-vip commented Feb 22, 2021

Describe the bug
Test work with Java 8-15, no longer with Java 16, throws an IllegalAccessError.

To Reproduce
Run test below with Java 16.

Code that triggers the behavior

import java.util.Objects;
import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;

class ImageEntryTest {

    @Test
    void testEqualsContract() {
        EqualsVerifier.forClass(ImageEntry.class).usingGetClass()
            .suppress(Warning.NONFINAL_FIELDS)
            .verify();
    }

    public final class ImageEntry {

        private java.awt.Image thumbnail;

        @Override
        public int hashCode() {
            return Objects.hash(thumbnail);
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null || getClass() != obj.getClass())
                return false;
            ImageEntry other = (ImageEntry) obj;
            return Objects.equals(thumbnail, other.thumbnail);
        }
    }
}

Error message

java.lang.AssertionError: EqualsVerifier found a problem in class org.openstreetmap.josm.gui.layer.geoimage.ImageEntry.
-> Error invoking java.lang.invoke.MethodHandles$Lookup#defineClass

For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.verify(SingleTypeEqualsVerifierApi.java:294)
	at org.openstreetmap.josm.gui.layer.geoimage.ImageEntryTest.testEqualsContract(ImageEntryTest.java:39)
    ...
Caused by: java.lang.IllegalAccessError: superclass access check failed: class nl.jqno.equalsverifier.internal.reflection.ImageAccessor$$DynamicSubclass$752001567 (in unnamed module @0x31a5c39e) cannot access class sun.awt.image.SurfaceManager$ImageAccessor (in module java.desktop) because module java.desktop does not export sun.awt.image to unnamed module @0x31a5c39e
	at java.base/java.lang.ClassLoader.defineClass0(Native Method)
	at java.base/java.lang.System$2.defineClass(System.java:2193)
	at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2446)
	at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2423)
	at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:1850)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.loading.ClassInjector$UsingLookup$Dispatcher$ForJava9CapableVm.defineClass(ClassInjector.java:1773)
	... 108 more

Expected behavior
No error.

Version
3.5.4

jqno added a commit that referenced this issue Feb 23, 2021
@jqno
Copy link
Owner

jqno commented Feb 23, 2021

I noticed a similar error in Java 11. I've added a prefab value for java.awt.Image, that should probably fix it. I'll try to make a release soon.

@jqno jqno added the accepted label Feb 23, 2021
@jqno
Copy link
Owner

jqno commented Feb 24, 2021

I've just released version 3.5.5!

@jqno jqno closed this as completed Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants