Skip to content

java.desktop module is no longer optionalΒ #4078

@azahnen

Description

@azahnen

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

#2910/#2913 made the java.desktop module optional, which worked fine in 2.13.x.
After an upgrade to 2.15.2, starting a modular application with Jackson that does not explicitly include java.desktop will throw an error:

Exception in thread "main" java.lang.IllegalAccessError: class com.fasterxml.jackson.databind.ext.Java7SupportImpl (in module de.ii.xtraplatform.runtime) cannot access class java.beans.Transient (in module java.desktop) because module de.ii.xtraplatform.runtime does not read module java.desktop
	at de.ii.xtraplatform.runtime.intellij/com.fasterxml.jackson.databind.ext.Java7SupportImpl.<init>(Java7SupportImpl.java:22)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at de.ii.xtraplatform.runtime.intellij/com.fasterxml.jackson.databind.util.ClassUtil.createInstance(ClassUtil.java:565)
	at de.ii.xtraplatform.runtime.intellij/com.fasterxml.jackson.databind.ext.Java7Support.<clinit>(Java7Support.java:24)
	at de.ii.xtraplatform.runtime.intellij/com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.<clinit>(JacksonAnnotationIntrospector.java:68)
	at de.ii.xtraplatform.runtime.intellij/com.fasterxml.jackson.databind.ObjectMapper.<clinit>(ObjectMapper.java:375)
	at de.ii.xtraplatform.runtime.intellij/io.dropwizard.jackson.Jackson.newObjectMapper(Jackson.java:45)
        at [email protected]/de.ii.xtraplatform.base.domain.ConfigurationReader.<init>(ConfigurationReader.java:98)
	at [email protected]/de.ii.xtraplatform.base.domain.AppLauncher.init(AppLauncher.java:109)
	at [email protected]/de.ii.xtraplatform.application.Launcher.main(Launcher.java:32)

This seems to be caused by the changes introduced in #3827. IncompatibleClassChangeError, which is considered fatal and therefore rethrown, is the super class of IllegalAccessError, which is thrown when accessing a class from an absent optional module.

Version Information

2.15.2

Reproduction

Start a modular application that does not explicitly include java.desktop and creates a new ObjectMapper.

Expected behavior

The application starts without errors.

Additional context

As a workaround, Java7Support can be initialised before creating the first ObjectMapper, which allows to catch and ignore the exception:

try{
  Java7Support java7Support = Java7Support.instance();
} catch (IllegalAccessError e) {
  // ignore
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions