This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new eb94f49184 Fix compatibility with Native 2.0.x after native code 
removal
eb94f49184 is described below

commit eb94f491843e6b313ef19fef06ca6e43ddbd4593
Author: Mark Thomas <[email protected]>
AuthorDate: Sat Sep 5 19:20:22 2026 +0100

    Fix compatibility with Native 2.0.x after native code removal
---
 java/org/apache/tomcat/jni/Library.java | 77 ++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 35 deletions(-)

diff --git a/java/org/apache/tomcat/jni/Library.java 
b/java/org/apache/tomcat/jni/Library.java
index 2944a52b1c..80873f9659 100644
--- a/java/org/apache/tomcat/jni/Library.java
+++ b/java/org/apache/tomcat/jni/Library.java
@@ -309,42 +309,49 @@ public final class Library {
             APR_PATCH_VERSION = version(0x13);
             APR_IS_DEV_VERSION = version(0x14);
 
-            APR_SIZEOF_VOIDP = size(1);
-            APR_PATH_MAX = size(2);
-            APRMAXHOSTLEN = size(3);
-            APR_MAX_IOVEC_SIZE = size(4);
-            APR_MAX_SECS_TO_LINGER = size(5);
-            APR_MMAP_THRESHOLD = size(6);
-            APR_MMAP_LIMIT = size(7);
+            /*
+             * Only try and initialise these with Tomcat Native 1.x. The 
necessary methods don't exist with Native 2.x
+             * and neither does the support for the related JNI calls.
+             */
+            if (TCN_MAJOR_VERSION == 1) {
+                APR_SIZEOF_VOIDP = size(1);
+                APR_PATH_MAX = size(2);
+                APRMAXHOSTLEN = size(3);
+                APR_MAX_IOVEC_SIZE = size(4);
+                APR_MAX_SECS_TO_LINGER = size(5);
+                APR_MMAP_THRESHOLD = size(6);
+                APR_MMAP_LIMIT = size(7);
 
-            APR_HAVE_IPV6 = has(0);
-            APR_HAS_SHARED_MEMORY = has(1);
-            APR_HAS_THREADS = has(2);
-            APR_HAS_SENDFILE = has(3);
-            APR_HAS_MMAP = has(4);
-            APR_HAS_FORK = has(5);
-            APR_HAS_RANDOM = has(6);
-            APR_HAS_OTHER_CHILD = has(7);
-            APR_HAS_DSO = has(8);
-            APR_HAS_SO_ACCEPTFILTER = has(9);
-            APR_HAS_UNICODE_FS = has(10);
-            APR_HAS_PROC_INVOKED = has(11);
-            APR_HAS_USER = has(12);
-            APR_HAS_LARGE_FILES = has(13);
-            APR_HAS_XTHREAD_FILES = has(14);
-            APR_HAS_OS_UUID = has(15);
-            APR_IS_BIGENDIAN = has(16);
-            APR_FILES_AS_SOCKETS = has(17);
-            APR_CHARSET_EBCDIC = has(18);
-            APR_TCP_NODELAY_INHERITED = has(19);
-            APR_O_NONBLOCK_INHERITED = has(20);
-            APR_POLLSET_WAKEABLE = has(21);
-            APR_HAVE_UNIX = has(22);
-            if (APR_MAJOR_VERSION < 1) {
-                throw new UnsatisfiedLinkError("Unsupported APR Version (" + 
aprVersionString() + ")");
-            }
-            if (!APR_HAS_THREADS) {
-                throw new UnsatisfiedLinkError("Missing threading support from 
APR");
+                APR_HAVE_IPV6 = has(0);
+                APR_HAS_SHARED_MEMORY = has(1);
+                APR_HAS_THREADS = has(2);
+                APR_HAS_SENDFILE = has(3);
+                APR_HAS_MMAP = has(4);
+                APR_HAS_FORK = has(5);
+                APR_HAS_RANDOM = has(6);
+                APR_HAS_OTHER_CHILD = has(7);
+                APR_HAS_DSO = has(8);
+                APR_HAS_SO_ACCEPTFILTER = has(9);
+                APR_HAS_UNICODE_FS = has(10);
+                APR_HAS_PROC_INVOKED = has(11);
+                APR_HAS_USER = has(12);
+                APR_HAS_LARGE_FILES = has(13);
+                APR_HAS_XTHREAD_FILES = has(14);
+                APR_HAS_OS_UUID = has(15);
+                APR_IS_BIGENDIAN = has(16);
+                APR_FILES_AS_SOCKETS = has(17);
+                APR_CHARSET_EBCDIC = has(18);
+                APR_TCP_NODELAY_INHERITED = has(19);
+                APR_O_NONBLOCK_INHERITED = has(20);
+                APR_POLLSET_WAKEABLE = has(21);
+                APR_HAVE_UNIX = has(22);
+
+                if (APR_MAJOR_VERSION < 1) {
+                    throw new UnsatisfiedLinkError("Unsupported APR Version (" 
+ aprVersionString() + ")");
+                }
+                if (!APR_HAS_THREADS) {
+                    throw new UnsatisfiedLinkError("Missing threading support 
from APR");
+                }
             }
         }
         return initialize();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to