git: 55925767376b - main - java/openjdk8: fix build with clang 19

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 07 Aug 2024 16:47:09 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/ports/commit/?id=55925767376bb8d4ffe1a0304555988464c25599

commit 55925767376bb8d4ffe1a0304555988464c25599
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-08-01 10:34:13 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-08-07 16:44:09 +0000

    java/openjdk8: fix build with clang 19
    
    Clang 19 is now more strict about undefined integral expressions used as
    constants in enum, which results in errors compiling java/openjdk8,
    similar to:
    
        /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u422-b05.1/hotspot/src/share/vm/oops/cpCache.hpp:195:34: error: expression is not an integral constant expression
          195 |     option_bits_mask           = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask))
              |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u422-b05.1/hotspot/src/share/vm/oops/cpCache.hpp:195:42: note: left shift of negative value -1
          195 |     option_bits_mask           = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask))
              |                                          ^
    
        /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u422-b05.1/hotspot/src/share/vm/code/dependencies.hpp:173:27: error: expression is not an integral constant expression
          173 |     all_types           = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
              |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u422-b05.1/hotspot/src/share/vm/code/dependencies.hpp:173:59: note: left shift of negative value -1
          173 |     all_types           = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
              |                                                           ^
    
        In file included from /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u422-b05.1/jdk/src/share/native/com/sun/java/util/jar/pack/bands.cpp:43:
        /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u422-b05.1/jdk/src/share/native/com/sun/java/util/jar/pack/constants.h:226:33: error: expression is not an integral constant expression
          226 |     AO_UNUSED_MBZ             = (-1)<<13, // options bits reserved for future use.
              |                                 ^~~~~~~~
        /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u422-b05.1/jdk/src/share/native/com/sun/java/util/jar/pack/constants.h:226:37: note: left shift of negative value -1
          226 |     AO_UNUSED_MBZ             = (-1)<<13, // options bits reserved for future use.
              |                                     ^
    
    In openjdk11 and later, the (-1) constants have been replaced by the
    unsigned variant (~0u), which fixes these errors.
    
    PR:             280559
    Approved by:    glewis (maintainer)
    MFH:            2024Q3
---
 .../files/patch-hotspot_src_share_vm_code_dependencies.hpp    | 11 +++++++++++
 .../files/patch-hotspot_src_share_vm_oops_cpCache.hpp         | 11 +++++++++++
 ...dk_src_share_native_com_sun_java_util_jar_pack_constants.h | 11 +++++++++++
 3 files changed, 33 insertions(+)

diff --git a/java/openjdk8/files/patch-hotspot_src_share_vm_code_dependencies.hpp b/java/openjdk8/files/patch-hotspot_src_share_vm_code_dependencies.hpp
new file mode 100644
index 000000000000..8b0a6e6f8342
--- /dev/null
+++ b/java/openjdk8/files/patch-hotspot_src_share_vm_code_dependencies.hpp
@@ -0,0 +1,11 @@
+--- hotspot/src/share/vm/code/dependencies.hpp.orig	2024-07-27 18:28:39 UTC
++++ hotspot/src/share/vm/code/dependencies.hpp
+@@ -170,7 +170,7 @@ class Dependencies: public ResourceObj {
+     LG2_TYPE_LIMIT = 4,  // assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT))
+ 
+     // handy categorizations of dependency types:
+-    all_types           = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
++    all_types           = ((1 << TYPE_LIMIT) - 1) & ((~0u) << FIRST_TYPE),
+ 
+     non_klass_types     = (1 << call_site_target_value),
+     klass_types         = all_types & ~non_klass_types,
diff --git a/java/openjdk8/files/patch-hotspot_src_share_vm_oops_cpCache.hpp b/java/openjdk8/files/patch-hotspot_src_share_vm_oops_cpCache.hpp
new file mode 100644
index 000000000000..1799f8cec164
--- /dev/null
+++ b/java/openjdk8/files/patch-hotspot_src_share_vm_oops_cpCache.hpp
@@ -0,0 +1,11 @@
+--- hotspot/src/share/vm/oops/cpCache.hpp.orig	2024-07-27 18:28:39 UTC
++++ hotspot/src/share/vm/oops/cpCache.hpp
+@@ -192,7 +192,7 @@ class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC {
+     field_index_mask           = right_n_bits(field_index_bits),
+     parameter_size_bits        = 8,  // subset of field_index_mask, range is 0..255
+     parameter_size_mask        = right_n_bits(parameter_size_bits),
+-    option_bits_mask           = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask))
++    option_bits_mask           = ~(((~0u) << tos_state_shift) | (field_index_mask | parameter_size_mask))
+   };
+ 
+   // specific bit definitions for the indices field:
diff --git a/java/openjdk8/files/patch-jdk_src_share_native_com_sun_java_util_jar_pack_constants.h b/java/openjdk8/files/patch-jdk_src_share_native_com_sun_java_util_jar_pack_constants.h
new file mode 100644
index 000000000000..33670869a90d
--- /dev/null
+++ b/java/openjdk8/files/patch-jdk_src_share_native_com_sun_java_util_jar_pack_constants.h
@@ -0,0 +1,11 @@
+--- jdk/src/share/native/com/sun/java/util/jar/pack/constants.h.orig	2024-07-27 18:28:39 UTC
++++ jdk/src/share/native/com/sun/java/util/jar/pack/constants.h
+@@ -223,7 +223,7 @@ enum {
+     AO_HAVE_FIELD_FLAGS_HI    = 1<<10,
+     AO_HAVE_METHOD_FLAGS_HI   = 1<<11,
+     AO_HAVE_CODE_FLAGS_HI     = 1<<12,
+-    AO_UNUSED_MBZ             = (-1)<<13, // options bits reserved for future use.
++    AO_UNUSED_MBZ             = (~0u)<<13, // options bits reserved for future use.
+ 
+ #define ARCHIVE_BIT_DO(F) \
+          F(AO_HAVE_SPECIAL_FORMATS) \