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 2023/01/19 10:32:39 UTC

[tomcat] branch main updated: Remove JreCompat support for Java 16 and associated Java < 16 code

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


The following commit(s) were added to refs/heads/main by this push:
     new 954cb1c3f2 Remove JreCompat support for Java 16 and associated Java < 16 code
954cb1c3f2 is described below

commit 954cb1c3f259941152ad889b18a380be2bec6756
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jan 19 10:32:28 2023 +0000

    Remove JreCompat support for Java 16 and associated Java < 16 code
---
 .../apache/tomcat/util/buf/LocalStrings.properties |   2 -
 .../tomcat/util/buf/LocalStrings_cs.properties     |  16 ----
 .../tomcat/util/buf/LocalStrings_de.properties     |  16 ----
 .../tomcat/util/buf/LocalStrings_es.properties     |   2 -
 .../tomcat/util/buf/LocalStrings_fr.properties     |   2 -
 .../tomcat/util/buf/LocalStrings_ja.properties     |   2 -
 .../tomcat/util/buf/LocalStrings_ko.properties     |   2 -
 .../tomcat/util/buf/LocalStrings_pt_BR.properties  |  16 ----
 .../tomcat/util/buf/LocalStrings_zh_CN.properties  |   2 -
 java/org/apache/tomcat/util/buf/MessageBytes.java  |  41 ---------
 .../org/apache/tomcat/util/compat/Jre16Compat.java | 100 ---------------------
 .../org/apache/tomcat/util/compat/Jre19Compat.java |   2 +-
 java/org/apache/tomcat/util/compat/JreCompat.java  |  52 +----------
 .../tomcat/util/compat/LocalStrings.properties     |   5 --
 .../tomcat/util/compat/LocalStrings_fr.properties  |   5 --
 .../tomcat/util/compat/LocalStrings_ja.properties  |   5 --
 .../tomcat/util/compat/LocalStrings_ko.properties  |  19 ----
 .../util/compat/LocalStrings_zh_CN.properties      |   5 --
 java/org/apache/tomcat/util/net/NioEndpoint.java   |  11 +--
 .../apache/tomcat/util/buf/TestMessageBytes.java   |  95 --------------------
 .../apache/tomcat/util/net/TestXxxEndpoint.java    |  10 +--
 21 files changed, 14 insertions(+), 396 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/LocalStrings.properties b/java/org/apache/tomcat/util/buf/LocalStrings.properties
index b4d5a4eccb..cd883e6f57 100644
--- a/java/org/apache/tomcat/util/buf/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/buf/LocalStrings.properties
@@ -27,8 +27,6 @@ encodedSolidusHandling.invalid=The value [{0}] is not recognised
 hexUtils.fromHex.nonHex=The input must consist only of hex digits
 hexUtils.fromHex.oddDigits=The input must consist of an even number of hex digits
 
-messageBytes.illegalCharacter=The Unicode character [{0}] at code point [{1}] cannot be encoded as it is outside the permitted range of 0 to 255
-
 uDecoder.eof=End of file (EOF)
 uDecoder.noSlash=The encoded slash character is not allowed
 uDecoder.urlDecode.conversionError=Failed to decode [{0}] using character set [{1}]
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_cs.properties b/java/org/apache/tomcat/util/buf/LocalStrings_cs.properties
deleted file mode 100644
index 1a0a1214f0..0000000000
--- a/java/org/apache/tomcat/util/buf/LocalStrings_cs.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-messageBytes.illegalCharacter=Unicode znak [{0}] na kódové značce [{1}] nemůže být zakódován, protože je mimo povolený rozsah 0 až 255.
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_de.properties b/java/org/apache/tomcat/util/buf/LocalStrings_de.properties
deleted file mode 100644
index 2220bbfc34..0000000000
--- a/java/org/apache/tomcat/util/buf/LocalStrings_de.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-messageBytes.illegalCharacter=Das Unicode Zeichen [{0}] an Code Punkt [{1}] kann nicht kodiert werden, da es außerhalb des erlaubten Bereiches von 0 bis 255 ist.
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_es.properties b/java/org/apache/tomcat/util/buf/LocalStrings_es.properties
index 8946d507c2..30376482cd 100644
--- a/java/org/apache/tomcat/util/buf/LocalStrings_es.properties
+++ b/java/org/apache/tomcat/util/buf/LocalStrings_es.properties
@@ -14,5 +14,3 @@
 # limitations under the License.
 
 b2cConverter.unknownEncoding=La codificación de carácter [{0}] no está soportada
