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
Remove dependency on java.desktop and other modules #26884
Comments
I guess this is more on the Framework side of things at https://github.com/spring-projects/spring-framework. The Having that said - I'd love to see this in a perfect world, but I doubt it's easy or straightforward, if at all possible. |
We are aware of our rather wide-spread dependencies across the traditional JDK-scoped libraries. Some of those are entirely optional (e.g. JNDI, JMX, RMI and JSR-223 Scripting are only used on demand and do not have to be present at runtime - at least from the core Spring Framework perspective) but the Our only way out is to reimplement the introspection algorithm ourselves and to replace |
Thanks a lot Juergen for sharing the roadmap for 6.0. This will certainly speed up modernization of Java applications with latest JDK releases, as Spring has become a de facto standard of server side development. In the meantime, is there official documentation and/or tooling to help developers produce customized jlink runtimes for 5 and older? Your comment that some modules are optional is key, but I haven't found this in the docs. |
That will help on native side as well. |
Here are some more data points. I found that with a vanilla Spring Boot webflux app
(so no XML modules). If you remove the
You have to add back If Spring 6 could shed I suppose it's an open question for the JDK why The code I used to test: https://github.com/dsyer/sample-docker-microservice UPDATE: you can run without |
Our JNDI support and therefore the |
Just This command will show package-level dependences that you can find out what classes references these modules.
(You can use
|
Thanks @mlchung that's a useful summary and a good example. The point really is that |
Just tried to run Spring without java.desktop and bumped into AnnotationBeanNameGenerator dependency on java.beans.Introspector - just for the sake of using Introspector.decapitalize() in buildDefaultBeanName() :). |
As a workaround, could you provide the "optimal" module configuration for spring with
Am I missing something, or is anything obsolete? |
It depends which features you need at runtime. E.g. see my examples above #26884 (comment) which both have fewer modules than yours. |
@dsyer this is because |
Would the docker build fail if a module is missing that my application would required? |
Pretty sure it’s a runtime error. Why don’t you try it and report back? |
I can report back missing modules result in runtime errors, which is really bad. I discovered it when using a Took me several hours to identify the spot, and fix it by including jdeps Beware that obviously building spring-boot apps with a jdeps minimal jre modules configuration might lead to unpredictable results. |
I am running spring boot 3 (spring framework 6), and still can't run it without java.desktop dependency. I thought the plan was to remove the unnecessary dependencies in spring framework 6. This has not been done yet or the plan was abandoned? |
@sid-hbm The issue is still open and hasn't been done yet. The target is for M6, but that's not a cast-iron guarantee. |
Spring requires the
java.desktop
module to be present at Java runtimes only so that it can use the classes in the java.beans package.Would be a good start for modernizing Spring apps on a post Java 9+ era of modules if Spring could at least work on slim Java runtimes produced with
jlink
.Other modules to consider adjusting the dependency are
java.naming
,java.xml
,java.sql
,jdk.*
,java.instrument
,java.management
,java.rmi
,java.scripting
.This is not about making Spring compatible with Java SE modules. This is only to allow developers to have smaller Java runtimes created with jlink.
In an ideal world, a Java runtime, created with the following
jlink
command should be sufficient to run a Spring Boot Hello World with the Web dependency:The text was updated successfully, but these errors were encountered: