From cac623b3f46e98b41b2769aa7f9eb2105bcc5d91 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:00:39 +0200 Subject: [PATCH] Refer to the "Java Module System" instead of "Jigsaw" --- .../pages/core/beans/classpath-scanning.adoc | 4 +-- .../modules/ROOT/pages/core/resources.adoc | 4 +-- .../modules/ROOT/pages/overview.adoc | 12 ++++----- .../support/ResourceBundleMessageSource.java | 4 +-- .../org/springframework/util/ClassUtils.java | 26 ++++++++++--------- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc b/framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc index 4f98a935f8..8a0e96e6da 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc @@ -317,8 +317,8 @@ exposed based on security policies in some environments -- for example, standalo JDK 1.7.0_45 and higher (which requires 'Trusted-Library' setup in your manifests -- see {stackoverflow-questions}/19394570/java-jre-7u45-breaks-classloader-getresources). -On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected. -However, make sure that your component classes are exported in your `module-info` +On the module path (Java Module System), Spring's classpath scanning generally works as +expected. However, make sure that your component classes are exported in your `module-info` descriptors. If you expect Spring to invoke non-public members of your classes, make sure that they are 'opened' (that is, that they use an `opens` declaration instead of an `exports` declaration in your `module-info` descriptor). diff --git a/framework-docs/modules/ROOT/pages/core/resources.adoc b/framework-docs/modules/ROOT/pages/core/resources.adoc index 5fd279ab5c..3e72c1eaa8 100644 --- a/framework-docs/modules/ROOT/pages/core/resources.adoc +++ b/framework-docs/modules/ROOT/pages/core/resources.adoc @@ -905,8 +905,8 @@ policies in some environments -- for example, stand-alone applications on JDK 1. and higher (which requires 'Trusted-Library' to be set up in your manifests. See {stackoverflow-questions}/19394570/java-jre-7u45-breaks-classloader-getresources). -On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected. -Putting resources into a dedicated directory is highly recommendable here as well, +On the module path (Java Module System), Spring's classpath scanning generally works as +expected. Putting resources into a dedicated directory is highly recommendable here as well, avoiding the aforementioned portability problems with searching the jar file root level. ==== diff --git a/framework-docs/modules/ROOT/pages/overview.adoc b/framework-docs/modules/ROOT/pages/overview.adoc index 9e002aea0a..118f591087 100644 --- a/framework-docs/modules/ROOT/pages/overview.adoc +++ b/framework-docs/modules/ROOT/pages/overview.adoc @@ -37,12 +37,12 @@ support for different application architectures, including messaging, transactio persistence, and web. It also includes the Servlet-based Spring MVC web framework and, in parallel, the Spring WebFlux reactive web framework. -A note about modules: Spring's framework jars allow for deployment to JDK 9's module path -("Jigsaw"). For use in Jigsaw-enabled applications, the Spring Framework 5 jars come with -"Automatic-Module-Name" manifest entries which define stable language-level module names -("spring.core", "spring.context", etc.) independent from jar artifact names (the jars follow -the same naming pattern with "-" instead of ".", e.g. "spring-core" and "spring-context"). -Of course, Spring's framework jars keep working fine on the classpath on both JDK 8 and 9+. +A note about modules: Spring Framework's jars allow for deployment to the module path (Java +Module System). For use in module-enabled applications, the Spring Framework jars come with +`Automatic-Module-Name` manifest entries which define stable language-level module names +(`spring.core`, `spring.context`, etc.) independent from jar artifact names. The jars follow +the same naming pattern with `-` instead of `.` – for example, `spring-core` and `spring-context`. +Of course, Spring Framework's jars also work fine on the classpath. diff --git a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java index 026977b4fe..bc3393ebb6 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java @@ -243,12 +243,12 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou return ResourceBundle.getBundle(basename, locale, classLoader, control); } catch (UnsupportedOperationException ex) { - // Probably in a Jigsaw environment on JDK 9+ + // Probably in a Java Module System environment on JDK 9+ this.control = null; String encoding = getDefaultEncoding(); if (encoding != null && logger.isInfoEnabled()) { logger.info("ResourceBundleMessageSource is configured to read resources with encoding '" + - encoding + "' but ResourceBundle.Control not supported in current system environment: " + + encoding + "' but ResourceBundle.Control is not supported in current system environment: " + ex.getMessage() + " - falling back to plain ResourceBundle.getBundle retrieval with the " + "platform default encoding. Consider setting the 'defaultEncoding' property to 'null' " + "for participating in the platform default and therefore avoiding this log message."); diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 003da863f3..e191a0552d 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -332,10 +332,10 @@ public abstract class ClassUtils { * @return a class instance for the supplied name * @throws IllegalArgumentException if the class name was not resolvable * (that is, the class could not be found or the class file could not be loaded) - * @throws IllegalStateException if the corresponding class is resolvable but - * there was a readability mismatch in the inheritance hierarchy of the class - * (typically a missing dependency declaration in a Jigsaw module definition - * for a superclass or interface implemented by the class to be loaded here) + * @throws IllegalStateException if the corresponding class is resolvable but there + * was a readability mismatch in the inheritance hierarchy of the class (typically a + * missing dependency declaration in a Java Module System module definition for a + * superclass or interface implemented by the class to be loaded here) * @see #forName(String, ClassLoader) */ public static Class resolveClassName(String className, @Nullable ClassLoader classLoader) @@ -365,10 +365,10 @@ public abstract class ClassUtils { * (can be {@code null} which indicates the default class loader) * @return whether the specified class is present (including all of its * superclasses and interfaces) - * @throws IllegalStateException if the corresponding class is resolvable but - * there was a readability mismatch in the inheritance hierarchy of the class - * (typically a missing dependency declaration in a Jigsaw module definition - * for a superclass or interface implemented by the class to be checked here) + * @throws IllegalStateException if the corresponding class is resolvable but there + * was a readability mismatch in the inheritance hierarchy of the class (typically a + * missing dependency declaration in a Java Module System module definition for a + * superclass or interface implemented by the class to be checked here) */ public static boolean isPresent(String className, @Nullable ClassLoader classLoader) { try { @@ -1388,8 +1388,9 @@ public abstract class ClassUtils { /** * Determine a corresponding interface method for the given method handle, if possible. - *

This is particularly useful for arriving at a public exported type on Jigsaw - * which can be reflectively invoked without an illegal access warning. + *

This is particularly useful for arriving at a public exported type on the Java + * Module System which allows the method to be invoked via reflection without an illegal + * access warning. * @param method the method to be invoked, potentially from an implementation class * @return the corresponding interface method, or the original method if none found * @since 5.1 @@ -1402,8 +1403,9 @@ public abstract class ClassUtils { /** * Determine a corresponding interface method for the given method handle, if possible. - *

This is particularly useful for arriving at a public exported type on Jigsaw - * which can be reflectively invoked without an illegal access warning. + *

This is particularly useful for arriving at a public exported type on the Java + * Module System which allows the method to be invoked via reflection without an illegal + * access warning. * @param method the method to be invoked, potentially from an implementation class * @param targetClass the target class to check for declared interfaces * @return the corresponding interface method, or the original method if none found