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 6b9d6114d117e3d8e68cfbd4cda56f1696866909 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue May 17 11:11:38 2022 +0100 Improve handling of errors associated with --enable-preview --- .../el/TestImportHandlerStandardPackages.java | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/javax/el/TestImportHandlerStandardPackages.java b/test/javax/el/TestImportHandlerStandardPackages.java index 5db9da7b22..87ad0aa618 100644 --- a/test/javax/el/TestImportHandlerStandardPackages.java +++ b/test/javax/el/TestImportHandlerStandardPackages.java @@ -72,9 +72,13 @@ public class TestImportHandlerStandardPackages { try { return Class.forName("java.lang." + c); // Get the class object } catch (ClassNotFoundException e) { - throw new RuntimeException(); + throw new RuntimeException(c); + } catch (Throwable t) { + swallowEnablePreview(c, t); + return null; } }) + .filter(c -> null != c) .filter(c -> Modifier.isPublic(c.getModifiers())) // Exclude non-public classes .map(c -> c.getName().substring(10)) // Back to the class name .map(c -> c.replace('$', '.')) @@ -158,4 +162,25 @@ public class TestImportHandlerStandardPackages { Stream<String> result = (Stream<String>) clazzModuleReader.getMethod("list").invoke(mr); return result; } + + + /* + * This is a bit of a hack but there isn't a specific exception that can be + * caught. + */ + private void swallowEnablePreview(String className, Throwable t) { + while (t != null) { + if (t.getMessage() != null && t.getMessage().contains("--enable-preview")) { + return; + } + + Throwable cause = t.getCause(); + if (t == cause) { + break; + } + t = cause; + } + + throw new RuntimeException(className, t); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org