-
-messageBytes.illegalCharacter=El carácter Unicode [{0}] en el punto del código [{1}] no puede ser codificado al estar fuera del rango permitido de 0 a 255.
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_fr.properties b/java/org/apache/tomcat/util/buf/LocalStrings_fr.properties
index 38af8c80fa..ba593d9b99 100644
--- a/java/org/apache/tomcat/util/buf/LocalStrings_fr.properties
+++ b/java/org/apache/tomcat/util/buf/LocalStrings_fr.properties
@@ -27,8 +27,6 @@ encodedSolidusHandling.invalid=La valeur [{0}] n''est pas reconnue
 hexUtils.fromHex.nonHex=L'entrée doit être uniquement des chiffres héxadécimaux
 hexUtils.fromHex.oddDigits=L'entrée doit contenir un nombre pair de chiffres héxadécimaux
 
-messageBytes.illegalCharacter=Le caractère Unicode [{0}] ayant le code point [{1}] ne peut être encodé, parce qu''il est en-dehors de l''éventail permis 0-255.
-
 uDecoder.eof=Fin de fichier (EOF)
 uDecoder.noSlash=Un caractère slash encodé n'est pas autorisé
 uDecoder.urlDecode.conversionError=Echec de décodage [{0}] en utilisant le jeu de caractères [{1}]
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_ja.properties b/java/org/apache/tomcat/util/buf/LocalStrings_ja.properties
index 1309663770..6f1870ae7c 100644
--- a/java/org/apache/tomcat/util/buf/LocalStrings_ja.properties
+++ b/java/org/apache/tomcat/util/buf/LocalStrings_ja.properties
@@ -27,8 +27,6 @@ encodedSolidusHandling.invalid=値 [{0}] は認識されません
 hexUtils.fromHex.nonHex=入力は16進数でなければなりません
 hexUtils.fromHex.oddDigits=入力は、偶数の16進数で構成する必要があります。
 
-messageBytes.illegalCharacter=コードポイント [{1}] のユニコード文字 [{0}] は有効範囲 0 から 255 の範囲外のため、エンコードできません。
-
 uDecoder.eof=予期せぬ場所で終端に達しました。
 uDecoder.noSlash="/" を符号化して含めることはできません。
 uDecoder.urlDecode.conversionError=文字セット [{1}] を使用した [{0}] のデコードに失敗しました
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_ko.properties b/java/org/apache/tomcat/util/buf/LocalStrings_ko.properties
index 1341cfda04..cc6a3a8d9d 100644
--- a/java/org/apache/tomcat/util/buf/LocalStrings_ko.properties
+++ b/java/org/apache/tomcat/util/buf/LocalStrings_ko.properties
@@ -27,8 +27,6 @@ encodedSolidusHandling.invalid=해당 값 [{0}]은(는) 인식되지 않습니
 hexUtils.fromHex.nonHex=입력은 오직 16진수 숫자로만 이루어져야 합니다.
 hexUtils.fromHex.oddDigits=입력은 반드시 짝수 개의 16진수 숫자들로 이루어져야 합니다.
 
-messageBytes.illegalCharacter=code point [{1}]에 위치한 유니코드 문자 [{0}]은(는), 0에서 255까지의 허용 범위 바깥에 있으므로 인코딩될 수 없습니다.
-
 uDecoder.eof=파일의 끝 (EOF)
 uDecoder.noSlash=인코딩된 슬래시 문자는 허용되지 않습니다.
 uDecoder.urlDecode.conversionError=문자셋 [{1}]을(를) 사용하여 [{0}]을(를) 디코드하지 못했습니다.
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_pt_BR.properties b/java/org/apache/tomcat/util/buf/LocalStrings_pt_BR.properties
deleted file mode 100644
index 0ff8d884f3..0000000000
--- a/java/org/apache/tomcat/util/buf/LocalStrings_pt_BR.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-messageBytes.illegalCharacter=Caracter Unicode [{0}] no code point [{1}] não pode ser codificado porque está fora do limite (de 0 a 255)
diff --git a/java/org/apache/tomcat/util/buf/LocalStrings_zh_CN.properties b/java/org/apache/tomcat/util/buf/LocalStrings_zh_CN.properties
index 8f937024bc..7434a083dc 100644
--- a/java/org/apache/tomcat/util/buf/LocalStrings_zh_CN.properties
+++ b/java/org/apache/tomcat/util/buf/LocalStrings_zh_CN.properties
@@ -27,8 +27,6 @@ encodedSolidusHandling.invalid=值[{0}]未识别
 hexUtils.fromHex.nonHex=输入只能由十六进制数字组成
 hexUtils.fromHex.oddDigits=输入必须由偶数个十六进制数字组成
 
