This is an automated email from the ASF dual-hosted git repository. remm 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 729962816f Cleanup 729962816f is described below commit 729962816fe2d36d351cf1223fdc45bbcdae199b Author: remm <r...@apache.org> AuthorDate: Tue Dec 5 12:10:17 2023 +0100 Cleanup I don't see why the method handle needs a separate method, maybe it is simply a leftover at this point. Try to remove it for the code that is not generated by jextract. --- .../util/openssl/openssl_h_Compatibility.java | 88 +++------- .../tomcat/util/openssl/openssl_h_Macros.java | 191 +++++++-------------- 2 files changed, 90 insertions(+), 189 deletions(-) diff --git a/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java b/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java index 829e8e059f..11692f086b 100644 --- a/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java +++ b/java/org/apache/tomcat/util/openssl/openssl_h_Compatibility.java @@ -27,67 +27,43 @@ import static java.lang.foreign.ValueLayout.*; public class openssl_h_Compatibility { // OpenSSL 1.1 FIPS_mode - public static MethodHandle FIPS_mode$MH() { + public static int FIPS_mode() { class Holder { - static final FunctionDescriptor DESC = FunctionDescriptor.of( - JAVA_INT - ); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle( - openssl_h.findOrThrow("FIPS_mode"), + static final FunctionDescriptor DESC = FunctionDescriptor.of(JAVA_INT); + static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("FIPS_mode"), DESC); } - return Holder.MH; - } - - public static int FIPS_mode() { - var mh$ = FIPS_mode$MH(); + var mh$ = Holder.MH; try { return (int) mh$.invokeExact(); } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); + throw new AssertionError("should not reach here", ex$); } } // OpenSSL 1.1 FIPS_mode_set - public static MethodHandle FIPS_mode_set$MH() { + public static int FIPS_mode_set(int r) { class Holder { - static final FunctionDescriptor DESC = FunctionDescriptor.of( - JAVA_INT, JAVA_INT - ); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle( - openssl_h.findOrThrow("FIPS_mode_set"), + static final FunctionDescriptor DESC = FunctionDescriptor.of(JAVA_INT, JAVA_INT); + static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("FIPS_mode_set"), DESC); } - return Holder.MH; - } - - public static int FIPS_mode_set(int r) { - var mh$ = FIPS_mode_set$MH(); + var mh$ = Holder.MH; try { return (int) mh$.invokeExact(r); } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); + throw new AssertionError("should not reach here", ex$); } } // OpenSSL 1.1 EVP_PKEY_base_id - public static MethodHandle EVP_PKEY_base_id$MH() { + public static int EVP_PKEY_base_id(MemorySegment pkey) { class Holder { - static final FunctionDescriptor DESC = FunctionDescriptor.of( - JAVA_INT, openssl_h.C_POINTER - ); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle( - openssl_h.findOrThrow("EVP_PKEY_base_id"), - DESC); + static final FunctionDescriptor DESC = FunctionDescriptor.of(JAVA_INT, openssl_h.C_POINTER); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("EVP_PKEY_base_id"), DESC); } - return Holder.MH; - } - - public static int EVP_PKEY_base_id(MemorySegment pkey) { - var mh$ = EVP_PKEY_base_id$MH(); + var mh$ = Holder.MH; try { return (int) mh$.invokeExact(pkey); } catch (Throwable ex$) { @@ -96,21 +72,13 @@ public class openssl_h_Compatibility { } // OpenSSL 1.1 EVP_PKEY_bits - public static MethodHandle EVP_PKEY_bits$MH() { + public static int EVP_PKEY_bits(MemorySegment pkey) { class Holder { - static final FunctionDescriptor DESC = FunctionDescriptor.of( - JAVA_INT, openssl_h.C_POINTER - ); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle( - openssl_h.findOrThrow("EVP_PKEY_bits"), + static final FunctionDescriptor DESC = FunctionDescriptor.of(JAVA_INT, openssl_h.C_POINTER); + static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("EVP_PKEY_bits"), DESC); } - return Holder.MH; - } - - public static int EVP_PKEY_bits(MemorySegment pkey) { - var mh$ = EVP_PKEY_bits$MH(); + var mh$ = Holder.MH; try { return (int) mh$.invokeExact(pkey); } catch (Throwable ex$) { @@ -119,21 +87,13 @@ public class openssl_h_Compatibility { } // OpenSSL 1.1 SSL_get_peer_certificate - public static MethodHandle SSL_get_peer_certificate$MH() { + public static MemorySegment SSL_get_peer_certificate(MemorySegment s) { class Holder { - static final FunctionDescriptor DESC = FunctionDescriptor.of( - openssl_h.C_POINTER, openssl_h.C_POINTER - ); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle( - openssl_h.findOrThrow("SSL_get_peer_certificate"), - DESC); + static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER, openssl_h.C_POINTER); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("SSL_get_peer_certificate"), DESC); } - return Holder.MH; - } - - public static MemorySegment SSL_get_peer_certificate(MemorySegment s) { - var mh$ = SSL_get_peer_certificate$MH(); + var mh$ = Holder.MH; try { return (java.lang.foreign.MemorySegment) mh$.invokeExact(s); } catch (Throwable ex$) { diff --git a/java/org/apache/tomcat/util/openssl/openssl_h_Macros.java b/java/org/apache/tomcat/util/openssl/openssl_h_Macros.java index f7a0dd69a7..627bc004be 100644 --- a/java/org/apache/tomcat/util/openssl/openssl_h_Macros.java +++ b/java/org/apache/tomcat/util/openssl/openssl_h_Macros.java @@ -255,17 +255,13 @@ public class openssl_h_Macros { * {@snippet lang = c : * void X509_free(X509* a); * } */ - public static MethodHandle X509_free$MH() { + public static void X509_free(MemorySegment a) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("X509_free"), DESC); + static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("X509_free"), + DESC); } - return Holder.MH; - } - - public static void X509_free(MemorySegment a) { - var mh$ = X509_free$MH(); + var mh$ = Holder.MH; try { mh$.invokeExact(a); } catch (Throwable ex$) { @@ -277,18 +273,14 @@ public class openssl_h_Macros { * {@snippet lang = c : * X509* d2i_X509(X509** a, unsigned char** in, long len); * } */ - public static MethodHandle d2i_X509$MH() { + public static MemorySegment d2i_X509(MemorySegment a, MemorySegment in, long len) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, ValueLayout.JAVA_LONG); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("d2i_X509"), DESC); + static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("d2i_X509"), + DESC); } - return Holder.MH; - } - - public static MemorySegment d2i_X509(MemorySegment a, MemorySegment in, long len) { - var mh$ = d2i_X509$MH(); + var mh$ = Holder.MH; try { return (MemorySegment) mh$.invokeExact(a, in, len); } catch (Throwable ex$) { @@ -300,18 +292,14 @@ public class openssl_h_Macros { * {@snippet lang = c : * int i2d_X509(const X509* a, unsigned char** out); * } */ - public static MethodHandle i2d_X509$MH() { + public static int i2d_X509(MemorySegment a, MemorySegment out) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(ValueLayout.JAVA_INT, openssl_h.C_POINTER, openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("i2d_X509"), DESC); + static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("i2d_X509"), + DESC); } - return Holder.MH; - } - - public static int i2d_X509(MemorySegment a, MemorySegment out) { - var mh$ = i2d_X509$MH(); + var mh$ = Holder.MH; try { return (int) mh$.invokeExact(a, out); } catch (Throwable ex$) { @@ -323,19 +311,15 @@ public class openssl_h_Macros { * {@snippet lang = c : * X509* PEM_read_bio_X509_AUX(BIO* out, X509** x, pem_password_cb* cb, void* u); * } */ - public static MethodHandle PEM_read_bio_X509_AUX$MH() { + public static MemorySegment PEM_read_bio_X509_AUX(MemorySegment out, MemorySegment x, MemorySegment cb, + MemorySegment u) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("PEM_read_bio_X509_AUX"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("PEM_read_bio_X509_AUX"), DESC); } - return Holder.MH; - } - - public static MemorySegment PEM_read_bio_X509_AUX(MemorySegment out, MemorySegment x, MemorySegment cb, - MemorySegment u) { - var mh$ = PEM_read_bio_X509_AUX$MH(); + var mh$ = Holder.MH; try { return (MemorySegment) mh$.invokeExact(out, x, cb, u); } catch (Throwable ex$) { @@ -348,20 +332,16 @@ public class openssl_h_Macros { * : * EC_GROUP* PEM_read_bio_ECPKParameters(BIO* out, EC_GROUP** x, pem_password_cb* cb, void* u); * } */ - public static MethodHandle PEM_read_bio_ECPKParameters$MH() { + @Deprecated + public static MemorySegment PEM_read_bio_ECPKParameters(MemorySegment out, MemorySegment x, MemorySegment cb, + MemorySegment u) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("PEM_read_bio_ECPKParameters"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("PEM_read_bio_ECPKParameters"), DESC); } - return Holder.MH; - } - - @Deprecated - public static MemorySegment PEM_read_bio_ECPKParameters(MemorySegment out, MemorySegment x, MemorySegment cb, - MemorySegment u) { - var mh$ = PEM_read_bio_ECPKParameters$MH(); + var mh$ = Holder.MH; try { return (MemorySegment) mh$.invokeExact(out, x, cb, u); } catch (Throwable ex$) { @@ -373,20 +353,17 @@ public class openssl_h_Macros { * {@snippet lang = c : * DH* PEM_read_bio_DHparams(BIO* out, DH** x, pem_password_cb* cb, void* u); * } */ - public static MethodHandle PEM_read_bio_DHparams$MH() { + @Deprecated + public static MemorySegment PEM_read_bio_DHparams(MemorySegment out, MemorySegment x, MemorySegment cb, + MemorySegment u) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER); - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("PEM_read_bio_DHparams"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("PEM_read_bio_DHparams"), DESC); } - return Holder.MH; - } - - @Deprecated - public static MemorySegment PEM_read_bio_DHparams(MemorySegment out, MemorySegment x, MemorySegment cb, - MemorySegment u) { - var mh$ = PEM_read_bio_DHparams$MH(); + var mh$ = Holder.MH; try { return (MemorySegment) mh$.invokeExact(out, x, cb, u); } catch (Throwable ex$) { @@ -398,19 +375,15 @@ public class openssl_h_Macros { * {@snippet lang = c : * EVP_PKEY* PEM_read_bio_PrivateKey(BIO* out, EVP_PKEY** x, pem_password_cb* cb, void* u); * } */ - public static MethodHandle PEM_read_bio_PrivateKey$MH() { + public static MemorySegment PEM_read_bio_PrivateKey(MemorySegment out, MemorySegment x, MemorySegment cb, + MemorySegment u) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("PEM_read_bio_PrivateKey"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("PEM_read_bio_PrivateKey"), DESC); } - return Holder.MH; - } - - public static MemorySegment PEM_read_bio_PrivateKey(MemorySegment out, MemorySegment x, MemorySegment cb, - MemorySegment u) { - var mh$ = PEM_read_bio_PrivateKey$MH(); + var mh$ = Holder.MH; try { return (MemorySegment) mh$.invokeExact(out, x, cb, u); } catch (Throwable ex$) { @@ -422,17 +395,13 @@ public class openssl_h_Macros { * {@snippet lang = c : * void PKCS12_free(PKCS12* a); * } */ - public static MethodHandle PKCS12_free$MH() { + public static void PKCS12_free(MemorySegment a) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("PKCS12_free"), DESC); + static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("PKCS12_free"), + DESC); } - return Holder.MH; - } - - public static void PKCS12_free(MemorySegment a) { - var mh$ = PKCS12_free$MH(); + var mh$ = Holder.MH; try { mh$.invokeExact(a); } catch (Throwable ex$) { @@ -445,17 +414,13 @@ public class openssl_h_Macros { * {@snippet lang = c : * void OCSP_BASICRESP_free(OCSP_BASICRESP* a); * } */ - public static MethodHandle OCSP_BASICRESP_free$MH() { + public static void OCSP_BASICRESP_free(MemorySegment a) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("OCSP_BASICRESP_free"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("OCSP_BASICRESP_free"), DESC); } - return Holder.MH; - } - - public static void OCSP_BASICRESP_free(MemorySegment a) { - var mh$ = OCSP_BASICRESP_free$MH(); + var mh$ = Holder.MH; try { mh$.invokeExact(a); } catch (Throwable ex$) { @@ -467,17 +432,13 @@ public class openssl_h_Macros { * {@snippet lang = c : * void OCSP_RESPONSE_free(OCSP_RESPONSE* a); * } */ - public static MethodHandle OCSP_RESPONSE_free$MH() { + public static void OCSP_RESPONSE_free(MemorySegment a) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("OCSP_RESPONSE_free"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("OCSP_RESPONSE_free"), DESC); } - return Holder.MH; - } - - public static void OCSP_RESPONSE_free(MemorySegment a) { - var mh$ = OCSP_RESPONSE_free$MH(); + var mh$ = Holder.MH; try { mh$.invokeExact(a); } catch (Throwable ex$) { @@ -489,18 +450,14 @@ public class openssl_h_Macros { * {@snippet lang = c : * OCSP_RESPONSE* d2i_OCSP_RESPONSE(OCSP_RESPONSE** a, unsigned char** in, long len); * } */ - public static MethodHandle d2i_OCSP_RESPONSE$MH() { + public static MemorySegment d2i_OCSP_RESPONSE(MemorySegment a, MemorySegment in, long len) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER, openssl_h.C_POINTER, openssl_h.C_POINTER, ValueLayout.JAVA_LONG); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("d2i_OCSP_RESPONSE"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("d2i_OCSP_RESPONSE"), DESC); } - return Holder.MH; - } - - public static MemorySegment d2i_OCSP_RESPONSE(MemorySegment a, MemorySegment in, long len) { - var mh$ = d2i_OCSP_RESPONSE$MH(); + var mh$ = Holder.MH; try { return (MemorySegment) mh$.invokeExact(a, in, len); } catch (Throwable ex$) { @@ -512,17 +469,13 @@ public class openssl_h_Macros { * {@snippet lang = c : * void OCSP_CERTID_free(OCSP_CERTID* a); * } */ - public static MethodHandle OCSP_CERTID_free$MH() { + public static void OCSP_CERTID_free(MemorySegment a) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("OCSP_CERTID_free"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("OCSP_CERTID_free"), DESC); } - return Holder.MH; - } - - public static void OCSP_CERTID_free(MemorySegment a) { - var mh$ = OCSP_CERTID_free$MH(); + var mh$ = Holder.MH; try { mh$.invokeExact(a); } catch (Throwable ex$) { @@ -534,17 +487,13 @@ public class openssl_h_Macros { * {@snippet lang = c : * OCSP_REQUEST* OCSP_REQUEST_new(); * } */ - public static MethodHandle OCSP_REQUEST_new$MH() { + public static MemorySegment OCSP_REQUEST_new() { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("OCSP_REQUEST_new"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("OCSP_REQUEST_new"), DESC); } - return Holder.MH; - } - - public static MemorySegment OCSP_REQUEST_new() { - var mh$ = OCSP_REQUEST_new$MH(); + var mh$ = Holder.MH; try { return (MemorySegment) mh$.invokeExact(); } catch (Throwable ex$) { @@ -556,17 +505,13 @@ public class openssl_h_Macros { * {@snippet lang = c : * void OCSP_REQUEST_free(OCSP_REQUEST* a); * } */ - public static MethodHandle OCSP_REQUEST_free$MH() { + public static void OCSP_REQUEST_free(MemorySegment a) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("OCSP_REQUEST_free"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("OCSP_REQUEST_free"), DESC); } - return Holder.MH; - } - - public static void OCSP_REQUEST_free(MemorySegment a) { - var mh$ = OCSP_REQUEST_free$MH(); + var mh$ = Holder.MH; try { mh$.invokeExact(a); } catch (Throwable ex$) { @@ -578,18 +523,14 @@ public class openssl_h_Macros { * {@snippet lang = c : * int i2d_OCSP_REQUEST(const OCSP_REQUEST* a, unsigned char** out); * } */ - public static MethodHandle i2d_OCSP_REQUEST$MH() { + public static int i2d_OCSP_REQUEST(MemorySegment a, MemorySegment out) { class Holder { static final FunctionDescriptor DESC = FunctionDescriptor.of(ValueLayout.JAVA_INT, openssl_h.C_POINTER, openssl_h.C_POINTER); - - static final MethodHandle MH = Linker.nativeLinker().downcallHandle(openssl_h.findOrThrow("i2d_OCSP_REQUEST"), DESC); + static final MethodHandle MH = Linker.nativeLinker() + .downcallHandle(openssl_h.findOrThrow("i2d_OCSP_REQUEST"), DESC); } - return Holder.MH; - } - - public static int i2d_OCSP_REQUEST(MemorySegment a, MemorySegment out) { - var mh$ = i2d_OCSP_REQUEST$MH(); + var mh$ = Holder.MH; try { return (int) mh$.invokeExact(a, out); } catch (Throwable ex$) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org