[tomcat] 01/02: Improve error message if a required --add-opens option is missing
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 4be7247e582ef3c3eccba10ad8ecda6a25a24b83 Author: Mark Thomas AuthorDate: Wed May 18 17:08:08 2022 +0100 Improve error message if a required --add-opens option is missing --- java/org/apache/tomcat/util/compat/Jre9Compat.java | 6 +- webapps/docs/changelog.xml | 4 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java index 1dba8c7116..581191d954 100644 --- a/java/org/apache/tomcat/util/compat/Jre9Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java @@ -253,7 +253,11 @@ class Jre9Compat extends Jre8Compat { public String getModuleName(Class type) { try { Object module = getModuleMethod.invoke(type); -return (String) getNameMethod.invoke(module); +String moduleName = (String) getNameMethod.invoke(module); +if (moduleName == null) { +moduleName = "ALL-UNNAMED"; +} +return moduleName; } catch (ReflectiveOperationException e) { return "ERROR"; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 53a28c5d23..91d7bc229b 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -111,6 +111,10 @@ Update the memory leak protection code to support stopping application created executor threads when running on Java 19 and later. (markt) + +Improve the error message if a required --add-opens option +is missing. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/02: Improve error message if a required --add-opens option is missing
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 2d1c1deeed5dbca097e3b1dee7fb928dac6df813 Author: Mark Thomas AuthorDate: Wed May 18 17:08:08 2022 +0100 Improve error message if a required --add-opens option is missing --- java/org/apache/tomcat/util/compat/Jre9Compat.java | 6 +- webapps/docs/changelog.xml | 4 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java index 87a3c385c0..86fba5eb30 100644 --- a/java/org/apache/tomcat/util/compat/Jre9Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java @@ -253,7 +253,11 @@ class Jre9Compat extends JreCompat { public String getModuleName(Class type) { try { Object module = getModuleMethod.invoke(type); -return (String) getNameMethod.invoke(module); +String moduleName = (String) getNameMethod.invoke(module); +if (moduleName == null) { +moduleName = "ALL-UNNAMED"; +} +return moduleName; } catch (ReflectiveOperationException e) { return "ERROR"; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 1781bc212f..df5dc3da15 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -111,6 +111,10 @@ Update the memory leak protection code to support stopping application created executor threads when running on Java 19 and later. (markt) + +Improve the error message if a required --add-opens option +is missing. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/02: Improve error message if a required --add-opens option is missing
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 84d78cce19c57f291949ad3c2e8b2a0649ef497c Author: Mark Thomas AuthorDate: Wed May 18 17:08:08 2022 +0100 Improve error message if a required --add-opens option is missing --- java/org/apache/tomcat/util/compat/Jre9Compat.java | 6 +- webapps/docs/changelog.xml | 4 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java index 87a3c385c0..86fba5eb30 100644 --- a/java/org/apache/tomcat/util/compat/Jre9Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java @@ -253,7 +253,11 @@ class Jre9Compat extends JreCompat { public String getModuleName(Class type) { try { Object module = getModuleMethod.invoke(type); -return (String) getNameMethod.invoke(module); +String moduleName = (String) getNameMethod.invoke(module); +if (moduleName == null) { +moduleName = "ALL-UNNAMED"; +} +return moduleName; } catch (ReflectiveOperationException e) { return "ERROR"; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index c19ee8e19b..5a519acaa2 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -111,6 +111,10 @@ Update the memory leak protection code to support stopping application created executor threads when running on Java 19 and later. (markt) + +Improve the error message if a required --add-opens option +is missing. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/02: Improve error message if a required --add-opens option is missing
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 43022dd099019a254944874b5984c20135c8b65e Author: Mark Thomas AuthorDate: Wed May 18 17:08:08 2022 +0100 Improve error message if a required --add-opens option is missing --- .../org/apache/catalina/loader/WebappClassLoaderBase.java | 15 --- webapps/docs/changelog.xml| 4 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java b/java/org/apache/catalina/loader/WebappClassLoaderBase.java index 3376713d6f..b87cc72abe 100644 --- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java +++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java @@ -2025,7 +2025,7 @@ public abstract class WebappClassLoaderBase extends URLClassLoader } } catch (InaccessibleObjectException e) { // Must be running on without the necessary command line options. -log.warn(sm.getString("webappClassLoader.addExportsThreadLocal", this.getClass().getModule().getName())); +log.warn(sm.getString("webappClassLoader.addExportsThreadLocal", getCurrentModuleName())); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.warn(sm.getString( @@ -2283,7 +2283,7 @@ public abstract class WebappClassLoaderBase extends URLClassLoader getContextName()), e); } catch (InaccessibleObjectException e) { // Must be running on without the necessary command line options. -log.warn(sm.getString("webappClassLoader.addExportsRmi", this.getClass().getModule().getName())); +log.warn(sm.getString("webappClassLoader.addExportsRmi", getCurrentModuleName())); } } @@ -2298,11 +2298,20 @@ public abstract class WebappClassLoaderBase extends URLClassLoader "webappClassLoader.clearObjectStreamClassCachesFail", getContextName()), e); } catch (InaccessibleObjectException e) { // Must be running on without the necessary command line options. -log.warn(sm.getString("webappClassLoader.addExportsJavaIo", this.getClass().getModule().getName())); +log.warn(sm.getString("webappClassLoader.addExportsJavaIo", getCurrentModuleName())); } } +private String getCurrentModuleName() { +String moduleName = this.getClass().getModule().getName(); +if (moduleName == null) { +moduleName = "ALL-UNNAMED"; +} +return moduleName; +} + + private void clearCache(Class target, String mapName) throws ReflectiveOperationException, SecurityException, ClassCastException { Field f = target.getDeclaredField(mapName); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index ca1521f30f..2b22817b79 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -111,6 +111,10 @@ Update the memory leak protection code to support stopping application created executor threads when running on Java 19 and later. (markt) + +Improve the error message if a required --add-opens option +is missing. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org