-messageBytes.illegalCharacter=代码点[{1}]处的Unicode字符[{0}]无法编码,因为它超出了允许的0到255范围。
-
 uDecoder.eof=文件结尾(EOF)
 uDecoder.noSlash=不允许使用编码的斜杠字符
 uDecoder.urlDecode.conversionError=使用编码[{1}]解码[{0}]失败
diff --git a/java/org/apache/tomcat/util/buf/MessageBytes.java b/java/org/apache/tomcat/util/buf/MessageBytes.java
index be693b399f..d013231470 100644
--- a/java/org/apache/tomcat/util/buf/MessageBytes.java
+++ b/java/org/apache/tomcat/util/buf/MessageBytes.java
@@ -26,9 +26,6 @@ import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CodingErrorAction;
 import java.util.Locale;
 
-import org.apache.tomcat.util.compat.JreCompat;
-import org.apache.tomcat.util.res.StringManager;
-
 /**
  * This class is used to represent a subarray of bytes in an HTTP message.
  * It represents all request/response elements. The byte/char conversions are
@@ -45,8 +42,6 @@ public final class MessageBytes implements Cloneable, Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    private static final StringManager sm = StringManager.getManager(MessageBytes.class);
-
     // primary type ( whatever is set as original value )
     private int type = T_NULL;
 
@@ -256,17 +251,6 @@ public final class MessageBytes implements Cloneable, Serializable {
             return;
         }
 
-        if (!JreCompat.isJre16Available() && getCharset() == ByteChunk.DEFAULT_CHARSET) {
-            if (type == T_CHARS) {
-                toBytesSimple(charC.getChars(), charC.getStart(), charC.getLength());
-            } else {
-                // Must be T_STR
-                char[] chars = strValue.toCharArray();
-                toBytesSimple(chars, 0, chars.length);
-            }
-            return;
-        }
-
         ByteBuffer bb;
         CharsetEncoder encoder = getCharset().newEncoder();
         encoder.onMalformedInput(CodingErrorAction.REPORT);
@@ -292,31 +276,6 @@ public final class MessageBytes implements Cloneable, Serializable {
     }
 
 
-    /**
-     * Simple conversion of chars to bytes.
-     *
-     * @throws IllegalArgumentException if any of the characters to convert are
-     *                                  above code point 0xFF.
-     */
-    private void toBytesSimple(char[] chars, int start, int len) {
-        byteC.recycle();
-        byteC.allocate(len, byteC.getLimit());
-        byte[] bytes = byteC.getBuffer();
-
-        for (int i = 0; i < len; i++) {
-            if (chars[i + start] > 255) {
-                throw new IllegalArgumentException(sm.getString("messageBytes.illegalCharacter",
-                        Character.toString(chars[i + start]), Integer.valueOf(chars[i + start])));
-            } else {
-                bytes[i] = (byte) chars[i + start];
-            }
-        }
-
-        byteC.setEnd(len);
-        type = T_BYTES;
-    }
-
-
     /**
      * Convert to char[] and fill the CharChunk.
      *
diff --git a/java/org/apache/tomcat/util/compat/Jre16Compat.java b/java/org/apache/tomcat/util/compat/Jre16Compat.java
deleted file mode 100644
index fd05da4830..0000000000
--- a/java/org/apache/tomcat/util/compat/Jre16Compat.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.tomcat.util.compat;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.ProtocolFamily;
-import java.net.SocketAddress;
-import java.net.StandardProtocolFamily;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.res.StringManager;
-
-class Jre16Compat extends JreCompat {
-
-    private static final Log log = LogFactory.getLog(Jre16Compat.class);
-    private static final StringManager sm = StringManager.getManager(Jre16Compat.class);
-
-    private static final Class<?> unixDomainSocketAddressClazz;
-    private static final Method openServerSocketChannelFamilyMethod;
-    private static final Method unixDomainSocketAddressOfMethod;
-    private static final Method openSocketChannelFamilyMethod;
-
-    static {
-        Class<?> c1 = null;
-        Method m1 = null;
-        Method m2 = null;
-        Method m3 = null;
-        try {
-            c1 = Class.forName("java.net.UnixDomainSocketAddress");
-            m1 = ServerSocketChannel.class.getMethod("open", ProtocolFamily.class);
-            m2 = c1.getMethod("of", String.class);
-            m3 = SocketChannel.class.getMethod("open", ProtocolFamily.class);
-        } catch (ClassNotFoundException e) {
-            // Must be pre-Java 16
-            log.debug(sm.getString("jre16Compat.javaPre16"), e);
-        } catch (ReflectiveOperationException | IllegalArgumentException e) {
-            // Should never happen
-            log.error(sm.getString("jre16Compat.unexpected"), e);
-        }
-        unixDomainSocketAddressClazz = c1;
-        openServerSocketChannelFamilyMethod = m1;
-        unixDomainSocketAddressOfMethod = m2;
-        openSocketChannelFamilyMethod = m3;
-    }
-
-    static boolean isSupported() {
-        return unixDomainSocketAddressClazz != null;
-    }
-
-
-    @Override
-    public SocketAddress getUnixDomainSocketAddress(String path) {
-        try {
-            return (SocketAddress) unixDomainSocketAddressOfMethod.invoke(null, path);
-        } catch (IllegalAccessException | IllegalArgumentException
-                | InvocationTargetException e) {
-            throw new UnsupportedOperationException(e);
-        }
-    }
-
-
-    @Override
-    public ServerSocketChannel openUnixDomainServerSocketChannel() {
-        try {
-            return (ServerSocketChannel) openServerSocketChannelFamilyMethod.invoke
-                    (null, StandardProtocolFamily.valueOf("UNIX"));
-        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-            throw new UnsupportedOperationException(e);
-        }
-    }
-
-
-    @Override
-    public SocketChannel openUnixDomainSocketChannel() {
-        try {
-            return (SocketChannel) openSocketChannelFamilyMethod.invoke
-                    (null, StandardProtocolFamily.valueOf("UNIX"));
-        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-            throw new UnsupportedOperationException(e);
-        }
-    }
-}
diff --git a/java/org/apache/tomcat/util/compat/Jre19Compat.java b/java/org/apache/tomcat/util/compat/Jre19Compat.java
index fb94810b40..9fb26f0090 100644
--- a/java/org/apache/tomcat/util/compat/Jre19Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre19Compat.java
@@ -22,7 +22,7 @@ import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.res.StringManager;
 
-public class Jre19Compat extends Jre16Compat {
+public class Jre19Compat extends JreCompat {
 
     private static final Log log = LogFactory.getLog(Jre19Compat.class);
     private static final StringManager sm = StringManager.getManager(Jre19Compat.class);
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java b/java/org/apache/tomcat/util/compat/JreCompat.java
index 93c31993da..2fc13d62c6 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -17,11 +17,6 @@
 package org.apache.tomcat.util.compat;
 
 import java.lang.reflect.Field;
-import java.net.SocketAddress;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-import org.apache.tomcat.util.res.StringManager;
 
 /**
  * This is the base implementation class for JRE compatibility and provides an
@@ -32,9 +27,7 @@ public class JreCompat {
 
     private static final JreCompat instance;
     private static final boolean graalAvailable;
-    private static final boolean jre16Available;
     private static final boolean jre19Available;
-    private static final StringManager sm = StringManager.getManager(JreCompat.class);
 
     static {
         boolean result = false;
@@ -48,20 +41,14 @@ public class JreCompat {
         }
         graalAvailable = result || System.getProperty("org.graalvm.nativeimage.imagecode") != null;
 
-        // This is Tomcat 11.0.x with a minimum Java version of Java 11.
+        // This is Tomcat 11.0.x with a minimum Java version of Java 17.
         // Look for the highest supported JVM first
         if (Jre19Compat.isSupported()) {
             instance = new Jre19Compat();
             jre19Available = true;
-            jre16Available = true;
-        } else if (Jre16Compat.isSupported()) {
-            instance = new Jre16Compat();
-            jre19Available = false;
-            jre16Available = true;
         } else {
             instance = new JreCompat();
             jre19Available = false;
-            jre16Available = false;
         }
     }
 
@@ -76,47 +63,12 @@ public class JreCompat {
     }
 
 
-    public static boolean isJre16Available() {
-        return jre16Available;
-    }
-
-
     public static boolean isJre19Available() {
         return jre19Available;
     }
 
 
-    // Java 11 implementations of Java 16 methods
-
-    /**
-     * Return Unix domain socket address for given path.
-     * @param path The path
-     * @return the socket address
-     */
-    public SocketAddress getUnixDomainSocketAddress(String path) {
-        return null;
-    }
-
-
-    /**
-     * Create server socket channel using the Unix domain socket ProtocolFamily.
-     * @return the server socket channel
-     */
-    public ServerSocketChannel openUnixDomainServerSocketChannel() {
-        throw new UnsupportedOperationException(sm.getString("jreCompat.noUnixDomainSocket"));
-    }
-
-
-    /**
-     * Create socket channel using the Unix domain socket ProtocolFamily.
-     * @return the socket channel
-     */
-    public SocketChannel openUnixDomainSocketChannel() {
-        throw new UnsupportedOperationException(sm.getString("jreCompat.noUnixDomainSocket"));
-    }
-
-
-    // Java 11 implementations of Java 19 methods
+    // Java 17 implementations of Java 19 methods
 
     /**
      * Obtains the executor, if any, used to create the provided thread.
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings.properties b/java/org/apache/tomcat/util/compat/LocalStrings.properties
index 17f9ce4304..a3d30954e7 100644
--- a/java/org/apache/tomcat/util/compat/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/compat/LocalStrings.properties
@@ -13,9 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-jre16Compat.javaPre16=Class not found so assuming code is running on a pre-Java 16 JVM
-jre16Compat.unexpected=Failed to create references to Java 16 classes and methods
-
 jre19Compat.javaPre19=Class not found so assuming code is running on a pre-Java 19 JVM
-
-jreCompat.noUnixDomainSocket=Java Runtime does not support Unix domain sockets. You must use Java 16 to use this feature.
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings_fr.properties b/java/org/apache/tomcat/util/compat/LocalStrings_fr.properties
index e623c0f7a0..ee07dd61d3 100644
--- a/java/org/apache/tomcat/util/compat/LocalStrings_fr.properties
+++ b/java/org/apache/tomcat/util/compat/LocalStrings_fr.properties
@@ -13,9 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-jre16Compat.javaPre16=Le code est considéré être exécuté sur une JVM antérieure à Java 16 car la classe n'a pas été trouvée
-jre16Compat.unexpected=Impossible de créer les références vers les classes et méthodes de Java 16
-
 jre19Compat.javaPre19=Classe non trouvée donc le code est exécutée sur une JVM antérieure à Java 19
-
-jreCompat.noUnixDomainSocket=L'environnement Java ne supporte pas les sockets de domaine de Unix, cette fonctionnalité demande Java 16
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings_ja.properties b/java/org/apache/tomcat/util/compat/LocalStrings_ja.properties
index 77b94c3136..2246b19e0e 100644
--- a/java/org/apache/tomcat/util/compat/LocalStrings_ja.properties
+++ b/java/org/apache/tomcat/util/compat/LocalStrings_ja.properties
@@ -13,9 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-jre16Compat.javaPre16=クラスが見つからないため、コードがJava 16未満のJVMで実行されていると仮定します
-jre16Compat.unexpected=Java 16クラスおよびメソッドへの参照の作成に失敗しました
-
 jre19Compat.javaPre19=クラスが見つからないため、Java 19より前のJVMでコードが実行されていると仮定します
-
-jreCompat.noUnixDomainSocket=Java実行環境はUnixドメインソケットに対応していません。 この機能を使用するには、Java 16を使用する必要があります。
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings_ko.properties b/java/org/apache/tomcat/util/compat/LocalStrings_ko.properties
deleted file mode 100644
index 8f15320c37..0000000000
--- a/java/org/apache/tomcat/util/compat/LocalStrings_ko.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-jre16Compat.javaPre16=클래스가 발견되지 않습니다. 자바 16 이전의 JVM에서 실행 중인 것으로 보입니다.
-jre16Compat.unexpected=자바 16 클래스들과 메소드들을 참조할 수 없습니다.
-
-jreCompat.noUnixDomainSocket=자바 런타임이 Unix 도메인 소켓을 지원하지 않습니다. 이 기능을 사용하려면 자바 16을 사용해야 합니다.
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings_zh_CN.properties b/java/org/apache/tomcat/util/compat/LocalStrings_zh_CN.properties
index c7be88b3ae..571a2bffd2 100644
--- a/java/org/apache/tomcat/util/compat/LocalStrings_zh_CN.properties
+++ b/java/org/apache/tomcat/util/compat/LocalStrings_zh_CN.properties
@@ -13,9 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-jre16Compat.javaPre16=类未找到,因此假设代码在Java16之前的JVM上运行
-jre16Compat.unexpected=无法创建对Java16中类和方法的引用
-
 jre19Compat.javaPre19=该类未找到,因此推测当前代码运行在Java 19版本之前的虚拟机上
-
-jreCompat.noUnixDomainSocket=Java运行环境不支持Unix域名套接字。你必须使用Java16来运行该特性。
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 7bad146bcf..8c6a3ae566 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -24,6 +24,8 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.net.SocketTimeoutException;
+import java.net.StandardProtocolFamily;
+import java.net.UnixDomainSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.CancelledKeyException;
 import java.nio.channels.Channel;
@@ -57,7 +59,6 @@ import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.collections.SynchronizedQueue;
 import org.apache.tomcat.util.collections.SynchronizedStack;
-import org.apache.tomcat.util.compat.JreCompat;
 import org.apache.tomcat.util.compat.JrePlatform;
 import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.net.Acceptor.AcceptorState;
@@ -219,8 +220,8 @@ public class NioEndpoint extends AbstractNetworkChannelEndpoint<NioChannel,Socke
                 throw new IllegalArgumentException(sm.getString("endpoint.init.bind.inherited"));
             }
         } else if (getUnixDomainSocketPath() != null) {
-            SocketAddress sa = JreCompat.getInstance().getUnixDomainSocketAddress(getUnixDomainSocketPath());
-            serverSock = JreCompat.getInstance().openUnixDomainServerSocketChannel();
+            SocketAddress sa = UnixDomainSocketAddress.of(getUnixDomainSocketPath());
+            serverSock = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
             serverSock.bind(sa, getAcceptCount());
             if (getUnixDomainSocketPathPermissions() != null) {
                 Path path = Paths.get(getUnixDomainSocketPath());
@@ -393,8 +394,8 @@ public class NioEndpoint extends AbstractNetworkChannelEndpoint<NioChannel,Socke
                 return;
             }
             try {
-                SocketAddress sa = JreCompat.getInstance().getUnixDomainSocketAddress(getUnixDomainSocketPath());
-                try (SocketChannel socket = JreCompat.getInstance().openUnixDomainSocketChannel()) {
+                SocketAddress sa = UnixDomainSocketAddress.of(getUnixDomainSocketPath());
+                try (SocketChannel socket = SocketChannel.open(StandardProtocolFamily.UNIX)) {
                     // With a UDS, expect no delay connecting and no defer accept
                     socket.connect(sa);
                 }
diff --git a/test/org/apache/tomcat/util/buf/TestMessageBytes.java b/test/org/apache/tomcat/util/buf/TestMessageBytes.java
index 4abc1b6374..f9af7fd19d 100644
--- a/test/org/apache/tomcat/util/buf/TestMessageBytes.java
+++ b/test/org/apache/tomcat/util/buf/TestMessageBytes.java
@@ -16,40 +16,10 @@
  */
 package org.apache.tomcat.util.buf;
 
