You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/10/01 14:19:00 UTC

[tomcat] 01/02: Try and detect bugs like BZ 63778

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 0bcf094a2d25429f67c79ac8f32b0227a94a2016
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Oct 1 15:14:08 2019 +0100

    Try and detect bugs like BZ 63778
---
 java/org/apache/tomcat/util/compat/Jre9Compat.java | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java
index 7ad6f66..3bbdd12 100644
--- a/java/org/apache/tomcat/util/compat/Jre9Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java
@@ -77,6 +77,10 @@ class Jre9Compat extends Jre8Compat {
         Object o15 = null;
 
         try {
+            // Order is important for the error handling below.
+            // Must look up c1 first.
+            c1 = Class.forName("java.lang.reflect.InaccessibleObjectException");
+
             Class<?> moduleLayerClazz = Class.forName("java.lang.ModuleLayer");
             Class<?> configurationClazz = Class.forName("java.lang.module.Configuration");
             Class<?> resolvedModuleClazz = Class.forName("java.lang.module.ResolvedModule");
@@ -86,7 +90,6 @@ class Jre9Compat extends Jre8Compat {
             Method runtimeVersionMethod = JarFile.class.getMethod("runtimeVersion");
             Method majorMethod = versionClazz.getMethod("major");
 
-            c1 = Class.forName("java.lang.reflect.InaccessibleObjectException");
             m2 = SSLParameters.class.getMethod("setApplicationProtocols", String[].class);
             m3 = SSLEngine.class.getMethod("getApplicationProtocol");
             m4 = URLConnection.class.getMethod("setDefaultUseCaches", String.class, boolean.class);
@@ -103,8 +106,13 @@ class Jre9Compat extends Jre8Compat {
             o15 = majorMethod.invoke(o14);
 
         } catch (ClassNotFoundException e) {
-            // Must be pre-Java 9
-            log.debug(sm.getString("jre9Compat.javaPre9"), e);
+            if (c1 == null) {
+                // Must be pre-Java 9
+                log.debug(sm.getString("jre9Compat.javaPre9"), e);
+            } else {
+                // Should never happen - signature error in lookup?
+                log.error(sm.getString("jre9Compat.unexpected"), e);
+            }
         } catch (ReflectiveOperationException | IllegalArgumentException e) {
             // Should never happen
             log.error(sm.getString("jre9Compat.unexpected"), e);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org