JDK-8263489 : Impossible/extremely difficult to modularize Spring Boot
  • Type: Enhancement
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 15
  • Priority: P4
  • Status: Closed
  • Resolution: External
  • OS: generic
  • CPU: x86_64
  • Submitted: 2021-03-11
  • Updated: 2021-03-17
  • Resolved: 2021-03-14
Description
A DESCRIPTION OF THE PROBLEM :
I would like to be able to use jlink to create a modularized version of an application running Spring Boot.

As described in this issue, after many many attempts I found it essentially impossible:

https://github.com/wiverson/maven-jpackage-template/issues/8

Issues I ran into:

- Libraries that declared transitive dependencies in their module-info.java that wound up requiring now-removed modules (specifically, activation).
- Confusing error messages throughout
- Attempts to use jdeps to add module-info to existing libraries ran into many problems and errors, including circular references (e.g. slf4j -> logback -> slf4j)
- Extraordinarily confusing terminology in practice and errors (e.g. static in modules has nothing to do with static in Java)

I would suggest that the developer experience for jlink/jdeps be enhanced to make it possible for an end developer to be able to create a Spring Boot image trivially. The GraalVM and Spring Native projects are an effort to make small, cloud-friendly Spring Boot applications - https://github.com/spring-projects-experimental/spring-native - and jlink could be a solid competitive given additional investment in the developer experience.



Comments
If I read this I correctly, this is someone trying to create a run-time image with jlink that has an application, Spring Boot, and a list of components/libraries that have not yet been migrated to explicit modules (the authors of these libraries have not written the module-info.java yet). The jilnk tool requires all components to be explicit modules and it looks like the project, or a plugin that it is using, is making use of jdeps to generate a module-info.java. Using jdeps --generate-module-info is useful for the module author to get started but it will often require editing from the module author. It's often not a good idea to generate a module-info add it to a JAR file that you don't maintain. So I think the majority of the pain in the linked issue is because the author is taking on the big project to migrate Spring Boot and several libraries to modules. This is something that I would expect the Spring maintainers to do. In the mean-time, it would be useful to know if the submitter has investigated running jlink to create a run-time image with just the standard and JDK modules that are needed but leaving SpringBoot on the class path. That should serve as input to jpackage to create an installable package if required.
17-03-2021

Request to enhance developer experience for jlink/jdeps to make it possible for an end developer to be able to create a Spring Boot image trivially. The issue can be traced back to https://github.com/wiverson/maven-jpackage-template/issues/8#issuecomment-795855001
12-03-2021