-import java.nio.CharBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.StandardCharsets;
-
-import org.junit.Assert;
-import org.junit.Assume;
 import org.junit.Test;
 
-import org.apache.tomcat.util.compat.JreCompat;
-
 public class TestMessageBytes {
 
-    private static final String CONVERSION_STRING =
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +
-            "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
-
-    private static final int CONVERSION_LOOPS = 1000000;
-
     @Test
     public void testToStringFromNull() {
         MessageBytes mb = MessageBytes.newInstance();
@@ -96,69 +66,4 @@ public class TestMessageBytes {
         mb.recycle();
         mb.toChars();
     }
-
-
-    /*
-     * Checks the the optimized code is faster than the non-optimized code.
-     */
-    @Test
-    public void testConversionPerformance() {
-
-        // ISO_8859_1 conversion appears to be optimised in Java 16 onwards
-        Assume.assumeFalse(JreCompat.isJre16Available());
-
-        long optimized = -1;
-        long nonOptimized = -1;
-
-        /*
-         * One loop is likely to be enough as the optimised code is
-         * significantly (3x to 4x on markt's desktop) faster than the
-         * non-optimised code. Loop three times allows once to warn up the JVM
-         * once to run the test and once more in case of unexpected CI /GC
-         * slowness. The test will exit early if possible.
-         *
-         * MessageBytes only optimises conversion for ISO_8859_1
-         */
-        for (int i = 0; i < 3; i++) {
-            optimized = doTestOptimisedConversionPerformance();
-            nonOptimized = doTestConversionPerformance();
-
-            System.out.println(optimized + " " + nonOptimized);
-            if (optimized * 2 < nonOptimized) {
-                break;
-            }
-        }
-
-        Assert.assertTrue("Non-optimised code was faster (" + nonOptimized + "ns) compared to optimized (" +
-                optimized + "ns)", optimized < nonOptimized);
-    }
-
-
-    private long doTestOptimisedConversionPerformance() {
-        MessageBytes mb = MessageBytes.newInstance();
-
-        long start = System.nanoTime();
-        for (int i = 0; i < CONVERSION_LOOPS; i++) {
-            mb.recycle();
-            mb.setCharset(StandardCharsets.ISO_8859_1);
-            mb.setString(CONVERSION_STRING);
-            mb.toBytes();
-        }
-        return System.nanoTime() - start;
-    }
-
-
-    private long doTestConversionPerformance() {
-        long start = System.nanoTime();
-        for (int i = 0; i < CONVERSION_LOOPS; i++) {
-            CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder().onMalformedInput(
-                    CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
-            try {
-                encoder.encode(CharBuffer.wrap(CONVERSION_STRING));
-            } catch (CharacterCodingException cce) {
-                Assert.fail();
-            }
-        }
-        return System.nanoTime() - start;
-    }
 }
diff --git a/test/org/apache/tomcat/util/net/TestXxxEndpoint.java b/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
index ea97bf8300..2fd3ab50f1 100644
--- a/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
+++ b/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
@@ -20,6 +20,8 @@ import java.io.File;
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.SocketAddress;
+import java.net.StandardProtocolFamily;
+import java.net.UnixDomainSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
 
@@ -30,7 +32,6 @@ import org.junit.Test;
 import org.apache.catalina.connector.Connector;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.tomcat.util.compat.JreCompat;
 
 /**
  * Test case for the Endpoint implementations. The testing framework will ensure
@@ -90,8 +91,7 @@ public class TestXxxEndpoint extends TomcatBaseTest {
         Tomcat tomcat = getTomcatInstance();
         Connector c = tomcat.getConnector();
         Assume.assumeTrue("NIO Unix domain sockets have to be supported for this test",
-                c.getProtocolHandlerClassName().contains("NioProtocol")
-                && JreCompat.isJre16Available());
+                c.getProtocolHandlerClassName().contains("NioProtocol"));
 
         File tempPath = File.createTempFile("uds-tomcat-test-", ".sock");
         String unixDomainSocketPath = tempPath.getAbsolutePath();
@@ -101,9 +101,9 @@ public class TestXxxEndpoint extends TomcatBaseTest {
         tomcat.start();
 
         // Connect to the domain socket as a client
-        SocketAddress sa = JreCompat.getInstance().getUnixDomainSocketAddress(unixDomainSocketPath);
+        SocketAddress sa =  UnixDomainSocketAddress.of(unixDomainSocketPath);
         ByteBuffer response = ByteBuffer.allocate(1024);
-        try (SocketChannel socket = JreCompat.getInstance().openUnixDomainSocketChannel()) {
+        try (SocketChannel socket = SocketChannel.open(StandardProtocolFamily.UNIX)) {
             socket.connect(sa);
             socket.write(ByteBuffer.wrap("OPTIONS * HTTP/1.0\r\n\r\n".getBytes()));
             socket.read(response);


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