diff --git a/make/autoconf/build-performance.m4 b/make/autoconf/build-performance.m4
index 09e46bfad0d..3f0ab1bf57c 100644
--- a/make/autoconf/build-performance.m4
+++ b/make/autoconf/build-performance.m4
@@ -26,7 +26,6 @@
 AC_DEFUN([BPERF_CHECK_CORES],
 [
   AC_MSG_CHECKING([for number of cores])
-  NUM_CORES=0
 
   if test -f /proc/cpuinfo; then
     # Looks like a Linux (or cygwin) system
@@ -38,10 +37,7 @@ AC_DEFUN([BPERF_CHECK_CORES],
     # Looks like a MacOSX system
     NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu`
   elif test "x$OPENJDK_BUILD_OS" = xaix ; then
-    NUM_LCPU=`lparstat -m 2> /dev/null | $GREP -o "lcpu=[[0-9]]*" | $CUT -d "=" -f 2`
-    if test -n "$NUM_LCPU"; then
-      NUM_CORES=$NUM_LCPU
-    fi
+    NUM_CORES=`lparstat -m 2> /dev/null | $GREP -o "lcpu=[[0-9]]*" | $CUT -d "=" -f 2`
   elif test -n "$NUMBER_OF_PROCESSORS"; then
     # On windows, look in the env
     NUM_CORES=$NUMBER_OF_PROCESSORS
diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js
index 2b21b7fbdfa..350222bf756 100644
--- a/make/conf/jib-profiles.js
+++ b/make/conf/jib-profiles.js
@@ -813,24 +813,6 @@ var getJibProfilesProfiles = function (input, common, data) {
         }
     });
 
-    // Define the reference implementation profiles. These are basically the same
-    // as the open profiles, but upload artifacts to a different location.
-    common.main_profile_names.forEach(function (name) {
-        var riName = name + "-ri";
-        var riDebugName = riName + common.debug_suffix;
-        var openName = name + common.open_suffix;
-        var openDebugName = openName + common.debug_suffix;
-        profiles[riName] = clone(profiles[openName]);
-        profiles[riDebugName] = clone(profiles[openDebugName]);
-        // Rewrite all remote dirs to "bundles/openjdk/BCL/..."
-        for (artifactName in profiles[riName].artifacts) {
-            var artifact = profiles[riName].artifacts[artifactName];
-            artifact.remote = replaceAll(
-                "\/GPL\/", "/BCL/",
-                (artifact.remote != null ? artifact.remote : artifact.local));
-        }
-    });
-
     // For open profiles, the non-debug jdk bundles, need an "open" prefix on the
     // remote bundle names, forming the word "openjdk". See JDK-8188789.
     common.main_profile_names.forEach(function (name) {
diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad
index 79a7b016626..9d8339a9f27 100644
--- a/src/hotspot/cpu/aarch64/aarch64.ad
+++ b/src/hotspot/cpu/aarch64/aarch64.ad
@@ -2301,6 +2301,12 @@ const bool Matcher::match_rule_supported(int opcode) {
         ret_value = false;
       }
       break;
+    case Op_ExpandBits:
+    case Op_CompressBits:
+      if (!(UseSVE > 1 && VM_Version::supports_svebitperm())) {
+        ret_value = false;
+      }
+      break;
   }
 
   return ret_value; // Per default match rules are supported.
@@ -17350,6 +17356,157 @@ instruct encode_ascii_array(iRegP_R2 src, iRegP_R1 dst, iRegI_R3 len,
   ins_pipe(pipe_class_memory);
 %}
 
+//----------------------------- CompressBits/ExpandBits ------------------------
+
+instruct compressBitsI_reg(iRegINoSp dst, iRegIorL2I src, iRegIorL2I mask,
+                           vRegF tdst, vRegF tsrc, vRegF tmask) %{
+  match(Set dst (CompressBits src mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "mov    $tsrc, $src\n\t"
+            "mov    $tmask, $mask\n\t"
+            "bext   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    __ mov($tsrc$$FloatRegister, __ S, 0, $src$$Register);
+    __ mov($tmask$$FloatRegister, __ S, 0, $mask$$Register);
+    __ sve_bext($tdst$$FloatRegister, __ S, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ S, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
+instruct compressBitsI_memcon(iRegINoSp dst, memory4 mem, immI mask,
+                           vRegF tdst, vRegF tsrc, vRegF tmask) %{
+  match(Set dst (CompressBits (LoadI mem) mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "ldrs   $tsrc, $mem\n\t"
+            "ldrs   $tmask, $mask\n\t"
+            "bext   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    loadStore(C2_MacroAssembler(&cbuf), &MacroAssembler::ldrs, $tsrc$$FloatRegister, $mem->opcode(),
+              as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
+    __ ldrs($tmask$$FloatRegister, $constantaddress($mask));
+    __ sve_bext($tdst$$FloatRegister, __ S, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ S, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
+instruct compressBitsL_reg(iRegLNoSp dst, iRegL src, iRegL mask,
+                           vRegD tdst, vRegD tsrc, vRegD tmask) %{
+  match(Set dst (CompressBits src mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "mov    $tsrc, $src\n\t"
+            "mov    $tmask, $mask\n\t"
+            "bext   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    __ mov($tsrc$$FloatRegister, __ D, 0, $src$$Register);
+    __ mov($tmask$$FloatRegister, __ D, 0, $mask$$Register);
+    __ sve_bext($tdst$$FloatRegister, __ D, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ D, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
+instruct compressBitsL_memcon(iRegLNoSp dst, memory8 mem, immL mask,
+                           vRegF tdst, vRegF tsrc, vRegF tmask) %{
+  match(Set dst (CompressBits (LoadL mem) mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "ldrd   $tsrc, $mem\n\t"
+            "ldrd   $tmask, $mask\n\t"
+            "bext   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    loadStore(C2_MacroAssembler(&cbuf), &MacroAssembler::ldrd, $tsrc$$FloatRegister, $mem->opcode(),
+              as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
+    __ ldrd($tmask$$FloatRegister, $constantaddress($mask));
+    __ sve_bext($tdst$$FloatRegister, __ D, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ D, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
+instruct expandBitsI_reg(iRegINoSp dst, iRegIorL2I src, iRegIorL2I mask,
+                         vRegF tdst, vRegF tsrc, vRegF tmask) %{
+  match(Set dst (ExpandBits src mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "mov    $tsrc, $src\n\t"
+            "mov    $tmask, $mask\n\t"
+            "bdep   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    __ mov($tsrc$$FloatRegister, __ S, 0, $src$$Register);
+    __ mov($tmask$$FloatRegister, __ S, 0, $mask$$Register);
+    __ sve_bdep($tdst$$FloatRegister, __ S, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ S, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
+instruct expandBitsI_memcon(iRegINoSp dst, memory4 mem, immI mask,
+                         vRegF tdst, vRegF tsrc, vRegF tmask) %{
+  match(Set dst (ExpandBits (LoadI mem) mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "ldrs   $tsrc, $mem\n\t"
+            "ldrs   $tmask, $mask\n\t"
+            "bdep   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    loadStore(C2_MacroAssembler(&cbuf), &MacroAssembler::ldrs, $tsrc$$FloatRegister, $mem->opcode(),
+              as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
+    __ ldrs($tmask$$FloatRegister, $constantaddress($mask));
+    __ sve_bdep($tdst$$FloatRegister, __ S, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ S, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
+instruct expandBitsL_reg(iRegLNoSp dst, iRegL src, iRegL mask,
+                         vRegD tdst, vRegD tsrc, vRegD tmask) %{
+  match(Set dst (ExpandBits src mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "mov    $tsrc, $src\n\t"
+            "mov    $tmask, $mask\n\t"
+            "bdep   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    __ mov($tsrc$$FloatRegister, __ D, 0, $src$$Register);
+    __ mov($tmask$$FloatRegister, __ D, 0, $mask$$Register);
+    __ sve_bdep($tdst$$FloatRegister, __ D, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ D, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
+
+instruct expandBitsL_memcon(iRegINoSp dst, memory8 mem, immL mask,
+                         vRegF tdst, vRegF tsrc, vRegF tmask) %{
+  match(Set dst (ExpandBits (LoadL mem) mask));
+  effect(TEMP tdst, TEMP tsrc, TEMP tmask);
+  format %{ "ldrd   $tsrc, $mem\n\t"
+            "ldrd   $tmask, $mask\n\t"
+            "bdep   $tdst, $tsrc, $tmask\n\t"
+            "mov    $dst, $tdst"
+          %}
+  ins_encode %{
+    loadStore(C2_MacroAssembler(&cbuf), &MacroAssembler::ldrd, $tsrc$$FloatRegister, $mem->opcode(),
+              as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
+    __ ldrd($tmask$$FloatRegister, $constantaddress($mask));
+    __ sve_bdep($tdst$$FloatRegister, __ D, $tsrc$$FloatRegister, $tmask$$FloatRegister);
+    __ mov($dst$$Register, $tdst$$FloatRegister, __ D, 0);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
 // ============================================================================
 // This name is KNOWN by the ADLC and cannot be changed.
 // The ADLC forces a 'TypeRawPtr::BOTTOM' output type
diff --git a/src/hotspot/cpu/aarch64/aarch64_vector.ad b/src/hotspot/cpu/aarch64/aarch64_vector.ad
index 31427871120..d49c0eb416f 100644
--- a/src/hotspot/cpu/aarch64/aarch64_vector.ad
+++ b/src/hotspot/cpu/aarch64/aarch64_vector.ad
@@ -5689,6 +5689,18 @@ instruct vmask_gen_imm(pReg pd, immL con, rFlagsReg cr) %{
   ins_pipe(pipe_slow);
 %}
 
+instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{
+  predicate(UseSVE > 0);
+  match(Set pd (VectorMaskGen (SubL src1 src2)));
+  effect(KILL cr);
+  format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %}
+  ins_encode %{
+    BasicType bt = Matcher::vector_element_basic_type(this);
+    __ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
 // ------------------------------ Popcount vector ------------------------------
 
 // vector popcount - INT
diff --git a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4
index 9c458399e44..6cb7e23b249 100644
--- a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4
+++ b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4
@@ -4072,6 +4072,18 @@ instruct vmask_gen_imm(pReg pd, immL con, rFlagsReg cr) %{
   ins_pipe(pipe_slow);
 %}
 
+instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{
+  predicate(UseSVE > 0);
+  match(Set pd (VectorMaskGen (SubL src1 src2)));
+  effect(KILL cr);
+  format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %}
+  ins_encode %{
+    BasicType bt = Matcher::vector_element_basic_type(this);
+    __ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
+  %}
+  ins_pipe(pipe_slow);
+%}
+
 // ------------------------------ Popcount vector ------------------------------
 
 // vector popcount - INT
diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp
index 90b9b64e699..0dda457b449 100644
--- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp
@@ -299,3 +299,18 @@ void BarrierSetAssembler::c2i_entry_barrier(MacroAssembler* masm) {
   __ bind(method_live);
 }
 
+void BarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
+  // Check if the oop is in the right area of memory
+  __ mov(tmp2, (intptr_t) Universe::verify_oop_mask());
+  __ andr(tmp1, obj, tmp2);
+  __ mov(tmp2, (intptr_t) Universe::verify_oop_bits());
+
+  // Compare tmp1 and tmp2.  We don't use a compare
+  // instruction here because the flags register is live.
+  __ eor(tmp1, tmp1, tmp2);
+  __ cbnz(tmp1, error);
+
+  // make sure klass is 'reasonable', which is not zero.
+  __ load_klass(obj, obj); // get klass
+  __ cbz(obj, error);      // if klass is NULL it is broken
+}
diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp
index f308603a8cb..b4d5161ed74 100644
--- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp
@@ -72,6 +72,8 @@ class BarrierSetAssembler: public CHeapObj<mtGC> {
   virtual void nmethod_entry_barrier(MacroAssembler* masm, Label* slow_path, Label* continuation, Label* guard);
   virtual void c2i_entry_barrier(MacroAssembler* masm);
 
+  virtual void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
+
   virtual bool supports_instruction_patching() {
     NMethodPatchingType patching_type = nmethod_patching_type();
     return patching_type == NMethodPatchingType::conc_instruction_and_data_patch ||
diff --git a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp
index 0693a2c063b..6f4d201a27a 100644
--- a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -444,6 +444,19 @@ void ZBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, Z
   __ b(*stub->continuation());
 }
 
+#endif // COMPILER2
+
 #undef __
+#define __ masm->
 
-#endif // COMPILER2
+void ZBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
+  // Check if mask is good.
+  // verifies that ZAddressBadMask & r0 == 0
+  __ ldr(tmp2, Address(rthread, ZThreadLocalData::address_bad_mask_offset()));
+  __ andr(tmp1, obj, tmp2);
+  __ cbnz(tmp1, error);
+
+  BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error);
+}
+
+#undef __
diff --git a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp
index ac32d9111e1..c852dac3a4d 100644
--- a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp
@@ -97,6 +97,8 @@ class ZBarrierSetAssembler : public ZBarrierSetAssemblerBase {
   void generate_c2_load_barrier_stub(MacroAssembler* masm,
                                      ZLoadBarrierStubC2* stub) const;
 #endif // COMPILER2
+
+  void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
 };
 
 #endif // CPU_AARCH64_GC_Z_ZBARRIERSETASSEMBLER_AARCH64_HPP
diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
index 34fc3eff9ad..2bc60b43ba6 100644
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
@@ -568,29 +568,8 @@ class StubGenerator: public StubCodeGenerator {
     // make sure object is 'reasonable'
     __ cbz(r0, exit); // if obj is NULL it is OK
 
-#if INCLUDE_ZGC
-    if (UseZGC) {
-      // Check if mask is good.
-      // verifies that ZAddressBadMask & r0 == 0
-      __ ldr(c_rarg3, Address(rthread, ZThreadLocalData::address_bad_mask_offset()));
-      __ andr(c_rarg2, r0, c_rarg3);
-      __ cbnz(c_rarg2, error);
-    }
-#endif
-
-    // Check if the oop is in the right area of memory
-    __ mov(c_rarg3, (intptr_t) Universe::verify_oop_mask());
-    __ andr(c_rarg2, r0, c_rarg3);
-    __ mov(c_rarg3, (intptr_t) Universe::verify_oop_bits());
-
-    // Compare c_rarg2 and c_rarg3.  We don't use a compare
-    // instruction here because the flags register is live.
-    __ eor(c_rarg2, c_rarg2, c_rarg3);
-    __ cbnz(c_rarg2, error);
-
-    // make sure klass is 'reasonable', which is not zero.
-    __ load_klass(r0, r0);  // get klass
-    __ cbz(r0, error);      // if klass is NULL it is broken
+    BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
+    bs_asm->check_oop(_masm, r0, c_rarg2, c_rarg3, error);
 
     // return if everything seems ok
     __ bind(exit);
diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
index 93616b0fe88..fbbd16466ef 100644
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
@@ -731,7 +731,10 @@ int LIR_Assembler::store(LIR_Opr from_reg, Register base, int offset, BasicType
             __ verify_coop(from_reg->as_register(), FILE_AND_LINE);
           } else {
             __ std(from_reg->as_register(), offset, base);
-            __ verify_oop(from_reg->as_register(), FILE_AND_LINE);
+            if (VerifyOops) {
+              BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+              bs->check_oop(_masm, from_reg->as_register(), FILE_AND_LINE); // kills R0
+            }
           }
           break;
         }
@@ -772,7 +775,10 @@ int LIR_Assembler::store(LIR_Opr from_reg, Register base, Register disp, BasicTy
           __ verify_coop(from_reg->as_register(), FILE_AND_LINE); // kills R0
         } else {
           __ stdx(from_reg->as_register(), base, disp);
-          __ verify_oop(from_reg->as_register(), FILE_AND_LINE); // kills R0
+          if (VerifyOops) {
+            BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+            bs->check_oop(_masm, from_reg->as_register(), FILE_AND_LINE); // kills R0
+          }
         }
         break;
       }
@@ -813,7 +819,10 @@ int LIR_Assembler::load(Register base, int offset, LIR_Opr to_reg, BasicType typ
           } else {
             __ ld(to_reg->as_register(), offset, base);
           }
-          __ verify_oop(to_reg->as_register(), FILE_AND_LINE);
+          if (VerifyOops) {
+            BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+            bs->check_oop(_masm, to_reg->as_register(), FILE_AND_LINE); // kills R0
+          }
           break;
         }
       case T_FLOAT:  __ lfs(to_reg->as_float_reg(), offset, base); break;
@@ -844,7 +853,10 @@ int LIR_Assembler::load(Register base, Register disp, LIR_Opr to_reg, BasicType
         } else {
           __ ldx(to_reg->as_register(), base, disp);
         }
-        __ verify_oop(to_reg->as_register(), FILE_AND_LINE);
+        if (VerifyOops) {
+          BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+          bs->check_oop(_masm, to_reg->as_register(), FILE_AND_LINE); // kills R0
+        }
         break;
       }
     case T_FLOAT:  __ lfsx(to_reg->as_float_reg() , base, disp); break;
diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp
index 051e1d08aec..f507c290aa1 100644
--- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp
@@ -255,3 +255,7 @@ void BarrierSetAssembler::c2i_entry_barrier(MacroAssembler *masm, Register tmp1,
 
   __ block_comment("} c2i_entry_barrier (c2i_entry_barrier)");
 }
+
+void BarrierSetAssembler::check_oop(MacroAssembler *masm, Register oop, const char* msg) {
+  __ verify_oop(oop, msg);
+}
diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp
index 9ad474961cb..0265f97b639 100644
--- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp
+++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp
@@ -69,6 +69,8 @@ class BarrierSetAssembler: public CHeapObj<mtGC> {
 
   virtual void nmethod_entry_barrier(MacroAssembler* masm, Register tmp);
   virtual void c2i_entry_barrier(MacroAssembler* masm, Register tmp1, Register tmp2, Register tmp3);
+
+  virtual void check_oop(MacroAssembler *masm, Register oop, const char* msg);
 };
 
 #endif // CPU_PPC_GC_SHARED_BARRIERSETASSEMBLER_PPC_HPP
diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
index 27e2bae6ab7..c621f25bcea 100644
--- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
+++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
@@ -1980,34 +1980,38 @@ static void gen_continuation_yield(MacroAssembler* masm,
 
   Label L_pinned;
 
-  __ cmpdi(CCR0, R3_RET, 0);
+  __ cmpwi(CCR0, R3_RET, 0);
   __ bne(CCR0, L_pinned);
 
+  // yield succeeded
+
   // Pop frames of continuation including this stub's frame
   __ ld_ptr(R1_SP, JavaThread::cont_entry_offset(), R16_thread);
   // The frame pushed by gen_continuation_enter is on top now again
   continuation_enter_cleanup(masm);
 
-  __ bind(L_pinned); // pinned -- return to caller
+  // Pop frame and return
+  Label L_return;
+  __ bind(L_return);
+  __ pop_frame();
+  __ ld(R0, _abi0(lr), R1_SP); // Return pc
+  __ mtlr(R0);
+  __ blr();
+
+  // yield failed - continuation is pinned
+
+  __ bind(L_pinned);
 
   // handle pending exception thrown by freeze
-  Label ok;
   __ ld(tmp, in_bytes(JavaThread::pending_exception_offset()), R16_thread);
   __ cmpdi(CCR0, tmp, 0);
-  __ beq(CCR0, ok);
+  __ beq(CCR0, L_return); // return if no exception is pending
   __ pop_frame();
   __ ld(R0, _abi0(lr), R1_SP); // Return pc
   __ mtlr(R0);
   __ load_const_optimized(tmp, StubRoutines::forward_exception_entry(), R0);
   __ mtctr(tmp);
   __ bctr();
-  __ bind(ok);
-
-  // Pop frame and return
-  __ pop_frame();
-  __ ld(R0, _abi0(lr), R1_SP); // Return pc
-  __ mtlr(R0);
-  __ blr();
 }
 
 // ---------------------------------------------------------------------------
diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp
index e092850f2a9..81ee91e4481 100644
--- a/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp
+++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp
@@ -92,18 +92,17 @@ void LIR_Assembler::arraycopy_simple_check(Register src, Register src_pos, Regis
   // of the arraycopy is an array type, check at runtime if the source or the destination is
   // an instance type.
   if (flags & LIR_OpArrayCopy::type_check) {
+    assert(Klass::_lh_neutral_value == 0, "or replace bgez instructions");
     if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) {
       __ load_klass(tmp, dst);
       __ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset())));
-      __ mv(t1, Klass::_lh_neutral_value);
-      __ bge(t0, t1, *stub->entry(), /* is_far */ true);
+      __ bgez(t0, *stub->entry(), /* is_far */ true);
     }
 
     if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) {
       __ load_klass(tmp, src);
       __ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset())));
-      __ mv(t1, Klass::_lh_neutral_value);
-      __ bge(t0, t1, *stub->entry(), /* is_far */ true);
+      __ bgez(t0, *stub->entry(), /* is_far */ true);
     }
   }
 
diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
index f234697ab89..79544e36d5a 100644
--- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
@@ -1001,7 +1001,7 @@ void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
   if (op->init_check()) {
     __ lbu(t0, Address(op->klass()->as_register(),
                        InstanceKlass::init_state_offset()));
-    __ mv(t1, InstanceKlass::fully_initialized);
+    __ mv(t1, (u1)InstanceKlass::fully_initialized);
     add_debug_info_for_null_check_here(op->stub()->info());
     __ bne(t0, t1, *op->stub()->entry(), /* is_far */ true);
   }
diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
index d8d0beeadfa..662de44de29 100644
--- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
@@ -308,3 +308,17 @@ void BarrierSetAssembler::c2i_entry_barrier(MacroAssembler* masm) {
   __ far_jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
   __ bind(method_live);
 }
+
+void BarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
+  // Check if the oop is in the right area of memory
+  __ mv(tmp2, (intptr_t) Universe::verify_oop_mask());
+  __ andr(tmp1, obj, tmp2);
+  __ mv(tmp2, (intptr_t) Universe::verify_oop_bits());
+
+  // Compare tmp1 and tmp2.
+  __ bne(tmp1, tmp2, error);
+
+  // Make sure klass is 'reasonable', which is not zero.
+  __ load_klass(obj, obj, tmp1); // get klass
+  __ beqz(obj, error);           // if klass is NULL it is broken
+}
diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp
index 7e24c920926..fe6d5b2da92 100644
--- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp
+++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp
@@ -74,6 +74,8 @@ class BarrierSetAssembler: public CHeapObj<mtGC> {
   virtual void nmethod_entry_barrier(MacroAssembler* masm, Label* slow_path, Label* continuation, Label* guard);
   virtual void c2i_entry_barrier(MacroAssembler* masm);
 
+  virtual void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
+
   virtual bool supports_instruction_patching() {
     NMethodPatchingType patching_type = nmethod_patching_type();
     return patching_type == NMethodPatchingType::conc_instruction_and_data_patch ||
diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
index 0240217abff..ee2844e0180 100644
--- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -351,8 +351,6 @@ void ZBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, Z
   __ j(*stub->continuation());
 }
 
-#undef __
-
 #endif // COMPILER2
 
 #ifdef COMPILER1
@@ -442,5 +440,19 @@ void ZBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler*
   __ epilogue();
 }
 
-#undef __
 #endif // COMPILER1
+
+#undef __
+#define __ masm->
+
+void ZBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
+  // Check if mask is good.
+  // verifies that ZAddressBadMask & obj == 0
+  __ ld(tmp2, Address(xthread, ZThreadLocalData::address_bad_mask_offset()));
+  __ andr(tmp1, obj, tmp2);
+  __ bnez(tmp1, error);
+
+  BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error);
+}
+
+#undef __
diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp
index 25d512b9307..c7f29684a64 100644
--- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp
+++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp
@@ -99,6 +99,8 @@ class ZBarrierSetAssembler : public ZBarrierSetAssemblerBase {
   void generate_c2_load_barrier_stub(MacroAssembler* masm,
                                      ZLoadBarrierStubC2* stub) const;
 #endif // COMPILER2
+
+  void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
 };
 
 #endif // CPU_RISCV_GC_Z_ZBARRIERSETASSEMBLER_RISCV_HPP
diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
index 6954a29e182..15f72b52411 100644
--- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
- * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2150,7 +2150,7 @@ void MacroAssembler::encode_klass_not_null(Register dst, Register src, Register
     return;
   }
 
-  if (((uint64_t)(uintptr_t)CompressedKlassPointers::base() & 0xffffffff) == 0 &&
+  if (((uint64_t)CompressedKlassPointers::base() & 0xffffffff) == 0 &&
       CompressedKlassPointers::shift() == 0) {
     zero_extend(dst, src, 32);
     return;
@@ -2162,7 +2162,7 @@ void MacroAssembler::encode_klass_not_null(Register dst, Register src, Register
   }
 
   assert_different_registers(src, xbase);
-  mv(xbase, (intptr_t)CompressedKlassPointers::base());
+  mv(xbase, (uintptr_t)CompressedKlassPointers::base());
   sub(dst, src, xbase);
   if (CompressedKlassPointers::shift() != 0) {
     assert(LogKlassAlignmentInBytes == CompressedKlassPointers::shift(), "decode alg wrong");
diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
index a61784b0f2d..53faf8e358a 100644
--- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
+++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
- * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2142,7 +2142,7 @@ void SharedRuntime::generate_deopt_blob() {
     __ mv(t0, -1);
     __ sw(t0, Address(xthread, in_bytes(JavaThread::pending_deoptimization_offset())));
 
-    __ mv(xcpool, (int32_t)Deoptimization::Unpack_reexecute);
+    __ mv(xcpool, Deoptimization::Unpack_reexecute);
     __ mv(c_rarg0, xthread);
     __ orrw(c_rarg2, zr, xcpool); // exec mode
     RuntimeAddress target(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap));
@@ -2483,7 +2483,7 @@ void SharedRuntime::generate_uncommon_trap_blob() {
   // n.b. 3 gp args, 0 fp args, integral return type
 
   __ mv(c_rarg0, xthread);
-  __ mv(c_rarg2, (unsigned)Deoptimization::Unpack_uncommon_trap);
+  __ mv(c_rarg2, Deoptimization::Unpack_uncommon_trap);
   RuntimeAddress target(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap));
   __ relocate(target.rspec(), [&] {
     int32_t offset;
@@ -2610,7 +2610,7 @@ void SharedRuntime::generate_uncommon_trap_blob() {
 
   // sp should already be aligned
   __ mv(c_rarg0, xthread);
-  __ mv(c_rarg1, (unsigned)Deoptimization::Unpack_uncommon_trap);
+  __ mv(c_rarg1, Deoptimization::Unpack_uncommon_trap);
   target = RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames));
   __ relocate(target.rspec(), [&] {
     int32_t offset;
diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
index 7a33edb9f81..1b092a76bc0 100644
--- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
+++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
- * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -614,27 +614,8 @@ class StubGenerator: public StubCodeGenerator {
     // make sure object is 'reasonable'
     __ beqz(x10, exit); // if obj is NULL it is OK
 
-#if INCLUDE_ZGC
-    if (UseZGC) {
-      // Check if mask is good.
-      // verifies that ZAddressBadMask & x10 == 0
-      __ ld(c_rarg3, Address(xthread, ZThreadLocalData::address_bad_mask_offset()));
-      __ andr(c_rarg2, x10, c_rarg3);
-      __ bnez(c_rarg2, error);
-    }
-#endif
-
-    // Check if the oop is in the right area of memory
-    __ mv(c_rarg3, (intptr_t) Universe::verify_oop_mask());
-    __ andr(c_rarg2, x10, c_rarg3);
-    __ mv(c_rarg3, (intptr_t) Universe::verify_oop_bits());
-
-    // Compare c_rarg2 and c_rarg3.
-    __ bne(c_rarg2, c_rarg3, error);
-
-    // make sure klass is 'reasonable', which is not zero.
-    __ load_klass(x10, x10);  // get klass
-    __ beqz(x10, error);      // if klass is NULL it is broken
+    BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
+    bs_asm->check_oop(_masm, x10, c_rarg2, c_rarg3, error);
 
     // return if everything seems ok
     __ bind(exit);
@@ -1866,7 +1847,7 @@ class StubGenerator: public StubCodeGenerator {
     {
       BLOCK_COMMENT("assert primitive array {");
       Label L;
-      __ mv(t1, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
+      __ mv(t1, (int32_t)(Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift));
       __ bge(lh, t1, L);
       __ stop("must be a primitive array");
       __ bind(L);
@@ -3895,7 +3876,7 @@ class StubGenerator: public StubCodeGenerator {
     }
 
     // If we want, we can templatize thaw by kind, and have three different entries
-    __ mv(c_rarg1, (uint32_t)kind);
+    __ mv(c_rarg1, kind);
 
     __ call_VM_leaf(Continuation::thaw_entry(), xthread, c_rarg1);
     __ mv(t1, x10); // x10 is the sp of the yielding frame
diff --git a/src/hotspot/cpu/s390/runtime_s390.cpp b/src/hotspot/cpu/s390/runtime_s390.cpp
index 392a7d7dadc..65fc8fba35e 100644
--- a/src/hotspot/cpu/s390/runtime_s390.cpp
+++ b/src/hotspot/cpu/s390/runtime_s390.cpp
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -137,8 +137,8 @@ void OptoRuntime::generate_exception_blob() {
   __ clear_mem(Address(Z_thread, JavaThread::exception_oop_offset()),sizeof(intptr_t));
 #ifdef ASSERT
   __ clear_mem(Address(Z_thread, JavaThread::exception_handler_pc_offset()), sizeof(intptr_t));
-  __ clear_mem(Address(Z_thread, JavaThread::exception_pc_offset()), sizeof(intptr_t));
 #endif
+  NOT_PRODUCT(__ clear_mem(Address(Z_thread, JavaThread::exception_pc_offset()), sizeof(intptr_t)));
 
   __ z_br(handle_exception);
 
diff --git a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp
index 05983b20b2a..3901a6be8c1 100644
--- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp
+++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016, 2020 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2023 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1080,8 +1080,9 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
     generate_stack_overflow_check(frame_size, fp/*tmp1*/);
   }
 
-  DEBUG_ONLY(__ z_cg(Z_R14, _z_abi16(return_pc), Z_SP));
-  __ asm_assert_eq("killed Z_R14", 0);
+  // asm_assert* is a nop in product builds
+  NOT_PRODUCT(__ z_cg(Z_R14, _z_abi16(return_pc), Z_SP));
+  NOT_PRODUCT(__ asm_assert_eq("killed Z_R14", 0));
   __ resize_frame_absolute(sp_after_resize, fp, true);
   __ save_return_pc(Z_R14);
 
@@ -1351,10 +1352,8 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
   }
 #endif // ASSERT
 
-#ifdef ASSERT
   // Save the return PC into the callers frame for assertion in generate_fixed_frame.
-  __ save_return_pc(Z_R14);
-#endif
+  NOT_PRODUCT(__ save_return_pc(Z_R14));
 
   // Generate the code to allocate the interpreter stack frame.
   generate_fixed_frame(true);
@@ -1719,10 +1718,8 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
   }
 #endif // ASSERT
 
-#ifdef ASSERT
   // Save the return PC into the callers frame for assertion in generate_fixed_frame.
-  __ save_return_pc(Z_R14);
-#endif
+  NOT_PRODUCT(__ save_return_pc(Z_R14));
 
   // Generate the code to allocate the interpreter stack frame.
   generate_fixed_frame(false);
diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
index b508429f0ab..cb11789523a 100644
--- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
+++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
@@ -559,6 +559,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp
   if (use_rtm) {
     assert_different_registers(objReg, boxReg, tmpReg, scrReg, cx1Reg, cx2Reg);
   } else {
+    assert(cx1Reg == noreg, "");
     assert(cx2Reg == noreg, "");
     assert_different_registers(objReg, boxReg, tmpReg, scrReg);
   }
@@ -581,7 +582,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp
   Label IsInflated, DONE_LABEL, NO_COUNT, COUNT;
 
   if (DiagnoseSyncOnValueBasedClasses != 0) {
-    load_klass(tmpReg, objReg, cx1Reg);
+    load_klass(tmpReg, objReg, scrReg);
     movl(tmpReg, Address(tmpReg, Klass::access_flags_offset()));
     testl(tmpReg, JVM_ACC_IS_VALUE_BASED_CLASS);
     jcc(Assembler::notZero, DONE_LABEL);
diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp
index 348fd00c9d4..06007d8be58 100644
--- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp
+++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp
@@ -366,3 +366,18 @@ void BarrierSetAssembler::c2i_entry_barrier(MacroAssembler* masm) {
   __ pop(tmp1);
 #endif
 }
+
+void BarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
+  // Check if the oop is in the right area of memory
+  __ movptr(tmp1, obj);
+  __ movptr(tmp2, (intptr_t) Universe::verify_oop_mask());
+  __ andptr(tmp1, tmp2);
+  __ movptr(tmp2, (intptr_t) Universe::verify_oop_bits());
+  __ cmpptr(tmp1, tmp2);
+  __ jcc(Assembler::notZero, error);
+
+  // make sure klass is 'reasonable', which is not zero.
+  __ load_klass(obj, obj, tmp1);  // get klass
+  __ testptr(obj, obj);
+  __ jcc(Assembler::zero, error); // if klass is NULL it is broken
+}
diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp
index d793a299eb5..1ba289e4fa4 100644
--- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp
+++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp
@@ -64,6 +64,8 @@ class BarrierSetAssembler: public CHeapObj<mtGC> {
 
   virtual void nmethod_entry_barrier(MacroAssembler* masm, Label* slow_path, Label* continuation);
   virtual void c2i_entry_barrier(MacroAssembler* masm);
+
+  virtual void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
 };
 
 #endif // CPU_X86_GC_SHARED_BARRIERSETASSEMBLER_X86_HPP
diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp
index c93d1d4de6f..0f4e62341a5 100644
--- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp
+++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 #include "gc/z/zBarrierSet.hpp"
 #include "gc/z/zBarrierSetAssembler.hpp"
 #include "gc/z/zBarrierSetRuntime.hpp"
+#include "gc/z/zThreadLocalData.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "utilities/macros.hpp"
@@ -697,6 +698,16 @@ void ZBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, Z
   __ jmp(*stub->continuation());
 }
 
+#endif // COMPILER2
+
 #undef __
+#define __ masm->
 
-#endif // COMPILER2
+void ZBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
+  // Check if metadata bits indicate a bad oop
+  __ testptr(obj, Address(r15_thread, ZThreadLocalData::address_bad_mask_offset()));
+  __ jcc(Assembler::notZero, error);
+  BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error);
+}
+
+#undef __
diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp
index 2446bd1e46a..2c5887361eb 100644
--- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp
+++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp
@@ -96,6 +96,8 @@ class ZBarrierSetAssembler : public ZBarrierSetAssemblerBase {
   void generate_c2_load_barrier_stub(MacroAssembler* masm,
                                      ZLoadBarrierStubC2* stub) const;
 #endif // COMPILER2
+
+  void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
 };
 
 #endif // CPU_X86_GC_Z_ZBARRIERSETASSEMBLER_X86_HPP
diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
index 05b55348658..9420e6c016e 100644
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
@@ -1093,26 +1093,8 @@ address StubGenerator::generate_verify_oop() {
   __ testptr(rax, rax);
   __ jcc(Assembler::zero, exit); // if obj is NULL it is OK
 
-#if INCLUDE_ZGC
-  if (UseZGC) {
-    // Check if metadata bits indicate a bad oop
-    __ testptr(rax, Address(r15_thread, ZThreadLocalData::address_bad_mask_offset()));
-    __ jcc(Assembler::notZero, error);
-  }
-#endif
-
-  // Check if the oop is in the right area of memory
-  __ movptr(c_rarg2, rax);
-  __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_mask());
-  __ andptr(c_rarg2, c_rarg3);
-  __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_bits());
-  __ cmpptr(c_rarg2, c_rarg3);
-  __ jcc(Assembler::notZero, error);
-
-  // make sure klass is 'reasonable', which is not zero.
-  __ load_klass(rax, rax, rscratch1);  // get klass
-  __ testptr(rax, rax);
-  __ jcc(Assembler::zero, error); // if klass is NULL it is broken
+   BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
+   bs_asm->check_oop(_masm, rax, c_rarg2, c_rarg3, error);
 
   // return if everything seems ok
   __ bind(exit);
@@ -1660,7 +1642,6 @@ address StubGenerator::generate_base64_encodeBlock()
   // calculate length from offsets
   __ movl(length, end_offset);
   __ subl(length, start_offset);
-  __ cmpl(length, 0);
   __ jcc(Assembler::lessEqual, L_exit);
 
   // Code for 512-bit VBMI encoding.  Encodes 48 input bytes into 64
@@ -1703,8 +1684,7 @@ address StubGenerator::generate_base64_encodeBlock()
   }
 
   __ BIND(L_not512);
-  if (VM_Version::supports_avx2()
-      && VM_Version::supports_avx512vlbw()) {
+  if (VM_Version::supports_avx2()) {
     /*
     ** This AVX2 encoder is based off the paper at:
     **      https://dl.acm.org/doi/10.1145/3132709
@@ -1721,15 +1701,17 @@ address StubGenerator::generate_base64_encodeBlock()
     __ vmovdqu(xmm9, ExternalAddress(StubRoutines::x86::base64_avx2_shuffle_addr()), rax);
     // 6-bit mask for 2nd and 4th (and multiples) 6-bit values
     __ movl(rax, 0x0fc0fc00);
+    __ movdl(xmm8, rax);
     __ vmovdqu(xmm1, ExternalAddress(StubRoutines::x86::base64_avx2_input_mask_addr()), rax);
-    __ evpbroadcastd(xmm8, rax, Assembler::AVX_256bit);
+    __ vpbroadcastd(xmm8, xmm8, Assembler::AVX_256bit);
 
     // Multiplication constant for "shifting" right by 6 and 10
     // bits
     __ movl(rax, 0x04000040);
 
     __ subl(length, 24);
-    __ evpbroadcastd(xmm7, rax, Assembler::AVX_256bit);
+    __ movdl(xmm7, rax);
+    __ vpbroadcastd(xmm7, xmm7, Assembler::AVX_256bit);
 
     // For the first load, we mask off reading of the first 4
     // bytes into the register. This is so we can get 4 3-byte
@@ -1831,19 +1813,23 @@ address StubGenerator::generate_base64_encodeBlock()
     // Load masking register for first and third (and multiples)
     // 6-bit values.
     __ movl(rax, 0x003f03f0);
-    __ evpbroadcastd(xmm6, rax, Assembler::AVX_256bit);
+    __ movdl(xmm6, rax);
+    __ vpbroadcastd(xmm6, xmm6, Assembler::AVX_256bit);
     // Multiplication constant for "shifting" left by 4 and 8 bits
     __ movl(rax, 0x01000010);
-    __ evpbroadcastd(xmm5, rax, Assembler::AVX_256bit);
+    __ movdl(xmm5, rax);
+    __ vpbroadcastd(xmm5, xmm5, Assembler::AVX_256bit);
 
     // Isolate 6-bit chunks of interest
     __ vpand(xmm0, xmm8, xmm1, Assembler::AVX_256bit);
 
     // Load constants for encoding
     __ movl(rax, 0x19191919);
-    __ evpbroadcastd(xmm3, rax, Assembler::AVX_256bit);
+    __ movdl(xmm3, rax);
+    __ vpbroadcastd(xmm3, xmm3, Assembler::AVX_256bit);
     __ movl(rax, 0x33333333);
-    __ evpbroadcastd(xmm4, rax, Assembler::AVX_256bit);
+    __ movdl(xmm4, rax);
+    __ vpbroadcastd(xmm4, xmm4, Assembler::AVX_256bit);
 
     // Shift output bytes 0 and 2 into proper lanes
     __ vpmulhuw(xmm2, xmm0, xmm7, Assembler::AVX_256bit);
@@ -2151,6 +2137,80 @@ address StubGenerator::base64_vbmi_join_2_3_addr() {
   return start;
 }
 
+address StubGenerator::base64_AVX2_decode_tables_addr() {
+  __ align64();
+  StubCodeMark mark(this, "StubRoutines", "AVX2_tables_base64");
+  address start = __ pc();
+
+  assert(((unsigned long long)start & 0x3f) == 0,
+         "Alignment problem (0x%08llx)", (unsigned long long)start);
+  __ emit_data(0x2f2f2f2f, relocInfo::none, 0);
+  __ emit_data(0x5f5f5f5f, relocInfo::none, 0);  // for URL
+
+  __ emit_data(0xffffffff, relocInfo::none, 0);
+  __ emit_data(0xfcfcfcfc, relocInfo::none, 0);  // for URL
+
+  // Permute table
+  __ emit_data64(0x0000000100000000, relocInfo::none);
+  __ emit_data64(0x0000000400000002, relocInfo::none);
+  __ emit_data64(0x0000000600000005, relocInfo::none);
+  __ emit_data64(0xffffffffffffffff, relocInfo::none);
+
+  // Shuffle table
+  __ emit_data64(0x090a040506000102, relocInfo::none);
+  __ emit_data64(0xffffffff0c0d0e08, relocInfo::none);
+  __ emit_data64(0x090a040506000102, relocInfo::none);
+  __ emit_data64(0xffffffff0c0d0e08, relocInfo::none);
+
+  // merge table
+  __ emit_data(0x01400140, relocInfo::none, 0);
+
+  // merge multiplier
+  __ emit_data(0x00011000, relocInfo::none, 0);
+
+  return start;
+}
+
+address StubGenerator::base64_AVX2_decode_LUT_tables_addr() {
+  __ align64();
+  StubCodeMark mark(this, "StubRoutines", "AVX2_tables_URL_base64");
+  address start = __ pc();
+
+  assert(((unsigned long long)start & 0x3f) == 0,
+         "Alignment problem (0x%08llx)", (unsigned long long)start);
+  // lut_lo
+  __ emit_data64(0x1111111111111115, relocInfo::none);
+  __ emit_data64(0x1a1b1b1b1a131111, relocInfo::none);
+  __ emit_data64(0x1111111111111115, relocInfo::none);
+  __ emit_data64(0x1a1b1b1b1a131111, relocInfo::none);
+
+  // lut_roll
+  __ emit_data64(0xb9b9bfbf04131000, relocInfo::none);
+  __ emit_data64(0x0000000000000000, relocInfo::none);
+  __ emit_data64(0xb9b9bfbf04131000, relocInfo::none);
+  __ emit_data64(0x0000000000000000, relocInfo::none);
+
+  // lut_lo URL
+  __ emit_data64(0x1111111111111115, relocInfo::none);
+  __ emit_data64(0x1b1b1a1b1b131111, relocInfo::none);
+  __ emit_data64(0x1111111111111115, relocInfo::none);
+  __ emit_data64(0x1b1b1a1b1b131111, relocInfo::none);
+
+  // lut_roll URL
+  __ emit_data64(0xb9b9bfbf0411e000, relocInfo::none);
+  __ emit_data64(0x0000000000000000, relocInfo::none);
+  __ emit_data64(0xb9b9bfbf0411e000, relocInfo::none);
+  __ emit_data64(0x0000000000000000, relocInfo::none);
+
+  // lut_hi
+  __ emit_data64(0x0804080402011010, relocInfo::none);
+  __ emit_data64(0x1010101010101010, relocInfo::none);
+  __ emit_data64(0x0804080402011010, relocInfo::none);
+  __ emit_data64(0x1010101010101010, relocInfo::none);
+
+  return start;
+}
+
 address StubGenerator::base64_decoding_table_addr() {
   StubCodeMark mark(this, "StubRoutines", "decoding_table_base64");
   address start = __ pc();
@@ -2307,7 +2367,7 @@ address StubGenerator::generate_base64_decodeBlock() {
 
   Label L_process256, L_process64, L_process64Loop, L_exit, L_processdata, L_loadURL;
   Label L_continue, L_finalBit, L_padding, L_donePadding, L_bruteForce;
-  Label L_forceLoop, L_bottomLoop, L_checkMIME, L_exit_no_vzero;
+  Label L_forceLoop, L_bottomLoop, L_checkMIME, L_exit_no_vzero, L_lastChunk;
 
   // calculate length from offsets
   __ movl(length, end_offset);
@@ -2317,11 +2377,11 @@ address StubGenerator::generate_base64_decodeBlock() {
   // If AVX512 VBMI not supported, just compile non-AVX code
   if(VM_Version::supports_avx512_vbmi() &&
      VM_Version::supports_avx512bw()) {
-    __ cmpl(length, 128);     // 128-bytes is break-even for AVX-512
-    __ jcc(Assembler::lessEqual, L_bruteForce);
+    __ cmpl(length, 31);     // 32-bytes is break-even for AVX-512
+    __ jcc(Assembler::lessEqual, L_lastChunk);
 
     __ cmpl(isMIME, 0);
-    __ jcc(Assembler::notEqual, L_bruteForce);
+    __ jcc(Assembler::notEqual, L_lastChunk);
 
     // Load lookup tables based on isURL
     __ cmpl(isURL, 0);
@@ -2572,6 +2632,89 @@ address StubGenerator::generate_base64_decodeBlock() {
     __ BIND(L_bruteForce);
   }   // End of if(avx512_vbmi)
 
+  if (VM_Version::supports_avx2()) {
+    Label L_tailProc, L_topLoop, L_enterLoop;
+
+    __ cmpl(isMIME, 0);
+    __ jcc(Assembler::notEqual, L_lastChunk);
+
+    // Check for buffer too small (for algorithm)
+    __ subl(length, 0x2c);
+    __ jcc(Assembler::less, L_tailProc);
+
+    __ shll(isURL, 2);
+
+    // Algorithm adapted from https://arxiv.org/abs/1704.00605, "Faster Base64
+    // Encoding and Decoding using AVX2 Instructions".  URL modifications added.
+
+    // Set up constants
+    __ lea(r13, ExternalAddress(StubRoutines::x86::base64_AVX2_decode_tables_addr()));
+    __ vpbroadcastd(xmm4, Address(r13, isURL, Address::times_1), Assembler::AVX_256bit);  // 2F or 5F
+    __ vpbroadcastd(xmm10, Address(r13, isURL, Address::times_1, 0x08), Assembler::AVX_256bit);  // -1 or -4
+    __ vmovdqu(xmm12, Address(r13, 0x10));  // permute
+    __ vmovdqu(xmm13, Address(r13, 0x30)); // shuffle
+    __ vpbroadcastd(xmm7, Address(r13, 0x50), Assembler::AVX_256bit);  // merge
+    __ vpbroadcastd(xmm6, Address(r13, 0x54), Assembler::AVX_256bit);  // merge mult
+
+    __ lea(r13, ExternalAddress(StubRoutines::x86::base64_AVX2_decode_LUT_tables_addr()));
+    __ shll(isURL, 4);
+    __ vmovdqu(xmm11, Address(r13, isURL, Address::times_1, 0x00));  // lut_lo
+    __ vmovdqu(xmm8, Address(r13, isURL, Address::times_1, 0x20)); // lut_roll
+    __ shrl(isURL, 6);  // restore isURL
+    __ vmovdqu(xmm9, Address(r13, 0x80));  // lut_hi
+    __ jmp(L_enterLoop);
+
+    __ align32();
+    __ bind(L_topLoop);
+    // Add in the offset value (roll) to get 6-bit out values
+    __ vpaddb(xmm0, xmm0, xmm2, Assembler::AVX_256bit);
+    // Merge and permute the output bits into appropriate output byte lanes
+    __ vpmaddubsw(xmm0, xmm0, xmm7, Assembler::AVX_256bit);
+    __ vpmaddwd(xmm0, xmm0, xmm6, Assembler::AVX_256bit);
+    __ vpshufb(xmm0, xmm0, xmm13, Assembler::AVX_256bit);
+    __ vpermd(xmm0, xmm12, xmm0, Assembler::AVX_256bit);
+    // Store the output bytes
+    __ vmovdqu(Address(dest, dp, Address::times_1, 0), xmm0);
+    __ addptr(source, 0x20);
+    __ addptr(dest, 0x18);
+    __ subl(length, 0x20);
+    __ jcc(Assembler::less, L_tailProc);
+
+    __ bind(L_enterLoop);
+
+    // Load in encoded string (32 bytes)
+    __ vmovdqu(xmm2, Address(source, start_offset, Address::times_1, 0x0));
+    // Extract the high nibble for indexing into the lut tables.  High 4 bits are don't care.
+    __ vpsrld(xmm1, xmm2, 0x4, Assembler::AVX_256bit);
+    __ vpand(xmm1, xmm4, xmm1, Assembler::AVX_256bit);
+    // Extract the low nibble. 5F/2F will isolate the low-order 4 bits.  High 4 bits are don't care.
+    __ vpand(xmm3, xmm2, xmm4, Assembler::AVX_256bit);
+    // Check for special-case (0x2F or 0x5F (URL))
+    __ vpcmpeqb(xmm0, xmm4, xmm2, Assembler::AVX_256bit);
+    // Get the bitset based on the low nibble.  vpshufb uses low-order 4 bits only.
+    __ vpshufb(xmm3, xmm11, xmm3, Assembler::AVX_256bit);
+    // Get the bit value of the high nibble
+    __ vpshufb(xmm5, xmm9, xmm1, Assembler::AVX_256bit);
+    // Make sure 2F / 5F shows as valid
+    __ vpandn(xmm3, xmm0, xmm3, Assembler::AVX_256bit);
+    // Make adjustment for roll index.  For non-URL, this is a no-op,
+    // for URL, this adjusts by -4.  This is to properly index the
+    // roll value for 2F / 5F.
+    __ vpand(xmm0, xmm0, xmm10, Assembler::AVX_256bit);
+    // If the and of the two is non-zero, we have an invalid input character
+    __ vptest(xmm3, xmm5);
+    // Extract the "roll" value - value to add to the input to get 6-bit out value
+    __ vpaddb(xmm0, xmm0, xmm1, Assembler::AVX_256bit); // Handle 2F / 5F
+    __ vpshufb(xmm0, xmm8, xmm0, Assembler::AVX_256bit);
+    __ jcc(Assembler::equal, L_topLoop);  // Fall through on error
+
+    __ bind(L_tailProc);
+
+    __ addl(length, 0x2c);
+
+    __ vzeroupper();
+  }
+
   // Use non-AVX code to decode 4-byte chunks into 3 bytes of output
 
   // Register state (Linux):
@@ -2602,6 +2745,8 @@ address StubGenerator::generate_base64_decodeBlock() {
   const Register byte3 = WIN64_ONLY(r8) NOT_WIN64(rdx);
   const Register byte4 = WIN64_ONLY(r10) NOT_WIN64(r9);
 
+  __ bind(L_lastChunk);
+
   __ shrl(length, 2);    // Multiple of 4 bytes only - length is # 4-byte chunks
   __ cmpl(length, 0);
   __ jcc(Assembler::lessEqual, L_exit_no_vzero);
@@ -3847,12 +3992,12 @@ void StubGenerator::generate_all() {
   }
 
   if (UseBASE64Intrinsics) {
-    if(VM_Version::supports_avx2() &&
-       VM_Version::supports_avx512bw() &&
-       VM_Version::supports_avx512vl()) {
+    if(VM_Version::supports_avx2()) {
       StubRoutines::x86::_avx2_shuffle_base64 = base64_avx2_shuffle_addr();
       StubRoutines::x86::_avx2_input_mask_base64 = base64_avx2_input_mask_addr();
       StubRoutines::x86::_avx2_lut_base64 = base64_avx2_lut_addr();
+      StubRoutines::x86::_avx2_decode_tables_base64 = base64_AVX2_decode_tables_addr();
+      StubRoutines::x86::_avx2_decode_lut_tables_base64 = base64_AVX2_decode_LUT_tables_addr();
     }
     StubRoutines::x86::_encoding_table_base64 = base64_encoding_table_addr();
     if (VM_Version::supports_avx512_vbmi()) {
diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp
index d9680c75542..da39d9da30f 100644
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp
@@ -441,6 +441,8 @@ class StubGenerator: public StubCodeGenerator {
   address base64_vbmi_join_1_2_addr();
   address base64_vbmi_join_2_3_addr();
   address base64_decoding_table_addr();
+  address base64_AVX2_decode_tables_addr();
+  address base64_AVX2_decode_LUT_tables_addr();
 
   // Code for generating Base64 decoding.
   //
diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_poly.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_poly.cpp
index 01245409b0b..6e091331f7d 100644
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64_poly.cpp
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_poly.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Intel Corporation. All rights reserved.
+ * Copyright (c) 2022, 2023, Intel Corporation. All rights reserved.
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -37,19 +37,19 @@
 // Explanation for the 'well known' modular arithmetic optimization, reduction by pseudo-Mersene prime 2^130-5:
 //
 // Reduction by 2^130-5 can be expressed as follows:
-//    ( a×2^130 + b ) mod 2^130-5     //i.e. number split along the 130-bit boundary
-//                                 = ( a×2^130 - 5×a + 5×a + b ) mod 2^130-5
-//                                 = ( a×(2^130 - 5) + 5×a + b ) mod 2^130-5 // i.e. adding multiples of modulus is a noop
-//                                 = ( 5×a + b ) mod 2^130-5
+//    ( ax2^130 + b ) mod 2^130-5     //i.e. number split along the 130-bit boundary
+//                                 = ( ax2^130 - 5xa + 5xa + b ) mod 2^130-5
+//                                 = ( ax(2^130 - 5) + 5xa + b ) mod 2^130-5 // i.e. adding multiples of modulus is a noop
+//                                 = ( 5xa + b ) mod 2^130-5
 // QED: shows mathematically the well known algorithm of 'split the number down the middle, multiply upper and add'
 // This is particularly useful to understand when combining with 'odd-sized' limbs that might cause misallignment
 //
 
 // Pseudocode for this file (in general):
 //    * used for poly1305_multiply_scalar
-//    × used for poly1305_multiply8_avx512
-//    lower-case variables are scalar numbers in 3×44-bit limbs (in gprs)
-//    upper-case variables are 8-element vector numbers in 3×44-bit limbs (in zmm registers)
+//    x used for poly1305_multiply8_avx512
+//    lower-case variables are scalar numbers in 3x44-bit limbs (in gprs)
+//    upper-case variables are 8-element vector numbers in 3x44-bit limbs (in zmm registers)
 //    [ ] used to denote vector numbers (with their elements)
 
 // Constant Pool:
@@ -84,16 +84,16 @@ static address poly1305_mask44() {
 }
 
 // Compute product for 8 16-byte message blocks,
-// i.e. For each block, compute [a2 a1 a0] = [a2 a1 a0] × [r2 r1 r0]
+// i.e. For each block, compute [a2 a1 a0] = [a2 a1 a0] x [r2 r1 r0]
 //
 // Each block/number is represented by 3 44-bit limb digits, start with multiplication
 //
 //      a2       a1       a0
-// ×    r2       r1       r0
+// x    r2       r1       r0
 // ----------------------------------
-//     a2×r0    a1×r0    a0×r0
-// +   a1×r1    a0×r1  5×a2×r1'     (r1' = r1<<2)
-// +   a0×r2  5×a2×r2' 5×a1×r2'     (r2' = r2<<2)
+//     a2xr0    a1xr0    a0xr0
+// +   a1xr1    a0xr1  5xa2xr1'     (r1' = r1<<2)
+// +   a0xr2  5xa2xr2' 5xa1xr2'     (r2' = r2<<2)
 // ----------------------------------
 //        p2       p1       p0
 //
@@ -101,24 +101,24 @@ static address poly1305_mask44() {
 // Then, modular reduction from upper limb wrapped to lower limbs
 //
 // Math Note 1: 'carry propagation' from p2 to p0 involves multiplication by 5 (i.e. slightly modified modular reduction from above):
-//    ( p2×2^88 ) mod 2^130-5
-//                             = ( p2'×2^88 + p2''×2^130) mod 2^130-5 // Split on 130-bit boudary
-//                             = ( p2'×2^88 + p2''×2^130 - 5×p2'' + 5×p2'') mod 2^130-5
-//                             = ( p2'×2^88 + p2''×(2^130 - 5) + 5×p2'') mod 2^130-5 // i.e. adding multiples of modulus is a noop
-//                             = ( p2'×2^88 + 5×p2'') mod 2^130-5
+//    ( p2x2^88 ) mod 2^130-5
+//                             = ( p2'x2^88 + p2''x2^130) mod 2^130-5 // Split on 130-bit boudary
+//                             = ( p2'x2^88 + p2''x2^130 - 5xp2'' + 5xp2'') mod 2^130-5
+//                             = ( p2'x2^88 + p2''x(2^130 - 5) + 5xp2'') mod 2^130-5 // i.e. adding multiples of modulus is a noop
+//                             = ( p2'x2^88 + 5xp2'') mod 2^130-5
 //
 // Math Note 2: R1P = 4*5*R1 and R2P = 4*5*R2; This precomputation allows simultaneous reduction and multiplication.
 // This is not the standard 'multiply-upper-by-5', here is why the factor is 4*5 instead of 5.
-// For example, partial product (a2×r2):
-//    (a2×2^88)×(r2×2^88) mod 2^130-5
-//                                    = (a2×r2 × 2^176) mod 2^130-5
-//                                    = (a2×r2 × 2^46×2^130) mod 2^130-5
-//                                    = (a2×r2×2^46 × 2^130- 5×a2×r2×2^46 + 5×a2×r2×2^46) mod 2^130-5
-//                                    = (a2×r2×2^46 × (2^130- 5) + 5×a2×r2×2^46) mod 2^130-5 // i.e. adding multiples of modulus is a noop
-//                                    = (5×a2×r2×2^46) mod 2^130-5
-//                                    = (a2×5×r2×2^2 × 2^44) mod 2^130-5 // Align to limb boudary
-//                                    = (a2×[5×r2×4] × 2^44) mod 2^130-5
-//                                    = (a2×R2P × 2^44) mod 2^130-5 // i.e. R2P = 4*5*R2
+// For example, partial product (a2xr2):
+//    (a2x2^88)x(r2x2^88) mod 2^130-5
+//                                    = (a2xr2 x 2^176) mod 2^130-5
+//                                    = (a2xr2 x 2^46x2^130) mod 2^130-5
+//                                    = (a2xr2x2^46 x 2^130- 5xa2xr2x2^46 + 5xa2xr2x2^46) mod 2^130-5
+//                                    = (a2xr2x2^46 x (2^130- 5) + 5xa2xr2x2^46) mod 2^130-5 // i.e. adding multiples of modulus is a noop
+//                                    = (5xa2xr2x2^46) mod 2^130-5
+//                                    = (a2x5xr2x2^2 x 2^44) mod 2^130-5 // Align to limb boudary
+//                                    = (a2x[5xr2x4] x 2^44) mod 2^130-5
+//                                    = (a2xR2P x 2^44) mod 2^130-5 // i.e. R2P = 4*5*R2
 //
 void StubGenerator::poly1305_multiply8_avx512(
   const XMMRegister A0, const XMMRegister A1, const XMMRegister A2,
@@ -136,9 +136,9 @@ void StubGenerator::poly1305_multiply8_avx512(
   __ evpxorq(P2H, P2H, P2H, Assembler::AVX_512bit);
 
   // Calculate partial products
-  // p0 = a2×r1'
-  // p1 = a2×r2'
-  // p2 = a2×r0
+  // p0 = a2xr1'
+  // p1 = a2xr2'
+  // p2 = a2xr0
   __ evpmadd52luq(P0L, A2, R1P, Assembler::AVX_512bit);
   __ evpmadd52huq(P0H, A2, R1P, Assembler::AVX_512bit);
   __ evpmadd52luq(P1L, A2, R2P, Assembler::AVX_512bit);
@@ -146,9 +146,9 @@ void StubGenerator::poly1305_multiply8_avx512(
   __ evpmadd52luq(P2L, A2, R0, Assembler::AVX_512bit);
   __ evpmadd52huq(P2H, A2, R0, Assembler::AVX_512bit);
 
-  // p0 += a0×r0
-  // p1 += a0×r1
-  // p2 += a0×r2
+  // p0 += a0xr0
+  // p1 += a0xr1
+  // p2 += a0xr2
   __ evpmadd52luq(P1L, A0, R1, Assembler::AVX_512bit);
   __ evpmadd52huq(P1H, A0, R1, Assembler::AVX_512bit);
   __ evpmadd52luq(P2L, A0, R2, Assembler::AVX_512bit);
@@ -156,9 +156,9 @@ void StubGenerator::poly1305_multiply8_avx512(
   __ evpmadd52luq(P0L, A0, R0, Assembler::AVX_512bit);
   __ evpmadd52huq(P0H, A0, R0, Assembler::AVX_512bit);
 
-  // p0 += a1×r2'
-  // p1 += a1×r0
-  // p2 += a1×r1
+  // p0 += a1xr2'
+  // p1 += a1xr0
+  // p2 += a1xr1
   __ evpmadd52luq(P0L, A1, R2P, Assembler::AVX_512bit);
   __ evpmadd52huq(P0H, A1, R2P, Assembler::AVX_512bit);
   __ evpmadd52luq(P1L, A1, R0, Assembler::AVX_512bit);
@@ -168,10 +168,10 @@ void StubGenerator::poly1305_multiply8_avx512(
 
   // Carry propagation:
   // (Not quite aligned)                         | More mathematically correct:
-  //         P2L   P1L   P0L                     |                 P2L×2^88 + P1L×2^44 + P0L×2^0
-  // + P2H   P1H   P0H                           |   + P2H×2^140 + P1H×2^96 + P0H×2^52
+  //         P2L   P1L   P0L                     |                 P2Lx2^88 + P1Lx2^44 + P0Lx2^0
+  // + P2H   P1H   P0H                           |   + P2Hx2^140 + P1Hx2^96 + P0Hx2^52
   // ---------------------------                 |   -----------------------------------------------
-  // = P2H    A2    A1    A0                     |   = P2H×2^130 + A2×2^88 +   A1×2^44 +  A0×2^0
+  // = P2H    A2    A1    A0                     |   = P2Hx2^130 + A2x2^88 +   A1x2^44 +  A0x2^0
   //
   __ vpsrlq(TMP, P0L, 44, Assembler::AVX_512bit);
   __ evpandq(A0, P0L, ExternalAddress(poly1305_mask44()), Assembler::AVX_512bit, rscratch); // Clear top 20 bits
@@ -214,8 +214,8 @@ void StubGenerator::poly1305_multiply8_avx512(
 //          a2        a1        a0
 //        x           r1        r0
 //   -----------------------------
-//       a2×r0     a1×r0     a0×r0
-//   +             a0×r1
+//       a2xr0     a1xr0     a0xr0
+//   +             a0xr1
 //   +           5xa2xr1   5xa1xr1
 //   -----------------------------
 //     [0|L2L] [L1H|L1L] [L0H|L0L]
@@ -347,7 +347,7 @@ void StubGenerator::poly1305_limbs_avx512(
 }
 
 /**
- * Copy 5×26-bit (unreduced) limbs stored at Register limbs into  a2:a1:a0 (3×64-bit limbs)
+ * Copy 5x26-bit (unreduced) limbs stored at Register limbs into  a2:a1:a0 (3x64-bit limbs)
  *
  * a2 is optional. When only128 is set, limbs are expected to fit into 128-bits (i.e. a1:a0 such as clamped R)
  */
@@ -393,7 +393,7 @@ void StubGenerator::poly1305_limbs(
 }
 
 /**
- * Break 3×64-bit a2:a1:a0 limbs into 5×26-bit limbs and store out into 5 quadwords at address `limbs`
+ * Break 3x64-bit a2:a1:a0 limbs into 5x26-bit limbs and store out into 5 quadwords at address `limbs`
  */
 void StubGenerator::poly1305_limbs_out(
     const Register a0, const Register a1, const Register a2,
@@ -474,9 +474,9 @@ void StubGenerator::poly1305_limbs_out(
 //
 // Pseudocode:
 //  * used for poly1305_multiply_scalar
-//  × used for poly1305_multiply8_avx512
-//  lower-case variables are scalar numbers in 3×44-bit limbs (in gprs)
-//  upper-case variables are 8&16-element vector numbers in 3×44-bit limbs (in zmm registers)
+//  x used for poly1305_multiply8_avx512
+//  lower-case variables are scalar numbers in 3x44-bit limbs (in gprs)
+//  upper-case variables are 8&16-element vector numbers in 3x44-bit limbs (in zmm registers)
 //
 //    CL = a       // [0 0 0 0 0 0 0 a]
 //    AL = poly1305_limbs_avx512(input)
@@ -496,24 +496,24 @@ void StubGenerator::poly1305_limbs_out(
 //    B  = limbs(T)           // [r^4  0  r^3  0  r^2  0  r^1  0 ]
 //    CL = B >> 1             // [ 0  r^4  0  r^3  0  r^2  0  r^1]
 //    R  = r^4 || r^4 || ..   // [r^4 r^4 r^4 r^4 r^4 r^4 r^4 r^4]
-//    B  = B×R                // [r^8  0  r^7  0  r^6  0  r^5  0 ]
+//    B  = BxR                // [r^8  0  r^7  0  r^6  0  r^5  0 ]
 //    B  = B | CL             // [r^8 r^4 r^7 r^3 r^6 r^2 r^5 r^1]
 //    CL = B
 //    R  = r^8 || r^8 || ..   // [r^8 r^8 r^8 r^8 r^8 r^8 r^8 r^8]
-//    B  = B × R              // [r^16 r^12 r^15 r^11 r^14 r^10 r^13 r^9]
+//    B  = B x R              // [r^16 r^12 r^15 r^11 r^14 r^10 r^13 r^9]
 //    CH = B
 //    R = r^16 || r^16 || ..  // [r^16 r^16 r^16 r^16 r^16 r^16 r^16 r^16]
 //
 // for (;length>=16; input+=16, length-=16)
 //     BL = poly1305_limbs_avx512(input)
 //     BH = poly1305_limbs_avx512(input+8)
-//     AL = AL × R
-//     AH = AH × R
+//     AL = AL x R
+//     AH = AH x R
 //     AL = AL + BL
 //     AH = AH + BH
 //
-//  AL = AL × CL
-//  AH = AH × CH
+//  AL = AL x CL
+//  AH = AH x CH
 //  A = AL + AH // 16->8 blocks
 //  T = A >> 4  // 8 ->4 blocks
 //  A = A + T
diff --git a/src/hotspot/cpu/x86/stubRoutines_x86.cpp b/src/hotspot/cpu/x86/stubRoutines_x86.cpp
index f210de8e60c..021fb528f5e 100644
--- a/src/hotspot/cpu/x86/stubRoutines_x86.cpp
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.cpp
@@ -71,6 +71,8 @@ address StubRoutines::x86::_shuffle_base64 = NULL;
 address StubRoutines::x86::_avx2_shuffle_base64 = NULL;
 address StubRoutines::x86::_avx2_input_mask_base64 = NULL;
 address StubRoutines::x86::_avx2_lut_base64 = NULL;
+address StubRoutines::x86::_avx2_decode_tables_base64 = NULL;
+address StubRoutines::x86::_avx2_decode_lut_tables_base64 = NULL;
 address StubRoutines::x86::_lookup_lo_base64 = NULL;
 address StubRoutines::x86::_lookup_hi_base64 = NULL;
 address StubRoutines::x86::_lookup_lo_base64url = NULL;
diff --git a/src/hotspot/cpu/x86/stubRoutines_x86.hpp b/src/hotspot/cpu/x86/stubRoutines_x86.hpp
index c769d8b620c..3654032a594 100644
--- a/src/hotspot/cpu/x86/stubRoutines_x86.hpp
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.hpp
@@ -185,6 +185,8 @@ class x86 {
   static address _avx2_shuffle_base64;
   static address _avx2_input_mask_base64;
   static address _avx2_lut_base64;
+  static address _avx2_decode_tables_base64;
+  static address _avx2_decode_lut_tables_base64;
   static address _lookup_lo_base64;
   static address _lookup_hi_base64;
   static address _lookup_lo_base64url;
@@ -325,6 +327,8 @@ class x86 {
   static address base64_vbmi_join_1_2_addr() { return _join_1_2_base64; }
   static address base64_vbmi_join_2_3_addr() { return _join_2_3_base64; }
   static address base64_decoding_table_addr() { return _decoding_table_base64; }
+  static address base64_AVX2_decode_tables_addr() { return _avx2_decode_tables_base64; }
+  static address base64_AVX2_decode_LUT_tables_addr() { return _avx2_decode_lut_tables_base64; }
 #endif
   static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; }
   static address arrays_hashcode_powers_of_31() { return (address)_arrays_hashcode_powers_of_31; }
diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp
index 7967564699b..28ead33c608 100644
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp
@@ -1140,7 +1140,7 @@ void VM_Version::get_processor_features() {
   }
 
   // Base64 Intrinsics (Check the condition for which the intrinsic will be active)
-  if ((UseAVX > 2) && supports_avx512vl() && supports_avx512bw()) {
+  if (UseAVX >= 2) {
     if (FLAG_IS_DEFAULT(UseBASE64Intrinsics)) {
       UseBASE64Intrinsics = true;
     }
diff --git a/src/hotspot/cpu/x86/x86_64.ad b/src/hotspot/cpu/x86/x86_64.ad
index d0d5246eddc..5d48c95ddbb 100644
--- a/src/hotspot/cpu/x86/x86_64.ad
+++ b/src/hotspot/cpu/x86/x86_64.ad
@@ -13369,15 +13369,15 @@ instruct cmpFastLockRTM(rFlagsReg cr, rRegP object, rbx_RegP box, rax_RegI tmp,
   ins_pipe(pipe_slow);
 %}
 
-instruct cmpFastLock(rFlagsReg cr, rRegP object, rbx_RegP box, rax_RegI tmp, rRegP scr, rRegP cx1) %{
+instruct cmpFastLock(rFlagsReg cr, rRegP object, rbx_RegP box, rax_RegI tmp, rRegP scr) %{
   predicate(!Compile::current()->use_rtm());
   match(Set cr (FastLock object box));
-  effect(TEMP tmp, TEMP scr, TEMP cx1, USE_KILL box);
+  effect(TEMP tmp, TEMP scr, USE_KILL box);
   ins_cost(300);
   format %{ "fastlock $object,$box\t! kills $box,$tmp,$scr" %}
   ins_encode %{
     __ fast_lock($object$$Register, $box$$Register, $tmp$$Register,
-                 $scr$$Register, $cx1$$Register, noreg, NULL, NULL, NULL, false, false);
+                 $scr$$Register, noreg, noreg, NULL, NULL, NULL, false, false);
   %}
   ins_pipe(pipe_slow);
 %}
diff --git a/src/hotspot/cpu/zero/abstractInterpreter_zero.cpp b/src/hotspot/cpu/zero/abstractInterpreter_zero.cpp
index d81a73b747f..bf0d13f02f8 100644
--- a/src/hotspot/cpu/zero/abstractInterpreter_zero.cpp
+++ b/src/hotspot/cpu/zero/abstractInterpreter_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -103,13 +103,13 @@ void AbstractInterpreter::layout_activation(Method* method,
 
   BytecodeInterpreter::layout_interpreterState(istate,
                                                caller,
-                                               NULL,
+                                               nullptr,
                                                method,
                                                locals,
                                                stack,
                                                stack_base,
                                                monitor_base,
-                                               NULL,
+                                               nullptr,
                                                is_top_frame);
 }
 
diff --git a/src/hotspot/cpu/zero/bytecodeInterpreter_zero.cpp b/src/hotspot/cpu/zero/bytecodeInterpreter_zero.cpp
index de44d3afb58..3f02ff573fa 100644
--- a/src/hotspot/cpu/zero/bytecodeInterpreter_zero.cpp
+++ b/src/hotspot/cpu/zero/bytecodeInterpreter_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2008 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -60,7 +60,7 @@ const char *BytecodeInterpreter::name_of_field_at_address(address addr) {
 #undef DO
   if (addr > (address) &_result && addr < (address) (&_result + 1))
     return "_result)";
-  return NULL;
+  return nullptr;
 }
 
 void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
@@ -77,13 +77,13 @@ void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
   istate->set_method(method);
   istate->set_mirror(method->method_holder()->java_mirror());
   istate->set_self_link(istate);
-  istate->set_prev_link(NULL);
+  istate->set_prev_link(nullptr);
   // thread will be set by a hacky repurposing of frame::patch_pc()
   // bcp will be set by vframeArrayElement::unpack_on_stack()
   istate->set_constants(method->constants()->cache());
   istate->set_msg(BytecodeInterpreter::method_resume);
   istate->set_bcp_advance(0);
-  istate->set_oop_temp(NULL);
+  istate->set_oop_temp(nullptr);
   if (caller->is_interpreted_frame()) {
     interpreterState prev = caller->get_interpreterState();
     prev->set_callee(method);
@@ -92,7 +92,7 @@ void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
     else
       prev->set_bcp_advance(3);
   }
-  istate->set_callee(NULL);
+  istate->set_callee(nullptr);
   istate->set_monitor_base((BasicObjectLock *) monitor_base);
   istate->set_stack_base(stack_base);
   istate->set_stack(stack);
diff --git a/src/hotspot/cpu/zero/compiledIC_zero.cpp b/src/hotspot/cpu/zero/compiledIC_zero.cpp
index 5a3bfb028e3..b0564643af0 100644
--- a/src/hotspot/cpu/zero/compiledIC_zero.cpp
+++ b/src/hotspot/cpu/zero/compiledIC_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 
 address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) {
   ShouldNotReachHere(); // Only needed for COMPILER2.
-  return NULL;
+  return nullptr;
 }
 
 int CompiledStaticCall::to_interp_stub_size() {
diff --git a/src/hotspot/cpu/zero/continuationFreezeThaw_zero.inline.hpp b/src/hotspot/cpu/zero/continuationFreezeThaw_zero.inline.hpp
index 7de24a461c9..83f163d2bd5 100644
--- a/src/hotspot/cpu/zero/continuationFreezeThaw_zero.inline.hpp
+++ b/src/hotspot/cpu/zero/continuationFreezeThaw_zero.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -80,7 +80,7 @@ inline void ThawBase::derelativize_interpreted_frame_metadata(const frame& hf, c
 
 inline intptr_t* ThawBase::align(const frame& hf, intptr_t* frame_sp, frame& caller, bool bottom) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline void ThawBase::patch_pd(frame& f, const frame& caller) {
diff --git a/src/hotspot/cpu/zero/continuationHelper_zero.inline.hpp b/src/hotspot/cpu/zero/continuationHelper_zero.inline.hpp
index 70a12473e0e..56da168d9b1 100644
--- a/src/hotspot/cpu/zero/continuationHelper_zero.inline.hpp
+++ b/src/hotspot/cpu/zero/continuationHelper_zero.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 template<typename FKind> // TODO: maybe do the same CRTP trick with Interpreted and Compiled as with hframe
 static inline intptr_t** link_address(const frame& f) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline int ContinuationHelper::frame_align_words(int size) {
@@ -40,7 +40,7 @@ inline int ContinuationHelper::frame_align_words(int size) {
 
 inline intptr_t* ContinuationHelper::frame_align_pointer(intptr_t* sp) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 template<typename FKind>
@@ -73,18 +73,18 @@ inline bool ContinuationHelper::Frame::assert_frame_laid_out(frame f) {
 
 inline intptr_t** ContinuationHelper::Frame::callee_link_address(const frame& f) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 template<typename FKind>
 static inline intptr_t* real_fp(const frame& f) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline address* ContinuationHelper::InterpretedFrame::return_pc_address(const frame& f) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline void ContinuationHelper::InterpretedFrame::patch_sender_sp(frame& f, const frame& caller) {
@@ -93,12 +93,12 @@ inline void ContinuationHelper::InterpretedFrame::patch_sender_sp(frame& f, cons
 
 inline address* ContinuationHelper::Frame::return_pc_address(const frame& f) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline address ContinuationHelper::Frame::real_pc(const frame& f) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline void ContinuationHelper::Frame::patch_pc(const frame& f, address pc) {
@@ -107,22 +107,22 @@ inline void ContinuationHelper::Frame::patch_pc(const frame& f, address pc) {
 
 inline intptr_t* ContinuationHelper::InterpretedFrame::frame_top(const frame& f, InterpreterOopMap* mask) { // inclusive; this will be copied with the frame
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline intptr_t* ContinuationHelper::InterpretedFrame::frame_bottom(const frame& f) { // exclusive; this will not be copied with the frame
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline intptr_t* ContinuationHelper::InterpretedFrame::frame_top(const frame& f, int callee_argsize, bool callee_interpreted) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline intptr_t* ContinuationHelper::InterpretedFrame::callers_sp(const frame& f) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 #endif // CPU_ZERO_CONTINUATIONHELPER_ZERO_INLINE_HPP
diff --git a/src/hotspot/cpu/zero/disassembler_zero.hpp b/src/hotspot/cpu/zero/disassembler_zero.hpp
index 559eb62fb51..20739a040b2 100644
--- a/src/hotspot/cpu/zero/disassembler_zero.hpp
+++ b/src/hotspot/cpu/zero/disassembler_zero.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -39,7 +39,7 @@
   // the perfect job. In those cases, decode_instruction0 may kick in
   // and do it right.
   // If nothing had to be done, just return "here", otherwise return "here + instr_len(here)"
-  static address decode_instruction0(address here, outputStream* st, address virtual_begin = NULL) {
+  static address decode_instruction0(address here, outputStream* st, address virtual_begin = nullptr) {
     return here;
   }
 
diff --git a/src/hotspot/cpu/zero/frame_zero.cpp b/src/hotspot/cpu/zero/frame_zero.cpp
index 66766a4094a..70f19708a53 100644
--- a/src/hotspot/cpu/zero/frame_zero.cpp
+++ b/src/hotspot/cpu/zero/frame_zero.cpp
@@ -53,7 +53,7 @@ bool frame::is_fake_stub_frame() const {
 
 frame frame::sender_for_entry_frame(RegisterMap *map) const {
   assert(zeroframe()->is_entry_frame(), "wrong type of frame");
-  assert(map != NULL, "map must be set");
+  assert(map != nullptr, "map must be set");
   assert(!entry_frame_is_first(), "next Java fp must be non zero");
   assert(entry_frame_call_wrapper()->anchor()->last_Java_sp() == sender_sp(),
          "sender should be next Java frame");
@@ -88,14 +88,14 @@ BasicObjectLock* frame::interpreter_frame_monitor_end() const {
 }
 
 void frame::patch_pc(Thread* thread, address pc) {
-  if (pc != NULL) {
+  if (pc != nullptr) {
     assert(_cb == CodeCache::find_blob(pc), "unexpected pc");
     _pc = pc;
     _deopt_state = is_deoptimized;
   } else {
     // We borrow this call to set the thread pointer in the interpreter
     // state; the hook to set up deoptimized frames isn't supplied it.
-    assert(pc == NULL, "should be");
+    assert(pc == nullptr, "should be");
     get_interpreterState()->set_thread(JavaThread::cast(thread));
   }
 }
@@ -207,9 +207,9 @@ BasicType frame::interpreter_frame_result(oop* oop_result,
     }
     else {
       oop* obj_p = (oop *) tos_addr;
-      obj = (obj_p == NULL) ? (oop) NULL : *obj_p;
+      obj = (obj_p == nullptr) ? (oop) nullptr : *obj_p;
     }
-    assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
+    assert(obj == nullptr || Universe::heap()->is_in(obj), "sanity check");
     *oop_result = obj;
     break;
 
@@ -338,7 +338,7 @@ void InterpreterFrame::identify_word(int   frame_index,
   // JNI stuff
   if (istate->method()->is_native() && addr < istate->stack_base()) {
     address hA = istate->method()->signature_handler();
-    if (hA != NULL) {
+    if (hA != nullptr) {
       if (hA != (address) InterpreterRuntime::slow_signature_handler) {
         InterpreterRuntime::SignatureHandler *handler =
           InterpreterRuntime::SignatureHandler::from_handlerAddr(hA);
diff --git a/src/hotspot/cpu/zero/frame_zero.inline.hpp b/src/hotspot/cpu/zero/frame_zero.inline.hpp
index 46131a13a72..1b504cfa666 100644
--- a/src/hotspot/cpu/zero/frame_zero.inline.hpp
+++ b/src/hotspot/cpu/zero/frame_zero.inline.hpp
@@ -31,16 +31,16 @@
 // Constructors
 
 inline frame::frame() {
-  _zeroframe = NULL;
-  _sp = NULL;
-  _pc = NULL;
-  _cb = NULL;
+  _zeroframe = nullptr;
+  _sp = nullptr;
+  _pc = nullptr;
+  _cb = nullptr;
   _deopt_state = unknown;
   _on_heap = false;
   DEBUG_ONLY(_frame_index = -1;)
 }
 
-inline address  frame::sender_pc()           const { ShouldNotCallThis(); return NULL; }
+inline address  frame::sender_pc()           const { ShouldNotCallThis(); return nullptr; }
 
 inline frame::frame(intptr_t* sp) {
   Unimplemented();
@@ -54,19 +54,19 @@ inline frame::frame(ZeroFrame* zf, intptr_t* sp) {
   switch (zeroframe()->type()) {
   case ZeroFrame::ENTRY_FRAME:
     _pc = StubRoutines::call_stub_return_pc();
-    _cb = NULL;
+    _cb = nullptr;
     _deopt_state = not_deoptimized;
     break;
 
   case ZeroFrame::INTERPRETER_FRAME:
-    _pc = NULL;
-    _cb = NULL;
+    _pc = nullptr;
+    _cb = nullptr;
     _deopt_state = not_deoptimized;
     break;
 
   case ZeroFrame::FAKE_STUB_FRAME:
-    _pc = NULL;
-    _cb = NULL;
+    _pc = nullptr;
+    _cb = nullptr;
     _deopt_state = not_deoptimized;
     break;
 
@@ -87,12 +87,12 @@ inline intptr_t* frame::real_fp() const {
 
 inline intptr_t* frame::link() const {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 inline intptr_t* frame::link_or_null() const {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 inline interpreterState frame::get_interpreterState() const {
@@ -121,7 +121,7 @@ inline oop* frame::interpreter_frame_mirror_addr() const {
 
 inline intptr_t* frame::interpreter_frame_mdp_addr() const {
   fatal("Should not call this: Zero never profiles");
-  return NULL; // silence compiler warnings
+  return nullptr; // silence compiler warnings
 }
 
 inline intptr_t* frame::interpreter_frame_tos_address() const {
@@ -143,7 +143,7 @@ inline intptr_t* frame::interpreter_frame_expression_stack() const {
 }
 
 // Return a unique id for this frame. The id must have a value where
-// we can distinguish identity and younger/older relationship. NULL
+// we can distinguish identity and younger/older relationship. null
 // represents an invalid (incomparable) frame.
 inline intptr_t* frame::id() const {
   return fp();
@@ -159,7 +159,7 @@ inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
 
 inline oop frame::saved_oop_result(RegisterMap* map) const {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 inline bool frame::is_older(intptr_t* id) const {
@@ -169,7 +169,7 @@ inline bool frame::is_older(intptr_t* id) const {
 
 inline intptr_t* frame::entry_frame_argument_at(int offset) const {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 inline intptr_t* frame::unextended_sp() const {
@@ -178,7 +178,7 @@ inline intptr_t* frame::unextended_sp() const {
 
 inline const ImmutableOopMap* frame::get_oop_map() const {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 inline int frame::compiled_frame_stack_argsize() const {
@@ -217,7 +217,7 @@ inline int frame::frame_size() const {
 
 inline address* frame::sender_pc_addr() const {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 //------------------------------------------------------------------------------
diff --git a/src/hotspot/cpu/zero/icBuffer_zero.cpp b/src/hotspot/cpu/zero/icBuffer_zero.cpp
index 64b273c908c..adde916a4c4 100644
--- a/src/hotspot/cpu/zero/icBuffer_zero.cpp
+++ b/src/hotspot/cpu/zero/icBuffer_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -47,10 +47,10 @@ void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin,
 address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) {
   // NB ic_stub_code_size() must return the size of the code we generate
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 void* InlineCacheBuffer::ic_buffer_cached_value(address code_begin) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
diff --git a/src/hotspot/cpu/zero/interpreterRT_zero.cpp b/src/hotspot/cpu/zero/interpreterRT_zero.cpp
index 59328afd731..5aeb5a0981d 100644
--- a/src/hotspot/cpu/zero/interpreterRT_zero.cpp
+++ b/src/hotspot/cpu/zero/interpreterRT_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -62,7 +62,7 @@ void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_object() {
 }
 
 void InterpreterRuntime::SignatureHandlerGeneratorBase::push(BasicType type) {
-  ffi_type *ftype = NULL;
+  ffi_type *ftype = nullptr;
   switch (type) {
   case T_VOID:
     ftype = &ffi_type_void;
diff --git a/src/hotspot/cpu/zero/javaFrameAnchor_zero.hpp b/src/hotspot/cpu/zero/javaFrameAnchor_zero.hpp
index cb92f1b97a4..89eb5ac23f1 100644
--- a/src/hotspot/cpu/zero/javaFrameAnchor_zero.hpp
+++ b/src/hotspot/cpu/zero/javaFrameAnchor_zero.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -35,15 +35,15 @@
   //  1 - initializing a new state (thread creation, javaCalls)
   //  2 - saving a current state (javaCalls)
   //  3 - restoring an old state (javaCalls)
-  // Note that whenever _last_Java_sp != NULL other anchor fields
+  // Note that whenever _last_Java_sp != null other anchor fields
   // must be valid.  The profiler apparently depends on this.
 
   void clear() {
     // clearing _last_Java_sp must be first
-    _last_Java_sp = NULL;
+    _last_Java_sp = nullptr;
     // fence?
-    _last_Java_fp = NULL;
-    _last_Java_pc = NULL;
+    _last_Java_fp = nullptr;
+    _last_Java_pc = nullptr;
   }
 
   void copy(JavaFrameAnchor* src) {
@@ -56,11 +56,11 @@
     // data
     //
     // Hack Alert: Temporary bugfix for 4717480/4721647 To act like
-    // previous version (pd_cache_state) don't NULL _last_Java_sp
+    // previous version (pd_cache_state) don't null _last_Java_sp
     // unless the value is changing
     //
     if (_last_Java_sp != sp)
-      _last_Java_sp = NULL;
+      _last_Java_sp = nullptr;
 
     _last_Java_fp = fp;
     _last_Java_pc = pc;
diff --git a/src/hotspot/cpu/zero/methodHandles_zero.cpp b/src/hotspot/cpu/zero/methodHandles_zero.cpp
index 3ec5081cba7..4021d0e74b6 100644
--- a/src/hotspot/cpu/zero/methodHandles_zero.cpp
+++ b/src/hotspot/cpu/zero/methodHandles_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -84,7 +84,7 @@ void MethodHandles::setup_frame_anchor(JavaThread* thread) {
     frame = frame->next();
   }
 
-  assert(frame != NULL, "must be");
+  assert(frame != nullptr, "must be");
   thread->set_last_Java_frame(frame, sp);
 }
 
@@ -127,7 +127,7 @@ int MethodHandles::method_handle_entry_invokeBasic(Method* method, intptr_t UNUS
   int numArgs = method->size_of_parameters();
 
   oop recv = STACK_OBJECT(-numArgs);
-  if (recv == NULL) {
+  if (recv == nullptr) {
     throw_NPE(THREAD);
     return 0;
   }
@@ -172,7 +172,7 @@ int MethodHandles::method_handle_entry_linkToInterface(Method* method, intptr_t
 
   int numArgs = target->size_of_parameters();
   oop recv = STACK_OBJECT(-numArgs);
-  if (recv == NULL) {
+  if (recv == nullptr) {
     throw_NPE(THREAD);
     return 0;
   }
@@ -190,7 +190,7 @@ int MethodHandles::method_handle_entry_linkToInterface(Method* method, intptr_t
   // that the method no longer exists (got deleted) or is private.
   // Private class methods can never be an implementation of an
   // interface method. In those cases, throw AME.
-  if (vmtarget != NULL) {
+  if (vmtarget != nullptr) {
     invoke_target(vmtarget, THREAD);
   } else {
     throw_AME(recv->klass(), target, THREAD);
@@ -216,7 +216,7 @@ int MethodHandles::method_handle_entry_linkToVirtual(Method* method, intptr_t UN
 
   int numArgs = target->size_of_parameters();
   oop recv = STACK_OBJECT(-numArgs);
-  if (recv == NULL) {
+  if (recv == nullptr) {
     throw_NPE(THREAD);
     return 0;
   }
@@ -258,7 +258,7 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler*
     return ZeroInterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToVirtual);
   default:
     ShouldNotReachHere();
-    return NULL;
+    return nullptr;
   }
 }
 
diff --git a/src/hotspot/cpu/zero/nativeInst_zero.hpp b/src/hotspot/cpu/zero/nativeInst_zero.hpp
index 9cafe5ca700..5b2c9743cf9 100644
--- a/src/hotspot/cpu/zero/nativeInst_zero.hpp
+++ b/src/hotspot/cpu/zero/nativeInst_zero.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -61,7 +61,7 @@ class NativeInstruction {
 
 inline NativeInstruction* nativeInstruction_at(address address) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 class NativeCall : public NativeInstruction {
@@ -72,22 +72,22 @@ class NativeCall : public NativeInstruction {
 
   address instruction_address() const {
     ShouldNotCallThis();
-    return NULL;
+    return nullptr;
   }
 
   address next_instruction_address() const {
     ShouldNotCallThis();
-    return NULL;
+    return nullptr;
   }
 
   address return_address() const {
     ShouldNotCallThis();
-    return NULL;
+    return nullptr;
   }
 
   address destination() const {
     ShouldNotCallThis();
-    return NULL;
+    return nullptr;
   }
 
   void set_destination_mt_safe(address dest) {
@@ -110,19 +110,19 @@ class NativeCall : public NativeInstruction {
 
 inline NativeCall* nativeCall_before(address return_address) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 inline NativeCall* nativeCall_at(address address) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 class NativeMovConstReg : public NativeInstruction {
  public:
   address next_instruction_address() const {
     ShouldNotCallThis();
-    return NULL;
+    return nullptr;
   }
 
   intptr_t data() const {
@@ -137,7 +137,7 @@ class NativeMovConstReg : public NativeInstruction {
 
 inline NativeMovConstReg* nativeMovConstReg_at(address address) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 class NativeMovRegMem : public NativeInstruction {
@@ -158,7 +158,7 @@ class NativeMovRegMem : public NativeInstruction {
 
 inline NativeMovRegMem* nativeMovRegMem_at(address address) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 class NativeJump : public NativeInstruction {
@@ -169,7 +169,7 @@ class NativeJump : public NativeInstruction {
 
   address jump_destination() const {
     ShouldNotCallThis();
-    return NULL;
+    return nullptr;
   }
 
   void set_jump_destination(address dest) {
@@ -187,14 +187,14 @@ class NativeJump : public NativeInstruction {
 
 inline NativeJump* nativeJump_at(address address) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 class NativeGeneralJump : public NativeInstruction {
  public:
   address jump_destination() const {
     ShouldNotCallThis();
-    return NULL;
+    return nullptr;
   }
 
   static void insert_unconditional(address code_pos, address entry) {
@@ -208,7 +208,7 @@ class NativeGeneralJump : public NativeInstruction {
 
 inline NativeGeneralJump* nativeGeneralJump_at(address address) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 class NativePostCallNop: public NativeInstruction {
@@ -221,13 +221,13 @@ class NativePostCallNop: public NativeInstruction {
 
 inline NativePostCallNop* nativePostCallNop_at(address address) {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 class NativeDeoptInstruction: public NativeInstruction {
 public:
-  address instruction_address() const       { Unimplemented(); return NULL; }
-  address next_instruction_address() const  { Unimplemented(); return NULL; }
+  address instruction_address() const       { Unimplemented(); return nullptr; }
+  address next_instruction_address() const  { Unimplemented(); return nullptr; }
 
   void  verify() { Unimplemented(); }
 
diff --git a/src/hotspot/cpu/zero/registerMap_zero.hpp b/src/hotspot/cpu/zero/registerMap_zero.hpp
index d8c5809543d..0715a96f5ee 100644
--- a/src/hotspot/cpu/zero/registerMap_zero.hpp
+++ b/src/hotspot/cpu/zero/registerMap_zero.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,8 +31,8 @@
  private:
   // This is the hook for finding a register in an "well-known" location,
   // such as a register block of a predetermined format.
-  // Since there is none, we just return NULL.
-  address pd_location(VMReg reg) const { return NULL; }
+  // Since there is none, we just return null.
+  address pd_location(VMReg reg) const { return nullptr; }
 
   address pd_location(VMReg base_reg, int slot_idx) const {
     return location(base_reg->next(slot_idx), nullptr);
diff --git a/src/hotspot/cpu/zero/register_zero.cpp b/src/hotspot/cpu/zero/register_zero.cpp
index 5d695430171..812119b66af 100644
--- a/src/hotspot/cpu/zero/register_zero.cpp
+++ b/src/hotspot/cpu/zero/register_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -32,10 +32,10 @@ const int ConcreteRegisterImpl::max_fpr =
 
 const char* RegisterImpl::name() const {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 const char* FloatRegisterImpl::name() const {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
diff --git a/src/hotspot/cpu/zero/relocInfo_zero.cpp b/src/hotspot/cpu/zero/relocInfo_zero.cpp
index e908f796136..1e9fdc1081d 100644
--- a/src/hotspot/cpu/zero/relocInfo_zero.cpp
+++ b/src/hotspot/cpu/zero/relocInfo_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -36,7 +36,7 @@ void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
 
 address Relocation::pd_call_destination(address orig_addr) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 void Relocation::pd_set_call_destination(address x) {
@@ -45,7 +45,7 @@ void Relocation::pd_set_call_destination(address x) {
 
 address Relocation::pd_get_address_from_code() {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 address* Relocation::pd_address_in_code() {
diff --git a/src/hotspot/cpu/zero/sharedRuntime_zero.cpp b/src/hotspot/cpu/zero/sharedRuntime_zero.cpp
index aec0e709d88..d55b7aead3f 100644
--- a/src/hotspot/cpu/zero/sharedRuntime_zero.cpp
+++ b/src/hotspot/cpu/zero/sharedRuntime_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -74,7 +74,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
                                                 VMRegPair *regs,
                                                 BasicType ret_type) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 int Deoptimization::last_frame_adjust(int callee_parameters,
diff --git a/src/hotspot/cpu/zero/smallRegisterMap_zero.inline.hpp b/src/hotspot/cpu/zero/smallRegisterMap_zero.inline.hpp
index 45f43228f10..b85ead32fd2 100644
--- a/src/hotspot/cpu/zero/smallRegisterMap_zero.inline.hpp
+++ b/src/hotspot/cpu/zero/smallRegisterMap_zero.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@ class SmallRegisterMap {
 
   inline address location(VMReg reg, intptr_t* sp) const {
     Unimplemented();
-    return NULL;
+    return nullptr;
   }
 
   inline void set_location(VMReg reg, address loc) { assert_is_rfp(reg); }
@@ -77,7 +77,7 @@ class SmallRegisterMap {
   bool should_skip_missing() const  { return false; }
   VMReg find_register_spilled_here(void* p, intptr_t* sp) {
     Unimplemented();
-    return NULL;
+    return nullptr;
   }
   void print() const { print_on(tty); }
   void print_on(outputStream* st) const { st->print_cr("Small register map"); }
diff --git a/src/hotspot/cpu/zero/stackChunkFrameStream_zero.inline.hpp b/src/hotspot/cpu/zero/stackChunkFrameStream_zero.inline.hpp
index d9f16caca1e..84d6dee9149 100644
--- a/src/hotspot/cpu/zero/stackChunkFrameStream_zero.inline.hpp
+++ b/src/hotspot/cpu/zero/stackChunkFrameStream_zero.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,25 +46,25 @@ inline frame StackChunkFrameStream<frame_kind>::to_frame() const {
 template <ChunkFrames frame_kind>
 inline address StackChunkFrameStream<frame_kind>::get_pc() const {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 template <ChunkFrames frame_kind>
 inline intptr_t* StackChunkFrameStream<frame_kind>::fp() const {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 template <ChunkFrames frame_kind>
 inline intptr_t* StackChunkFrameStream<frame_kind>::derelativize(int offset) const {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 template <ChunkFrames frame_kind>
 inline intptr_t* StackChunkFrameStream<frame_kind>::unextended_sp_for_interpreter_frame() const {
   Unimplemented();
-  return NULL;
+  return nullptr;
 }
 
 template <ChunkFrames frame_kind>
diff --git a/src/hotspot/cpu/zero/stack_zero.cpp b/src/hotspot/cpu/zero/stack_zero.cpp
index 275853a6032..ef986111cf8 100644
--- a/src/hotspot/cpu/zero/stack_zero.cpp
+++ b/src/hotspot/cpu/zero/stack_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -33,7 +33,7 @@
 
 // Inlined causes circular inclusion with thread.hpp
 ZeroStack::ZeroStack()
-    : _base(NULL), _top(NULL), _sp(NULL) {
+    : _base(nullptr), _top(nullptr), _sp(nullptr) {
     _shadow_pages_size = StackOverflow::stack_shadow_zone_size();
   }
 
@@ -64,7 +64,7 @@ void ZeroStack::handle_overflow(TRAPS) {
       frame = frame->next();
     }
 
-    if (frame == NULL)
+    if (frame == nullptr)
       fatal("unrecoverable stack overflow");
 
     thread->set_last_Java_frame(frame, sp);
diff --git a/src/hotspot/cpu/zero/stack_zero.hpp b/src/hotspot/cpu/zero/stack_zero.hpp
index b5742b6a381..3d87ef1a6d2 100644
--- a/src/hotspot/cpu/zero/stack_zero.hpp
+++ b/src/hotspot/cpu/zero/stack_zero.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -42,7 +42,7 @@ class ZeroStack {
   ZeroStack();
 
   bool needs_setup() const {
-    return _base == NULL;
+    return _base == nullptr;
   }
 
   int suggest_size(Thread *thread) const;
@@ -59,9 +59,9 @@ class ZeroStack {
     assert(!needs_setup(), "not set up");
     assert(_sp == _top, "stuff on stack at teardown");
 
-    _base = NULL;
-    _top  = NULL;
-    _sp   = NULL;
+    _base = nullptr;
+    _top  = nullptr;
+    _sp   = nullptr;
   }
 
   intptr_t *sp() const {
diff --git a/src/hotspot/cpu/zero/stubGenerator_zero.cpp b/src/hotspot/cpu/zero/stubGenerator_zero.cpp
index 4fe19588133..f9b48127527 100644
--- a/src/hotspot/cpu/zero/stubGenerator_zero.cpp
+++ b/src/hotspot/cpu/zero/stubGenerator_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2010, 2015 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -145,8 +145,8 @@ class StubGenerator: public StubCodeGenerator {
     StubRoutines::_checkcast_arraycopy       = ShouldNotCallThisStub();
     StubRoutines::_generic_arraycopy         = ShouldNotCallThisStub();
 
-    // Shared code tests for "NULL" to discover the stub is not generated.
-    StubRoutines::_unsafe_arraycopy          = NULL;
+    // Shared code tests for "null" to discover the stub is not generated.
+    StubRoutines::_unsafe_arraycopy          = nullptr;
 
     // We don't generate specialized code for HeapWord-aligned source
     // arrays, so just use the code we've already generated
diff --git a/src/hotspot/cpu/zero/vtableStubs_zero.cpp b/src/hotspot/cpu/zero/vtableStubs_zero.cpp
index dccbbb2c344..6258762279e 100644
--- a/src/hotspot/cpu/zero/vtableStubs_zero.cpp
+++ b/src/hotspot/cpu/zero/vtableStubs_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -29,12 +29,12 @@
 
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 VtableStub* VtableStubs::create_itable_stub(int vtable_index) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 int VtableStub::pd_code_alignment() {
diff --git a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
index e8f8b8e38b9..a195a076091 100644
--- a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
+++ b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -50,12 +50,12 @@
 #include "stack_zero.inline.hpp"
 
 void ZeroInterpreter::initialize_stub() {
-  if (_code != NULL) return;
+  if (_code != nullptr) return;
 
   // generate interpreter
   int code_size = InterpreterCodeSize;
   NOT_PRODUCT(code_size *= 4;)  // debug uses extra interpreter code space
-  _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
+  _code = new StubQueue(new InterpreterCodeletInterface, code_size, nullptr,
                          "Interpreter");
 }
 
@@ -120,8 +120,8 @@ int ZeroInterpreter::Reference_get_entry(Method* method, intptr_t UNUSED, TRAPS)
 
   oop ref = STACK_OBJECT(0);
 
-  // Shortcut if reference is known NULL
-  if (ref == NULL) {
+  // Shortcut if reference is known null
+  if (ref == nullptr) {
     return normal_entry(method, 0, THREAD);
   }
 
@@ -174,7 +174,7 @@ void ZeroInterpreter::main_loop(int recurse, TRAPS) {
   interpreterState istate = frame->interpreter_state();
   Method* method = istate->method();
 
-  intptr_t *result = NULL;
+  intptr_t *result = nullptr;
   int result_slots = 0;
 
   while (true) {
@@ -254,7 +254,7 @@ void ZeroInterpreter::main_loop(int recurse, TRAPS) {
       istate->set_stack_base(istate->stack_base() - monitor_words);
 
       // Zero the new monitor so the interpreter can find it.
-      ((BasicObjectLock *) istate->stack_base())->set_obj(NULL);
+      ((BasicObjectLock *) istate->stack_base())->set_obj(nullptr);
 
       // Resume the interpreter
       istate->set_msg(BytecodeInterpreter::got_monitors);
@@ -327,7 +327,7 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
 
   // Lock if necessary
   BasicObjectLock *monitor;
-  monitor = NULL;
+  monitor = nullptr;
   if (method->is_synchronized()) {
     monitor = (BasicObjectLock*) istate->stack_base();
     oop lockee = monitor->obj();
@@ -338,7 +338,7 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
     if (call_vm || lockee->cas_set_mark(markWord::from_pointer(monitor), disp) != disp) {
       // Is it simple recursive case?
       if (!call_vm && thread->is_lock_owned((address) disp.clear_lock_bits().to_pointer())) {
-        monitor->lock()->set_displaced_header(markWord::from_pointer(NULL));
+        monitor->lock()->set_displaced_header(markWord::from_pointer(nullptr));
       } else {
         inc_monitor_count = false;
         CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
@@ -354,17 +354,17 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
   // Get the signature handler
   InterpreterRuntime::SignatureHandler *handler; {
     address handlerAddr = method->signature_handler();
-    if (handlerAddr == NULL) {
+    if (handlerAddr == nullptr) {
       CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method));
       if (HAS_PENDING_EXCEPTION)
         goto unlock_unwind_and_return;
 
       handlerAddr = method->signature_handler();
-      assert(handlerAddr != NULL, "eh?");
+      assert(handlerAddr != nullptr, "eh?");
     }
     if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) {
       CALL_VM_NOCHECK(handlerAddr =
-        InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL));
+        InterpreterRuntime::slow_signature_handler(thread, method, nullptr,nullptr));
       if (HAS_PENDING_EXCEPTION)
         goto unlock_unwind_and_return;
     }
@@ -375,7 +375,7 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
   // Get the native function entry point
   address function;
   function = method->native_function();
-  assert(function != NULL, "should be set if signature handler is");
+  assert(function != nullptr, "should be set if signature handler is");
 
   // Build the argument list
   stack->overflow_check(handler->argument_count() * 2, THREAD);
@@ -465,7 +465,7 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
   // we release the handle it might be protected by.
   if (handler->result_type() == &ffi_type_pointer) {
     if (result[0] == 0) {
-      istate->set_oop_temp(NULL);
+      istate->set_oop_temp(nullptr);
     } else {
       jobject handle = reinterpret_cast<jobject>(result[0]);
       istate->set_oop_temp(JNIHandles::resolve(handle));
@@ -482,10 +482,10 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
     BasicLock *lock = monitor->lock();
     markWord header = lock->displaced_header();
     oop rcvr = monitor->obj();
-    monitor->set_obj(NULL);
+    monitor->set_obj(nullptr);
 
     bool dec_monitor_count = true;
-    if (header.to_pointer() != NULL) {
+    if (header.to_pointer() != nullptr) {
       markWord old_header = markWord::encode(lock);
       if (rcvr->cas_set_mark(header, old_header) != old_header) {
         monitor->set_obj(rcvr);
@@ -616,7 +616,7 @@ int ZeroInterpreter::getter_entry(Method* method, intptr_t UNUSED, TRAPS) {
   // Load the object pointer and drop into the slow path
   // if we have a NullPointerException
   oop object = STACK_OBJECT(0);
-  if (object == NULL) {
+  if (object == nullptr) {
     return normal_entry(method, 0, THREAD);
   }
 
@@ -706,7 +706,7 @@ int ZeroInterpreter::setter_entry(Method* method, intptr_t UNUSED, TRAPS) {
 
   // Figure out where the receiver is. If there is a long/double
   // operand on stack top, then receiver is two slots down.
-  oop object = NULL;
+  oop object = nullptr;
   switch (entry->flag_state()) {
     case ltos:
     case dtos:
@@ -719,7 +719,7 @@ int ZeroInterpreter::setter_entry(Method* method, intptr_t UNUSED, TRAPS) {
 
   // Load the receiver pointer and drop into the slow path
   // if we have a NullPointerException
-  if (object == NULL) {
+  if (object == nullptr) {
     return normal_entry(method, 0, THREAD);
   }
 
@@ -825,13 +825,13 @@ InterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) {
   istate->set_method(method);
   istate->set_mirror(method->method_holder()->java_mirror());
   istate->set_self_link(istate);
-  istate->set_prev_link(NULL);
+  istate->set_prev_link(nullptr);
   istate->set_thread(thread);
-  istate->set_bcp(method->is_native() ? NULL : method->code_base());
+  istate->set_bcp(method->is_native() ? nullptr : method->code_base());
   istate->set_constants(method->constants()->cache());
   istate->set_msg(BytecodeInterpreter::method_entry);
-  istate->set_oop_temp(NULL);
-  istate->set_callee(NULL);
+  istate->set_oop_temp(nullptr);
+  istate->set_callee(nullptr);
 
   istate->set_monitor_base((BasicObjectLock *) stack->sp());
   if (method->is_synchronized()) {
@@ -872,7 +872,7 @@ InterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
   interpreterState istate =
     (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
   assert(fp - stack->sp() == istate_off, "should be");
-  istate->set_self_link(NULL); // mark invalid
+  istate->set_self_link(nullptr); // mark invalid
 
   stack->alloc((size_in_words - header_words) * wordSize);
 
@@ -881,11 +881,11 @@ InterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
 
 address ZeroInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
   ShouldNotCallThis();
-  return NULL;
+  return nullptr;
 }
 
 address ZeroInterpreter::deopt_entry(TosState state, int length) {
-  return NULL;
+  return nullptr;
 }
 
 address ZeroInterpreter::remove_activation_preserving_args_entry() {
@@ -895,7 +895,7 @@ address ZeroInterpreter::remove_activation_preserving_args_entry() {
 }
 
 address ZeroInterpreter::remove_activation_early_entry(TosState state) {
-  return NULL;
+  return nullptr;
 }
 
 // Helper for figuring out if frames are interpreter frames
diff --git a/src/hotspot/os/posix/gc/z/zUtils_posix.cpp b/src/hotspot/os/posix/gc/z/zUtils_posix.cpp
index f1cffcde13f..dc5af2b973a 100644
--- a/src/hotspot/os/posix/gc/z/zUtils_posix.cpp
+++ b/src/hotspot/os/posix/gc/z/zUtils_posix.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 #include <stdlib.h>
 
 uintptr_t ZUtils::alloc_aligned(size_t alignment, size_t size) {
-  void* res = NULL;
+  void* res = nullptr;
 
   // Use raw posix_memalign as long as we have no wrapper for it
   ALLOW_C_FUNCTION(::posix_memalign, int rc = posix_memalign(&res, alignment, size);)
diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp
index 1e0ac60e063..cf0f489740f 100644
--- a/src/hotspot/os/posix/os_posix.cpp
+++ b/src/hotspot/os/posix/os_posix.cpp
@@ -159,8 +159,8 @@ int os::get_native_stack(address* stack, int frames, int toSkip) {
     } else {
       stack[frame_idx ++] = fr.pc();
     }
-    if (fr.fp() == NULL || fr.cb() != NULL ||
-        fr.sender_pc() == NULL || os::is_first_C_frame(&fr)) break;
+    if (fr.fp() == nullptr || fr.cb() != nullptr ||
+        fr.sender_pc() == nullptr || os::is_first_C_frame(&fr)) break;
 
     if (fr.sender_pc() && !os::is_first_C_frame(&fr)) {
       fr = os::get_sender_for_C_frame(&fr);
@@ -170,7 +170,7 @@ int os::get_native_stack(address* stack, int frames, int toSkip) {
   }
   num_of_frames = frame_idx;
   for (; frame_idx < frames; frame_idx ++) {
-    stack[frame_idx] = NULL;
+    stack[frame_idx] = nullptr;
   }
 
   return num_of_frames;
@@ -209,7 +209,7 @@ int os::create_file_for_heap(const char* dir) {
 
 #if defined(LINUX) && defined(O_TMPFILE)
   char* native_dir = os::strdup(dir);
-  if (native_dir == NULL) {
+  if (native_dir == nullptr) {
     vm_exit_during_initialization(err_msg("strdup failed during creation of backing file for heap (%s)", os::strerror(errno)));
     return -1;
   }
@@ -224,7 +224,7 @@ int os::create_file_for_heap(const char* dir) {
 
     size_t fullname_len = strlen(dir) + strlen(name_template);
     char *fullname = (char*)os::malloc(fullname_len + 1, mtInternal);
-    if (fullname == NULL) {
+    if (fullname == nullptr) {
       vm_exit_during_initialization(err_msg("Malloc failed during creation of backing file for heap (%s)", os::strerror(errno)));
       return -1;
     }
@@ -254,15 +254,15 @@ int os::create_file_for_heap(const char* dir) {
 
 // Is a (classpath) directory empty?
 bool os::dir_is_empty(const char* path) {
-  DIR *dir = NULL;
+  DIR *dir = nullptr;
   struct dirent *ptr;
 
   dir = ::opendir(path);
-  if (dir == NULL) return true;
+  if (dir == nullptr) return true;
 
   // Scan the directory
   bool result = true;
-  while (result && (ptr = ::readdir(dir)) != NULL) {
+  while (result && (ptr = ::readdir(dir)) != nullptr) {
     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
       result = false;
     }
@@ -274,7 +274,7 @@ bool os::dir_is_empty(const char* path) {
 static char* reserve_mmapped_memory(size_t bytes, char* requested_addr) {
   char * addr;
   int flags = MAP_PRIVATE NOT_AIX( | MAP_NORESERVE ) | MAP_ANONYMOUS;
-  if (requested_addr != NULL) {
+  if (requested_addr != nullptr) {
     assert((uintptr_t)requested_addr % os::vm_page_size() == 0, "Requested address should be aligned to OS page size");
     flags |= MAP_FIXED;
   }
@@ -289,7 +289,7 @@ static char* reserve_mmapped_memory(size_t bytes, char* requested_addr) {
     MemTracker::record_virtual_memory_reserve((address)addr, bytes, CALLER_PC);
     return addr;
   }
-  return NULL;
+  return nullptr;
 }
 
 static int util_posix_fallocate(int fd, off_t offset, off_t len) {
@@ -319,32 +319,32 @@ char* os::map_memory_to_file(char* base, size_t size, int fd) {
   int ret = util_posix_fallocate(fd, 0, (off_t)size);
   if (ret != 0) {
     vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory. error(%d)", ret));
-    return NULL;
+    return nullptr;
   }
 
   int prot = PROT_READ | PROT_WRITE;
   int flags = MAP_SHARED;
-  if (base != NULL) {
+  if (base != nullptr) {
     flags |= MAP_FIXED;
   }
   char* addr = (char*)mmap(base, size, prot, flags, fd, 0);
 
   if (addr == MAP_FAILED) {
     warning("Failed mmap to file. (%s)", os::strerror(errno));
-    return NULL;
+    return nullptr;
   }
-  if (base != NULL && addr != base) {
+  if (base != nullptr && addr != base) {
     if (!os::release_memory(addr, size)) {
       warning("Could not release memory on unsuccessful file mapping");
     }
-    return NULL;
+    return nullptr;
   }
   return addr;
 }
 
 char* os::replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd) {
   assert(fd != -1, "File descriptor is not valid");
-  assert(base != NULL, "Base cannot be NULL");
+  assert(base != nullptr, "Base cannot be null");
 
   return map_memory_to_file(base, size, fd);
 }
@@ -391,8 +391,8 @@ static char* chop_extra_memory(size_t size, size_t alignment, char* extra_base,
 char* os::reserve_memory_aligned(size_t size, size_t alignment, bool exec) {
   size_t extra_size = calculate_aligned_extra_size(size, alignment);
   char* extra_base = os::reserve_memory(extra_size, exec);
-  if (extra_base == NULL) {
-    return NULL;
+  if (extra_base == nullptr) {
+    return nullptr;
   }
   return chop_extra_memory(size, alignment, extra_base, extra_size);
 }
@@ -405,13 +405,13 @@ char* os::map_memory_to_file_aligned(size_t size, size_t alignment, int file_des
   // - The memory API os::reserve_memory uses is an implementation detail. It may (and usually is)
   //   mmap but it also may System V shared memory which cannot be uncommitted as a whole, so
   //   chopping off and unmapping excess bits back and front (see below) would not work.
-  char* extra_base = reserve_mmapped_memory(extra_size, NULL);
-  if (extra_base == NULL) {
-    return NULL;
+  char* extra_base = reserve_mmapped_memory(extra_size, nullptr);
+  if (extra_base == nullptr) {
+    return nullptr;
   }
   char* aligned_base = chop_extra_memory(size, alignment, extra_base, extra_size);
   // After we have an aligned address, we can replace anonymous mapping with file mapping
-  if (replace_existing_mapping_with_file_mapping(aligned_base, size, file_desc) == NULL) {
+  if (replace_existing_mapping_with_file_mapping(aligned_base, size, file_desc) == nullptr) {
     vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory"));
   }
   MemTracker::record_virtual_memory_commit((address)aligned_base, size, CALLER_PC);
@@ -454,7 +454,7 @@ void os::Posix::print_load_average(outputStream* st) {
 // for reboot at least on my test machines
 void os::Posix::print_uptime_info(outputStream* st) {
   int bootsec = -1;
-  int currsec = time(NULL);
+  int currsec = time(nullptr);
   struct utmpx* ent;
   setutxent();
   while ((ent = getutxent())) {
@@ -593,14 +593,14 @@ void os::print_active_locale(outputStream* st) {
   #define XX(cat) { cat, #cat },
   const struct { int c; const char* name; } categories[] = {
       LOCALE_CAT_DO(XX)
-      { -1, NULL }
+      { -1, nullptr }
   };
   #undef XX
   #undef LOCALE_CAT_DO
   for (int i = 0; categories[i].c != -1; i ++) {
-    const char* locale = setlocale(categories[i].c, NULL);
+    const char* locale = setlocale(categories[i].c, nullptr);
     st->print_cr("%s=%s", categories[i].name,
-                 ((locale != NULL) ? locale : "<unknown>"));
+                 ((locale != nullptr) ? locale : "<unknown>"));
   }
 }
 
@@ -627,7 +627,7 @@ static bool is_allocatable(size_t s) {
   }
   // Use raw anonymous mmap here; no need to go through any
   // of our reservation layers. We will unmap right away.
-  void* p = ::mmap(NULL, s, PROT_NONE,
+  void* p = ::mmap(nullptr, s, PROT_NONE,
                    MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS, -1, 0);
   if (p == MAP_FAILED) {
     return false;
@@ -708,9 +708,9 @@ void* os::get_default_process_handle() {
   // MacOS X needs to use RTLD_FIRST instead of RTLD_LAZY
   // to avoid finding unexpected symbols on second (or later)
   // loads of a library.
-  return (void*)::dlopen(NULL, RTLD_FIRST);
+  return (void*)::dlopen(nullptr, RTLD_FIRST);
 #else
-  return (void*)::dlopen(NULL, RTLD_LAZY);
+  return (void*)::dlopen(nullptr, RTLD_LAZY);
 #endif
 }
 
@@ -722,30 +722,30 @@ void os::dll_unload(void *lib) {
   // os::Linux::dll_path returns a pointer to a string that is owned by the dynamic loader. Upon
   // calling dlclose the dynamic loader may free the memory containing the string, thus we need to
   // copy the string to be able to reference it after dlclose.
-  const char* l_path = NULL;
+  const char* l_path = nullptr;
 #ifdef LINUX
-  char* l_pathdup = NULL;
+  char* l_pathdup = nullptr;
   l_path = os::Linux::dll_path(lib);
-  if (l_path != NULL) {
+  if (l_path != nullptr) {
     l_path = l_pathdup = os::strdup(l_path);
   }
 #endif  // LINUX
-  if (l_path == NULL) {
+  if (l_path == nullptr) {
     l_path = "<not available>";
   }
   int res = ::dlclose(lib);
 
   if (res == 0) {
-    Events::log_dll_message(NULL, "Unloaded shared library \"%s\" [" INTPTR_FORMAT "]",
+    Events::log_dll_message(nullptr, "Unloaded shared library \"%s\" [" INTPTR_FORMAT "]",
                             l_path, p2i(lib));
     log_info(os)("Unloaded shared library \"%s\" [" INTPTR_FORMAT "]", l_path, p2i(lib));
   } else {
     const char* error_report = ::dlerror();
-    if (error_report == NULL) {
+    if (error_report == nullptr) {
       error_report = "dlerror returned no error description";
     }
 
-    Events::log_dll_message(NULL, "Attempt to unload shared library \"%s\" [" INTPTR_FORMAT "] failed, %s",
+    Events::log_dll_message(nullptr, "Attempt to unload shared library \"%s\" [" INTPTR_FORMAT "] failed, %s",
                             l_path, p2i(lib), error_report);
     log_info(os)("Attempt to unload shared library \"%s\" [" INTPTR_FORMAT "] failed, %s",
                   l_path, p2i(lib), error_report);
@@ -790,17 +790,17 @@ void os::funlockfile(FILE* fp) {
 }
 
 DIR* os::opendir(const char* dirname) {
-  assert(dirname != NULL, "just checking");
+  assert(dirname != nullptr, "just checking");
   return ::opendir(dirname);
 }
 
 struct dirent* os::readdir(DIR* dirp) {
-  assert(dirp != NULL, "just checking");
+  assert(dirp != nullptr, "just checking");
   return ::readdir(dirp);
 }
 
 int os::closedir(DIR *dirp) {
-  assert(dirp != NULL, "just checking");
+  assert(dirp != nullptr, "just checking");
   return ::closedir(dirp);
 }
 
@@ -840,7 +840,7 @@ void os::_exit(int num) {
 // which is used to find statically linked in agents.
 // Parameters:
 //            sym_name: Symbol in library we are looking for
-//            lib_name: Name of library to look in, NULL for shared libs.
+//            lib_name: Name of library to look in, null for shared libs.
 //            is_absolute_path == true if lib_name is absolute path to agent
 //                                     such as "/a/b/libL.so"
 //            == false if only the base name of the library is passed in
@@ -854,27 +854,27 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
   size_t suffix_len = strlen(JNI_LIB_SUFFIX);
   const char *start;
 
-  if (lib_name != NULL) {
+  if (lib_name != nullptr) {
     name_len = strlen(lib_name);
     if (is_absolute_path) {
       // Need to strip path, prefix and suffix
-      if ((start = strrchr(lib_name, *os::file_separator())) != NULL) {
+      if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) {
         lib_name = ++start;
       }
       if (strlen(lib_name) <= (prefix_len + suffix_len)) {
-        return NULL;
+        return nullptr;
       }
       lib_name += prefix_len;
       name_len = strlen(lib_name) - suffix_len;
     }
   }
-  len = (lib_name != NULL ? name_len : 0) + strlen(sym_name) + 2;
+  len = (lib_name != nullptr ? name_len : 0) + strlen(sym_name) + 2;
   agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread);
-  if (agent_entry_name == NULL) {
-    return NULL;
+  if (agent_entry_name == nullptr) {
+    return nullptr;
   }
   strcpy(agent_entry_name, sym_name);
-  if (lib_name != NULL) {
+  if (lib_name != nullptr) {
     strcat(agent_entry_name, "_");
     strncat(agent_entry_name, lib_name, name_len);
   }
@@ -893,7 +893,7 @@ void os::naked_short_nanosleep(jlong ns) {
   assert(ns > -1 && ns < NANOUNITS, "Un-interruptable sleep, short time use only");
   req.tv_sec = 0;
   req.tv_nsec = ns;
-  ::nanosleep(&req, NULL);
+  ::nanosleep(&req, nullptr);
   return;
 }
 
@@ -920,19 +920,19 @@ char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_a
 
 char* os::Posix::realpath(const char* filename, char* outbuf, size_t outbuflen) {
 
-  if (filename == NULL || outbuf == NULL || outbuflen < 1) {
+  if (filename == nullptr || outbuf == nullptr || outbuflen < 1) {
     assert(false, "os::Posix::realpath: invalid arguments.");
     errno = EINVAL;
-    return NULL;
+    return nullptr;
   }
 
-  char* result = NULL;
+  char* result = nullptr;
 
   // This assumes platform realpath() is implemented according to POSIX.1-2008.
-  // POSIX.1-2008 allows to specify NULL for the output buffer, in which case
+  // POSIX.1-2008 allows to specify null for the output buffer, in which case
   // output buffer is dynamically allocated and must be ::free()'d by the caller.
-  ALLOW_C_FUNCTION(::realpath, char* p = ::realpath(filename, NULL);)
-  if (p != NULL) {
+  ALLOW_C_FUNCTION(::realpath, char* p = ::realpath(filename, nullptr);)
+  if (p != nullptr) {
     if (strlen(p) < outbuflen) {
       strcpy(outbuf, p);
       result = outbuf;
@@ -943,13 +943,13 @@ char* os::Posix::realpath(const char* filename, char* outbuf, size_t outbuflen)
   } else {
     // Fallback for platforms struggling with modern Posix standards (AIX 5.3, 6.1). If realpath
     // returns EINVAL, this may indicate that realpath is not POSIX.1-2008 compatible and
-    // that it complains about the NULL we handed down as user buffer.
+    // that it complains about the null we handed down as user buffer.
     // In this case, use the user provided buffer but at least check whether realpath caused
     // a memory overwrite.
     if (errno == EINVAL) {
       outbuf[outbuflen - 1] = '\0';
       ALLOW_C_FUNCTION(::realpath, p = ::realpath(filename, outbuf);)
-      if (p != NULL) {
+      if (p != nullptr) {
         guarantee(outbuf[outbuflen - 1] == '\0', "realpath buffer overwrite detected.");
         result = p;
       }
@@ -1071,7 +1071,7 @@ static bool get_frame_at_stack_banging_point(JavaThread* thread, address pc, con
     // more complex code with compiled code
     assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
     CodeBlob* cb = CodeCache::find_blob(pc);
-    if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
+    if (cb == nullptr || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
       // Not sure where the pc points to, fallback to default
       // stack overflow handling
       return false;
@@ -1107,7 +1107,7 @@ bool os::Posix::handle_stack_overflow(JavaThread* thread, address addr, address
           assert(fr.is_java_frame(), "Must be a Java frame");
           frame activation =
             SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
-          if (activation.sp() != NULL) {
+          if (activation.sp() != nullptr) {
             overflow_state->disable_stack_reserved_zone();
             if (activation.is_interpreted_frame()) {
               overflow_state->set_reserved_stack_activation((address)(activation.fp()
@@ -1211,7 +1211,7 @@ static void pthread_init_common(void) {
   PlatformMutex::init();
 }
 
-static int (*_pthread_condattr_setclock)(pthread_condattr_t *, clockid_t) = NULL;
+static int (*_pthread_condattr_setclock)(pthread_condattr_t *, clockid_t) = nullptr;
 
 static bool _use_clock_monotonic_condattr = false;
 
@@ -1232,7 +1232,7 @@ void os::Posix::init(void) {
   int (*condattr_setclock_func)(pthread_condattr_t*, clockid_t) =
     (int (*)(pthread_condattr_t*, clockid_t))dlsym(RTLD_DEFAULT,
                                                    "pthread_condattr_setclock");
-  if (condattr_setclock_func != NULL) {
+  if (condattr_setclock_func != nullptr) {
     _pthread_condattr_setclock = condattr_setclock_func;
   }
 
@@ -1241,7 +1241,7 @@ void os::Posix::init(void) {
   pthread_init_common();
 
   int status;
-  if (_pthread_condattr_setclock != NULL) {
+  if (_pthread_condattr_setclock != nullptr) {
     if ((status = _pthread_condattr_setclock(_condAttr, CLOCK_MONOTONIC)) != 0) {
       if (status == EINVAL) {
         _use_clock_monotonic_condattr = false;
@@ -1261,7 +1261,7 @@ void os::Posix::init(void) {
 void os::Posix::init_2(void) {
   log_info(os)("Use of CLOCK_MONOTONIC is supported");
   log_info(os)("Use of pthread_condattr_setclock is%s supported",
-               (_pthread_condattr_setclock != NULL ? "" : " not"));
+               (_pthread_condattr_setclock != nullptr ? "" : " not"));
   log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with %s",
                _use_clock_monotonic_condattr ? "CLOCK_MONOTONIC" : "the default clock");
 }
@@ -1639,7 +1639,7 @@ void PlatformEvent::unpark() {
  PlatformParker::PlatformParker() : _counter(0), _cur_index(-1) {
   int status = pthread_cond_init(&_cond[REL_INDEX], _condAttr);
   assert_status(status == 0, status, "cond_init rel");
-  status = pthread_cond_init(&_cond[ABS_INDEX], NULL);
+  status = pthread_cond_init(&_cond[ABS_INDEX], nullptr);
   assert_status(status == 0, status, "cond_init abs");
   status = pthread_mutex_init(_mutex, _mutexAttr);
   assert_status(status == 0, status, "mutex_init");
@@ -1767,7 +1767,7 @@ void Parker::unpark() {
 
 #if PLATFORM_MONITOR_IMPL_INDIRECT
 
-PlatformMutex::Mutex::Mutex() : _next(NULL) {
+PlatformMutex::Mutex::Mutex() : _next(nullptr) {
   int status = pthread_mutex_init(&_mutex, _mutexAttr);
   assert_status(status == 0, status, "mutex_init");
 }
@@ -1778,7 +1778,7 @@ PlatformMutex::Mutex::~Mutex() {
 }
 
 pthread_mutex_t PlatformMutex::_freelist_lock;
-PlatformMutex::Mutex* PlatformMutex::_mutex_freelist = NULL;
+PlatformMutex::Mutex* PlatformMutex::_mutex_freelist = nullptr;
 
 void PlatformMutex::init() {
   int status = pthread_mutex_init(&_freelist_lock, _mutexAttr);
@@ -1801,9 +1801,9 @@ PlatformMutex::PlatformMutex() {
   {
     WithFreeListLocked wfl;
     _impl = _mutex_freelist;
-    if (_impl != NULL) {
+    if (_impl != nullptr) {
       _mutex_freelist = _impl->_next;
-      _impl->_next = NULL;
+      _impl->_next = nullptr;
       return;
     }
   }
@@ -1812,12 +1812,12 @@ PlatformMutex::PlatformMutex() {
 
 PlatformMutex::~PlatformMutex() {
   WithFreeListLocked wfl;
-  assert(_impl->_next == NULL, "invariant");
+  assert(_impl->_next == nullptr, "invariant");
   _impl->_next = _mutex_freelist;
   _mutex_freelist = _impl;
 }
 
-PlatformMonitor::Cond::Cond() : _next(NULL) {
+PlatformMonitor::Cond::Cond() : _next(nullptr) {
   int status = pthread_cond_init(&_cond, _condAttr);
   assert_status(status == 0, status, "cond_init");
 }
@@ -1827,15 +1827,15 @@ PlatformMonitor::Cond::~Cond() {
   assert_status(status == 0, status, "cond_destroy");
 }
 
-PlatformMonitor::Cond* PlatformMonitor::_cond_freelist = NULL;
+PlatformMonitor::Cond* PlatformMonitor::_cond_freelist = nullptr;
 
 PlatformMonitor::PlatformMonitor() {
   {
     WithFreeListLocked wfl;
     _impl = _cond_freelist;
-    if (_impl != NULL) {
+    if (_impl != nullptr) {
       _cond_freelist = _impl->_next;
-      _impl->_next = NULL;
+      _impl->_next = nullptr;
       return;
     }
   }
@@ -1844,7 +1844,7 @@ PlatformMonitor::PlatformMonitor() {
 
 PlatformMonitor::~PlatformMonitor() {
   WithFreeListLocked wfl;
-  assert(_impl->_next == NULL, "invariant");
+  assert(_impl->_next == nullptr, "invariant");
   _impl->_next = _cond_freelist;
   _cond_freelist = _impl;
 }
@@ -1918,13 +1918,13 @@ char** os::get_environ() { return environ; }
 //        -this function is unsafe to use in non-error situations, mainly
 //         because the child process will inherit all parent descriptors.
 int os::fork_and_exec(const char* cmd) {
-  const char* argv[4] = {"sh", "-c", cmd, NULL};
+  const char* argv[4] = {"sh", "-c", cmd, nullptr};
   pid_t pid = -1;
   char** env = os::get_environ();
   // Note: cast is needed because posix_spawn() requires - for compatibility with ancient
   // C-code - a non-const argv/envp pointer array. But it is fine to hand in literal
   // strings and just cast the constness away. See also ProcessImpl_md.c.
-  int rc = ::posix_spawn(&pid, "/bin/sh", NULL, NULL, (char**) argv, env);
+  int rc = ::posix_spawn(&pid, "/bin/sh", nullptr, nullptr, (char**) argv, env);
   if (rc == 0) {
     int status;
     // Wait for the child process to exit.  This returns immediately if
@@ -1994,7 +1994,7 @@ void os::shutdown() {
 
   // Check for abort hook
   abort_hook_t abort_hook = Arguments::abort_hook();
-  if (abort_hook != NULL) {
+  if (abort_hook != nullptr) {
     abort_hook();
   }
 
diff --git a/src/hotspot/os/posix/os_posix.hpp b/src/hotspot/os/posix/os_posix.hpp
index f8bf60c775a..051b23d51bd 100644
--- a/src/hotspot/os/posix/os_posix.hpp
+++ b/src/hotspot/os/posix/os_posix.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,8 +76,8 @@ class os::Posix {
   // A safe implementation of realpath which will not cause a buffer overflow if the resolved path
   //   is longer than PATH_MAX.
   // On success, returns 'outbuf', which now contains the path.
-  // On error, it will return NULL and set errno. The content of 'outbuf' is undefined.
-  // On truncation error ('outbuf' too small), it will return NULL and set errno to ENAMETOOLONG.
+  // On error, it will return null and set errno. The content of 'outbuf' is undefined.
+  // On truncation error ('outbuf' too small), it will return null and set errno to ENAMETOOLONG.
   static char* realpath(const char* filename, char* outbuf, size_t outbuflen);
 
   // Returns true if given uid is root.
diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp
index 598955cbdfb..0e6e193b950 100644
--- a/src/hotspot/os/posix/perfMemory_posix.cpp
+++ b/src/hotspot/os/posix/perfMemory_posix.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2021 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -55,7 +55,7 @@
 # include <sys/file.h>
 #endif
 
-static char* backing_store_file_name = NULL;  // name of the backing store
+static char* backing_store_file_name = nullptr;  // name of the backing store
                                               // file, if successfully created.
 
 // Standard Memory Implementation Details
@@ -67,8 +67,8 @@ static char* create_standard_memory(size_t size) {
   // allocate an aligned chuck of memory
   char* mapAddress = os::reserve_memory(size);
 
-  if (mapAddress == NULL) {
-    return NULL;
+  if (mapAddress == nullptr) {
+    return nullptr;
   }
 
   // commit memory
@@ -77,7 +77,7 @@ static char* create_standard_memory(size_t size) {
       warning("Could not commit PerfData memory\n");
     }
     os::release_memory(mapAddress, size);
-    return NULL;
+    return nullptr;
   }
 
   return mapAddress;
@@ -183,7 +183,7 @@ static pid_t filename_to_pid(const char* filename) {
   // check if file name can be converted to an integer without
   // any leftover characters.
   //
-  char* remainder = NULL;
+  char* remainder = nullptr;
   errno = 0;
   pid_t pid = (pid_t)strtol(filename, &remainder, 10);
 
@@ -194,7 +194,7 @@ static pid_t filename_to_pid(const char* filename) {
   // check for left over characters. If any, then the filename is
   // not a candidate for conversion.
   //
-  if (remainder != NULL && *remainder != '\0') {
+  if (remainder != nullptr && *remainder != '\0') {
     return 0;
   }
 
@@ -307,7 +307,7 @@ static DIR *open_directory_secure(const char* dirname) {
   // introduce a window of opportunity for the directory to be attacked that
   // calling opendir() and is_directory_secure() does.
   int result;
-  DIR *dirp = NULL;
+  DIR *dirp = nullptr;
   RESTARTABLE(::open(dirname, O_RDONLY|O_NOFOLLOW), result);
   if (result == OS_ERR) {
     // Directory doesn't exist or is a symlink, so there is nothing to cleanup.
@@ -331,7 +331,7 @@ static DIR *open_directory_secure(const char* dirname) {
 
   // Open the directory.
   dirp = ::opendir(dirname);
-  if (dirp == NULL) {
+  if (dirp == nullptr) {
     // The directory doesn't exist, close fd and return.
     ::close(fd);
     return dirp;
@@ -342,7 +342,7 @@ static DIR *open_directory_secure(const char* dirname) {
     // The directory is not secure.
     ::close(fd);
     os::closedir(dirp);
-    dirp = NULL;
+    dirp = nullptr;
     return dirp;
   }
 
@@ -366,7 +366,7 @@ static DIR *open_directory_secure_cwd(const char* dirname, int *saved_cwd_fd) {
 
   // Open the directory.
   DIR* dirp = open_directory_secure(dirname);
-  if (dirp == NULL) {
+  if (dirp == nullptr) {
     // Directory doesn't exist or is insecure, so there is nothing to cleanup.
     return dirp;
   }
@@ -394,7 +394,7 @@ static DIR *open_directory_secure_cwd(const char* dirname, int *saved_cwd_fd) {
     }
     // Close the directory.
     os::closedir(dirp);
-    return NULL;
+    return nullptr;
   } else {
     return dirp;
   }
@@ -457,19 +457,19 @@ static char* get_user_name(uid_t uid) {
 
   char* pwbuf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
 
-  struct passwd* p = NULL;
+  struct passwd* p = nullptr;
   int result = getpwuid_r(uid, &pwent, pwbuf, (size_t)bufsize, &p);
 
-  if (result != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') {
+  if (result != 0 || p == nullptr || p->pw_name == nullptr || *(p->pw_name) == '\0') {
     if (PrintMiscellaneous && Verbose) {
       if (result != 0) {
         warning("Could not retrieve passwd entry: %s\n",
                 os::strerror(result));
       }
-      else if (p == NULL) {
+      else if (p == nullptr) {
         // this check is added to protect against an observed problem
         // with getpwuid_r() on RedHat 9 where getpwuid_r returns 0,
-        // indicating success, but has p == NULL. This was observed when
+        // indicating success, but has p == nullptr. This was observed when
         // inserting a file descriptor exhaustion fault prior to the call
         // getpwuid_r() call. In this case, error is set to the appropriate
         // error condition, but this is undocumented behavior. This check
@@ -482,12 +482,12 @@ static char* get_user_name(uid_t uid) {
       }
       else {
         warning("Could not determine user name: %s\n",
-                p->pw_name == NULL ? "pw_name = NULL" :
+                p->pw_name == nullptr ? "pw_name = null" :
                                      "pw_name zero length");
       }
     }
     FREE_C_HEAP_ARRAY(char, pwbuf);
-    return NULL;
+    return nullptr;
   }
 
   char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1, mtInternal);
@@ -520,7 +520,7 @@ static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
   }
 
   // directory search
-  char* oldest_user = NULL;
+  char* oldest_user = nullptr;
   time_t oldest_ctime = 0;
   int searchpid;
   char* tmpdirname = (char *)os::get_temp_directory();
@@ -544,9 +544,9 @@ static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
   // open the temp directory
   DIR* tmpdirp = os::opendir(tmpdirname);
 
-  if (tmpdirp == NULL) {
+  if (tmpdirp == nullptr) {
     // Cannot open the directory to get the user name, return.
-    return NULL;
+    return nullptr;
   }
 
   // for each entry in the directory that matches the pattern hsperfdata_*,
@@ -556,7 +556,7 @@ static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
   //
   struct dirent* dentry;
   errno = 0;
-  while ((dentry = os::readdir(tmpdirp)) != NULL) {
+  while ((dentry = os::readdir(tmpdirp)) != nullptr) {
 
     // check if the directory entry is a hsperfdata file
     if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
@@ -573,7 +573,7 @@ static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
     // open the user directory
     DIR* subdirp = open_directory_secure(usrdir_name);
 
-    if (subdirp == NULL) {
+    if (subdirp == nullptr) {
       FREE_C_HEAP_ARRAY(char, usrdir_name);
       continue;
     }
@@ -592,7 +592,7 @@ static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
 
     struct dirent* udentry;
     errno = 0;
-    while ((udentry = os::readdir(subdirp)) != NULL) {
+    while ((udentry = os::readdir(subdirp)) != nullptr) {
 
       if (filename_to_pid(udentry->d_name) == searchpid) {
         struct stat statbuf;
@@ -652,10 +652,10 @@ static char* get_user_name(int vmid, int *nspid, TRAPS) {
 #if defined(LINUX)
   // If we are examining a container process without PID namespaces enabled
   // we need to use /proc/{pid}/root/tmp to find hsperfdata files.
-  if (result == NULL) {
+  if (result == nullptr) {
     result = get_user_name_slow(vmid, vmid, CHECK_NULL);
     // Enable nspid logic going forward
-    if (result != NULL) *nspid = vmid;
+    if (result != nullptr) *nspid = vmid;
   }
 #endif
   return result;
@@ -717,7 +717,7 @@ static void cleanup_sharedmem_files(const char* dirname) {
   int saved_cwd_fd;
   // open the directory and set the current working directory to it
   DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
-  if (dirp == NULL) {
+  if (dirp == nullptr) {
     // directory doesn't exist or is insecure, so there is nothing to cleanup
     return;
   }
@@ -731,7 +731,7 @@ static void cleanup_sharedmem_files(const char* dirname) {
   //
   struct dirent* entry;
   errno = 0;
-  while ((entry = os::readdir(dirp)) != NULL) {
+  while ((entry = os::readdir(dirp)) != nullptr) {
     const char* filename = entry->d_name;
     pid_t pid = filename_to_pid(filename);
 
@@ -874,7 +874,7 @@ static int create_sharedmem_file(const char* dirname, const char* filename, size
   int saved_cwd_fd;
   // open the directory and set the current working directory to it
   DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
-  if (dirp == NULL) {
+  if (dirp == nullptr) {
     // Directory doesn't exist or is insecure, so cannot create shared
     // memory file.
     return -1;
@@ -1013,8 +1013,8 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
 }
 
 // create a named shared memory region. returns the address of the
-// memory region on success or NULL on failure. A return value of
-// NULL will ultimately disable the shared memory feature.
+// memory region on success or null on failure. A return value of
+// null will ultimately disable the shared memory feature.
 //
 // The name space for shared memory objects is the file system name space.
 //
@@ -1034,15 +1034,15 @@ static char* mmap_create_shared(size_t size) {
 
   char* user_name = get_user_name(geteuid());
 
-  if (user_name == NULL)
-    return NULL;
+  if (user_name == nullptr)
+    return nullptr;
 
   char* dirname = get_user_tmp_dir(user_name, vmid, -1);
   char* filename = get_sharedmem_filename(dirname, vmid, -1);
 
   // get the short filename
   char* short_filename = strrchr(filename, '/');
-  if (short_filename == NULL) {
+  if (short_filename == nullptr) {
     short_filename = filename;
   } else {
     short_filename++;
@@ -1062,7 +1062,7 @@ static char* mmap_create_shared(size_t size) {
 
   if (fd == -1) {
     FREE_C_HEAP_ARRAY(char, filename);
-    return NULL;
+    return nullptr;
   }
 
   mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
@@ -1076,7 +1076,7 @@ static char* mmap_create_shared(size_t size) {
     }
     remove_file(filename);
     FREE_C_HEAP_ARRAY(char, filename);
-    return NULL;
+    return nullptr;
   }
 
   // save the file name for use in delete_shared_memory()
@@ -1131,12 +1131,12 @@ static void delete_shared_memory(char* addr, size_t size) {
 
   assert(!PerfDisableSharedMem, "shouldn't be here");
 
-  if (backing_store_file_name != NULL) {
+  if (backing_store_file_name != nullptr) {
     remove_file(backing_store_file_name);
     // Don't.. Free heap memory could deadlock os::abort() if it is called
     // from signal handler. OS will reclaim the heap memory.
     // FREE_C_HEAP_ARRAY(char, backing_store_file_name);
-    backing_store_file_name = NULL;
+    backing_store_file_name = nullptr;
   }
 }
 
@@ -1177,7 +1177,7 @@ static void mmap_attach_shared(int vmid, char** addr, size_t* sizep, TRAPS) {
   int nspid = LINUX_ONLY(os::Linux::get_namespace_pid(vmid)) NOT_LINUX(-1);
   const char* luser = get_user_name(vmid, &nspid, CHECK);
 
-  if (luser == NULL) {
+  if (luser == nullptr) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Could not map vmid to user Name");
   }
@@ -1258,7 +1258,7 @@ void PerfMemory::create_memory_region(size_t size) {
   }
   else {
     _start = create_shared_memory(size);
-    if (_start == NULL) {
+    if (_start == nullptr) {
 
       // creation of the shared memory region failed, attempt
       // to create a contiguous, non-shared memory region instead.
@@ -1271,7 +1271,7 @@ void PerfMemory::create_memory_region(size_t size) {
     }
   }
 
-  if (_start != NULL) _capacity = size;
+  if (_start != nullptr) _capacity = size;
 
 }
 
@@ -1283,13 +1283,13 @@ void PerfMemory::create_memory_region(size_t size) {
 //
 void PerfMemory::delete_memory_region() {
 
-  assert((start() != NULL && capacity() > 0), "verify proper state");
+  assert((start() != nullptr && capacity() > 0), "verify proper state");
 
   // If user specifies PerfDataSaveFile, it will save the performance data
   // to the specified file name no matter whether PerfDataSaveToFile is specified
   // or not. In other word, -XX:PerfDataSaveFile=.. overrides flag
   // -XX:+PerfDataSaveToFile.
-  if (PerfDataSaveToFile || PerfDataSaveFile != NULL) {
+  if (PerfDataSaveToFile || PerfDataSaveFile != nullptr) {
     save_memory_to_file(start(), capacity());
   }
 
diff --git a/src/hotspot/os/posix/safefetch_sigjmp.cpp b/src/hotspot/os/posix/safefetch_sigjmp.cpp
index 71b6d4445e8..e141b8fb573 100644
--- a/src/hotspot/os/posix/safefetch_sigjmp.cpp
+++ b/src/hotspot/os/posix/safefetch_sigjmp.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2022 SAP SE. All rights reserved.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 #include "precompiled.hpp"
 
 #include "runtime/safefetch.hpp"
+#include "sanitizers/address.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
 
@@ -36,7 +37,7 @@
 #include <pthread.h>
 static pthread_key_t g_jmpbuf_key;
 
-struct InitTLSKey { InitTLSKey() { pthread_key_create(&g_jmpbuf_key, NULL); } };
+struct InitTLSKey { InitTLSKey() { pthread_key_create(&g_jmpbuf_key, nullptr); } };
 static InitTLSKey g_init_tly_key;
 
 // Handle safefetch, sigsetjmp style:
@@ -49,7 +50,7 @@ static InitTLSKey g_init_tly_key;
 // caller sites simple.
 bool handle_safefetch(int sig, address ignored1, void* ignored2) {
   if (sig == SIGSEGV || sig == SIGBUS) {
-    // Retrieve jump buffer pointer from TLS. If not NULL, it means we set the
+    // Retrieve jump buffer pointer from TLS. If not null, it means we set the
     // jump buffer and this is indeed a SafeFetch fault.
     // Note signal safety: pthread_getspecific is not safe for signal handler
     // usage, but in practice it works and we have done this in the JVM for many
@@ -63,7 +64,7 @@ bool handle_safefetch(int sig, address ignored1, void* ignored2) {
 }
 
 template <class T>
-static bool _SafeFetchXX_internal(const T *adr, T* result) {
+ATTRIBUTE_NO_ASAN static bool _SafeFetchXX_internal(const T *adr, T* result) {
 
   T n = 0;
 
@@ -73,7 +74,7 @@ static bool _SafeFetchXX_internal(const T *adr, T* result) {
   sigjmp_buf jb;
   if (sigsetjmp(jb, 1) != 0) {
     // We faulted. Reset TLS slot, then return.
-    pthread_setspecific(g_jmpbuf_key, NULL);
+    pthread_setspecific(g_jmpbuf_key, nullptr);
     *result = 0;
     return false;
   }
@@ -86,7 +87,7 @@ static bool _SafeFetchXX_internal(const T *adr, T* result) {
 
   // Still here... All went well, adr was valid.
   // Reset TLS slot, then return result.
-  pthread_setspecific(g_jmpbuf_key, NULL);
+  pthread_setspecific(g_jmpbuf_key, nullptr);
   *result = n;
 
   return true;
diff --git a/src/hotspot/os/posix/safefetch_static_posix.cpp b/src/hotspot/os/posix/safefetch_static_posix.cpp
index 171d9d31556..5685a9e09f9 100644
--- a/src/hotspot/os/posix/safefetch_static_posix.cpp
+++ b/src/hotspot/os/posix/safefetch_static_posix.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2022 SAP SE. All rights reserved.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@ extern "C" char _SafeFetchN_fault[] __attribute__ ((visibility ("hidden")));
 
 bool handle_safefetch(int sig, address pc, void* context) {
   ucontext_t* uc = (ucontext_t*)context;
-  if ((sig == SIGSEGV || sig == SIGBUS) && uc != NULL) {
+  if ((sig == SIGSEGV || sig == SIGBUS) && uc != nullptr) {
     if (pc == (address)_SafeFetch32_fault) {
       os::Posix::ucontext_set_pc(uc, (address)_SafeFetch32_continuation);
       return true;
diff --git a/src/hotspot/os/posix/signals_posix.cpp b/src/hotspot/os/posix/signals_posix.cpp
index 2f3a684eab3..285e69ba150 100644
--- a/src/hotspot/os/posix/signals_posix.cpp
+++ b/src/hotspot/os/posix/signals_posix.cpp
@@ -124,7 +124,7 @@ class SavedSignalHandlers {
 
   void set(int sig, const struct sigaction* act) {
     if (check_signal_number(sig)) {
-      assert(_sa[sig] == NULL, "Overwriting signal handler?");
+      assert(_sa[sig] == nullptr, "Overwriting signal handler?");
       _sa[sig] = NEW_C_HEAP_OBJ(struct sigaction, mtInternal);
       *_sa[sig] = *act;
     }
@@ -134,7 +134,7 @@ class SavedSignalHandlers {
     if (check_signal_number(sig)) {
       return _sa[sig];
     }
-    return NULL;
+    return nullptr;
   }
 };
 
@@ -155,7 +155,7 @@ static bool do_check_signal_periodically[NSIG] = { 0 };
 static SavedSignalHandlers chained_handlers;
 static bool libjsig_is_loaded = false;
 typedef struct sigaction *(*get_signal_t)(int);
-static get_signal_t get_signal_action = NULL;
+static get_signal_t get_signal_action = nullptr;
 
 // suspend/resume support
 #if defined(__APPLE__)
@@ -169,7 +169,7 @@ static get_signal_t get_signal_action = NULL;
 int PosixSignals::SR_signum = SIGUSR2;
 
 // sun.misc.Signal support
-static Semaphore* sig_semaphore = NULL;
+static Semaphore* sig_semaphore = nullptr;
 // a counter for each possible signal value
 static volatile jint pending_signals[NSIG+1] = { 0 };
 
@@ -332,7 +332,7 @@ static const struct {
 #ifdef SIGXRES
   {  SIGXRES,     "SIGXRES" },
 #endif
-  { -1, NULL }
+  { -1, nullptr }
 };
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -347,7 +347,7 @@ void jdk_misc_signal_init() {
 }
 
 void os::signal_notify(int sig) {
-  if (sig_semaphore != NULL) {
+  if (sig_semaphore != nullptr) {
     Atomic::inc(&pending_signals[sig]);
     sig_semaphore->signal();
   } else {
@@ -379,13 +379,13 @@ int os::signal_wait() {
 // signal chaining support
 
 struct sigaction* get_chained_signal_action(int sig) {
-  struct sigaction *actp = NULL;
+  struct sigaction *actp = nullptr;
 
   if (libjsig_is_loaded) {
     // Retrieve the old signal handler from libjsig
     actp = (*get_signal_action)(sig);
   }
-  if (actp == NULL) {
+  if (actp == nullptr) {
     // Retrieve the preinstalled signal handler from jvm
     actp = const_cast<struct sigaction*>(chained_handlers.get(sig));
   }
@@ -406,8 +406,8 @@ static bool call_chained_handler(struct sigaction *actp, int sig,
       sigaddset(&(actp->sa_mask), sig);
     }
 
-    sa_handler_t hand = NULL;
-    sa_sigaction_t sa = NULL;
+    sa_handler_t hand = nullptr;
+    sa_sigaction_t sa = nullptr;
     bool siginfo_flag_set = (actp->sa_flags & SA_SIGINFO) != 0;
     // retrieve the chained handler
     if (siginfo_flag_set) {
@@ -433,7 +433,7 @@ static bool call_chained_handler(struct sigaction *actp, int sig,
     }
 
     // restore the signal mask
-    pthread_sigmask(SIG_SETMASK, &oset, NULL);
+    pthread_sigmask(SIG_SETMASK, &oset, nullptr);
   }
   // Tell jvm's signal handler the signal is taken care of.
   return true;
@@ -444,7 +444,7 @@ bool PosixSignals::chained_handler(int sig, siginfo_t* siginfo, void* context) {
   // signal-chaining
   if (UseSignalChaining) {
     struct sigaction *actp = get_chained_signal_action(sig);
-    if (actp != NULL) {
+    if (actp != nullptr) {
       chained = call_chained_handler(actp, sig, siginfo, context);
     }
   }
@@ -467,7 +467,7 @@ bool PosixSignals::chained_handler(int sig, siginfo_t* siginfo, void* context) {
 // We also include SIGTRAP in that list of never-to-block-signals. While not
 // mentioned by the Posix documentation, in our (SAPs) experience blocking it
 // causes similar problems. Beside, during normal operation - outside of error
-// handling - SIGTRAP may be used for implicit NULL checking, so it makes sense
+// handling - SIGTRAP may be used for implicit null checking, so it makes sense
 // to never block it.
 //
 // We deal with those signals in two ways:
@@ -498,7 +498,7 @@ void PosixSignals::unblock_error_signals() {
   sigset_t set;
   sigemptyset(&set);
   add_error_signals_to_set(&set);
-  ::pthread_sigmask(SIG_UNBLOCK, &set, NULL);
+  ::pthread_sigmask(SIG_UNBLOCK, &set, nullptr);
 }
 
 class ErrnoPreserver: public StackObj {
@@ -555,7 +555,7 @@ extern "C" JNIEXPORT
 int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
                           void* ucVoid, int abort_if_unrecognized)
 {
-  assert(info != NULL && ucVoid != NULL, "sanity");
+  assert(info != nullptr && ucVoid != nullptr, "sanity");
 
   // Note: it's not uncommon that JNI code uses signal/sigset to install,
   // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
@@ -584,7 +584,7 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
   // Handle assertion poison page accesses.
 #ifdef CAN_SHOW_REGISTERS_ON_ASSERT
   if (!signal_was_handled &&
-      ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison)) {
+      ((sig == SIGSEGV || sig == SIGBUS) && info != nullptr && info->si_addr == g_assert_poison)) {
     signal_was_handled = handle_assert_poison_fault(ucVoid, info->si_addr);
   }
 #endif
@@ -592,8 +592,8 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
   // Extract pc from context. Note that for certain signals and certain
   // architectures the pc in ucontext_t will point *after* the offending
   // instruction. In those cases, use siginfo si_addr instead.
-  address pc = NULL;
-  if (uc != NULL) {
+  address pc = nullptr;
+  if (uc != nullptr) {
     if (S390_ONLY(sig == SIGILL || sig == SIGFPE) NOT_S390(false)) {
       pc = (address)info->si_addr;
     } else {
@@ -615,17 +615,17 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
 #ifndef ZERO
   // Check for UD trap caused by NOP patching.
   // If it is, patch return address to be deopt handler.
-  if (!signal_was_handled && pc != NULL && os::is_readable_pointer(pc)) {
+  if (!signal_was_handled && pc != nullptr && os::is_readable_pointer(pc)) {
     if (NativeDeoptInstruction::is_deopt_at(pc)) {
       CodeBlob* cb = CodeCache::find_blob(pc);
-      if (cb != NULL && cb->is_compiled()) {
+      if (cb != nullptr && cb->is_compiled()) {
         MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, t);) // can call PcDescCache::add_pc_desc
         CompiledMethod* cm = cb->as_compiled_method();
         assert(cm->insts_contains_inclusive(pc), "");
         address deopt = cm->is_method_handle_return(pc) ?
           cm->deopt_mh_handler_begin() :
           cm->deopt_handler_begin();
-        assert(deopt != NULL, "");
+        assert(deopt != nullptr, "");
 
         frame fr = os::fetch_frame_from_context(uc);
         cm->set_original_pc(&fr, pc);
@@ -639,7 +639,7 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,
 
   // Call platform dependent signal handler.
   if (!signal_was_handled) {
-    JavaThread* const jt = (t != NULL && t->is_Java_thread()) ? JavaThread::cast(t) : NULL;
+    JavaThread* const jt = (t != nullptr && t->is_Java_thread()) ? JavaThread::cast(t) : nullptr;
     signal_was_handled = PosixSignals::pd_hotspot_signal_handler(sig, info, uc, jt);
   }
 
@@ -804,18 +804,18 @@ static bool check_signal_handler(int sig) {
   }
 
   const struct sigaction* expected_act = vm_handlers.get(sig);
-  assert(expected_act != NULL, "Sanity");
+  assert(expected_act != nullptr, "Sanity");
 
   // Retrieve current signal setup.
   struct sigaction act;
-  static os_sigaction_t os_sigaction = NULL;
-  if (os_sigaction == NULL) {
+  static os_sigaction_t os_sigaction = nullptr;
+  if (os_sigaction == nullptr) {
     // only trust the default sigaction, in case it has been interposed
     os_sigaction = (os_sigaction_t)dlsym(RTLD_DEFAULT, "sigaction");
-    if (os_sigaction == NULL) return false;
+    if (os_sigaction == nullptr) return false;
   }
 
-  os_sigaction(sig, (struct sigaction*)NULL, &act);
+  os_sigaction(sig, (struct sigaction*)nullptr, &act);
 
   // Compare both sigaction structures (intelligently; only the members we care about).
   // Ignore if the handler is our own crash handler.
@@ -1006,7 +1006,7 @@ static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t
     { SIGPOLL, POLL_PRI,     "POLL_PRI",     "High priority input available." },
     { SIGPOLL, POLL_HUP,     "POLL_HUP",     "Device disconnected. [Option End]" },
 #endif
-    { -1, -1, NULL, NULL }
+    { -1, -1, nullptr, nullptr }
   };
 
   // Codes valid in any signal context.
@@ -1037,11 +1037,11 @@ static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t
     { SI_EMPTY,     "SI_EMPTY",    "siginfo contains no useful information" },
 #endif
 
-    { -1, NULL, NULL }
+    { -1, nullptr, nullptr }
   };
 
-  const char* s_code = NULL;
-  const char* s_desc = NULL;
+  const char* s_code = nullptr;
+  const char* s_desc = nullptr;
 
   for (int i = 0; t1[i].sig != -1; i ++) {
     if (t1[i].sig == si->si_signo && t1[i].code == si->si_code) {
@@ -1051,8 +1051,8 @@ static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t
     }
   }
 
-  if (s_code == NULL) {
-    for (int i = 0; t2[i].s_code != NULL; i ++) {
+  if (s_code == nullptr) {
+    for (int i = 0; t2[i].s_code != nullptr; i ++) {
       if (t2[i].code == si->si_code) {
         s_code = t2[i].s_code;
         s_desc = t2[i].s_desc;
@@ -1060,7 +1060,7 @@ static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t
     }
   }
 
-  if (s_code == NULL) {
+  if (s_code == nullptr) {
     out->s_name = "unknown";
     out->s_desc = "unknown";
     return false;
@@ -1102,7 +1102,7 @@ static bool is_valid_signal(int sig) {
 
 static const char* get_signal_name(int sig, char* out, size_t outlen) {
 
-  const char* ret = NULL;
+  const char* ret = nullptr;
 
 #ifdef SIGRTMIN
   if (sig >= SIGRTMIN && sig <= SIGRTMAX) {
@@ -1214,12 +1214,12 @@ bool os::signal_thread(Thread* thread, int sig, const char* reason) {
 }
 
 // Returns:
-// NULL for an invalid signal number
+// null for an invalid signal number
 // "SIG<num>" for a valid but unknown signal number
 // signal name otherwise.
 const char* os::exception_name(int sig, char* buf, size_t size) {
   if (!is_valid_signal(sig)) {
-    return NULL;
+    return nullptr;
   }
   const char* const name = get_signal_name(sig, buf, size);
   if (strcmp(name, "UNKNOWN") == 0) {
@@ -1246,7 +1246,7 @@ int os::get_signal_number(const char* signal_name) {
 void set_signal_handler(int sig) {
   // Check for overwrite.
   struct sigaction oldAct;
-  sigaction(sig, (struct sigaction*)NULL, &oldAct);
+  sigaction(sig, (struct sigaction*)nullptr, &oldAct);
 
   // Query the current signal handler. Needs to be a separate operation
   // from installing a new handler since we need to honor AllowUserSignalHandlers.
@@ -1293,11 +1293,11 @@ void set_signal_handler(int sig) {
 void install_signal_handlers() {
   // signal-chaining
   typedef void (*signal_setting_t)();
-  signal_setting_t begin_signal_setting = NULL;
-  signal_setting_t end_signal_setting = NULL;
+  signal_setting_t begin_signal_setting = nullptr;
+  signal_setting_t end_signal_setting = nullptr;
   begin_signal_setting = CAST_TO_FN_PTR(signal_setting_t,
                                         dlsym(RTLD_DEFAULT, "JVM_begin_signal_setting"));
-  if (begin_signal_setting != NULL) {
+  if (begin_signal_setting != nullptr) {
     end_signal_setting = CAST_TO_FN_PTR(signal_setting_t,
                                         dlsym(RTLD_DEFAULT, "JVM_end_signal_setting"));
     get_signal_action = CAST_TO_FN_PTR(get_signal_t,
@@ -1344,7 +1344,7 @@ void install_signal_handlers() {
   // handlers. By replacing the existing task exception handler, we disable lldb's mach
   // exception handling, while leaving the standard BSD signal handlers functional.
   //
-  // EXC_MASK_BAD_ACCESS needed by all architectures for NULL ptr checking
+  // EXC_MASK_BAD_ACCESS needed by all architectures for null ptr checking
   // EXC_MASK_ARITHMETIC needed by all architectures for div by 0 checking
   // EXC_MASK_BAD_INSTRUCTION needed by aarch64 to initiate deoptimization
   kern_return_t kr;
@@ -1434,12 +1434,12 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
   st->print("%10s: ", os::exception_name(sig, buf, buflen));
 
   struct sigaction current_act;
-  sigaction(sig, NULL, &current_act);
+  sigaction(sig, nullptr, &current_act);
 
   print_single_signal_handler(st, &current_act, buf, buflen);
 
   sigset_t thread_sig_mask;
-  if (::pthread_sigmask(/* ignored */ SIG_BLOCK, NULL, &thread_sig_mask) == 0) {
+  if (::pthread_sigmask(/* ignored */ SIG_BLOCK, nullptr, &thread_sig_mask) == 0) {
     st->print(", %s", sigismember(&thread_sig_mask, sig) ? "blocked" : "unblocked");
   }
   st->cr();
@@ -1448,7 +1448,7 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
   //  print a warning (unless the handler replacing it is our own crash handler, which can
   //  happen if this function is called during error reporting).
   const struct sigaction* expected_act = vm_handlers.get(sig);
-  if (expected_act != NULL) {
+  if (expected_act != nullptr) {
     const address current_handler = get_signal_handler(&current_act);
     if (!(HANDLER_IS(current_handler, VMError::crash_handler_address))) {
       if (!are_actions_equal(&current_act, expected_act)) {
@@ -1462,7 +1462,7 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
 
   // If there is a chained handler waiting behind the current one, print it too.
   const struct sigaction* chained_act = get_chained_signal_action(sig);
-  if (chained_act != NULL) {
+  if (chained_act != nullptr) {
     st->print("  chained to: ");
     print_single_signal_handler(st, &current_act, buf, buflen);
     st->cr();
@@ -1494,7 +1494,7 @@ void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
 
 bool PosixSignals::is_sig_ignored(int sig) {
   struct sigaction oact;
-  sigaction(sig, (struct sigaction*)NULL, &oact);
+  sigaction(sig, (struct sigaction*)nullptr, &oact);
   if (HANDLER_IS_IGN(get_signal_handler(&oact))) {
     return true;
   } else {
@@ -1565,20 +1565,20 @@ void PosixSignals::hotspot_sigmask(Thread* thread) {
 
   //Save caller's signal mask before setting VM signal mask
   sigset_t caller_sigmask;
-  pthread_sigmask(SIG_BLOCK, NULL, &caller_sigmask);
+  pthread_sigmask(SIG_BLOCK, nullptr, &caller_sigmask);
 
   OSThread* osthread = thread->osthread();
   osthread->set_caller_sigmask(caller_sigmask);
 
-  pthread_sigmask(SIG_UNBLOCK, unblocked_signals(), NULL);
+  pthread_sigmask(SIG_UNBLOCK, unblocked_signals(), nullptr);
 
   if (!ReduceSignalUsage) {
     if (thread->is_VM_thread()) {
       // Only the VM thread handles BREAK_SIGNAL ...
-      pthread_sigmask(SIG_UNBLOCK, vm_signals(), NULL);
+      pthread_sigmask(SIG_UNBLOCK, vm_signals(), nullptr);
     } else {
       // ... all other threads block BREAK_SIGNAL
-      pthread_sigmask(SIG_BLOCK, vm_signals(), NULL);
+      pthread_sigmask(SIG_BLOCK, vm_signals(), nullptr);
     }
   }
 }
@@ -1610,8 +1610,8 @@ void PosixSignals::hotspot_sigmask(Thread* thread) {
 //    - StackBanging: get_frame_at_stack_banging_point()
 
 static void resume_clear_context(OSThread *osthread) {
-  osthread->set_ucontext(NULL);
-  osthread->set_siginfo(NULL);
+  osthread->set_ucontext(nullptr);
+  osthread->set_siginfo(nullptr);
 }
 
 static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, void* ucVoid) {
@@ -1653,7 +1653,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, void* context) {
     ss.print_raw("Non-attached thread received stray SR signal (");
     os::print_siginfo(&ss, siginfo);
     ss.print_raw(").");
-    assert(thread != NULL, "%s.", ss.base());
+    assert(thread != nullptr, "%s.", ss.base());
     log_warning(os)("%s", ss.base());
     return;
   }
@@ -1684,7 +1684,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, void* context) {
       sigemptyset(&suspend_set);
 
       // get current set of blocked signals and unblock resume signal
-      pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
+      pthread_sigmask(SIG_BLOCK, nullptr, &suspend_set);
       sigdelset(&suspend_set, PosixSignals::SR_signum);
 
       sr_semaphore.signal();
@@ -1744,7 +1744,7 @@ int SR_initialize() {
   act.sa_sigaction = SR_handler;
 
   // SR_signum is blocked when the handler runs.
-  pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask);
+  pthread_sigmask(SIG_BLOCK, nullptr, &act.sa_mask);
   remove_error_signals_from_set(&(act.sa_mask));
 
   if (sigaction(PosixSignals::SR_signum, &act, 0) == -1) {
diff --git a/src/hotspot/os/posix/threadCrashProtection_posix.cpp b/src/hotspot/os/posix/threadCrashProtection_posix.cpp
index 04954178ea4..7d19b060479 100644
--- a/src/hotspot/os/posix/threadCrashProtection_posix.cpp
+++ b/src/hotspot/os/posix/threadCrashProtection_posix.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,8 @@
 #include "runtime/thread.hpp"
 #include "runtime/threadCrashProtection.hpp"
 
-Thread* ThreadCrashProtection::_protected_thread = NULL;
-ThreadCrashProtection* ThreadCrashProtection::_crash_protection = NULL;
+Thread* ThreadCrashProtection::_protected_thread = nullptr;
+ThreadCrashProtection* ThreadCrashProtection::_crash_protection = nullptr;
 
 ThreadCrashProtection::ThreadCrashProtection() {
   _protected_thread = Thread::current();
@@ -46,35 +46,35 @@ bool ThreadCrashProtection::call(CrashProtectionCallback& cb) {
   // we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask
   // since on at least some systems (OS X) siglongjmp will restore the mask
   // for the process, not the thread
-  pthread_sigmask(0, NULL, &saved_sig_mask);
+  pthread_sigmask(0, nullptr, &saved_sig_mask);
   if (sigsetjmp(_jmpbuf, 0) == 0) {
     // make sure we can see in the signal handler that we have crash protection
     // installed
     _crash_protection = this;
     cb.call();
     // and clear the crash protection
-    _crash_protection = NULL;
-    _protected_thread = NULL;
+    _crash_protection = nullptr;
+    _protected_thread = nullptr;
     return true;
   }
   // this happens when we siglongjmp() back
-  pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
-  _crash_protection = NULL;
-  _protected_thread = NULL;
+  pthread_sigmask(SIG_SETMASK, &saved_sig_mask, nullptr);
+  _crash_protection = nullptr;
+  _protected_thread = nullptr;
   return false;
 }
 
 void ThreadCrashProtection::restore() {
-  assert(_crash_protection != NULL, "must have crash protection");
+  assert(_crash_protection != nullptr, "must have crash protection");
   siglongjmp(_jmpbuf, 1);
 }
 
 void ThreadCrashProtection::check_crash_protection(int sig,
     Thread* thread) {
 
-  if (thread != NULL &&
+  if (thread != nullptr &&
       thread == _protected_thread &&
-      _crash_protection != NULL) {
+      _crash_protection != nullptr) {
 
     if (sig == SIGSEGV || sig == SIGBUS) {
       _crash_protection->restore();
diff --git a/src/hotspot/os/posix/threadCrashProtection_posix.hpp b/src/hotspot/os/posix/threadCrashProtection_posix.hpp
index ee48c6f7de6..48226b6c2cf 100644
--- a/src/hotspot/os/posix/threadCrashProtection_posix.hpp
+++ b/src/hotspot/os/posix/threadCrashProtection_posix.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ class Thread;
 class ThreadCrashProtection : public StackObj {
 public:
   static bool is_crash_protected(Thread* thr) {
-    return _crash_protection != NULL && _protected_thread == thr;
+    return _crash_protection != nullptr && _protected_thread == thr;
   }
 
   ThreadCrashProtection();
diff --git a/src/hotspot/os/posix/threadLocalStorage_posix.cpp b/src/hotspot/os/posix/threadLocalStorage_posix.cpp
index 25bbbe2244f..44a1d294cd5 100644
--- a/src/hotspot/os/posix/threadLocalStorage_posix.cpp
+++ b/src/hotspot/os/posix/threadLocalStorage_posix.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@ Thread* ThreadLocalStorage::thread() {
   // the initialization process, which is using Thread::current without
   // checking TLS is initialized - see java.cpp vm_exit
   assert(_initialized, "TLS not initialized yet!");
-  return (Thread*) pthread_getspecific(_thread_key); // may be NULL
+  return (Thread*) pthread_getspecific(_thread_key); // may be null
 }
 
 void ThreadLocalStorage::set_thread(Thread* current) {
diff --git a/src/hotspot/os/posix/vmError_posix.cpp b/src/hotspot/os/posix/vmError_posix.cpp
index bc2000f5235..7d7fe6c13c1 100644
--- a/src/hotspot/os/posix/vmError_posix.cpp
+++ b/src/hotspot/os/posix/vmError_posix.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2018, 2020 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -69,7 +69,7 @@ static void crash_handler(int sig, siginfo_t* info, void* context) {
   PosixSignals::unblock_error_signals();
 
   ucontext_t* const uc = (ucontext_t*) context;
-  address pc = (uc != NULL) ? os::Posix::ucontext_get_pc(uc) : NULL;
+  address pc = (uc != nullptr) ? os::Posix::ucontext_get_pc(uc) : nullptr;
 
   // Correct pc for SIGILL, SIGFPE (see JDK-8176872)
   if (sig == SIGILL || sig == SIGFPE) {
@@ -83,14 +83,14 @@ static void crash_handler(int sig, siginfo_t* info, void* context) {
 
   // Needed because asserts may happen in error handling too.
 #ifdef CAN_SHOW_REGISTERS_ON_ASSERT
-  if ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison) {
+  if ((sig == SIGSEGV || sig == SIGBUS) && info != nullptr && info->si_addr == g_assert_poison) {
     if (handle_assert_poison_fault(context, info->si_addr)) {
       return;
     }
   }
 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
 
-  VMError::report_and_die(NULL, sig, pc, info, context);
+  VMError::report_and_die(nullptr, sig, pc, info, context);
 }
 
 const void* VMError::crash_handler_address = CAST_FROM_FN_PTR(void *, crash_handler);
@@ -116,7 +116,7 @@ void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
     const siginfo_t* const si = (siginfo_t*)siginfo;
     if (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) {
       const void* const fault_addr = si->si_addr;
-      if (fault_addr != NULL) {
+      if (fault_addr != nullptr) {
         if (MetaspaceShared::is_in_shared_metaspace(fault_addr)) {
           st->print("Error accessing class data sharing archive. "
             "Mapped file inaccessible during execution, possible disk/network problem.");
diff --git a/src/hotspot/os/windows/safefetch_windows.hpp b/src/hotspot/os/windows/safefetch_windows.hpp
index 01904ffa9b2..c745b832abe 100644
--- a/src/hotspot/os/windows/safefetch_windows.hpp
+++ b/src/hotspot/os/windows/safefetch_windows.hpp
@@ -26,12 +26,13 @@
 #ifndef OS_WINDOWS_SAFEFETCH_WINDOWS_HPP
 #define OS_WINDOWS_SAFEFETCH_WINDOWS_HPP
 
+#include "sanitizers/address.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 // On windows, we use structured exception handling to implement SafeFetch
 
 template <class T>
-inline T SafeFetchXX(const T* adr, T errValue) {
+ATTRIBUTE_NO_ASAN inline T SafeFetchXX(const T* adr, T errValue) {
   T v = 0;
   __try {
     v = *adr;
diff --git a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp
index 034dd6b8b8a..4319d7f3763 100644
--- a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp
+++ b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp
@@ -141,7 +141,7 @@ frame os::fetch_compiled_frame_from_context(const void* ucVoid) {
 }
 
 frame os::get_sender_for_C_frame(frame* fr) {
-  if (*fr->sp() == nullptr) {
+  if (*fr->sp() == (intptr_t) nullptr) {
     // fr is the last C frame
     return frame(nullptr, nullptr);
   }
diff --git a/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp
index 761da5d743e..11cd9e1d72d 100644
--- a/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp
+++ b/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp
@@ -37,8 +37,15 @@ template<size_t byte_size>
 struct Atomic::PlatformAdd {
   template<typename D, typename I>
   D add_and_fetch(D volatile* dest, I add_value, atomic_memory_order order) const {
-    D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE);
-    FULL_MEM_BARRIER;
+    if (order != memory_order_relaxed) {
+      FULL_MEM_BARRIER;
+    }
+
+    D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELAXED);
+
+    if (order != memory_order_relaxed) {
+      FULL_MEM_BARRIER;
+    }
     return res;
   }
 
@@ -54,8 +61,15 @@ inline T Atomic::PlatformXchg<byte_size>::operator()(T volatile* dest,
                                                      T exchange_value,
                                                      atomic_memory_order order) const {
   STATIC_ASSERT(byte_size == sizeof(T));
-  T res = __atomic_exchange_n(dest, exchange_value, __ATOMIC_RELEASE);
-  FULL_MEM_BARRIER;
+  if (order != memory_order_relaxed) {
+    FULL_MEM_BARRIER;
+  }
+
+  T res = __atomic_exchange_n(dest, exchange_value, __ATOMIC_RELAXED);
+
+  if (order != memory_order_relaxed) {
+    FULL_MEM_BARRIER;
+  }
   return res;
 }
 
@@ -88,26 +102,29 @@ inline T Atomic::PlatformCmpxchg<4>::operator()(T volatile* dest __attribute__((
                                                 T exchange_value,
                                                 atomic_memory_order order) const {
   STATIC_ASSERT(4 == sizeof(T));
+
+  T old_value;
+  long rc;
+
   if (order != memory_order_relaxed) {
     FULL_MEM_BARRIER;
   }
-  T rv;
-  int tmp;
-  __asm volatile(
-    "1:\n\t"
-    " addiw     %[tmp], %[cv], 0\n\t" // make sure compare_value signed_extend
-    " lr.w.aq   %[rv], (%[dest])\n\t"
-    " bne       %[rv], %[tmp], 2f\n\t"
-    " sc.w.rl   %[tmp], %[ev], (%[dest])\n\t"
-    " bnez      %[tmp], 1b\n\t"
-    "2:\n\t"
-    : [rv] "=&r" (rv), [tmp] "=&r" (tmp)
-    : [ev] "r" (exchange_value), [dest] "r" (dest), [cv] "r" (compare_value)
-    : "memory");
+
+  __asm__ __volatile__ (
+    "1:  sext.w    %1, %3      \n\t" // sign-extend compare_value
+    "    lr.w      %0, %2      \n\t"
+    "    bne       %0, %1, 2f  \n\t"
+    "    sc.w      %1, %4, %2  \n\t"
+    "    bnez      %1, 1b      \n\t"
+    "2:                        \n\t"
+    : /*%0*/"=&r" (old_value), /*%1*/"=&r" (rc), /*%2*/"+A" (*dest)
+    : /*%3*/"r" (compare_value), /*%4*/"r" (exchange_value)
+    : "memory" );
+
   if (order != memory_order_relaxed) {
     FULL_MEM_BARRIER;
   }
-  return rv;
+  return old_value;
 }
 
 template<size_t byte_size>
diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp
index b13aa55da08..f69596dd41e 100644
--- a/src/hotspot/share/cds/archiveBuilder.cpp
+++ b/src/hotspot/share/cds/archiveBuilder.cpp
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "cds/archiveBuilder.hpp"
+#include "cds/archiveHeapWriter.hpp"
 #include "cds/archiveUtils.hpp"
 #include "cds/cppVtables.hpp"
 #include "cds/dumpAllocStats.hpp"
@@ -830,14 +831,11 @@ uintx ArchiveBuilder::any_to_offset(address p) const {
   return buffer_to_offset(p);
 }
 
-// Update a Java object to point its Klass* to the address whene
-// the class would be mapped at runtime.
-void ArchiveBuilder::relocate_klass_ptr_of_oop(oop o) {
+narrowKlass ArchiveBuilder::get_requested_narrow_klass(Klass* k) {
   assert(DumpSharedSpaces, "sanity");
-  Klass* k = get_buffered_klass(o->klass());
+  k = get_buffered_klass(k);
   Klass* requested_k = to_requested(k);
-  narrowKlass nk = CompressedKlassPointers::encode_not_null(requested_k, _requested_static_archive_bottom);
-  o->set_narrow_klass(nk);
+  return CompressedKlassPointers::encode_not_null(requested_k, _requested_static_archive_bottom);
 }
 
 // RelocateBufferToRequested --- Relocate all the pointers in rw/ro,
@@ -1062,19 +1060,18 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
 
       while (start < end) {
         size_t byte_size;
-        oop archived_oop = cast_to_oop(start);
-        oop original_oop = HeapShared::get_original_object(archived_oop);
+        oop original_oop = ArchiveHeapWriter::buffered_addr_to_source_obj(start);
         if (original_oop != nullptr) {
           ResourceMark rm;
           log_info(cds, map)(PTR_FORMAT ": @@ Object %s",
                              p2i(to_requested(start)), original_oop->klass()->external_name());
           byte_size = original_oop->size() * BytesPerWord;
-        } else if (archived_oop == HeapShared::roots()) {
+        } else if (start == ArchiveHeapWriter::buffered_heap_roots_addr()) {
           // HeapShared::roots() is copied specially so it doesn't exist in
           // HeapShared::OriginalObjectTable. See HeapShared::copy_roots().
           log_info(cds, map)(PTR_FORMAT ": @@ Object HeapShared::roots (ObjArray)",
                              p2i(to_requested(start)));
-          byte_size = objArrayOopDesc::object_size(HeapShared::roots()->length()) * BytesPerWord;
+          byte_size = ArchiveHeapWriter::heap_roots_word_size() * BytesPerWord;
         } else {
           // We have reached the end of the region
           break;
@@ -1091,7 +1088,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
     }
   }
   static address to_requested(address p) {
-    return HeapShared::to_requested_address(p);
+    return ArchiveHeapWriter::buffered_addr_to_requested_addr(p);
   }
 #endif
 
diff --git a/src/hotspot/share/cds/archiveBuilder.hpp b/src/hotspot/share/cds/archiveBuilder.hpp
index 21b130f494a..9d39892fdc4 100644
--- a/src/hotspot/share/cds/archiveBuilder.hpp
+++ b/src/hotspot/share/cds/archiveBuilder.hpp
@@ -443,7 +443,7 @@ class ArchiveBuilder : public StackObj {
     return alloc_stats()->string_stats();
   }
 
-  void relocate_klass_ptr_of_oop(oop o);
+  narrowKlass get_requested_narrow_klass(Klass* k);
 
   static Klass* get_buffered_klass(Klass* src_klass) {
     Klass* klass = (Klass*)current()->get_buffered_addr((address)src_klass);
diff --git a/src/hotspot/share/cds/archiveHeapWriter.cpp b/src/hotspot/share/cds/archiveHeapWriter.cpp
new file mode 100644
index 00000000000..91cd15c762d
--- /dev/null
+++ b/src/hotspot/share/cds/archiveHeapWriter.cpp
@@ -0,0 +1,657 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "cds/archiveHeapWriter.hpp"
+#include "cds/filemap.hpp"
+#include "cds/heapShared.hpp"
+#include "gc/shared/collectedHeap.hpp"
+#include "memory/iterator.inline.hpp"
+#include "memory/oopFactory.hpp"
+#include "memory/universe.hpp"
+#include "oops/compressedOops.hpp"
+#include "oops/oop.inline.hpp"
+#include "oops/objArrayOop.inline.hpp"
+#include "oops/oopHandle.inline.hpp"
+#include "oops/typeArrayKlass.hpp"
+#include "oops/typeArrayOop.hpp"
+#include "runtime/java.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "utilities/bitMap.inline.hpp"
+
+#if INCLUDE_G1GC
+#include "gc/g1/g1CollectedHeap.hpp"
+#include "gc/g1/heapRegion.hpp"
+#endif
+
+#if INCLUDE_CDS_JAVA_HEAP
+
+
+GrowableArrayCHeap<u1, mtClassShared>* ArchiveHeapWriter::_buffer;
+
+// The following are offsets from buffer_bottom()
+size_t ArchiveHeapWriter::_buffer_top;
+size_t ArchiveHeapWriter::_open_bottom;
+size_t ArchiveHeapWriter::_open_top;
+size_t ArchiveHeapWriter::_closed_bottom;
+size_t ArchiveHeapWriter::_closed_top;
+size_t ArchiveHeapWriter::_heap_roots_bottom;
+
+size_t ArchiveHeapWriter::_heap_roots_word_size;
+
+address ArchiveHeapWriter::_requested_open_region_bottom;
+address ArchiveHeapWriter::_requested_open_region_top;
+address ArchiveHeapWriter::_requested_closed_region_bottom;
+address ArchiveHeapWriter::_requested_closed_region_top;
+
+ResourceBitMap* ArchiveHeapWriter::_closed_oopmap;
+ResourceBitMap* ArchiveHeapWriter::_open_oopmap;
+
+GrowableArrayCHeap<ArchiveHeapWriter::NativePointerInfo, mtClassShared>* ArchiveHeapWriter::_native_pointers;
+GrowableArrayCHeap<oop, mtClassShared>* ArchiveHeapWriter::_source_objs;
+
+ArchiveHeapWriter::BufferOffsetToSourceObjectTable*
+  ArchiveHeapWriter::_buffer_offset_to_source_obj_table = nullptr;
+
+void ArchiveHeapWriter::init() {
+  if (HeapShared::can_write()) {
+    Universe::heap()->collect(GCCause::_java_lang_system_gc);
+
+    _buffer_offset_to_source_obj_table = new BufferOffsetToSourceObjectTable();
+
+    _requested_open_region_bottom = nullptr;
+    _requested_open_region_top = nullptr;
+    _requested_closed_region_bottom = nullptr;
+    _requested_closed_region_top = nullptr;
+
+    _native_pointers = new GrowableArrayCHeap<NativePointerInfo, mtClassShared>(2048);
+    _source_objs = new GrowableArrayCHeap<oop, mtClassShared>(10000);
+
+    guarantee(UseG1GC, "implementation limitation");
+    guarantee(MIN_GC_REGION_ALIGNMENT <= /*G1*/HeapRegion::min_region_size_in_words() * HeapWordSize, "must be");
+  }
+}
+
+void ArchiveHeapWriter::add_source_obj(oop src_obj) {
+  _source_objs->append(src_obj);
+}
+
+// For the time being, always support two regions (to be strictly compatible with existing G1
+// mapping code. We might eventually use a single region (JDK-8298048).
+void ArchiveHeapWriter::write(GrowableArrayCHeap<oop, mtClassShared>* roots,
+                              GrowableArray<MemRegion>* closed_regions, GrowableArray<MemRegion>* open_regions,
+                              GrowableArray<ArchiveHeapBitmapInfo>* closed_bitmaps,
+                              GrowableArray<ArchiveHeapBitmapInfo>* open_bitmaps) {
+  assert(HeapShared::can_write(), "sanity");
+  allocate_buffer();
+  copy_source_objs_to_buffer(roots);
+  set_requested_address_for_regions(closed_regions, open_regions);
+  relocate_embedded_oops(roots, closed_bitmaps, open_bitmaps);
+}
+
+bool ArchiveHeapWriter::is_too_large_to_archive(oop o) {
+  return is_too_large_to_archive(o->size());
+}
+
+bool ArchiveHeapWriter::is_string_too_large_to_archive(oop string) {
+  typeArrayOop value = java_lang_String::value_no_keepalive(string);
+  return is_too_large_to_archive(value);
+}
+
+bool ArchiveHeapWriter::is_too_large_to_archive(size_t size) {
+  assert(size > 0, "no zero-size object");
+  assert(size * HeapWordSize > size, "no overflow");
+  static_assert(MIN_GC_REGION_ALIGNMENT > 0, "must be positive");
+
+  size_t byte_size = size * HeapWordSize;
+  if (byte_size > size_t(MIN_GC_REGION_ALIGNMENT)) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+// Various lookup functions between source_obj, buffered_obj and requested_obj
+bool ArchiveHeapWriter::is_in_requested_regions(oop o) {
+  assert(_requested_open_region_bottom != nullptr, "do not call before this is initialized");
+  assert(_requested_closed_region_bottom != nullptr, "do not call before this is initialized");
+
+  address a = cast_from_oop<address>(o);
+  return (_requested_open_region_bottom <= a && a < _requested_open_region_top) ||
+         (_requested_closed_region_bottom <= a && a < _requested_closed_region_top);
+}
+
+oop ArchiveHeapWriter::requested_obj_from_buffer_offset(size_t offset) {
+  oop req_obj = cast_to_oop(_requested_open_region_bottom + offset);
+  assert(is_in_requested_regions(req_obj), "must be");
+  return req_obj;
+}
+
+oop ArchiveHeapWriter::source_obj_to_requested_obj(oop src_obj) {
+  assert(DumpSharedSpaces, "dump-time only");
+  HeapShared::CachedOopInfo* p = HeapShared::archived_object_cache()->get(src_obj);
+  if (p != nullptr) {
+    return requested_obj_from_buffer_offset(p->buffer_offset());
+  } else {
+    return nullptr;
+  }
+}
+
+oop ArchiveHeapWriter::buffered_addr_to_source_obj(address buffered_addr) {
+  oop* p = _buffer_offset_to_source_obj_table->get(buffered_address_to_offset(buffered_addr));
+  if (p != nullptr) {
+    return *p;
+  } else {
+    return nullptr;
+  }
+}
+
+address ArchiveHeapWriter::buffered_addr_to_requested_addr(address buffered_addr) {
+  return _requested_open_region_bottom + buffered_address_to_offset(buffered_addr);
+}
+
+oop ArchiveHeapWriter::heap_roots_requested_address() {
+  return requested_obj_from_buffer_offset(_heap_roots_bottom);
+}
+
+address ArchiveHeapWriter::heap_region_requested_bottom(int heap_region_idx) {
+  assert(_buffer != nullptr, "must be initialized");
+  switch (heap_region_idx) {
+  case MetaspaceShared::first_closed_heap_region:
+    return _requested_closed_region_bottom;
+  case MetaspaceShared::first_open_heap_region:
+    return _requested_open_region_bottom;
+  default:
+    ShouldNotReachHere();
+    return nullptr;
+  }
+}
+
+void ArchiveHeapWriter::allocate_buffer() {
+  int initial_buffer_size = 100000;
+  _buffer = new GrowableArrayCHeap<u1, mtClassShared>(initial_buffer_size);
+  _open_bottom = _buffer_top = 0;
+  ensure_buffer_space(1); // so that buffer_bottom() works
+}
+
+void ArchiveHeapWriter::ensure_buffer_space(size_t min_bytes) {
+  // We usually have very small heaps. If we get a huge one it's probably caused by a bug.
+  guarantee(min_bytes <= max_jint, "we dont support archiving more than 2G of objects");
+  _buffer->at_grow(to_array_index(min_bytes));
+}
+
+void ArchiveHeapWriter::copy_roots_to_buffer(GrowableArrayCHeap<oop, mtClassShared>* roots) {
+  Klass* k = Universe::objectArrayKlassObj(); // already relocated to point to archived klass
+  int length = roots != nullptr ? roots->length() : 0;
+  _heap_roots_word_size = objArrayOopDesc::object_size(length);
+  size_t byte_size = _heap_roots_word_size * HeapWordSize;
+  if (byte_size >= MIN_GC_REGION_ALIGNMENT) {
+    log_error(cds, heap)("roots array is too large. Please reduce the number of classes");
+    vm_exit(1);
+  }
+
+  maybe_fill_gc_region_gap(byte_size);
+
+  size_t new_top = _buffer_top + byte_size;
+  ensure_buffer_space(new_top);
+
+  HeapWord* mem = offset_to_buffered_address<HeapWord*>(_buffer_top);
+  memset(mem, 0, byte_size);
+  {
+    // This is copied from MemAllocator::finish
+    oopDesc::set_mark(mem, markWord::prototype());
+    oopDesc::release_set_klass(mem, k);
+  }
+  {
+    // This is copied from ObjArrayAllocator::initialize
+    arrayOopDesc::set_length(mem, length);
+  }
+
+  objArrayOop arrayOop = objArrayOop(cast_to_oop(mem));
+  for (int i = 0; i < length; i++) {
+    // Do not use arrayOop->obj_at_put(i, o) as arrayOop is outside of the real heap!
+    oop o = roots->at(i);
+    if (UseCompressedOops) {
+      * arrayOop->obj_at_addr<narrowOop>(i) = CompressedOops::encode(o);
+    } else {
+      * arrayOop->obj_at_addr<oop>(i) = o;
+    }
+  }
+  log_info(cds)("archived obj roots[%d] = " SIZE_FORMAT " bytes, klass = %p, obj = %p", length, byte_size, k, mem);
+
+  _heap_roots_bottom = _buffer_top;
+  _buffer_top = new_top;
+}
+
+void ArchiveHeapWriter::copy_source_objs_to_buffer(GrowableArrayCHeap<oop, mtClassShared>* roots) {
+  copy_source_objs_to_buffer_by_region(/*copy_open_region=*/true);
+  copy_roots_to_buffer(roots);
+  _open_top = _buffer_top;
+
+  // Align the closed region to the next G1 region
+  _buffer_top = _closed_bottom = align_up(_buffer_top, HeapRegion::GrainBytes);
+  copy_source_objs_to_buffer_by_region(/*copy_open_region=*/false);
+  _closed_top = _buffer_top;
+
+  log_info(cds, heap)("Size of open region   = " SIZE_FORMAT " bytes", _open_top   - _open_bottom);
+  log_info(cds, heap)("Size of closed region = " SIZE_FORMAT " bytes", _closed_top - _closed_bottom);
+}
+
+void ArchiveHeapWriter::copy_source_objs_to_buffer_by_region(bool copy_open_region) {
+  for (int i = 0; i < _source_objs->length(); i++) {
+    oop src_obj = _source_objs->at(i);
+    HeapShared::CachedOopInfo* info = HeapShared::archived_object_cache()->get(src_obj);
+    assert(info != nullptr, "must be");
+    if (info->in_open_region() == copy_open_region) {
+      // For region-based collectors such as G1, we need to make sure that we don't have
+      // an object that can possible span across two regions.
+      size_t buffer_offset = copy_one_source_obj_to_buffer(src_obj);
+      info->set_buffer_offset(buffer_offset);
+
+      _buffer_offset_to_source_obj_table->put(buffer_offset, src_obj);
+    }
+  }
+}
+
+size_t ArchiveHeapWriter::filler_array_byte_size(int length) {
+  size_t byte_size = objArrayOopDesc::object_size(length) * HeapWordSize;
+  return byte_size;
+}
+
+int ArchiveHeapWriter::filler_array_length(size_t fill_bytes) {
+  assert(is_object_aligned(fill_bytes), "must be");
+  size_t elemSize = (UseCompressedOops ? sizeof(narrowOop) : sizeof(oop));
+
+  int initial_length = to_array_length(fill_bytes / elemSize);
+  for (int length = initial_length; length >= 0; length --) {
+    size_t array_byte_size = filler_array_byte_size(length);
+    if (array_byte_size == fill_bytes) {
+      return length;
+    }
+  }
+
+  ShouldNotReachHere();
+  return -1;
+}
+
+void ArchiveHeapWriter::init_filler_array_at_buffer_top(int array_length, size_t fill_bytes) {
+  assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
+  Klass* oak = Universe::objectArrayKlassObj(); // already relocated to point to archived klass
+  HeapWord* mem = offset_to_buffered_address<HeapWord*>(_buffer_top);
+  memset(mem, 0, fill_bytes);
+  oopDesc::set_mark(mem, markWord::prototype());
+  narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(oak);
+  cast_to_oop(mem)->set_narrow_klass(nk);
+  arrayOopDesc::set_length(mem, array_length);
+}
+
+void ArchiveHeapWriter::maybe_fill_gc_region_gap(size_t required_byte_size) {
+  // We fill only with arrays (so we don't need to use a single HeapWord filler if the
+  // leftover space is smaller than a zero-sized array object). Therefore, we need to
+  // make sure there's enough space of min_filler_byte_size in the current region after
+  // required_byte_size has been allocated. If not, fill the remainder of the current
+  // region.
+  size_t min_filler_byte_size = filler_array_byte_size(0);
+  size_t new_top = _buffer_top + required_byte_size + min_filler_byte_size;
+
+  const size_t cur_min_region_bottom = align_down(_buffer_top, MIN_GC_REGION_ALIGNMENT);
+  const size_t next_min_region_bottom = align_down(new_top, MIN_GC_REGION_ALIGNMENT);
+
+  if (cur_min_region_bottom != next_min_region_bottom) {
+    // Make sure that no objects span across MIN_GC_REGION_ALIGNMENT. This way
+    // we can map the region in any region-based collector.
+    assert(next_min_region_bottom > cur_min_region_bottom, "must be");
+    assert(next_min_region_bottom - cur_min_region_bottom == MIN_GC_REGION_ALIGNMENT,
+           "no buffered object can be larger than %d bytes",  MIN_GC_REGION_ALIGNMENT);
+
+    const size_t filler_end = next_min_region_bottom;
+    const size_t fill_bytes = filler_end - _buffer_top;
+    assert(fill_bytes > 0, "must be");
+    ensure_buffer_space(filler_end);
+
+    int array_length = filler_array_length(fill_bytes);
+    log_info(cds, heap)("Inserting filler obj array of %d elements (" SIZE_FORMAT " bytes total) @ buffer offset " SIZE_FORMAT,
+                        array_length, fill_bytes, _buffer_top);
+    init_filler_array_at_buffer_top(array_length, fill_bytes);
+
+    _buffer_top = filler_end;
+  }
+}
+
+size_t ArchiveHeapWriter::copy_one_source_obj_to_buffer(oop src_obj) {
+  assert(!is_too_large_to_archive(src_obj), "already checked");
+  size_t byte_size = src_obj->size() * HeapWordSize;
+  assert(byte_size > 0, "no zero-size objects");
+
+  maybe_fill_gc_region_gap(byte_size);
+
+  size_t new_top = _buffer_top + byte_size;
+  assert(new_top > _buffer_top, "no wrap around");
+
+  size_t cur_min_region_bottom = align_down(_buffer_top, MIN_GC_REGION_ALIGNMENT);
+  size_t next_min_region_bottom = align_down(new_top, MIN_GC_REGION_ALIGNMENT);
+  assert(cur_min_region_bottom == next_min_region_bottom, "no object should cross minimal GC region boundaries");
+
+  ensure_buffer_space(new_top);
+
+  address from = cast_from_oop<address>(src_obj);
+  address to = offset_to_buffered_address<address>(_buffer_top);
+  assert(is_object_aligned(_buffer_top), "sanity");
+  assert(is_object_aligned(byte_size), "sanity");
+  memcpy(to, from, byte_size);
+
+  size_t buffered_obj_offset = _buffer_top;
+  _buffer_top = new_top;
+
+  return buffered_obj_offset;
+}
+
+void ArchiveHeapWriter::set_requested_address_for_regions(GrowableArray<MemRegion>* closed_regions,
+                                                          GrowableArray<MemRegion>* open_regions) {
+  assert(closed_regions->length() == 0, "must be");
+  assert(open_regions->length() == 0, "must be");
+
+  assert(UseG1GC, "must be");
+  address heap_end = (address)G1CollectedHeap::heap()->reserved().end();
+  log_info(cds, heap)("Heap end = %p", heap_end);
+
+  size_t closed_region_byte_size = _closed_top - _closed_bottom;
+  size_t open_region_byte_size = _open_top - _open_bottom;
+  assert(closed_region_byte_size > 0, "must archived at least one object for closed region!");
+  assert(open_region_byte_size > 0, "must archived at least one object for open region!");
+
+  // The following two asserts are ensured by copy_source_objs_to_buffer_by_region().
+  assert(is_aligned(_closed_bottom, HeapRegion::GrainBytes), "sanity");
+  assert(is_aligned(_open_bottom, HeapRegion::GrainBytes), "sanity");
+
+  _requested_closed_region_bottom = align_down(heap_end - closed_region_byte_size, HeapRegion::GrainBytes);
+  _requested_open_region_bottom = _requested_closed_region_bottom - (_closed_bottom - _open_bottom);
+
+  assert(is_aligned(_requested_closed_region_bottom, HeapRegion::GrainBytes), "sanity");
+  assert(is_aligned(_requested_open_region_bottom, HeapRegion::GrainBytes), "sanity");
+
+  _requested_open_region_top = _requested_open_region_bottom + (_open_top - _open_bottom);
+  _requested_closed_region_top = _requested_closed_region_bottom + (_closed_top - _closed_bottom);
+
+  assert(_requested_open_region_top <= _requested_closed_region_bottom, "no overlap");
+
+  closed_regions->append(MemRegion(offset_to_buffered_address<HeapWord*>(_closed_bottom),
+                                   offset_to_buffered_address<HeapWord*>(_closed_top)));
+  open_regions->append(  MemRegion(offset_to_buffered_address<HeapWord*>(_open_bottom),
+                                   offset_to_buffered_address<HeapWord*>(_open_top)));
+}
+
+// Oop relocation
+
+template <typename T> T* ArchiveHeapWriter::requested_addr_to_buffered_addr(T* p) {
+  assert(is_in_requested_regions(cast_to_oop(p)), "must be");
+
+  address addr = address(p);
+  assert(addr >= _requested_open_region_bottom, "must be");
+  size_t offset = addr - _requested_open_region_bottom;
+  return offset_to_buffered_address<T*>(offset);
+}
+
+template <typename T> oop ArchiveHeapWriter::load_source_oop_from_buffer(T* buffered_addr) {
+  oop o = load_oop_from_buffer(buffered_addr);
+  assert(!in_buffer(cast_from_oop<address>(o)), "must point to source oop");
+  return o;
+}
+
+template <typename T> void ArchiveHeapWriter::store_requested_oop_in_buffer(T* buffered_addr,
+                                                                            oop request_oop) {
+  assert(is_in_requested_regions(request_oop), "must be");
+  store_oop_in_buffer(buffered_addr, request_oop);
+}
+
+void ArchiveHeapWriter::store_oop_in_buffer(oop* buffered_addr, oop requested_obj) {
+  // Make heap content deterministic. See comments inside HeapShared::to_requested_address.
+  *buffered_addr = HeapShared::to_requested_address(requested_obj);
+}
+
+void ArchiveHeapWriter::store_oop_in_buffer(narrowOop* buffered_addr, oop requested_obj) {
+  // Note: HeapShared::to_requested_address() is not necessary because
+  // the heap always starts at a deterministic address with UseCompressedOops==true.
+  narrowOop val = CompressedOops::encode_not_null(requested_obj);
+  *buffered_addr = val;
+}
+
+oop ArchiveHeapWriter::load_oop_from_buffer(oop* buffered_addr) {
+  return *buffered_addr;
+}
+
+oop ArchiveHeapWriter::load_oop_from_buffer(narrowOop* buffered_addr) {
+  return CompressedOops::decode(*buffered_addr);
+}
+
+template <typename T> void ArchiveHeapWriter::relocate_field_in_buffer(T* field_addr_in_buffer) {
+  oop source_referent = load_source_oop_from_buffer<T>(field_addr_in_buffer);
+  if (!CompressedOops::is_null(source_referent)) {
+    oop request_referent = source_obj_to_requested_obj(source_referent);
+    store_requested_oop_in_buffer<T>(field_addr_in_buffer, request_referent);
+    mark_oop_pointer<T>(field_addr_in_buffer);
+  }
+}
+
+template <typename T> void ArchiveHeapWriter::mark_oop_pointer(T* buffered_addr) {
+  T* request_p = (T*)(buffered_addr_to_requested_addr((address)buffered_addr));
+  ResourceBitMap* oopmap;
+  address requested_region_bottom;
+
+  if (request_p >= (T*)_requested_closed_region_bottom) {
+    assert(request_p < (T*)_requested_closed_region_top, "sanity");
+    oopmap = _closed_oopmap;
+    requested_region_bottom = _requested_closed_region_bottom;
+  } else {
+    assert(request_p >= (T*)_requested_open_region_bottom, "sanity");
+    assert(request_p <  (T*)_requested_open_region_top, "sanity");
+    oopmap = _open_oopmap;
+    requested_region_bottom = _requested_open_region_bottom;
+  }
+
+  // Mark the pointer in the oopmap
+  T* region_bottom = (T*)requested_region_bottom;
+  assert(request_p >= region_bottom, "must be");
+  BitMap::idx_t idx = request_p - region_bottom;
+  assert(idx < oopmap->size(), "overflow");
+  oopmap->set_bit(idx);
+}
+
+void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj,  Klass* src_klass) {
+  assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
+  narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
+  address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
+
+  oop fake_oop = cast_to_oop(buffered_addr);
+  fake_oop->set_narrow_klass(nk);
+
+  // We need to retain the identity_hash, because it may have been used by some hashtables
+  // in the shared heap. This also has the side effect of pre-initializing the
+  // identity_hash for all shared objects, so they are less likely to be written
+  // into during run time, increasing the potential of memory sharing.
+  if (src_obj != nullptr) {
+    int src_hash = src_obj->identity_hash();
+    fake_oop->set_mark(markWord::prototype().copy_set_hash(src_hash));
+    assert(fake_oop->mark().is_unlocked(), "sanity");
+
+    DEBUG_ONLY(int archived_hash = fake_oop->identity_hash());
+    assert(src_hash == archived_hash, "Different hash codes: original %x, archived %x", src_hash, archived_hash);
+  }
+}
+
+// Relocate an element in the buffered copy of HeapShared::roots()
+template <typename T> void ArchiveHeapWriter::relocate_root_at(oop requested_roots, int index) {
+  size_t offset = (size_t)((objArrayOop)requested_roots)->obj_at_offset<T>(index);
+  relocate_field_in_buffer<T>((T*)(buffered_heap_roots_addr() + offset));
+}
+
+class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure {
+  oop _src_obj;
+  address _buffered_obj;
+
+public:
+  EmbeddedOopRelocator(oop src_obj, address buffered_obj) :
+    _src_obj(src_obj), _buffered_obj(buffered_obj) {}
+
+  void do_oop(narrowOop *p) { EmbeddedOopRelocator::do_oop_work(p); }
+  void do_oop(      oop *p) { EmbeddedOopRelocator::do_oop_work(p); }
+
+private:
+  template <class T> void do_oop_work(T *p) {
+    size_t field_offset = pointer_delta(p, _src_obj, sizeof(char));
+    ArchiveHeapWriter::relocate_field_in_buffer<T>((T*)(_buffered_obj + field_offset));
+  }
+};
+
+// Update all oop fields embedded in the buffered objects
+void ArchiveHeapWriter::relocate_embedded_oops(GrowableArrayCHeap<oop, mtClassShared>* roots,
+                                               GrowableArray<ArchiveHeapBitmapInfo>* closed_bitmaps,
+                                               GrowableArray<ArchiveHeapBitmapInfo>* open_bitmaps) {
+  size_t oopmap_unit = (UseCompressedOops ? sizeof(narrowOop) : sizeof(oop));
+  size_t closed_region_byte_size = _closed_top - _closed_bottom;
+  size_t open_region_byte_size   = _open_top   - _open_bottom;
+  ResourceBitMap closed_oopmap(closed_region_byte_size / oopmap_unit);
+  ResourceBitMap open_oopmap  (open_region_byte_size   / oopmap_unit);
+
+  _closed_oopmap = &closed_oopmap;
+  _open_oopmap = &open_oopmap;
+
+  auto iterator = [&] (oop src_obj, HeapShared::CachedOopInfo& info) {
+    oop requested_obj = requested_obj_from_buffer_offset(info.buffer_offset());
+    update_header_for_requested_obj(requested_obj, src_obj, src_obj->klass());
+
+    address buffered_obj = offset_to_buffered_address<address>(info.buffer_offset());
+    EmbeddedOopRelocator relocator(src_obj, buffered_obj);
+
+    src_obj->oop_iterate(&relocator);
+  };
+  HeapShared::archived_object_cache()->iterate_all(iterator);
+
+  // Relocate HeapShared::roots(), which is created in copy_roots_to_buffer() and
+  // doesn't have a corresponding src_obj, so we can't use EmbeddedOopRelocator on it.
+  oop requested_roots = requested_obj_from_buffer_offset(_heap_roots_bottom);
+  update_header_for_requested_obj(requested_roots, nullptr, Universe::objectArrayKlassObj());
+  int length = roots != nullptr ? roots->length() : 0;
+  for (int i = 0; i < length; i++) {
+    if (UseCompressedOops) {
+      relocate_root_at<narrowOop>(requested_roots, i);
+    } else {
+      relocate_root_at<oop>(requested_roots, i);
+    }
+  }
+
+  closed_bitmaps->append(make_bitmap_info(&closed_oopmap, /*is_open=*/false, /*is_oopmap=*/true));
+  open_bitmaps  ->append(make_bitmap_info(&open_oopmap,   /*is_open=*/false, /*is_oopmap=*/true));
+
+  closed_bitmaps->append(compute_ptrmap(/*is_open=*/false));
+  open_bitmaps  ->append(compute_ptrmap(/*is_open=*/true));
+
+  _closed_oopmap = nullptr;
+  _open_oopmap = nullptr;
+}
+
+ArchiveHeapBitmapInfo ArchiveHeapWriter::make_bitmap_info(ResourceBitMap* bitmap, bool is_open,  bool is_oopmap) {
+  size_t size_in_bits = bitmap->size();
+  size_t size_in_bytes;
+  uintptr_t* buffer;
+
+  if (size_in_bits > 0) {
+    size_in_bytes = bitmap->size_in_bytes();
+    buffer = (uintptr_t*)NEW_C_HEAP_ARRAY(char, size_in_bytes, mtInternal);
+    bitmap->write_to(buffer, size_in_bytes);
+  } else {
+    size_in_bytes = 0;
+    buffer = nullptr;
+  }
+
+  log_info(cds, heap)("%s @ " INTPTR_FORMAT " (" SIZE_FORMAT_W(6) " bytes) for %s heap region",
+                      is_oopmap ? "Oopmap" : "Ptrmap",
+                      p2i(buffer), size_in_bytes,
+                      is_open? "open" : "closed");
+
+  ArchiveHeapBitmapInfo info;
+  info._map = (address)buffer;
+  info._size_in_bits = size_in_bits;
+  info._size_in_bytes = size_in_bytes;
+
+  return info;
+}
+
+void ArchiveHeapWriter::mark_native_pointer(oop src_obj, int field_offset) {
+  Metadata* ptr = src_obj->metadata_field_acquire(field_offset);
+  if (ptr != nullptr) {
+    NativePointerInfo info;
+    info._src_obj = src_obj;
+    info._field_offset = field_offset;
+    _native_pointers->append(info);
+  }
+}
+
+ArchiveHeapBitmapInfo ArchiveHeapWriter::compute_ptrmap(bool is_open) {
+  int num_non_null_ptrs = 0;
+  Metadata** bottom = (Metadata**) (is_open ? _requested_open_region_bottom: _requested_closed_region_bottom);
+  Metadata** top = (Metadata**) (is_open ? _requested_open_region_top: _requested_closed_region_top); // exclusive
+  ResourceBitMap ptrmap(top - bottom);
+
+  for (int i = 0; i < _native_pointers->length(); i++) {
+    NativePointerInfo info = _native_pointers->at(i);
+    oop src_obj = info._src_obj;
+    int field_offset = info._field_offset;
+    HeapShared::CachedOopInfo* p = HeapShared::archived_object_cache()->get(src_obj);
+    if (p->in_open_region() == is_open) {
+      // requested_field_addr = the address of this field in the requested space
+      oop requested_obj = requested_obj_from_buffer_offset(p->buffer_offset());
+      Metadata** requested_field_addr = (Metadata**)(cast_from_oop<address>(requested_obj) + field_offset);
+      assert(bottom <= requested_field_addr && requested_field_addr < top, "range check");
+
+      // Mark this field in the bitmap
+      BitMap::idx_t idx = requested_field_addr - bottom;
+      ptrmap.set_bit(idx);
+      num_non_null_ptrs ++;
+
+      // Set the native pointer to the requested address of the metadata (at runtime, the metadata will have
+      // this address if the RO/RW regions are mapped at the default location).
+
+      Metadata** buffered_field_addr = requested_addr_to_buffered_addr(requested_field_addr);
+      Metadata* native_ptr = *buffered_field_addr;
+      assert(native_ptr != nullptr, "sanity");
+
+      address buffered_native_ptr = ArchiveBuilder::current()->get_buffered_addr((address)native_ptr);
+      address requested_native_ptr = ArchiveBuilder::current()->to_requested(buffered_native_ptr);
+      *buffered_field_addr = (Metadata*)requested_native_ptr;
+    }
+  }
+
+  log_info(cds, heap)("compute_ptrmap: marked %d non-null native pointers for %s heap region",
+                      num_non_null_ptrs, is_open ? "open" : "closed");
+
+  if (num_non_null_ptrs == 0) {
+    ResourceBitMap empty;
+    return make_bitmap_info(&empty, is_open, /*is_oopmap=*/ false);
+  } else {
+    return make_bitmap_info(&ptrmap, is_open, /*is_oopmap=*/ false);
+  }
+}
+
+#endif // INCLUDE_CDS_JAVA_HEAP
diff --git a/src/hotspot/share/cds/archiveHeapWriter.hpp b/src/hotspot/share/cds/archiveHeapWriter.hpp
new file mode 100644
index 00000000000..18eef9bcf46
--- /dev/null
+++ b/src/hotspot/share/cds/archiveHeapWriter.hpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_CDS_ARCHIVEHEAPWRITER_HPP
+#define SHARE_CDS_ARCHIVEHEAPWRITER_HPP
+
+#include "cds/heapShared.hpp"
+#include "memory/allocation.hpp"
+#include "memory/allStatic.hpp"
+#include "oops/oopHandle.hpp"
+#include "utilities/bitMap.hpp"
+#include "utilities/exceptions.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/macros.hpp"
+#include "utilities/resourceHash.hpp"
+
+#if INCLUDE_CDS_JAVA_HEAP
+
+struct ArchiveHeapBitmapInfo;
+class MemRegion;
+
+class ArchiveHeapWriter : AllStatic {
+  class EmbeddedOopRelocator;
+  struct NativePointerInfo {
+    oop _src_obj;
+    int _field_offset;
+  };
+
+  // The minimum region size of all collectors that are supported by CDS in
+  // ArchiveHeapLoader::can_map() mode. Currently only G1 is supported. G1's region size
+  // depends on -Xmx, but can never be smaller than 1 * M.
+  // (TODO: Perhaps change to 256K to be compatible with Shenandoah)
+  static constexpr int MIN_GC_REGION_ALIGNMENT = 1 * M;
+
+  // "source" vs "buffered" vs "requested"
+  //
+  // [1] HeapShared::archive_objects() identifies all of the oops that need to be stored
+  //     into the CDS archive. These are entered into HeapShared::archived_object_cache().
+  //     These are called "source objects"
+  //
+  // [2] ArchiveHeapWriter::write() copies all source objects into ArchiveHeapWriter::_buffer,
+  //     which is a GrowableArray that sites outside of the valid heap range. Therefore
+  //     we avoid using the addresses of these copies as oops. They are usually
+  //     called "buffered_addr" in the code (of the type "address").
+  //
+  // [3] Each archived object has a "requested address" -- at run time, if the object
+  //     can be mapped at this address, we can avoid relocation.
+  //
+  // Note: the design and convention is the same as for the archiving of Metaspace objects.
+  // See archiveBuilder.hpp.
+
+  static GrowableArrayCHeap<u1, mtClassShared>* _buffer;
+
+  // The exclusive top of the last object that has been copied into this->_buffer.
+  static size_t _buffer_top;
+
+  // The bounds of the open region inside this->_buffer.
+  static size_t _open_bottom;  // inclusive
+  static size_t _open_top;     // exclusive
+
+  // The bounds of the closed region inside this->_buffer.
+  static size_t _closed_bottom;  // inclusive
+  static size_t _closed_top;     // exclusive
+
+  // The bottom of the copy of Heap::roots() inside this->_buffer.
+  static size_t _heap_roots_bottom;
+  static size_t _heap_roots_word_size;
+
+  static address _requested_open_region_bottom;
+  static address _requested_open_region_top;
+  static address _requested_closed_region_bottom;
+  static address _requested_closed_region_top;
+
+  static ResourceBitMap* _closed_oopmap;
+  static ResourceBitMap* _open_oopmap;
+
+  static ArchiveHeapBitmapInfo _closed_oopmap_info;
+  static ArchiveHeapBitmapInfo _open_oopmap_info;
+
+  static GrowableArrayCHeap<NativePointerInfo, mtClassShared>* _native_pointers;
+  static GrowableArrayCHeap<oop, mtClassShared>* _source_objs;
+
+  typedef ResourceHashtable<size_t, oop,
+      36137, // prime number
+      AnyObj::C_HEAP,
+      mtClassShared> BufferOffsetToSourceObjectTable;
+  static BufferOffsetToSourceObjectTable* _buffer_offset_to_source_obj_table;
+
+  static void allocate_buffer();
+  static void ensure_buffer_space(size_t min_bytes);
+
+  // Both Java bytearray and GrowableArraty use int indices and lengths. Do a safe typecast with range check
+  static int to_array_index(size_t i) {
+    assert(i <= (size_t)max_jint, "must be");
+    return (size_t)i;
+  }
+  static int to_array_length(size_t n) {
+    return to_array_index(n);
+  }
+
+  template <typename T> static T offset_to_buffered_address(size_t offset) {
+    return (T)(_buffer->adr_at(to_array_index(offset)));
+  }
+
+  static address buffer_bottom() {
+    return offset_to_buffered_address<address>(0);
+  }
+
+  static address buffer_top() {
+    return buffer_bottom() + _buffer_top;
+  }
+
+  static bool in_buffer(address buffered_addr) {
+    return (buffer_bottom() <= buffered_addr) && (buffered_addr < buffer_top());
+  }
+
+  static size_t buffered_address_to_offset(address buffered_addr) {
+    assert(in_buffer(buffered_addr), "sanity");
+    return buffered_addr - buffer_bottom();
+  }
+
+  static void copy_roots_to_buffer(GrowableArrayCHeap<oop, mtClassShared>* roots);
+  static void copy_source_objs_to_buffer(GrowableArrayCHeap<oop, mtClassShared>* roots);
+  static void copy_source_objs_to_buffer_by_region(bool copy_open_region);
+  static size_t copy_one_source_obj_to_buffer(oop src_obj);
+
+  static void maybe_fill_gc_region_gap(size_t required_byte_size);
+  static size_t filler_array_byte_size(int length);
+  static int filler_array_length(size_t fill_bytes);
+  static void init_filler_array_at_buffer_top(int array_length, size_t fill_bytes);
+
+  static void set_requested_address_for_regions(GrowableArray<MemRegion>* closed_regions,
+                                                GrowableArray<MemRegion>* open_regions);
+  static void relocate_embedded_oops(GrowableArrayCHeap<oop, mtClassShared>* roots,
+                                     GrowableArray<ArchiveHeapBitmapInfo>* closed_bitmaps,
+                                     GrowableArray<ArchiveHeapBitmapInfo>* open_bitmaps);
+  static ArchiveHeapBitmapInfo compute_ptrmap(bool is_open);
+  static ArchiveHeapBitmapInfo make_bitmap_info(ResourceBitMap* bitmap, bool is_open,  bool is_oopmap);
+  static bool is_in_requested_regions(oop o);
+  static oop requested_obj_from_buffer_offset(size_t offset);
+
+  static oop load_oop_from_buffer(oop* buffered_addr);
+  static oop load_oop_from_buffer(narrowOop* buffered_addr);
+  static void store_oop_in_buffer(oop* buffered_addr, oop requested_obj);
+  static void store_oop_in_buffer(narrowOop* buffered_addr, oop requested_obj);
+
+  template <typename T> static oop load_source_oop_from_buffer(T* buffered_addr);
+  template <typename T> static void store_requested_oop_in_buffer(T* buffered_addr, oop request_oop);
+
+  template <typename T> static T* requested_addr_to_buffered_addr(T* p);
+  template <typename T> static void relocate_field_in_buffer(T* field_addr_in_buffer);
+  template <typename T> static void mark_oop_pointer(T* buffered_addr);
+  template <typename T> static void relocate_root_at(oop requested_roots, int index);
+
+  static void update_header_for_requested_obj(oop requested_obj, oop src_obj, Klass* src_klass);
+public:
+  static void init() NOT_CDS_JAVA_HEAP_RETURN;
+  static void add_source_obj(oop src_obj);
+  static bool is_too_large_to_archive(size_t size);
+  static bool is_too_large_to_archive(oop obj);
+  static bool is_string_too_large_to_archive(oop string);
+  static void write(GrowableArrayCHeap<oop, mtClassShared>*,
+                    GrowableArray<MemRegion>* closed_regions, GrowableArray<MemRegion>* open_regions,
+                    GrowableArray<ArchiveHeapBitmapInfo>* closed_bitmaps,
+                    GrowableArray<ArchiveHeapBitmapInfo>* open_bitmaps);
+  static address heap_region_requested_bottom(int heap_region_idx);
+  static oop heap_roots_requested_address();
+  static address buffered_heap_roots_addr() {
+    return offset_to_buffered_address<address>(_heap_roots_bottom);
+  }
+  static size_t heap_roots_word_size() {
+    return _heap_roots_word_size;
+  }
+
+  static void mark_native_pointer(oop src_obj, int offset);
+  static oop source_obj_to_requested_obj(oop src_obj);
+  static oop buffered_addr_to_source_obj(address buffered_addr);
+  static address buffered_addr_to_requested_addr(address buffered_addr);
+};
+#endif // INCLUDE_CDS_JAVA_HEAP
+#endif // SHARE_CDS_ARCHIVEHEAPWRITER_HPP
diff --git a/src/hotspot/share/cds/cdsHeapVerifier.cpp b/src/hotspot/share/cds/cdsHeapVerifier.cpp
index 1b17536c63f..b687ad566b3 100644
--- a/src/hotspot/share/cds/cdsHeapVerifier.cpp
+++ b/src/hotspot/share/cds/cdsHeapVerifier.cpp
@@ -276,10 +276,10 @@ void CDSHeapVerifier::trace_to_root(outputStream* st, oop orig_obj) {
 
 int CDSHeapVerifier::trace_to_root(outputStream* st, oop orig_obj, oop orig_field, HeapShared::CachedOopInfo* info) {
   int level = 0;
-  if (info->_referrer != nullptr) {
-    HeapShared::CachedOopInfo* ref = HeapShared::archived_object_cache()->get(info->_referrer);
+  if (info->orig_referrer() != nullptr) {
+    HeapShared::CachedOopInfo* ref = HeapShared::archived_object_cache()->get(info->orig_referrer());
     assert(ref != nullptr, "sanity");
-    level = trace_to_root(st, info->_referrer, orig_obj, ref) + 1;
+    level = trace_to_root(st, info->orig_referrer(), orig_obj, ref) + 1;
   } else if (java_lang_String::is_instance(orig_obj)) {
     st->print_cr("[%2d] (shared string table)", level++);
   }
diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp
index 1a3fb8b949d..2bd5012dadf 100644
--- a/src/hotspot/share/cds/filemap.cpp
+++ b/src/hotspot/share/cds/filemap.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "cds/archiveBuilder.hpp"
 #include "cds/archiveHeapLoader.inline.hpp"
+#include "cds/archiveHeapWriter.hpp"
 #include "cds/archiveUtils.inline.hpp"
 #include "cds/cds_globals.hpp"
 #include "cds/dynamicArchive.hpp"
@@ -1632,16 +1633,19 @@ void FileMapInfo::write_region(int region, char* base, size_t size,
     // This is an unused region (e.g., a heap region when !INCLUDE_CDS_JAVA_HEAP)
     requested_base = nullptr;
   } else if (HeapShared::is_heap_region(region)) {
+    assert(HeapShared::can_write(), "sanity");
+#if INCLUDE_CDS_JAVA_HEAP
     assert(!DynamicDumpSharedSpaces, "must be");
-    requested_base = base;
+    requested_base = (char*)ArchiveHeapWriter::heap_region_requested_bottom(region);
     if (UseCompressedOops) {
-      mapping_offset = (size_t)((address)base - CompressedOops::base());
+      mapping_offset = (size_t)((address)requested_base - CompressedOops::base());
       assert((mapping_offset >> CompressedOops::shift()) << CompressedOops::shift() == mapping_offset, "must be");
     } else {
 #if INCLUDE_G1GC
       mapping_offset = requested_base - (char*)G1CollectedHeap::heap()->reserved().start();
 #endif
     }
+#endif // INCLUDE_CDS_JAVA_HEAP
   } else {
     char* requested_SharedBaseAddress = (char*)MetaspaceShared::requested_base_address();
     requested_base = ArchiveBuilder::current()->to_requested(base);
diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp
index ef706b60aaa..6beac5f763e 100644
--- a/src/hotspot/share/cds/heapShared.cpp
+++ b/src/hotspot/share/cds/heapShared.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "cds/archiveBuilder.hpp"
 #include "cds/archiveHeapLoader.hpp"
+#include "cds/archiveHeapWriter.hpp"
 #include "cds/archiveUtils.hpp"
 #include "cds/cdsHeapVerifier.hpp"
 #include "cds/heapShared.hpp"
@@ -61,7 +62,6 @@
 #include "utilities/copy.hpp"
 #if INCLUDE_G1GC
 #include "gc/g1/g1CollectedHeap.hpp"
-#include "gc/g1/heapRegion.hpp"
 #endif
 
 #if INCLUDE_CDS_JAVA_HEAP
@@ -82,8 +82,8 @@ struct ArchivableStaticFieldInfo {
 };
 
 bool HeapShared::_disable_writing = false;
+bool HeapShared::_copying_open_region_objects = false;
 DumpedInternedStrings *HeapShared::_dumped_interned_strings = nullptr;
-GrowableArrayCHeap<Metadata**, mtClassShared>* HeapShared::_native_pointers = nullptr;
 
 size_t HeapShared::_alloc_count[HeapShared::ALLOC_STAT_SLOTS];
 size_t HeapShared::_alloc_size[HeapShared::ALLOC_STAT_SLOTS];
@@ -143,14 +143,6 @@ OopHandle HeapShared::_roots;
 OopHandle HeapShared::_scratch_basic_type_mirrors[T_VOID+1];
 KlassToOopHandleTable* HeapShared::_scratch_java_mirror_table = nullptr;
 
-#ifdef ASSERT
-bool HeapShared::is_archived_object_during_dumptime(oop p) {
-  assert(HeapShared::can_write(), "must be");
-  assert(DumpSharedSpaces, "this function is only used with -Xshare:dump");
-  return Universe::heap()->is_archived_object(p);
-}
-#endif
-
 static bool is_subgraph_root_class_of(ArchivableStaticFieldInfo fields[], InstanceKlass* ik) {
   for (int i = 0; fields[i].valid(); i++) {
     if (fields[i].klass == ik) {
@@ -220,16 +212,10 @@ void HeapShared::reset_archived_object_states(TRAPS) {
 }
 
 HeapShared::ArchivedObjectCache* HeapShared::_archived_object_cache = nullptr;
-HeapShared::OriginalObjectTable* HeapShared::_original_object_table = nullptr;
-oop HeapShared::find_archived_heap_object(oop obj) {
+
+bool HeapShared::has_been_archived(oop obj) {
   assert(DumpSharedSpaces, "dump-time only");
-  ArchivedObjectCache* cache = archived_object_cache();
-  CachedOopInfo* p = cache->get(obj);
-  if (p != nullptr) {
-    return p->_obj;
-  } else {
-    return nullptr;
-  }
+  return archived_object_cache()->get(obj) != nullptr;
 }
 
 int HeapShared::append_root(oop obj) {
@@ -263,19 +249,13 @@ objArrayOop HeapShared::roots() {
 // Returns an objArray that contains all the roots of the archived objects
 oop HeapShared::get_root(int index, bool clear) {
   assert(index >= 0, "sanity");
-  if (DumpSharedSpaces) {
-    assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
-    assert(_pending_roots != nullptr, "sanity");
-    return _pending_roots->at(index);
-  } else {
-    assert(UseSharedSpaces, "must be");
-    assert(!_roots.is_empty(), "must have loaded shared heap");
-    oop result = roots()->obj_at(index);
-    if (clear) {
-      clear_root(index);
-    }
-    return result;
+  assert(!DumpSharedSpaces && UseSharedSpaces, "runtime only");
+  assert(!_roots.is_empty(), "must have loaded shared heap");
+  oop result = roots()->obj_at(index);
+  if (clear) {
+    clear_root(index);
   }
+  return result;
 }
 
 void HeapShared::clear_root(int index) {
@@ -290,71 +270,47 @@ void HeapShared::clear_root(int index) {
   }
 }
 
-bool HeapShared::is_too_large_to_archive(oop o) {
-  // TODO: To make the CDS heap mappable for all collectors, this function should
-  // reject objects that may be too large for *any* collector.
-  assert(UseG1GC, "implementation limitation");
-  size_t sz = align_up(o->size() * HeapWordSize, ObjectAlignmentInBytes);
-  size_t max = /*G1*/HeapRegion::min_region_size_in_words() * HeapWordSize;
-  return (sz > max);
-}
-
-oop HeapShared::archive_object(oop obj) {
+bool HeapShared::archive_object(oop obj) {
   assert(DumpSharedSpaces, "dump-time only");
 
   assert(!obj->is_stackChunk(), "do not archive stack chunks");
-
-  oop ao = find_archived_heap_object(obj);
-  if (ao != nullptr) {
-    // already archived
-    return ao;
+  if (has_been_archived(obj)) {
+    return true;
   }
 
-  int len = obj->size();
-  if (G1CollectedHeap::heap()->is_archive_alloc_too_large(len)) {
+  if (ArchiveHeapWriter::is_too_large_to_archive(obj->size())) {
     log_debug(cds, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: " SIZE_FORMAT,
-                         p2i(obj), (size_t)obj->size());
-    return nullptr;
-  }
+                         p2i(obj), obj->size());
+    return false;
+  } else {
+    count_allocation(obj->size());
+    ArchiveHeapWriter::add_source_obj(obj);
+
+    CachedOopInfo info = make_cached_oop_info();
+    archived_object_cache()->put(obj, info);
+    mark_native_pointers(obj);
 
-  oop archived_oop = cast_to_oop(G1CollectedHeap::heap()->archive_mem_allocate(len));
-  if (archived_oop != nullptr) {
-    count_allocation(len);
-    Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), cast_from_oop<HeapWord*>(archived_oop), len);
-    // Reinitialize markword to remove age/marking/locking/etc.
-    //
-    // We need to retain the identity_hash, because it may have been used by some hashtables
-    // in the shared heap. This also has the side effect of pre-initializing the
-    // identity_hash for all shared objects, so they are less likely to be written
-    // into during run time, increasing the potential of memory sharing.
-    int hash_original = obj->identity_hash();
-    archived_oop->set_mark(markWord::prototype().copy_set_hash(hash_original));
-    assert(archived_oop->mark().is_unlocked(), "sanity");
-
-    DEBUG_ONLY(int hash_archived = archived_oop->identity_hash());
-    assert(hash_original == hash_archived, "Different hash codes: original %x, archived %x", hash_original, hash_archived);
-
-    ArchivedObjectCache* cache = archived_object_cache();
-    CachedOopInfo info = make_cached_oop_info(archived_oop);
-    cache->put(obj, info);
-    if (_original_object_table != nullptr) {
-      _original_object_table->put(archived_oop, obj);
-    }
-    mark_native_pointers(obj, archived_oop);
     if (log_is_enabled(Debug, cds, heap)) {
       ResourceMark rm;
-      log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT " : %s",
-                           p2i(obj), p2i(archived_oop), obj->klass()->external_name());
+      log_debug(cds, heap)("Archived heap object " PTR_FORMAT " : %s",
+                           p2i(obj), obj->klass()->external_name());
     }
-  } else {
-    log_error(cds, heap)(
-      "Cannot allocate space for object " PTR_FORMAT " in archived heap region",
-      p2i(obj));
-    log_error(cds)("Out of memory. Please run with a larger Java heap, current MaxHeapSize = "
-        SIZE_FORMAT "M", MaxHeapSize/M);
-    os::_exit(-1);
+
+    if (java_lang_Module::is_instance(obj)) {
+      if (Modules::check_module_oop(obj)) {
+        Modules::update_oops_in_archived_module(obj, append_root(obj));
+      }
+      java_lang_Module::set_module_entry(obj, nullptr);
+    } else if (java_lang_ClassLoader::is_instance(obj)) {
+      // class_data will be restored explicitly at run time.
+      guarantee(obj == SystemDictionary::java_platform_loader() ||
+                obj == SystemDictionary::java_system_loader() ||
+                java_lang_ClassLoader::loader_data(obj) == nullptr, "must be");
+      java_lang_ClassLoader::release_set_loader_data(obj, nullptr);
+    }
+
+    return true;
   }
-  return archived_oop;
 }
 
 class KlassToOopHandleTable: public ResourceHashtable<Klass*, OopHandle,
@@ -424,14 +380,14 @@ void HeapShared::archive_java_mirrors() {
     if (!is_reference_type(bt)) {
       oop m = _scratch_basic_type_mirrors[i].resolve();
       assert(m != nullptr, "sanity");
-      oop archived_m = archive_reachable_objects_from(1, _default_subgraph_info, m, /*is_closed_archive=*/ false);
-      assert(archived_m != nullptr, "sanity");
+      bool success = archive_reachable_objects_from(1, _default_subgraph_info, m, /*is_closed_archive=*/ false);
+      assert(success, "sanity");
 
       log_trace(cds, heap, mirror)(
-        "Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
-        type2name(bt), p2i(m), p2i(archived_m));
+        "Archived %s mirror object from " PTR_FORMAT,
+        type2name(bt), p2i(m));
 
-      Universe::set_archived_basic_type_mirror_index(bt, append_root(archived_m));
+      Universe::set_archived_basic_type_mirror_index(bt, append_root(m));
     }
   }
 
@@ -442,23 +398,23 @@ void HeapShared::archive_java_mirrors() {
     oop m = scratch_java_mirror(orig_k);
     if (m != nullptr) {
       Klass* buffered_k = ArchiveBuilder::get_buffered_klass(orig_k);
-      oop archived_m = archive_reachable_objects_from(1, _default_subgraph_info, m, /*is_closed_archive=*/ false);
-      guarantee(archived_m != nullptr, "scratch mirrors should not point to any unachivable objects");
-      buffered_k->set_archived_java_mirror(append_root(archived_m));
+      bool success = archive_reachable_objects_from(1, _default_subgraph_info, m, /*is_closed_archive=*/ false);
+      guarantee(success, "scratch mirrors should not point to any unachivable objects");
+      buffered_k->set_archived_java_mirror(append_root(m));
       ResourceMark rm;
       log_trace(cds, heap, mirror)(
-        "Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
-        buffered_k->external_name(), p2i(m), p2i(archived_m));
+        "Archived %s mirror object from " PTR_FORMAT,
+        buffered_k->external_name(), p2i(m));
 
       // archive the resolved_referenes array
       if (buffered_k->is_instance_klass()) {
         InstanceKlass* ik = InstanceKlass::cast(buffered_k);
         oop rr = ik->constants()->prepare_resolved_references_for_archiving();
-        if (rr != nullptr && !is_too_large_to_archive(rr)) {
-          oop archived_obj = HeapShared::archive_reachable_objects_from(1, _default_subgraph_info, rr,
-                                                                        /*is_closed_archive=*/false);
-          assert(archived_obj != nullptr,  "already checked not too large to archive");
-          int root_index = append_root(archived_obj);
+        if (rr != nullptr && !ArchiveHeapWriter::is_too_large_to_archive(rr)) {
+          bool success = HeapShared::archive_reachable_objects_from(1, _default_subgraph_info, rr,
+                                                                    /*is_closed_archive=*/false);
+          assert(success, "must be");
+          int root_index = append_root(rr);
           ik->constants()->cache()->set_archived_references(root_index);
         }
       }
@@ -468,29 +424,10 @@ void HeapShared::archive_java_mirrors() {
   delete_seen_objects_table();
 }
 
-void HeapShared::mark_native_pointers(oop orig_obj, oop archived_obj) {
+void HeapShared::mark_native_pointers(oop orig_obj) {
   if (java_lang_Class::is_instance(orig_obj)) {
-    mark_one_native_pointer(archived_obj, java_lang_Class::klass_offset());
-    mark_one_native_pointer(archived_obj, java_lang_Class::array_klass_offset());
-  }
-}
-
-void HeapShared::mark_one_native_pointer(oop archived_obj, int offset) {
-  Metadata* ptr = archived_obj->metadata_field_acquire(offset);
-  if (ptr != nullptr) {
-    // Set the native pointer to the requested address (at runtime, if the metadata
-    // is mapped at the default location, it will be at this address).
-    address buffer_addr = ArchiveBuilder::current()->get_buffered_addr((address)ptr);
-    address requested_addr = ArchiveBuilder::current()->to_requested(buffer_addr);
-    archived_obj->metadata_field_put(offset, (Metadata*)requested_addr);
-
-    // Remember this pointer. At runtime, if the metadata is mapped at a non-default
-    // location, the pointer needs to be patched (see ArchiveHeapLoader::patch_native_pointers()).
-    _native_pointers->append(archived_obj->field_addr<Metadata*>(offset));
-
-    log_debug(cds, heap, mirror)(
-        "Marked metadata field at %d: " PTR_FORMAT " ==> " PTR_FORMAT,
-         offset, p2i(ptr), p2i(requested_addr));
+    ArchiveHeapWriter::mark_native_pointer(orig_obj, java_lang_Class::klass_offset());
+    ArchiveHeapWriter::mark_native_pointer(orig_obj, java_lang_Class::array_klass_offset());
   }
 }
 
@@ -517,6 +454,7 @@ void HeapShared::check_enum_obj(int level,
                                 KlassSubGraphInfo* subgraph_info,
                                 oop orig_obj,
                                 bool is_closed_archive) {
+  assert(level > 1, "must never be called at the first (outermost) level");
   Klass* k = orig_obj->klass();
   Klass* buffered_k = ArchiveBuilder::get_buffered_klass(k);
   if (!k->is_instance_klass()) {
@@ -544,11 +482,12 @@ void HeapShared::check_enum_obj(int level,
           guarantee(false, "static field %s::%s is of the wrong type",
                     ik->external_name(), fd.name()->as_C_string());
         }
-        oop archived_oop_field = archive_reachable_objects_from(level, subgraph_info, oop_field, is_closed_archive);
-        int root_index = append_root(archived_oop_field);
-        log_info(cds, heap)("Archived enum obj @%d %s::%s (" INTPTR_FORMAT " -> " INTPTR_FORMAT ")",
+        bool success = archive_reachable_objects_from(level, subgraph_info, oop_field, is_closed_archive);
+        assert(success, "VM should have exited with unarchivable objects for _level > 1");
+        int root_index = append_root(oop_field);
+        log_info(cds, heap)("Archived enum obj @%d %s::%s (" INTPTR_FORMAT ")",
                             root_index, ik->external_name(), fd.name()->as_C_string(),
-                            p2i((oopDesc*)oop_field), p2i((oopDesc*)archived_oop_field));
+                            p2i((oopDesc*)oop_field));
         SystemDictionaryShared::add_enum_klass_static_field(ik, root_index);
       }
     }
@@ -582,37 +521,17 @@ bool HeapShared::initialize_enum_klass(InstanceKlass* k, TRAPS) {
   return true;
 }
 
-void HeapShared::run_full_gc_in_vm_thread() {
-  if (HeapShared::can_write()) {
-    // Avoid fragmentation while archiving heap objects.
-    // We do this inside a safepoint, so that no further allocation can happen after GC
-    // has finished.
-    if (GCLocker::is_active()) {
-      // Just checking for safety ...
-      // This should not happen during -Xshare:dump. If you see this, probably the Java core lib
-      // has been modified such that JNI code is executed in some clean up threads after
-      // we have finished class loading.
-      log_warning(cds)("GC locker is held, unable to start extra compacting GC. This may produce suboptimal results.");
-    } else {
-      log_info(cds)("Run GC ...");
-      Universe::heap()->collect_as_vm_thread(GCCause::_archive_time_gc);
-      log_info(cds)("Run GC done");
-    }
-  }
-}
-
 void HeapShared::archive_objects(GrowableArray<MemRegion>* closed_regions,
-                                 GrowableArray<MemRegion>* open_regions) {
-
-  G1HeapVerifier::verify_ready_for_archiving();
-
+                                 GrowableArray<MemRegion>* open_regions,
+                                 GrowableArray<ArchiveHeapBitmapInfo>* closed_bitmaps,
+                                 GrowableArray<ArchiveHeapBitmapInfo>* open_bitmaps) {
   {
     NoSafepointVerifier nsv;
 
     _default_subgraph_info = init_subgraph_info(vmClasses::Object_klass(), false);
 
     // Cache for recording where the archived objects are copied to
-    create_archived_object_cache(log_is_enabled(Info, cds, map));
+    create_archived_object_cache();
 
     log_info(cds)("Heap range = [" PTR_FORMAT " - "  PTR_FORMAT "]",
                    UseCompressedOops ? p2i(CompressedOops::begin()) :
@@ -620,16 +539,18 @@ void HeapShared::archive_objects(GrowableArray<MemRegion>* closed_regions,
                    UseCompressedOops ? p2i(CompressedOops::end()) :
                                        p2i((address)G1CollectedHeap::heap()->reserved().end()));
     log_info(cds)("Dumping objects to closed archive heap region ...");
-    copy_closed_objects(closed_regions);
+    copy_closed_objects();
+
+    _copying_open_region_objects = true;
 
     log_info(cds)("Dumping objects to open archive heap region ...");
-    copy_open_objects(open_regions);
+    copy_open_objects();
 
     CDSHeapVerifier::verify();
     check_default_subgraph_classes();
   }
 
-  G1HeapVerifier::verify_archive_regions();
+  ArchiveHeapWriter::write(_pending_roots, closed_regions, open_regions, closed_bitmaps, open_bitmaps);
   StringTable::write_shared_table(_dumped_interned_strings);
 }
 
@@ -638,14 +559,13 @@ void HeapShared::copy_interned_strings() {
 
   auto copier = [&] (oop s, bool value_ignored) {
     assert(s != nullptr, "sanity");
-    typeArrayOop value = java_lang_String::value_no_keepalive(s);
-    if (!HeapShared::is_too_large_to_archive(value)) {
-      oop archived_s = archive_reachable_objects_from(1, _default_subgraph_info,
-                                                      s, /*is_closed_archive=*/true);
-      assert(archived_s != nullptr, "already checked not too large to archive");
+    if (!ArchiveHeapWriter::is_string_too_large_to_archive(s)) {
+      bool success = archive_reachable_objects_from(1, _default_subgraph_info,
+                                                    s, /*is_closed_archive=*/true);
+      assert(success, "must be");
       // Prevent string deduplication from changing the value field to
       // something not in the archive.
-      java_lang_String::set_deduplication_forbidden(archived_s);
+      java_lang_String::set_deduplication_forbidden(s);
     }
   };
   _dumped_interned_strings->iterate_all(copier);
@@ -653,27 +573,20 @@ void HeapShared::copy_interned_strings() {
   delete_seen_objects_table();
 }
 
-void HeapShared::copy_closed_objects(GrowableArray<MemRegion>* closed_regions) {
+void HeapShared::copy_closed_objects() {
   assert(HeapShared::can_write(), "must be");
 
-  G1CollectedHeap::heap()->begin_archive_alloc_range();
-
   // Archive interned string objects
   copy_interned_strings();
 
   archive_object_subgraphs(closed_archive_subgraph_entry_fields,
                            true /* is_closed_archive */,
                            false /* is_full_module_graph */);
-
-  G1CollectedHeap::heap()->end_archive_alloc_range(closed_regions,
-                                                   os::vm_allocation_granularity());
 }
 
-void HeapShared::copy_open_objects(GrowableArray<MemRegion>* open_regions) {
+void HeapShared::copy_open_objects() {
   assert(HeapShared::can_write(), "must be");
 
-  G1CollectedHeap::heap()->begin_archive_alloc_range(true /* open */);
-
   archive_java_mirrors();
 
   archive_object_subgraphs(open_archive_subgraph_entry_fields,
@@ -685,43 +598,6 @@ void HeapShared::copy_open_objects(GrowableArray<MemRegion>* open_regions) {
                              true /* is_full_module_graph */);
     Modules::verify_archived_modules();
   }
-
-  copy_roots();
-
-  G1CollectedHeap::heap()->end_archive_alloc_range(open_regions,
-                                                   os::vm_allocation_granularity());
-}
-
-// Copy _pending_archive_roots into an objArray
-void HeapShared::copy_roots() {
-  // HeapShared::roots() points into an ObjArray in the open archive region. A portion of the
-  // objects in this array are discovered during HeapShared::archive_objects(). For example,
-  // in HeapShared::archive_reachable_objects_from() ->  HeapShared::check_enum_obj().
-  // However, HeapShared::archive_objects() happens inside a safepoint, so we can't
-  // allocate a "regular" ObjArray and pass the result to HeapShared::archive_object().
-  // Instead, we have to roll our own alloc/copy routine here.
-  int length = _pending_roots != nullptr ? _pending_roots->length() : 0;
-  size_t size = objArrayOopDesc::object_size(length);
-  Klass* k = Universe::objectArrayKlassObj(); // already relocated to point to archived klass
-  HeapWord* mem = G1CollectedHeap::heap()->archive_mem_allocate(size);
-
-  memset(mem, 0, size * BytesPerWord);
-  {
-    // This is copied from MemAllocator::finish
-    oopDesc::set_mark(mem, markWord::prototype());
-    oopDesc::release_set_klass(mem, k);
-  }
-  {
-    // This is copied from ObjArrayAllocator::initialize
-    arrayOopDesc::set_length(mem, length);
-  }
-
-  _roots = OopHandle(Universe::vm_global(), cast_to_oop(mem));
-  for (int i = 0; i < length; i++) {
-    roots()->obj_at_put(i, _pending_roots->at(i));
-  }
-  log_info(cds)("archived obj roots[%d] = " SIZE_FORMAT " words, klass = %p, obj = %p", length, size, k, mem);
-  count_allocation(roots()->size());
 }
 
 //
@@ -985,7 +861,9 @@ void HeapShared::serialize_root(SerializeClosure* soc) {
     }
   } else {
     // writing
-    roots_oop = roots();
+    if (HeapShared::can_write()) {
+      roots_oop = ArchiveHeapWriter::heap_roots_requested_address();
+    }
     soc->do_oop(&roots_oop); // write to archive
   }
 }
@@ -1223,8 +1101,7 @@ class WalkOopAndArchiveClosure: public BasicOopIterateClosure {
   bool _is_closed_archive;
   bool _record_klasses_only;
   KlassSubGraphInfo* _subgraph_info;
-  oop _orig_referencing_obj;
-  oop _archived_referencing_obj;
+  oop _referencing_obj;
 
   // The following are for maintaining a stack for determining
   // CachedOopInfo::_referrer
@@ -1235,11 +1112,11 @@ class WalkOopAndArchiveClosure: public BasicOopIterateClosure {
                            bool is_closed_archive,
                            bool record_klasses_only,
                            KlassSubGraphInfo* subgraph_info,
-                           oop orig, oop archived) :
+                           oop orig) :
     _level(level), _is_closed_archive(is_closed_archive),
     _record_klasses_only(record_klasses_only),
     _subgraph_info(subgraph_info),
-    _orig_referencing_obj(orig), _archived_referencing_obj(archived) {
+    _referencing_obj(orig) {
     _last = _current;
     _current = this;
   }
@@ -1253,16 +1130,12 @@ class WalkOopAndArchiveClosure: public BasicOopIterateClosure {
   template <class T> void do_oop_work(T *p) {
     oop obj = RawAccess<>::oop_load(p);
     if (!CompressedOops::is_null(obj)) {
-      assert(!HeapShared::is_archived_object_during_dumptime(obj),
-             "original objects must not point to archived objects");
-
-      size_t field_delta = pointer_delta(p, _orig_referencing_obj, sizeof(char));
-      T* new_p = (T*)(cast_from_oop<address>(_archived_referencing_obj) + field_delta);
+      size_t field_delta = pointer_delta(p, _referencing_obj, sizeof(char));
 
       if (!_record_klasses_only && log_is_enabled(Debug, cds, heap)) {
         ResourceMark rm;
         log_debug(cds, heap)("(%d) %s[" SIZE_FORMAT "] ==> " PTR_FORMAT " size " SIZE_FORMAT " %s", _level,
-                             _orig_referencing_obj->klass()->external_name(), field_delta,
+                             _referencing_obj->klass()->external_name(), field_delta,
                              p2i(obj), obj->size() * HeapWordSize, obj->klass()->external_name());
         if (log_is_enabled(Trace, cds, heap)) {
           LogTarget(Trace, cds, heap) log;
@@ -1271,37 +1144,24 @@ class WalkOopAndArchiveClosure: public BasicOopIterateClosure {
         }
       }
 
-      oop archived = HeapShared::archive_reachable_objects_from(
+      bool success = HeapShared::archive_reachable_objects_from(
           _level + 1, _subgraph_info, obj, _is_closed_archive);
-      assert(archived != nullptr, "VM should have exited with unarchivable objects for _level > 1");
-      assert(HeapShared::is_archived_object_during_dumptime(archived), "must be");
-
-      if (!_record_klasses_only) {
-        // Update the reference in the archived copy of the referencing object.
-        log_debug(cds, heap)("(%d) updating oop @[" PTR_FORMAT "] " PTR_FORMAT " ==> " PTR_FORMAT,
-                             _level, p2i(new_p), p2i(obj), p2i(archived));
-        RawAccess<IS_NOT_NULL>::oop_store(new_p, archived);
-      }
+      assert(success, "VM should have exited with unarchivable objects for _level > 1");
     }
   }
 
  public:
   static WalkOopAndArchiveClosure* current()  { return _current;              }
-  oop orig_referencing_obj()                  { return _orig_referencing_obj; }
+  oop referencing_obj()                       { return _referencing_obj;      }
   KlassSubGraphInfo* subgraph_info()          { return _subgraph_info;        }
 };
 
 WalkOopAndArchiveClosure* WalkOopAndArchiveClosure::_current = nullptr;
 
-HeapShared::CachedOopInfo HeapShared::make_cached_oop_info(oop orig_obj) {
-  CachedOopInfo info;
+HeapShared::CachedOopInfo HeapShared::make_cached_oop_info() {
   WalkOopAndArchiveClosure* walker = WalkOopAndArchiveClosure::current();
-
-  info._subgraph_info = (walker == nullptr) ? nullptr : walker->subgraph_info();
-  info._referrer = (walker == nullptr) ? nullptr : walker->orig_referencing_obj();
-  info._obj = orig_obj;
-
-  return info;
+  oop referrer = (walker == nullptr) ? nullptr : walker->referencing_obj();
+  return CachedOopInfo(referrer, _copying_open_region_objects);
 }
 
 void HeapShared::check_closed_region_object(InstanceKlass* k) {
@@ -1324,12 +1184,11 @@ void HeapShared::check_closed_region_object(InstanceKlass* k) {
 // (2) If orig_obj has not been seen yet (since start_recording_subgraph() was called),
 //     trace all  objects that are reachable from it, and make sure these objects are archived.
 // (3) Record the klasses of all orig_obj and all reachable objects.
-oop HeapShared::archive_reachable_objects_from(int level,
-                                               KlassSubGraphInfo* subgraph_info,
-                                               oop orig_obj,
-                                               bool is_closed_archive) {
+bool HeapShared::archive_reachable_objects_from(int level,
+                                                KlassSubGraphInfo* subgraph_info,
+                                                oop orig_obj,
+                                                bool is_closed_archive) {
   assert(orig_obj != nullptr, "must be");
-  assert(!is_archived_object_during_dumptime(orig_obj), "sanity");
 
   if (!JavaClasses::is_supported_for_archiving(orig_obj)) {
     // This object has injected fields that cannot be supported easily, so we disallow them for now.
@@ -1350,25 +1209,18 @@ oop HeapShared::archive_reachable_objects_from(int level,
     os::_exit(1);
   }
 
-  oop archived_obj = find_archived_heap_object(orig_obj);
-  if (java_lang_String::is_instance(orig_obj) && archived_obj != nullptr) {
-    // To save time, don't walk strings that are already archived. They just contain
-    // pointers to a type array, whose klass doesn't need to be recorded.
-    return archived_obj;
-  }
-
   if (has_been_seen_during_subgraph_recording(orig_obj)) {
     // orig_obj has already been archived and traced. Nothing more to do.
-    return archived_obj;
+    return true;
   } else {
     set_has_been_seen_during_subgraph_recording(orig_obj);
   }
 
-  bool record_klasses_only = (archived_obj != nullptr);
-  if (archived_obj == nullptr) {
+  bool already_archived = has_been_archived(orig_obj);
+  bool record_klasses_only = already_archived;
+  if (!already_archived) {
     ++_num_new_archived_objs;
-    archived_obj = archive_object(orig_obj);
-    if (archived_obj == nullptr) {
+    if (!archive_object(orig_obj)) {
       // Skip archiving the sub-graph referenced from the current entry field.
       ResourceMark rm;
       log_error(cds, heap)(
@@ -1378,7 +1230,7 @@ oop HeapShared::archive_reachable_objects_from(int level,
       if (level == 1) {
         // Don't archive a subgraph root that's too big. For archives static fields, that's OK
         // as the Java code will take care of initializing this field dynamically.
-        return nullptr;
+        return false;
       } else {
         // We don't know how to handle an object that has been archived, but some of its reachable
         // objects cannot be archived. Bail out for now. We might need to fix this in the future if
@@ -1386,34 +1238,20 @@ oop HeapShared::archive_reachable_objects_from(int level,
         os::_exit(1);
       }
     }
-
-    if (java_lang_Module::is_instance(orig_obj)) {
-      if (Modules::check_module_oop(orig_obj)) {
-        Modules::update_oops_in_archived_module(orig_obj, append_root(archived_obj));
-      }
-      java_lang_Module::set_module_entry(archived_obj, nullptr);
-    } else if (java_lang_ClassLoader::is_instance(orig_obj)) {
-      // class_data will be restored explicitly at run time.
-      guarantee(orig_obj == SystemDictionary::java_platform_loader() ||
-                orig_obj == SystemDictionary::java_system_loader() ||
-                java_lang_ClassLoader::loader_data(orig_obj) == nullptr, "must be");
-      java_lang_ClassLoader::release_set_loader_data(archived_obj, nullptr);
-    }
   }
 
-  assert(archived_obj != nullptr, "must be");
   Klass *orig_k = orig_obj->klass();
   subgraph_info->add_subgraph_object_klass(orig_k);
 
   WalkOopAndArchiveClosure walker(level, is_closed_archive, record_klasses_only,
-                                  subgraph_info, orig_obj, archived_obj);
+                                  subgraph_info, orig_obj);
   orig_obj->oop_iterate(&walker);
   if (is_closed_archive && orig_k->is_instance_klass()) {
     check_closed_region_object(InstanceKlass::cast(orig_k));
   }
 
   check_enum_obj(level + 1, subgraph_info, orig_obj, is_closed_archive);
-  return archived_obj;
+  return true;
 }
 
 //
@@ -1472,17 +1310,17 @@ void HeapShared::archive_reachable_objects_from_static_field(InstanceKlass *k,
       f->print_on(&out);
     }
 
-    oop af = archive_reachable_objects_from(1, subgraph_info, f, is_closed_archive);
+    bool success = archive_reachable_objects_from(1, subgraph_info, f, is_closed_archive);
 
-    if (af == nullptr) {
+    if (!success) {
       log_error(cds, heap)("Archiving failed %s::%s (some reachable objects cannot be archived)",
                            klass_name, field_name);
     } else {
       // Note: the field value is not preserved in the archived mirror.
       // Record the field as a new subGraph entry point. The recorded
       // information is restored from the archive at runtime.
-      subgraph_info->add_subgraph_entry_field(field_offset, af, is_closed_archive);
-      log_info(cds, heap)("Archived field %s::%s => " PTR_FORMAT, klass_name, field_name, p2i(af));
+      subgraph_info->add_subgraph_entry_field(field_offset, f, is_closed_archive);
+      log_info(cds, heap)("Archived field %s::%s => " PTR_FORMAT, klass_name, field_name, p2i(f));
     }
   } else {
     // The field contains null, we still need to record the entry point,
@@ -1493,12 +1331,7 @@ void HeapShared::archive_reachable_objects_from_static_field(InstanceKlass *k,
 
 #ifndef PRODUCT
 class VerifySharedOopClosure: public BasicOopIterateClosure {
- private:
-  bool _is_archived;
-
  public:
-  VerifySharedOopClosure(bool is_archived) : _is_archived(is_archived) {}
-
   void do_oop(narrowOop *p) { VerifySharedOopClosure::do_oop_work(p); }
   void do_oop(      oop *p) { VerifySharedOopClosure::do_oop_work(p); }
 
@@ -1506,7 +1339,7 @@ class VerifySharedOopClosure: public BasicOopIterateClosure {
   template <class T> void do_oop_work(T *p) {
     oop obj = RawAccess<>::oop_load(p);
     if (!CompressedOops::is_null(obj)) {
-      HeapShared::verify_reachable_objects_from(obj, _is_archived);
+      HeapShared::verify_reachable_objects_from(obj);
     }
   }
 };
@@ -1523,8 +1356,7 @@ void HeapShared::verify_subgraph_from_static_field(InstanceKlass* k, int field_o
 }
 
 void HeapShared::verify_subgraph_from(oop orig_obj) {
-  oop archived_obj = find_archived_heap_object(orig_obj);
-  if (archived_obj == nullptr) {
+  if (!has_been_archived(orig_obj)) {
     // It's OK for the root of a subgraph to be not archived. See comments in
     // archive_reachable_objects_from().
     return;
@@ -1532,32 +1364,16 @@ void HeapShared::verify_subgraph_from(oop orig_obj) {
 
   // Verify that all objects reachable from orig_obj are archived.
   init_seen_objects_table();
-  verify_reachable_objects_from(orig_obj, false);
+  verify_reachable_objects_from(orig_obj);
   delete_seen_objects_table();
-
-  // Note: we could also verify that all objects reachable from the archived
-  // copy of orig_obj can only point to archived objects, with:
-  //      init_seen_objects_table();
-  //      verify_reachable_objects_from(archived_obj, true);
-  //      init_seen_objects_table();
-  // but that's already done in G1HeapVerifier::verify_archive_regions so we
-  // won't do it here.
 }
 
-void HeapShared::verify_reachable_objects_from(oop obj, bool is_archived) {
+void HeapShared::verify_reachable_objects_from(oop obj) {
   _num_total_verifications ++;
   if (!has_been_seen_during_subgraph_recording(obj)) {
     set_has_been_seen_during_subgraph_recording(obj);
-
-    if (is_archived) {
-      assert(is_archived_object_during_dumptime(obj), "must be");
-      assert(find_archived_heap_object(obj) == nullptr, "must be");
-    } else {
-      assert(!is_archived_object_during_dumptime(obj), "must be");
-      assert(find_archived_heap_object(obj) != nullptr, "must be");
-    }
-
-    VerifySharedOopClosure walker(is_archived);
+    assert(has_been_archived(obj), "must be");
+    VerifySharedOopClosure walker;
     obj->oop_iterate(&walker);
   }
 }
@@ -1811,7 +1627,6 @@ void HeapShared::init_for_dumping(TRAPS) {
   if (HeapShared::can_write()) {
     setup_test_class(ArchiveHeapTestClass);
     _dumped_interned_strings = new (mtClass)DumpedInternedStrings();
-    _native_pointers = new GrowableArrayCHeap<Metadata**, mtClassShared>(2048);
     init_subgraph_entry_fields(CHECK);
   }
 }
@@ -1877,10 +1692,12 @@ void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
 //   [2] included in the SharedArchiveConfigFile.
 void HeapShared::add_to_dumped_interned_strings(oop string) {
   assert_at_safepoint(); // DumpedInternedStrings uses raw oops
+  assert(!ArchiveHeapWriter::is_string_too_large_to_archive(string), "must be");
   bool created;
   _dumped_interned_strings->put_if_absent(string, true, &created);
 }
 
+#ifndef PRODUCT
 // At dump-time, find the location of all the non-null oop pointers in an archived heap
 // region. This way we can quickly relocate all the pointers without using
 // BasicOopIterateClosure at runtime.
@@ -1912,10 +1729,6 @@ class FindEmbeddedNonNullPointers: public BasicOopIterateClosure {
     if ((*p) != nullptr) {
       size_t idx = p - (oop*)_start;
       _oopmap->set_bit(idx);
-      if (DumpSharedSpaces) {
-        // Make heap content deterministic.
-        *p = HeapShared::to_requested_address(*p);
-      }
     } else {
       _num_null_oops ++;
     }
@@ -1923,7 +1736,7 @@ class FindEmbeddedNonNullPointers: public BasicOopIterateClosure {
   int num_total_oops() const { return _num_total_oops; }
   int num_null_oops()  const { return _num_null_oops; }
 };
-
+#endif
 
 address HeapShared::to_requested_address(address dumptime_addr) {
   assert(DumpSharedSpaces, "static dump time only");
@@ -1952,6 +1765,7 @@ address HeapShared::to_requested_address(address dumptime_addr) {
   return requested_addr;
 }
 
+#ifndef PRODUCT
 ResourceBitMap HeapShared::calculate_oopmap(MemRegion region) {
   size_t num_bits = region.byte_size() / (UseCompressedOops ? sizeof(narrowOop) : sizeof(oop));
   ResourceBitMap oopmap(num_bits);
@@ -1959,16 +1773,12 @@ ResourceBitMap HeapShared::calculate_oopmap(MemRegion region) {
   HeapWord* p   = region.start();
   HeapWord* end = region.end();
   FindEmbeddedNonNullPointers finder((void*)p, &oopmap);
-  ArchiveBuilder* builder = DumpSharedSpaces ? ArchiveBuilder::current() : nullptr;
 
   int num_objs = 0;
   while (p < end) {
     oop o = cast_to_oop(p);
     o->oop_iterate(&finder);
     p += o->size();
-    if (DumpSharedSpaces) {
-      builder->relocate_klass_ptr_of_oop(o);
-    }
     ++ num_objs;
   }
 
@@ -1977,34 +1787,7 @@ ResourceBitMap HeapShared::calculate_oopmap(MemRegion region) {
   return oopmap;
 }
 
-
-ResourceBitMap HeapShared::calculate_ptrmap(MemRegion region) {
-  size_t num_bits = region.byte_size() / sizeof(Metadata*);
-  ResourceBitMap oopmap(num_bits);
-
-  Metadata** start = (Metadata**)region.start();
-  Metadata** end   = (Metadata**)region.end();
-
-  int num_non_null_ptrs = 0;
-  int len = _native_pointers->length();
-  for (int i = 0; i < len; i++) {
-    Metadata** p = _native_pointers->at(i);
-    if (start <= p && p < end) {
-      assert(*p != nullptr, "must be non-null");
-      num_non_null_ptrs ++;
-      size_t idx = p - start;
-      oopmap.set_bit(idx);
-    }
-  }
-
-  log_info(cds, heap)("calculate_ptrmap: marked %d non-null native pointers out of "
-                      SIZE_FORMAT " possible locations", num_non_null_ptrs, num_bits);
-  if (num_non_null_ptrs > 0) {
-    return oopmap;
-  } else {
-    return ResourceBitMap(0);
-  }
-}
+#endif // !PRODUCT
 
 void HeapShared::count_allocation(size_t size) {
   _total_obj_count ++;
diff --git a/src/hotspot/share/cds/heapShared.hpp b/src/hotspot/share/cds/heapShared.hpp
index a38af10c5e0..dd1cf950316 100644
--- a/src/hotspot/share/cds/heapShared.hpp
+++ b/src/hotspot/share/cds/heapShared.hpp
@@ -165,8 +165,8 @@ class HeapShared: AllStatic {
 private:
 #if INCLUDE_CDS_JAVA_HEAP
   static bool _disable_writing;
+  static bool _copying_open_region_objects;
   static DumpedInternedStrings *_dumped_interned_strings;
-  static GrowableArrayCHeap<Metadata**, mtClassShared>* _native_pointers;
 
   // statistics
   constexpr static int ALLOC_STAT_SLOTS = 16;
@@ -183,11 +183,21 @@ class HeapShared: AllStatic {
     return java_lang_String::hash_code(string);
   }
 
-  struct CachedOopInfo {
-    KlassSubGraphInfo* _subgraph_info;
-    oop _referrer;
-    oop _obj;
-    CachedOopInfo() :_subgraph_info(), _referrer(), _obj() {}
+  class CachedOopInfo {
+    // See "TEMP notes: What are these?" in archiveHeapWriter.hpp
+    oop _orig_referrer;
+
+    // The location of this object inside ArchiveHeapWriter::_buffer
+    size_t _buffer_offset;
+    bool _in_open_region;
+  public:
+    CachedOopInfo(oop orig_referrer, bool in_open_region)
+      : _orig_referrer(orig_referrer),
+        _buffer_offset(0), _in_open_region(in_open_region) {}
+    oop orig_referrer()             const { return _orig_referrer;   }
+    bool in_open_region()           const { return _in_open_region;  }
+    void set_buffer_offset(size_t offset) { _buffer_offset = offset; }
+    size_t buffer_offset()          const { return _buffer_offset;   }
   };
 
 private:
@@ -203,13 +213,6 @@ class HeapShared: AllStatic {
       HeapShared::oop_hash> ArchivedObjectCache;
   static ArchivedObjectCache* _archived_object_cache;
 
-  typedef ResourceHashtable<oop, oop,
-      36137, // prime number
-      AnyObj::C_HEAP,
-      mtClassShared,
-      HeapShared::oop_hash> OriginalObjectTable;
-  static OriginalObjectTable* _original_object_table;
-
   class DumpTimeKlassSubGraphInfoTable
     : public ResourceHashtable<Klass*, KlassSubGraphInfo,
                                137, // prime number
@@ -237,7 +240,7 @@ class HeapShared: AllStatic {
   static RunTimeKlassSubGraphInfoTable _run_time_subgraph_info_table;
 
   static void check_closed_region_object(InstanceKlass* k);
-  static CachedOopInfo make_cached_oop_info(oop orig_obj);
+  static CachedOopInfo make_cached_oop_info();
   static void archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
                                        bool is_closed_archive,
                                        bool is_full_module_graph);
@@ -251,7 +254,7 @@ class HeapShared: AllStatic {
 
   static void verify_subgraph_from_static_field(
     InstanceKlass* k, int field_offset) PRODUCT_RETURN;
-  static void verify_reachable_objects_from(oop obj, bool is_archived) PRODUCT_RETURN;
+  static void verify_reachable_objects_from(oop obj) PRODUCT_RETURN;
   static void verify_subgraph_from(oop orig_obj) PRODUCT_RETURN;
   static void check_default_subgraph_classes();
 
@@ -316,7 +319,7 @@ class HeapShared: AllStatic {
 
   static bool has_been_seen_during_subgraph_recording(oop obj);
   static void set_has_been_seen_during_subgraph_recording(oop obj);
-  static oop archive_object(oop obj);
+  static bool archive_object(oop obj);
 
   static void copy_interned_strings();
   static void copy_roots();
@@ -338,58 +341,36 @@ class HeapShared: AllStatic {
   static void init_loaded_heap_relocation(LoadedArchiveHeapRegion* reloc_info,
                                           int num_loaded_regions);
   static void fill_failed_loaded_region();
-  static void mark_native_pointers(oop orig_obj, oop archived_obj);
-  static void mark_one_native_pointer(oop archived_obj, int offset);
+  static void mark_native_pointers(oop orig_obj);
+  static bool has_been_archived(oop orig_obj);
+  static void archive_java_mirrors();
  public:
   static void reset_archived_object_states(TRAPS);
-  static void create_archived_object_cache(bool create_orig_table) {
+  static void create_archived_object_cache() {
     _archived_object_cache =
       new (mtClass)ArchivedObjectCache();
-    if (create_orig_table) {
-      _original_object_table =
-        new (mtClass)OriginalObjectTable();
-    } else {
-      _original_object_table = nullptr;
-    }
   }
   static void destroy_archived_object_cache() {
     delete _archived_object_cache;
     _archived_object_cache = nullptr;
-    if (_original_object_table != nullptr) {
-      delete _original_object_table;
-      _original_object_table = nullptr;
-    }
   }
   static ArchivedObjectCache* archived_object_cache() {
     return _archived_object_cache;
   }
-  static oop get_original_object(oop archived_object) {
-    assert(_original_object_table != nullptr, "sanity");
-    oop* r = _original_object_table->get(archived_object);
-    if (r == nullptr) {
-      return nullptr;
-    } else {
-      return *r;
-    }
-  }
-
-  static bool is_too_large_to_archive(oop o);
-  static oop find_archived_heap_object(oop obj);
-
-  static void archive_java_mirrors();
 
   static void archive_objects(GrowableArray<MemRegion>* closed_regions,
-                              GrowableArray<MemRegion>* open_regions);
-  static void copy_closed_objects(GrowableArray<MemRegion>* closed_regions);
-  static void copy_open_objects(GrowableArray<MemRegion>* open_regions);
+                              GrowableArray<MemRegion>* open_regions,
+                              GrowableArray<ArchiveHeapBitmapInfo>* closed_bitmaps,
+                              GrowableArray<ArchiveHeapBitmapInfo>* open_bitmaps);
+  static void copy_closed_objects();
+  static void copy_open_objects();
 
-  static oop archive_reachable_objects_from(int level,
-                                            KlassSubGraphInfo* subgraph_info,
-                                            oop orig_obj,
-                                            bool is_closed_archive);
+  static bool archive_reachable_objects_from(int level,
+                                             KlassSubGraphInfo* subgraph_info,
+                                             oop orig_obj,
+                                             bool is_closed_archive);
 
   static ResourceBitMap calculate_oopmap(MemRegion region); // marks all the oop pointers
-  static ResourceBitMap calculate_ptrmap(MemRegion region); // marks all the native pointers
   static void add_to_dumped_interned_strings(oop string);
 
   // Scratch objects for archiving Klass::java_mirror()
@@ -426,16 +407,12 @@ class HeapShared: AllStatic {
 
  public:
   static void init_scratch_objects(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
-  static void run_full_gc_in_vm_thread() NOT_CDS_JAVA_HEAP_RETURN;
-
   static bool is_heap_region(int idx) {
     CDS_JAVA_HEAP_ONLY(return (idx >= MetaspaceShared::first_closed_heap_region &&
                                idx <= MetaspaceShared::last_open_heap_region);)
     NOT_CDS_JAVA_HEAP_RETURN_(false);
   }
 
-  static bool is_archived_object_during_dumptime(oop p) NOT_CDS_JAVA_HEAP_RETURN_(false);
-
   static void resolve_classes(JavaThread* current) NOT_CDS_JAVA_HEAP_RETURN;
   static void initialize_from_archived_subgraph(JavaThread* current, Klass* k) NOT_CDS_JAVA_HEAP_RETURN;
 
diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp
index cc750691790..ad9ecb99caa 100644
--- a/src/hotspot/share/cds/metaspaceShared.cpp
+++ b/src/hotspot/share/cds/metaspaceShared.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "cds/archiveBuilder.hpp"
 #include "cds/archiveHeapLoader.hpp"
+#include "cds/archiveHeapWriter.hpp"
 #include "cds/cds_globals.hpp"
 #include "cds/cdsProtectionDomain.hpp"
 #include "cds/classListWriter.hpp"
@@ -82,9 +83,6 @@
 #include "utilities/ostream.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/resourceHash.hpp"
-#if INCLUDE_G1GC
-#include "gc/g1/g1CollectedHeap.inline.hpp"
-#endif
 
 ReservedSpace MetaspaceShared::_symbol_rs;
 VirtualSpace MetaspaceShared::_symbol_vs;
@@ -331,22 +329,16 @@ void MetaspaceShared::read_extra_data(JavaThread* current, const char* filename)
                                reader.last_line_no(), utf8_length);
         CLEAR_PENDING_EXCEPTION;
       } else {
-#if INCLUDE_G1GC
-        if (UseG1GC) {
-          typeArrayOop body = java_lang_String::value(str);
-          const HeapRegion* hr = G1CollectedHeap::heap()->heap_region_containing(body);
-          if (hr->is_humongous()) {
-            // Don't keep it alive, so it will be GC'ed before we dump the strings, in order
-            // to maximize free heap space and minimize fragmentation.
-            log_warning(cds, heap)("[line %d] extra interned string ignored; size too large: %d",
-                                reader.last_line_no(), utf8_length);
-            continue;
-          }
+#if INCLUDE_CDS_JAVA_HEAP
+        if (ArchiveHeapWriter::is_string_too_large_to_archive(str)) {
+          log_warning(cds, heap)("[line %d] extra interned string ignored; size too large: %d",
+                                 reader.last_line_no(), utf8_length);
+          continue;
         }
-#endif
         // Make sure this string is included in the dumped interned string table.
         assert(str != nullptr, "must succeed");
         _extra_interned_strings->append(OopHandle(Universe::vm_global(), str));
+#endif
       }
     }
   }
@@ -436,7 +428,7 @@ void MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread
   }
 }
 
-class VM_PopulateDumpSharedSpace : public VM_GC_Operation {
+class VM_PopulateDumpSharedSpace : public VM_Operation {
 private:
   GrowableArray<MemRegion> *_closed_heap_regions;
   GrowableArray<MemRegion> *_open_heap_regions;
@@ -445,11 +437,6 @@ class VM_PopulateDumpSharedSpace : public VM_GC_Operation {
   GrowableArray<ArchiveHeapBitmapInfo> *_open_heap_bitmaps;
 
   void dump_java_heap_objects(GrowableArray<Klass*>* klasses) NOT_CDS_JAVA_HEAP_RETURN;
-  void dump_heap_bitmaps() NOT_CDS_JAVA_HEAP_RETURN;
-  void dump_heap_bitmaps(GrowableArray<MemRegion>* regions,
-                         GrowableArray<ArchiveHeapBitmapInfo>* bitmaps);
-  void dump_one_heap_bitmap(MemRegion region, GrowableArray<ArchiveHeapBitmapInfo>* bitmaps,
-                            ResourceBitMap bitmap, bool is_oopmap);
   void dump_shared_symbol_table(GrowableArray<Symbol*>* symbols) {
     log_info(cds)("Dumping symbol table ...");
     SymbolTable::write_to_archive(symbols);
@@ -458,8 +445,7 @@ class VM_PopulateDumpSharedSpace : public VM_GC_Operation {
 
 public:
 
-  VM_PopulateDumpSharedSpace() :
-    VM_GC_Operation(0 /* total collections, ignored */, GCCause::_archive_time_gc),
+  VM_PopulateDumpSharedSpace() : VM_Operation(),
     _closed_heap_regions(nullptr),
     _open_heap_regions(nullptr),
     _closed_heap_bitmaps(nullptr),
@@ -508,15 +494,10 @@ char* VM_PopulateDumpSharedSpace::dump_read_only_tables() {
   WriteClosure wc(ro_region);
   MetaspaceShared::serialize(&wc);
 
-  // Write the bitmaps for patching the archive heap regions
-  dump_heap_bitmaps();
-
   return start;
 }
 
 void VM_PopulateDumpSharedSpace::doit() {
-  HeapShared::run_full_gc_in_vm_thread();
-
   DEBUG_ONLY(SystemDictionaryShared::NoClassLoadingMark nclm);
 
   FileMapInfo::check_nonempty_dir_in_shared_path_table();
@@ -820,9 +801,10 @@ void MetaspaceShared::preload_and_dump_impl(TRAPS) {
   log_info(cds)("Rewriting and linking classes: done");
 
 #if INCLUDE_CDS_JAVA_HEAP
-    if (use_full_module_graph()) {
-      HeapShared::reset_archived_object_states(CHECK);
-    }
+  ArchiveHeapWriter::init();
+  if (use_full_module_graph()) {
+    HeapShared::reset_archived_object_states(CHECK);
+  }
 #endif
 
   VM_PopulateDumpSharedSpace op;
@@ -895,60 +877,13 @@ void VM_PopulateDumpSharedSpace::dump_java_heap_objects(GrowableArray<Klass*>* k
   // See FileMapInfo::write_heap_regions() for details.
   _closed_heap_regions = new GrowableArray<MemRegion>(2);
   _open_heap_regions = new GrowableArray<MemRegion>(2);
-  HeapShared::archive_objects(_closed_heap_regions, _open_heap_regions);
+  _closed_heap_bitmaps = new GrowableArray<ArchiveHeapBitmapInfo>(2);
+  _open_heap_bitmaps = new GrowableArray<ArchiveHeapBitmapInfo>(2);
+  HeapShared::archive_objects(_closed_heap_regions, _open_heap_regions,
+                              _closed_heap_bitmaps, _open_heap_bitmaps);
   ArchiveBuilder::OtherROAllocMark mark;
   HeapShared::write_subgraph_info_table();
 }
-
-void VM_PopulateDumpSharedSpace::dump_heap_bitmaps() {
-  if (HeapShared::can_write()) {
-    _closed_heap_bitmaps = new GrowableArray<ArchiveHeapBitmapInfo>(2);
-    dump_heap_bitmaps(_closed_heap_regions, _closed_heap_bitmaps);
-
-    _open_heap_bitmaps = new GrowableArray<ArchiveHeapBitmapInfo>(2);
-    dump_heap_bitmaps(_open_heap_regions, _open_heap_bitmaps);
-  }
-}
-
-void VM_PopulateDumpSharedSpace::dump_heap_bitmaps(GrowableArray<MemRegion>* regions,
-                                                   GrowableArray<ArchiveHeapBitmapInfo>* bitmaps) {
-  for (int i = 0; i < regions->length(); i++) {
-    MemRegion region = regions->at(i);
-    ResourceBitMap oopmap = HeapShared::calculate_oopmap(region);
-    ResourceBitMap ptrmap = HeapShared::calculate_ptrmap(region);
-    dump_one_heap_bitmap(region, bitmaps, oopmap, true);
-    dump_one_heap_bitmap(region, bitmaps, ptrmap, false);
-  }
-}
-
-void VM_PopulateDumpSharedSpace::dump_one_heap_bitmap(MemRegion region,
-                                                      GrowableArray<ArchiveHeapBitmapInfo>* bitmaps,
-                                                      ResourceBitMap bitmap, bool is_oopmap) {
-  size_t size_in_bits = bitmap.size();
-  size_t size_in_bytes;
-  uintptr_t* buffer;
-
-  if (size_in_bits > 0) {
-    size_in_bytes = bitmap.size_in_bytes();
-    buffer = (uintptr_t*)NEW_C_HEAP_ARRAY(char, size_in_bytes, mtInternal);
-    bitmap.write_to(buffer, size_in_bytes);
-  } else {
-    size_in_bytes = 0;
-    buffer = nullptr;
-  }
-
-  log_info(cds, heap)("%s = " INTPTR_FORMAT " (" SIZE_FORMAT_W(6) " bytes) for heap region "
-                      INTPTR_FORMAT " (" SIZE_FORMAT_W(8) " bytes)",
-                      is_oopmap ? "Oopmap" : "Ptrmap",
-                      p2i(buffer), size_in_bytes,
-                      p2i(region.start()), region.byte_size());
-
-  ArchiveHeapBitmapInfo info;
-  info._map = (address)buffer;
-  info._size_in_bits = size_in_bits;
-  info._size_in_bytes = size_in_bytes;
-  bitmaps->append(info);
-}
 #endif // INCLUDE_CDS_JAVA_HEAP
 
 void MetaspaceShared::set_shared_metaspace_range(void* base, void *static_top, void* top) {
diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp
index 8c26d28ef5b..f2ff82c4949 100644
--- a/src/hotspot/share/classfile/classFileParser.cpp
+++ b/src/hotspot/share/classfile/classFileParser.cpp
@@ -1895,7 +1895,6 @@ const ClassFileParser::unsafe_u2* ClassFileParser::parse_localvariable_table(con
 
 static const u1* parse_stackmap_table(const ClassFileStream* const cfs,
                                       u4 code_attribute_length,
-                                      bool need_verify,
                                       TRAPS) {
   assert(cfs != nullptr, "invariant");
 
@@ -1906,12 +1905,9 @@ static const u1* parse_stackmap_table(const ClassFileStream* const cfs,
   const u1* const stackmap_table_start = cfs->current();
   assert(stackmap_table_start != nullptr, "null stackmap table");
 
-  // check code_attribute_length first
+  // check code_attribute_length
   cfs->skip_u1(code_attribute_length, CHECK_NULL);
 
-  if (!need_verify && !DumpSharedSpaces) {
-    return nullptr;
-  }
   return stackmap_table_start;
 }
 
@@ -2535,7 +2531,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
             classfile_parse_error("Multiple StackMapTable attributes in class file %s", THREAD);
             return nullptr;
           }
-          stackmap_data = parse_stackmap_table(cfs, code_attribute_length, _need_verify, CHECK_NULL);
+          stackmap_data = parse_stackmap_table(cfs, code_attribute_length, CHECK_NULL);
           stackmap_data_length = code_attribute_length;
           parsed_stackmap_attribute = true;
         } else {
diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp
index 816a7e3f45f..364974666f4 100644
--- a/src/hotspot/share/classfile/javaClasses.cpp
+++ b/src/hotspot/share/classfile/javaClasses.cpp
@@ -1516,6 +1516,8 @@ int java_lang_Thread::_contextClassLoader_offset;
 int java_lang_Thread::_inheritedAccessControlContext_offset;
 int java_lang_Thread::_eetop_offset;
 int java_lang_Thread::_jvmti_thread_state_offset;
+int java_lang_Thread::_jvmti_VTMS_transition_disable_count_offset;
+int java_lang_Thread::_jvmti_is_in_VTMS_transition_offset;
 int java_lang_Thread::_interrupted_offset;
 int java_lang_Thread::_tid_offset;
 int java_lang_Thread::_continuation_offset;
@@ -1566,6 +1568,31 @@ void java_lang_Thread::set_jvmti_thread_state(oop java_thread, JvmtiThreadState*
   java_thread->address_field_put(_jvmti_thread_state_offset, (address)state);
 }
 
+int java_lang_Thread::VTMS_transition_disable_count(oop java_thread) {
+  return java_thread->int_field(_jvmti_VTMS_transition_disable_count_offset);
+}
+
+void java_lang_Thread::inc_VTMS_transition_disable_count(oop java_thread) {
+  assert(JvmtiVTMSTransition_lock->owned_by_self(), "Must be locked");
+  int val = VTMS_transition_disable_count(java_thread);
+  java_thread->int_field_put(_jvmti_VTMS_transition_disable_count_offset, val + 1);
+}
+
+void java_lang_Thread::dec_VTMS_transition_disable_count(oop java_thread) {
+  assert(JvmtiVTMSTransition_lock->owned_by_self(), "Must be locked");
+  int val = VTMS_transition_disable_count(java_thread);
+  assert(val > 0, "VTMS_transition_disable_count should never be negative");
+  java_thread->int_field_put(_jvmti_VTMS_transition_disable_count_offset, val - 1);
+}
+
+bool java_lang_Thread::is_in_VTMS_transition(oop java_thread) {
+  return java_thread->bool_field_volatile(_jvmti_is_in_VTMS_transition_offset);
+}
+
+void java_lang_Thread::set_is_in_VTMS_transition(oop java_thread, bool val) {
+  java_thread->bool_field_put_volatile(_jvmti_is_in_VTMS_transition_offset, val);
+}
+
 void java_lang_Thread::clear_scopedValueBindings(oop java_thread) {
   assert(java_thread != nullptr, "need a java_lang_Thread pointer here");
   java_thread->obj_field_put(_scopedValueBindings_offset, nullptr);
diff --git a/src/hotspot/share/classfile/javaClasses.hpp b/src/hotspot/share/classfile/javaClasses.hpp
index f02ca41a0f1..1d21c1ab634 100644
--- a/src/hotspot/share/classfile/javaClasses.hpp
+++ b/src/hotspot/share/classfile/javaClasses.hpp
@@ -334,6 +334,8 @@ class java_lang_Class : AllStatic {
 
 #define THREAD_INJECTED_FIELDS(macro)                                  \
   macro(java_lang_Thread, jvmti_thread_state, intptr_signature, false) \
+  macro(java_lang_Thread, jvmti_VTMS_transition_disable_count, int_signature, false) \
+  macro(java_lang_Thread, jvmti_is_in_VTMS_transition, bool_signature, false) \
   JFR_ONLY(macro(java_lang_Thread, jfr_epoch, short_signature, false))
 
 class java_lang_Thread : AllStatic {
@@ -347,6 +349,8 @@ class java_lang_Thread : AllStatic {
   static int _inheritedAccessControlContext_offset;
   static int _eetop_offset;
   static int _jvmti_thread_state_offset;
+  static int _jvmti_VTMS_transition_disable_count_offset;
+  static int _jvmti_is_in_VTMS_transition_offset;
   static int _interrupted_offset;
   static int _tid_offset;
   static int _continuation_offset;
@@ -396,6 +400,11 @@ class java_lang_Thread : AllStatic {
 
   static JvmtiThreadState* jvmti_thread_state(oop java_thread);
   static void set_jvmti_thread_state(oop java_thread, JvmtiThreadState* state);
+  static int  VTMS_transition_disable_count(oop java_thread);
+  static void inc_VTMS_transition_disable_count(oop java_thread);
+  static void dec_VTMS_transition_disable_count(oop java_thread);
+  static bool is_in_VTMS_transition(oop java_thread);
+  static void set_is_in_VTMS_transition(oop java_thread, bool val);
 
   // Clear all scoped value bindings on error
   static void clear_scopedValueBindings(oop java_thread);
diff --git a/src/hotspot/share/classfile/placeholders.cpp b/src/hotspot/share/classfile/placeholders.cpp
index f6614881e0d..ff9e34d274a 100644
--- a/src/hotspot/share/classfile/placeholders.cpp
+++ b/src/hotspot/share/classfile/placeholders.cpp
@@ -191,7 +191,11 @@ bool PlaceholderEntry::remove_seen_thread(JavaThread* thread, PlaceholderTable::
 }
 
 
-// Placeholder methods
+void PlaceholderEntry::set_supername(Symbol* supername) {
+  assert_locked_or_safepoint(SystemDictionary_lock);
+  assert(_supername == nullptr || _supername->refcount() > 1, "must be referenced also by the loader");
+  _supername = supername;
+}
 
 // Placeholder objects represent classes currently being loaded.
 // All threads examining the placeholder table must hold the
@@ -272,7 +276,6 @@ PlaceholderEntry* PlaceholderTable::find_and_add(Symbol* name,
 
 
 // placeholder is used to track class loading internal states
-// placeholder existence now for loading superclass/superinterface
 // superthreadQ tracks class circularity, while loading superclass/superinterface
 // loadInstanceThreadQ tracks load_instance_class calls
 // definer() tracks the single thread that owns define token
@@ -283,21 +286,21 @@ PlaceholderEntry* PlaceholderTable::find_and_add(Symbol* name,
 // On removal: if definer and all queues empty, remove entry
 // Note: you can be in both placeholders and systemDictionary
 // Therefore - must always check SD first
-// Ignores the case where entry is not found
 void PlaceholderTable::find_and_remove(Symbol* name, ClassLoaderData* loader_data,
                                        classloadAction action,
                                        JavaThread* thread) {
   assert_locked_or_safepoint(SystemDictionary_lock);
   PlaceholderEntry* probe = get_entry(name, loader_data);
-  if (probe != nullptr) {
-    log(name, probe, "find_and_remove", action);
-    probe->remove_seen_thread(thread, action);
-    // If no other threads using this entry, and this thread is not using this entry for other states
-    if ((probe->superThreadQ() == nullptr) && (probe->loadInstanceThreadQ() == nullptr)
-        && (probe->defineThreadQ() == nullptr) && (probe->definer() == nullptr)) {
-      probe->clear_supername();
-      remove_entry(name, loader_data);
-    }
+  assert(probe != nullptr, "must find an entry");
+  log(name, probe, "find_and_remove", action);
+  probe->remove_seen_thread(thread, action);
+  if (probe->superThreadQ() == nullptr) {
+    probe->set_supername(nullptr);
+  }
+  // If no other threads using this entry, and this thread is not using this entry for other states
+  if ((probe->superThreadQ() == nullptr) && (probe->loadInstanceThreadQ() == nullptr)
+      && (probe->defineThreadQ() == nullptr) && (probe->definer() == nullptr)) {
+    remove_entry(name, loader_data);
   }
 }
 
diff --git a/src/hotspot/share/classfile/placeholders.hpp b/src/hotspot/share/classfile/placeholders.hpp
index bc5a4c373a7..72235a689f1 100644
--- a/src/hotspot/share/classfile/placeholders.hpp
+++ b/src/hotspot/share/classfile/placeholders.hpp
@@ -25,10 +25,11 @@
 #ifndef SHARE_CLASSFILE_PLACEHOLDERS_HPP
 #define SHARE_CLASSFILE_PLACEHOLDERS_HPP
 
+#include "oops/symbolHandle.hpp"
+
 class PlaceholderEntry;
 class Thread;
 class ClassLoaderData;
-class Symbol;
 
 // Placeholder objects. These represent classes currently
 // being loaded, as well as arrays of primitives.
@@ -80,7 +81,7 @@ class SeenThread;
 class PlaceholderEntry {
   friend class PlaceholderTable;
  private:
-  Symbol*           _supername;
+  SymbolHandle      _supername;
   JavaThread*       _definer;       // owner of define token
   InstanceKlass*    _instanceKlass; // InstanceKlass from successful define
   SeenThread*       _superThreadQ;  // doubly-linked queue of Threads loading a superclass for this class
@@ -98,23 +99,21 @@ class PlaceholderEntry {
   void add_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action);
   bool remove_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action);
 
+  SeenThread*        superThreadQ()        const { return _superThreadQ; }
+  void               set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }
+
+  SeenThread*        loadInstanceThreadQ() const { return _loadInstanceThreadQ; }
+  void               set_loadInstanceThreadQ(SeenThread* SeenThread) { _loadInstanceThreadQ = SeenThread; }
+
+  SeenThread*        defineThreadQ()       const { return _defineThreadQ; }
+  void               set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
  public:
   PlaceholderEntry() :
-     _supername(nullptr), _definer(nullptr), _instanceKlass(nullptr),
+     _definer(nullptr), _instanceKlass(nullptr),
      _superThreadQ(nullptr), _loadInstanceThreadQ(nullptr), _defineThreadQ(nullptr) { }
 
   Symbol*            supername()           const { return _supername; }
-  void               set_supername(Symbol* supername) {
-    if (supername != _supername) {
-      Symbol::maybe_decrement_refcount(_supername);
-      _supername = supername;
-      Symbol::maybe_increment_refcount(_supername);
-    }
-  }
-  void               clear_supername() {
-    Symbol::maybe_decrement_refcount(_supername);
-    _supername = nullptr;
-  }
+  void               set_supername(Symbol* supername);
 
   JavaThread*        definer()             const {return _definer; }
   void               set_definer(JavaThread* definer) { _definer = definer; }
@@ -122,15 +121,6 @@ class PlaceholderEntry {
   InstanceKlass*     instance_klass()      const {return _instanceKlass; }
   void               set_instance_klass(InstanceKlass* ik) { _instanceKlass = ik; }
 
-  SeenThread*        superThreadQ()        const { return _superThreadQ; }
-  void               set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }
-
-  SeenThread*        loadInstanceThreadQ() const { return _loadInstanceThreadQ; }
-  void               set_loadInstanceThreadQ(SeenThread* SeenThread) { _loadInstanceThreadQ = SeenThread; }
-
-  SeenThread*        defineThreadQ()       const { return _defineThreadQ; }
-  void               set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
-
   bool super_load_in_progress() {
      return (_superThreadQ != nullptr);
   }
diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp
index 7a88bda5699..91e6f8d360e 100644
--- a/src/hotspot/share/classfile/stringTable.cpp
+++ b/src/hotspot/share/classfile/stringTable.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "cds/archiveBuilder.hpp"
 #include "cds/archiveHeapLoader.inline.hpp"
+#include "cds/archiveHeapWriter.hpp"
 #include "cds/filemap.hpp"
 #include "cds/heapShared.hpp"
 #include "classfile/altHashing.hpp"
@@ -770,14 +771,14 @@ class EncodeSharedStringsAsOffsets : StackObj {
   EncodeSharedStringsAsOffsets(CompactHashtableWriter* writer) : _writer(writer) {}
   bool do_entry(oop s, bool value_ignored) {
     assert(s != nullptr, "sanity");
-    oop new_s = HeapShared::find_archived_heap_object(s);
-    if (new_s != nullptr) { // could be null if the string is too big
-      unsigned int hash = java_lang_String::hash_code(s);
-      if (UseCompressedOops) {
-        _writer->add(hash, CompressedOops::narrow_oop_value(new_s));
-      } else {
-        _writer->add(hash, compute_delta(new_s));
-      }
+    assert(!ArchiveHeapWriter::is_string_too_large_to_archive(s), "must be");
+    oop req_s = ArchiveHeapWriter::source_obj_to_requested_obj(s);
+    assert(req_s != nullptr, "must have been archived");
+    unsigned int hash = java_lang_String::hash_code(s);
+    if (UseCompressedOops) {
+      _writer->add(hash, CompressedOops::narrow_oop_value(req_s));
+    } else {
+      _writer->add(hash, compute_delta(req_s));
     }
     return true; // keep iterating
   }
diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp
index 4a3690c68b3..d982ad6f457 100644
--- a/src/hotspot/share/classfile/systemDictionary.cpp
+++ b/src/hotspot/share/classfile/systemDictionary.cpp
@@ -670,7 +670,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
 
   bool super_load_in_progress  = false;
   InstanceKlass* loaded_class = nullptr;
-  Symbol* superclassname = nullptr;
+  SymbolHandle superclassname; // Keep alive while loading in parallel thread.
 
   assert(THREAD->can_call_java(),
          "can not load classes with compiler thread: class=%s, classloader=%s",
diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp
index 2d608b4e2b8..71bdfab62cc 100644
--- a/src/hotspot/share/classfile/systemDictionaryShared.cpp
+++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp
@@ -1449,11 +1449,9 @@ class CloneDumpTimeClassTable: public StackObj {
     assert(_cloned_table != nullptr, "_cloned_table is nullptr");
   }
   void do_entry(InstanceKlass* k, DumpTimeClassInfo& info) {
-    if (!info.is_excluded()) {
-      bool created;
-      _cloned_table->put_if_absent(k, info, &created);
-      assert(created, "must be");
-    }
+    bool created;
+    _cloned_table->put_if_absent(k, info, &created);
+    assert(created, "must be");
   }
 };
 
diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp
index 92ab554d620..02be97362c7 100644
--- a/src/hotspot/share/classfile/vmIntrinsics.hpp
+++ b/src/hotspot/share/classfile/vmIntrinsics.hpp
@@ -1211,6 +1211,16 @@ class methodHandle;
                                        "Ljdk/internal/vm/vector/VectorSupport$Vector;")                                                        \
     do_name(index_vector_op_name, "indexVector")                                                                                               \
                                                                                                                                                \
+  do_intrinsic(_IndexPartiallyInUpperRange, jdk_internal_vm_vector_VectorSupport, index_partially_in_upper_range_name, index_partially_in_upper_range_sig, F_S)\
+    do_signature(index_partially_in_upper_range_sig, "(Ljava/lang/Class;"                                                                                      \
+                                                     "Ljava/lang/Class;"                                                                                       \
+                                                     "I"                                                                                                       \
+                                                     "J"                                                                                                       \
+                                                     "J"                                                                                                       \
+                                                     "Ljdk/internal/vm/vector/VectorSupport$IndexPartiallyInUpperRangeOperation;)"                             \
+                                                     "Ljdk/internal/vm/vector/VectorSupport$VectorMask;")                                                      \
+    do_name(index_partially_in_upper_range_name, "indexPartiallyInUpperRange")                                                                                 \
+                                                                                                                               \
    /* (2) Bytecode intrinsics                                                                        */                        \
                                                                                                                                \
   do_intrinsic(_park,                     jdk_internal_misc_Unsafe,     park_name, park_signature,                     F_RN)   \
@@ -1319,7 +1329,7 @@ enum class vmIntrinsicID : int {
                    __IGNORE_CLASS, __IGNORE_NAME, __IGNORE_SIGNATURE, __IGNORE_ALIAS)
 
   ID_LIMIT,
-  LAST_COMPILER_INLINE = _IndexVector,
+  LAST_COMPILER_INLINE = _IndexPartiallyInUpperRange,
   FIRST_MH_SIG_POLY    = _invokeGeneric,
   FIRST_MH_STATIC      = _linkToVirtual,
   LAST_MH_SIG_POLY     = _linkToNative,
diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp
index f6a4d8b2143..b321b7fffd3 100644
--- a/src/hotspot/share/classfile/vmSymbols.hpp
+++ b/src/hotspot/share/classfile/vmSymbols.hpp
@@ -520,6 +520,8 @@
   template(java_lang_Boolean_signature,               "Ljava/lang/Boolean;")                      \
   template(url_code_signer_array_void_signature,      "(Ljava/net/URL;[Ljava/security/CodeSigner;)V") \
   template(jvmti_thread_state_name,                   "jvmti_thread_state")                       \
+  template(jvmti_VTMS_transition_disable_count_name,  "jvmti_VTMS_transition_disable_count")      \
+  template(jvmti_is_in_VTMS_transition_name,          "jvmti_is_in_VTMS_transition")              \
   template(module_entry_name,                         "module_entry")                             \
   template(resolved_references_name,                  "<resolved_references>")                    \
   template(init_lock_name,                            "<init_lock>")                              \
diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp
index df1b27b3165..ce6e67e9b82 100644
--- a/src/hotspot/share/code/codeCache.cpp
+++ b/src/hotspot/share/code/codeCache.cpp
@@ -168,7 +168,7 @@ class CodeBlob_sizes {
 
 address CodeCache::_low_bound = 0;
 address CodeCache::_high_bound = 0;
-int CodeCache::_number_of_nmethods_with_dependencies = 0;
+volatile int CodeCache::_number_of_nmethods_with_dependencies = 0;
 ExceptionCache* volatile CodeCache::_exception_cache_purge_list = nullptr;
 
 // Initialize arrays of CodeHeap subsets
@@ -587,7 +587,7 @@ void CodeCache::free(CodeBlob* cb) {
   if (cb->is_nmethod()) {
     heap->set_nmethod_count(heap->nmethod_count() - 1);
     if (((nmethod *)cb)->has_dependencies()) {
-      _number_of_nmethods_with_dependencies--;
+      Atomic::dec(&_number_of_nmethods_with_dependencies);
     }
   }
   if (cb->is_adapter_blob()) {
@@ -622,7 +622,7 @@ void CodeCache::commit(CodeBlob* cb) {
   if (cb->is_nmethod()) {
     heap->set_nmethod_count(heap->nmethod_count() + 1);
     if (((nmethod *)cb)->has_dependencies()) {
-      _number_of_nmethods_with_dependencies++;
+      Atomic::inc(&_number_of_nmethods_with_dependencies);
     }
   }
   if (cb->is_adapter_blob()) {
@@ -1219,8 +1219,8 @@ void codeCache_init() {
 
 //------------------------------------------------------------------------------------------------
 
-int CodeCache::number_of_nmethods_with_dependencies() {
-  return _number_of_nmethods_with_dependencies;
+bool CodeCache::has_nmethods_with_dependencies() {
+  return Atomic::load_acquire(&_number_of_nmethods_with_dependencies) != 0;
 }
 
 void CodeCache::clear_inline_caches() {
@@ -1431,7 +1431,9 @@ void CodeCache::make_nmethod_deoptimized(CompiledMethod* nm) {
 void CodeCache::flush_dependents_on(InstanceKlass* dependee) {
   assert_lock_strong(Compile_lock);
 
-  if (number_of_nmethods_with_dependencies() == 0) return;
+  if (!has_nmethods_with_dependencies()) {
+    return;
+  }
 
   int marked = 0;
   if (dependee->is_linked()) {
diff --git a/src/hotspot/share/code/codeCache.hpp b/src/hotspot/share/code/codeCache.hpp
index 289c84d8184..58c69b73b09 100644
--- a/src/hotspot/share/code/codeCache.hpp
+++ b/src/hotspot/share/code/codeCache.hpp
@@ -93,9 +93,9 @@ class CodeCache : AllStatic {
   static GrowableArray<CodeHeap*>* _nmethod_heaps;
   static GrowableArray<CodeHeap*>* _allocable_heaps;
 
-  static address _low_bound;                            // Lower bound of CodeHeap addresses
-  static address _high_bound;                           // Upper bound of CodeHeap addresses
-  static int _number_of_nmethods_with_dependencies;     // Total number of nmethods with dependencies
+  static address _low_bound;                                 // Lower bound of CodeHeap addresses
+  static address _high_bound;                                // Upper bound of CodeHeap addresses
+  static volatile int _number_of_nmethods_with_dependencies; // Total number of nmethods with dependencies
 
   static uint8_t           _unloading_cycle;          // Global state for recognizing old nmethods that need to be unloaded
   static uint64_t          _gc_epoch;                 // Global state for tracking when nmethods were found to be on-stack
@@ -323,8 +323,8 @@ class CodeCache : AllStatic {
   // Support for fullspeed debugging
   static void flush_dependents_on_method(const methodHandle& dependee);
 
-  // tells how many nmethods have dependencies
-  static int number_of_nmethods_with_dependencies();
+  // tells if there are nmethods with dependencies
+  static bool has_nmethods_with_dependencies();
 
   static int get_codemem_full_count(CodeBlobType code_blob_type) {
     CodeHeap* heap = get_code_heap(code_blob_type);
diff --git a/src/hotspot/share/gc/g1/g1Allocator.cpp b/src/hotspot/share/gc/g1/g1Allocator.cpp
index 6eab853381b..41859e910e7 100644
--- a/src/hotspot/share/gc/g1/g1Allocator.cpp
+++ b/src/hotspot/share/gc/g1/g1Allocator.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -484,153 +484,3 @@ size_t G1PLABAllocator::undo_waste() const {
   }
   return result;
 }
-
-G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* g1h, bool open) {
-  return new G1ArchiveAllocator(g1h, open);
-}
-
-bool G1ArchiveAllocator::alloc_new_region() {
-  // Allocate the highest free region in the reserved heap,
-  // and add it to our list of allocated regions. It is marked
-  // archive and added to the old set.
-  HeapRegion* hr = _g1h->alloc_highest_free_region();
-  if (hr == NULL) {
-    return false;
-  }
-  assert(hr->is_empty(), "expected empty region (index %u)", hr->hrm_index());
-  if (_open) {
-    hr->set_open_archive();
-  } else {
-    hr->set_closed_archive();
-  }
-  _g1h->policy()->remset_tracker()->update_at_allocate(hr);
-  _g1h->archive_set_add(hr);
-  _g1h->hr_printer()->alloc(hr);
-  _allocated_regions.append(hr);
-  _allocation_region = hr;
-
-  // Set up _bottom and _max to begin allocating in the lowest
-  // min_region_size'd chunk of the allocated G1 region.
-  _bottom = hr->bottom();
-  _max = _bottom + HeapRegion::min_region_size_in_words();
-
-  // Since we've modified the old set, call update_sizes.
-  _g1h->monitoring_support()->update_sizes();
-  return true;
-}
-
-HeapWord* G1ArchiveAllocator::archive_mem_allocate(size_t word_size) {
-  assert(word_size != 0, "size must not be zero");
-  if (_allocation_region == NULL) {
-    if (!alloc_new_region()) {
-      return NULL;
-    }
-  }
-  HeapWord* old_top = _allocation_region->top();
-  assert(_bottom >= _allocation_region->bottom(),
-         "inconsistent allocation state: " PTR_FORMAT " < " PTR_FORMAT,
-         p2i(_bottom), p2i(_allocation_region->bottom()));
-  assert(_max <= _allocation_region->end(),
-         "inconsistent allocation state: " PTR_FORMAT " > " PTR_FORMAT,
-         p2i(_max), p2i(_allocation_region->end()));
-  assert(_bottom <= old_top && old_top <= _max,
-         "inconsistent allocation state: expected "
-         PTR_FORMAT " <= " PTR_FORMAT " <= " PTR_FORMAT,
-         p2i(_bottom), p2i(old_top), p2i(_max));
-
-  // Try to allocate word_size in the current allocation chunk. Two cases
-  // require special treatment:
-  // 1. no enough space for word_size
-  // 2. after allocating word_size, there's non-zero space left, but too small for the minimal filler
-  // In both cases, we retire the current chunk and move on to the next one.
-  size_t free_words = pointer_delta(_max, old_top);
-  if (free_words < word_size ||
-      ((free_words - word_size != 0) && (free_words - word_size < CollectedHeap::min_fill_size()))) {
-    // Retiring the current chunk
-    if (old_top != _max) {
-      // Non-zero space; need to insert the filler
-      size_t fill_size = free_words;
-      CollectedHeap::fill_with_object(old_top, fill_size);
-    }
-    // Set the current chunk as "full"
-    _allocation_region->set_top(_max);
-
-    // Check if we've just used up the last min_region_size'd chunk
-    // in the current region, and if so, allocate a new one.
-    if (_max != _allocation_region->end()) {
-      // Shift to the next chunk
-      old_top = _bottom = _max;
-      _max = _bottom + HeapRegion::min_region_size_in_words();
-    } else {
-      if (!alloc_new_region()) {
-        return NULL;
-      }
-      old_top = _allocation_region->bottom();
-    }
-  }
-  assert(pointer_delta(_max, old_top) >= word_size, "enough space left");
-  _allocation_region->set_top(old_top + word_size);
-
-  return old_top;
-}
-
-void G1ArchiveAllocator::complete_archive(GrowableArray<MemRegion>* ranges,
-                                          size_t end_alignment_in_bytes) {
-  assert((end_alignment_in_bytes >> LogHeapWordSize) < HeapRegion::min_region_size_in_words(),
-         "alignment " SIZE_FORMAT " too large", end_alignment_in_bytes);
-  assert(is_aligned(end_alignment_in_bytes, HeapWordSize),
-         "alignment " SIZE_FORMAT " is not HeapWord (%u) aligned", end_alignment_in_bytes, HeapWordSize);
-
-  // If we've allocated nothing, simply return.
-  if (_allocation_region == NULL) {
-    return;
-  }
-
-  // If an end alignment was requested, insert filler objects.
-  if (end_alignment_in_bytes != 0) {
-    HeapWord* currtop = _allocation_region->top();
-    HeapWord* newtop = align_up(currtop, end_alignment_in_bytes);
-    size_t fill_size = pointer_delta(newtop, currtop);
-    if (fill_size != 0) {
-      if (fill_size < CollectedHeap::min_fill_size()) {
-        // If the required fill is smaller than we can represent,
-        // bump up to the next aligned address. We know we won't exceed the current
-        // region boundary because the max supported alignment is smaller than the min
-        // region size, and because the allocation code never leaves space smaller than
-        // the min_fill_size at the top of the current allocation region.
-        newtop = align_up(currtop + CollectedHeap::min_fill_size(),
-                          end_alignment_in_bytes);
-        fill_size = pointer_delta(newtop, currtop);
-      }
-      HeapWord* fill = archive_mem_allocate(fill_size);
-      CollectedHeap::fill_with_objects(fill, fill_size);
-    }
-  }
-
-  // Loop through the allocated regions, and create MemRegions summarizing
-  // the allocated address range, combining contiguous ranges. Add the
-  // MemRegions to the GrowableArray provided by the caller.
-  int index = _allocated_regions.length() - 1;
-  assert(_allocated_regions.at(index) == _allocation_region,
-         "expected region %u at end of array, found %u",
-         _allocation_region->hrm_index(), _allocated_regions.at(index)->hrm_index());
-  HeapWord* base_address = _allocation_region->bottom();
-  HeapWord* top = base_address;
-
-  while (index >= 0) {
-    HeapRegion* next = _allocated_regions.at(index);
-    HeapWord* new_base = next->bottom();
-    HeapWord* new_top = next->top();
-    if (new_base != top) {
-      ranges->append(MemRegion(base_address, pointer_delta(top, base_address)));
-      base_address = new_base;
-    }
-    top = new_top;
-    index = index - 1;
-  }
-
-  assert(top != base_address, "zero-sized range, address " PTR_FORMAT, p2i(base_address));
-  ranges->append(MemRegion(base_address, pointer_delta(top, base_address)));
-  _allocated_regions.clear();
-  _allocation_region = NULL;
-};
diff --git a/src/hotspot/share/gc/g1/g1Allocator.hpp b/src/hotspot/share/gc/g1/g1Allocator.hpp
index 9dd5fcdebe6..99eaab310c4 100644
--- a/src/hotspot/share/gc/g1/g1Allocator.hpp
+++ b/src/hotspot/share/gc/g1/g1Allocator.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -225,60 +225,4 @@ class G1PLABAllocator : public CHeapObj<mtGC> {
   void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz, uint node_index);
 };
 
-// G1ArchiveAllocator is used to allocate memory in archive
-// regions. Such regions are not scavenged nor compacted by GC.
-// There are two types of archive regions, which are
-// differ in the kind of references allowed for the contained objects:
-//
-// - 'Closed' archive region contain no references outside of other
-//   closed archive regions. The region is immutable by GC. GC does
-//   not mark object header in 'closed' archive region.
-// - An 'open' archive region allow references to any other regions,
-//   including closed archive, open archive and other java heap regions.
-//   GC can adjust pointers and mark object header in 'open' archive region.
-class G1ArchiveAllocator : public CHeapObj<mtGC> {
-protected:
-  bool _open; // Indicate if the region is 'open' archive.
-  G1CollectedHeap* _g1h;
-
-  // The current allocation region
-  HeapRegion* _allocation_region;
-
-  // Regions allocated for the current archive range.
-  GrowableArrayCHeap<HeapRegion*, mtGC> _allocated_regions;
-
-  // Current allocation window within the current region.
-  HeapWord* _bottom;
-  HeapWord* _top;
-  HeapWord* _max;
-
-  // Allocate a new region for this archive allocator.
-  // Allocation is from the top of the reserved heap downward.
-  bool alloc_new_region();
-
-public:
-  G1ArchiveAllocator(G1CollectedHeap* g1h, bool open) :
-    _open(open),
-    _g1h(g1h),
-    _allocation_region(NULL),
-    _allocated_regions(2),
-    _bottom(NULL),
-    _top(NULL),
-    _max(NULL) { }
-
-  virtual ~G1ArchiveAllocator() {
-    assert(_allocation_region == NULL, "_allocation_region not NULL");
-  }
-
-  static G1ArchiveAllocator* create_allocator(G1CollectedHeap* g1h, bool open);
-
-  // Allocate memory for an individual object.
-  HeapWord* archive_mem_allocate(size_t word_size);
-
-  // Return the memory ranges used in the current archive, after
-  // aligning to the requested alignment.
-  void complete_archive(GrowableArray<MemRegion>* ranges,
-                        size_t end_alignment_in_bytes);
-};
-
 #endif // SHARE_GC_G1_G1ALLOCATOR_HPP
diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.hpp
index d90d83298c9..7652bf8c7af 100644
--- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp
@@ -78,7 +78,7 @@ class G1BarrierSet: public CardTableBarrierSet {
   void write_ref_array_work(MemRegion mr) { invalidate(mr); }
 
   template <DecoratorSet decorators, typename T>
-  void write_ref_field_post(T* field, oop new_val);
+  void write_ref_field_post(T* field);
   void write_ref_field_post_slow(volatile CardValue* byte);
 
   virtual void on_thread_create(Thread* thread);
diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp
index f7a6fd3ee5a..32d239ef695 100644
--- a/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp
@@ -68,7 +68,7 @@ inline void G1BarrierSet::write_ref_field_pre(T* field) {
 }
 
 template <DecoratorSet decorators, typename T>
-inline void G1BarrierSet::write_ref_field_post(T* field, oop new_val) {
+inline void G1BarrierSet::write_ref_field_post(T* field) {
   volatile CardValue* byte = _card_table->byte_for(field);
   if (*byte != G1CardTable::g1_young_card_val()) {
     // Take a slow path for cards in old
diff --git a/src/hotspot/share/gc/g1/g1CardCounts.cpp b/src/hotspot/share/gc/g1/g1CardCounts.cpp
deleted file mode 100644
index 6e56eecafb9..00000000000
--- a/src/hotspot/share/gc/g1/g1CardCounts.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "gc/g1/g1CardCounts.hpp"
-#include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/shared/cardTableBarrierSet.hpp"
-#include "services/memTracker.hpp"
-#include "utilities/copy.hpp"
-
-void G1CardCountsMappingChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
-  if (zero_filled) {
-    return;
-  }
-  MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);
-  _counts->clear_range(mr);
-}
-
-size_t G1CardCounts::compute_size(size_t mem_region_size_in_words) {
-  // We keep card counts for every card, so the size of the card counts table must
-  // be the same as the card table.
-  return G1CardTable::compute_size(mem_region_size_in_words);
-}
-
-size_t G1CardCounts::heap_map_factor() {
-  // See G1CardCounts::compute_size() why we reuse the card table value.
-  return G1CardTable::heap_map_factor();
-}
-
-void G1CardCounts::clear_range(size_t from_card_num, size_t to_card_num) {
-  if (has_count_table()) {
-    assert(from_card_num < to_card_num,
-           "Wrong order? from: " SIZE_FORMAT ", to: " SIZE_FORMAT,
-           from_card_num, to_card_num);
-    Copy::fill_to_bytes(&_card_counts[from_card_num], (to_card_num - from_card_num));
-  }
-}
-
-G1CardCounts::G1CardCounts(G1CollectedHeap *g1h):
-  _listener(), _g1h(g1h), _ct(NULL), _card_counts(NULL), _reserved_max_card_num(0), _ct_bot(NULL) {
-  _listener.set_cardcounts(this);
-}
-
-void G1CardCounts::initialize(G1RegionToSpaceMapper* mapper) {
-  assert(_g1h->reserved().byte_size() > 0, "initialization order");
-  assert(_g1h->capacity() == 0, "initialization order");
-
-  if (G1ConcRSHotCardLimit > 0) {
-    // The max value we can store in the counts table is
-    // max_jubyte. Guarantee the value of the hot
-    // threshold limit is no more than this.
-    guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity");
-
-    _ct = _g1h->card_table();
-    _ct_bot = _ct->byte_for_const(_g1h->reserved().start());
-
-    _card_counts = (jubyte*) mapper->reserved().start();
-    _reserved_max_card_num = mapper->reserved().byte_size();
-    mapper->set_mapping_changed_listener(&_listener);
-  }
-}
-
-uint G1CardCounts::add_card_count(CardValue* card_ptr) {
-  // Returns the number of times the card has been refined.
-  // If we failed to reserve/commit the counts table, return 0.
-  // If card_ptr is beyond the committed end of the counts table,
-  // return 0.
-  // Otherwise return the actual count.
-  // Unless G1ConcRSHotCardLimit has been set appropriately,
-  // returning 0 will result in the card being considered
-  // cold and will be refined immediately.
-  uint count = 0;
-  if (has_count_table()) {
-    size_t card_num = ptr_2_card_num(card_ptr);
-    assert(card_num < _reserved_max_card_num,
-           "Card " SIZE_FORMAT " outside of card counts table (max size " SIZE_FORMAT ")",
-           card_num, _reserved_max_card_num);
-    count = (uint) _card_counts[card_num];
-    if (count < G1ConcRSHotCardLimit) {
-      _card_counts[card_num] =
-        (jubyte)(MIN2((uintx)(_card_counts[card_num] + 1), G1ConcRSHotCardLimit));
-    }
-  }
-  return count;
-}
-
-bool G1CardCounts::is_hot(uint count) {
-  return (count >= G1ConcRSHotCardLimit);
-}
-
-void G1CardCounts::clear_region(HeapRegion* hr) {
-  MemRegion mr(hr->bottom(), hr->end());
-  clear_range(mr);
-}
-
-void G1CardCounts::clear_range(MemRegion mr) {
-  if (has_count_table()) {
-    const CardValue* from_card_ptr = _ct->byte_for_const(mr.start());
-    // We use the last address in the range as the range could represent the
-    // last region in the heap. In which case trying to find the card will be an
-    // OOB access to the card table.
-    const CardValue* last_card_ptr = _ct->byte_for_const(mr.last());
-
-#ifdef ASSERT
-    HeapWord* start_addr = _ct->addr_for(from_card_ptr);
-    assert(start_addr == mr.start(), "MemRegion start must be aligned to a card.");
-    HeapWord* last_addr = _ct->addr_for(last_card_ptr);
-    assert((last_addr + G1CardTable::card_size_in_words()) == mr.end(), "MemRegion end must be aligned to a card.");
-#endif // ASSERT
-
-    // Clear the counts for the (exclusive) card range.
-    size_t from_card_num = ptr_2_card_num(from_card_ptr);
-    size_t to_card_num = ptr_2_card_num(last_card_ptr) + 1;
-    clear_range(from_card_num, to_card_num);
-  }
-}
-
-class G1CardCountsClearClosure : public HeapRegionClosure {
- private:
-  G1CardCounts* _card_counts;
- public:
-  G1CardCountsClearClosure(G1CardCounts* card_counts) :
-    HeapRegionClosure(), _card_counts(card_counts) { }
-
-
-  virtual bool do_heap_region(HeapRegion* r) {
-    _card_counts->clear_region(r);
-    return false;
-  }
-};
-
-void G1CardCounts::clear_all() {
-  assert(SafepointSynchronize::is_at_safepoint(), "don't call this otherwise");
-  G1CardCountsClearClosure cl(this);
-  _g1h->heap_region_iterate(&cl);
-}
diff --git a/src/hotspot/share/gc/g1/g1CardCounts.hpp b/src/hotspot/share/gc/g1/g1CardCounts.hpp
deleted file mode 100644
index e4a7a97dae4..00000000000
--- a/src/hotspot/share/gc/g1/g1CardCounts.hpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_GC_G1_G1CARDCOUNTS_HPP
-#define SHARE_GC_G1_G1CARDCOUNTS_HPP
-
-#include "gc/g1/g1CardTable.hpp"
-#include "gc/g1/g1RegionToSpaceMapper.hpp"
-#include "memory/allocation.hpp"
-#include "memory/virtualspace.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-class CardTableBarrierSet;
-class G1CardCounts;
-class G1CollectedHeap;
-class G1RegionToSpaceMapper;
-class HeapRegion;
-
-class G1CardCountsMappingChangedListener : public G1MappingChangedListener {
- private:
-  G1CardCounts* _counts;
- public:
-  void set_cardcounts(G1CardCounts* counts) { _counts = counts; }
-
-  virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
-};
-
-// Table to track the number of times a card has been refined. Once
-// a card has been refined a certain number of times, it is
-// considered 'hot' and its refinement is delayed by inserting the
-// card into the hot card cache. The card will then be refined when
-// it is evicted from the hot card cache, or when the hot card cache
-// is 'drained' during the next evacuation pause.
-
-class G1CardCounts: public CHeapObj<mtGC> {
-public:
-  typedef CardTable::CardValue CardValue;
-
-private:
-  G1CardCountsMappingChangedListener _listener;
-
-  G1CollectedHeap* _g1h;
-  G1CardTable*     _ct;
-
-  // The table of counts
-  uint8_t* _card_counts;
-
-  // Max capacity of the reserved space for the counts table
-  size_t _reserved_max_card_num;
-
-  // CardTable bottom.
-  const CardValue* _ct_bot;
-
-  // Returns true if the card counts table has been reserved.
-  bool has_reserved_count_table() { return _card_counts != NULL; }
-
-  // Returns true if the card counts table has been reserved and committed.
-  bool has_count_table() {
-    return has_reserved_count_table();
-  }
-
-  size_t ptr_2_card_num(const CardValue* card_ptr) {
-    assert(card_ptr >= _ct_bot,
-           "Invalid card pointer: "
-           "card_ptr: " PTR_FORMAT ", "
-           "_ct_bot: " PTR_FORMAT,
-           p2i(card_ptr), p2i(_ct_bot));
-    size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(CardValue));
-    assert(card_num < _reserved_max_card_num,
-           "card pointer out of range: " PTR_FORMAT, p2i(card_ptr));
-    return card_num;
-  }
-
-  CardValue* card_num_2_ptr(size_t card_num) {
-    assert(card_num < _reserved_max_card_num,
-           "card num out of range: " SIZE_FORMAT, card_num);
-    return (CardValue*) (_ct_bot + card_num);
-  }
-
-  // Clear the counts table for the given (exclusive) index range.
-  void clear_range(size_t from_card_num, size_t to_card_num);
-
- public:
-  G1CardCounts(G1CollectedHeap* g1h);
-
-  // Return the number of slots needed for a card counts table
-  // that covers mem_region_words words.
-  static size_t compute_size(size_t mem_region_size_in_words);
-
-  // Returns how many bytes of the heap a single byte of the card counts table
-  // corresponds to.
-  static size_t heap_map_factor();
-
-  void initialize(G1RegionToSpaceMapper* mapper);
-
-  // Increments the refinement count for the given card.
-  // Returns the pre-increment count value.
-  uint add_card_count(CardValue* card_ptr);
-
-  // Returns true if the given count is high enough to be considered
-  // 'hot'; false otherwise.
-  bool is_hot(uint count);
-
-  // Clears the card counts for the cards spanned by the region
-  void clear_region(HeapRegion* hr);
-
-  // Clears the card counts for the cards spanned by the MemRegion
-  void clear_range(MemRegion mr);
-
-  // Clear the entire card counts table during GC.
-  void clear_all();
-};
-
-#endif // SHARE_GC_G1_G1CARDCOUNTS_HPP
diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
index 3d6306ee335..1244acba285 100644
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
@@ -50,7 +50,6 @@
 #include "gc/g1/g1HeapSizingPolicy.hpp"
 #include "gc/g1/g1HeapTransition.hpp"
 #include "gc/g1/g1HeapVerifier.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1InitLogger.hpp"
 #include "gc/g1/g1MemoryPool.hpp"
 #include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
@@ -490,40 +489,6 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size) {
   return NULL;
 }
 
-void G1CollectedHeap::begin_archive_alloc_range(bool open) {
-  assert_at_safepoint_on_vm_thread();
-  assert(_archive_allocator == nullptr, "should not be initialized");
-  _archive_allocator = G1ArchiveAllocator::create_allocator(this, open);
-}
-
-bool G1CollectedHeap::is_archive_alloc_too_large(size_t word_size) {
-  // Allocations in archive regions cannot be of a size that would be considered
-  // humongous even for a minimum-sized region, because G1 region sizes/boundaries
-  // may be different at archive-restore time.
-  return word_size >= humongous_threshold_for(HeapRegion::min_region_size_in_words());
-}
-
-HeapWord* G1CollectedHeap::archive_mem_allocate(size_t word_size) {
-  assert_at_safepoint_on_vm_thread();
-  assert(_archive_allocator != nullptr, "_archive_allocator not initialized");
-  if (is_archive_alloc_too_large(word_size)) {
-    return nullptr;
-  }
-  return _archive_allocator->archive_mem_allocate(word_size);
-}
-
-void G1CollectedHeap::end_archive_alloc_range(GrowableArray<MemRegion>* ranges,
-                                              size_t end_alignment_in_bytes) {
-  assert_at_safepoint_on_vm_thread();
-  assert(_archive_allocator != nullptr, "_archive_allocator not initialized");
-
-  // Call complete_archive to do the real work, filling in the MemRegion
-  // array with the archive regions.
-  _archive_allocator->complete_archive(ranges, end_alignment_in_bytes);
-  delete _archive_allocator;
-  _archive_allocator = nullptr;
-}
-
 bool G1CollectedHeap::check_archive_addresses(MemRegion* ranges, size_t count) {
   assert(ranges != NULL, "MemRegion array NULL");
   assert(count != 0, "No MemRegions provided");
@@ -1010,7 +975,7 @@ void G1CollectedHeap::verify_before_full_collection(bool explicit_gc) {
   _verifier->verify_bitmap_clear(true /* above_tams_only */);
 }
 
-void G1CollectedHeap::prepare_heap_for_mutators() {
+void G1CollectedHeap::prepare_for_mutator_after_full_collection() {
   // Delete metaspaces for unloaded class loaders and clean up loader_data graph
   ClassLoaderDataGraph::purge(/*at_safepoint*/true);
   DEBUG_ONLY(MetaspaceUtils::verify();)
@@ -1025,9 +990,7 @@ void G1CollectedHeap::prepare_heap_for_mutators() {
   // Rebuild the code root lists for each region
   rebuild_code_roots();
 
-  // Start a new incremental collection set for the next pause
   start_new_collection_set();
-
   _allocator->init_mutator_alloc_regions();
 
   // Post collection state updates.
@@ -1035,10 +998,6 @@ void G1CollectedHeap::prepare_heap_for_mutators() {
 }
 
 void G1CollectedHeap::abort_refinement() {
-  if (G1HotCardCache::use_cache()) {
-    _hot_card_cache->reset_hot_cache();
-  }
-
   // Discard all remembered set updates and reset refinement statistics.
   G1BarrierSet::dirty_card_queue_set().abandon_logs_and_stats();
   assert(G1BarrierSet::dirty_card_queue_set().num_cards() == 0,
@@ -1423,7 +1382,6 @@ G1CollectedHeap::G1CollectedHeap() :
   _verifier(NULL),
   _summary_bytes_used(0),
   _bytes_used_during_gc(0),
-  _archive_allocator(nullptr),
   _survivor_evac_stats("Young", YoungPLABSize, PLABWeight),
   _old_evac_stats("Old", OldPLABSize, PLABWeight),
   _monitoring_support(nullptr),
@@ -1440,7 +1398,6 @@ G1CollectedHeap::G1CollectedHeap() :
   _policy(new G1Policy(_gc_timer_stw)),
   _heap_sizing_policy(NULL),
   _collection_set(this, _policy),
-  _hot_card_cache(NULL),
   _rem_set(NULL),
   _card_set_config(),
   _card_set_freelist_pool(G1CardSetConfiguration::num_mem_object_types()),
@@ -1578,9 +1535,6 @@ jint G1CollectedHeap::initialize() {
     satbqs.set_buffer_enqueue_threshold_percentage(G1SATBBufferEnqueueingThresholdPercent);
   }
 
-  // Create the hot card cache.
-  _hot_card_cache = new G1HotCardCache(this);
-
   // Create space mappers.
   size_t page_size = heap_rs.page_size();
   G1RegionToSpaceMapper* heap_storage =
@@ -1603,7 +1557,7 @@ jint G1CollectedHeap::initialize() {
                        heap_rs.size());
   heap_storage->set_mapping_changed_listener(&_listener);
 
-  // Create storage for the BOT, card table, card counts table (hot card cache) and the bitmap.
+  // Create storage for the BOT, card table and the bitmap.
   G1RegionToSpaceMapper* bot_storage =
     create_aux_memory_mapper("Block Offset Table",
                              G1BlockOffsetTable::compute_size(heap_rs.size() / HeapWordSize),
@@ -1614,21 +1568,13 @@ jint G1CollectedHeap::initialize() {
                              G1CardTable::compute_size(heap_rs.size() / HeapWordSize),
                              G1CardTable::heap_map_factor());
 
-  G1RegionToSpaceMapper* card_counts_storage =
-    create_aux_memory_mapper("Card Counts Table",
-                             G1CardCounts::compute_size(heap_rs.size() / HeapWordSize),
-                             G1CardCounts::heap_map_factor());
-
   size_t bitmap_size = G1CMBitMap::compute_size(heap_rs.size());
   G1RegionToSpaceMapper* bitmap_storage =
     create_aux_memory_mapper("Mark Bitmap", bitmap_size, G1CMBitMap::heap_map_factor());
 
-  _hrm.initialize(heap_storage, bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
+  _hrm.initialize(heap_storage, bitmap_storage, bot_storage, cardtable_storage);
   _card_table->initialize(cardtable_storage);
 
-  // Do later initialization work for concurrent refinement.
-  _hot_card_cache->initialize(card_counts_storage);
-
   // 6843694 - ensure that the maximum region index can fit
   // in the remembered set structures.
   const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
@@ -1639,7 +1585,7 @@ jint G1CollectedHeap::initialize() {
   guarantee((uintptr_t)(heap_rs.base()) >= G1CardTable::card_size(), "Java heap must not start within the first card.");
   G1FromCardCache::initialize(max_reserved_regions());
   // Also create a G1 rem set.
-  _rem_set = new G1RemSet(this, _card_table, _hot_card_cache);
+  _rem_set = new G1RemSet(this, _card_table);
   _rem_set->initialize(max_reserved_regions());
 
   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
@@ -1819,14 +1765,9 @@ size_t G1CollectedHeap::unused_committed_regions_in_bytes() const {
   return _hrm.total_free_bytes();
 }
 
-void G1CollectedHeap::iterate_hcc_closure(G1CardTableEntryClosure* cl, uint worker_id) {
-  _hot_card_cache->drain(cl, worker_id);
-}
-
 // Computes the sum of the storage used by the various regions.
 size_t G1CollectedHeap::used() const {
   size_t result = _summary_bytes_used + _allocator->used_in_alloc_regions();
-  assert(_archive_allocator == nullptr, "must be, should not contribute to used");
   return result;
 }
 
@@ -1866,32 +1807,6 @@ bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
   }
 }
 
-#ifndef PRODUCT
-void G1CollectedHeap::allocate_dummy_regions() {
-  // Let's fill up most of the region
-  size_t word_size = HeapRegion::GrainWords - 1024;
-  // And as a result the region we'll allocate will be humongous.
-  guarantee(is_humongous(word_size), "sanity");
-
-  // _filler_array_max_size is set to humongous object threshold
-  // but temporarily change it to use CollectedHeap::fill_with_object().
-  AutoModifyRestore<size_t> temporarily(_filler_array_max_size, word_size);
-
-  for (uintx i = 0; i < G1DummyRegionsPerGC; ++i) {
-    // Let's use the existing mechanism for the allocation
-    HeapWord* dummy_obj = humongous_obj_allocate(word_size);
-    if (dummy_obj != NULL) {
-      MemRegion mr(dummy_obj, word_size);
-      CollectedHeap::fill_with_object(mr);
-    } else {
-      // If we can't allocate once, we probably cannot allocate
-      // again. Let's get out of the loop.
-      break;
-    }
-  }
-}
-#endif // !PRODUCT
-
 void G1CollectedHeap::increment_old_marking_cycles_started() {
   assert(_old_marking_cycles_started == _old_marking_cycles_completed ||
          _old_marking_cycles_started == _old_marking_cycles_completed + 1,
@@ -2642,8 +2557,6 @@ class VerifyRegionRemSetClosure : public HeapRegionClosure {
 };
 
 void G1CollectedHeap::start_new_collection_set() {
-  double start = os::elapsedTime();
-
   collection_set()->start_incremental_building();
 
   clear_region_attr();
@@ -2654,8 +2567,6 @@ void G1CollectedHeap::start_new_collection_set() {
   // We redo the verification but now wrt to the new CSet which
   // has just got initialized after the previous CSet was freed.
   _cm->verify_no_collection_set_oops();
-
-  phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
 }
 
 G1HeapVerifier::G1VerifyType G1CollectedHeap::young_collection_verify_type() const {
@@ -2765,19 +2676,17 @@ G1JFRTracerMark::~G1JFRTracerMark() {
   _tracer->report_gc_end(_timer->gc_end(), _timer->time_partitions());
 }
 
-void G1CollectedHeap::prepare_tlabs_for_mutator() {
+void G1CollectedHeap::prepare_for_mutator_after_young_collection() {
   Ticks start = Ticks::now();
 
   _survivor_evac_stats.adjust_desired_plab_size();
   _old_evac_stats.adjust_desired_plab_size();
 
-  allocate_dummy_regions();
-
+  // Start a new incremental collection set for the mutator phase.
+  start_new_collection_set();
   _allocator->init_mutator_alloc_regions();
 
-  resize_all_tlabs();
-
-  phase_times()->record_resize_tlab_time_ms((Ticks::now() - start).seconds() * 1000.0);
+  phase_times()->record_prepare_for_mutator_time_ms((Ticks::now() - start).seconds() * 1000.0);
 }
 
 void G1CollectedHeap::retire_tlabs() {
@@ -2880,13 +2789,6 @@ void G1CollectedHeap::free_region(HeapRegion* hr, FreeRegionList* free_list) {
   assert(!hr->is_empty(), "the region should not be empty");
   assert(_hrm.is_available(hr->hrm_index()), "region should be committed");
 
-  // Clear the card counts for this region.
-  // Note: we only need to do this if the region is not young
-  // (since we don't refine cards in young regions).
-  if (!hr->is_young()) {
-    _hot_card_cache->reset_card_counts(hr);
-  }
-
   // Reset region metadata to allow reuse.
   hr->hr_clear(true /* clear_space */);
   _policy->remset_tracker()->update_at_free(hr);
@@ -3107,7 +3009,6 @@ void G1CollectedHeap::rebuild_region_sets(bool free_list_only) {
 
   if (!free_list_only) {
     set_used(cl.total_used());
-    assert(_archive_allocator == nullptr, "must be, should not contribute to used");
   }
   assert_used_and_recalculate_used_equal(this);
 }
@@ -3306,8 +3207,6 @@ void G1CollectedHeap::update_used_after_gc(bool evacuation_failed) {
     evac_failure_injector()->reset();
 
     set_used(recalculate_used());
-
-    assert(_archive_allocator == nullptr, "must be, should not contribute to used");
   } else {
     // The "used" of the collection set have already been subtracted
     // when they were freed.  Add in the bytes used.
@@ -3315,10 +3214,6 @@ void G1CollectedHeap::update_used_after_gc(bool evacuation_failed) {
   }
 }
 
-void G1CollectedHeap::reset_hot_card_cache() {
-  _hot_card_cache->reset_hot_cache();
-}
-
 class RebuildCodeRootClosure: public CodeBlobClosure {
   G1CollectedHeap* _g1h;
 
diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp
index 77358d22433..644098d88a7 100644
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp
@@ -57,6 +57,7 @@
 #include "memory/iterator.hpp"
 #include "memory/memRegion.hpp"
 #include "runtime/mutexLocker.hpp"
+#include "runtime/threadSMR.hpp"
 #include "utilities/bitMap.hpp"
 
 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot.
@@ -66,7 +67,6 @@
 
 // Forward declarations
 class G1Allocator;
-class G1ArchiveAllocator;
 class G1BatchedTask;
 class G1CardTableEntryClosure;
 class G1ConcurrentMark;
@@ -75,7 +75,6 @@ class G1ConcurrentRefine;
 class G1GCCounters;
 class G1GCPhaseTimes;
 class G1HeapSizingPolicy;
-class G1HotCardCache;
 class G1NewTracer;
 class G1RemSet;
 class G1ServiceTask;
@@ -120,6 +119,32 @@ class G1RegionMappingChangedListener : public G1MappingChangedListener {
   void on_commit(uint start_idx, size_t num_regions, bool zero_filled) override;
 };
 
+// Helper to claim contiguous sets of JavaThread for processing by multiple threads.
+class G1JavaThreadsListClaimer : public StackObj {
+  ThreadsListHandle _list;
+  uint _claim_step;
+
+  volatile uint _cur_claim;
+
+  // Attempts to claim _claim_step JavaThreads, returning an array of claimed
+  // JavaThread* with count elements. Returns null (and a zero count) if there
+  // are no more threads to claim.
+  JavaThread* const* claim(uint& count);
+
+public:
+  G1JavaThreadsListClaimer(uint claim_step) : _list(), _claim_step(claim_step), _cur_claim(0) {
+    assert(claim_step > 0, "must be");
+  }
+
+  // Executes the given closure on the elements of the JavaThread list, chunking the
+  // JavaThread set in claim_step chunks for each caller to reduce parallelization
+  // overhead.
+  void apply(ThreadClosure* cl);
+
+  // Total number of JavaThreads that can be claimed.
+  uint length() const { return _list.length(); }
+};
+
 class G1CollectedHeap : public CollectedHeap {
   friend class VM_G1CollectForAllocation;
   friend class VM_G1CollectFull;
@@ -218,9 +243,6 @@ class G1CollectedHeap : public CollectedHeap {
   size_t bytes_used_during_gc() const { return _bytes_used_during_gc; }
 
 private:
-  // Class that handles archive allocation ranges.
-  G1ArchiveAllocator* _archive_allocator;
-
   // GC allocation statistics policy for survivors.
   G1EvacStats _survivor_evac_stats;
 
@@ -273,14 +295,6 @@ class G1CollectedHeap : public CollectedHeap {
   // concurrent cycles) we have completed.
   volatile uint _old_marking_cycles_completed;
 
-  // This is a non-product method that is helpful for testing. It is
-  // called at the end of a GC and artificially expands the heap by
-  // allocating a number of dead regions. This way we can induce very
-  // frequent marking cycles and stress the cleanup / concurrent
-  // cleanup code more (as all the regions that will be allocated by
-  // this method will be found dead by the marking cycle).
-  void allocate_dummy_regions() PRODUCT_RETURN;
-
   // Create a memory mapper for auxiliary data structures of the given size and
   // translation factor.
   static G1RegionToSpaceMapper* create_aux_memory_mapper(const char* description,
@@ -491,7 +505,7 @@ class G1CollectedHeap : public CollectedHeap {
   bool abort_concurrent_cycle();
   void verify_before_full_collection(bool explicit_gc);
   void prepare_heap_for_full_collection();
-  void prepare_heap_for_mutators();
+  void prepare_for_mutator_after_full_collection();
   void abort_refinement();
   void verify_after_full_collection();
   void print_heap_after_full_collection();
@@ -682,26 +696,6 @@ class G1CollectedHeap : public CollectedHeap {
   void free_humongous_region(HeapRegion* hr,
                              FreeRegionList* free_list);
 
-  // Facility for allocating in 'archive' regions in high heap memory and
-  // recording the allocated ranges. These should all be called from the
-  // VM thread at safepoints, without the heap lock held. They can be used
-  // to create and archive a set of heap regions which can be mapped at the
-  // same fixed addresses in a subsequent JVM invocation.
-  void begin_archive_alloc_range(bool open = false);
-
-  // Check if the requested size would be too large for an archive allocation.
-  bool is_archive_alloc_too_large(size_t word_size);
-
-  // Allocate memory of the requested size from the archive region. This will
-  // return NULL if the size is too large or if no memory is available. It
-  // does not trigger a garbage collection.
-  HeapWord* archive_mem_allocate(size_t word_size);
-
-  // Optionally aligns the end address and returns the allocated ranges in
-  // an array of MemRegions in order of ascending addresses.
-  void end_archive_alloc_range(GrowableArray<MemRegion>* ranges,
-                               size_t end_alignment_in_bytes = 0);
-
   // Facility for allocating a fixed range within the heap and marking
   // the containing regions as 'archive'. For use at JVM init time, when the
   // caller may mmap archived heap data at the specified range(s).
@@ -771,7 +765,7 @@ class G1CollectedHeap : public CollectedHeap {
   // Start a concurrent cycle.
   void start_concurrent_cycle(bool concurrent_operation_is_full_mark);
 
-  void prepare_tlabs_for_mutator();
+  void prepare_for_mutator_after_young_collection();
 
   void retire_tlabs();
 
@@ -780,9 +774,6 @@ class G1CollectedHeap : public CollectedHeap {
   void record_obj_copy_mem_stats();
 
 private:
-  // The hot card cache for remembered set insertion optimization.
-  G1HotCardCache* _hot_card_cache;
-
   // The g1 remembered set of the heap.
   G1RemSet* _rem_set;
   // Global card set configuration
@@ -936,9 +927,6 @@ class G1CollectedHeap : public CollectedHeap {
   static void start_codecache_marking_cycle_if_inactive(bool concurrent_mark_start);
   static void finish_codecache_marking_cycle();
 
-  // Apply the given closure on all cards in the Hot Card Cache, emptying it.
-  void iterate_hcc_closure(G1CardTableEntryClosure* cl, uint worker_id);
-
   // The shared block offset table array.
   G1BlockOffsetTable* bot() const { return _bot; }
 
@@ -1066,8 +1054,6 @@ class G1CollectedHeap : public CollectedHeap {
     return reserved().contains(addr);
   }
 
-  G1HotCardCache* hot_card_cache() const { return _hot_card_cache; }
-
   G1CardTable* card_table() const {
     return _card_table;
   }
@@ -1269,10 +1255,6 @@ class G1CollectedHeap : public CollectedHeap {
   // Recalculate amount of used memory after GC. Must be called after all allocation
   // has finished.
   void update_used_after_gc(bool evacuation_failed);
-  // Reset and re-enable the hot card cache.
-  // Note the counts for the cards in the regions in the
-  // collection set are reset when the collection set is freed.
-  void reset_hot_card_cache();
 
   // Rebuild the code root lists for each region
   // after a full GC.
diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
index e7f9b9ddf91..eea7ba13bdf 100644
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
@@ -41,6 +41,7 @@
 #include "gc/shared/taskqueue.inline.hpp"
 #include "oops/stackChunkOop.hpp"
 #include "runtime/atomic.hpp"
+#include "runtime/threadSMR.inline.hpp"
 #include "utilities/bitMap.inline.hpp"
 
 inline bool G1STWIsAliveClosure::do_object_b(oop p) {
@@ -49,6 +50,30 @@ inline bool G1STWIsAliveClosure::do_object_b(oop p) {
   return !_g1h->is_in_cset(p) || p->is_forwarded();
 }
 
+inline JavaThread* const* G1JavaThreadsListClaimer::claim(uint& count) {
+  count = 0;
+  if (Atomic::load(&_cur_claim) >= _list.length()) {
+    return nullptr;
+  }
+  uint claim = Atomic::fetch_and_add(&_cur_claim, _claim_step);
+  if (claim >= _list.length()) {
+    return nullptr;
+  }
+  count = MIN2(_list.length() - claim, _claim_step);
+  return _list.list()->threads() + claim;
+}
+
+inline void G1JavaThreadsListClaimer::apply(ThreadClosure* cl) {
+  JavaThread* const* list;
+  uint count;
+
+  while ((list = claim(count)) != nullptr) {
+    for (uint i = 0; i < count; i++) {
+      cl->do_thread(list[i]);
+    }
+  }
+}
+
 G1GCPhaseTimes* G1CollectedHeap::phase_times() const {
   return _policy->phase_times();
 }
@@ -214,7 +239,7 @@ inline bool G1CollectedHeap::requires_barriers(stackChunkOop obj) const {
 }
 
 inline bool G1CollectedHeap::is_obj_filler(const oop obj) {
-  Klass* k = obj->klass();
+  Klass* k = obj->klass_raw();
   return k == Universe::fillerArrayKlassObj() || k == vmClasses::FillerObject_klass();
 }
 
diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.cpp b/src/hotspot/share/gc/g1/g1CollectionSet.cpp
index a3c6446ebb9..3353294c959 100644
--- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp
+++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp
@@ -28,7 +28,6 @@
 #include "gc/g1/g1CollectionSet.hpp"
 #include "gc/g1/g1CollectionSetCandidates.hpp"
 #include "gc/g1/g1CollectorState.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1ParScanThreadState.hpp"
 #include "gc/g1/g1Policy.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
@@ -293,8 +292,7 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi
   guarantee(target_pause_time_ms > 0.0,
             "target_pause_time_ms = %1.6lf should be positive", target_pause_time_ms);
 
-  size_t pending_cards = _policy->pending_cards_at_gc_start() +
-                         _g1h->hot_card_cache()->num_entries();
+  size_t pending_cards = _policy->pending_cards_at_gc_start();
 
   log_trace(gc, ergo, cset)("Start choosing CSet. Pending cards: " SIZE_FORMAT " target pause time: %1.2fms",
                             pending_cards, target_pause_time_ms);
diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp
index 01d7fdf06d8..cae06c67d6c 100644
--- a/src/hotspot/share/gc/g1/g1FullCollector.cpp
+++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp
@@ -228,7 +228,7 @@ void G1FullCollector::complete_collection() {
   // Prepare the bitmap for the next (potentially concurrent) marking.
   _heap->concurrent_mark()->clear_bitmap(_heap->workers());
 
-  _heap->prepare_heap_for_mutators();
+  _heap->prepare_for_mutator_after_full_collection();
 
   _heap->resize_all_tlabs();
 
diff --git a/src/hotspot/share/gc/g1/g1FullGCMarker.inline.hpp b/src/hotspot/share/gc/g1/g1FullGCMarker.inline.hpp
index 3e6d1ad4232..d6075c7f593 100644
--- a/src/hotspot/share/gc/g1/g1FullGCMarker.inline.hpp
+++ b/src/hotspot/share/gc/g1/g1FullGCMarker.inline.hpp
@@ -127,7 +127,7 @@ void G1FullGCMarker::follow_array_chunk(objArrayOop array, int index) {
     _verify_closure.set_containing_obj(array);
     array->oop_iterate_range(&_verify_closure, beg_index, end_index);
     if (_verify_closure.failures()) {
-      assert(false, "Failed");
+      fatal("there should not have been any failures");
     }
   }
 }
@@ -148,7 +148,7 @@ inline void G1FullGCMarker::follow_object(oop obj) {
       obj->oop_iterate(&_verify_closure);
       if (_verify_closure.failures()) {
         log_warning(gc, verify)("Failed after %d", _verify_closure._cc);
-        assert(false, "Failed");
+        fatal("there should not have been any failures");
       }
     }
   }
diff --git a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
index 22ba021ec6d..e207f1e32cb 100644
--- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
+++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
@@ -30,7 +30,6 @@
 #include "gc/g1/g1FullGCMarker.hpp"
 #include "gc/g1/g1FullGCOopClosures.inline.hpp"
 #include "gc/g1/g1FullGCPrepareTask.inline.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/referenceProcessor.hpp"
@@ -119,11 +118,6 @@ G1FullGCPrepareTask::G1ResetMetadataClosure::G1ResetMetadataClosure(G1FullCollec
 void G1FullGCPrepareTask::G1ResetMetadataClosure::reset_region_metadata(HeapRegion* hr) {
   hr->rem_set()->clear();
   hr->clear_cardtable();
-
-  G1HotCardCache* hcc = _g1h->hot_card_cache();
-  if (G1HotCardCache::use_cache()) {
-    hcc->reset_card_counts(hr);
-  }
 }
 
 bool G1FullGCPrepareTask::G1ResetMetadataClosure::do_heap_region(HeapRegion* hr) {
diff --git a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp
index 3d7e204bfa3..df98fdd3478 100644
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp
@@ -26,7 +26,6 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1GCParPhaseTimesTracker.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1ParScanThreadState.inline.hpp"
 #include "gc/shared/gcTimer.hpp"
 #include "gc/shared/oopStorage.hpp"
@@ -83,13 +82,6 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) :
   }
 
   _gc_par_phases[MergeLB] = new WorkerDataArray<double>("MergeLB", "Log Buffers (ms):", max_gc_threads);
-  if (G1HotCardCache::use_cache()) {
-    _gc_par_phases[MergeHCC] = new WorkerDataArray<double>("MergeHCC", "Hot Card Cache (ms):", max_gc_threads);
-    _gc_par_phases[MergeHCC]->create_thread_work_items("Dirty Cards:", MergeHCCDirtyCards);
-    _gc_par_phases[MergeHCC]->create_thread_work_items("Skipped Cards:", MergeHCCSkippedCards);
-  } else {
-    _gc_par_phases[MergeHCC] = NULL;
-  }
   _gc_par_phases[ScanHR] = new WorkerDataArray<double>("ScanHR", "Scan Heap Roots (ms):", max_gc_threads);
   _gc_par_phases[OptScanHR] = new WorkerDataArray<double>("OptScanHR", "Optional Scan Heap Roots (ms):", max_gc_threads);
   _gc_par_phases[CodeRoots] = new WorkerDataArray<double>("CodeRoots", "Code Root Scan (ms):", max_gc_threads);
@@ -106,7 +98,6 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) :
   _gc_par_phases[RemoveSelfForwards] = new WorkerDataArray<double>("RemoveSelfForwards", "Remove Self Forwards (ms):", max_gc_threads);
   _gc_par_phases[ClearCardTable] = new WorkerDataArray<double>("ClearLoggedCards", "Clear Logged Cards (ms):", max_gc_threads);
   _gc_par_phases[RecalculateUsed] = new WorkerDataArray<double>("RecalculateUsed", "Recalculate Used Memory (ms):", max_gc_threads);
-  _gc_par_phases[ResetHotCardCache] = new WorkerDataArray<double>("ResetHotCardCache", "Reset Hot Card Cache (ms):", max_gc_threads);
 #if COMPILER2_OR_JVMCI
   _gc_par_phases[UpdateDerivedPointers] = new WorkerDataArray<double>("UpdateDerivedPointers", "Update Derived Pointers (ms):", max_gc_threads);
 #endif
@@ -153,6 +144,8 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) :
   _gc_par_phases[RedirtyCards] = new WorkerDataArray<double>("RedirtyCards", "Redirty Logged Cards (ms):", max_gc_threads);
   _gc_par_phases[RedirtyCards]->create_thread_work_items("Redirtied Cards:");
 
+  _gc_par_phases[ResizeThreadLABs] = new WorkerDataArray<double>("ResizeTLABs", "Resize TLABs (ms):", max_gc_threads);
+
   _gc_par_phases[FreeCollectionSet] = new WorkerDataArray<double>("FreeCSet", "Free Collection Set (ms):", max_gc_threads);
   _gc_par_phases[YoungFreeCSet] = new WorkerDataArray<double>("YoungFreeCSet", "Young Free Collection Set (ms):", max_gc_threads);
   _gc_par_phases[NonYoungFreeCSet] = new WorkerDataArray<double>("NonYoungFreeCSet", "Non-Young Free Collection Set (ms):", max_gc_threads);
@@ -173,7 +166,6 @@ void G1GCPhaseTimes::reset() {
   _cur_prepare_merge_heap_roots_time_ms = 0.0;
   _cur_optional_prepare_merge_heap_roots_time_ms = 0.0;
   _cur_prepare_tlab_time_ms = 0.0;
-  _cur_resize_tlab_time_ms = 0.0;
   _cur_post_evacuate_cleanup_1_time_ms = 0.0;
   _cur_post_evacuate_cleanup_2_time_ms = 0.0;
   _cur_expand_heap_time_ms = 0.0;
@@ -184,7 +176,7 @@ void G1GCPhaseTimes::reset() {
   _recorded_prepare_heap_roots_time_ms = 0.0;
   _recorded_young_cset_choice_time_ms = 0.0;
   _recorded_non_young_cset_choice_time_ms = 0.0;
-  _recorded_start_new_cset_time_ms = 0.0;
+  _recorded_prepare_for_mutator_time_ms = 0.0;
   _recorded_serial_free_cset_time_ms = 0.0;
   _recorded_total_rebuild_freelist_time_ms = 0.0;
   _recorded_serial_rebuild_freelist_time_ms = 0.0;
@@ -247,7 +239,6 @@ void G1GCPhaseTimes::record_gc_pause_end() {
       ASSERT_PHASE_UNINITIALIZED(MergeER);
       ASSERT_PHASE_UNINITIALIZED(MergeRS);
       ASSERT_PHASE_UNINITIALIZED(OptMergeRS);
-      ASSERT_PHASE_UNINITIALIZED(MergeHCC);
       ASSERT_PHASE_UNINITIALIZED(MergeLB);
       ASSERT_PHASE_UNINITIALIZED(ScanHR);
       ASSERT_PHASE_UNINITIALIZED(CodeRoots);
@@ -459,9 +450,6 @@ double G1GCPhaseTimes::print_evacuate_initial_collection_set() const {
   debug_time("Prepare Merge Heap Roots", _cur_prepare_merge_heap_roots_time_ms);
   debug_phase_merge_remset();
 
-  if (G1HotCardCache::use_cache()) {
-    debug_phase(_gc_par_phases[MergeHCC]);
-  }
   debug_phase(_gc_par_phases[MergeLB]);
 
   info_time("Evacuate Collection Set", _cur_collection_initial_evac_time_ms);
@@ -489,7 +477,7 @@ double G1GCPhaseTimes::print_post_evacuate_collection_set(bool evacuation_failed
                         _cur_post_evacuate_cleanup_1_time_ms +
                         _cur_post_evacuate_cleanup_2_time_ms +
                         _recorded_total_rebuild_freelist_time_ms +
-                        _recorded_start_new_cset_time_ms +
+                        _recorded_prepare_for_mutator_time_ms +
                         _cur_expand_heap_time_ms;
 
   info_time("Post Evacuate Collection Set", sum_ms);
@@ -517,7 +505,6 @@ double G1GCPhaseTimes::print_post_evacuate_collection_set(bool evacuation_failed
     debug_phase(_gc_par_phases[RestorePreservedMarks], 1);
     debug_phase(_gc_par_phases[ClearRetainedRegionBitmaps], 1);
   }
-  debug_phase(_gc_par_phases[ResetHotCardCache], 1);
 #if COMPILER2_OR_JVMCI
   debug_phase(_gc_par_phases[UpdateDerivedPointers], 1);
 #endif
@@ -527,6 +514,9 @@ double G1GCPhaseTimes::print_post_evacuate_collection_set(bool evacuation_failed
     debug_phase(_gc_par_phases[SampleCollectionSetCandidates], 1);
   }
   debug_phase(_gc_par_phases[RedirtyCards], 1);
+  if (UseTLAB && ResizeTLAB) {
+    debug_phase(_gc_par_phases[ResizeThreadLABs], 1);
+  }
   debug_phase(_gc_par_phases[FreeCollectionSet], 1);
   trace_phase(_gc_par_phases[YoungFreeCSet], true, 1);
   trace_phase(_gc_par_phases[NonYoungFreeCSet], true, 1);
@@ -537,10 +527,7 @@ double G1GCPhaseTimes::print_post_evacuate_collection_set(bool evacuation_failed
   trace_time("Serial Rebuild Free List ", _recorded_serial_rebuild_freelist_time_ms);
   trace_phase(_gc_par_phases[RebuildFreeList]);
 
-  debug_time("Start New Collection Set", _recorded_start_new_cset_time_ms);
-  if (UseTLAB && ResizeTLAB) {
-    debug_time("Resize TLABs", _cur_resize_tlab_time_ms);
-  }
+  debug_time("Prepare For Mutator", _recorded_prepare_for_mutator_time_ms);
   debug_time("Expand Heap After Collection", _cur_expand_heap_time_ms);
 
   return sum_ms;
diff --git a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp
index 98fb9688102..a5aef338655 100644
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp
@@ -58,7 +58,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
     MergeRS,
     OptMergeRS,
     MergeLB,
-    MergeHCC,
     ScanHR,
     OptScanHR,
     CodeRoots,
@@ -74,6 +73,7 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
     FreeCollectionSet,
     YoungFreeCSet,
     NonYoungFreeCSet,
+    ResizeThreadLABs,
     RebuildFreeList,
     SampleCollectionSetCandidates,
     MergePSS,
@@ -81,7 +81,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
     RemoveSelfForwards,
     ClearCardTable,
     RecalculateUsed,
-    ResetHotCardCache,
 #if COMPILER2_OR_JVMCI
     UpdateDerivedPointers,
 #endif
@@ -128,11 +127,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
     ScanHRUsedMemory
   };
 
-  enum GCMergeHCCWorkItems {
-    MergeHCCDirtyCards,
-    MergeHCCSkippedCards
-  };
-
   enum GCMergeLBWorkItems {
     MergeLBDirtyCards,
     MergeLBSkippedCards
@@ -179,7 +173,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
   double _cur_optional_prepare_merge_heap_roots_time_ms;
 
   double _cur_prepare_tlab_time_ms;
-  double _cur_resize_tlab_time_ms;
 
   double _cur_concatenate_dirty_card_logs_time_ms;
 
@@ -199,7 +192,7 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
   double _recorded_young_cset_choice_time_ms;
   double _recorded_non_young_cset_choice_time_ms;
 
-  double _recorded_start_new_cset_time_ms;
+  double _recorded_prepare_for_mutator_time_ms;
 
   double _recorded_serial_free_cset_time_ms;
 
@@ -276,10 +269,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
     _cur_prepare_tlab_time_ms = ms;
   }
 
-  void record_resize_tlab_time_ms(double ms) {
-    _cur_resize_tlab_time_ms = ms;
-  }
-
   void record_concatenate_dirty_card_logs_time_ms(double ms) {
     _cur_concatenate_dirty_card_logs_time_ms = ms;
   }
@@ -356,8 +345,8 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
     _recorded_non_young_cset_choice_time_ms = time_ms;
   }
 
-  void record_start_new_cset_time_ms(double time_ms) {
-    _recorded_start_new_cset_time_ms = time_ms;
+  void record_prepare_for_mutator_time_ms(double time_ms) {
+    _recorded_prepare_for_mutator_time_ms = time_ms;
   }
 
   void record_cur_collection_start_sec(double time_ms) {
diff --git a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp
index e1b20b9b247..ad971da5fcd 100644
--- a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp
+++ b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -310,28 +310,6 @@ class VerifyReadyForArchivingRegionClosure : public HeapRegionClosure {
   }
 };
 
-// We want all used regions to be moved to the bottom-end of the heap, so we have
-// a contiguous range of free regions at the top end of the heap. This way, we can
-// avoid fragmentation while allocating the archive regions.
-//
-// Before calling this, a full GC should have been executed with a single worker thread,
-// so that no old regions would be moved to the middle of the heap.
-void G1HeapVerifier::verify_ready_for_archiving() {
-  VerifyReadyForArchivingRegionClosure cl;
-  G1CollectedHeap::heap()->heap_region_iterate(&cl);
-  if (cl.has_holes()) {
-    log_warning(gc, verify)("All free regions should be at the top end of the heap, but"
-                            " we found holes. This is probably caused by (unmovable) humongous"
-                            " allocations or active GCLocker, and may lead to fragmentation while"
-                            " writing archive heap memory regions.");
-  }
-  if (cl.has_humongous()) {
-    log_warning(gc, verify)("(Unmovable) humongous regions have been found and"
-                            " may lead to fragmentation while"
-                            " writing archive heap memory regions.");
-  }
-}
-
 class VerifyArchivePointerRegionClosure: public HeapRegionClosure {
   virtual bool do_heap_region(HeapRegion* r) {
    if (r->is_archive()) {
diff --git a/src/hotspot/share/gc/g1/g1HeapVerifier.hpp b/src/hotspot/share/gc/g1/g1HeapVerifier.hpp
index d48e185d18a..df51e1f2d2b 100644
--- a/src/hotspot/share/gc/g1/g1HeapVerifier.hpp
+++ b/src/hotspot/share/gc/g1/g1HeapVerifier.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,6 @@ class G1HeapVerifier : public CHeapObj<mtGC> {
   void verify_dirty_region(HeapRegion* hr) PRODUCT_RETURN;
   void verify_dirty_young_regions() PRODUCT_RETURN;
 
-  static void verify_ready_for_archiving();
   static void verify_archive_regions();
 };
 
diff --git a/src/hotspot/share/gc/g1/g1HotCardCache.cpp b/src/hotspot/share/gc/g1/g1HotCardCache.cpp
deleted file mode 100644
index 371c0200053..00000000000
--- a/src/hotspot/share/gc/g1/g1HotCardCache.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "gc/g1/g1CardTableEntryClosure.hpp"
-#include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1DirtyCardQueue.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
-#include "runtime/atomic.hpp"
-
-G1HotCardCache::G1HotCardCache(G1CollectedHeap *g1h):
-  _g1h(g1h), _card_counts(g1h),
-  _hot_cache(NULL), _hot_cache_size(0), _hot_cache_par_chunk_size(0),
-  _hot_cache_idx(0), _hot_cache_par_claimed_idx(0), _cache_wrapped_around(false)
-{}
-
-void G1HotCardCache::initialize(G1RegionToSpaceMapper* card_counts_storage) {
-  if (use_cache()) {
-    _hot_cache_size = (size_t)1 << G1ConcRSLogCacheSize;
-    _hot_cache = ArrayAllocator<CardValue*>::allocate(_hot_cache_size, mtGC);
-
-    reset_hot_cache_internal();
-
-    // For refining the cards in the hot cache in parallel
-    _hot_cache_par_chunk_size = ClaimChunkSize;
-    _hot_cache_par_claimed_idx = 0;
-
-    _cache_wrapped_around = false;
-
-    _card_counts.initialize(card_counts_storage);
-  }
-}
-
-G1HotCardCache::~G1HotCardCache() {
-  if (use_cache()) {
-    assert(_hot_cache != NULL, "Logic");
-    ArrayAllocator<CardValue*>::free(_hot_cache, _hot_cache_size);
-    _hot_cache = NULL;
-  }
-}
-
-CardTable::CardValue* G1HotCardCache::insert(CardValue* card_ptr) {
-  uint count = _card_counts.add_card_count(card_ptr);
-  if (!_card_counts.is_hot(count)) {
-    // The card is not hot so do not store it in the cache;
-    // return it for immediate refining.
-    return card_ptr;
-  }
-  // Otherwise, the card is hot.
-  size_t index = Atomic::fetch_and_add(&_hot_cache_idx, 1u);
-  if (index == _hot_cache_size) {
-    // Can use relaxed store because all racing threads are writing the same
-    // value and there aren't any concurrent readers.
-    Atomic::store(&_cache_wrapped_around, true);
-  }
-  size_t masked_index = index & (_hot_cache_size - 1);
-  CardValue* current_ptr = _hot_cache[masked_index];
-
-  // Try to store the new card pointer into the cache. Compare-and-swap to guard
-  // against the unlikely event of a race resulting in another card pointer to
-  // have already been written to the cache. In this case we will return
-  // card_ptr in favor of the other option, which would be starting over. This
-  // should be OK since card_ptr will likely be the older card already when/if
-  // this ever happens.
-  CardValue* previous_ptr = Atomic::cmpxchg(&_hot_cache[masked_index],
-                                            current_ptr,
-                                            card_ptr);
-  return (previous_ptr == current_ptr) ? previous_ptr : card_ptr;
-}
-
-void G1HotCardCache::drain(G1CardTableEntryClosure* cl, uint worker_id) {
-  assert(use_cache(), "Drain only necessary if we use the hot card cache.");
-
-  assert(_hot_cache != NULL, "Logic");
-
-  while (_hot_cache_par_claimed_idx < _hot_cache_size) {
-    size_t end_idx = Atomic::add(&_hot_cache_par_claimed_idx,
-                                 _hot_cache_par_chunk_size);
-    size_t start_idx = end_idx - _hot_cache_par_chunk_size;
-    // The current worker has successfully claimed the chunk [start_idx..end_idx)
-    end_idx = MIN2(end_idx, _hot_cache_size);
-    for (size_t i = start_idx; i < end_idx; i++) {
-      CardValue* card_ptr = _hot_cache[i];
-      if (card_ptr != NULL) {
-        cl->do_card_ptr(card_ptr, worker_id);
-      } else {
-        break;
-      }
-    }
-  }
-
-  // The existing entries in the hot card cache, which were just refined
-  // above, are discarded prior to re-enabling the cache near the end of the GC.
-}
-
-void G1HotCardCache::reset_card_counts(HeapRegion* hr) {
-  _card_counts.clear_region(hr);
-}
diff --git a/src/hotspot/share/gc/g1/g1HotCardCache.hpp b/src/hotspot/share/gc/g1/g1HotCardCache.hpp
deleted file mode 100644
index 8ec0f9352a7..00000000000
--- a/src/hotspot/share/gc/g1/g1HotCardCache.hpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_GC_G1_G1HOTCARDCACHE_HPP
-#define SHARE_GC_G1_G1HOTCARDCACHE_HPP
-
-#include "gc/g1/g1CardCounts.hpp"
-#include "memory/allocation.hpp"
-#include "runtime/javaThread.hpp"
-#include "runtime/safepoint.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-class G1CardTableEntryClosure;
-class G1CollectedHeap;
-class HeapRegion;
-
-// An evicting cache of cards that have been logged by the G1 post
-// write barrier. Placing a card in the cache delays the refinement
-// of the card until the card is evicted, or the cache is drained
-// during the next evacuation pause.
-//
-// The first thing the G1 post write barrier does is to check whether
-// the card containing the updated pointer is already dirty and, if
-// so, skips the remaining code in the barrier.
-//
-// Delaying the refinement of a card will make the card fail the
-// first is_dirty check in the write barrier, skipping the remainder
-// of the write barrier.
-//
-// This can significantly reduce the overhead of the write barrier
-// code, increasing throughput.
-
-class G1HotCardCache: public CHeapObj<mtGC> {
-public:
-  typedef CardTable::CardValue CardValue;
-
-private:
-  G1CollectedHeap*  _g1h;
-
-  G1CardCounts      _card_counts;
-
-
-  // The card cache table
-  CardValue** _hot_cache;
-
-  size_t            _hot_cache_size;
-
-  size_t            _hot_cache_par_chunk_size;
-
-  // Avoids false sharing when concurrently updating _hot_cache_idx or
-  // _hot_cache_par_claimed_idx. These are never updated at the same time
-  // thus it's not necessary to separate them as well
-  char _pad_before[DEFAULT_CACHE_LINE_SIZE];
-
-  volatile size_t _hot_cache_idx;
-
-  volatile size_t _hot_cache_par_claimed_idx;
-
-  char _pad_after[DEFAULT_CACHE_LINE_SIZE];
-
-  // Records whether insertion overflowed the hot card cache at least once. This
-  // avoids the need for a separate atomic counter of how many valid entries are
-  // in the HCC.
-  volatile bool _cache_wrapped_around;
-
-  // The number of cached cards a thread claims when flushing the cache
-  static const int ClaimChunkSize = 32;
-
- public:
-  static bool use_cache() {
-    return (G1ConcRSLogCacheSize > 0);
-  }
-
-  G1HotCardCache(G1CollectedHeap* g1h);
-  ~G1HotCardCache();
-
-  void initialize(G1RegionToSpaceMapper* card_counts_storage);
-
-  // Returns the card to be refined or NULL.
-  //
-  // Increments the count for given the card. if the card is not 'hot',
-  // it is returned for immediate refining. Otherwise the card is
-  // added to the hot card cache.
-  // If there is enough room in the hot card cache for the card we're
-  // adding, NULL is returned and no further action in needed.
-  // If we evict a card from the cache to make room for the new card,
-  // the evicted card is then returned for refinement.
-  CardValue* insert(CardValue* card_ptr);
-
-  // Refine the cards that have delayed as a result of
-  // being in the cache.
-  void drain(G1CardTableEntryClosure* cl, uint worker_id);
-
-  // Set up for parallel processing of the cards in the hot cache
-  void reset_hot_cache_claimed_index() {
-    _hot_cache_par_claimed_idx = 0;
-  }
-
-  // Resets the hot card cache and discards the entries.
-  void reset_hot_cache() {
-    assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
-    if (use_cache()) {
-      reset_hot_cache_internal();
-    }
-  }
-
-  // Zeros the values in the card counts table for the given region
-  void reset_card_counts(HeapRegion* hr);
-
-  // Number of entries in the HCC.
-  size_t num_entries() const {
-    return _cache_wrapped_around ? _hot_cache_size : _hot_cache_idx + 1;
-  }
- private:
-  void reset_hot_cache_internal() {
-    assert(_hot_cache != NULL, "Logic");
-    _hot_cache_idx = 0;
-    for (size_t i = 0; i < _hot_cache_size; i++) {
-      _hot_cache[i] = NULL;
-    }
-    _cache_wrapped_around = false;
-  }
-};
-
-#endif // SHARE_GC_G1_G1HOTCARDCACHE_HPP
diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp
index a3ee1e04819..46006cc1196 100644
--- a/src/hotspot/share/gc/g1/g1Policy.cpp
+++ b/src/hotspot/share/gc/g1/g1Policy.cpp
@@ -34,7 +34,6 @@
 #include "gc/g1/g1ConcurrentRefine.hpp"
 #include "gc/g1/g1ConcurrentRefineStats.hpp"
 #include "gc/g1/g1CollectionSetChooser.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1IHOPControl.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
 #include "gc/g1/g1Policy.hpp"
@@ -800,11 +799,9 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar
 
   _eden_surv_rate_group->start_adding_regions();
 
-  double merge_hcc_time_ms = average_time_ms(G1GCPhaseTimes::MergeHCC);
   if (update_stats) {
     // Update prediction for card merge.
-    size_t const merged_cards_from_log_buffers = p->sum_thread_work_items(G1GCPhaseTimes::MergeHCC, G1GCPhaseTimes::MergeHCCDirtyCards) +
-                                                 p->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards);
+    size_t const merged_cards_from_log_buffers = p->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards);
     // MergeRSCards includes the cards from the Eager Reclaim phase.
     size_t const merged_cards_from_rs = p->sum_thread_work_items(G1GCPhaseTimes::MergeRS, G1GCPhaseTimes::MergeRSCards) +
                                         p->sum_thread_work_items(G1GCPhaseTimes::OptMergeRS, G1GCPhaseTimes::MergeRSCards);
@@ -814,7 +811,6 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar
     if (total_cards_merged >= G1NumCardsCostSampleThreshold) {
       double avg_time_merge_cards = average_time_ms(G1GCPhaseTimes::MergeER) +
                                     average_time_ms(G1GCPhaseTimes::MergeRS) +
-                                    average_time_ms(G1GCPhaseTimes::MergeHCC) +
                                     average_time_ms(G1GCPhaseTimes::MergeLB) +
                                     average_time_ms(G1GCPhaseTimes::OptMergeRS);
       _analytics->report_cost_per_card_merge_ms(avg_time_merge_cards / total_cards_merged, is_young_only_pause);
@@ -897,36 +893,21 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar
   // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
   double logged_cards_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
 
-  if (logged_cards_time_goal_ms < merge_hcc_time_ms) {
-    log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)."
-                                "Logged Cards Scan time goal: %1.2fms Scan HCC time: %1.2fms",
-                                logged_cards_time_goal_ms, merge_hcc_time_ms);
-
-    logged_cards_time_goal_ms = 0;
-  } else {
-    logged_cards_time_goal_ms -= merge_hcc_time_ms;
-  }
-
   double const logged_cards_time_ms = logged_cards_processing_time();
   size_t logged_cards =
     phase_times()->sum_thread_work_items(G1GCPhaseTimes::MergeLB,
                                          G1GCPhaseTimes::MergeLBDirtyCards);
-  size_t hcc_cards =
-    phase_times()->sum_thread_work_items(G1GCPhaseTimes::MergeHCC,
-                                         G1GCPhaseTimes::MergeHCCDirtyCards);
   bool exceeded_goal = logged_cards_time_goal_ms < logged_cards_time_ms;
   size_t predicted_thread_buffer_cards = _analytics->predict_dirtied_cards_in_thread_buffers();
   G1ConcurrentRefine* cr = _g1h->concurrent_refine();
 
   log_debug(gc, ergo, refine)
-           ("GC refinement: goal: %zu + %zu / %1.2fms, actual: %zu / %1.2fms, HCC: %zu / %1.2fms%s",
+           ("GC refinement: goal: %zu + %zu / %1.2fms, actual: %zu / %1.2fms, %s",
             cr->pending_cards_target(),
             predicted_thread_buffer_cards,
             logged_cards_time_goal_ms,
             logged_cards,
             logged_cards_time_ms,
-            hcc_cards,
-            merge_hcc_time_ms,
             (exceeded_goal ? " (exceeded goal)" : ""));
 
   cr->adjust_after_gc(logged_cards_time_ms,
diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp
index ff59b3a1189..1554f52ec58 100644
--- a/src/hotspot/share/gc/g1/g1RemSet.cpp
+++ b/src/hotspot/share/gc/g1/g1RemSet.cpp
@@ -35,7 +35,6 @@
 #include "gc/g1/g1FromCardCache.hpp"
 #include "gc/g1/g1GCParPhaseTimesTracker.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1OopClosures.inline.hpp"
 #include "gc/g1/g1Policy.hpp"
 #include "gc/g1/g1RootClosures.hpp"
@@ -64,7 +63,7 @@
 // Collects information about the overall heap root scan progress during an evacuation.
 //
 // Scanning the remembered sets works by first merging all sources of cards to be
-// scanned (log buffers, hcc, remembered sets) into a single data structure to remove
+// scanned (log buffers, remembered sets) into a single data structure to remove
 // duplicates and simplify work distribution.
 //
 // During the following card scanning we not only scan this combined set of cards, but
@@ -467,14 +466,12 @@ class G1RemSetScanState : public CHeapObj<mtGC> {
 };
 
 G1RemSet::G1RemSet(G1CollectedHeap* g1h,
-                   G1CardTable* ct,
-                   G1HotCardCache* hot_card_cache) :
+                   G1CardTable* ct) :
   _scan_state(new G1RemSetScanState()),
   _prev_period_summary(false),
   _g1h(g1h),
   _ct(ct),
-  _g1p(_g1h->policy()),
-  _hot_card_cache(hot_card_cache) {
+  _g1p(_g1h->policy()) {
 }
 
 G1RemSet::~G1RemSet() {
@@ -1370,17 +1367,6 @@ class G1MergeHeapRootsTask : public WorkerTask {
       }
     }
 
-    // Apply closure to log entries in the HCC.
-    if (_initial_evacuation && G1HotCardCache::use_cache()) {
-      assert(merge_remset_phase == G1GCPhaseTimes::MergeRS, "Wrong merge phase");
-      G1GCParPhaseTimesTracker x(p, G1GCPhaseTimes::MergeHCC, worker_id);
-      G1MergeLogBufferCardsClosure cl(g1h, _scan_state);
-      g1h->iterate_hcc_closure(&cl, worker_id);
-
-      p->record_thread_work_item(G1GCPhaseTimes::MergeHCC, worker_id, cl.cards_dirty(), G1GCPhaseTimes::MergeHCCDirtyCards);
-      p->record_thread_work_item(G1GCPhaseTimes::MergeHCC, worker_id, cl.cards_skipped(), G1GCPhaseTimes::MergeHCCSkippedCards);
-    }
-
     // Now apply the closure to all remaining log entries.
     if (_initial_evacuation) {
       assert(merge_remset_phase == G1GCPhaseTimes::MergeRS, "Wrong merge phase");
@@ -1528,37 +1514,6 @@ bool G1RemSet::clean_card_before_refine(CardValue** const card_ptr_addr) {
     return false;
   }
 
-  // The result from the hot card cache insert call is either:
-  //   * pointer to the current card
-  //     (implying that the current card is not 'hot'),
-  //   * null
-  //     (meaning we had inserted the card ptr into the "hot" card cache,
-  //     which had some headroom),
-  //   * a pointer to a "hot" card that was evicted from the "hot" cache.
-  //
-
-  if (G1HotCardCache::use_cache()) {
-    const CardValue* orig_card_ptr = card_ptr;
-    card_ptr = _hot_card_cache->insert(card_ptr);
-    if (card_ptr == NULL) {
-      // There was no eviction. Nothing to do.
-      return false;
-    } else if (card_ptr != orig_card_ptr) {
-      // Original card was inserted and an old card was evicted.
-      start = _ct->addr_for(card_ptr);
-      r = _g1h->heap_region_containing_or_null(start);
-
-      // Check whether the region formerly in the cache should be
-      // ignored, as discussed earlier for the original card.  The
-      // region could have been freed (or even uncommitted) while
-      // in the cache.
-      if (r == nullptr || !r->is_old_or_humongous_or_archive()) {
-        return false;
-      }
-      *card_ptr_addr = card_ptr;
-    } // Else we still have the original card.
-  }
-
   // Trim the region designated by the card to what's been allocated
   // in the region.  The card could be stale, or the card could cover
   // (part of) an object at the end of the allocated space and extend
diff --git a/src/hotspot/share/gc/g1/g1RemSet.hpp b/src/hotspot/share/gc/g1/g1RemSet.hpp
index 54e5a7c97b3..053fc39aa83 100644
--- a/src/hotspot/share/gc/g1/g1RemSet.hpp
+++ b/src/hotspot/share/gc/g1/g1RemSet.hpp
@@ -43,7 +43,6 @@ class CodeBlobClosure;
 class G1AbstractSubTask;
 class G1CollectedHeap;
 class G1CMBitMap;
-class G1HotCardCache;
 class G1RemSetScanState;
 class G1ParScanThreadState;
 class G1ParScanThreadStateSet;
@@ -69,7 +68,6 @@ class G1RemSet: public CHeapObj<mtGC> {
 
   G1CardTable*           _ct;
   G1Policy*              _g1p;
-  G1HotCardCache*        _hot_card_cache;
 
   void print_merge_heap_roots_stats();
 
@@ -81,9 +79,7 @@ class G1RemSet: public CHeapObj<mtGC> {
   // Initialize data that depends on the heap size being known.
   void initialize(uint max_reserved_regions);
 
-  G1RemSet(G1CollectedHeap* g1h,
-           G1CardTable* ct,
-           G1HotCardCache* hot_card_cache);
+  G1RemSet(G1CollectedHeap* g1h, G1CardTable* ct);
   ~G1RemSet();
 
   // Scan all cards in the non-collection set regions that potentially contain
@@ -94,7 +90,7 @@ class G1RemSet: public CHeapObj<mtGC> {
                        G1GCPhaseTimes::GCParPhases objcopy_phase,
                        bool remember_already_scanned_cards);
 
-  // Merge cards from various sources (remembered sets, hot card cache, log buffers)
+  // Merge cards from various sources (remembered sets, log buffers)
   // and calculate the cards that need to be scanned later (via scan_heap_roots()).
   // If initial_evacuation is set, this is called during the initial evacuation.
   void merge_heap_roots(bool initial_evacuation);
@@ -126,8 +122,7 @@ class G1RemSet: public CHeapObj<mtGC> {
   // Two methods for concurrent refinement support, executed concurrently to
   // the mutator:
   // Cleans the card at "*card_ptr_addr" before refinement, returns true iff the
-  // card needs later refinement. Note that "*card_ptr_addr" could be updated to
-  // a different card due to use of hot card cache.
+  // card needs later refinement.
   bool clean_card_before_refine(CardValue** const card_ptr_addr);
   // Refine the region corresponding to "card_ptr". Must be called after
   // being filtered by clean_card_before_refine(), and after proper
diff --git a/src/hotspot/share/gc/g1/g1YoungCollector.cpp b/src/hotspot/share/gc/g1/g1YoungCollector.cpp
index 37659776d1b..6a23ffe3cf5 100644
--- a/src/hotspot/share/gc/g1/g1YoungCollector.cpp
+++ b/src/hotspot/share/gc/g1/g1YoungCollector.cpp
@@ -36,7 +36,6 @@
 #include "gc/g1/g1YoungGCEvacFailureInjector.hpp"
 #include "gc/g1/g1EvacInfo.hpp"
 #include "gc/g1/g1HRPrinter.hpp"
-#include "gc/g1/g1HotCardCache.hpp"
 #include "gc/g1/g1MonitoringSupport.hpp"
 #include "gc/g1/g1ParScanThreadState.inline.hpp"
 #include "gc/g1/g1Policy.hpp"
@@ -202,10 +201,6 @@ G1GCPhaseTimes* G1YoungCollector::phase_times() const {
   return _g1h->phase_times();
 }
 
-G1HotCardCache* G1YoungCollector::hot_card_cache() const {
-  return _g1h->hot_card_cache();
-}
-
 G1HRPrinter* G1YoungCollector::hr_printer() const {
   return _g1h->hr_printer();
 }
@@ -520,8 +515,6 @@ void G1YoungCollector::pre_evacuate_collection_set(G1EvacInfo* evacuation_info)
 
   _g1h->gc_prologue(false);
 
-  hot_card_cache()->reset_hot_cache_claimed_index();
-
   // Initialize the GC alloc regions.
   allocator()->init_gc_alloc_regions(evacuation_info);
 
@@ -1022,9 +1015,7 @@ void G1YoungCollector::post_evacuate_collection_set(G1EvacInfo* evacuation_info,
 
   evacuation_info->set_bytes_used(_g1h->bytes_used_during_gc());
 
-  _g1h->start_new_collection_set();
-
-  _g1h->prepare_tlabs_for_mutator();
+  _g1h->prepare_for_mutator_after_young_collection();
 
   _g1h->gc_epilogue(false);
 
diff --git a/src/hotspot/share/gc/g1/g1YoungCollector.hpp b/src/hotspot/share/gc/g1/g1YoungCollector.hpp
index 6e482d155ef..c34e9e2752a 100644
--- a/src/hotspot/share/gc/g1/g1YoungCollector.hpp
+++ b/src/hotspot/share/gc/g1/g1YoungCollector.hpp
@@ -40,7 +40,6 @@ class G1ConcurrentMark;
 class G1EvacFailureRegions;
 class G1EvacInfo;
 class G1GCPhaseTimes;
-class G1HotCardCache;
 class G1HRPrinter;
 class G1MonitoringSupport;
 class G1MonotonicArenaMemoryStats;
@@ -69,7 +68,7 @@ class G1YoungCollector {
   G1ConcurrentMark* concurrent_mark() const;
   STWGCTimer* gc_timer_stw() const;
   G1NewTracer* gc_tracer_stw() const;
-  G1HotCardCache* hot_card_cache() const;
+
   G1HRPrinter* hr_printer() const;
   G1MonitoringSupport* monitoring_support() const;
   G1GCPhaseTimes* phase_times() const;
diff --git a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp
index 4ac32e91cb2..5ec9d4acffd 100644
--- a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp
+++ b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp
@@ -37,6 +37,8 @@
 #include "gc/g1/g1YoungGCPostEvacuateTasks.hpp"
 #include "gc/shared/preservedMarks.inline.hpp"
 #include "jfr/jfrEvents.hpp"
+#include "runtime/threads.hpp"
+#include "runtime/threadSMR.hpp"
 #include "utilities/ticks.hpp"
 
 class G1PostEvacuateCollectionSetCleanupTask1::MergePssTask : public G1AbstractSubTask {
@@ -237,14 +239,6 @@ class G1FreeHumongousRegionClosure : public HeapRegionIndexClosure {
   }
 };
 
-class G1PostEvacuateCollectionSetCleanupTask2::ResetHotCardCacheTask : public G1AbstractSubTask {
-public:
-  ResetHotCardCacheTask() : G1AbstractSubTask(G1GCPhaseTimes::ResetHotCardCache) { }
-
-  double worker_cost() const override { return 0.5; }
-  void do_work(uint worker_id) override { G1CollectedHeap::heap()->reset_hot_card_cache(); }
-};
-
 #if COMPILER2_OR_JVMCI
 class G1PostEvacuateCollectionSetCleanupTask2::UpdateDerivedPointersTask : public G1AbstractSubTask {
 public:
@@ -701,12 +695,36 @@ class G1PostEvacuateCollectionSetCleanupTask2::FreeCollectionSetTask : public G1
   }
 };
 
+class G1PostEvacuateCollectionSetCleanupTask2::ResizeTLABsTask : public G1AbstractSubTask {
+  G1JavaThreadsListClaimer _claimer;
+
+  // There is not much work per thread so the number of threads per worker is high.
+  static const uint ThreadsPerWorker = 250;
+
+public:
+  ResizeTLABsTask() : G1AbstractSubTask(G1GCPhaseTimes::ResizeThreadLABs), _claimer(ThreadsPerWorker) { }
+
+  void do_work(uint worker_id) override {
+    class ResizeClosure : public ThreadClosure {
+    public:
+
+      void do_thread(Thread* thread) {
+        static_cast<JavaThread*>(thread)->tlab().resize();
+      }
+    } cl;
+    _claimer.apply(&cl);
+  }
+
+  double worker_cost() const override {
+    return (double)_claimer.length() / ThreadsPerWorker;
+  }
+};
+
 G1PostEvacuateCollectionSetCleanupTask2::G1PostEvacuateCollectionSetCleanupTask2(G1ParScanThreadStateSet* per_thread_states,
                                                                                  G1EvacInfo* evacuation_info,
                                                                                  G1EvacFailureRegions* evac_failure_regions) :
   G1BatchedTask("Post Evacuate Cleanup 2", G1CollectedHeap::heap()->phase_times())
 {
-  add_serial_task(new ResetHotCardCacheTask());
 #if COMPILER2_OR_JVMCI
   add_serial_task(new UpdateDerivedPointersTask());
 #endif
@@ -722,6 +740,9 @@ G1PostEvacuateCollectionSetCleanupTask2::G1PostEvacuateCollectionSetCleanupTask2
     }
   }
   add_parallel_task(new RedirtyLoggedCardsTask(per_thread_states->rdcqs(), evac_failure_regions));
+  if (UseTLAB && ResizeTLAB) {
+    add_parallel_task(new ResizeTLABsTask());
+  }
   add_parallel_task(new FreeCollectionSetTask(evacuation_info,
                                               per_thread_states->surviving_young_words(),
                                               evac_failure_regions));
diff --git a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp
index c897059541d..c03550d1676 100644
--- a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp
+++ b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp
@@ -54,15 +54,14 @@ class G1PostEvacuateCollectionSetCleanupTask1 : public G1BatchedTask {
 
 // Second set of post evacuate collection set tasks containing (s means serial):
 // - Eagerly Reclaim Humongous Objects (s)
-// - Reset Hot Card Cache (s)
 // - Update Derived Pointers (s)
 // - Clear Retained Region Bitmaps (on evacuation failure)
 // - Redirty Logged Cards
 // - Restore Preserved Marks (on evacuation failure)
 // - Free Collection Set
+// - Resize TLABs
 class G1PostEvacuateCollectionSetCleanupTask2 : public G1BatchedTask {
   class EagerlyReclaimHumongousObjectsTask;
-  class ResetHotCardCacheTask;
 #if COMPILER2_OR_JVMCI
   class UpdateDerivedPointersTask;
 #endif
@@ -70,6 +69,7 @@ class G1PostEvacuateCollectionSetCleanupTask2 : public G1BatchedTask {
   class ClearRetainedRegionBitmaps;
   class RedirtyLoggedCardsTask;
   class RestorePreservedMarksTask;
+  class ResizeTLABsTask;
   class FreeCollectionSetTask;
 
 public:
diff --git a/src/hotspot/share/gc/g1/g1_globals.hpp b/src/hotspot/share/gc/g1/g1_globals.hpp
index f9cb6e69e6c..7f4f65dc931 100644
--- a/src/hotspot/share/gc/g1/g1_globals.hpp
+++ b/src/hotspot/share/gc/g1/g1_globals.hpp
@@ -178,14 +178,6 @@
           "Control whether concurrent refinement is performed. "            \
           "Disabling effectively ignores G1RSetUpdatingPauseTimePercent")   \
                                                                             \
-  product(size_t, G1ConcRSLogCacheSize, 10,                                 \
-          "Log base 2 of the length of conc RS hot-card cache.")            \
-          range(0, 27)                                                      \
-                                                                            \
-  product(uintx, G1ConcRSHotCardLimit, 4,                                   \
-          "The threshold that defines (>=) a hot card.")                    \
-          range(0, max_jubyte)                                              \
-                                                                            \
   develop(uint, G1RemSetArrayOfCardsEntriesBase, 8,                         \
           "Maximum number of entries per region in the Array of Cards "     \
           "card set container per MB of a heap region.")                    \
@@ -244,11 +236,6 @@
   develop(bool, G1VerifyCTCleanup, false,                                   \
           "Verify card table cleanup.")                                     \
                                                                             \
-  develop(uintx, G1DummyRegionsPerGC, 0,                                    \
-          "The number of dummy regions G1 will allocate at the end of "     \
-          "each evacuation pause in order to artificially fill up the "     \
-          "heap and stress the marking implementation.")                    \
-                                                                            \
   develop(bool, G1ExitOnExpansionFailure, false,                            \
           "Raise a fatal VM exit out of memory failure in the event "       \
           " that heap expansion fails due to running out of swap.")         \
diff --git a/src/hotspot/share/gc/g1/heapRegion.cpp b/src/hotspot/share/gc/g1/heapRegion.cpp
index dae37ae2be5..df0c5f718a6 100644
--- a/src/hotspot/share/gc/g1/heapRegion.cpp
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp
@@ -494,61 +494,54 @@ class G1VerificationClosure : public BasicOopIterateClosure {
 };
 
 class VerifyLiveClosure : public G1VerificationClosure {
-public:
-  VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
-  virtual void do_oop(narrowOop* p) { do_oop_work(p); }
-  virtual void do_oop(oop* p) { do_oop_work(p); }
 
   template <class T>
   void do_oop_work(T* p) {
     assert(_containing_obj != NULL, "Precondition");
     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
       "Precondition");
-    verify_liveness(p);
-  }
 
-  template <class T>
-  void verify_liveness(T* p) {
     T heap_oop = RawAccess<>::oop_load(p);
-    Log(gc, verify) log;
-    if (!CompressedOops::is_null(heap_oop)) {
-      oop obj = CompressedOops::decode_not_null(heap_oop);
-      bool failed = false;
-      bool is_in_heap = _g1h->is_in(obj);
-      if (!is_in_heap || _g1h->is_obj_dead_cond(obj, _vo)) {
-        MutexLocker x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
+    if (CompressedOops::is_null(heap_oop)) {
+      return;
+    }
 
-        if (!_failures) {
-          log.error("----------");
-        }
-        ResourceMark rm;
-        if (!is_in_heap) {
-          HeapRegion* from = _g1h->heap_region_containing(p);
-          log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
-                    p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
-          LogStream ls(log.error());
-          print_object(&ls, _containing_obj);
-          HeapRegion* const to = _g1h->heap_region_containing(obj);
-          log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT " remset %s",
-                    p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
-        } else {
-          HeapRegion* from = _g1h->heap_region_containing(p);
-          HeapRegion* to = _g1h->heap_region_containing(obj);
-          log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
-                    p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
-          LogStream ls(log.error());
-          print_object(&ls, _containing_obj);
-          log.error("points to dead obj " PTR_FORMAT " in region " HR_FORMAT,
-                    p2i(obj), HR_FORMAT_PARAMS(to));
-          print_object(&ls, obj);
-        }
+    oop obj = CompressedOops::decode_raw_not_null(heap_oop);
+    bool is_in_heap = _g1h->is_in(obj);
+    if (!is_in_heap || _g1h->is_obj_dead_cond(obj, _vo)) {
+      MutexLocker x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
+
+      Log(gc, verify) log;
+      if (!_failures) {
         log.error("----------");
-        _failures = true;
-        failed = true;
-        _n_failures++;
       }
+      ResourceMark rm;
+
+      HeapRegion* from = _g1h->heap_region_containing(p);
+      log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
+                p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
+      LogStream ls(log.error());
+      print_object(&ls, _containing_obj);
+
+      if (!is_in_heap) {
+        log.error("points to address " PTR_FORMAT " outside of heap", p2i(obj));
+      } else {
+        HeapRegion* to = _g1h->heap_region_containing(obj);
+        log.error("points to dead obj " PTR_FORMAT " in region " HR_FORMAT " remset %s",
+                  p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
+        print_object(&ls, obj);
+      }
+      log.error("----------");
+      _failures = true;
+      _n_failures++;
     }
   }
+
+public:
+  VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
+
+  virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+  virtual void do_oop(oop* p) { do_oop_work(p); }
 };
 
 class VerifyRemSetClosure : public G1VerificationClosure {
diff --git a/src/hotspot/share/gc/g1/heapRegionManager.cpp b/src/hotspot/share/gc/g1/heapRegionManager.cpp
index 913d2df5017..41421101e09 100644
--- a/src/hotspot/share/gc/g1/heapRegionManager.cpp
+++ b/src/hotspot/share/gc/g1/heapRegionManager.cpp
@@ -64,7 +64,6 @@ class MasterFreeRegionListChecker : public HeapRegionSetChecker {
 HeapRegionManager::HeapRegionManager() :
   _bot_mapper(NULL),
   _cardtable_mapper(NULL),
-  _card_counts_mapper(NULL),
   _committed_map(),
   _allocated_heapregions_length(0),
   _regions(), _heap_mapper(NULL),
@@ -75,8 +74,7 @@ HeapRegionManager::HeapRegionManager() :
 void HeapRegionManager::initialize(G1RegionToSpaceMapper* heap_storage,
                                    G1RegionToSpaceMapper* bitmap,
                                    G1RegionToSpaceMapper* bot,
-                                   G1RegionToSpaceMapper* cardtable,
-                                   G1RegionToSpaceMapper* card_counts) {
+                                   G1RegionToSpaceMapper* cardtable) {
   _allocated_heapregions_length = 0;
 
   _heap_mapper = heap_storage;
@@ -86,8 +84,6 @@ void HeapRegionManager::initialize(G1RegionToSpaceMapper* heap_storage,
   _bot_mapper = bot;
   _cardtable_mapper = cardtable;
 
-  _card_counts_mapper = card_counts;
-
   _regions.initialize(heap_storage->reserved(), HeapRegion::GrainBytes);
 
   _committed_map.initialize(reserved_length());
@@ -191,8 +187,6 @@ void HeapRegionManager::commit_regions(uint index, size_t num_regions, WorkerThr
 
   _bot_mapper->commit_regions(index, num_regions, pretouch_workers);
   _cardtable_mapper->commit_regions(index, num_regions, pretouch_workers);
-
-  _card_counts_mapper->commit_regions(index, num_regions, pretouch_workers);
 }
 
 void HeapRegionManager::uncommit_regions(uint start, uint num_regions) {
@@ -218,8 +212,6 @@ void HeapRegionManager::uncommit_regions(uint start, uint num_regions) {
   _bot_mapper->uncommit_regions(start, num_regions);
   _cardtable_mapper->uncommit_regions(start, num_regions);
 
-  _card_counts_mapper->uncommit_regions(start, num_regions);
-
   _committed_map.uncommit(start, end);
 }
 
@@ -271,22 +263,18 @@ void HeapRegionManager::clear_auxiliary_data_structures(uint start, uint num_reg
   _bot_mapper->signal_mapping_changed(start, num_regions);
   // Signal G1CardTable to clear the given regions.
   _cardtable_mapper->signal_mapping_changed(start, num_regions);
-  // Signal G1CardCounts to clear the given regions.
-  _card_counts_mapper->signal_mapping_changed(start, num_regions);
 }
 
 MemoryUsage HeapRegionManager::get_auxiliary_data_memory_usage() const {
   size_t used_sz =
     _bitmap_mapper->committed_size() +
     _bot_mapper->committed_size() +
-    _cardtable_mapper->committed_size() +
-    _card_counts_mapper->committed_size();
+    _cardtable_mapper->committed_size();
 
   size_t committed_sz =
     _bitmap_mapper->reserved_size() +
     _bot_mapper->reserved_size() +
-    _cardtable_mapper->reserved_size() +
-    _card_counts_mapper->reserved_size();
+    _cardtable_mapper->reserved_size();
 
   return MemoryUsage(0, used_sz, committed_sz, committed_sz);
 }
diff --git a/src/hotspot/share/gc/g1/heapRegionManager.hpp b/src/hotspot/share/gc/g1/heapRegionManager.hpp
index 39b6a68cbf3..79a6ae9a15e 100644
--- a/src/hotspot/share/gc/g1/heapRegionManager.hpp
+++ b/src/hotspot/share/gc/g1/heapRegionManager.hpp
@@ -76,7 +76,6 @@ class HeapRegionManager: public CHeapObj<mtGC> {
 
   G1RegionToSpaceMapper* _bot_mapper;
   G1RegionToSpaceMapper* _cardtable_mapper;
-  G1RegionToSpaceMapper* _card_counts_mapper;
 
   // Keeps track of the currently committed regions in the heap. The committed regions
   // can either be active (ready for use) or inactive (ready for uncommit).
@@ -163,8 +162,7 @@ class HeapRegionManager: public CHeapObj<mtGC> {
   void initialize(G1RegionToSpaceMapper* heap_storage,
                   G1RegionToSpaceMapper* bitmap,
                   G1RegionToSpaceMapper* bot,
-                  G1RegionToSpaceMapper* cardtable,
-                  G1RegionToSpaceMapper* card_counts);
+                  G1RegionToSpaceMapper* cardtable);
 
   // Return the "dummy" region used for G1AllocRegion. This is currently a hardwired
   // new HeapRegion that owns HeapRegion at index 0. Since at the moment we commit
diff --git a/src/hotspot/share/gc/parallel/psCardTable.hpp b/src/hotspot/share/gc/parallel/psCardTable.hpp
index 82fcbb4d765..6953c15d37c 100644
--- a/src/hotspot/share/gc/parallel/psCardTable.hpp
+++ b/src/hotspot/share/gc/parallel/psCardTable.hpp
@@ -81,7 +81,7 @@ class PSCardTable: public CardTable {
   static bool card_is_verify(int value)     { return value == verify_card; }
 
   // Card marking
-  void inline_write_ref_field_gc(void* field, oop new_val) {
+  void inline_write_ref_field_gc(void* field) {
     CardValue* byte = byte_for(field);
     *byte = youngergen_card;
   }
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
index 5c5fe19e830..f702bc48348 100644
--- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
@@ -317,7 +317,7 @@ inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) {
 
   if (!PSScavenge::is_obj_in_young((HeapWord*)p) &&
        PSScavenge::is_obj_in_young(new_obj)) {
-    PSScavenge::card_table()->inline_write_ref_field_gc(p, new_obj);
+    PSScavenge::card_table()->inline_write_ref_field_gc(p);
   }
 }
 
diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp
index 7bbc9976473..54de71c8709 100644
--- a/src/hotspot/share/gc/serial/defNewGeneration.cpp
+++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp
@@ -228,6 +228,10 @@ void DefNewGeneration::compute_space_boundaries(uintx minimum_eden_size,
   uintx size = _virtual_space.committed_size();
   uintx survivor_size = compute_survivor_size(size, SpaceAlignment);
   uintx eden_size = size - (2*survivor_size);
+  if (eden_size > max_eden_size()) {
+    eden_size = max_eden_size();
+    survivor_size = (size - eden_size)/2;
+  }
   assert(eden_size > 0 && survivor_size <= eden_size, "just checking");
 
   if (eden_size < minimum_eden_size) {
diff --git a/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp b/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp
index 5895652065f..ea94d13a1a5 100644
--- a/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp
+++ b/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -383,7 +383,7 @@ bool AdaptiveSizePolicy::print() const {
   }
 
   // Print goal for which action is needed.
-  char* action = NULL;
+  char* action = nullptr;
   bool change_for_pause = false;
   if ((change_old_gen_for_maj_pauses() ==
          decrease_old_gen_for_maj_pauses_true) ||
@@ -408,8 +408,8 @@ bool AdaptiveSizePolicy::print() const {
   // Pauses
   // Currently the size of the old gen is only adjusted to
   // change the major pause times.
-  char* young_gen_action = NULL;
-  char* tenured_gen_action = NULL;
+  char* young_gen_action = nullptr;
+  char* tenured_gen_action = nullptr;
 
   char* shrink_msg = (char*) "(attempted to shrink)";
   char* grow_msg = (char*) "(attempted to grow)";
diff --git a/src/hotspot/share/gc/shared/barrierSet.cpp b/src/hotspot/share/gc/shared/barrierSet.cpp
index 933d6449e23..c3a0c9cbbff 100644
--- a/src/hotspot/share/gc/shared/barrierSet.cpp
+++ b/src/hotspot/share/gc/shared/barrierSet.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,10 +32,10 @@
 #include "utilities/debug.hpp"
 #include "utilities/macros.hpp"
 
-BarrierSet* BarrierSet::_barrier_set = NULL;
+BarrierSet* BarrierSet::_barrier_set = nullptr;
 
 void BarrierSet::set_barrier_set(BarrierSet* barrier_set) {
-  assert(_barrier_set == NULL, "Already initialized");
+  assert(_barrier_set == nullptr, "Already initialized");
   _barrier_set = barrier_set;
 
   // Notify barrier set of the current (main) thread.  Normally the
@@ -53,7 +53,7 @@ void BarrierSet::set_barrier_set(BarrierSet* barrier_set) {
 }
 
 static BarrierSetNMethod* select_barrier_set_nmethod(BarrierSetNMethod* barrier_set_nmethod) {
-  if (barrier_set_nmethod != NULL) {
+  if (barrier_set_nmethod != nullptr) {
     // The GC needs nmethod entry barriers to do concurrent GC
     return barrier_set_nmethod;
   } else {
@@ -64,7 +64,7 @@ static BarrierSetNMethod* select_barrier_set_nmethod(BarrierSetNMethod* barrier_
 }
 
 static BarrierSetStackChunk* select_barrier_set_stack_chunk(BarrierSetStackChunk* barrier_set_stack_chunk) {
-  if (barrier_set_stack_chunk != NULL) {
+  if (barrier_set_stack_chunk != nullptr) {
     return barrier_set_stack_chunk;
   } else {
     return new BarrierSetStackChunk();
diff --git a/src/hotspot/share/gc/shared/barrierSet.hpp b/src/hotspot/share/gc/shared/barrierSet.hpp
index 51f14e935a2..e171316fdcc 100644
--- a/src/hotspot/share/gc/shared/barrierSet.hpp
+++ b/src/hotspot/share/gc/shared/barrierSet.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -106,17 +106,17 @@ class BarrierSet: public CHeapObj<mtGC> {
 
   template <class BarrierSetAssemblerT>
   static BarrierSetAssembler* make_barrier_set_assembler() {
-    return NOT_ZERO(new BarrierSetAssemblerT()) ZERO_ONLY(NULL);
+    return NOT_ZERO(new BarrierSetAssemblerT()) ZERO_ONLY(nullptr);
   }
 
   template <class BarrierSetC1T>
   static BarrierSetC1* make_barrier_set_c1() {
-    return COMPILER1_PRESENT(new BarrierSetC1T()) NOT_COMPILER1(NULL);
+    return COMPILER1_PRESENT(new BarrierSetC1T()) NOT_COMPILER1(nullptr);
   }
 
   template <class BarrierSetC2T>
   static BarrierSetC2* make_barrier_set_c2() {
-    return COMPILER2_PRESENT(new BarrierSetC2T()) NOT_COMPILER2(NULL);
+    return COMPILER2_PRESENT(new BarrierSetC2T()) NOT_COMPILER2(nullptr);
   }
 
 public:
@@ -150,17 +150,17 @@ class BarrierSet: public CHeapObj<mtGC> {
   static void set_barrier_set(BarrierSet* barrier_set);
 
   BarrierSetAssembler* barrier_set_assembler() {
-    assert(_barrier_set_assembler != NULL, "should be set");
+    assert(_barrier_set_assembler != nullptr, "should be set");
     return _barrier_set_assembler;
   }
 
   BarrierSetC1* barrier_set_c1() {
-    assert(_barrier_set_c1 != NULL, "should be set");
+    assert(_barrier_set_c1 != nullptr, "should be set");
     return _barrier_set_c1;
   }
 
   BarrierSetC2* barrier_set_c2() {
-    assert(_barrier_set_c2 != NULL, "should be set");
+    assert(_barrier_set_c2 != nullptr, "should be set");
     return _barrier_set_c2;
   }
 
@@ -169,7 +169,7 @@ class BarrierSet: public CHeapObj<mtGC> {
   }
 
   BarrierSetStackChunk* barrier_set_stack_chunk() {
-    assert(_barrier_set_stack_chunk != NULL, "should be set");
+    assert(_barrier_set_stack_chunk != nullptr, "should be set");
     return _barrier_set_stack_chunk;
   }
 
diff --git a/src/hotspot/share/gc/shared/barrierSet.inline.hpp b/src/hotspot/share/gc/shared/barrierSet.inline.hpp
index 032912d60b2..8b314bb5995 100644
--- a/src/hotspot/share/gc/shared/barrierSet.inline.hpp
+++ b/src/hotspot/share/gc/shared/barrierSet.inline.hpp
@@ -42,7 +42,7 @@ inline bool BarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy_in
 
   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
     // Covariant, copy without checks
-    return Raw::oop_arraycopy(NULL, 0, src, NULL, 0, dst, length);
+    return Raw::oop_arraycopy(nullptr, 0, src, nullptr, 0, dst, length);
   }
 
   // Copy each element with checking casts
diff --git a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp
index 2f80028bd27..e2faf30405d 100644
--- a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp
+++ b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -162,7 +162,7 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
   address return_address = *return_address_ptr;
   AARCH64_PORT_ONLY(return_address = pauth_strip_pointer(return_address));
   CodeBlob* cb = CodeCache::find_blob(return_address);
-  assert(cb != NULL, "invariant");
+  assert(cb != nullptr, "invariant");
 
   nmethod* nm = cb->as_nmethod();
   BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
diff --git a/src/hotspot/share/gc/shared/bufferNodeList.cpp b/src/hotspot/share/gc/shared/bufferNodeList.cpp
index bcf4b42ec96..4a527b3d642 100644
--- a/src/hotspot/share/gc/shared/bufferNodeList.cpp
+++ b/src/hotspot/share/gc/shared/bufferNodeList.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,13 @@
 #include "utilities/debug.hpp"
 
 BufferNodeList::BufferNodeList() :
-  _head(NULL), _tail(NULL), _entry_count(0) {}
+  _head(nullptr), _tail(nullptr), _entry_count(0) {}
 
 BufferNodeList::BufferNodeList(BufferNode* head,
                                BufferNode* tail,
                                size_t entry_count) :
   _head(head), _tail(tail), _entry_count(entry_count)
 {
-  assert((_head == NULL) == (_tail == NULL), "invariant");
-  assert((_head == NULL) == (_entry_count == 0), "invariant");
+  assert((_head == nullptr) == (_tail == nullptr), "invariant");
+  assert((_head == nullptr) == (_entry_count == 0), "invariant");
 }
diff --git a/src/hotspot/share/gc/shared/bufferNodeList.hpp b/src/hotspot/share/gc/shared/bufferNodeList.hpp
index ae66a1fcc71..55905ec071a 100644
--- a/src/hotspot/share/gc/shared/bufferNodeList.hpp
+++ b/src/hotspot/share/gc/shared/bufferNodeList.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,8 +30,8 @@
 class BufferNode;
 
 struct BufferNodeList {
-  BufferNode* _head;            // First node in list or NULL if empty.
-  BufferNode* _tail;            // Last node in list or NULL if empty.
+  BufferNode* _head;            // First node in list or null if empty.
+  BufferNode* _tail;            // Last node in list or null if empty.
   size_t _entry_count;          // Sum of entries in nodes in list.
 
   BufferNodeList();
diff --git a/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp b/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp
index b1828fcdb17..fbaef426b51 100644
--- a/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp
+++ b/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -224,7 +224,7 @@ void BarrierSetC1::generate_referent_check(LIRAccess& access, LabelObj* cont) {
   // We need to generate code similar to the following...
   //
   // if (offset == java_lang_ref_Reference::referent_offset()) {
-  //   if (src != NULL) {
+  //   if (src != nullptr) {
   //     if (klass(src)->reference_type() != REF_NONE) {
   //       pre_barrier(..., value, ...);
   //     }
@@ -269,7 +269,7 @@ void BarrierSetC1::generate_referent_check(LIRAccess& access, LabelObj* cont) {
     // We still need to continue with the checks.
     if (base.is_constant()) {
       ciObject* src_con = base.get_jobject_constant();
-      guarantee(src_con != NULL, "no source constant");
+      guarantee(src_con != nullptr, "no source constant");
 
       if (src_con->is_null_object()) {
         // The constant src object is null - We can skip
@@ -287,7 +287,7 @@ void BarrierSetC1::generate_referent_check(LIRAccess& access, LabelObj* cont) {
     // Can the klass of object be statically determined to be
     // a sub-class of Reference?
     ciType* type = base.value()->declared_type();
-    if ((type != NULL) && type->is_loaded()) {
+    if ((type != nullptr) && type->is_loaded()) {
       if (type->is_subtype_of(gen->compilation()->env()->Reference_klass())) {
         gen_type_check = false;
       } else if (type->is_klass() &&
@@ -327,14 +327,14 @@ void BarrierSetC1::generate_referent_check(LIRAccess& access, LabelObj* cont) {
     if (gen_source_check) {
       // offset is a const and equals referent offset
       // if (source == null) -> continue
-      __ cmp(lir_cond_equal, base_reg, LIR_OprFact::oopConst(NULL));
+      __ cmp(lir_cond_equal, base_reg, LIR_OprFact::oopConst(nullptr));
       __ branch(lir_cond_equal, cont->label());
     }
     LIR_Opr src_klass = gen->new_register(T_METADATA);
     if (gen_type_check) {
       // We have determined that offset == referent_offset && src != null.
       // if (src->_klass->_reference_type == REF_NONE) -> continue
-      gen->load_klass(base_reg, src_klass, NULL);
+      gen->load_klass(base_reg, src_klass, nullptr);
       LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
       LIR_Opr reference_type = gen->new_register(T_INT);
       __ move(reference_type_addr, reference_type);
diff --git a/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp b/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp
index bc0a9a7e57b..0fd6493d50e 100644
--- a/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp
+++ b/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,16 +42,16 @@ class LIRAddressOpr: public StackObj {
   LIR_Opr  _opr;
 public:
   LIRAddressOpr(LIRItem& item) : _item(&item), _opr() {}
-  LIRAddressOpr(LIR_Opr opr) : _item(NULL), _opr(opr) {}
+  LIRAddressOpr(LIR_Opr opr) : _item(nullptr), _opr(opr) {}
   LIRAddressOpr(const LIRAddressOpr& other) : _item(other._item), _opr(other._opr) {}
 
   LIRItem& item() const {
-    assert(_item != NULL, "sanity");
+    assert(_item != nullptr, "sanity");
     return *_item;
   }
 
   LIR_Opr opr() const {
-    if (_item == NULL) {
+    if (_item == nullptr) {
       return _opr;
     } else {
       return _item->result();
@@ -74,7 +74,7 @@ class LIRAccess: public StackObj {
 public:
   LIRAccess(LIRGenerator* gen, DecoratorSet decorators,
             LIRAddressOpr base, LIRAddressOpr offset, BasicType type,
-            CodeEmitInfo* patch_emit_info = NULL, CodeEmitInfo* access_emit_info = NULL) :
+            CodeEmitInfo* patch_emit_info = nullptr, CodeEmitInfo* access_emit_info = nullptr) :
     _gen(gen),
     _decorators(AccessInternal::decorator_fixup(decorators, type)),
     _base(base),
diff --git a/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp b/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp
index de3a26c1ed5..c2074c2859f 100644
--- a/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp
+++ b/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@ void ModRefBarrierSetC1::store_at_resolved(LIRAccess& access, LIR_Opr value) {
 LIR_Opr ModRefBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value) {
   if (access.is_oop()) {
     pre_barrier(access, access.resolved_addr(),
-                LIR_OprFact::illegalOpr /* pre_val */, NULL);
+                LIR_OprFact::illegalOpr /* pre_val */, nullptr);
   }
 
   LIR_Opr result = BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
@@ -69,7 +69,7 @@ LIR_Opr ModRefBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LIRIte
 LIR_Opr ModRefBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
   if (access.is_oop()) {
     pre_barrier(access, access.resolved_addr(),
-                LIR_OprFact::illegalOpr /* pre_val */, NULL);
+                LIR_OprFact::illegalOpr /* pre_val */, nullptr);
   }
 
   LIR_Opr result = BarrierSetC1::atomic_xchg_at_resolved(access, value);
diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp
index 69f89283f7d..90fae8c3588 100644
--- a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp
+++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,7 +99,8 @@ Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) cons
     }
 
     store = kit->store_to_memory(kit->control(), access.addr().node(), val.node(), bt,
-                                 access.addr().type(), mo, requires_atomic_access, unaligned, mismatched, unsafe);
+                                 access.addr().type(), mo, requires_atomic_access, unaligned,
+                                 mismatched, unsafe, access.barrier_data());
   } else {
     assert(access.is_opt_access(), "either parse or opt access");
     C2OptAccess& opt_access = static_cast<C2OptAccess&>(access);
@@ -117,6 +118,7 @@ Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) cons
     if (mismatched) {
       st->set_mismatched_access();
     }
+    st->set_barrier_data(access.barrier_data());
     store = gvn.transform(st);
     if (store == st) {
       mm->set_memory_at(alias, st);
@@ -148,7 +150,7 @@ Node* BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) con
   if (access.is_parse_access()) {
     C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
     GraphKit* kit = parse_access.kit();
-    Node* control = control_dependent ? kit->control() : NULL;
+    Node* control = control_dependent ? kit->control() : nullptr;
 
     if (immutable) {
       Compile* C = Compile::current();
@@ -165,7 +167,7 @@ Node* BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) con
   } else {
     assert(access.is_opt_access(), "either parse or opt access");
     C2OptAccess& opt_access = static_cast<C2OptAccess&>(access);
-    Node* control = control_dependent ? opt_access.ctl() : NULL;
+    Node* control = control_dependent ? opt_access.ctl() : nullptr;
     MergeMemNode* mm = opt_access.mem();
     PhaseGVN& gvn = opt_access.gvn();
     Node* mem = mm->memory_at(gvn.C->get_alias_index(adr_type));
@@ -184,8 +186,8 @@ class C2AccessFence: public StackObj {
 
 public:
   C2AccessFence(C2Access& access) :
-    _access(access), _leading_membar(NULL) {
-    GraphKit* kit = NULL;
+    _access(access), _leading_membar(nullptr) {
+    GraphKit* kit = nullptr;
     if (access.is_parse_access()) {
       C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
       kit = parse_access.kit();
@@ -200,7 +202,7 @@ class C2AccessFence: public StackObj {
     bool is_release = (decorators & MO_RELEASE) != 0;
 
     if (is_atomic) {
-      assert(kit != NULL, "unsupported at optimization time");
+      assert(kit != nullptr, "unsupported at optimization time");
       // Memory-model-wise, a LoadStore acts like a little synchronized
       // block, so needs barriers on each side.  These don't translate
       // into actual barriers on most machines, but we still need rest of
@@ -219,7 +221,7 @@ class C2AccessFence: public StackObj {
       // floating down past the volatile write.  Also prevents commoning
       // another volatile read.
       if (is_volatile || is_release) {
-        assert(kit != NULL, "unsupported at optimization time");
+        assert(kit != nullptr, "unsupported at optimization time");
         _leading_membar = kit->insert_mem_bar(Op_MemBarRelease);
       }
     } else {
@@ -229,13 +231,13 @@ class C2AccessFence: public StackObj {
       // so there's no problems making a strong assert about mixing users
       // of safe & unsafe memory.
       if (is_volatile && support_IRIW_for_not_multiple_copy_atomic_cpu) {
-        assert(kit != NULL, "unsupported at optimization time");
+        assert(kit != nullptr, "unsupported at optimization time");
         _leading_membar = kit->insert_mem_bar(Op_MemBarVolatile);
       }
     }
 
     if (access.needs_cpu_membar()) {
-      assert(kit != NULL, "unsupported at optimization time");
+      assert(kit != nullptr, "unsupported at optimization time");
       kit->insert_mem_bar(Op_MemBarCPUOrder);
     }
 
@@ -248,7 +250,7 @@ class C2AccessFence: public StackObj {
   }
 
   ~C2AccessFence() {
-    GraphKit* kit = NULL;
+    GraphKit* kit = nullptr;
     if (_access.is_parse_access()) {
       C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(_access);
       kit = parse_access.kit();
@@ -269,29 +271,29 @@ class C2AccessFence: public StackObj {
     }
 
     if (is_atomic) {
-      assert(kit != NULL, "unsupported at optimization time");
+      assert(kit != nullptr, "unsupported at optimization time");
       if (is_acquire || is_volatile) {
         Node* n = _access.raw_access();
         Node* mb = kit->insert_mem_bar(Op_MemBarAcquire, n);
-        if (_leading_membar != NULL) {
+        if (_leading_membar != nullptr) {
           MemBarNode::set_load_store_pair(_leading_membar->as_MemBar(), mb->as_MemBar());
         }
       }
     } else if (is_write) {
       // If not multiple copy atomic, we do the MemBarVolatile before the load.
       if (is_volatile && !support_IRIW_for_not_multiple_copy_atomic_cpu) {
-        assert(kit != NULL, "unsupported at optimization time");
+        assert(kit != nullptr, "unsupported at optimization time");
         Node* n = _access.raw_access();
         Node* mb = kit->insert_mem_bar(Op_MemBarVolatile, n); // Use fat membar
-        if (_leading_membar != NULL) {
+        if (_leading_membar != nullptr) {
           MemBarNode::set_store_pair(_leading_membar->as_MemBar(), mb->as_MemBar());
         }
       }
     } else {
       if (is_volatile || is_acquire) {
-        assert(kit != NULL, "unsupported at optimization time");
+        assert(kit != nullptr, "unsupported at optimization time");
         Node* n = _access.raw_access();
-        assert(_leading_membar == NULL || support_IRIW_for_not_multiple_copy_atomic_cpu, "no leading membar expected");
+        assert(_leading_membar == nullptr || support_IRIW_for_not_multiple_copy_atomic_cpu, "no leading membar expected");
         Node* mb = kit->insert_mem_bar(Op_MemBarAcquire, n);
         mb->as_MemBar()->set_trailing_load();
       }
@@ -388,7 +390,7 @@ void BarrierSetC2::pin_atomic_op(C2AtomicParseAccess& access) const {
   C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
   GraphKit* kit = parse_access.kit();
   Node* load_store = access.raw_access();
-  assert(load_store != NULL, "must pin atomic op");
+  assert(load_store != nullptr, "must pin atomic op");
   Node* proj = kit->gvn().transform(new SCMemProjNode(load_store));
   kit->set_memory(proj, access.alias_idx());
 }
@@ -407,7 +409,7 @@ Node* BarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access,
   Node* adr = access.addr().node();
   const TypePtr* adr_type = access.addr().type();
 
-  Node* load_store = NULL;
+  Node* load_store = nullptr;
 
   if (access.is_oop()) {
 #ifdef _LP64
@@ -465,7 +467,7 @@ Node* BarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access,
   MemNode::MemOrd mo = access.mem_node_mo();
   Node* mem = access.memory();
   bool is_weak_cas = (decorators & C2_WEAK_CMPXCHG) != 0;
-  Node* load_store = NULL;
+  Node* load_store = nullptr;
   Node* adr = access.addr().node();
 
   if (access.is_oop()) {
@@ -540,7 +542,7 @@ Node* BarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* n
   Node* mem = access.memory();
   Node* adr = access.addr().node();
   const TypePtr* adr_type = access.addr().type();
-  Node* load_store = NULL;
+  Node* load_store = nullptr;
 
   if (access.is_oop()) {
 #ifdef _LP64
@@ -587,7 +589,7 @@ Node* BarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* n
 }
 
 Node* BarrierSetC2::atomic_add_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const {
-  Node* load_store = NULL;
+  Node* load_store = nullptr;
   GraphKit* kit = access.kit();
   Node* adr = access.addr().node();
   const TypePtr* adr_type = access.addr().type();
@@ -767,7 +769,7 @@ void BarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac
   Node* payload_dst = phase->basic_plus_adr(dest, dest_offset);
 
   const char* copyfunc_name = "arraycopy";
-  address     copyfunc_addr = phase->basictype2arraycopy(T_LONG, NULL, NULL, true, copyfunc_name, true);
+  address     copyfunc_addr = phase->basictype2arraycopy(T_LONG, nullptr, nullptr, true, copyfunc_name, true);
 
   const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
   const TypeFunc* call_type = OptoRuntime::fast_arraycopy_Type();
diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
index 5c86dcc0c82..4fef0dcfb6f 100644
--- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
+++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
@@ -116,7 +116,7 @@ class C2Access: public StackObj {
     _type(type),
     _base(base),
     _addr(addr),
-    _raw_access(NULL),
+    _raw_access(nullptr),
     _barrier_data(0)
   {}
 
@@ -173,7 +173,7 @@ class C2AtomicParseAccess: public C2ParseAccess {
   C2AtomicParseAccess(GraphKit* kit, DecoratorSet decorators, BasicType type,
                  Node* base, C2AccessValuePtr& addr, uint alias_idx) :
     C2ParseAccess(kit, decorators, type, base, addr),
-    _memory(NULL),
+    _memory(nullptr),
     _alias_idx(alias_idx) {}
 
   // Set the memory node based on the current memory slice.
@@ -242,7 +242,7 @@ class BarrierSetC2: public CHeapObj<mtGC> {
                              Node*& fast_oop_ctrl, Node*& fast_oop_rawmem,
                              intx prefetch_lines) const;
 
-  virtual Node* ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const { return NULL; }
+  virtual Node* ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const { return nullptr; }
 
   // These are general helper methods used by C2
   enum ArrayCopyPhase {
@@ -270,7 +270,7 @@ class BarrierSetC2: public CHeapObj<mtGC> {
 
   // Allow barrier sets to have shared state that is preserved across a compilation unit.
   // This could for example comprise macro nodes to be expanded during macro expansion.
-  virtual void* create_barrier_state(Arena* comp_arena) const { return NULL; }
+  virtual void* create_barrier_state(Arena* comp_arena) const { return nullptr; }
   // If the BarrierSetC2 state has barrier nodes in its compilation
   // unit state to be expanded later, then now is the time to do so.
   virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const { return false; }
diff --git a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp
index 0a7a032c117..87bb9f3cd51 100644
--- a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp
+++ b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 Node* CardTableBarrierSetC2::byte_map_base_node(GraphKit* kit) const {
   // Get base of card map
   CardTable::CardValue* card_table_base = ci_card_table_address();
-   if (card_table_base != NULL) {
+   if (card_table_base != nullptr) {
      return kit->makecon(TypeRawPtr::make((address)card_table_base));
    } else {
      return kit->null();
@@ -58,8 +58,8 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit,
                                          Node* val,
                                          BasicType bt,
                                          bool use_precise) const {
-  // No store check needed if we're storing a NULL.
-  if (val != NULL && val->is_Con()) {
+  // No store check needed if we're storing a null.
+  if (val != nullptr && val->is_Con()) {
     const Type* t = val->bottom_type();
     if (t == TypePtr::NULL_PTR || t == Type::TOP) {
       return;
@@ -83,7 +83,7 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit,
     // Else it's an array (or unknown), and we want more precise card marks.
   }
 
-  assert(adr != NULL, "");
+  assert(adr != nullptr, "");
 
   IdealKit ideal(kit, true);
 
@@ -136,8 +136,8 @@ void CardTableBarrierSetC2::clone(GraphKit* kit, Node* src, Node* dst, Node* siz
     // Put in store barrier for any and all oops we are sticking
     // into this object.  (We could avoid this if we could prove
     // that the object type contains no oop fields at all.)
-    Node* no_particular_value = NULL;
-    Node* no_particular_field = NULL;
+    Node* no_particular_value = nullptr;
+    Node* no_particular_field = nullptr;
     int raw_adr_idx = Compile::AliasIdxRaw;
     post_barrier(kit, kit->control(),
                  kit->memory(raw_adr_type),
diff --git a/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp
index 5b83ceba477..a8a1fb58fce 100644
--- a/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp
+++ b/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@ Node* ModRefBarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val
   assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
 
   pre_barrier(kit, true /* do_load */, kit->control(), access.base(), adr, adr_idx, val.node(),
-              static_cast<const TypeOopPtr*>(val.type()), NULL /* pre_val */, access.type());
+              static_cast<const TypeOopPtr*>(val.type()), nullptr /* pre_val */, access.type());
   Node* store = BarrierSetC2::store_at_resolved(access, val);
   post_barrier(kit, kit->control(), access.raw_access(), access.base(), adr, adr_idx, val.node(),
                access.type(), use_precise);
@@ -71,7 +71,7 @@ Node* ModRefBarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& ac
   }
 
   pre_barrier(kit, false /* do_load */,
-              kit->control(), NULL, NULL, max_juint, NULL, NULL,
+              kit->control(), nullptr, nullptr, max_juint, nullptr, nullptr,
               expected_val /* pre_val */, T_OBJECT);
 
   Node* result = BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, value_type);
@@ -91,7 +91,7 @@ Node* ModRefBarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& a
   }
 
   pre_barrier(kit, false /* do_load */,
-              kit->control(), NULL, NULL, max_juint, NULL, NULL,
+              kit->control(), nullptr, nullptr, max_juint, nullptr, nullptr,
               expected_val /* pre_val */, T_OBJECT);
 
   Node* load_store = BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type);
@@ -130,7 +130,7 @@ Node* ModRefBarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, N
   // The pre_barrier can execute after the xchg as long as no safepoint
   // gets inserted between them.
   pre_barrier(kit, false /* do_load */,
-              kit->control(), NULL, NULL, max_juint, NULL, NULL,
+              kit->control(), nullptr, nullptr, max_juint, nullptr, nullptr,
               result /* pre_val */, T_OBJECT);
   post_barrier(kit, kit->control(), access.raw_access(), access.base(), access.addr().node(),
                access.alias_idx(), new_val, T_OBJECT, true);
diff --git a/src/hotspot/share/gc/shared/cardTable.cpp b/src/hotspot/share/gc/shared/cardTable.cpp
index 54067b55053..a0133d1ddd0 100644
--- a/src/hotspot/share/gc/shared/cardTable.cpp
+++ b/src/hotspot/share/gc/shared/cardTable.cpp
@@ -71,8 +71,8 @@ CardTable::CardTable(MemRegion whole_heap) :
   _whole_heap(whole_heap),
   _page_size(os::vm_page_size()),
   _byte_map_size(0),
-  _byte_map(NULL),
-  _byte_map_base(NULL),
+  _byte_map(nullptr),
+  _byte_map_base(nullptr),
   _cur_covered_regions(0),
   _covered(MemRegion::create_array(_max_covered_regions, mtGC)),
   _committed(MemRegion::create_array(_max_covered_regions, mtGC)),
@@ -157,7 +157,7 @@ int CardTable::find_covering_region_by_base(HeapWord* base) {
 }
 
 HeapWord* CardTable::largest_prev_committed_end(int ind) const {
-  HeapWord* max_end = NULL;
+  HeapWord* max_end = nullptr;
   for (int j = 0; j < ind; j++) {
     HeapWord* this_end = _committed[j].end();
     if (this_end > max_end) max_end = this_end;
diff --git a/src/hotspot/share/gc/shared/cardTable.hpp b/src/hotspot/share/gc/shared/cardTable.hpp
index 89a21a8e5bf..04f7ad4f379 100644
--- a/src/hotspot/share/gc/shared/cardTable.hpp
+++ b/src/hotspot/share/gc/shared/cardTable.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@ class CardTable: public CHeapObj<mtGC> {
   int find_covering_region_by_base(HeapWord* base);
 
   // Returns the leftmost end of a committed region corresponding to a
-  // covered region before covered region "ind", or else "NULL" if "ind" is
+  // covered region before covered region "ind", or else "null" if "ind" is
   // the first covered region.
   HeapWord* largest_prev_committed_end(int ind) const;
 
diff --git a/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp b/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp
index 43a70d82d42..feff87688fa 100644
--- a/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp
+++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp
@@ -80,7 +80,7 @@ class CardTableBarrierSet: public ModRefBarrierSet {
   // either precise or imprecise. We make non-virtual inline variants of
   // these functions here for performance.
   template <DecoratorSet decorators, typename T>
-  void write_ref_field_post(T* field, oop newVal);
+  void write_ref_field_post(T* field);
 
   virtual void invalidate(MemRegion mr);
 
diff --git a/src/hotspot/share/gc/shared/cardTableBarrierSet.inline.hpp b/src/hotspot/share/gc/shared/cardTableBarrierSet.inline.hpp
index aa12f97452b..dd0690d44fb 100644
--- a/src/hotspot/share/gc/shared/cardTableBarrierSet.inline.hpp
+++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.inline.hpp
@@ -31,7 +31,7 @@
 #include "runtime/atomic.hpp"
 
 template <DecoratorSet decorators, typename T>
-inline void CardTableBarrierSet::write_ref_field_post(T* field, oop newVal) {
+inline void CardTableBarrierSet::write_ref_field_post(T* field) {
   volatile CardValue* byte = _card_table->byte_for(field);
   *byte = CardTable::dirty_card_val();
 }
diff --git a/src/hotspot/share/gc/shared/cardTableRS.cpp b/src/hotspot/share/gc/shared/cardTableRS.cpp
index da7c586875e..bb51045236f 100644
--- a/src/hotspot/share/gc/shared/cardTableRS.cpp
+++ b/src/hotspot/share/gc/shared/cardTableRS.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -174,7 +174,7 @@ class VerifyCleanCardClosure: public BasicOopIterateClosure {
            "[_begin, _end) = [" PTR_FORMAT "," PTR_FORMAT ")",
            p2i(jp), p2i(_begin), p2i(_end));
     oop obj = RawAccess<>::oop_load(p);
-    guarantee(obj == NULL || cast_from_oop<HeapWord*>(obj) >= _boundary,
+    guarantee(obj == nullptr || cast_from_oop<HeapWord*>(obj) >= _boundary,
               "pointer " PTR_FORMAT " at " PTR_FORMAT " on "
               "clean card crosses boundary" PTR_FORMAT,
               p2i(obj), p2i(jp), p2i(_boundary));
diff --git a/src/hotspot/share/gc/shared/collectedHeap.cpp b/src/hotspot/share/gc/shared/collectedHeap.cpp
index e518ffac2a3..eeacc6c4570 100644
--- a/src/hotspot/share/gc/shared/collectedHeap.cpp
+++ b/src/hotspot/share/gc/shared/collectedHeap.cpp
@@ -61,7 +61,7 @@
 class ClassLoaderData;
 
 size_t CollectedHeap::_lab_alignment_reserve = ~(size_t)0;
-Klass* CollectedHeap::_filler_object_klass = NULL;
+Klass* CollectedHeap::_filler_object_klass = nullptr;
 size_t CollectedHeap::_filler_array_max_size = 0;
 size_t CollectedHeap::_stack_chunk_max_size = 0;
 
@@ -99,7 +99,7 @@ void GCHeapLog::log_heap(CollectedHeap* heap, bool before) {
   double timestamp = fetch_timestamp();
   MutexLocker ml(&_mutex, Mutex::_no_safepoint_check_flag);
   int index = compute_log_index();
-  _records[index].thread = NULL; // Its the GC thread so it's not that interesting.
+  _records[index].thread = nullptr; // Its the GC thread so it's not that interesting.
   _records[index].timestamp = timestamp;
   _records[index].data.is_before = before;
   stringStream st(_records[index].data.buffer(), _records[index].data.size());
@@ -161,7 +161,7 @@ void CollectedHeap::print_heap_before_gc() {
     print_on(&ls);
   }
 
-  if (_gc_heap_log != NULL) {
+  if (_gc_heap_log != nullptr) {
     _gc_heap_log->log_heap_before(this);
   }
 }
@@ -175,7 +175,7 @@ void CollectedHeap::print_heap_after_gc() {
     print_on(&ls);
   }
 
-  if (_gc_heap_log != NULL) {
+  if (_gc_heap_log != nullptr) {
     _gc_heap_log->log_heap_after(this);
   }
 }
@@ -188,7 +188,7 @@ void CollectedHeap::print_on_error(outputStream* st) const {
   st->cr();
 
   BarrierSet* bs = BarrierSet::barrier_set();
-  if (bs != NULL) {
+  if (bs != nullptr) {
     bs->print_on(st);
   }
 }
@@ -275,7 +275,7 @@ CollectedHeap::CollectedHeap() :
   if (LogEvents) {
     _gc_heap_log = new GCHeapLog();
   } else {
-    _gc_heap_log = NULL;
+    _gc_heap_log = nullptr;
   }
 }
 
@@ -298,7 +298,6 @@ void CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) {
       do_full_collection(false);        // don't clear all soft refs
       break;
     }
-    case GCCause::_archive_time_gc:
     case GCCause::_metadata_GC_clear_soft_refs: {
       HandleMark hm(thread);
       do_full_collection(true);         // do clear all soft refs
@@ -320,7 +319,7 @@ MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loa
 
   do {
     MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
-    if (result != NULL) {
+    if (result != nullptr) {
       return result;
     }
 
@@ -329,7 +328,7 @@ MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loa
       // If that does not succeed, wait if this thread is not
       // in a critical section itself.
       result = loader_data->metaspace_non_null()->expand_and_allocate(word_size, mdtype);
-      if (result != NULL) {
+      if (result != nullptr) {
         return result;
       }
       JavaThread* jthr = JavaThread::current();
@@ -346,7 +345,7 @@ MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loa
           fatal("Possible deadlock due to allocating while"
                 " in jni critical section");
         }
-        return NULL;
+        return nullptr;
       }
     }
 
@@ -520,7 +519,7 @@ HeapWord* CollectedHeap::allocate_new_tlab(size_t min_size,
                                            size_t requested_size,
                                            size_t* actual_size) {
   guarantee(false, "thread-local allocation buffers not supported");
-  return NULL;
+  return nullptr;
 }
 
 void CollectedHeap::ensure_parsability(bool retire_tlabs) {
@@ -563,7 +562,7 @@ void CollectedHeap::record_whole_heap_examined_timestamp() {
 }
 
 void CollectedHeap::full_gc_dump(GCTimer* timer, bool before) {
-  assert(timer != NULL, "timer is null");
+  assert(timer != nullptr, "timer is null");
   if ((HeapDumpBeforeFullGC && before) || (HeapDumpAfterFullGC && !before)) {
     GCTraceTime(Info, gc) tm(before ? "Heap Dump (before full gc)" : "Heap Dump (after full gc)", timer);
     HeapDumper::dump_heap();
diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp
index db9ac52f213..33aa32bb6d6 100644
--- a/src/hotspot/share/gc/shared/collectedHeap.hpp
+++ b/src/hotspot/share/gc/shared/collectedHeap.hpp
@@ -201,7 +201,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
   template<typename T>
   static T* named_heap(Name kind) {
     CollectedHeap* heap = Universe::heap();
-    assert(heap != NULL, "Uninitialized heap");
+    assert(heap != nullptr, "Uninitialized heap");
     assert(kind == heap->kind(), "Heap kind %u should be %u",
            static_cast<uint>(heap->kind()), static_cast<uint>(kind));
     return static_cast<T*>(heap);
@@ -278,7 +278,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
   // code.
   virtual bool is_in(const void* p) const = 0;
 
-  DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == NULL || is_in(p); })
+  DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == nullptr || is_in(p); })
 
   void set_gc_cause(GCCause::Cause v);
   GCCause::Cause gc_cause() { return _gc_cause; }
@@ -414,7 +414,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
 
  protected:
   virtual ParallelObjectIteratorImpl* parallel_object_iterator(uint thread_num) {
-    return NULL;
+    return nullptr;
   }
 
  public:
@@ -490,7 +490,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
   virtual bool supports_concurrent_gc_breakpoints() const;
 
   // Workers used in non-GC safepoints for parallel safepoint cleanup. If this
-  // method returns NULL, cleanup tasks are done serially in the VMThread. See
+  // method returns null, cleanup tasks are done serially in the VMThread. See
   // `SafepointSynchronize::do_cleanup_tasks` for details.
   // GCs using a GC worker thread pool inside GC safepoints may opt to share
   // that pool with non-GC safepoints, avoiding creating extraneous threads.
@@ -498,7 +498,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
   // overlap. For example, `G1CollectedHeap::workers()` (for GC safepoints) and
   // `G1CollectedHeap::safepoint_workers()` (for non-GC safepoints) return the
   // same thread-pool.
-  virtual WorkerThreads* safepoint_workers() { return NULL; }
+  virtual WorkerThreads* safepoint_workers() { return nullptr; }
 
   // Support for object pinning. This is used by JNI Get*Critical()
   // and Release*Critical() family of functions. The GC must guarantee
@@ -513,7 +513,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
   // Support for loading objects from CDS archive into the heap
   // (usually as a snapshot of the old generation).
   virtual bool can_load_archived_objects() const { return false; }
-  virtual HeapWord* allocate_loaded_archive_space(size_t size) { return NULL; }
+  virtual HeapWord* allocate_loaded_archive_space(size_t size) { return nullptr; }
   virtual void complete_loaded_archive_space(MemRegion archive_space) { }
 
   virtual bool is_oop(oop object) const;
diff --git a/src/hotspot/share/gc/shared/concurrentGCBreakpoints.cpp b/src/hotspot/share/gc/shared/concurrentGCBreakpoints.cpp
index ae821e46a85..9b0b4bd7b10 100644
--- a/src/hotspot/share/gc/shared/concurrentGCBreakpoints.cpp
+++ b/src/hotspot/share/gc/shared/concurrentGCBreakpoints.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,11 +34,11 @@
 
 // States:
 //                                 _run_to     _want_idle    _is_stopped
-// (1) No active request            NULL         false          false
-// (2) Active run_to() running     non-NULL      false          false
-// (3) Active run_to() in at()      NULL         false          true
-// (4) Active run_to_idle()         NULL         true           false
-const char* ConcurrentGCBreakpoints::_run_to = NULL;
+// (1) No active request            null         false          false
+// (2) Active run_to() running     non-null      false          false
+// (3) Active run_to() in at()      null         false          true
+// (4) Active run_to_idle()         null         true           false
+const char* ConcurrentGCBreakpoints::_run_to = nullptr;
 bool ConcurrentGCBreakpoints::_want_idle = false;
 bool ConcurrentGCBreakpoints::_is_stopped = false;
 
@@ -46,7 +46,7 @@ bool ConcurrentGCBreakpoints::_is_stopped = false;
 bool ConcurrentGCBreakpoints::_is_idle = true;
 
 void ConcurrentGCBreakpoints::reset_request_state() {
-  _run_to = NULL;
+  _run_to = nullptr;
   _want_idle = false;
   _is_stopped = false;
 }
@@ -57,7 +57,7 @@ Monitor* ConcurrentGCBreakpoints::monitor() {
 
 bool ConcurrentGCBreakpoints::is_controlled() {
   assert_locked_or_safepoint(monitor());
-  return _want_idle || _is_stopped || (_run_to != NULL);
+  return _want_idle || _is_stopped || (_run_to != nullptr);
 }
 
 #define assert_Java_thread() \
@@ -99,7 +99,7 @@ void ConcurrentGCBreakpoints::run_to_idle() {
 
 bool ConcurrentGCBreakpoints::run_to(const char* breakpoint) {
   assert_Java_thread();
-  assert(breakpoint != NULL, "precondition");
+  assert(breakpoint != nullptr, "precondition");
 
   MonitorLocker ml(monitor());
   assert(is_controlled(), "precondition");
@@ -132,18 +132,18 @@ bool ConcurrentGCBreakpoints::run_to(const char* breakpoint) {
 
 void ConcurrentGCBreakpoints::at(const char* breakpoint) {
   assert(Thread::current()->is_ConcurrentGC_thread(), "precondition");
-  assert(breakpoint != NULL, "precondition");
+  assert(breakpoint != nullptr, "precondition");
   MonitorLocker ml(monitor(), Mutex::_no_safepoint_check_flag);
 
   // Ignore non-matching request state.
-  if ((_run_to == NULL) || (strcmp(_run_to, breakpoint) != 0)) {
+  if ((_run_to == nullptr) || (strcmp(_run_to, breakpoint) != 0)) {
     log_trace(gc, breakpoint)("unmatched breakpoint %s", breakpoint);
     return;
   }
   log_trace(gc, breakpoint)("matched breakpoint %s", breakpoint);
 
   // Notify request.
-  _run_to = NULL;
+  _run_to = nullptr;
   _is_stopped = true;
   ml.notify_all();              // Wakeup waiting request.
   // Wait for request to be cancelled.
@@ -158,10 +158,10 @@ void ConcurrentGCBreakpoints::notify_active_to_idle() {
   assert(!_is_stopped, "invariant");
   // Notify pending run_to request of miss by replacing the run_to() request
   // with a run_to_idle() request.
-  if (_run_to != NULL) {
+  if (_run_to != nullptr) {
     log_debug(gc, breakpoint)
              ("Concurrent cycle completed without reaching breakpoint %s", _run_to);
-    _run_to = NULL;
+    _run_to = nullptr;
     _want_idle = true;
   }
   _is_idle = true;
diff --git a/src/hotspot/share/gc/shared/freeListAllocator.hpp b/src/hotspot/share/gc/shared/freeListAllocator.hpp
index a23c8750a3c..d8ab4c4e8bc 100644
--- a/src/hotspot/share/gc/shared/freeListAllocator.hpp
+++ b/src/hotspot/share/gc/shared/freeListAllocator.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,8 +74,8 @@ class FreeListAllocator {
   };
 
   struct NodeList {
-    FreeNode* _head;     // First node in list or nullptr if empty.
-    FreeNode* _tail;     // Last node in list or nullptr if empty.
+    FreeNode* _head;     // First node in list or null if empty.
+    FreeNode* _tail;     // Last node in list or null if empty.
     size_t _entry_count; // Sum of entries in nodes in list.
 
     NodeList();
diff --git a/src/hotspot/share/gc/shared/gcBehaviours.cpp b/src/hotspot/share/gc/shared/gcBehaviours.cpp
index 3b5136f74f0..76d28d1ab75 100644
--- a/src/hotspot/share/gc/shared/gcBehaviours.cpp
+++ b/src/hotspot/share/gc/shared/gcBehaviours.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 #include "code/nmethod.hpp"
 #include "gc/shared/gcBehaviours.hpp"
 
-IsUnloadingBehaviour* IsUnloadingBehaviour::_current = NULL;
+IsUnloadingBehaviour* IsUnloadingBehaviour::_current = nullptr;
 
 bool IsUnloadingBehaviour::is_unloading(CompiledMethod* cm) {
   if (cm->method()->can_be_allocated_in_NonNMethod_space()) {
@@ -53,7 +53,7 @@ class IsCompiledMethodUnloadingOopClosure: public OopClosure {
       return;
     }
     oop obj = *p;
-    if (obj == NULL) {
+    if (obj == nullptr) {
       return;
     }
     if (!_cl->do_object_b(obj)) {
diff --git a/src/hotspot/share/gc/shared/gcCause.cpp b/src/hotspot/share/gc/shared/gcCause.cpp
index dc5a83d5d00..426154fdca3 100644
--- a/src/hotspot/share/gc/shared/gcCause.cpp
+++ b/src/hotspot/share/gc/shared/gcCause.cpp
@@ -60,9 +60,6 @@ const char* GCCause::to_string(GCCause::Cause cause) {
     case _wb_breakpoint:
       return "WhiteBox Initiated Run to Breakpoint";
 
-    case _archive_time_gc:
-      return "Full GC for -Xshare:dump";
-
     case _no_gc:
       return "No GC";
 
diff --git a/src/hotspot/share/gc/shared/gcCause.hpp b/src/hotspot/share/gc/shared/gcCause.hpp
index 0b3225c524e..bf794fad9f5 100644
--- a/src/hotspot/share/gc/shared/gcCause.hpp
+++ b/src/hotspot/share/gc/shared/gcCause.hpp
@@ -53,7 +53,6 @@ class GCCause : public AllStatic {
     _wb_young_gc,
     _wb_full_gc,
     _wb_breakpoint,
-    _archive_time_gc,
 
     /* implementation independent, but reserved for GC use */
     _no_gc,
diff --git a/src/hotspot/share/gc/shared/gcConfig.cpp b/src/hotspot/share/gc/shared/gcConfig.cpp
index 0ed0a57f3fa..8eb265b54d9 100644
--- a/src/hotspot/share/gc/shared/gcConfig.cpp
+++ b/src/hotspot/share/gc/shared/gcConfig.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,7 +83,7 @@ SHENANDOAHGC_ONLY_ARG(IncludedGC(UseShenandoahGC,    CollectedHeap::Shenandoah,
     vm_exit_during_initialization("Option -XX:+" #option " not supported"); \
   }
 
-GCArguments* GCConfig::_arguments = NULL;
+GCArguments* GCConfig::_arguments = nullptr;
 bool GCConfig::_gc_selected_ergonomically = false;
 
 void GCConfig::fail_if_non_included_gc_is_selected() {
@@ -150,7 +150,7 @@ GCArguments* GCConfig::select_gc() {
     if (is_no_gc_selected()) {
       // Failed to select GC ergonomically
       vm_exit_during_initialization("Garbage collector not selected "
-                                    "(default collector explicitly disabled)", NULL);
+                                    "(default collector explicitly disabled)", nullptr);
     }
 
     // Succeeded to select GC ergonomically
@@ -159,7 +159,7 @@ GCArguments* GCConfig::select_gc() {
 
   if (!is_exactly_one_gc_selected()) {
     // More than one GC selected
-    vm_exit_during_initialization("Multiple garbage collectors selected", NULL);
+    vm_exit_during_initialization("Multiple garbage collectors selected", nullptr);
   }
 
   // Exactly one GC selected
@@ -171,11 +171,11 @@ GCArguments* GCConfig::select_gc() {
 
   fatal("Should have found the selected GC");
 
-  return NULL;
+  return nullptr;
 }
 
 void GCConfig::initialize() {
-  assert(_arguments == NULL, "Already initialized");
+  assert(_arguments == nullptr, "Already initialized");
   _arguments = select_gc();
 }
 
@@ -231,6 +231,6 @@ const char* GCConfig::hs_err_name(CollectedHeap::Name name) {
 }
 
 GCArguments* GCConfig::arguments() {
-  assert(_arguments != NULL, "Not initialized");
+  assert(_arguments != nullptr, "Not initialized");
   return _arguments;
 }
diff --git a/src/hotspot/share/gc/shared/gcHeapSummary.hpp b/src/hotspot/share/gc/shared/gcHeapSummary.hpp
index 6f72ec51b60..588dd3f6631 100644
--- a/src/hotspot/share/gc/shared/gcHeapSummary.hpp
+++ b/src/hotspot/share/gc/shared/gcHeapSummary.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@ class VirtualSpaceSummary : public StackObj {
   HeapWord* _reserved_end;
 public:
   VirtualSpaceSummary() :
-      _start(NULL), _committed_end(NULL), _reserved_end(NULL) { }
+      _start(nullptr), _committed_end(nullptr), _reserved_end(nullptr) { }
   VirtualSpaceSummary(HeapWord* start, HeapWord* committed_end, HeapWord* reserved_end) :
       _start(start), _committed_end(committed_end), _reserved_end(reserved_end) { }
 
@@ -52,7 +52,7 @@ class SpaceSummary : public StackObj {
   size_t    _used;
 public:
   SpaceSummary() :
-      _start(NULL), _end(NULL), _used(0) { }
+      _start(nullptr), _end(nullptr), _used(0) { }
   SpaceSummary(HeapWord* start, HeapWord* end, size_t used) :
       _start(start), _end(end), _used(used) { }
 
diff --git a/src/hotspot/share/gc/shared/gcId.cpp b/src/hotspot/share/gc/shared/gcId.cpp
index 08b5c6d3fb7..97f13a1304d 100644
--- a/src/hotspot/share/gc/shared/gcId.cpp
+++ b/src/hotspot/share/gc/shared/gcId.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@ uint GCId::current_or_undefined() {
 
 size_t GCId::print_prefix(char* buf, size_t len) {
   Thread* thread = Thread::current_or_null();
-  if (thread != NULL) {
+  if (thread != nullptr) {
     uint gc_id = current_or_undefined();
     if (gc_id != undefined()) {
       int ret = jio_snprintf(buf, len, "GC(%u) ", gc_id);
diff --git a/src/hotspot/share/gc/shared/gcLogPrecious.cpp b/src/hotspot/share/gc/shared/gcLogPrecious.cpp
index 7578343ed1f..afc42e7cfcc 100644
--- a/src/hotspot/share/gc/shared/gcLogPrecious.cpp
+++ b/src/hotspot/share/gc/shared/gcLogPrecious.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,9 +28,9 @@
 #include "runtime/os.hpp"
 #include "utilities/ostream.hpp"
 
-stringStream* GCLogPrecious::_lines = NULL;
-stringStream* GCLogPrecious::_temp = NULL;
-Mutex* GCLogPrecious::_lock = NULL;
+stringStream* GCLogPrecious::_lines = nullptr;
+stringStream* GCLogPrecious::_temp = nullptr;
+Mutex* GCLogPrecious::_lock = nullptr;
 
 void GCLogPrecious::initialize() {
   _lines = new (mtGC) stringStream();
@@ -79,7 +79,7 @@ void GCLogPrecious::vwrite_and_debug(LogTargetHandle log,
 void GCLogPrecious::print_on_error(outputStream* st) {
   st->print_cr("GC Precious Log:");
 
-  if (_lines == NULL) {
+  if (_lines == nullptr) {
     st->print_cr("<Not initialized>\n");
     return;
   }
diff --git a/src/hotspot/share/gc/shared/gcName.hpp b/src/hotspot/share/gc/shared/gcName.hpp
index 2648ce99612..ca40c642f3e 100644
--- a/src/hotspot/share/gc/shared/gcName.hpp
+++ b/src/hotspot/share/gc/shared/gcName.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@ class GCNameHelper {
       case Z: return "Z";
       case Shenandoah: return "Shenandoah";
       case NA: return "N/A";
-      default: ShouldNotReachHere(); return NULL;
+      default: ShouldNotReachHere(); return nullptr;
     }
   }
 };
diff --git a/src/hotspot/share/gc/shared/gcTimer.cpp b/src/hotspot/share/gc/shared/gcTimer.cpp
index 6d19686fee3..e293cb335a8 100644
--- a/src/hotspot/share/gc/shared/gcTimer.cpp
+++ b/src/hotspot/share/gc/shared/gcTimer.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -120,7 +120,7 @@ TimePartitions::TimePartitions() {
 
 TimePartitions::~TimePartitions() {
   delete _phases;
-  _phases = NULL;
+  _phases = nullptr;
 }
 
 void TimePartitions::clear() {
diff --git a/src/hotspot/share/gc/shared/gcTrace.cpp b/src/hotspot/share/gc/shared/gcTrace.cpp
index 19fc54956ec..3c8a69b3915 100644
--- a/src/hotspot/share/gc/shared/gcTrace.cpp
+++ b/src/hotspot/share/gc/shared/gcTrace.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,7 @@ class ObjectCountEventSenderClosure : public KlassInfoClosure {
 };
 
 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
-  assert(is_alive_cl != NULL, "Must supply function to check liveness");
+  assert(is_alive_cl != nullptr, "Must supply function to check liveness");
 
   if (ObjectCountEventSender::should_send_event()) {
     ResourceMark rm;
diff --git a/src/hotspot/share/gc/shared/gcTrace.hpp b/src/hotspot/share/gc/shared/gcTrace.hpp
index 58d9ee4581a..4cdeacb8806 100644
--- a/src/hotspot/share/gc/shared/gcTrace.hpp
+++ b/src/hotspot/share/gc/shared/gcTrace.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,7 @@ class SharedGCInfo {
 class ParallelOldGCInfo {
   void* _dense_prefix;
  public:
-  ParallelOldGCInfo() : _dense_prefix(NULL) {}
+  ParallelOldGCInfo() : _dense_prefix(nullptr) {}
   void report_dense_prefix(void* addr) {
     _dense_prefix = addr;
   }
diff --git a/src/hotspot/share/gc/shared/gcTraceTime.hpp b/src/hotspot/share/gc/shared/gcTraceTime.hpp
index 955f267ddef..390f6d1a87b 100644
--- a/src/hotspot/share/gc/shared/gcTraceTime.hpp
+++ b/src/hotspot/share/gc/shared/gcTraceTime.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,9 +75,9 @@ class GCTraceTimeDriver : public StackObj {
   void at_end(TimespanCallback* cb, Ticks end);
 
  public:
-  GCTraceTimeDriver(TimespanCallback* cb0 = NULL,
-                    TimespanCallback* cb1 = NULL,
-                    TimespanCallback* cb2 = NULL);
+  GCTraceTimeDriver(TimespanCallback* cb0 = nullptr,
+                    TimespanCallback* cb1 = nullptr,
+                    TimespanCallback* cb2 = nullptr);
   ~GCTraceTimeDriver();
 };
 
diff --git a/src/hotspot/share/gc/shared/gcTraceTime.inline.hpp b/src/hotspot/share/gc/shared/gcTraceTime.inline.hpp
index aa904b08f8e..388087c5557 100644
--- a/src/hotspot/share/gc/shared/gcTraceTime.inline.hpp
+++ b/src/hotspot/share/gc/shared/gcTraceTime.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,17 +64,17 @@ inline GCTraceTimeDriver::~GCTraceTimeDriver() {
 }
 
 inline bool GCTraceTimeDriver::has_callbacks() const {
-  return _cb0 != NULL || _cb1 != NULL || _cb2 != NULL;
+  return _cb0 != nullptr || _cb1 != nullptr || _cb2 != nullptr;
 }
 
 inline void GCTraceTimeDriver::at_start(TimespanCallback* cb, Ticks start) {
-  if (cb != NULL) {
+  if (cb != nullptr) {
     cb->at_start(start);
   }
 }
 
 inline void GCTraceTimeDriver::at_end(TimespanCallback* cb, Ticks end) {
-  if (cb != NULL) {
+  if (cb != nullptr) {
     cb->at_end(end);
   }
 }
@@ -113,14 +113,14 @@ inline bool GCTraceTimeLoggerImpl::is_enabled() const {
 inline GCTraceTimeTimer::GCTraceTimeTimer(const char* title, GCTimer* timer) : _title(title), _timer(timer) {}
 
 inline void GCTraceTimeTimer::at_start(Ticks start) {
-  if (_timer != NULL) {
+  if (_timer != nullptr) {
     _timer->register_gc_phase_start(_title, start);
   }
 
 }
 
 inline void GCTraceTimeTimer::at_end(Ticks end) {
-  if (_timer != NULL) {
+  if (_timer != nullptr) {
     _timer->register_gc_phase_end(end);
   }
 }
@@ -128,13 +128,13 @@ inline void GCTraceTimeTimer::at_end(Ticks end) {
 inline GCTraceTimePauseTimer::GCTraceTimePauseTimer(const char* title, GCTimer* timer) : _title(title), _timer(timer) {}
 
 inline void GCTraceTimePauseTimer::at_start(Ticks start) {
-  if (_timer != NULL) {
+  if (_timer != nullptr) {
     _timer->register_gc_pause_start(_title, start);
   }
 }
 
 inline void GCTraceTimePauseTimer::at_end(Ticks end) {
-  if (_timer != NULL) {
+  if (_timer != nullptr) {
     _timer->register_gc_pause_end(end);
   }
 }
@@ -153,8 +153,8 @@ inline GCTraceTimeImpl::GCTraceTimeImpl(
                 out_end),
         _timer(title, timer),
         // Only register the callbacks if they are enabled
-        _driver((_logger.is_enabled() ? &_logger : NULL),
-                (timer != NULL ? &_timer : NULL)) {}
+        _driver((_logger.is_enabled() ? &_logger : nullptr),
+                (timer != nullptr ? &_timer : nullptr)) {}
 
 // Figure out the first __NO_TAG position and replace it with 'start'.
 #define INJECT_START_TAG(T1, T2, T3, T4) \
@@ -186,7 +186,7 @@ class GCTraceTimeWrapper : public StackObj {
 public:
   GCTraceTimeWrapper(
       const char* title,
-      GCTimer* timer = NULL,
+      GCTimer* timer = nullptr,
       GCCause::Cause gc_cause = GCCause::_no_gc,
       bool log_heap_usage = false) :
           _impl(title,
diff --git a/src/hotspot/share/gc/shared/gcVMOperations.cpp b/src/hotspot/share/gc/shared/gcVMOperations.cpp
index c381ac58fe0..e39e590283a 100644
--- a/src/hotspot/share/gc/shared/gcVMOperations.cpp
+++ b/src/hotspot/share/gc/shared/gcVMOperations.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -177,9 +177,9 @@ void VM_GenCollectForAllocation::doit() {
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   GCCauseSetter gccs(gch, _gc_cause);
   _result = gch->satisfy_failed_allocation(_word_size, _tlab);
-  assert(_result == NULL || gch->is_in_reserved(_result), "result not in heap");
+  assert(_result == nullptr || gch->is_in_reserved(_result), "result not in heap");
 
-  if (_result == NULL && GCLocker::is_active_and_needs_gc()) {
+  if (_result == nullptr && GCLocker::is_active_and_needs_gc()) {
     set_gc_locked();
   }
 }
@@ -199,7 +199,7 @@ VM_CollectForMetadataAllocation::VM_CollectForMetadataAllocation(ClassLoaderData
                                                                  uint full_gc_count_before,
                                                                  GCCause::Cause gc_cause)
     : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true),
-      _result(NULL), _size(size), _mdtype(mdtype), _loader_data(loader_data) {
+      _result(nullptr), _size(size), _mdtype(mdtype), _loader_data(loader_data) {
   assert(_size != 0, "An allocation should always be requested with this operation.");
   AllocTracer::send_allocation_requiring_gc_event(_size * HeapWordSize, GCId::peek());
 }
@@ -215,7 +215,7 @@ void VM_CollectForMetadataAllocation::doit() {
   // a GC that freed space for the allocation.
   if (!MetadataAllocationFailALot) {
     _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype);
-    if (_result != NULL) {
+    if (_result != nullptr) {
       return;
     }
   }
@@ -225,7 +225,7 @@ void VM_CollectForMetadataAllocation::doit() {
     G1CollectedHeap::heap()->start_concurrent_gc_for_metadata_allocation(_gc_cause);
     // For G1 expand since the collection is going to be concurrent.
     _result = _loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype);
-    if (_result != NULL) {
+    if (_result != nullptr) {
       return;
     }
 
@@ -238,7 +238,7 @@ void VM_CollectForMetadataAllocation::doit() {
   // After a GC try to allocate without expanding.  Could fail
   // and expansion will be tried below.
   _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype);
-  if (_result != NULL) {
+  if (_result != nullptr) {
     return;
   }
 
@@ -248,14 +248,14 @@ void VM_CollectForMetadataAllocation::doit() {
   // This should work unless there really is no more space
   // or a MaxMetaspaceSize has been specified on the command line.
   _result = _loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype);
-  if (_result != NULL) {
+  if (_result != nullptr) {
     return;
   }
 
   // If expansion failed, do a collection clearing soft references.
   heap->collect_as_vm_thread(GCCause::_metadata_GC_clear_soft_refs);
   _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype);
-  if (_result != NULL) {
+  if (_result != nullptr) {
     return;
   }
 
@@ -267,7 +267,7 @@ void VM_CollectForMetadataAllocation::doit() {
 }
 
 VM_CollectForAllocation::VM_CollectForAllocation(size_t word_size, uint gc_count_before, GCCause::Cause cause)
-    : VM_GC_Operation(gc_count_before, cause), _word_size(word_size), _result(NULL) {
+    : VM_GC_Operation(gc_count_before, cause), _word_size(word_size), _result(nullptr) {
   // Only report if operation was really caused by an allocation.
   if (_word_size != 0) {
     AllocTracer::send_allocation_requiring_gc_event(_word_size * HeapWordSize, GCId::peek());
diff --git a/src/hotspot/share/gc/shared/gcVMOperations.hpp b/src/hotspot/share/gc/shared/gcVMOperations.hpp
index 4864d227e13..58aa76cb4ba 100644
--- a/src/hotspot/share/gc/shared/gcVMOperations.hpp
+++ b/src/hotspot/share/gc/shared/gcVMOperations.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -179,7 +179,7 @@ class VM_GC_HeapInspection: public VM_GC_Operation {
 class VM_CollectForAllocation : public VM_GC_Operation {
  protected:
   size_t    _word_size; // Size of object to be allocated (in number of words)
-  HeapWord* _result;    // Allocation result (NULL if allocation failed)
+  HeapWord* _result;    // Allocation result (null if allocation failed)
 
  public:
   VM_CollectForAllocation(size_t word_size, uint gc_count_before, GCCause::Cause cause);
diff --git a/src/hotspot/share/gc/shared/gcWhen.hpp b/src/hotspot/share/gc/shared/gcWhen.hpp
index 23e2ef6b229..22d6f76b54f 100644
--- a/src/hotspot/share/gc/shared/gcWhen.hpp
+++ b/src/hotspot/share/gc/shared/gcWhen.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@ class GCWhen : AllStatic {
     switch (when) {
     case BeforeGC: return "Before GC";
     case AfterGC:  return "After GC";
-    default: ShouldNotReachHere(); return NULL;
+    default: ShouldNotReachHere(); return nullptr;
     }
   }
 };
diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
index 5b34d3e5837..c002662e226 100644
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,8 +85,8 @@ GenCollectedHeap::GenCollectedHeap(Generation::Name young,
                                    Generation::Name old,
                                    const char* policy_counters_name) :
   CollectedHeap(),
-  _young_gen(NULL),
-  _old_gen(NULL),
+  _young_gen(nullptr),
+  _old_gen(nullptr),
   _young_gen_spec(new GenerationSpec(young,
                                      NewSize,
                                      MaxNewSize,
@@ -95,14 +95,14 @@ GenCollectedHeap::GenCollectedHeap(Generation::Name young,
                                    OldSize,
                                    MaxOldSize,
                                    GenAlignment)),
-  _rem_set(NULL),
+  _rem_set(nullptr),
   _soft_ref_gen_policy(),
-  _size_policy(NULL),
+  _size_policy(nullptr),
   _gc_policy_counters(new GCPolicyCounters(policy_counters_name, 2, 2)),
   _incremental_collection_failed(false),
   _full_collections_completed(0),
-  _young_manager(NULL),
-  _old_manager(NULL) {
+  _young_manager(nullptr),
+  _old_manager(nullptr) {
 }
 
 jint GenCollectedHeap::initialize() {
@@ -269,16 +269,16 @@ bool GenCollectedHeap::should_try_older_generation_allocation(size_t word_size)
 }
 
 HeapWord* GenCollectedHeap::expand_heap_and_allocate(size_t size, bool   is_tlab) {
-  HeapWord* result = NULL;
+  HeapWord* result = nullptr;
   if (_old_gen->should_allocate(size, is_tlab)) {
     result = _old_gen->expand_and_allocate(size, is_tlab);
   }
-  if (result == NULL) {
+  if (result == nullptr) {
     if (_young_gen->should_allocate(size, is_tlab)) {
       result = _young_gen->expand_and_allocate(size, is_tlab);
     }
   }
-  assert(result == NULL || is_in_reserved(result), "result not in heap");
+  assert(result == nullptr || is_in_reserved(result), "result not in heap");
   return result;
 }
 
@@ -290,7 +290,7 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
   // limit is being exceeded as checked below.
   *gc_overhead_limit_was_exceeded = false;
 
-  HeapWord* result = NULL;
+  HeapWord* result = nullptr;
 
   // Loop until the allocation is satisfied, or unsatisfied after GC.
   for (uint try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) {
@@ -299,7 +299,7 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
     Generation *young = _young_gen;
     if (young->should_allocate(size, is_tlab)) {
       result = young->par_allocate(size, is_tlab);
-      if (result != NULL) {
+      if (result != nullptr) {
         assert(is_in_reserved(result), "result not in heap");
         return result;
       }
@@ -313,26 +313,26 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
       bool first_only = !should_try_older_generation_allocation(size);
 
       result = attempt_allocation(size, is_tlab, first_only);
-      if (result != NULL) {
+      if (result != nullptr) {
         assert(is_in_reserved(result), "result not in heap");
         return result;
       }
 
       if (GCLocker::is_active_and_needs_gc()) {
         if (is_tlab) {
-          return NULL;  // Caller will retry allocating individual object.
+          return nullptr;  // Caller will retry allocating individual object.
         }
         if (!is_maximal_no_gc()) {
           // Try and expand heap to satisfy request.
           result = expand_heap_and_allocate(size, is_tlab);
           // Result could be null if we are out of space.
-          if (result != NULL) {
+          if (result != nullptr) {
             return result;
           }
         }
 
         if (gclocker_stalled_count > GCLockerRetryAllocationCount) {
-          return NULL; // We didn't get to do a GC and we didn't get any memory.
+          return nullptr; // We didn't get to do a GC and we didn't get any memory.
         }
 
         // If this thread is not in a jni critical section, we stall
@@ -353,7 +353,7 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
             fatal("Possible deadlock due to allocating while"
                   " in jni critical section");
           }
-          return NULL;
+          return nullptr;
         }
       }
 
@@ -366,13 +366,13 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
     if (op.prologue_succeeded()) {
       result = op.result();
       if (op.gc_locked()) {
-         assert(result == NULL, "must be NULL if gc_locked() is true");
+         assert(result == nullptr, "must be null if gc_locked() is true");
          continue;  // Retry and/or stall as necessary.
       }
 
       // Allocation has failed and a collection
       // has been done.  If the gc time limit was exceeded the
-      // this time, return NULL so that an out-of-memory
+      // this time, return null so that an out-of-memory
       // will be thrown.  Clear gc_overhead_limit_exceeded
       // so that the overhead exceeded does not persist.
 
@@ -382,12 +382,12 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
       if (limit_exceeded && softrefs_clear) {
         *gc_overhead_limit_was_exceeded = true;
         size_policy()->set_gc_overhead_limit_exceeded(false);
-        if (op.result() != NULL) {
+        if (op.result() != nullptr) {
           CollectedHeap::fill_with_object(op.result(), size);
         }
-        return NULL;
+        return nullptr;
       }
-      assert(result == NULL || is_in_reserved(result),
+      assert(result == nullptr || is_in_reserved(result),
              "result not in heap");
       return result;
     }
@@ -404,11 +404,11 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
 HeapWord* GenCollectedHeap::attempt_allocation(size_t size,
                                                bool is_tlab,
                                                bool first_only) {
-  HeapWord* res = NULL;
+  HeapWord* res = nullptr;
 
   if (_young_gen->should_allocate(size, is_tlab)) {
     res = _young_gen->allocate(size, is_tlab);
-    if (res != NULL || first_only) {
+    if (res != nullptr || first_only) {
       return res;
     }
   }
@@ -530,7 +530,7 @@ void GenCollectedHeap::do_collection(bool           full,
   if (do_young_collection) {
     GCIdMark gc_id_mark;
     GCTraceCPUTime tcpu(((DefNewGeneration*)_young_gen)->gc_tracer());
-    GCTraceTime(Info, gc) t("Pause Young", NULL, gc_cause(), true);
+    GCTraceTime(Info, gc) t("Pause Young", nullptr, gc_cause(), true);
 
     print_heap_before_gc();
 
@@ -580,7 +580,7 @@ void GenCollectedHeap::do_collection(bool           full,
   if (do_full_collection) {
     GCIdMark gc_id_mark;
     GCTraceCPUTime tcpu(GenMarkSweep::gc_tracer());
-    GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
+    GCTraceTime(Info, gc) t("Pause Full", nullptr, gc_cause(), true);
 
     print_heap_before_gc();
 
@@ -664,7 +664,7 @@ void GenCollectedHeap::prune_scavengable_nmethods() {
 
 HeapWord* GenCollectedHeap::satisfy_failed_allocation(size_t size, bool is_tlab) {
   GCCauseSetter x(this, GCCause::_allocation_failure);
-  HeapWord* result = NULL;
+  HeapWord* result = nullptr;
 
   assert(size != 0, "Precondition violated");
   if (GCLocker::is_active_and_needs_gc()) {
@@ -696,14 +696,14 @@ HeapWord* GenCollectedHeap::satisfy_failed_allocation(size_t size, bool is_tlab)
 
   result = attempt_allocation(size, is_tlab, false /*first_only*/);
 
-  if (result != NULL) {
+  if (result != nullptr) {
     assert(is_in_reserved(result), "result not in heap");
     return result;
   }
 
   // OK, collection failed, try expansion.
   result = expand_heap_and_allocate(size, is_tlab);
-  if (result != NULL) {
+  if (result != nullptr) {
     return result;
   }
 
@@ -723,7 +723,7 @@ HeapWord* GenCollectedHeap::satisfy_failed_allocation(size_t size, bool is_tlab)
   }
 
   result = attempt_allocation(size, is_tlab, false /* first_only */);
-  if (result != NULL) {
+  if (result != nullptr) {
     assert(is_in_reserved(result), "result not in heap");
     return result;
   }
@@ -735,7 +735,7 @@ HeapWord* GenCollectedHeap::satisfy_failed_allocation(size_t size, bool is_tlab)
   // space available is large enough for the allocation, then a more
   // complete compaction phase than we've tried so far might be
   // appropriate.
-  return NULL;
+  return nullptr;
 }
 
 #ifdef ASSERT
@@ -755,25 +755,25 @@ void GenCollectedHeap::process_roots(ScanningOption so,
                                      CLDClosure* weak_cld_closure,
                                      CodeBlobToOopClosure* code_roots) {
   // General roots.
-  assert(code_roots != NULL, "code root closure should always be set");
+  assert(code_roots != nullptr, "code root closure should always be set");
 
   ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure);
 
   // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway
-  CodeBlobToOopClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
+  CodeBlobToOopClosure* roots_from_code_p = (so & SO_AllCodeCache) ? nullptr : code_roots;
 
   Threads::oops_do(strong_roots, roots_from_code_p);
 
   OopStorageSet::strong_oops_do(strong_roots);
 
   if (so & SO_ScavengeCodeCache) {
-    assert(code_roots != NULL, "must supply closure for code cache");
+    assert(code_roots != nullptr, "must supply closure for code cache");
 
     // We only visit parts of the CodeCache when scavenging.
     ScavengableNMethods::nmethods_do(code_roots);
   }
   if (so & SO_AllCodeCache) {
-    assert(code_roots != NULL, "must supply closure for code cache");
+    assert(code_roots != nullptr, "must supply closure for code cache");
 
     // CMSCollector uses this to do intermediate-strength collections.
     // We scan the entire code cache, since CodeCache::do_unloading is not called.
@@ -871,9 +871,9 @@ bool GenCollectedHeap::is_in(const void* p) const {
 // Don't implement this by using is_in_young().  This method is used
 // in some cases to check that is_in_young() is correct.
 bool GenCollectedHeap::is_in_partial_collection(const void* p) {
-  assert(is_in_reserved(p) || p == NULL,
+  assert(is_in_reserved(p) || p == nullptr,
     "Does not work if address is non-null and outside of the heap");
-  return p < _young_gen->reserved().end() && p != NULL;
+  return p < _young_gen->reserved().end() && p != nullptr;
 }
 #endif
 
@@ -889,11 +889,11 @@ void GenCollectedHeap::object_iterate(ObjectClosure* cl) {
 
 Space* GenCollectedHeap::space_containing(const void* addr) const {
   Space* res = _young_gen->space_containing(addr);
-  if (res != NULL) {
+  if (res != nullptr) {
     return res;
   }
   res = _old_gen->space_containing(addr);
-  assert(res != NULL, "Could not find containing space");
+  assert(res != nullptr, "Could not find containing space");
   return res;
 }
 
@@ -945,14 +945,14 @@ HeapWord* GenCollectedHeap::allocate_new_tlab(size_t min_size,
   HeapWord* result = mem_allocate_work(requested_size /* size */,
                                        true /* is_tlab */,
                                        &gc_overhead_limit_was_exceeded);
-  if (result != NULL) {
+  if (result != nullptr) {
     *actual_size = requested_size;
   }
 
   return result;
 }
 
-// Requires "*prev_ptr" to be non-NULL.  Deletes and a block of minimal size
+// Requires "*prev_ptr" to be non-null.  Deletes and a block of minimal size
 // from the list headed by "*prev_ptr".
 static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
   bool first = true;
@@ -978,7 +978,7 @@ static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) {
 // Sort the scratch block list headed by res into decreasing size order,
 // and set "res" to the result.
 static void sort_scratch_list(ScratchBlock*& list) {
-  ScratchBlock* sorted = NULL;
+  ScratchBlock* sorted = nullptr;
   ScratchBlock* unsorted = list;
   while (unsorted) {
     ScratchBlock *smallest = removeSmallestScratch(&unsorted);
@@ -990,7 +990,7 @@ static void sort_scratch_list(ScratchBlock*& list) {
 
 ScratchBlock* GenCollectedHeap::gather_scratch(Generation* requestor,
                                                size_t max_alloc_words) {
-  ScratchBlock* res = NULL;
+  ScratchBlock* res = nullptr;
   _young_gen->contribute_scratch(res, requestor, max_alloc_words);
   _old_gen->contribute_scratch(res, requestor, max_alloc_words);
   sort_scratch_list(res);
@@ -1052,10 +1052,10 @@ void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
 }
 
 void GenCollectedHeap::print_on(outputStream* st) const {
-  if (_young_gen != NULL) {
+  if (_young_gen != nullptr) {
     _young_gen->print_on(st);
   }
-  if (_old_gen != NULL) {
+  if (_old_gen != nullptr) {
     _old_gen->print_on(st);
   }
   MetaspaceUtils::print_on(st);
diff --git a/src/hotspot/share/gc/shared/genOopClosures.hpp b/src/hotspot/share/gc/shared/genOopClosures.hpp
index 968ef3de047..33d4bb903e9 100644
--- a/src/hotspot/share/gc/shared/genOopClosures.hpp
+++ b/src/hotspot/share/gc/shared/genOopClosures.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,7 @@ class DefNewScanClosure : public FastScanClosure<DefNewScanClosure> {
   DefNewScanClosure(DefNewGeneration* g);
 
   void set_scanned_cld(ClassLoaderData* cld) {
-    assert(cld == NULL || _scanned_cld == NULL, "Must be");
+    assert(cld == nullptr || _scanned_cld == nullptr, "Must be");
     _scanned_cld = cld;
   }
 
diff --git a/src/hotspot/share/gc/shared/genOopClosures.inline.hpp b/src/hotspot/share/gc/shared/genOopClosures.inline.hpp
index a23525c589d..7d15701d2d0 100644
--- a/src/hotspot/share/gc/shared/genOopClosures.inline.hpp
+++ b/src/hotspot/share/gc/shared/genOopClosures.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,11 +89,11 @@ void DefNewYoungerGenClosure::barrier(T* p) {
 }
 
 inline DefNewScanClosure::DefNewScanClosure(DefNewGeneration* g) :
-    FastScanClosure<DefNewScanClosure>(g), _scanned_cld(NULL) {}
+    FastScanClosure<DefNewScanClosure>(g), _scanned_cld(nullptr) {}
 
 template <class T>
 void DefNewScanClosure::barrier(T* p) {
-  if (_scanned_cld != NULL && !_scanned_cld->has_modified_oops()) {
+  if (_scanned_cld != nullptr && !_scanned_cld->has_modified_oops()) {
     _scanned_cld->record_modified_oops();
   }
 }
diff --git a/src/hotspot/share/gc/shared/generation.cpp b/src/hotspot/share/gc/shared/generation.cpp
index e58605c72d5..3c0bccbf2cf 100644
--- a/src/hotspot/share/gc/shared/generation.cpp
+++ b/src/hotspot/share/gc/shared/generation.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,8 +43,8 @@
 #include "utilities/events.hpp"
 
 Generation::Generation(ReservedSpace rs, size_t initial_size) :
-  _gc_manager(NULL),
-  _ref_processor(NULL) {
+  _gc_manager(nullptr),
+  _ref_processor(nullptr) {
   if (!_virtual_space.initialize(rs, initial_size)) {
     vm_exit_during_initialization("Could not reserve enough space for "
                     "object heap");
@@ -74,7 +74,7 @@ size_t Generation::max_capacity() const {
 // By default we get a single threaded default reference processor;
 // generations needing multi-threaded refs processing or discovery override this method.
 void Generation::ref_processor_init() {
-  assert(_ref_processor == NULL, "a reference processor already exists");
+  assert(_ref_processor == nullptr, "a reference processor already exists");
   assert(!_reserved.is_empty(), "empty generation?");
   _span_based_discoverer.set_span(_reserved);
   _ref_processor = new ReferenceProcessor(&_span_based_discoverer);    // a vanilla reference processor
@@ -110,11 +110,11 @@ class GenerationIsInReservedClosure : public SpaceClosure {
   const void* _p;
   Space* sp;
   virtual void do_space(Space* s) {
-    if (sp == NULL) {
+    if (sp == nullptr) {
       if (s->is_in_reserved(_p)) sp = s;
     }
   }
-  GenerationIsInReservedClosure(const void* p) : _p(p), sp(NULL) {}
+  GenerationIsInReservedClosure(const void* p) : _p(p), sp(nullptr) {}
 };
 
 class GenerationIsInClosure : public SpaceClosure {
@@ -122,17 +122,17 @@ class GenerationIsInClosure : public SpaceClosure {
   const void* _p;
   Space* sp;
   virtual void do_space(Space* s) {
-    if (sp == NULL) {
+    if (sp == nullptr) {
       if (s->is_in(_p)) sp = s;
     }
   }
-  GenerationIsInClosure(const void* p) : _p(p), sp(NULL) {}
+  GenerationIsInClosure(const void* p) : _p(p), sp(nullptr) {}
 };
 
 bool Generation::is_in(const void* p) const {
   GenerationIsInClosure blk(p);
   ((Generation*)this)->space_iterate(&blk);
-  return blk.sp != NULL;
+  return blk.sp != nullptr;
 }
 
 size_t Generation::max_contiguous_available() const {
@@ -159,17 +159,17 @@ oop Generation::promote(oop obj, size_t obj_size) {
 
 #ifndef PRODUCT
   if (GenCollectedHeap::heap()->promotion_should_fail()) {
-    return NULL;
+    return nullptr;
   }
 #endif  // #ifndef PRODUCT
 
   // Allocate new object.
   HeapWord* result = allocate(obj_size, false);
-  if (result == NULL) {
+  if (result == nullptr) {
     // Promotion of obj into gen failed.  Try to expand and allocate.
     result = expand_and_allocate(obj_size, false);
-    if (result == NULL) {
-      return NULL;
+    if (result == nullptr) {
+      return nullptr;
     }
   }
 
@@ -198,11 +198,11 @@ class GenerationBlockStartClosure : public SpaceClosure {
   const void* _p;
   HeapWord* _start;
   virtual void do_space(Space* s) {
-    if (_start == NULL && s->is_in_reserved(_p)) {
+    if (_start == nullptr && s->is_in_reserved(_p)) {
       _start = s->block_start(_p);
     }
   }
-  GenerationBlockStartClosure(const void* p) { _p = p; _start = NULL; }
+  GenerationBlockStartClosure(const void* p) { _p = p; _start = nullptr; }
 };
 
 HeapWord* Generation::block_start(const void* p) const {
@@ -286,7 +286,7 @@ void Generation::object_iterate(ObjectClosure* cl) {
 void Generation::prepare_for_compaction(CompactPoint* cp) {
   // Generic implementation, can be specialized
   CompactibleSpace* space = first_compaction_space();
-  while (space != NULL) {
+  while (space != nullptr) {
     space->prepare_for_compaction(cp);
     space = space->next_compaction_space();
   }
@@ -308,7 +308,7 @@ void Generation::adjust_pointers() {
 
 void Generation::compact() {
   CompactibleSpace* sp = first_compaction_space();
-  while (sp != NULL) {
+  while (sp != nullptr) {
     sp->compact();
     sp = sp->next_compaction_space();
   }
diff --git a/src/hotspot/share/gc/shared/generation.hpp b/src/hotspot/share/gc/shared/generation.hpp
index 081f9f8343a..a1675196d2a 100644
--- a/src/hotspot/share/gc/shared/generation.hpp
+++ b/src/hotspot/share/gc/shared/generation.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -119,7 +119,7 @@ class Generation: public CHeapObj<mtGC> {
   // allocate and initialize ("weak") refs processing support
   void ref_processor_init();
   void set_ref_processor(ReferenceProcessor* rp) {
-    assert(_ref_processor == NULL, "clobbering existing _ref_processor");
+    assert(_ref_processor == nullptr, "clobbering existing _ref_processor");
     _ref_processor = rp;
   }
 
@@ -194,14 +194,14 @@ class Generation: public CHeapObj<mtGC> {
   }
 
   // If some space in the generation contains the given "addr", return a
-  // pointer to that space, else return "NULL".
+  // pointer to that space, else return "null".
   virtual Space* space_containing(const void* addr) const;
 
   // Iteration - do not use for time critical operations
   virtual void space_iterate(SpaceClosure* blk, bool usedOnly = false) = 0;
 
   // Returns the first space, if any, in the generation that can participate
-  // in compaction, or else "NULL".
+  // in compaction, or else "null".
   virtual CompactibleSpace* first_compaction_space() const = 0;
 
   // Returns "true" iff this generation should be used to allocate an
@@ -218,7 +218,7 @@ class Generation: public CHeapObj<mtGC> {
     return result;
   }
 
-  // Allocate and returns a block of the requested size, or returns "NULL".
+  // Allocate and returns a block of the requested size, or returns "null".
   // Assumes the caller has done any necessary locking.
   virtual HeapWord* allocate(size_t word_size, bool is_tlab) = 0;
 
@@ -242,7 +242,7 @@ class Generation: public CHeapObj<mtGC> {
 
   // "obj" is the address of an object in a younger generation.  Allocate space
   // for "obj" in the current (or some higher) generation, and copy "obj" into
-  // the newly allocated space, if possible, returning the result (or NULL if
+  // the newly allocated space, if possible, returning the result (or null if
   // the allocation failed).
   //
   // The "obj_size" argument is just obj->size(), passed along so the caller can
@@ -288,7 +288,7 @@ class Generation: public CHeapObj<mtGC> {
   // space to support an allocation of the given "word_size".  If
   // successful, perform the allocation and return the resulting
   // "oop" (initializing the allocated block). If the allocation is
-  // still unsuccessful, return "NULL".
+  // still unsuccessful, return "null".
   virtual HeapWord* expand_and_allocate(size_t word_size, bool is_tlab) = 0;
 
   // Some generations may require some cleanup or preparation actions before
@@ -420,7 +420,7 @@ class Generation: public CHeapObj<mtGC> {
   virtual CollectorCounters* counters() { return _gc_counters; }
 
   GCMemoryManager* gc_manager() const {
-    assert(_gc_manager != NULL, "not initialized yet");
+    assert(_gc_manager != nullptr, "not initialized yet");
     return _gc_manager;
   }
 
diff --git a/src/hotspot/share/gc/shared/generationCounters.cpp b/src/hotspot/share/gc/shared/generationCounters.cpp
index 47e47c070e6..05460ea8898 100644
--- a/src/hotspot/share/gc/shared/generationCounters.cpp
+++ b/src/hotspot/share/gc/shared/generationCounters.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@ GenerationCounters::GenerationCounters(const char* name,
                                        size_t min_capacity, size_t max_capacity,
                                        VirtualSpace* v)
   : _virtual_space(v) {
-  assert(v != NULL, "don't call this constructor if v == NULL");
+  assert(v != nullptr, "don't call this constructor if v == nullptr");
   initialize(name, ordinal, spaces,
              min_capacity, max_capacity, v->committed_size());
 }
@@ -76,7 +76,7 @@ GenerationCounters::GenerationCounters(const char* name,
                                        int ordinal, int spaces,
                                        size_t min_capacity, size_t max_capacity,
                                        size_t curr_capacity)
-  : _virtual_space(NULL) {
+  : _virtual_space(nullptr) {
   initialize(name, ordinal, spaces, min_capacity, max_capacity, curr_capacity);
 }
 
@@ -85,6 +85,6 @@ GenerationCounters::~GenerationCounters() {
 }
 
 void GenerationCounters::update_all() {
-  assert(_virtual_space != NULL, "otherwise, override this method");
+  assert(_virtual_space != nullptr, "otherwise, override this method");
   _current_size->set_value(_virtual_space->committed_size());
 }
diff --git a/src/hotspot/share/gc/shared/generationCounters.hpp b/src/hotspot/share/gc/shared/generationCounters.hpp
index 1e491f45637..292ea61d46d 100644
--- a/src/hotspot/share/gc/shared/generationCounters.hpp
+++ b/src/hotspot/share/gc/shared/generationCounters.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@ class GenerationCounters: public CHeapObj<mtGC> {
   // constructor. The need for such an constructor should be eliminated
   // when VirtualSpace and PSVirtualSpace are unified.
   GenerationCounters()
-             : _current_size(NULL), _virtual_space(NULL), _name_space(NULL) {}
+             : _current_size(nullptr), _virtual_space(nullptr), _name_space(nullptr) {}
 
   // This constructor is used for subclasses that do not have a space
   // associated with them (e.g, in G1).
diff --git a/src/hotspot/share/gc/shared/generationSpec.cpp b/src/hotspot/share/gc/shared/generationSpec.cpp
index b6ca7e24f09..34e93bfe6f2 100644
--- a/src/hotspot/share/gc/shared/generationSpec.cpp
+++ b/src/hotspot/share/gc/shared/generationSpec.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,6 @@ Generation* GenerationSpec::init(ReservedSpace rs, CardTableRS* remset) {
 
     default:
       guarantee(false, "unrecognized GenerationName");
-      return NULL;
+      return nullptr;
   }
 }
diff --git a/src/hotspot/share/gc/shared/locationPrinter.inline.hpp b/src/hotspot/share/gc/shared/locationPrinter.inline.hpp
index faf11af9e5c..d368aa1c6c6 100644
--- a/src/hotspot/share/gc/shared/locationPrinter.inline.hpp
+++ b/src/hotspot/share/gc/shared/locationPrinter.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,14 +39,14 @@ oop BlockLocationPrinter<CollectedHeapT>::base_oop_or_null(void* addr) {
 
   // Try to find addr using block_start.
   HeapWord* p = CollectedHeapT::heap()->block_start(addr);
-  if (p != NULL && CollectedHeapT::heap()->block_is_obj(p)) {
+  if (p != nullptr && CollectedHeapT::heap()->block_is_obj(p)) {
     if (!is_valid_obj(p)) {
-      return NULL;
+      return nullptr;
     }
     return cast_to_oop(p);
   }
 
-  return NULL;
+  return nullptr;
 }
 
 template <typename CollectedHeapT>
@@ -54,7 +54,7 @@ bool BlockLocationPrinter<CollectedHeapT>::print_location(outputStream* st, void
   // Check if addr points into Java heap.
   if (CollectedHeapT::heap()->is_in(addr)) {
     oop o = base_oop_or_null(addr);
-    if (o != NULL) {
+    if (o != nullptr) {
       if ((void*)o == addr) {
         st->print(PTR_FORMAT " is an oop: ", p2i(addr));
       } else {
diff --git a/src/hotspot/share/gc/shared/markBitMap.hpp b/src/hotspot/share/gc/shared/markBitMap.hpp
index c900cb800da..adfd9307813 100644
--- a/src/hotspot/share/gc/shared/markBitMap.hpp
+++ b/src/hotspot/share/gc/shared/markBitMap.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -79,8 +79,8 @@ class MarkBitMap {
   }
 
   // Return the address corresponding to the next marked bit at or after
-  // "addr", and before "limit", if "limit" is non-NULL.  If there is no
-  // such bit, returns "limit" if that is non-NULL, or else "endWord()".
+  // "addr", and before "limit", if "limit" is non-null.  If there is no
+  // such bit, returns "limit" if that is non-null, or else "endWord()".
   inline HeapWord* get_next_marked_addr(const HeapWord* addr,
                                         HeapWord* limit) const;
 
diff --git a/src/hotspot/share/gc/shared/markBitMap.inline.hpp b/src/hotspot/share/gc/shared/markBitMap.inline.hpp
index c251b2322eb..8a2217f79b8 100644
--- a/src/hotspot/share/gc/shared/markBitMap.inline.hpp
+++ b/src/hotspot/share/gc/shared/markBitMap.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 
 inline HeapWord* MarkBitMap::get_next_marked_addr(const HeapWord* const addr,
                                                   HeapWord* const limit) const {
-  assert(limit != NULL, "limit must not be NULL");
+  assert(limit != nullptr, "limit must not be null");
   // Round addr up to a possible object boundary to be safe.
   size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter));
   size_t const limit_offset = addr_to_offset(limit);
diff --git a/src/hotspot/share/gc/shared/memAllocator.cpp b/src/hotspot/share/gc/shared/memAllocator.cpp
index d4ab96f2c3d..475a3b2925b 100644
--- a/src/hotspot/share/gc/shared/memAllocator.cpp
+++ b/src/hotspot/share/gc/shared/memAllocator.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -102,7 +102,7 @@ class MemAllocator::Allocation::PreserveObj: StackObj {
       _handle(thread, *obj_ptr),
       _obj_ptr(obj_ptr)
   {
-    *obj_ptr = NULL;
+    *obj_ptr = nullptr;
   }
 
   ~PreserveObj() {
@@ -118,7 +118,7 @@ bool MemAllocator::Allocation::check_out_of_memory() {
   JavaThread* THREAD = _thread; // For exception macros.
   assert(!HAS_PENDING_EXCEPTION, "Unexpected exception, will result in uninitialized storage");
 
-  if (obj() != NULL) {
+  if (obj() != nullptr) {
     return false;
   }
 
@@ -240,7 +240,7 @@ void MemAllocator::Allocation::notify_allocation_dtrace_sampler(JavaThread* thre
     // support for Dtrace object alloc event (no-op most of the time)
     Klass* klass = obj()->klass();
     size_t word_size = _allocator._word_size;
-    if (klass != NULL && klass->name() != NULL) {
+    if (klass != nullptr && klass->name() != nullptr) {
       SharedRuntime::dtrace_object_alloc(thread, obj(), word_size);
     }
   }
@@ -256,7 +256,7 @@ void MemAllocator::Allocation::notify_allocation(JavaThread* thread) {
 HeapWord* MemAllocator::mem_allocate_outside_tlab(Allocation& allocation) const {
   allocation._allocated_outside_tlab = true;
   HeapWord* mem = Universe::heap()->mem_allocate(_word_size, &allocation._overhead_limit_exceeded);
-  if (mem == NULL) {
+  if (mem == nullptr) {
     return mem;
   }
 
@@ -272,7 +272,7 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab(Allocation& allocation) const {
 
   // Try allocating from an existing TLAB.
   HeapWord* mem = mem_allocate_inside_tlab_fast();
-  if (mem != NULL) {
+  if (mem != nullptr) {
     return mem;
   }
 
@@ -285,7 +285,7 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab_fast() const {
 }
 
 HeapWord* MemAllocator::mem_allocate_inside_tlab_slow(Allocation& allocation) const {
-  HeapWord* mem = NULL;
+  HeapWord* mem = nullptr;
   ThreadLocalAllocBuffer& tlab = _thread->tlab();
 
   if (JvmtiExport::should_post_sampled_object_alloc()) {
@@ -296,7 +296,7 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab_slow(Allocation& allocation) co
     // when done.
     allocation._tlab_end_reset_for_sample = true;
 
-    if (mem != NULL) {
+    if (mem != nullptr) {
       return mem;
     }
   }
@@ -305,7 +305,7 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab_slow(Allocation& allocation) co
   // the amount free in the tlab is too large to discard.
   if (tlab.free() > tlab.refill_waste_limit()) {
     tlab.record_slow_allocation(_word_size);
-    return NULL;
+    return nullptr;
   }
 
   // Discard tlab and allocate a new one.
@@ -315,19 +315,19 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab_slow(Allocation& allocation) co
   tlab.retire_before_allocation();
 
   if (new_tlab_size == 0) {
-    return NULL;
+    return nullptr;
   }
 
   // Allocate a new TLAB requesting new_tlab_size. Any size
   // between minimal and new_tlab_size is accepted.
   size_t min_tlab_size = ThreadLocalAllocBuffer::compute_min_size(_word_size);
   mem = Universe::heap()->allocate_new_tlab(min_tlab_size, new_tlab_size, &allocation._allocated_tlab_size);
-  if (mem == NULL) {
+  if (mem == nullptr) {
     assert(allocation._allocated_tlab_size == 0,
            "Allocation failed, but actual size was updated. min: " SIZE_FORMAT
            ", desired: " SIZE_FORMAT ", actual: " SIZE_FORMAT,
            min_tlab_size, new_tlab_size, allocation._allocated_tlab_size);
-    return NULL;
+    return nullptr;
   }
   assert(allocation._allocated_tlab_size != 0, "Allocation succeeded but actual size not updated. mem at: "
          PTR_FORMAT " min: " SIZE_FORMAT ", desired: " SIZE_FORMAT,
@@ -359,7 +359,7 @@ HeapWord* MemAllocator::mem_allocate_slow(Allocation& allocation) const {
   if (UseTLAB) {
     // Try refilling the TLAB and allocating the object in it.
     HeapWord* mem = mem_allocate_inside_tlab_slow(allocation);
-    if (mem != NULL) {
+    if (mem != nullptr) {
       return mem;
     }
   }
@@ -371,7 +371,7 @@ HeapWord* MemAllocator::mem_allocate(Allocation& allocation) const {
   if (UseTLAB) {
     // Try allocating from an existing TLAB.
     HeapWord* mem = mem_allocate_inside_tlab_fast();
-    if (mem != NULL) {
+    if (mem != nullptr) {
       return mem;
     }
   }
@@ -380,23 +380,23 @@ HeapWord* MemAllocator::mem_allocate(Allocation& allocation) const {
 }
 
 oop MemAllocator::allocate() const {
-  oop obj = NULL;
+  oop obj = nullptr;
   {
     Allocation allocation(*this, &obj);
     HeapWord* mem = mem_allocate(allocation);
-    if (mem != NULL) {
+    if (mem != nullptr) {
       obj = initialize(mem);
     } else {
       // The unhandled oop detector will poison local variable obj,
-      // so reset it to NULL if mem is NULL.
-      obj = NULL;
+      // so reset it to null if mem is null.
+      obj = nullptr;
     }
   }
   return obj;
 }
 
 void MemAllocator::mem_clear(HeapWord* mem) const {
-  assert(mem != NULL, "cannot initialize NULL object");
+  assert(mem != nullptr, "cannot initialize null object");
   const size_t hs = oopDesc::header_size();
   assert(_word_size >= hs, "unexpected object size");
   oopDesc::set_klass_gap(mem, 0);
@@ -404,11 +404,11 @@ void MemAllocator::mem_clear(HeapWord* mem) const {
 }
 
 oop MemAllocator::finish(HeapWord* mem) const {
-  assert(mem != NULL, "NULL object pointer");
+  assert(mem != nullptr, "null object pointer");
   // May be bootstrapping
   oopDesc::set_mark(mem, markWord::prototype());
   // Need a release store to ensure array/class length, mark word, and
-  // object zeroing are visible before setting the klass non-NULL, for
+  // object zeroing are visible before setting the klass non-null, for
   // concurrent collectors.
   oopDesc::release_set_klass(mem, _klass);
   return cast_to_oop(mem);
@@ -430,7 +430,7 @@ MemRegion ObjArrayAllocator::obj_memory_range(oop obj) const {
 
 oop ObjArrayAllocator::initialize(HeapWord* mem) const {
   // Set array length before setting the _klass field because a
-  // non-NULL klass field indicates that the object is parsable by
+  // non-null klass field indicates that the object is parsable by
   // concurrent GC.
   assert(_length >= 0, "length should be non-negative");
   if (_do_zero) {
@@ -442,7 +442,7 @@ oop ObjArrayAllocator::initialize(HeapWord* mem) const {
 
 oop ClassAllocator::initialize(HeapWord* mem) const {
   // Set oop_size field before setting the _klass field because a
-  // non-NULL _klass field indicates that the object is parsable by
+  // non-null _klass field indicates that the object is parsable by
   // concurrent GC.
   assert(_word_size > 0, "oop_size must be positive.");
   mem_clear(mem);
diff --git a/src/hotspot/share/gc/shared/modRefBarrierSet.hpp b/src/hotspot/share/gc/shared/modRefBarrierSet.hpp
index 4424e1c6bdd..4eca9154660 100644
--- a/src/hotspot/share/gc/shared/modRefBarrierSet.hpp
+++ b/src/hotspot/share/gc/shared/modRefBarrierSet.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,8 @@ class ModRefBarrierSet: public BarrierSet {
     : BarrierSet(barrier_set_assembler,
                  barrier_set_c1,
                  barrier_set_c2,
-                 NULL /* barrier_set_nmethod */,
-                 NULL /* barrier_set_stack_chunk */,
+                 nullptr /* barrier_set_nmethod */,
+                 nullptr /* barrier_set_stack_chunk */,
                  fake_rtti.add_tag(BarrierSet::ModRef)) { }
   ~ModRefBarrierSet() { }
 
@@ -49,7 +49,7 @@ class ModRefBarrierSet: public BarrierSet {
   inline void write_ref_field_pre(T* addr) {}
 
   template <DecoratorSet decorators, typename T>
-  inline void write_ref_field_post(T *addr, oop new_value) {}
+  inline void write_ref_field_post(T *addr) {}
 
   // Causes all refs in "mr" to be assumed to be modified.
   virtual void invalidate(MemRegion mr) = 0;
diff --git a/src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp b/src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp
index 411817c3b04..8034d3bda9f 100644
--- a/src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp
+++ b/src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,7 +63,7 @@ oop_store_in_heap(T* addr, oop value) {
   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
   bs->template write_ref_field_pre<decorators>(addr);
   Raw::oop_store(addr, value);
-  bs->template write_ref_field_post<decorators>(addr, value);
+  bs->template write_ref_field_post<decorators>(addr);
 }
 
 template <DecoratorSet decorators, typename BarrierSetT>
@@ -74,7 +74,7 @@ oop_atomic_cmpxchg_in_heap(T* addr, oop compare_value, oop new_value) {
   bs->template write_ref_field_pre<decorators>(addr);
   oop result = Raw::oop_atomic_cmpxchg(addr, compare_value, new_value);
   if (result == compare_value) {
-    bs->template write_ref_field_post<decorators>(addr, new_value);
+    bs->template write_ref_field_post<decorators>(addr);
   }
   return result;
 }
@@ -86,7 +86,7 @@ oop_atomic_xchg_in_heap(T* addr, oop new_value) {
   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
   bs->template write_ref_field_pre<decorators>(addr);
   oop result = Raw::oop_atomic_xchg(addr, new_value);
-  bs->template write_ref_field_post<decorators>(addr, new_value);
+  bs->template write_ref_field_post<decorators>(addr);
   return result;
 }
 
@@ -105,10 +105,10 @@ oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
     // Optimized covariant case
     bs->write_ref_array_pre(dst_raw, length,
                             HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value);
-    Raw::oop_arraycopy(NULL, 0, src_raw, NULL, 0, dst_raw, length);
+    Raw::oop_arraycopy(nullptr, 0, src_raw, nullptr, 0, dst_raw, length);
     bs->write_ref_array((HeapWord*)dst_raw, length);
   } else {
-    assert(dst_obj != NULL, "better have an actual oop");
+    assert(dst_obj != nullptr, "better have an actual oop");
     Klass* bound = objArrayOop(dst_obj)->element_klass();
     T* from = const_cast<T*>(src_raw);
     T* end = from + length;
diff --git a/src/hotspot/share/gc/shared/oopStorage.cpp b/src/hotspot/share/gc/shared/oopStorage.cpp
index a541657497c..87b0293b73e 100644
--- a/src/hotspot/share/gc/shared/oopStorage.cpp
+++ b/src/hotspot/share/gc/shared/oopStorage.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,25 +49,25 @@
 #include "utilities/population_count.hpp"
 #include "utilities/powerOfTwo.hpp"
 
-OopStorage::AllocationListEntry::AllocationListEntry() : _prev(NULL), _next(NULL) {}
+OopStorage::AllocationListEntry::AllocationListEntry() : _prev(nullptr), _next(nullptr) {}
 
 OopStorage::AllocationListEntry::~AllocationListEntry() {
-  assert(_prev == NULL, "deleting attached block");
-  assert(_next == NULL, "deleting attached block");
+  assert(_prev == nullptr, "deleting attached block");
+  assert(_next == nullptr, "deleting attached block");
 }
 
-OopStorage::AllocationList::AllocationList() : _head(NULL), _tail(NULL) {}
+OopStorage::AllocationList::AllocationList() : _head(nullptr), _tail(nullptr) {}
 
 OopStorage::AllocationList::~AllocationList() {
   // ~OopStorage() empties its lists before destroying them.
-  assert(_head == NULL, "deleting non-empty block list");
-  assert(_tail == NULL, "deleting non-empty block list");
+  assert(_head == nullptr, "deleting non-empty block list");
+  assert(_tail == nullptr, "deleting non-empty block list");
 }
 
 void OopStorage::AllocationList::push_front(const Block& block) {
   const Block* old = _head;
-  if (old == NULL) {
-    assert(_tail == NULL, "invariant");
+  if (old == nullptr) {
+    assert(_tail == nullptr, "invariant");
     _head = _tail = &block;
   } else {
     block.allocation_list_entry()._next = old;
@@ -78,8 +78,8 @@ void OopStorage::AllocationList::push_front(const Block& block) {
 
 void OopStorage::AllocationList::push_back(const Block& block) {
   const Block* old = _tail;
-  if (old == NULL) {
-    assert(_head == NULL, "invariant");
+  if (old == nullptr) {
+    assert(_head == nullptr, "invariant");
     _head = _tail = &block;
   } else {
     old->allocation_list_entry()._next = &block;
@@ -92,19 +92,19 @@ void OopStorage::AllocationList::unlink(const Block& block) {
   const AllocationListEntry& block_entry = block.allocation_list_entry();
   const Block* prev_blk = block_entry._prev;
   const Block* next_blk = block_entry._next;
-  block_entry._prev = NULL;
-  block_entry._next = NULL;
-  if ((prev_blk == NULL) && (next_blk == NULL)) {
+  block_entry._prev = nullptr;
+  block_entry._next = nullptr;
+  if ((prev_blk == nullptr) && (next_blk == nullptr)) {
     assert(_head == &block, "invariant");
     assert(_tail == &block, "invariant");
-    _head = _tail = NULL;
-  } else if (prev_blk == NULL) {
+    _head = _tail = nullptr;
+  } else if (prev_blk == nullptr) {
     assert(_head == &block, "invariant");
-    next_blk->allocation_list_entry()._prev = NULL;
+    next_blk->allocation_list_entry()._prev = nullptr;
     _head = next_blk;
-  } else if (next_blk == NULL) {
+  } else if (next_blk == nullptr) {
     assert(_tail == &block, "invariant");
-    prev_blk->allocation_list_entry()._next = NULL;
+    prev_blk->allocation_list_entry()._next = nullptr;
     _tail = prev_blk;
   } else {
     next_blk->allocation_list_entry()._prev = prev_blk;
@@ -113,7 +113,7 @@ void OopStorage::AllocationList::unlink(const Block& block) {
 }
 
 bool OopStorage::AllocationList::contains(const Block& block) const {
-  return (next(block) != NULL) || (ctail() == &block);
+  return (next(block) != nullptr) || (ctail() == &block);
 }
 
 OopStorage::ActiveArray::ActiveArray(size_t size) :
@@ -131,7 +131,7 @@ OopStorage::ActiveArray* OopStorage::ActiveArray::create(size_t size,
                                                          AllocFailType alloc_fail) {
   size_t size_in_bytes = blocks_offset() + sizeof(Block*) * size;
   void* mem = NEW_C_HEAP_ARRAY3(char, size_in_bytes, memflags, CURRENT_PC, alloc_fail);
-  if (mem == NULL) return NULL;
+  if (mem == nullptr) return nullptr;
   return new (mem) ActiveArray(size);
 }
 
@@ -221,19 +221,19 @@ OopStorage::Block::Block(const OopStorage* owner, void* memory) :
   _memory(memory),
   _active_index(0),
   _allocation_list_entry(),
-  _deferred_updates_next(NULL),
+  _deferred_updates_next(nullptr),
   _release_refcount(0)
 {
   STATIC_ASSERT(_data_pos == 0);
   STATIC_ASSERT(section_size * section_count == ARRAY_SIZE(_data));
   assert(offset_of(Block, _data) == _data_pos, "invariant");
-  assert(owner != NULL, "NULL owner");
+  assert(owner != nullptr, "null owner");
   assert(is_aligned(this, block_alignment), "misaligned block");
 }
 
 OopStorage::Block::~Block() {
   assert(_release_refcount == 0, "deleting block while releasing");
-  assert(_deferred_updates_next == NULL, "deleting block with deferred update");
+  assert(_deferred_updates_next == nullptr, "deleting block with deferred update");
   // Clear fields used by block_for_ptr and entry validation, which
   // might help catch bugs.  Volatile to prevent dead-store elimination.
   const_cast<uintx volatile&>(_allocated_bitmask) = 0;
@@ -274,7 +274,7 @@ bool OopStorage::Block::is_safe_to_delete() const {
   assert(is_empty(), "precondition");
   OrderAccess::loadload();
   return (Atomic::load_acquire(&_release_refcount) == 0) &&
-         (Atomic::load_acquire(&_deferred_updates_next) == NULL);
+         (Atomic::load_acquire(&_deferred_updates_next) == nullptr);
 }
 
 OopStorage::Block* OopStorage::Block::deferred_updates_next() const {
@@ -344,8 +344,8 @@ OopStorage::Block* OopStorage::Block::new_block(const OopStorage* owner) {
   STATIC_ASSERT(_data_pos == 0);
   size_t size_needed = allocation_size();
   void* memory = NEW_C_HEAP_ARRAY_RETURN_NULL(char, size_needed, owner->memflags());
-  if (memory == NULL) {
-    return NULL;
+  if (memory == nullptr) {
+    return nullptr;
   }
   void* block_mem = align_up(memory, block_alignment);
   assert(sizeof(Block) + pointer_delta(block_mem, memory, 1) <= size_needed,
@@ -375,7 +375,7 @@ OopStorage::Block::block_for_ptr(const OopStorage* owner, const oop* ptr) {
   // Walk up through the potential block start positions, looking for
   // the owner in the expected location.  If we're below the actual block
   // start position, the value at the owner position will be some oop
-  // (possibly NULL), which can never match the owner.
+  // (possibly null), which can never match the owner.
   intptr_t owner_addr = reinterpret_cast<intptr_t>(owner);
   for (unsigned i = 0; i < section_count; ++i, section += section_size) {
     Block* candidate = reinterpret_cast<Block*>(section);
@@ -383,7 +383,7 @@ OopStorage::Block::block_for_ptr(const OopStorage* owner, const oop* ptr) {
       return candidate;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -437,14 +437,14 @@ oop* OopStorage::allocate() {
   MutexLocker ml(_allocation_mutex, Mutex::_no_safepoint_check_flag);
 
   Block* block = block_for_allocation();
-  if (block == NULL) return NULL; // Block allocation failed.
+  if (block == nullptr) return nullptr; // Block allocation failed.
   assert(!block->is_full(), "invariant");
   if (block->is_empty()) {
     // Transitioning from empty to not empty.
     log_block_transition(block, "not empty");
   }
   oop* result = block->allocate();
-  assert(result != NULL, "allocation failed");
+  assert(result != nullptr, "allocation failed");
   assert(!block->is_empty(), "postcondition");
   Atomic::inc(&_allocation_count); // release updates outside lock.
   if (block->is_full()) {
@@ -472,7 +472,7 @@ size_t OopStorage::allocate(oop** ptrs, size_t size) {
   {
     MutexLocker ml(_allocation_mutex, Mutex::_no_safepoint_check_flag);
     block = block_for_allocation();
-    if (block == NULL) return 0; // Block allocation failed.
+    if (block == nullptr) return 0; // Block allocation failed.
     // Taking all remaining entries, so remove from list.
     _allocation_list.unlink(*block);
     // Transitioning from empty to not empty.
@@ -518,7 +518,7 @@ bool OopStorage::try_add_block() {
     MutexUnlocker ul(_allocation_mutex, Mutex::_no_safepoint_check_flag);
     block = Block::new_block(this);
   }
-  if (block == NULL) return false;
+  if (block == nullptr) return false;
 
   // Add new block to the _active_array, growing if needed.
   if (!_active_array->push(block)) {
@@ -545,21 +545,21 @@ OopStorage::Block* OopStorage::block_for_allocation() {
   while (true) {
     // Use the first block in _allocation_list for the allocation.
     Block* block = _allocation_list.head();
-    if (block != NULL) {
+    if (block != nullptr) {
       return block;
     } else if (reduce_deferred_updates()) {
       // Might have added a block to the _allocation_list, so retry.
     } else if (try_add_block()) {
       // Successfully added a new block to the list, so retry.
-      assert(_allocation_list.chead() != NULL, "invariant");
-    } else if (_allocation_list.chead() != NULL) {
+      assert(_allocation_list.chead() != nullptr, "invariant");
+    } else if (_allocation_list.chead() != nullptr) {
       // Trying to add a block failed, but some other thread added to the
       // list while we'd dropped the lock over the new block allocation.
     } else if (!reduce_deferred_updates()) { // Once more before failure.
       // Attempt to add a block failed, no other thread added a block,
       // and no deferred updated added a block, then allocation failed.
       log_info(oopstorage, blocks)("%s: failed block allocation", name());
-      return NULL;
+      return nullptr;
     }
   }
 }
@@ -577,7 +577,7 @@ bool OopStorage::expand_active_array() {
   ActiveArray* new_array = ActiveArray::create(new_size,
                                                memflags(),
                                                AllocFailStrategy::RETURN_NULL);
-  if (new_array == NULL) return false;
+  if (new_array == nullptr) return false;
   new_array->copy_from(old_array);
   replace_active_array(new_array);
   relinquish_block_array(old_array);
@@ -644,7 +644,7 @@ class OopStorage::WithActiveArray : public StackObj {
 };
 
 OopStorage::Block* OopStorage::find_block_or_null(const oop* ptr) const {
-  assert(ptr != NULL, "precondition");
+  assert(ptr != nullptr, "precondition");
   return Block::block_for_ptr(this, ptr);
 }
 
@@ -689,7 +689,7 @@ void OopStorage::Block::release_entries(uintx releasing, OopStorage* owner) {
     // Log transitions.  Both transitions are possible in a single update.
     log_release_transitions(releasing, old_allocated, owner, this);
     // Attempt to claim responsibility for adding this block to the deferred
-    // list, by setting the link to non-NULL by self-looping.  If this fails,
+    // list, by setting the link to non-null by self-looping.  If this fails,
     // then someone else has made such a claim and the deferred update has not
     // yet been processed and will include our change, so we don't need to do
     // anything further.
@@ -697,7 +697,7 @@ void OopStorage::Block::release_entries(uintx releasing, OopStorage* owner) {
       // Successfully claimed.  Push, with self-loop for end-of-list.
       Block* head = owner->_deferred_updates;
       while (true) {
-        _deferred_updates_next = (head == NULL) ? this : head;
+        _deferred_updates_next = (head == nullptr) ? this : head;
         Block* fetched = Atomic::cmpxchg(&owner->_deferred_updates, head, this);
         if (fetched == head) break; // Successful update.
         head = fetched;             // Retry with updated head.
@@ -726,15 +726,15 @@ bool OopStorage::reduce_deferred_updates() {
   // The atomicity is wrto pushes by release().
   Block* block = Atomic::load_acquire(&_deferred_updates);
   while (true) {
-    if (block == NULL) return false;
+    if (block == nullptr) return false;
     // Try atomic pop of block from list.
     Block* tail = block->deferred_updates_next();
-    if (block == tail) tail = NULL; // Handle self-loop end marker.
+    if (block == tail) tail = nullptr; // Handle self-loop end marker.
     Block* fetched = Atomic::cmpxchg(&_deferred_updates, block, tail);
     if (fetched == block) break; // Update successful.
     block = fetched;             // Retry with updated block.
   }
-  block->set_deferred_updates_next(NULL); // Clear tail after updating head.
+  block->set_deferred_updates_next(nullptr); // Clear tail after updating head.
   // Ensure bitmask read after pop is complete, including clearing tail, for
   // ordering with release().  Without this, we may be processing a stale
   // bitmask state here while blocking a release() operation from recording
@@ -765,14 +765,14 @@ bool OopStorage::reduce_deferred_updates() {
 }
 
 static inline void check_release_entry(const oop* entry) {
-  assert(entry != NULL, "Releasing NULL");
-  assert(*entry == NULL, "Releasing uncleared entry: " PTR_FORMAT, p2i(entry));
+  assert(entry != nullptr, "Releasing null");
+  assert(*entry == nullptr, "Releasing uncleared entry: " PTR_FORMAT, p2i(entry));
 }
 
 void OopStorage::release(const oop* ptr) {
   check_release_entry(ptr);
   Block* block = find_block_or_null(ptr);
-  assert(block != NULL, "%s: invalid release " PTR_FORMAT, name(), p2i(ptr));
+  assert(block != nullptr, "%s: invalid release " PTR_FORMAT, name(), p2i(ptr));
   log_trace(oopstorage, ref)("%s: releasing " PTR_FORMAT, name(), p2i(ptr));
   block->release_entries(block->bitmask_for_entry(ptr), this);
   Atomic::dec(&_allocation_count);
@@ -783,7 +783,7 @@ void OopStorage::release(const oop* const* ptrs, size_t size) {
   while (i < size) {
     check_release_entry(ptrs[i]);
     Block* block = find_block_or_null(ptrs[i]);
-    assert(block != NULL, "%s: invalid release " PTR_FORMAT, name(), p2i(ptrs[i]));
+    assert(block != nullptr, "%s: invalid release " PTR_FORMAT, name(), p2i(ptrs[i]));
     size_t count = 0;
     uintx releasing = 0;
     for ( ; i < size; ++i) {
@@ -823,10 +823,10 @@ OopStorage::OopStorage(const char* name, MEMFLAGS memflags) :
   _name(os::strdup(name)),
   _active_array(ActiveArray::create(initial_active_array_size, memflags)),
   _allocation_list(),
-  _deferred_updates(NULL),
+  _deferred_updates(nullptr),
   _allocation_mutex(make_oopstorage_mutex(name, "alloc", Mutex::oopstorage)),
   _active_mutex(make_oopstorage_mutex(name, "active", Mutex::oopstorage - 1)),
-  _num_dead_callback(NULL),
+  _num_dead_callback(nullptr),
   _allocation_count(0),
   _concurrent_iteration_count(0),
   _memflags(memflags),
@@ -847,11 +847,11 @@ void OopStorage::delete_empty_block(const Block& block) {
 
 OopStorage::~OopStorage() {
   Block* block;
-  while ((block = _deferred_updates) != NULL) {
+  while ((block = _deferred_updates) != nullptr) {
     _deferred_updates = block->deferred_updates_next();
-    block->set_deferred_updates_next(NULL);
+    block->set_deferred_updates_next(nullptr);
   }
-  while ((block = _allocation_list.head()) != NULL) {
+  while ((block = _allocation_list.head()) != nullptr) {
     _allocation_list.unlink(*block);
   }
   bool unreferenced = _active_array->decrement_refcount();
@@ -865,18 +865,18 @@ OopStorage::~OopStorage() {
 }
 
 void OopStorage::register_num_dead_callback(NumDeadCallback f) {
-  assert(_num_dead_callback == NULL, "Only one callback function supported");
+  assert(_num_dead_callback == nullptr, "Only one callback function supported");
   _num_dead_callback = f;
 }
 
 void OopStorage::report_num_dead(size_t num_dead) const {
-  if (_num_dead_callback != NULL) {
+  if (_num_dead_callback != nullptr) {
     _num_dead_callback(num_dead);
   }
 }
 
 bool OopStorage::should_report_num_dead() const {
-  return _num_dead_callback != NULL;
+  return _num_dead_callback != nullptr;
 }
 
 // Managing service thread notifications.
@@ -942,7 +942,7 @@ bool OopStorage::delete_empty_blocks() {
   // Check for deferred updates even though that's not a service thread
   // trigger; since we're here, we might as well process them.
   if (!Atomic::load_acquire(&_needs_cleanup) &&
-      (Atomic::load_acquire(&_deferred_updates) == NULL)) {
+      (Atomic::load_acquire(&_deferred_updates) == nullptr)) {
     return false;
   }
 
@@ -973,7 +973,7 @@ bool OopStorage::delete_empty_blocks() {
       ThreadBlockInVM tbiv(JavaThread::current());
     } else {
       Block* block = _allocation_list.tail();
-      if ((block == NULL) || !block->is_empty()) {
+      if ((block == nullptr) || !block->is_empty()) {
         return false;
       } else if (!block->is_safe_to_delete()) {
         // Look for other work while waiting for block to be deletable.
@@ -1008,7 +1008,7 @@ bool OopStorage::delete_empty_blocks() {
 
 OopStorage::EntryStatus OopStorage::allocation_status(const oop* ptr) const {
   const Block* block = find_block_or_null(ptr);
-  if (block != NULL) {
+  if (block != nullptr) {
     // Prevent block deletion and _active_array modification.
     MutexLocker ml(_allocation_mutex, Mutex::_no_safepoint_check_flag);
     // Block could be a false positive, so get index carefully.
diff --git a/src/hotspot/share/gc/shared/oopStorage.hpp b/src/hotspot/share/gc/shared/oopStorage.hpp
index d40e5a49cda..dfc0f83fc19 100644
--- a/src/hotspot/share/gc/shared/oopStorage.hpp
+++ b/src/hotspot/share/gc/shared/oopStorage.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,12 +99,12 @@ class OopStorage : public CHeapObjBase {
   };
 
   // Locks _allocation_mutex.
-  // precondition: ptr != NULL.
+  // precondition: ptr != nullptr.
   EntryStatus allocation_status(const oop* ptr) const;
 
-  // Allocates and returns a new entry.  Returns NULL if memory allocation
+  // Allocates and returns a new entry.  Returns null if memory allocation
   // failed.  Locks _allocation_mutex.
-  // postcondition: result == NULL or *result == NULL.
+  // postcondition: result == nullptr or *result == nullptr.
   oop* allocate();
 
   // Maximum number of entries that can be obtained by one call to
@@ -120,18 +120,18 @@ class OopStorage : public CHeapObjBase {
   // precondition: size > 0.
   // postcondition: result <= min(size, bulk_allocate_limit).
   // postcondition: ptrs[i] is an allocated entry for i in [0, result).
-  // postcondition: *ptrs[i] == NULL for i in [0, result).
+  // postcondition: *ptrs[i] == nullptr for i in [0, result).
   size_t allocate(oop** ptrs, size_t size);
 
   // Deallocates ptr.  No locking.
   // precondition: ptr is a valid allocated entry.
-  // precondition: *ptr == NULL.
+  // precondition: *ptr == nullptr.
   void release(const oop* ptr);
 
   // Releases all the ptrs.  Possibly faster than individual calls to
   // release(oop*).  Best if ptrs is sorted by address.  No locking.
   // precondition: All elements of ptrs are valid allocated entries.
-  // precondition: *ptrs[i] == NULL, for i in [0,size).
+  // precondition: *ptrs[i] == nullptr, for i in [0,size).
   void release(const oop* const* ptrs, size_t size);
 
   // Applies f to each allocated entry's location.  f must be a function or
@@ -155,9 +155,9 @@ class OopStorage : public CHeapObjBase {
   // - is_alive->do_object_b(*p) must be a valid expression whose value is
   // convertible to bool.
   //
-  // For weak_oops_do, if *p == NULL then neither is_alive nor closure will be
+  // For weak_oops_do, if *p == nullptr then neither is_alive nor closure will be
   // invoked for p.  If is_alive->do_object_b(*p) is false, then closure will
-  // not be invoked on p, and *p will be set to NULL.
+  // not be invoked on p, and *p will be set to null.
 
   template<typename Closure> inline void oops_do(Closure* closure);
   template<typename Closure> inline void oops_do(Closure* closure) const;
@@ -181,7 +181,7 @@ class OopStorage : public CHeapObjBase {
 
   // Called by the GC after an iteration that may clear dead referents.
   // This calls the registered callback function, if any.  num_dead is the
-  // number of entries which were either already NULL or were cleared by the
+  // number of entries which were either already null or were cleared by the
   // iteration.
   void report_num_dead(size_t num_dead) const;
 
@@ -317,7 +317,7 @@ class OopStorage : public CHeapObjBase {
   template<typename IsAlive, typename F>
   static IfAliveFn<IsAlive, F> if_alive_fn(IsAlive* is_alive, F f);
 
-  // Wrapper for iteration handler, automatically skipping NULL entries.
+  // Wrapper for iteration handler, automatically skipping null entries.
   template<typename F> class SkipNullFn;
   template<typename F> static SkipNullFn<F> skip_null_fn(F f);
 };
diff --git a/src/hotspot/share/gc/shared/oopStorage.inline.hpp b/src/hotspot/share/gc/shared/oopStorage.inline.hpp
index 000700afde6..e1e815acd09 100644
--- a/src/hotspot/share/gc/shared/oopStorage.inline.hpp
+++ b/src/hotspot/share/gc/shared/oopStorage.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -184,7 +184,7 @@ class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
   void set_active_index(size_t index);
   static size_t active_index_safe(const Block* block); // Returns 0 if access fails.
 
-  // Returns NULL if ptr is not in a block or not allocated in that block.
+  // Returns null if ptr is not in a block or not allocated in that block.
   static Block* block_for_ptr(const OopStorage* owner, const oop* ptr);
 
   oop* allocate();
@@ -258,11 +258,11 @@ class OopStorage::IfAliveFn {
   bool operator()(oop* ptr) const {
     bool result = true;
     oop v = *ptr;
-    if (v != NULL) {
+    if (v != nullptr) {
       if (_is_alive->do_object_b(v)) {
         result = _f(ptr);
       } else {
-        *ptr = NULL;            // Clear dead value.
+        *ptr = nullptr;            // Clear dead value.
       }
     }
     return result;
@@ -285,7 +285,7 @@ class OopStorage::SkipNullFn {
 
   template<typename OopPtr>     // [const] oop*
   bool operator()(OopPtr ptr) const {
-    return (*ptr != NULL) ? _f(ptr) : true;
+    return (*ptr != nullptr) ? _f(ptr) : true;
   }
 
 private:
diff --git a/src/hotspot/share/gc/shared/oopStorageParState.hpp b/src/hotspot/share/gc/shared/oopStorageParState.hpp
index e76541483e5..f36a817ee49 100644
--- a/src/hotspot/share/gc/shared/oopStorageParState.hpp
+++ b/src/hotspot/share/gc/shared/oopStorageParState.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@
 // allocations and releases that occur after the iteration started will not be
 // seen by the iteration.  Further, some may overlap examination by the
 // iteration.  To help with this, allocate() and release() have an invariant
-// that an entry's value must be NULL when it is not in use.
+// that an entry's value must be null when it is not in use.
 //
 // ParState<concurrent, is_const>
 //   concurrent must be true if iteration may be concurrent with the
@@ -124,7 +124,7 @@
 //   - is_alive->do_object_b(*p) must be a valid expression whose value
 //   is convertible to bool.
 //
-//   If *p == NULL then neither is_alive nor cl will be invoked for p.
+//   If *p == nullptr then neither is_alive nor cl will be invoked for p.
 //   If is_alive->do_object_b(*p) is false, then cl will not be
 //   invoked on p.
 
diff --git a/src/hotspot/share/gc/shared/oopStorageSet.cpp b/src/hotspot/share/gc/shared/oopStorageSet.cpp
index 78da4988e21..e119e570759 100644
--- a/src/hotspot/share/gc/shared/oopStorageSet.cpp
+++ b/src/hotspot/share/gc/shared/oopStorageSet.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@ template OopStorage* OopStorageSet::get_storage(Id);
 
 void OopStorageSet::verify_initialized(uint index) {
   assert(index < ARRAY_SIZE(_storages), "invalid index");
-  assert(_storages[index] != NULL, "oopstorage_init not yet called");
+  assert(_storages[index] != nullptr, "oopstorage_init not yet called");
 }
 
 #endif // ASSERT
diff --git a/src/hotspot/share/gc/shared/oopStorageSetParState.inline.hpp b/src/hotspot/share/gc/shared/oopStorageSetParState.inline.hpp
index 09f35fe43a4..7aa63606c77 100644
--- a/src/hotspot/share/gc/shared/oopStorageSetParState.inline.hpp
+++ b/src/hotspot/share/gc/shared/oopStorageSetParState.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@ class DeadCounterClosure : public OopClosure {
   virtual void do_oop(oop* p) {
     _cl->do_oop(p);
     if (NativeAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(p) == nullptr) {
-      _num_dead++;              // Count both already NULL and cleared by closure.
+      _num_dead++;              // Count both already null and cleared by closure.
     }
   }
 
diff --git a/src/hotspot/share/gc/shared/parallelCleaning.cpp b/src/hotspot/share/gc/shared/parallelCleaning.cpp
index a3630557328..396f7e6c31e 100644
--- a/src/hotspot/share/gc/shared/parallelCleaning.cpp
+++ b/src/hotspot/share/gc/shared/parallelCleaning.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,8 +35,8 @@
 CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, bool unloading_occurred) :
   _unloading_occurred(unloading_occurred),
   _num_workers(num_workers),
-  _first_nmethod(NULL),
-  _claimed_nmethod(NULL) {
+  _first_nmethod(nullptr),
+  _claimed_nmethod(nullptr) {
   // Get first alive nmethod
   CompiledMethodIterator iter(CompiledMethodIterator::all_blobs);
   if(iter.next()) {
@@ -60,7 +60,7 @@ void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, i
     first = _claimed_nmethod;
     last = CompiledMethodIterator(CompiledMethodIterator::all_blobs, first);
 
-    if (first != NULL) {
+    if (first != nullptr) {
 
       for (int i = 0; i < MaxClaimNmethods; i++) {
         if (!last.next()) {
@@ -76,9 +76,9 @@ void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, i
 
 void CodeCacheUnloadingTask::work(uint worker_id) {
   // The first nmethods is claimed by the first worker.
-  if (worker_id == 0 && _first_nmethod != NULL) {
+  if (worker_id == 0 && _first_nmethod != nullptr) {
     _first_nmethod->do_unloading(_unloading_occurred);
-    _first_nmethod = NULL;
+    _first_nmethod = nullptr;
   }
 
   int num_claimed_nmethods;
@@ -114,7 +114,7 @@ InstanceKlass* KlassCleaningTask::claim_next_klass() {
   Klass* klass;
   do {
     klass =_klass_iterator.next_klass();
-  } while (klass != NULL && !klass->is_instance_klass());
+  } while (klass != nullptr && !klass->is_instance_klass());
 
   // this can be null so don't call InstanceKlass::cast
   return static_cast<InstanceKlass*>(klass);
@@ -130,7 +130,7 @@ void KlassCleaningTask::work() {
 
   // All workers will help cleaning the classes,
   InstanceKlass* klass;
-  while ((klass = claim_next_klass()) != NULL) {
+  while ((klass = claim_next_klass()) != nullptr) {
     clean_klass(klass);
   }
 }
diff --git a/src/hotspot/share/gc/shared/plab.cpp b/src/hotspot/share/gc/shared/plab.cpp
index 3af530c76bc..e9b267879ae 100644
--- a/src/hotspot/share/gc/shared/plab.cpp
+++ b/src/hotspot/share/gc/shared/plab.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,8 +54,8 @@ void PLAB::startup_initialization() {
 }
 
 PLAB::PLAB(size_t desired_plab_sz_) :
-  _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL),
-  _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0)
+  _word_sz(desired_plab_sz_), _bottom(nullptr), _top(nullptr),
+  _end(nullptr), _hard_end(nullptr), _allocated(0), _wasted(0), _undo_wasted(0)
 {
   assert(min_size() > CollectedHeap::lab_alignment_reserve(),
          "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " "
diff --git a/src/hotspot/share/gc/shared/plab.hpp b/src/hotspot/share/gc/shared/plab.hpp
index 6680db5f6e1..a34e420d447 100644
--- a/src/hotspot/share/gc/shared/plab.hpp
+++ b/src/hotspot/share/gc/shared/plab.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,14 +84,14 @@ class PLAB: public CHeapObj<mtGC> {
   // If an allocation of the given "word_sz" can be satisfied within the
   // buffer, do the allocation, returning a pointer to the start of the
   // allocated block.  If the allocation request cannot be satisfied,
-  // return NULL.
+  // return null.
   HeapWord* allocate(size_t word_sz) {
     HeapWord* res = _top;
     if (pointer_delta(_end, _top) >= word_sz) {
       _top = _top + word_sz;
       return res;
     } else {
-      return NULL;
+      return nullptr;
     }
   }
 
diff --git a/src/hotspot/share/gc/shared/preservedMarks.hpp b/src/hotspot/share/gc/shared/preservedMarks.hpp
index 959287ef99d..c96124effed 100644
--- a/src/hotspot/share/gc/shared/preservedMarks.hpp
+++ b/src/hotspot/share/gc/shared/preservedMarks.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,8 +86,8 @@ class PreservedMarksSet : public CHeapObj<mtGC> {
   uint _num;
 
   // Stack array (typically, one stack per GC worker) of length _num.
-  // This should be != NULL if the stacks have been initialized,
-  // or == NULL if they have not.
+  // This should be != null if the stacks have been initialized,
+  // or == null if they have not.
   Padded<PreservedMarks>* _stacks;
 
 public:
@@ -95,7 +95,7 @@ class PreservedMarksSet : public CHeapObj<mtGC> {
 
   // Return the i'th stack.
   PreservedMarks* get(uint i = 0) const {
-    assert(_num > 0 && _stacks != NULL, "stacks should have been initialized");
+    assert(_num > 0 && _stacks != nullptr, "stacks should have been initialized");
     assert(i < _num, "pre-condition");
     return (_stacks + i);
   }
@@ -105,7 +105,7 @@ class PreservedMarksSet : public CHeapObj<mtGC> {
 
   // Iterate over all stacks, restore all preserved marks, and reclaim
   // the memory taken up by the stack segments using the given WorkerThreads. If the WorkerThreads
-  // is NULL, perform the work serially in the current thread.
+  // is null, perform the work serially in the current thread.
   void restore(WorkerThreads* workers);
 
   WorkerTask* create_task();
@@ -117,10 +117,10 @@ class PreservedMarksSet : public CHeapObj<mtGC> {
   void assert_empty() PRODUCT_RETURN;
 
   PreservedMarksSet(bool in_c_heap)
-      : _in_c_heap(in_c_heap), _num(0), _stacks(NULL) { }
+      : _in_c_heap(in_c_heap), _num(0), _stacks(nullptr) { }
 
   ~PreservedMarksSet() {
-    assert(_stacks == NULL && _num == 0, "stacks should have been reclaimed");
+    assert(_stacks == nullptr && _num == 0, "stacks should have been reclaimed");
   }
 };
 
diff --git a/src/hotspot/share/gc/shared/pretouchTask.cpp b/src/hotspot/share/gc/shared/pretouchTask.cpp
index 4c18cf3eb20..1b9d527bb06 100644
--- a/src/hotspot/share/gc/shared/pretouchTask.cpp
+++ b/src/hotspot/share/gc/shared/pretouchTask.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,7 @@ void PretouchTask::pretouch(const char* task_name, char* start_address, char* en
     return;
   }
 
-  if (pretouch_workers != NULL) {
+  if (pretouch_workers != nullptr) {
     size_t num_chunks = ((total_bytes - 1) / chunk_size) + 1;
 
     uint num_workers = (uint)MIN2(num_chunks, (size_t)pretouch_workers->max_workers());
diff --git a/src/hotspot/share/gc/shared/ptrQueue.cpp b/src/hotspot/share/gc/shared/ptrQueue.cpp
index 3c3955b6eda..57bb71706e1 100644
--- a/src/hotspot/share/gc/shared/ptrQueue.cpp
+++ b/src/hotspot/share/gc/shared/ptrQueue.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,11 +31,11 @@
 PtrQueue::PtrQueue(PtrQueueSet* qset) :
   _index(0),
   _capacity_in_bytes(index_to_byte_index(qset->buffer_size())),
-  _buf(NULL)
+  _buf(nullptr)
 {}
 
 PtrQueue::~PtrQueue() {
-  assert(_buf == NULL, "queue must be flushed before delete");
+  assert(_buf == nullptr, "queue must be flushed before delete");
 }
 
 BufferNode::AllocatorConfig::AllocatorConfig(size_t size) : _buffer_size(size) {}
@@ -66,8 +66,8 @@ BufferNode* BufferNode::Allocator::allocate() {
 }
 
 void BufferNode::Allocator::release(BufferNode* node) {
-  assert(node != NULL, "precondition");
-  assert(node->next() == NULL, "precondition");
+  assert(node != nullptr, "precondition");
+  assert(node->next() == nullptr, "precondition");
   node->~BufferNode();
   _free_list.release(node);
 }
diff --git a/src/hotspot/share/gc/shared/ptrQueue.hpp b/src/hotspot/share/gc/shared/ptrQueue.hpp
index 24780444550..eb691e9c7e7 100644
--- a/src/hotspot/share/gc/shared/ptrQueue.hpp
+++ b/src/hotspot/share/gc/shared/ptrQueue.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -123,7 +123,7 @@ class BufferNode {
   BufferNode* volatile _next;
   void* _buffer[1];             // Pseudo flexible array member.
 
-  BufferNode() : _index(0), _next(NULL) { }
+  BufferNode() : _index(0), _next(nullptr) { }
   ~BufferNode() { }
 
   NONCOPYABLE(BufferNode);
diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp
index f6666858b5f..8c0f227839c 100644
--- a/src/hotspot/share/gc/shared/referenceProcessor.cpp
+++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,8 +43,8 @@
 #include "runtime/nonJavaThread.hpp"
 #include "utilities/globalDefinitions.hpp"
 
-ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
-ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy      = NULL;
+ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = nullptr;
+ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy      = nullptr;
 jlong            ReferenceProcessor::_soft_ref_timestamp_clock = 0;
 
 void referenceProcessor_init() {
@@ -96,7 +96,7 @@ ReferenceProcessor::ReferenceProcessor(BoolObjectClosure* is_subject_to_discover
   _next_id(0),
   _is_alive_non_header(is_alive_non_header)
 {
-  assert(is_subject_to_discovery != NULL, "must be set");
+  assert(is_subject_to_discovery != nullptr, "must be set");
 
   _discovery_is_concurrent = concurrent_discovery;
   _discovery_is_mt         = (mt_discovery_degree > 1);
@@ -110,7 +110,7 @@ ReferenceProcessor::ReferenceProcessor(BoolObjectClosure* is_subject_to_discover
   _discoveredFinalRefs   = &_discoveredWeakRefs[_max_num_queues];
   _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_queues];
 
-  // Initialize all entries to NULL
+  // Initialize all entries to null
   for (uint i = 0; i < _max_num_queues * number_of_subclasses_of_ref(); i++) {
     _discovered_refs[i].clear();
   }
@@ -238,7 +238,7 @@ void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
   _current_discovered_addr = java_lang_ref_Reference::discovered_addr_raw(_current_discovered);
   oop discovered = java_lang_ref_Reference::discovered(_current_discovered);
   assert(_current_discovered_addr && oopDesc::is_oop_or_null(discovered),
-         "Expected an oop or NULL for discovered field at " PTR_FORMAT, p2i(discovered));
+         "Expected an oop or null for discovered field at " PTR_FORMAT, p2i(discovered));
   _next_discovered = discovered;
   _referent = java_lang_ref_Reference::unknown_referent_no_keepalive(_current_discovered);
   assert(Universe::heap()->is_in_or_null(_referent),
@@ -247,20 +247,20 @@ void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
              oopDesc::is_oop_or_null(_referent)
            : oopDesc::is_oop(_referent),
          "Expected an oop%s for referent field at " PTR_FORMAT,
-         (allow_null_referent ? " or NULL" : ""),
+         (allow_null_referent ? " or null" : ""),
          p2i(_referent));
 }
 
 void DiscoveredListIterator::remove() {
   assert(oopDesc::is_oop(_current_discovered), "Dropping a bad reference");
-  RawAccess<>::oop_store(_current_discovered_addr, oop(NULL));
+  RawAccess<>::oop_store(_current_discovered_addr, oop(nullptr));
 
   // First _prev_next ref actually points into DiscoveredList (gross).
   oop new_next;
   if (_next_discovered == _current_discovered) {
     // At the end of the list, we should make _prev point to itself.
     // If _ref is the first ref, then _prev_next will be in the DiscoveredList,
-    // and _prev will be NULL.
+    // and _prev will be null.
     new_next = _prev_discovered;
   } else {
     new_next = _next_discovered;
@@ -338,7 +338,7 @@ size_t ReferenceProcessor::process_discovered_list_work(DiscoveredList&    refs_
   DiscoveredListIterator iter(refs_list, keep_alive, is_alive, enqueue);
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(discovery_is_concurrent() /* allow_null_referent */));
-    if (iter.referent() == NULL) {
+    if (iter.referent() == nullptr) {
       // Reference has been cleared since discovery; only possible if
       // discovery is concurrent (checked by load_ptrs).  Remove
       // reference from list.
@@ -379,14 +379,14 @@ size_t ReferenceProcessor::process_discovered_list_work(DiscoveredList&    refs_
 size_t ReferenceProcessor::process_final_keep_alive_work(DiscoveredList& refs_list,
                                                          OopClosure*     keep_alive,
                                                          EnqueueDiscoveredFieldClosure* enqueue) {
-  DiscoveredListIterator iter(refs_list, keep_alive, NULL, enqueue);
+  DiscoveredListIterator iter(refs_list, keep_alive, nullptr, enqueue);
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(false /* allow_null_referent */));
     // keep the referent and followers around
     iter.make_referent_alive();
 
     // Self-loop next, to mark the FinalReference not active.
-    assert(java_lang_ref_Reference::next(iter.obj()) == NULL, "enqueued FinalReference");
+    assert(java_lang_ref_Reference::next(iter.obj()) == nullptr, "enqueued FinalReference");
     java_lang_ref_Reference::set_next_raw(iter.obj(), iter.obj());
 
     iter.enqueue();
@@ -402,12 +402,12 @@ size_t ReferenceProcessor::process_final_keep_alive_work(DiscoveredList& refs_li
 
 void
 ReferenceProcessor::clear_discovered_references(DiscoveredList& refs_list) {
-  oop obj = NULL;
+  oop obj = nullptr;
   oop next = refs_list.head();
   while (next != obj) {
     obj = next;
     next = java_lang_ref_Reference::discovered(obj);
-    java_lang_ref_Reference::set_discovered_raw(obj, NULL);
+    java_lang_ref_Reference::set_discovered_raw(obj, nullptr);
   }
   refs_list.clear();
 }
@@ -423,7 +423,7 @@ void ReferenceProcessor::abandon_partial_discovery() {
 }
 
 size_t ReferenceProcessor::total_reference_count(ReferenceType type) const {
-  DiscoveredList* list = NULL;
+  DiscoveredList* list = nullptr;
 
   switch (type) {
     case REF_SOFT:
@@ -670,7 +670,7 @@ void ReferenceProcessor::balance_queues(DiscoveredList ref_lists[])
         }
 
         // Add the chain to the to list.
-        if (ref_lists[to_idx].head() == NULL) {
+        if (ref_lists[to_idx].head() == nullptr) {
           // to list is empty. Make a loop at the end.
           java_lang_ref_Reference::set_discovered_raw(move_tail, move_tail);
         } else {
@@ -682,7 +682,7 @@ void ReferenceProcessor::balance_queues(DiscoveredList ref_lists[])
         // Remove the chain from the from list.
         if (move_tail == new_head) {
           // We found the end of the from list.
-          ref_lists[from_idx].set_head(NULL);
+          ref_lists[from_idx].set_head(nullptr);
         } else {
           ref_lists[from_idx].set_head(new_head);
         }
@@ -714,7 +714,7 @@ void ReferenceProcessor::run_task(RefProcTask& task, RefProcProxyTask& proxy_tas
   proxy_task.prepare_run_task(task, num_queues(), processing_is_mt() ? RefProcThreadModel::Multi : RefProcThreadModel::Single, marks_oops_alive);
   if (processing_is_mt()) {
     WorkerThreads* workers = Universe::heap()->safepoint_workers();
-    assert(workers != NULL, "can not dispatch multi threaded without workers");
+    assert(workers != nullptr, "can not dispatch multi threaded without workers");
     assert(workers->active_workers() >= num_queues(),
            "Ergonomically chosen workers(%u) should be less than or equal to active workers(%u)",
            num_queues(), workers->active_workers());
@@ -826,7 +826,7 @@ inline DiscoveredList* ReferenceProcessor::get_discovered_list(ReferenceType rt)
   assert(id < _max_num_queues, "Id is out of bounds id %u and max id %u)", id, _max_num_queues);
 
   // Get the discovered queue to which we will add
-  DiscoveredList* list = NULL;
+  DiscoveredList* list = nullptr;
   switch (rt) {
     case REF_SOFT:
       list = &_discoveredSoftRefs[id];
@@ -860,7 +860,7 @@ inline void ReferenceProcessor::add_to_discovered_list(DiscoveredList& refs_list
   oop current_head = refs_list.head();
   // Prepare value to put into the discovered field. The last ref must have its
   // discovered field pointing to itself.
-  oop next_discovered = (current_head != NULL) ? current_head : obj;
+  oop next_discovered = (current_head != nullptr) ? current_head : obj;
 
   bool added = set_discovered_link(discovered_addr, next_discovered);
   if (added) {
@@ -899,15 +899,15 @@ inline bool ReferenceProcessor::set_discovered_link_mt(HeapWord* discovered_addr
   if (discovery_is_stw()) {
     // Try a raw store here, still making sure that we enqueue only once: the field
     // will be visited later when processing the discovered references.
-    retest = RawAccess<>::oop_atomic_cmpxchg(discovered_addr, oop(NULL), next_discovered);
+    retest = RawAccess<>::oop_atomic_cmpxchg(discovered_addr, oop(nullptr), next_discovered);
   } else {
-    retest = HeapAccess<AS_NO_KEEPALIVE>::oop_atomic_cmpxchg(discovered_addr, oop(NULL), next_discovered);
+    retest = HeapAccess<AS_NO_KEEPALIVE>::oop_atomic_cmpxchg(discovered_addr, oop(nullptr), next_discovered);
   }
-  return retest == NULL;
+  return retest == nullptr;
 }
 
 #ifndef PRODUCT
-// Concurrent discovery might allow us to observe j.l.References with NULL
+// Concurrent discovery might allow us to observe j.l.References with null
 // referents, being those cleared concurrently by mutators during (or after) discovery.
 void ReferenceProcessor::verify_referent(oop obj) {
   bool concurrent = discovery_is_concurrent();
@@ -955,7 +955,7 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
     return false;
   }
 
-  if ((rt == REF_FINAL) && (java_lang_ref_Reference::next(obj) != NULL)) {
+  if ((rt == REF_FINAL) && (java_lang_ref_Reference::next(obj) != nullptr)) {
     // Don't rediscover non-active FinalReferences.
     return false;
   }
@@ -970,7 +970,7 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
 
   // We only discover references whose referents are not (yet)
   // known to be strongly reachable.
-  if (is_alive_non_header() != NULL) {
+  if (is_alive_non_header() != nullptr) {
     verify_referent(obj);
     oop referent = java_lang_ref_Reference::unknown_referent_no_keepalive(obj);
     if (is_alive_non_header()->do_object_b(referent)) {
@@ -994,8 +994,8 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
 
   HeapWord* const discovered_addr = java_lang_ref_Reference::discovered_addr_raw(obj);
   const oop  discovered = java_lang_ref_Reference::discovered(obj);
-  assert(oopDesc::is_oop_or_null(discovered), "Expected an oop or NULL for discovered field at " PTR_FORMAT, p2i(discovered));
-  if (discovered != NULL) {
+  assert(oopDesc::is_oop_or_null(discovered), "Expected an oop or null for discovered field at " PTR_FORMAT, p2i(discovered));
+  if (discovered != nullptr) {
     // The reference has already been discovered...
     log_develop_trace(gc, ref)("Already discovered reference (" PTR_FORMAT ": %s)",
                                p2i(obj), obj->klass()->internal_name());
@@ -1157,7 +1157,7 @@ const char* ReferenceProcessor::list_name(uint i) {
      case 3: return "PhantomRef";
    }
    ShouldNotReachHere();
-   return NULL;
+   return nullptr;
 }
 
 uint RefProcMTDegreeAdjuster::ergo_proc_thread_count(size_t ref_count,
diff --git a/src/hotspot/share/gc/shared/referenceProcessor.hpp b/src/hotspot/share/gc/shared/referenceProcessor.hpp
index fded4af981c..77f095a13fb 100644
--- a/src/hotspot/share/gc/shared/referenceProcessor.hpp
+++ b/src/hotspot/share/gc/shared/referenceProcessor.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@ class BarrierEnqueueDiscoveredFieldClosure : public EnqueueDiscoveredFieldClosur
 // List of discovered references.
 class DiscoveredList {
 public:
-  DiscoveredList() : _oop_head(NULL), _compressed_head(narrowOop::null), _len(0) { }
+  DiscoveredList() : _oop_head(nullptr), _compressed_head(narrowOop::null), _len(0) { }
   inline oop head() const;
   HeapWord* adr_head() {
     return UseCompressedOops ? (HeapWord*)&_compressed_head :
@@ -114,7 +114,7 @@ class DiscoveredListIterator {
                                 EnqueueDiscoveredFieldClosure* enqueue);
 
   // End Of List.
-  inline bool has_next() const { return _current_discovered != NULL; }
+  inline bool has_next() const { return _current_discovered != nullptr; }
 
   // Get oop to the Reference object.
   inline oop obj() const { return _current_discovered; }
@@ -129,7 +129,7 @@ class DiscoveredListIterator {
 
   // Loads data for the current reference.
   // The "allow_null_referent" argument tells us to allow for the possibility
-  // of a NULL referent in the discovered Reference object. This typically
+  // of a null referent in the discovered Reference object. This typically
   // happens in the case of concurrent collectors that may have done the
   // discovery concurrently, or interleaved, with mutator execution.
   void load_ptrs(DEBUG_ONLY(bool allow_null_referent));
@@ -153,7 +153,7 @@ class DiscoveredListIterator {
   // Move enqueued references to the reference pending list.
   void complete_enqueue();
 
-  // NULL out referent pointer.
+  // null out referent pointer.
   void clear_referent();
 
   // Statistics
@@ -163,7 +163,7 @@ class DiscoveredListIterator {
   inline void move_to_next() {
     if (_current_discovered == _next_discovered) {
       // End of the list.
-      _current_discovered = NULL;
+      _current_discovered = nullptr;
     } else {
       _current_discovered = _next_discovered;
     }
@@ -255,7 +255,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
 
   void run_task(RefProcTask& task, RefProcProxyTask& proxy_task, bool marks_oops_alive);
 
-  // Drop Soft/Weak/Final references with a NULL or live referent, and clear
+  // Drop Soft/Weak/Final references with a null or live referent, and clear
   // and enqueue non-Final references.
   void process_soft_weak_final_refs(RefProcProxyTask& proxy_task,
                                     ReferenceProcessorPhaseTimes& phase_times);
@@ -272,7 +272,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
   // removed elements.
 
   // Traverse the list and remove any Refs whose referents are alive,
-  // or NULL if discovery is concurrent. Enqueue and clear the reference for
+  // or null if discovery is concurrent. Enqueue and clear the reference for
   // others if do_enqueue_and_clear is set.
   size_t process_discovered_list_work(DiscoveredList&    refs_list,
                                       BoolObjectClosure* is_alive,
@@ -305,7 +305,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
   }
 
   // "Preclean" all the discovered reference lists by removing references whose
-  // referents are NULL or strongly reachable (`is_alive` returns true).
+  // referents are null or strongly reachable (`is_alive` returns true).
   // Note: when a referent is strongly reachable, we assume it's already marked
   // through, so this method doesn't perform (and doesn't need to) any marking
   // work at all. Currently, this assumption holds because G1 uses SATB and the
@@ -376,7 +376,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
                      uint mt_processing_degree = 1,
                      uint mt_discovery_degree  = 1,
                      bool concurrent_discovery = false,
-                     BoolObjectClosure* is_alive_non_header = NULL);
+                     BoolObjectClosure* is_alive_non_header = nullptr);
 
   // RefDiscoveryPolicy values
   enum DiscoveryPolicy {
@@ -428,7 +428,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
 
   // If a discovery is in process that is being superseded, abandon it: all
   // the discovered lists will be empty, and all the objects on them will
-  // have NULL discovered fields.  Must be called only at a safepoint.
+  // have null discovered fields.  Must be called only at a safepoint.
   void abandon_partial_discovery();
 
   size_t total_reference_count(ReferenceType rt) const;
diff --git a/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp b/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp
index 67b6c810074..d0fb3a7f070 100644
--- a/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp
+++ b/src/hotspot/share/gc/shared/referenceProcessor.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,11 +50,11 @@ void DiscoveredList::set_head(oop o) {
 }
 
 bool DiscoveredList::is_empty() const {
- return head() == NULL;
+ return head() == nullptr;
 }
 
 void DiscoveredList::clear() {
-  set_head(NULL);
+  set_head(nullptr);
   set_length(0);
 }
 
@@ -64,11 +64,11 @@ DiscoveredListIterator::DiscoveredListIterator(DiscoveredList&    refs_list,
                                                EnqueueDiscoveredFieldClosure* enqueue):
   _refs_list(refs_list),
   _prev_discovered_addr(refs_list.adr_head()),
-  _prev_discovered(NULL),
+  _prev_discovered(nullptr),
   _current_discovered(refs_list.head()),
-  _current_discovered_addr(NULL),
-  _next_discovered(NULL),
-  _referent(NULL),
+  _current_discovered_addr(nullptr),
+  _next_discovered(nullptr),
+  _referent(nullptr),
   _keep_alive(keep_alive),
   _is_alive(is_alive),
   _enqueue(enqueue),
diff --git a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp
index fc05b1c023a..2ad55b95424 100644
--- a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp
+++ b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -90,7 +90,7 @@ static const char* ref_type_2_string(ReferenceType ref_type) {
 
 RefProcWorkerTimeTracker::RefProcWorkerTimeTracker(WorkerDataArray<double>* worker_time, uint worker_id) :
   _worker_time(worker_time), _start_time(os::elapsedTime()), _worker_id(worker_id) {
-  assert(worker_time != NULL, "Invariant");
+  assert(worker_time != nullptr, "Invariant");
 }
 
 RefProcWorkerTimeTracker::~RefProcWorkerTimeTracker() {
@@ -108,7 +108,7 @@ RefProcPhaseTimeBaseTracker::RefProcPhaseTimeBaseTracker(const char* title,
                                                          ReferenceProcessor::RefProcPhases phase_number,
                                                          ReferenceProcessorPhaseTimes* phase_times) :
   _phase_times(phase_times), _start_ticks(), _end_ticks(), _phase_number(phase_number) {
-  assert(_phase_times != NULL, "Invariant");
+  assert(_phase_times != nullptr, "Invariant");
 
   _start_ticks.stamp();
   _phase_times->gc_timer()->register_gc_phase_start(title, _start_ticks);
@@ -157,9 +157,9 @@ ReferenceProcessorPhaseTimes::ReferenceProcessorPhaseTimes(GCTimer* gc_timer, ui
   _processing_is_mt(false), _gc_timer(gc_timer) {
   assert(gc_timer != nullptr, "pre-condition");
   for (uint i = 0; i < ReferenceProcessor::RefSubPhaseMax; i++) {
-    _sub_phases_worker_time_sec[i] = new WorkerDataArray<double>(NULL, SubPhasesParWorkTitle[i], max_gc_threads);
+    _sub_phases_worker_time_sec[i] = new WorkerDataArray<double>(nullptr, SubPhasesParWorkTitle[i], max_gc_threads);
   }
-  _soft_weak_final_refs_phase_worker_time_sec = new WorkerDataArray<double>(NULL, SoftWeakFinalRefsPhaseParWorkTitle, max_gc_threads);
+  _soft_weak_final_refs_phase_worker_time_sec = new WorkerDataArray<double>(nullptr, SoftWeakFinalRefsPhaseParWorkTitle, max_gc_threads);
 
   reset();
 }
diff --git a/src/hotspot/share/gc/shared/satbMarkQueue.cpp b/src/hotspot/share/gc/shared/satbMarkQueue.cpp
index c602eccfc3c..71ce8398241 100644
--- a/src/hotspot/share/gc/shared/satbMarkQueue.cpp
+++ b/src/hotspot/share/gc/shared/satbMarkQueue.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -206,7 +206,7 @@ void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active)
 
 bool SATBMarkQueueSet::apply_closure_to_completed_buffer(SATBBufferClosure* cl) {
   BufferNode* nd = get_completed_buffer();
-  if (nd != NULL) {
+  if (nd != nullptr) {
     void **buf = BufferNode::make_buffer_from_node(nd);
     size_t index = nd->index();
     size_t size = buffer_size();
@@ -272,7 +272,7 @@ bool SATBMarkQueueSet::should_enqueue_buffer(SATBMarkQueue& queue) {
 // pushing onto the allocator's list.
 
 void SATBMarkQueueSet::enqueue_completed_buffer(BufferNode* node) {
-  assert(node != NULL, "precondition");
+  assert(node != nullptr, "precondition");
   // Increment count and update flag appropriately.  Done before
   // pushing buffer so count is always at least the actual number in
   // the list, and decrement never underflows.
@@ -286,7 +286,7 @@ BufferNode* SATBMarkQueueSet::get_completed_buffer() {
     GlobalCounter::CriticalSection cs(Thread::current());
     node = _list.pop();
   }
-  if (node != NULL) {
+  if (node != nullptr) {
     // Got a buffer so decrement count and update flag appropriately.
     decrement_count(&_count_and_process_flag);
   }
@@ -307,7 +307,7 @@ void SATBMarkQueueSet::print_all(const char* msg) {
 
   BufferNode* nd = _list.top();
   int i = 0;
-  while (nd != NULL) {
+  while (nd != nullptr) {
     void** buf = BufferNode::make_buffer_from_node(nd);
     os::snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Enqueued: %d", i);
     print_satb_buffer(buffer, buf, nd->index(), buffer_size());
@@ -337,10 +337,10 @@ void SATBMarkQueueSet::print_all(const char* msg) {
 void SATBMarkQueueSet::abandon_completed_buffers() {
   Atomic::store(&_count_and_process_flag, size_t(0));
   BufferNode* buffers_to_delete = _list.pop_all();
-  while (buffers_to_delete != NULL) {
+  while (buffers_to_delete != nullptr) {
     BufferNode* bn = buffers_to_delete;
     buffers_to_delete = bn->next();
-    bn->set_next(NULL);
+    bn->set_next(nullptr);
     deallocate_buffer(bn);
   }
 }
diff --git a/src/hotspot/share/gc/shared/satbMarkQueue.hpp b/src/hotspot/share/gc/shared/satbMarkQueue.hpp
index e663ecb8f70..4d54bf4ab0b 100644
--- a/src/hotspot/share/gc/shared/satbMarkQueue.hpp
+++ b/src/hotspot/share/gc/shared/satbMarkQueue.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -174,7 +174,7 @@ template<typename Filter>
 inline void SATBMarkQueueSet::apply_filter(Filter filter_out, SATBMarkQueue& queue) {
   void** buf = queue.buffer();
 
-  if (buf == NULL) {
+  if (buf == nullptr) {
     // nothing to do
     return;
   }
diff --git a/src/hotspot/share/gc/shared/scavengableNMethods.cpp b/src/hotspot/share/gc/shared/scavengableNMethods.cpp
index 24da9eda14f..ec9983da4a9 100644
--- a/src/hotspot/share/gc/shared/scavengableNMethods.cpp
+++ b/src/hotspot/share/gc/shared/scavengableNMethods.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@ static ScavengableNMethodsData gc_data(nmethod* nm) {
   return ScavengableNMethodsData(nm);
 }
 
-nmethod* ScavengableNMethods::_head = NULL;
-BoolObjectClosure* ScavengableNMethods::_is_scavengable = NULL;
+nmethod* ScavengableNMethods::_head = nullptr;
+BoolObjectClosure* ScavengableNMethods::_is_scavengable = nullptr;
 
 void ScavengableNMethods::initialize(BoolObjectClosure* is_scavengable) {
   _is_scavengable = is_scavengable;
@@ -62,8 +62,8 @@ void ScavengableNMethods::unregister_nmethod(nmethod* nm) {
   assert_locked_or_safepoint(CodeCache_lock);
 
   if (gc_data(nm).on_list()) {
-    nmethod* prev = NULL;
-    for (nmethod* cur = _head; cur != NULL; cur = gc_data(cur).next()) {
+    nmethod* prev = nullptr;
+    for (nmethod* cur = _head; cur != nullptr; cur = gc_data(cur).next()) {
       if (cur == nm) {
         unlist_nmethod(cur, prev);
         return;
@@ -87,7 +87,7 @@ class DebugScavengableOops: public OopClosure {
 
   bool ok() { return _ok; }
   virtual void do_oop(oop* p) {
-    if (*p == NULL || !_is_scavengable->do_object_b(*p)) {
+    if (*p == nullptr || !_is_scavengable->do_object_b(*p)) {
       return;
     }
 
@@ -127,7 +127,7 @@ class HasScavengableOops: public OopClosure {
 
   bool found() { return _found; }
   virtual void do_oop(oop* p) {
-    if (!_found && *p != NULL && _is_scavengable->do_object_b(*p)) {
+    if (!_found && *p != nullptr && _is_scavengable->do_object_b(*p)) {
       _found = true;
     }
   }
@@ -146,14 +146,14 @@ void ScavengableNMethods::nmethods_do_and_prune(CodeBlobToOopClosure* cl) {
 
   debug_only(mark_on_list_nmethods());
 
-  nmethod* prev = NULL;
+  nmethod* prev = nullptr;
   nmethod* cur = _head;
-  while (cur != NULL) {
+  while (cur != nullptr) {
     ScavengableNMethodsData data = gc_data(cur);
     debug_only(data.clear_marked());
     assert(data.on_list(), "else shouldn't be on this list");
 
-    if (cl != NULL) {
+    if (cl != nullptr) {
       cl->do_code_blob(cur);
     }
 
@@ -169,11 +169,11 @@ void ScavengableNMethods::nmethods_do_and_prune(CodeBlobToOopClosure* cl) {
   }
 
   // Check for stray marks.
-  debug_only(verify_unlisted_nmethods(NULL));
+  debug_only(verify_unlisted_nmethods(nullptr));
 }
 
 void ScavengableNMethods::prune_nmethods() {
-  nmethods_do_and_prune(NULL /* No closure */);
+  nmethods_do_and_prune(nullptr /* No closure */);
 }
 
 // Walk the list of methods which might contain oops to the java heap.
@@ -185,7 +185,7 @@ void ScavengableNMethods::nmethods_do(CodeBlobToOopClosure* cl) {
 void ScavengableNMethods::asserted_non_scavengable_nmethods_do(CodeBlobClosure* cl) {
   // While we are here, verify the integrity of the list.
   mark_on_list_nmethods();
-  for (nmethod* cur = _head; cur != NULL; cur = gc_data(cur).next()) {
+  for (nmethod* cur = _head; cur != nullptr; cur = gc_data(cur).next()) {
     assert(gc_data(cur).on_list(), "else shouldn't be on this list");
     gc_data(cur).clear_marked();
   }
@@ -196,17 +196,17 @@ void ScavengableNMethods::asserted_non_scavengable_nmethods_do(CodeBlobClosure*
 void ScavengableNMethods::unlist_nmethod(nmethod* nm, nmethod* prev) {
   assert_locked_or_safepoint(CodeCache_lock);
 
-  assert((prev == NULL && _head == nm) ||
-         (prev != NULL && gc_data(prev).next() == nm), "precondition");
+  assert((prev == nullptr && _head == nm) ||
+         (prev != nullptr && gc_data(prev).next() == nm), "precondition");
 
   ScavengableNMethodsData data = gc_data(nm);
 
-  if (prev == NULL) {
+  if (prev == nullptr) {
     _head = data.next();
   } else {
     gc_data(prev).set_next(data.next());
   }
-  data.set_next(NULL);
+  data.set_next(nullptr);
   data.clear_on_list();
 }
 
@@ -232,7 +232,7 @@ void ScavengableNMethods::verify_unlisted_nmethods(CodeBlobClosure* cl) {
 
     verify_nmethod(nm);
 
-    if (cl != NULL && !gc_data(nm).on_list()) {
+    if (cl != nullptr && !gc_data(nm).on_list()) {
       cl->do_code_blob(nm);
     }
   }
diff --git a/src/hotspot/share/gc/shared/softRefGenPolicy.cpp b/src/hotspot/share/gc/shared/softRefGenPolicy.cpp
index 8d512fc200c..1f09aaedfcc 100644
--- a/src/hotspot/share/gc/shared/softRefGenPolicy.cpp
+++ b/src/hotspot/share/gc/shared/softRefGenPolicy.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@ void SoftRefGenPolicy::cleared_all_soft_refs() {
   // have been cleared in the last collection but if the gc overhear
   // limit continues to be near, SoftRefs should still be cleared.
   AdaptiveSizePolicy* size_policy = GenCollectedHeap::heap()->size_policy();
-  if (size_policy != NULL) {
+  if (size_policy != nullptr) {
     set_should_clear_all_soft_refs(size_policy->gc_overhead_limit_near());
   }
 
diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp
index 5419ddd660e..02f37db55e0 100644
--- a/src/hotspot/share/gc/shared/space.cpp
+++ b/src/hotspot/share/gc/shared/space.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
 
 HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,
                                                 HeapWord* top_obj) {
-  if (top_obj != NULL && top_obj < (_sp->toContiguousSpace())->top()) {
+  if (top_obj != nullptr && top_obj < (_sp->toContiguousSpace())->top()) {
     if (cast_to_oop(top_obj)->is_objArray() || cast_to_oop(top_obj)->is_typeArray()) {
       // An arrayOop is starting on the dirty card - since we do exact
       // store checks for objArrays we are done.
@@ -94,7 +94,7 @@ void DirtyCardToOopClosure::do_MemRegion(MemRegion mr) {
   HeapWord* bottom_obj;
   HeapWord* top_obj;
 
-  assert(_last_bottom == NULL || top <= _last_bottom,
+  assert(_last_bottom == nullptr || top <= _last_bottom,
          "Not decreasing");
   NOT_PRODUCT(_last_bottom = mr.start());
 
@@ -110,7 +110,7 @@ void DirtyCardToOopClosure::do_MemRegion(MemRegion mr) {
   top = get_actual_top(top, top_obj);
 
   // If the previous call did some part of this region, don't redo.
-  if (_min_done != NULL && _min_done < top) {
+  if (_min_done != nullptr && _min_done < top) {
     top = _min_done;
   }
 
@@ -120,7 +120,7 @@ void DirtyCardToOopClosure::do_MemRegion(MemRegion mr) {
   bottom = MIN2(bottom, top);
   MemRegion extended_mr = MemRegion(bottom, top);
   assert(bottom <= top &&
-         (_min_done == NULL || top <= _min_done),
+         (_min_done == nullptr || top <= _min_done),
          "overlap!");
 
   // Walk the region if it is not empty; otherwise there is nothing to do.
@@ -168,7 +168,7 @@ void Space::clear(bool mangle_space) {
   }
 }
 
-ContiguousSpace::ContiguousSpace(): CompactibleSpace(), _top(NULL) {
+ContiguousSpace::ContiguousSpace(): CompactibleSpace(), _top(nullptr) {
   _mangler = new GenSpaceMangler(this);
 }
 
@@ -244,7 +244,7 @@ void CompactibleSpace::initialize(MemRegion mr,
                                   bool mangle_space) {
   Space::initialize(mr, clear_space, mangle_space);
   set_compaction_top(bottom());
-  _next_compaction_space = NULL;
+  _next_compaction_space = nullptr;
 }
 
 void CompactibleSpace::clear(bool mangle_space) {
@@ -262,11 +262,11 @@ HeapWord* CompactibleSpace::forward(oop q, size_t size,
     // switch to next compaction space
     cp->space->set_compaction_top(compact_top);
     cp->space = cp->space->next_compaction_space();
-    if (cp->space == NULL) {
+    if (cp->space == nullptr) {
       cp->gen = GenCollectedHeap::heap()->young_gen();
-      assert(cp->gen != NULL, "compaction must succeed");
+      assert(cp->gen != nullptr, "compaction must succeed");
       cp->space = cp->gen->first_compaction_space();
-      assert(cp->space != NULL, "generation must have a first compaction space");
+      assert(cp->space != nullptr, "generation must have a first compaction space");
     }
     compact_top = cp->space->bottom();
     cp->space->set_compaction_top(compact_top);
@@ -304,8 +304,8 @@ void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
   // space, so this is a good time to initialize this:
   set_compaction_top(bottom());
 
-  if (cp->space == NULL) {
-    assert(cp->gen != NULL, "need a generation");
+  if (cp->space == nullptr) {
+    assert(cp->gen != nullptr, "need a generation");
     assert(cp->gen->first_compaction_space() == this, "just checking");
     cp->space = cp->gen->first_compaction_space();
     cp->space->initialize_threshold();
@@ -317,7 +317,7 @@ void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
   DeadSpacer dead_spacer(this);
 
   HeapWord*  end_of_live = bottom();  // One byte beyond the last byte of the last live object.
-  HeapWord*  first_dead = NULL; // The first dead object.
+  HeapWord*  first_dead = nullptr; // The first dead object.
 
   const intx interval = PrefetchScanIntervalInBytes;
 
@@ -354,7 +354,7 @@ void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
         *(HeapWord**)cur_obj = end;
 
         // see if this is the first dead region.
-        if (first_dead == NULL) {
+        if (first_dead == nullptr) {
           first_dead = cur_obj;
         }
       }
@@ -366,7 +366,7 @@ void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
 
   assert(cur_obj == scan_limit, "just checking");
   _end_of_live = end_of_live;
-  if (first_dead != NULL) {
+  if (first_dead != nullptr) {
     _first_dead = first_dead;
   } else {
     _first_dead = end_of_live;
@@ -393,7 +393,7 @@ void CompactibleSpace::adjust_pointers() {
 
   const intx interval = PrefetchScanIntervalInBytes;
 
-  debug_only(HeapWord* prev_obj = NULL);
+  debug_only(HeapWord* prev_obj = nullptr);
   while (cur_obj < end_of_live) {
     Prefetch::write(cur_obj, interval);
     if (cur_obj < first_dead || cast_to_oop(cur_obj)->is_gc_marked()) {
@@ -440,7 +440,7 @@ void CompactibleSpace::compact() {
     cur_obj = *(HeapWord**)(_first_dead);
   }
 
-  debug_only(HeapWord* prev_obj = NULL);
+  debug_only(HeapWord* prev_obj = nullptr);
   while (cur_obj < end_of_live) {
     if (!cast_to_oop(cur_obj)->is_forwarded()) {
       debug_only(prev_obj = cur_obj);
@@ -466,7 +466,7 @@ void CompactibleSpace::compact() {
       ContinuationGCSupport::transform_stack_chunk(new_obj);
 
       new_obj->init_mark();
-      assert(new_obj->klass() != NULL, "should have a class");
+      assert(new_obj->klass() != nullptr, "should have a class");
 
       debug_only(prev_obj = cur_obj);
       cur_obj += size;
@@ -511,7 +511,7 @@ void TenuredSpace::print_on(outputStream* st) const {
 void ContiguousSpace::verify() const {
   HeapWord* p = bottom();
   HeapWord* t = top();
-  HeapWord* prev_p = NULL;
+  HeapWord* prev_p = nullptr;
   while (p < t) {
     oopDesc::verify(cast_to_oop(p));
     prev_p = p;
@@ -608,7 +608,7 @@ inline HeapWord* ContiguousSpace::allocate_impl(size_t size) {
     assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
     return obj;
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -627,7 +627,7 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size) {
         return obj;
       }
     } else {
-      return NULL;
+      return nullptr;
     }
   } while (true);
 }
@@ -665,7 +665,7 @@ TenuredSpace::TenuredSpace(BlockOffsetSharedArray* sharedOffsetArray,
 
 void TenuredSpace::verify() const {
   HeapWord* p = bottom();
-  HeapWord* prev_p = NULL;
+  HeapWord* prev_p = nullptr;
   int objs = 0;
   int blocks = 0;
 
diff --git a/src/hotspot/share/gc/shared/space.hpp b/src/hotspot/share/gc/shared/space.hpp
index f07cade4561..ee6f04df93c 100644
--- a/src/hotspot/share/gc/shared/space.hpp
+++ b/src/hotspot/share/gc/shared/space.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,7 +77,7 @@ class Space: public CHeapObj<mtGC> {
   HeapWord* _saved_mark_word;
 
   Space():
-    _bottom(NULL), _end(NULL) { }
+    _bottom(nullptr), _end(nullptr) { }
 
  public:
   // Accessors
@@ -176,7 +176,7 @@ class Space: public CHeapObj<mtGC> {
   // If "p" is in the space, returns the address of the start of the
   // "block" that contains "p".  We say "block" instead of "object" since
   // some heaps may not pack objects densely; a chunk may either be an
-  // object or a non-object.  If "p" is not in the space, return NULL.
+  // object or a non-object.  If "p" is not in the space, return null.
   virtual HeapWord* block_start_const(const void* p) const = 0;
 
   // The non-const version may have benevolent side effects on the data
@@ -198,11 +198,11 @@ class Space: public CHeapObj<mtGC> {
   // the block is an object and the object is alive.
   virtual bool obj_is_alive(const HeapWord* addr) const;
 
-  // Allocation (return NULL if full).  Assumes the caller has established
+  // Allocation (return null if full).  Assumes the caller has established
   // mutually exclusive access to the space.
   virtual HeapWord* allocate(size_t word_size) = 0;
 
-  // Allocation (return NULL if full).  Enforces mutual exclusion internally.
+  // Allocation (return null if full).  Enforces mutual exclusion internally.
   virtual HeapWord* par_allocate(size_t word_size) = 0;
 
 #if INCLUDE_SERIALGC
@@ -217,9 +217,9 @@ class Space: public CHeapObj<mtGC> {
   virtual void print_short_on(outputStream* st) const;
 
 
-  // IF "this" is a ContiguousSpace, return it, else return NULL.
+  // IF "this" is a ContiguousSpace, return it, else return null.
   virtual ContiguousSpace* toContiguousSpace() {
-    return NULL;
+    return nullptr;
   }
 
   // Debugging
@@ -247,7 +247,7 @@ class DirtyCardToOopClosure: public MemRegionClosure {
                                 // imprecise write barrier; this is the
                                 // lowest location already done (or,
                                 // alternatively, the lowest address that
-                                // shouldn't be done again.  NULL means infinity.)
+                                // shouldn't be done again.  null means infinity.)
   NOT_PRODUCT(HeapWord* _last_bottom;)
 
   // Get the actual top of the area on which the closure will
@@ -278,8 +278,8 @@ class DirtyCardToOopClosure: public MemRegionClosure {
                                OopIterateClosure* cl);
 public:
   DirtyCardToOopClosure(Space* sp, OopIterateClosure* cl) :
-    _cl(cl), _sp(sp), _min_done(NULL) {
-    NOT_PRODUCT(_last_bottom = NULL);
+    _cl(cl), _sp(sp), _min_done(nullptr) {
+    NOT_PRODUCT(_last_bottom = nullptr);
   }
 
   void do_MemRegion(MemRegion mr) override;
@@ -292,8 +292,8 @@ class CompactPoint : public StackObj {
   Generation* gen;
   CompactibleSpace* space;
 
-  CompactPoint(Generation* g = NULL) :
-    gen(g), space(NULL) {}
+  CompactPoint(Generation* g = nullptr) :
+    gen(g), space(nullptr) {}
 };
 
 // A space that supports compaction operations.  This is usually, but not
@@ -314,7 +314,7 @@ class CompactibleSpace: public Space {
 
 public:
   CompactibleSpace() :
-   _compaction_top(NULL), _next_compaction_space(NULL) {}
+   _compaction_top(nullptr), _next_compaction_space(nullptr) {}
 
   void initialize(MemRegion mr, bool clear_space, bool mangle_space) override;
   void clear(bool mangle_space) override;
@@ -324,7 +324,7 @@ class CompactibleSpace: public Space {
   HeapWord* compaction_top() const { return _compaction_top;    }
 
   void set_compaction_top(HeapWord* value) {
-    assert(value == NULL || (value >= bottom() && value <= end()),
+    assert(value == nullptr || (value >= bottom() && value <= end()),
       "should point inside space");
     _compaction_top = value;
   }
@@ -409,7 +409,7 @@ class ContiguousSpace: public CompactibleSpace {
 
   GenSpaceMangler* mangler() { return _mangler; }
 
-  // Allocation helpers (return NULL if full).
+  // Allocation helpers (return null if full).
   inline HeapWord* allocate_impl(size_t word_size);
   inline HeapWord* par_allocate_impl(size_t word_size);
 
@@ -445,7 +445,7 @@ class ContiguousSpace: public CompactibleSpace {
   // Do some sparse checking on the area that should have been mangled.
   void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
   // Check the complete area that should have been mangled.
-  // This code may be NULL depending on the macro DEBUG_MANGLING.
+  // This code may be null depending on the macro DEBUG_MANGLING.
   void check_mangled_unused_area_complete() PRODUCT_RETURN;
 
   // Size computations: sizes in bytes.
@@ -458,7 +458,7 @@ class ContiguousSpace: public CompactibleSpace {
   // contain objects.
   MemRegion used_region() const override { return MemRegion(bottom(), top()); }
 
-  // Allocation (return NULL if full)
+  // Allocation (return null if full)
   HeapWord* allocate(size_t word_size) override;
   HeapWord* par_allocate(size_t word_size) override;
 
diff --git a/src/hotspot/share/gc/shared/space.inline.hpp b/src/hotspot/share/gc/shared/space.inline.hpp
index a2b3b67ed57..aa0526487b0 100644
--- a/src/hotspot/share/gc/shared/space.inline.hpp
+++ b/src/hotspot/share/gc/shared/space.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@ inline HeapWord* Space::block_start(const void* p) {
 #if INCLUDE_SERIALGC
 inline HeapWord* TenuredSpace::allocate(size_t size) {
   HeapWord* res = ContiguousSpace::allocate(size);
-  if (res != NULL) {
+  if (res != nullptr) {
     _offsets.alloc_block(res, size);
   }
   return res;
@@ -66,7 +66,7 @@ inline HeapWord* TenuredSpace::par_allocate(size_t size) {
   // above.  Perhaps in the future some lock-free manner of keeping the
   // coordination.
   HeapWord* res = ContiguousSpace::par_allocate(size);
-  if (res != NULL) {
+  if (res != nullptr) {
     _offsets.alloc_block(res, size);
   }
   return res;
@@ -137,7 +137,7 @@ inline void CompactibleSpace::verify_up_to_first_dead(SpaceType* space) {
      // we have a chunk of the space which hasn't moved and we've reinitialized
      // the mark word during the previous pass, so we can't use is_gc_marked for
      // the traversal.
-     HeapWord* prev_obj = NULL;
+     HeapWord* prev_obj = nullptr;
 
      while (cur_obj < space->_first_dead) {
        size_t size = cast_to_oop(cur_obj)->size();
@@ -172,7 +172,7 @@ template <typename OopClosureType>
 void ContiguousSpace::oop_since_save_marks_iterate(OopClosureType* blk) {
   HeapWord* t;
   HeapWord* p = saved_mark_word();
-  assert(p != NULL, "expected saved mark");
+  assert(p != nullptr, "expected saved mark");
 
   const intx interval = PrefetchScanIntervalInBytes;
   do {
diff --git a/src/hotspot/share/gc/shared/spaceDecorator.hpp b/src/hotspot/share/gc/shared/spaceDecorator.hpp
index 7ed4618117a..14ee14352d1 100644
--- a/src/hotspot/share/gc/shared/spaceDecorator.hpp
+++ b/src/hotspot/share/gc/shared/spaceDecorator.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,12 +83,12 @@ class SpaceMangler: public CHeapObj<mtGC> {
 
  public:
 
-  // Setting _top_for_allocations to NULL at initialization
+  // Setting _top_for_allocations to null at initialization
   // makes it always below top so that mangling done as part
   // of the initialize() call of a space does nothing (as it
   // should since the mangling is done as part of the constructor
   // for the space.
-  SpaceMangler() : _top_for_allocations(NULL) {}
+  SpaceMangler() : _top_for_allocations(nullptr) {}
 
   // Methods for top and end that delegate to the specific
   // space type.
diff --git a/src/hotspot/share/gc/shared/suspendibleThreadSet.cpp b/src/hotspot/share/gc/shared/suspendibleThreadSet.cpp
index fd8d672848b..163da887bb5 100644
--- a/src/hotspot/share/gc/shared/suspendibleThreadSet.cpp
+++ b/src/hotspot/share/gc/shared/suspendibleThreadSet.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@ uint          SuspendibleThreadSet::_nthreads_stopped  = 0;
 volatile bool SuspendibleThreadSet::_suspend_all       = false;
 double        SuspendibleThreadSet::_suspend_all_start = 0.0;
 
-static Semaphore* _synchronize_wakeup = NULL;
+static Semaphore* _synchronize_wakeup = nullptr;
 
 void SuspendibleThreadSet_init() {
-  assert(_synchronize_wakeup == NULL, "STS already initialized");
+  assert(_synchronize_wakeup == nullptr, "STS already initialized");
   _synchronize_wakeup = new Semaphore();
 }
 
diff --git a/src/hotspot/share/gc/shared/taskTerminator.cpp b/src/hotspot/share/gc/shared/taskTerminator.cpp
index f5345885c94..cd225699f37 100644
--- a/src/hotspot/share/gc/shared/taskTerminator.cpp
+++ b/src/hotspot/share/gc/shared/taskTerminator.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2018, 2020, Red Hat, Inc. All rights reserved.
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,14 +73,14 @@ TaskTerminator::TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
   _queue_set(queue_set),
   _offered_termination(0),
   _blocker(Mutex::nosafepoint, "TaskTerminator_lock"),
-  _spin_master(NULL) { }
+  _spin_master(nullptr) { }
 
 TaskTerminator::~TaskTerminator() {
   if (_offered_termination != 0) {
     assert(_offered_termination == _n_threads, "Must be terminated or aborted");
   }
 
-  assert(_spin_master == NULL, "Should have been reset");
+  assert(_spin_master == nullptr, "Should have been reset");
 }
 
 #ifdef ASSERT
@@ -93,7 +93,7 @@ void TaskTerminator::reset_for_reuse() {
   if (_offered_termination != 0) {
     assert(_offered_termination == _n_threads,
            "Only %u of %u threads offered termination", _offered_termination, _n_threads);
-    assert(_spin_master == NULL, "Leftover spin master " PTR_FORMAT, p2i(_spin_master));
+    assert(_spin_master == nullptr, "Leftover spin master " PTR_FORMAT, p2i(_spin_master));
     _offered_termination = 0;
   }
 }
@@ -104,7 +104,7 @@ void TaskTerminator::reset_for_reuse(uint n_threads) {
 }
 
 bool TaskTerminator::exit_termination(size_t tasks, TerminatorTerminator* terminator) {
-  return tasks > 0 || (terminator != NULL && terminator->should_exit_termination());
+  return tasks > 0 || (terminator != nullptr && terminator->should_exit_termination());
 }
 
 size_t TaskTerminator::tasks_in_queue_set() const {
@@ -117,7 +117,7 @@ void TaskTerminator::prepare_for_return(Thread* this_thread, size_t tasks) {
   assert(_offered_termination >= 1, "must be");
 
   if (_spin_master == this_thread) {
-    _spin_master = NULL;
+    _spin_master = nullptr;
   }
 
   if (tasks >= _offered_termination - 1) {
@@ -152,7 +152,7 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) {
   }
 
   for (;;) {
-    if (_spin_master == NULL) {
+    if (_spin_master == nullptr) {
       _spin_master = the_thread;
       DelayContext delay_context;
 
@@ -179,7 +179,7 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) {
         }
       }
       // Give up spin master before sleeping.
-      _spin_master = NULL;
+      _spin_master = nullptr;
     }
     bool timed_out = x.wait(WorkStealingSleepMillis);
 
diff --git a/src/hotspot/share/gc/shared/taskTerminator.hpp b/src/hotspot/share/gc/shared/taskTerminator.hpp
index 9b926e4a78f..79364555678 100644
--- a/src/hotspot/share/gc/shared/taskTerminator.hpp
+++ b/src/hotspot/share/gc/shared/taskTerminator.hpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2018, 2020, Red Hat, Inc. All rights reserved.
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -105,12 +105,12 @@ class TaskTerminator : public CHeapObj<mtGC> {
   // "false", available work has been observed in one of the task queues,
   // so the global task is not complete.
   bool offer_termination() {
-    return offer_termination(NULL);
+    return offer_termination(nullptr);
   }
 
   // As above, but it also terminates if the should_exit_termination()
   // method of the terminator parameter returns true. If terminator is
-  // NULL, then it is ignored.
+  // null, then it is ignored.
   bool offer_termination(TerminatorTerminator* terminator);
 
   // Reset the terminator, so that it may be reused again.
diff --git a/src/hotspot/share/gc/shared/taskqueue.cpp b/src/hotspot/share/gc/shared/taskqueue.cpp
index 43d354747da..61e2899b673 100644
--- a/src/hotspot/share/gc/shared/taskqueue.cpp
+++ b/src/hotspot/share/gc/shared/taskqueue.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -118,7 +118,7 @@ void TaskQueueStats::verify() const
 
 #ifdef ASSERT
 bool ObjArrayTask::is_valid() const {
-  return _obj != NULL && _obj->is_objArray() && _index >= 0 &&
+  return _obj != nullptr && _obj->is_objArray() && _index >= 0 &&
       _index < objArrayOop(_obj)->length();
 }
 #endif // ASSERT
diff --git a/src/hotspot/share/gc/shared/taskqueue.hpp b/src/hotspot/share/gc/shared/taskqueue.hpp
index 0c15c38a4d0..a5e3dfdf807 100644
--- a/src/hotspot/share/gc/shared/taskqueue.hpp
+++ b/src/hotspot/share/gc/shared/taskqueue.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -557,7 +557,7 @@ class TerminatorTerminator: public CHeapObj<mtInternal> {
 class ObjArrayTask
 {
 public:
-  ObjArrayTask(oop o = NULL, int idx = 0): _obj(o), _index(idx) { }
+  ObjArrayTask(oop o = nullptr, int idx = 0): _obj(o), _index(idx) { }
   ObjArrayTask(oop o, size_t idx): _obj(o), _index(int(idx)) {
     assert(idx <= size_t(max_jint), "too big");
   }
@@ -618,7 +618,7 @@ class ScannerTask {
   }
 
 public:
-  ScannerTask() : _p(NULL) {}
+  ScannerTask() : _p(nullptr) {}
 
   explicit ScannerTask(oop* p) : _p(encode(p, OopTag)) {}
 
diff --git a/src/hotspot/share/gc/shared/taskqueue.inline.hpp b/src/hotspot/share/gc/shared/taskqueue.inline.hpp
index f544a24d536..8faeb73cb8d 100644
--- a/src/hotspot/share/gc/shared/taskqueue.inline.hpp
+++ b/src/hotspot/share/gc/shared/taskqueue.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@ inline GenericTaskQueueSet<T, F>::GenericTaskQueueSet(uint n) : _n(n) {
   typedef T* GenericTaskQueuePtr;
   _queues = NEW_C_HEAP_ARRAY(GenericTaskQueuePtr, n, F);
   for (uint i = 0; i < n; i++) {
-    _queues[i] = NULL;
+    _queues[i] = nullptr;
   }
 }
 
diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp
index 98b0c2fdc07..14897bffafd 100644
--- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp
+++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,11 +42,11 @@ int          ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch = 0;
 unsigned int ThreadLocalAllocBuffer::_target_refills = 0;
 
 ThreadLocalAllocBuffer::ThreadLocalAllocBuffer() :
-  _start(NULL),
-  _top(NULL),
-  _pf_top(NULL),
-  _end(NULL),
-  _allocation_end(NULL),
+  _start(nullptr),
+  _top(nullptr),
+  _pf_top(nullptr),
+  _end(nullptr),
+  _allocation_end(nullptr),
   _desired_size(0),
   _refill_waste_limit(0),
   _allocated_before_last_gc(0),
@@ -66,7 +66,7 @@ size_t ThreadLocalAllocBuffer::min_size()                       { return align_o
 size_t ThreadLocalAllocBuffer::refill_waste_limit_increment()   { return TLABWasteIncrement; }
 
 size_t ThreadLocalAllocBuffer::remaining() {
-  if (end() == NULL) {
+  if (end() == nullptr) {
     return 0;
   }
 
@@ -117,14 +117,14 @@ void ThreadLocalAllocBuffer::accumulate_and_reset_statistics(ThreadLocalAllocSta
 }
 
 void ThreadLocalAllocBuffer::insert_filler() {
-  assert(end() != NULL, "Must not be retired");
+  assert(end() != nullptr, "Must not be retired");
   if (top() < hard_end()) {
     Universe::heap()->fill_with_dummy_object(top(), hard_end(), true);
   }
 }
 
 void ThreadLocalAllocBuffer::make_parsable() {
-  if (end() != NULL) {
+  if (end() != nullptr) {
     invariants();
     if (ZeroTLAB) {
       retire();
@@ -135,15 +135,15 @@ void ThreadLocalAllocBuffer::make_parsable() {
 }
 
 void ThreadLocalAllocBuffer::retire(ThreadLocalAllocStats* stats) {
-  if (stats != NULL) {
+  if (stats != nullptr) {
     accumulate_and_reset_statistics(stats);
   }
 
-  if (end() != NULL) {
+  if (end() != nullptr) {
     invariants();
     thread()->incr_allocated_bytes(used_bytes());
     insert_filler();
-    initialize(NULL, NULL, NULL);
+    initialize(nullptr, nullptr, nullptr);
   }
 }
 
@@ -206,9 +206,9 @@ void ThreadLocalAllocBuffer::initialize(HeapWord* start,
 }
 
 void ThreadLocalAllocBuffer::initialize() {
-  initialize(NULL,                    // start
-             NULL,                    // top
-             NULL);                   // end
+  initialize(nullptr,                    // start
+             nullptr,                    // top
+             nullptr);                   // end
 
   set_desired_size(initial_desired_size());
 
diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp
index 2b5c5ecca39..3b684808921 100644
--- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp
+++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -159,7 +159,7 @@ class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
   void make_parsable();
 
   // Retire an in-use tlab and optionally collect statistics.
-  void retire(ThreadLocalAllocStats* stats = NULL);
+  void retire(ThreadLocalAllocStats* stats = nullptr);
 
   // Retire in-use tlab before allocation of a new tlab
   void retire_before_allocation();
diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp
index 4cc7303ae49..3988134a8e9 100644
--- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp
+++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@ inline HeapWord* ThreadLocalAllocBuffer::allocate(size_t size) {
     invariants();
     return obj;
   }
-  return NULL;
+  return nullptr;
 }
 
 inline size_t ThreadLocalAllocBuffer::compute_size(size_t obj_size) {
diff --git a/src/hotspot/share/gc/shared/weakProcessor.inline.hpp b/src/hotspot/share/gc/shared/weakProcessor.inline.hpp
index edb1bf4471d..4b698996ce2 100644
--- a/src/hotspot/share/gc/shared/weakProcessor.inline.hpp
+++ b/src/hotspot/share/gc/shared/weakProcessor.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,13 +59,13 @@ class WeakProcessor::CountingClosure : public Closure {
 
   void do_oop(oop* p) {
     oop obj = *p;
-    if (obj == NULL) {
+    if (obj == nullptr) {
       ++_old_dead;
     } else if (_is_alive->do_object_b(obj)) {
       _keep_alive->do_oop(p);
       ++_live;
     } else {
-      *p = NULL;
+      *p = nullptr;
       ++_new_dead;
     }
   }
@@ -90,7 +90,7 @@ void WeakProcessor::Task::work(uint worker_id,
     assert(cur_state->storage() == OopStorageSet::storage(id), "invariant");
     cur_state->oops_do(&cl);
     cur_state->increment_num_dead(cl.dead());
-    if (_times != NULL) {
+    if (_times != nullptr) {
       _times->record_worker_items(worker_id, id, cl.new_dead(), cl.total());
     }
   }
diff --git a/src/hotspot/share/gc/shared/weakProcessorTimes.cpp b/src/hotspot/share/gc/shared/weakProcessorTimes.cpp
index ee9db87f2e6..48651603bf8 100644
--- a/src/hotspot/share/gc/shared/weakProcessorTimes.cpp
+++ b/src/hotspot/share/gc/shared/weakProcessorTimes.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@ WeakProcessorTimes::WeakProcessorTimes(uint max_threads) :
   for (auto id : EnumRange<OopStorageSet::WeakId>()) {
     assert(size_t(wpt - _worker_data) < ARRAY_SIZE(_worker_data), "invariant");
     const char* description = OopStorageSet::storage(id)->name();
-    *wpt = new WorkerDataArray<double>(NULL, description, _max_threads);
+    *wpt = new WorkerDataArray<double>(nullptr, description, _max_threads);
     (*wpt)->create_thread_work_items("Dead", DeadItems);
     (*wpt)->create_thread_work_items("Total", TotalItems);
     wpt++;
@@ -137,7 +137,7 @@ WeakProcessorTimeTracker::WeakProcessorTimeTracker(WeakProcessorTimes* times) :
 {}
 
 WeakProcessorTimeTracker::~WeakProcessorTimeTracker() {
-  if (_times != NULL) {
+  if (_times != nullptr) {
     Ticks end_time = Ticks::now();
     _times->record_total_time_sec(elapsed_time_sec(_start_time, end_time));
   }
@@ -151,13 +151,13 @@ WeakProcessorParTimeTracker::WeakProcessorParTimeTracker(WeakProcessorTimes* tim
   _worker_id(worker_id),
   _start_time(Ticks::now())
 {
-  assert(_times == NULL || worker_id < _times->active_workers(),
+  assert(_times == nullptr || worker_id < _times->active_workers(),
          "Invalid worker_id %u", worker_id);
 }
 
 
 WeakProcessorParTimeTracker::~WeakProcessorParTimeTracker() {
-  if (_times != NULL) {
+  if (_times != nullptr) {
     double time_sec = elapsed_time_sec(_start_time, Ticks::now());
     _times->record_worker_time_sec(_worker_id, _storage_id, time_sec);
   }
@@ -184,7 +184,7 @@ void WeakProcessorTimes::log_summary(OopStorageSet::WeakId id, uint indent) cons
 
   for (uint i = 0; i < worker_data(id)->MaxThreadWorkItems; i++) {
     WorkerDataArray<size_t>* work_items = worker_data(id)->thread_work_items(i);
-    if (work_items != NULL) {
+    if (work_items != nullptr) {
       ls.print("%s", indents[indent + 1]);
       work_items->print_summary_on(&ls, true);
       log_details(work_items, indent + 1);
diff --git a/src/hotspot/share/gc/shared/weakProcessorTimes.hpp b/src/hotspot/share/gc/shared/weakProcessorTimes.hpp
index 533dd731f68..7aab40cb838 100644
--- a/src/hotspot/share/gc/shared/weakProcessorTimes.hpp
+++ b/src/hotspot/share/gc/shared/weakProcessorTimes.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -78,7 +78,7 @@ class WeakProcessorTimes {
 };
 
 // Record total weak processor time and worker count in times.
-// Does nothing if times is NULL.
+// Does nothing if times is null.
 class WeakProcessorTimeTracker : StackObj {
   WeakProcessorTimes* _times;
   Ticks _start_time;
@@ -89,7 +89,7 @@ class WeakProcessorTimeTracker : StackObj {
 };
 
 // Record time contribution for the current thread.
-// Does nothing if times is NULL.
+// Does nothing if times is null.
 class WeakProcessorParTimeTracker : StackObj {
   WeakProcessorTimes* _times;
   OopStorageSet::WeakId _storage_id;
diff --git a/src/hotspot/share/gc/shared/workerDataArray.inline.hpp b/src/hotspot/share/gc/shared/workerDataArray.inline.hpp
index 283fb97af8d..5fcb1424db1 100644
--- a/src/hotspot/share/gc/shared/workerDataArray.inline.hpp
+++ b/src/hotspot/share/gc/shared/workerDataArray.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,14 @@
 
 template <typename T>
 WorkerDataArray<T>::WorkerDataArray(const char* short_name, const char* title, uint length) :
- _data(NULL),
+ _data(nullptr),
  _length(length),
  _short_name(short_name),
  _title(title) {
   assert(length > 0, "Must have some workers to store data for");
   _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);
   for (uint i = 0; i < MaxThreadWorkItems; i++) {
-    _thread_work_items[i] = NULL;
+    _thread_work_items[i] = nullptr;
   }
   reset();
 }
@@ -78,29 +78,29 @@ WorkerDataArray<T>::~WorkerDataArray() {
 template <typename T>
 void WorkerDataArray<T>::create_thread_work_items(const char* title, uint index, uint length_override) {
   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
-  assert(_thread_work_items[index] == NULL, "Tried to overwrite existing thread work item");
+  assert(_thread_work_items[index] == nullptr, "Tried to overwrite existing thread work item");
   uint length = length_override != 0 ? length_override : _length;
-  _thread_work_items[index] = new WorkerDataArray<size_t>(NULL, title, length);
+  _thread_work_items[index] = new WorkerDataArray<size_t>(nullptr, title, length);
 }
 
 template <typename T>
 void WorkerDataArray<T>::set_thread_work_item(uint worker_i, size_t value, uint index) {
   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
-  assert(_thread_work_items[index] != NULL, "No sub count");
+  assert(_thread_work_items[index] != nullptr, "No sub count");
   _thread_work_items[index]->set(worker_i, value);
 }
 
 template <typename T>
 void WorkerDataArray<T>::add_thread_work_item(uint worker_i, size_t value, uint index) {
   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
-  assert(_thread_work_items[index] != NULL, "No sub count");
+  assert(_thread_work_items[index] != nullptr, "No sub count");
   _thread_work_items[index]->add(worker_i, value);
 }
 
 template <typename T>
 void WorkerDataArray<T>::set_or_add_thread_work_item(uint worker_i, size_t value, uint index) {
   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
-  assert(_thread_work_items[index] != NULL, "No sub count");
+  assert(_thread_work_items[index] != nullptr, "No sub count");
   if (_thread_work_items[index]->get(worker_i) == _thread_work_items[index]->uninitialized()) {
     _thread_work_items[index]->set(worker_i, value);
   } else {
@@ -111,7 +111,7 @@ void WorkerDataArray<T>::set_or_add_thread_work_item(uint worker_i, size_t value
 template <typename T>
 size_t WorkerDataArray<T>::get_thread_work_item(uint worker_i, uint index) {
   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
-  assert(_thread_work_items[index] != NULL, "No sub count");
+  assert(_thread_work_items[index] != nullptr, "No sub count");
   return _thread_work_items[index]->get(worker_i);
 }
 
@@ -196,7 +196,7 @@ template <typename T>
 void WorkerDataArray<T>::reset() {
   set_all(uninitialized());
   for (uint i = 0; i < MaxThreadWorkItems; i++) {
-    if (_thread_work_items[i] != NULL) {
+    if (_thread_work_items[i] != nullptr) {
       _thread_work_items[i]->reset();
     }
   }
diff --git a/src/hotspot/share/gc/shared/workerThread.cpp b/src/hotspot/share/gc/shared/workerThread.cpp
index d303d8d404c..14f9c349d63 100644
--- a/src/hotspot/share/gc/shared/workerThread.cpp
+++ b/src/hotspot/share/gc/shared/workerThread.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 #include "runtime/os.hpp"
 
 WorkerTaskDispatcher::WorkerTaskDispatcher() :
-    _task(NULL),
+    _task(nullptr),
     _started(0),
     _not_finished(0),
     _start_semaphore(),
@@ -52,7 +52,7 @@ void WorkerTaskDispatcher::coordinator_distribute_task(WorkerTask* task, uint nu
 
   // No workers are allowed to read the state variables after the coordinator has been signaled.
   assert(_not_finished == 0, "%d not finished workers?", _not_finished);
-  _task = NULL;
+  _task = nullptr;
   _started = 0;
 }
 
@@ -95,14 +95,14 @@ void WorkerThreads::initialize_workers() {
 
 WorkerThread* WorkerThreads::create_worker(uint name_suffix) {
   if (is_init_completed() && InjectGCWorkerCreationFailure) {
-    return NULL;
+    return nullptr;
   }
 
   WorkerThread* const worker = new WorkerThread(_name, name_suffix, &_dispatcher);
 
   if (!os::create_thread(worker, os::gc_thread)) {
     delete worker;
-    return NULL;
+    return nullptr;
   }
 
   on_create_worker(worker);
@@ -119,7 +119,7 @@ uint WorkerThreads::set_active_workers(uint num_workers) {
 
   while (_created_workers < num_workers) {
     WorkerThread* const worker = create_worker(_created_workers);
-    if (worker == NULL) {
+    if (worker == nullptr) {
       log_error(gc, task)("Failed to create worker thread");
       break;
     }
diff --git a/src/hotspot/share/gc/shared/workerUtils.cpp b/src/hotspot/share/gc/shared/workerUtils.cpp
index a9b771a299f..41662092966 100644
--- a/src/hotspot/share/gc/shared/workerUtils.cpp
+++ b/src/hotspot/share/gc/shared/workerUtils.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -80,7 +80,7 @@ void WorkerThreadsBarrierSync::abort() {
 // SubTasksDone functions.
 
 SubTasksDone::SubTasksDone(uint n) :
-  _tasks(NULL), _n_tasks(n) {
+  _tasks(nullptr), _n_tasks(n) {
   _tasks = NEW_C_HEAP_ARRAY(bool, n, mtInternal);
   for (uint i = 0; i < _n_tasks; i++) {
     _tasks[i] = false;
diff --git a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp
index f4acf1664ce..cac0bc4d575 100644
--- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp
+++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp
@@ -51,11 +51,11 @@ void ShenandoahLoadReferenceBarrierStub::emit_code(LIR_Assembler* ce) {
 }
 
 ShenandoahBarrierSetC1::ShenandoahBarrierSetC1() :
-  _pre_barrier_c1_runtime_code_blob(NULL),
-  _load_reference_barrier_strong_rt_code_blob(NULL),
-  _load_reference_barrier_strong_native_rt_code_blob(NULL),
-  _load_reference_barrier_weak_rt_code_blob(NULL),
-  _load_reference_barrier_phantom_rt_code_blob(NULL) {}
+  _pre_barrier_c1_runtime_code_blob(nullptr),
+  _load_reference_barrier_strong_rt_code_blob(nullptr),
+  _load_reference_barrier_strong_native_rt_code_blob(nullptr),
+  _load_reference_barrier_weak_rt_code_blob(nullptr),
+  _load_reference_barrier_phantom_rt_code_blob(nullptr) {}
 
 void ShenandoahBarrierSetC1::pre_barrier(LIRGenerator* gen, CodeEmitInfo* info, DecoratorSet decorators, LIR_Opr addr_opr, LIR_Opr pre_val) {
   // First we test whether marking is in progress.
@@ -98,7 +98,7 @@ void ShenandoahBarrierSetC1::pre_barrier(LIRGenerator* gen, CodeEmitInfo* info,
       assert(addr_opr->is_register(), "must be");
       addr_opr = LIR_OprFact::address(new LIR_Address(addr_opr, T_OBJECT));
     }
-    slow = new ShenandoahPreBarrierStub(addr_opr, pre_val, pre_val_patch_code, info ? new CodeEmitInfo(info) : NULL);
+    slow = new ShenandoahPreBarrierStub(addr_opr, pre_val, pre_val_patch_code, info ? new CodeEmitInfo(info) : nullptr);
   } else {
     assert(addr_opr == LIR_OprFact::illegalOpr, "sanity");
     assert(pre_val->is_register(), "must be");
@@ -257,7 +257,7 @@ class C1ShenandoahPreBarrierCodeGenClosure : public StubAssemblerCodeGenClosure
   virtual OopMapSet* generate_code(StubAssembler* sasm) {
     ShenandoahBarrierSetAssembler* bs = (ShenandoahBarrierSetAssembler*)BarrierSet::barrier_set()->barrier_set_assembler();
     bs->generate_c1_pre_barrier_runtime_stub(sasm);
-    return NULL;
+    return nullptr;
   }
 };
 
@@ -271,7 +271,7 @@ class C1ShenandoahLoadReferenceBarrierCodeGenClosure : public StubAssemblerCodeG
   virtual OopMapSet* generate_code(StubAssembler* sasm) {
     ShenandoahBarrierSetAssembler* bs = (ShenandoahBarrierSetAssembler*)BarrierSet::barrier_set()->barrier_set_assembler();
     bs->generate_c1_load_reference_barrier_runtime_stub(sasm, _decorators);
-    return NULL;
+    return nullptr;
   }
 };
 
diff --git a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp
index e5e5ace430d..6ccb24e2541 100644
--- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp
+++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp
@@ -53,7 +53,7 @@ class ShenandoahPreBarrierStub: public CodeStub {
   // previous value is assumed to have already been loaded into pre_val.
   ShenandoahPreBarrierStub(LIR_Opr pre_val) :
     _do_load(false), _addr(LIR_OprFact::illegalOpr), _pre_val(pre_val),
-    _patch_code(lir_patch_none), _info(NULL)
+    _patch_code(lir_patch_none), _info(nullptr)
   {
     assert(_pre_val->is_register(), "should be a register");
   }
@@ -69,7 +69,7 @@ class ShenandoahPreBarrierStub: public CodeStub {
     if (_do_load) {
       // don't pass in the code emit info since it's processed in the fast
       // path
-      if (_info != NULL)
+      if (_info != nullptr)
         visitor->do_slow_case(_info);
       else
         visitor->do_slow_case();
@@ -142,7 +142,7 @@ class LIR_OpShenandoahCompareAndSwap : public LIR_Op {
 public:
   LIR_OpShenandoahCompareAndSwap(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
                                  LIR_Opr t1, LIR_Opr t2, LIR_Opr result)
-    : LIR_Op(lir_none, result, NULL)  // no info
+    : LIR_Op(lir_none, result, nullptr)  // no info
     , _addr(addr)
     , _cmp_value(cmp_value)
     , _new_value(new_value)
@@ -205,27 +205,27 @@ class ShenandoahBarrierSetC1 : public BarrierSetC1 {
   ShenandoahBarrierSetC1();
 
   CodeBlob* pre_barrier_c1_runtime_code_blob() {
-    assert(_pre_barrier_c1_runtime_code_blob != NULL, "");
+    assert(_pre_barrier_c1_runtime_code_blob != nullptr, "");
     return _pre_barrier_c1_runtime_code_blob;
   }
 
   CodeBlob* load_reference_barrier_strong_rt_code_blob() {
-    assert(_load_reference_barrier_strong_rt_code_blob != NULL, "");
+    assert(_load_reference_barrier_strong_rt_code_blob != nullptr, "");
     return _load_reference_barrier_strong_rt_code_blob;
   }
 
   CodeBlob* load_reference_barrier_strong_native_rt_code_blob() {
-    assert(_load_reference_barrier_strong_native_rt_code_blob != NULL, "");
+    assert(_load_reference_barrier_strong_native_rt_code_blob != nullptr, "");
     return _load_reference_barrier_strong_native_rt_code_blob;
   }
 
   CodeBlob* load_reference_barrier_weak_rt_code_blob() {
-    assert(_load_reference_barrier_weak_rt_code_blob != NULL, "");
+    assert(_load_reference_barrier_weak_rt_code_blob != nullptr, "");
     return _load_reference_barrier_weak_rt_code_blob;
   }
 
   CodeBlob* load_reference_barrier_phantom_rt_code_blob() {
-    assert(_load_reference_barrier_phantom_rt_code_blob != NULL, "");
+    assert(_load_reference_barrier_phantom_rt_code_blob != nullptr, "");
     return _load_reference_barrier_phantom_rt_code_blob;
   }
 
diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
index 785629fec9d..d4be3fbc384 100644
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
@@ -49,8 +49,8 @@ ShenandoahBarrierSetC2* ShenandoahBarrierSetC2::bsc2() {
 }
 
 ShenandoahBarrierSetC2State::ShenandoahBarrierSetC2State(Arena* comp_arena)
-  : _iu_barriers(new (comp_arena) GrowableArray<ShenandoahIUBarrierNode*>(comp_arena, 8,  0, NULL)),
-    _load_reference_barriers(new (comp_arena) GrowableArray<ShenandoahLoadReferenceBarrierNode*>(comp_arena, 8,  0, NULL)) {
+  : _iu_barriers(new (comp_arena) GrowableArray<ShenandoahIUBarrierNode*>(comp_arena, 8,  0, nullptr)),
+    _load_reference_barriers(new (comp_arena) GrowableArray<ShenandoahLoadReferenceBarrierNode*>(comp_arena, 8,  0, nullptr)) {
 }
 
 int ShenandoahBarrierSetC2State::iu_barriers_count() const {
@@ -108,7 +108,7 @@ bool ShenandoahBarrierSetC2::satb_can_remove_pre_barrier(GraphKit* kit, PhaseTra
     return false; // cannot unalias unless there are precise offsets
   }
 
-  if (alloc == NULL) {
+  if (alloc == nullptr) {
     return false; // No allocation found
   }
 
@@ -124,7 +124,7 @@ bool ShenandoahBarrierSetC2::satb_can_remove_pre_barrier(GraphKit* kit, PhaseTra
       intptr_t st_offset = 0;
       Node* st_base = AddPNode::Ideal_base_and_offset(st_adr, phase, st_offset);
 
-      if (st_base == NULL) {
+      if (st_base == nullptr) {
         break; // inscrutable pointer
       }
 
@@ -164,12 +164,12 @@ bool ShenandoahBarrierSetC2::satb_can_remove_pre_barrier(GraphKit* kit, PhaseTra
       // Make sure that we are looking at the same allocation site.
       // The alloc variable is guaranteed to not be null here from earlier check.
       if (alloc == st_alloc) {
-        // Check that the initialization is storing NULL so that no previous store
+        // Check that the initialization is storing null so that no previous store
         // has been moved up and directly write a reference
         Node* captured_store = st_init->find_captured_store(offset,
                                                             type2aelembytes(T_OBJECT),
                                                             phase);
-        if (captured_store == NULL || captured_store == st_init->zero_memory()) {
+        if (captured_store == nullptr || captured_store == st_init->zero_memory()) {
           return true;
         }
       }
@@ -200,9 +200,9 @@ void ShenandoahBarrierSetC2::satb_write_barrier_pre(GraphKit* kit,
 
   if (do_load) {
     // We need to generate the load of the previous value
-    assert(adr != NULL, "where are loading from?");
-    assert(pre_val == NULL, "loaded already?");
-    assert(val_type != NULL, "need a type");
+    assert(adr != nullptr, "where are loading from?");
+    assert(pre_val == nullptr, "loaded already?");
+    assert(val_type != nullptr, "need a type");
 
     if (ReduceInitialCardMarks
         && satb_can_remove_pre_barrier(kit, &kit->gvn(), adr, bt, alias_idx)) {
@@ -211,7 +211,7 @@ void ShenandoahBarrierSetC2::satb_write_barrier_pre(GraphKit* kit,
 
   } else {
     // In this case both val_type and alias_idx are unused.
-    assert(pre_val != NULL, "must be loaded already");
+    assert(pre_val != nullptr, "must be loaded already");
     // Nothing to be done if pre_val is null.
     if (pre_val->bottom_type() == TypePtr::NULL_PTR) return;
     assert(pre_val->bottom_type()->basic_type() == T_OBJECT, "or we shouldn't be here");
@@ -256,7 +256,7 @@ void ShenandoahBarrierSetC2::satb_write_barrier_pre(GraphKit* kit,
       pre_val = __ load(__ ctrl(), adr, val_type, bt, alias_idx);
     }
 
-    // if (pre_val != NULL)
+    // if (pre_val != nullptr)
     __ if_then(pre_val, BoolTest::ne, kit->null()); {
       Node* buffer  = __ load(__ ctrl(), buffer_adr, TypeRawPtr::NOTNULL, T_ADDRESS, Compile::AliasIdxRaw);
 
@@ -278,13 +278,13 @@ void ShenandoahBarrierSetC2::satb_write_barrier_pre(GraphKit* kit,
         const TypeFunc *tf = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type();
         __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), "shenandoah_wb_pre", pre_val, tls);
       } __ end_if();  // (!index)
-    } __ end_if();  // (pre_val != NULL)
+    } __ end_if();  // (pre_val != nullptr)
   } __ end_if();  // (!marking)
 
   // Final sync IdealKit and GraphKit.
   kit->final_sync(ideal);
 
-  if (ShenandoahSATBBarrier && adr != NULL) {
+  if (ShenandoahSATBBarrier && adr != nullptr) {
     Node* c = kit->control();
     Node* call = c->in(1)->in(1)->in(1)->in(0);
     assert(is_shenandoah_wb_pre_call(call), "shenandoah_wb_pre call expected");
@@ -371,7 +371,7 @@ void ShenandoahBarrierSetC2::insert_pre_barrier(GraphKit* kit, Node* base_oop, N
 
   // If offset is a constant, is it java_lang_ref_Reference::_reference_offset?
   const TypeX* otype = offset->find_intptr_t_type();
-  if (otype != NULL && otype->is_con() &&
+  if (otype != nullptr && otype->is_con() &&
       otype->get_con() != java_lang_ref_Reference::referent_offset()) {
     // Constant offset but not the reference_offset so just return
     return;
@@ -379,14 +379,14 @@ void ShenandoahBarrierSetC2::insert_pre_barrier(GraphKit* kit, Node* base_oop, N
 
   // We only need to generate the runtime guards for instances.
   const TypeOopPtr* btype = base_oop->bottom_type()->isa_oopptr();
-  if (btype != NULL) {
+  if (btype != nullptr) {
     if (btype->isa_aryptr()) {
       // Array type so nothing to do
       return;
     }
 
     const TypeInstPtr* itype = btype->isa_instptr();
-    if (itype != NULL) {
+    if (itype != nullptr) {
       // Can the klass of base_oop be statically determined to be
       // _not_ a sub-class of Reference and _not_ Object?
       ciKlass* klass = itype->instance_klass();
@@ -425,7 +425,7 @@ void ShenandoahBarrierSetC2::insert_pre_barrier(GraphKit* kit, Node* base_oop, N
       __ sync_kit(kit);
 
       Node* one = __ ConI(1);
-      // is_instof == 0 if base_oop == NULL
+      // is_instof == 0 if base_oop == nullptr
       __ if_then(is_instof, BoolTest::eq, one, unlikely); {
 
         // Update graphKit from IdeakKit.
@@ -433,7 +433,7 @@ void ShenandoahBarrierSetC2::insert_pre_barrier(GraphKit* kit, Node* base_oop, N
 
         // Use the pre-barrier to record the value in the referent field
         satb_write_barrier_pre(kit, false /* do_load */,
-                               NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */,
+                               nullptr /* obj */, nullptr /* adr */, max_juint /* alias_idx */, nullptr /* val */, nullptr /* val_type */,
                                pre_val /* pre_val */,
                                T_OBJECT);
         if (need_mem_bar) {
@@ -455,7 +455,7 @@ Node* ShenandoahBarrierSetC2::byte_map_base_node(GraphKit* kit) const {
   BarrierSet* bs = BarrierSet::barrier_set();
   ShenandoahBarrierSet* ctbs = barrier_set_cast<ShenandoahBarrierSet>(bs);
   CardTable::CardValue* card_table_base = ctbs->card_table()->byte_map_base();
-  if (card_table_base != NULL) {
+  if (card_table_base != nullptr) {
     return kit->makecon(TypeRawPtr::make((address)card_table_base));
   } else {
     return kit->null();
@@ -477,11 +477,11 @@ void ShenandoahBarrierSetC2::post_barrier(GraphKit* kit,
 
   ShenandoahBarrierSet* ctbs = barrier_set_cast<ShenandoahBarrierSet>(BarrierSet::barrier_set());
   CardTable* ct = ctbs->card_table();
-  // No store check needed if we're storing a NULL or an old object
+  // No store check needed if we're storing a nullptr or an old object
   // (latter case is probably a string constant). The concurrent
   // mark sweep garbage collector, however, needs to have all nonNull
   // oop updates flagged via card-marks.
-  if (val != NULL && val->is_Con()) {
+  if (val != nullptr && val->is_Con()) {
     // must be either an oop or NULL
     const Type* t = val->bottom_type();
     if (t == TypePtr::NULL_PTR || t == Type::TOP)
@@ -503,7 +503,7 @@ void ShenandoahBarrierSetC2::post_barrier(GraphKit* kit,
     adr = obj;
   }
   // (Else it's an array (or unknown), and we want more precise card marks.)
-  assert(adr != NULL, "");
+  assert(adr != nullptr, "");
 
   IdealKit ideal(kit, true);
 
@@ -605,7 +605,7 @@ Node* ShenandoahBarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue&
     value = shenandoah_iu_barrier(kit, value);
     val.set_node(value);
     shenandoah_write_barrier_pre(kit, true /* do_load */, /*kit->control(),*/ access.base(), adr, adr_idx, val.node(),
-                                 static_cast<const TypeOopPtr*>(val.type()), NULL /* pre_val */, access.type());
+                                 static_cast<const TypeOopPtr*>(val.type()), nullptr /* pre_val */, access.type());
 
     Node* result = BarrierSetC2::store_at_resolved(access, val);
 
@@ -640,7 +640,7 @@ Node* ShenandoahBarrierSetC2::load_at_resolved(C2Access& access, const Type* val
 
   // 2: apply LRB if needed
   if (ShenandoahBarrierSet::need_load_reference_barrier(decorators, type)) {
-    load = new ShenandoahLoadReferenceBarrierNode(NULL, load, decorators);
+    load = new ShenandoahLoadReferenceBarrierNode(nullptr, load, decorators);
     if (access.is_parse_access()) {
       load = static_cast<C2ParseAccess &>(access).kit()->gvn().transform(load);
     } else {
@@ -680,7 +680,7 @@ Node* ShenandoahBarrierSetC2::load_at_resolved(C2Access& access, const Type* val
     if (on_weak_ref) {
       // Use the pre-barrier to record the value in the referent field
       satb_write_barrier_pre(kit, false /* do_load */,
-                             NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */,
+                             nullptr /* obj */, nullptr /* adr */, max_juint /* alias_idx */, nullptr /* val */, nullptr /* val_type */,
                              load /* pre_val */, T_OBJECT);
       // Add memory barrier to prevent commoning reads from this field
       // across safepoint since GC can change its value.
@@ -701,14 +701,14 @@ Node* ShenandoahBarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess
   if (access.is_oop()) {
     new_val = shenandoah_iu_barrier(kit, new_val);
     shenandoah_write_barrier_pre(kit, false /* do_load */,
-                                 NULL, NULL, max_juint, NULL, NULL,
+                                 nullptr, nullptr, max_juint, nullptr, nullptr,
                                  expected_val /* pre_val */, T_OBJECT);
 
     MemNode::MemOrd mo = access.mem_node_mo();
     Node* mem = access.memory();
     Node* adr = access.addr().node();
     const TypePtr* adr_type = access.addr().type();
-    Node* load_store = NULL;
+    Node* load_store = nullptr;
 
 #ifdef _LP64
     if (adr->bottom_type()->is_ptr_to_narrowoop()) {
@@ -737,7 +737,7 @@ Node* ShenandoahBarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess
       load_store = kit->gvn().transform(new DecodeNNode(load_store, load_store->get_ptr_type()));
     }
 #endif
-    load_store = kit->gvn().transform(new ShenandoahLoadReferenceBarrierNode(NULL, load_store, access.decorators()));
+    load_store = kit->gvn().transform(new ShenandoahLoadReferenceBarrierNode(nullptr, load_store, access.decorators()));
     post_barrier(kit, kit->control(), access.raw_access(), access.base(), access.addr().node(), access.alias_idx(), new_val, T_OBJECT, true);
     return load_store;
   }
@@ -750,13 +750,13 @@ Node* ShenandoahBarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAcces
   if (access.is_oop()) {
     new_val = shenandoah_iu_barrier(kit, new_val);
     shenandoah_write_barrier_pre(kit, false /* do_load */,
-                                 NULL, NULL, max_juint, NULL, NULL,
+                                 nullptr, nullptr, max_juint, nullptr, nullptr,
                                  expected_val /* pre_val */, T_OBJECT);
     DecoratorSet decorators = access.decorators();
     MemNode::MemOrd mo = access.mem_node_mo();
     Node* mem = access.memory();
     bool is_weak_cas = (decorators & C2_WEAK_CMPXCHG) != 0;
-    Node* load_store = NULL;
+    Node* load_store = nullptr;
     Node* adr = access.addr().node();
 #ifdef _LP64
     if (adr->bottom_type()->is_ptr_to_narrowoop()) {
@@ -808,9 +808,9 @@ Node* ShenandoahBarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& acces
   }
   Node* result = BarrierSetC2::atomic_xchg_at_resolved(access, val, value_type);
   if (access.is_oop()) {
-    result = kit->gvn().transform(new ShenandoahLoadReferenceBarrierNode(NULL, result, access.decorators()));
+    result = kit->gvn().transform(new ShenandoahLoadReferenceBarrierNode(nullptr, result, access.decorators()));
     shenandoah_write_barrier_pre(kit, false /* do_load */,
-                                 NULL, NULL, max_juint, NULL, NULL,
+                                 nullptr, nullptr, max_juint, nullptr, nullptr,
                                  result /* pre_val */, T_OBJECT);
     post_barrier(kit, kit->control(), access.raw_access(), access.base(),
                  access.addr().node(), access.alias_idx(), val, T_OBJECT, true);
@@ -830,7 +830,7 @@ bool ShenandoahBarrierSetC2::is_gc_barrier_node(Node* node) const {
     return false;
   }
   CallLeafNode *call = node->as_CallLeaf();
-  if (call->_name == NULL) {
+  if (call->_name == nullptr) {
     return false;
   }
 
@@ -840,7 +840,7 @@ bool ShenandoahBarrierSetC2::is_gc_barrier_node(Node* node) const {
 }
 
 Node* ShenandoahBarrierSetC2::step_over_gc_barrier(Node* c) const {
-  if (c == NULL) {
+  if (c == nullptr) {
     return c;
   }
   if (c->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
@@ -889,7 +889,7 @@ bool ShenandoahBarrierSetC2::array_copy_requires_gc_barriers(bool tightly_couple
 
 bool ShenandoahBarrierSetC2::clone_needs_barrier(Node* src, PhaseGVN& gvn) {
   const TypeOopPtr* src_type = gvn.type(src)->is_oopptr();
-  if (src_type->isa_instptr() != NULL) {
+  if (src_type->isa_instptr() != nullptr) {
     ciInstanceKlass* ik = src_type->is_instptr()->instance_klass();
     if ((src_type->klass_is_exact() || !ik->has_subklass()) && !ik->has_injected_fields()) {
       if (ik->has_object_fields()) {
@@ -938,7 +938,7 @@ void ShenandoahBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCo
     Node* gc_state_addr = phase->transform_later(new AddPNode(phase->C->top(), thread, offset));
 
     uint gc_state_idx = Compile::AliasIdxRaw;
-    const TypePtr* gc_state_adr_type = NULL; // debug-mode-only argument
+    const TypePtr* gc_state_adr_type = nullptr; // debug-mode-only argument
     debug_only(gc_state_adr_type = phase->C->get_adr_type(gc_state_idx));
 
     Node* gc_state    = phase->transform_later(new LoadBNode(ctrl, mem, gc_state_addr, gc_state_adr_type, TypeInt::BYTE, MemNode::unordered));
@@ -979,7 +979,7 @@ void ShenandoahBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCo
     const char* name = "arraycopy";
     call = phase->make_leaf_call(ctrl, mem,
                                  OptoRuntime::fast_arraycopy_Type(),
-                                 phase->basictype2arraycopy(T_LONG, NULL, NULL, true, name, true),
+                                 phase->basictype2arraycopy(T_LONG, nullptr, nullptr, true, name, true),
                                  name, TypeRawPtr::BOTTOM,
                                  src, dest, length
                                  LP64_ONLY(COMMA phase->top()));
@@ -1111,7 +1111,7 @@ void ShenandoahBarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase p
     worklist.push(compile->root());
     while (worklist.size() > 0) {
       Node *x = worklist.pop();
-      if (x == NULL || x == compile->top()) continue;
+      if (x == nullptr || x == compile->top()) continue;
       if (visited.member(x)) {
         continue;
       } else {
@@ -1151,7 +1151,7 @@ void ShenandoahBarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase p
                     if_ctrl = if_ctrl->in(0)->in(0);
                   }
                 }
-                assert(load_ctrl != NULL && if_ctrl == load_ctrl, "controls must match");
+                assert(load_ctrl != nullptr && if_ctrl == load_ctrl, "controls must match");
               }
             }
           }
@@ -1180,7 +1180,7 @@ Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_resh
     Node* in1 = n->in(1);
     Node* in2 = n->in(2);
 
-    // If one input is NULL, then step over the strong LRB barriers on the other input
+    // If one input is null, then step over the strong LRB barriers on the other input
     if (in1->bottom_type() == TypePtr::NULL_PTR &&
         !((in2->Opcode() == Op_ShenandoahLoadReferenceBarrier) &&
           !ShenandoahBarrierSet::is_strong_access(((ShenandoahLoadReferenceBarrierNode*)in2)->decorators()))) {
@@ -1204,7 +1204,7 @@ Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_resh
   } else if (can_reshape &&
              n->Opcode() == Op_If &&
              ShenandoahBarrierC2Support::is_heap_stable_test(n) &&
-             n->in(0) != NULL &&
+             n->in(0) != nullptr &&
              n->outcnt() == 2) {
     Node* dom = n->in(0);
     Node* prev_dom = n;
@@ -1214,23 +1214,23 @@ Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_resh
     while (dom->Opcode() != op    ||  // Not same opcode?
            !ShenandoahBarrierC2Support::is_heap_stable_test(dom) ||  // Not same input 1?
            prev_dom->in(0) != dom) {  // One path of test does not dominate?
-      if (dist < 0) return NULL;
+      if (dist < 0) return nullptr;
 
       dist--;
       prev_dom = dom;
       dom = IfNode::up_one_dom(dom);
-      if (!dom) return NULL;
+      if (!dom) return nullptr;
     }
 
     // Check that we did not follow a loop back to ourselves
     if (n == dom) {
-      return NULL;
+      return nullptr;
     }
 
     return n->as_If()->dominated_by(prev_dom, phase->is_IterGVN());
   }
 
-  return NULL;
+  return nullptr;
 }
 
 bool ShenandoahBarrierSetC2::has_only_shenandoah_wb_pre_uses(Node* n) {
@@ -1328,7 +1328,7 @@ bool ShenandoahBarrierSetC2::escape_add_final_edges(ConnectionGraph* conn_graph,
     case Op_ShenandoahCompareAndExchangeP:
     case Op_ShenandoahCompareAndExchangeN: {
       Node *adr = n->in(MemNode::Address);
-      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, adr, NULL);
+      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, adr, nullptr);
       // fallthrough
     }
     case Op_ShenandoahCompareAndSwapP:
@@ -1337,10 +1337,10 @@ bool ShenandoahBarrierSetC2::escape_add_final_edges(ConnectionGraph* conn_graph,
     case Op_ShenandoahWeakCompareAndSwapN:
       return conn_graph->add_final_edges_unsafe_access(n, opcode);
     case Op_ShenandoahIUBarrier:
-      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(1), NULL);
+      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(1), nullptr);
       return true;
     case Op_ShenandoahLoadReferenceBarrier:
-      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(ShenandoahLoadReferenceBarrierNode::ValueIn), NULL);
+      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(ShenandoahLoadReferenceBarrierNode::ValueIn), nullptr);
       return true;
     default:
       // Nothing
diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
index 32efa25a78c..61b43ae41fe 100644
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
@@ -158,7 +158,7 @@ bool ShenandoahBarrierC2Support::verify_helper(Node* in, Node_Stack& phis, Vecto
 
   while (true) {
     if (in->bottom_type() == TypePtr::NULL_PTR) {
-      if (trace) {tty->print_cr("NULL");}
+      if (trace) {tty->print_cr("null");}
     } else if (!in->bottom_type()->make_ptr()->make_oopptr()) {
       if (trace) {tty->print_cr("Non oop");}
     } else {
@@ -265,10 +265,10 @@ bool ShenandoahBarrierC2Support::verify_helper(Node* in, Node_Stack& phis, Vecto
 }
 
 void ShenandoahBarrierC2Support::report_verify_failure(const char* msg, Node* n1, Node* n2) {
-  if (n1 != NULL) {
+  if (n1 != nullptr) {
     n1->dump(+10);
   }
-  if (n2 != NULL) {
+  if (n2 != nullptr) {
     n2->dump(+10);
   }
   fatal("%s", msg);
@@ -462,7 +462,7 @@ void ShenandoahBarrierC2Support::verify(RootNode* root) {
       };
 
       if (call->is_call_to_arraycopystub()) {
-        Node* dest = NULL;
+        Node* dest = nullptr;
         const TypeTuple* args = n->as_Call()->_tf->domain();
         for (uint i = TypeFunc::Parms, j = 0; i < args->cnt(); i++) {
           if (args->field_at(i)->isa_ptr()) {
@@ -597,7 +597,7 @@ void ShenandoahBarrierC2Support::verify(RootNode* root) {
           }
         }
         for (uint j = 1; j < stop; j++) {
-          if (n->in(j) != NULL && n->in(j)->bottom_type()->make_ptr() &&
+          if (n->in(j) != nullptr && n->in(j)->bottom_type()->make_ptr() &&
               n->in(j)->bottom_type()->make_ptr()->make_oopptr()) {
             uint k = 0;
             for (; k < inputs_len && others[i].inputs[k].pos != (int)j; k++);
@@ -608,7 +608,7 @@ void ShenandoahBarrierC2Support::verify(RootNode* root) {
         }
       } else {
         for (uint j = 1; j < stop; j++) {
-          if (n->in(j) != NULL && n->in(j)->bottom_type()->make_ptr() &&
+          if (n->in(j) != nullptr && n->in(j)->bottom_type()->make_ptr() &&
               n->in(j)->bottom_type()->make_ptr()->make_oopptr()) {
             fatal("%s not covered", n->Name());
           }
@@ -618,7 +618,7 @@ void ShenandoahBarrierC2Support::verify(RootNode* root) {
 
     if (n->is_SafePoint()) {
       SafePointNode* sfpt = n->as_SafePoint();
-      if (verify_no_useless_barrier && sfpt->jvms() != NULL) {
+      if (verify_no_useless_barrier && sfpt->jvms() != nullptr) {
         for (uint i = sfpt->jvms()->scloff(); i < sfpt->jvms()->endoff(); i++) {
           if (!verify_helper(sfpt->in(i), phis, visited, ShenandoahLoad, trace, barriers_used)) {
             phis.clear();
@@ -667,7 +667,7 @@ bool ShenandoahBarrierC2Support::is_dominator_same_ctrl(Node* c, Node* d, Node*
         }
       }
       for (uint i = 0; i < m->req(); i++) {
-        if (m->in(i) != NULL && phase->ctrl_or_self(m->in(i)) == c) {
+        if (m->in(i) != nullptr && phase->ctrl_or_self(m->in(i)) == c) {
           wq.push(m->in(i));
         }
       }
@@ -684,7 +684,7 @@ bool ShenandoahBarrierC2Support::is_dominator(Node* d_c, Node* n_c, Node* d, Nod
 }
 
 Node* next_mem(Node* mem, int alias) {
-  Node* res = NULL;
+  Node* res = nullptr;
   if (mem->is_Proj()) {
     res = mem->in(0);
   } else if (mem->is_SafePoint() || mem->is_MemBar()) {
@@ -706,7 +706,7 @@ Node* next_mem(Node* mem, int alias) {
 }
 
 Node* ShenandoahBarrierC2Support::no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase) {
-  Node* iffproj = NULL;
+  Node* iffproj = nullptr;
   while (c != dom) {
     Node* next = phase->idom(c);
     assert(next->unique_ctrl_out_or_null() == c || c->is_Proj() || c->is_Region(), "multiple control flow out but no proj or region?");
@@ -743,13 +743,13 @@ Node* ShenandoahBarrierC2Support::no_branches(Node* c, Node* dom, bool allow_one
       }
     } else  if (c->is_Proj()) {
       if (c->is_IfProj()) {
-        if (c->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) != NULL) {
+        if (c->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) != nullptr) {
           // continue;
         } else {
           if (!allow_one_proj) {
             return NodeSentinel;
           }
-          if (iffproj == NULL) {
+          if (iffproj == nullptr) {
             iffproj = c;
           } else {
             return NodeSentinel;
@@ -778,7 +778,7 @@ Node* ShenandoahBarrierC2Support::dom_mem(Node* mem, Node* ctrl, int alias, Node
   while (!phase->is_dominator(mem_ctrl, ctrl) || mem_ctrl == ctrl) {
     mem = next_mem(mem, alias);
     if (wq.test_set(mem->_idx)) {
-      return NULL;
+      return nullptr;
     }
     mem_ctrl = phase->ctrl_or_self(mem);
   }
@@ -790,11 +790,11 @@ Node* ShenandoahBarrierC2Support::dom_mem(Node* mem, Node* ctrl, int alias, Node
 }
 
 Node* ShenandoahBarrierC2Support::find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase) {
-  Node* mem = NULL;
+  Node* mem = nullptr;
   Node* c = ctrl;
   do {
     if (c->is_Region()) {
-      for (DUIterator_Fast imax, i = c->fast_outs(imax); i < imax && mem == NULL; i++) {
+      for (DUIterator_Fast imax, i = c->fast_outs(imax); i < imax && mem == nullptr; i++) {
         Node* u = c->fast_out(i);
         if (u->is_Phi() && u->bottom_type() == Type::MEMORY) {
           if (u->adr_type() == TypePtr::BOTTOM) {
@@ -803,12 +803,12 @@ Node* ShenandoahBarrierC2Support::find_bottom_mem(Node* ctrl, PhaseIdealLoop* ph
         }
       }
     } else {
-      if (c->is_Call() && c->as_Call()->adr_type() != NULL) {
+      if (c->is_Call() && c->as_Call()->adr_type() != nullptr) {
         CallProjections projs;
         c->as_Call()->extract_projections(&projs, true, false);
-        if (projs.fallthrough_memproj != NULL) {
+        if (projs.fallthrough_memproj != nullptr) {
           if (projs.fallthrough_memproj->adr_type() == TypePtr::BOTTOM) {
-            if (projs.catchall_memproj == NULL) {
+            if (projs.catchall_memproj == nullptr) {
               mem = projs.fallthrough_memproj;
             } else {
               if (phase->is_dominator(projs.fallthrough_catchproj, ctrl)) {
@@ -821,7 +821,7 @@ Node* ShenandoahBarrierC2Support::find_bottom_mem(Node* ctrl, PhaseIdealLoop* ph
           }
         } else {
           Node* proj = c->as_Call()->proj_out(TypeFunc::Memory);
-          if (proj != NULL &&
+          if (proj != nullptr &&
               proj->adr_type() == TypePtr::BOTTOM) {
             mem = proj;
           }
@@ -833,15 +833,15 @@ Node* ShenandoahBarrierC2Support::find_bottom_mem(Node* ctrl, PhaseIdealLoop* ph
               u->bottom_type() == Type::MEMORY &&
               u->adr_type() == TypePtr::BOTTOM) {
               assert(c->is_SafePoint() || c->is_MemBar() || c->is_Start(), "");
-              assert(mem == NULL, "only one proj");
+              assert(mem == nullptr, "only one proj");
               mem = u;
           }
         }
-        assert(!c->is_Call() || c->as_Call()->adr_type() != NULL || mem == NULL, "no mem projection expected");
+        assert(!c->is_Call() || c->as_Call()->adr_type() != nullptr || mem == nullptr, "no mem projection expected");
       }
     }
     c = phase->idom(c);
-  } while (mem == NULL);
+  } while (mem == nullptr);
   return mem;
 }
 
@@ -874,7 +874,7 @@ void ShenandoahBarrierC2Support::test_gc_state(Node*& ctrl, Node* raw_mem, Node*
   Node* gc_state_offset = igvn.MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
   Node* gc_state_addr   = new AddPNode(phase->C->top(), thread, gc_state_offset);
   Node* gc_state        = new LoadBNode(old_ctrl, raw_mem, gc_state_addr,
-                                        DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(NULL),
+                                        DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(nullptr),
                                         TypeInt::BYTE, MemNode::unordered);
   Node* gc_state_and    = new AndINode(gc_state, igvn.intcon(flags));
   Node* gc_state_cmp    = new CmpINode(gc_state_and, igvn.zerocon(T_INT));
@@ -940,7 +940,7 @@ void ShenandoahBarrierC2Support::test_in_cset(Node*& ctrl, Node*& not_cset_ctrl,
   Node* cset_load_ptr  = new CastX2PNode(cset_load_addr);
 
   Node* cset_load      = new LoadBNode(old_ctrl, raw_mem, cset_load_ptr,
-                                       DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(NULL),
+                                       DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(nullptr),
                                        TypeInt::BYTE, MemNode::unordered);
   Node* cset_cmp       = new CmpINode(cset_load, igvn.zerocon(T_INT));
   Node* cset_bool      = new BoolNode(cset_cmp, BoolTest::ne);
@@ -971,8 +971,8 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo
   IdealLoopTree*loop = phase->get_loop(ctrl);
   const TypePtr* obj_type = phase->igvn().type(val)->is_oopptr();
 
-  address calladdr = NULL;
-  const char* name = NULL;
+  address calladdr = nullptr;
+  const char* name = nullptr;
   bool is_strong  = ShenandoahBarrierSet::is_strong_access(decorators);
   bool is_weak    = ShenandoahBarrierSet::is_weak_access(decorators);
   bool is_phantom = ShenandoahBarrierSet::is_phantom_access(decorators);
@@ -1041,7 +1041,7 @@ void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const Mem
     Node *n = uses_to_ignore.at(next);
     for (uint i = 0; i < n->req(); i++) {
       Node* in = n->in(i);
-      if (in != NULL && phase->has_ctrl(in) && phase->get_ctrl(in) == ctrl) {
+      if (in != nullptr && phase->has_ctrl(in) && phase->get_ctrl(in) == ctrl) {
         uses_to_ignore.push(in);
       }
     }
@@ -1076,14 +1076,14 @@ void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const Mem
 }
 
 static Node* create_phis_on_call_return(Node* ctrl, Node* c, Node* n, Node* n_clone, const CallProjections& projs, PhaseIdealLoop* phase) {
-  Node* region = NULL;
+  Node* region = nullptr;
   while (c != ctrl) {
     if (c->is_Region()) {
       region = c;
     }
     c = phase->idom(c);
   }
-  assert(region != NULL, "");
+  assert(region != nullptr, "");
   Node* phi = new PhiNode(region, n->bottom_type());
   for (uint j = 1; j < region->req(); j++) {
     Node* in = region->in(j);
@@ -1125,14 +1125,14 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
     Node* ctrl = phase->get_ctrl(lrb);
     Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn);
 
-    CallStaticJavaNode* unc = NULL;
-    Node* unc_ctrl = NULL;
+    CallStaticJavaNode* unc = nullptr;
+    Node* unc_ctrl = nullptr;
     Node* uncasted_val = val;
 
     for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) {
       Node* u = lrb->fast_out(i);
       if (u->Opcode() == Op_CastPP &&
-          u->in(0) != NULL &&
+          u->in(0) != nullptr &&
           phase->is_dominator(u->in(0), ctrl)) {
         const Type* u_t = phase->igvn().type(u);
 
@@ -1153,7 +1153,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
           }
 
           Node* branch = no_branches(ctrl, u->in(0), false, phase);
-          assert(branch == NULL || branch == NodeSentinel, "was not looking for a branch");
+          assert(branch == nullptr || branch == NodeSentinel, "was not looking for a branch");
           if (branch == NodeSentinel) {
             continue;
           }
@@ -1184,7 +1184,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
           if (idx < n->req()) {
             Node* in = n->in(idx);
             stack.set_index(idx+1);
-            if (in != NULL) {
+            if (in != nullptr) {
               if (phase->has_ctrl(in)) {
                 if (phase->is_dominator(call, phase->get_ctrl(in))) {
 #ifdef ASSERT
@@ -1337,15 +1337,15 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
     Node* orig_ctrl = ctrl;
 
     Node* raw_mem = fixer.find_mem(ctrl, lrb);
-    Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL);
+    Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, nullptr);
 
     IdealLoopTree *loop = phase->get_loop(ctrl);
 
-    Node* heap_stable_ctrl = NULL;
-    Node* null_ctrl = NULL;
+    Node* heap_stable_ctrl = nullptr;
+    Node* null_ctrl = nullptr;
 
     assert(val->bottom_type()->make_oopptr(), "need oop");
-    assert(val->bottom_type()->make_oopptr()->const_oop() == NULL, "expect non-constant");
+    assert(val->bottom_type()->make_oopptr()->const_oop() == nullptr, "expect non-constant");
 
     enum { _heap_stable = 1, _evac_path, _not_cset, PATH_LIMIT };
     Node* region = new RegionNode(PATH_LIMIT);
@@ -1363,14 +1363,14 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
     region->init_req(_heap_stable, heap_stable_ctrl);
     val_phi->init_req(_heap_stable, val);
 
-    // Test for in-cset, unless it's a native-LRB. Native LRBs need to return NULL
+    // Test for in-cset, unless it's a native-LRB. Native LRBs need to return null
     // even for non-cset objects to prevent resurrection of such objects.
     // Wires !in_cset(obj) to slot 2 of region and phis
-    Node* not_cset_ctrl = NULL;
+    Node* not_cset_ctrl = nullptr;
     if (ShenandoahBarrierSet::is_strong_access(lrb->decorators())) {
       test_in_cset(ctrl, not_cset_ctrl, val, raw_mem, phase);
     }
-    if (not_cset_ctrl != NULL) {
+    if (not_cset_ctrl != nullptr) {
       region->init_req(_not_cset, not_cset_ctrl);
       val_phi->init_req(_not_cset, val);
     } else {
@@ -1382,7 +1382,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
     // Make the unconditional resolve for fwdptr.
 
     // Call lrb-stub and wire up that path in slots 4
-    Node* result_mem = NULL;
+    Node* result_mem = nullptr;
 
     Node* addr;
     if (ShenandoahSelfFixing) {
@@ -1469,9 +1469,9 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
     IdealLoopTree* loop = phase->get_loop(ctrl);
     Node* raw_mem = fixer.find_mem(ctrl, barrier);
     Node* init_raw_mem = raw_mem;
-    Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL);
-    Node* heap_stable_ctrl = NULL;
-    Node* null_ctrl = NULL;
+    Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, nullptr);
+    Node* heap_stable_ctrl = nullptr;
+    Node* null_ctrl = nullptr;
     uint last = phase->C->unique();
 
     enum { _heap_stable = 1, _heap_unstable, PATH_LIMIT };
@@ -1488,9 +1488,9 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
     phi->init_req(_heap_stable, raw_mem);
 
     // Null path
-    Node* reg2_ctrl = NULL;
+    Node* reg2_ctrl = nullptr;
     test_null(ctrl, pre_val, null_ctrl, phase);
-    if (null_ctrl != NULL) {
+    if (null_ctrl != nullptr) {
       reg2_ctrl = null_ctrl->in(0);
       region2->init_req(_null_path, null_ctrl);
       phi2->init_req(_null_path, raw_mem);
@@ -1518,7 +1518,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
     Node* index_test = new BoolNode(index_cmp, BoolTest::ne);
     phase->register_new_node(index_test, ctrl);
     IfNode* queue_full_iff = new IfNode(ctrl, index_test, PROB_LIKELY(0.999), COUNT_UNKNOWN);
-    if (reg2_ctrl == NULL) reg2_ctrl = queue_full_iff;
+    if (reg2_ctrl == nullptr) reg2_ctrl = queue_full_iff;
     phase->register_control(queue_full_iff, loop, ctrl);
     Node* not_full = new IfTrueNode(queue_full_iff);
     phase->register_control(not_full, loop, queue_full_iff);
@@ -1598,7 +1598,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
 
 Node* ShenandoahBarrierC2Support::get_load_addr(PhaseIdealLoop* phase, VectorSet& visited, Node* in) {
   if (visited.test_set(in->_idx)) {
-    return NULL;
+    return nullptr;
   }
   switch (in->Opcode()) {
     case Op_Proj:
@@ -1625,17 +1625,17 @@ Node* ShenandoahBarrierC2Support::get_load_addr(PhaseIdealLoop* phase, VectorSet
       Node* t = get_load_addr(phase, visited, in->in(CMoveNode::IfTrue));
       Node* f = get_load_addr(phase, visited, in->in(CMoveNode::IfFalse));
       // Handle unambiguous cases: single address reported on both branches.
-      if (t != NULL && f == NULL) return t;
-      if (t == NULL && f != NULL) return f;
-      if (t != NULL && t == f)    return t;
+      if (t != nullptr && f == nullptr) return t;
+      if (t == nullptr && f != nullptr) return f;
+      if (t != nullptr && t == f)    return t;
       // Ambiguity.
       return phase->igvn().zerocon(T_OBJECT);
     }
     case Op_Phi: {
-      Node* addr = NULL;
+      Node* addr = nullptr;
       for (uint i = 1; i < in->req(); i++) {
         Node* addr1 = get_load_addr(phase, visited, in->in(i));
-        if (addr == NULL) {
+        if (addr == nullptr) {
           addr = addr1;
         }
         if (addr != addr1) {
@@ -1677,7 +1677,7 @@ void ShenandoahBarrierC2Support::move_gc_state_test_out_of_loop(IfNode* iff, Pha
 
   assert(is_gc_state_load(load), "broken");
   if (!phase->is_dominator(load->in(0), entry_c)) {
-    Node* mem_ctrl = NULL;
+    Node* mem_ctrl = nullptr;
     Node* mem = dom_mem(load->in(MemNode::Memory), loop_head, Compile::AliasIdxRaw, mem_ctrl, phase);
     load = load->clone();
     load->set_req(MemNode::Memory, mem);
@@ -1771,7 +1771,7 @@ void ShenandoahBarrierC2Support::merge_back_to_back_tests(Node* n, PhaseIdealLoo
 IfNode* ShenandoahBarrierC2Support::find_unswitching_candidate(const IdealLoopTree* loop, PhaseIdealLoop* phase) {
   // Find first invariant test that doesn't exit the loop
   LoopNode *head = loop->_head->as_Loop();
-  IfNode* unswitch_iff = NULL;
+  IfNode* unswitch_iff = nullptr;
   Node* n = head->in(LoopNode::LoopBackControl);
   int loop_has_sfpts = -1;
   while (n != head) {
@@ -1846,14 +1846,14 @@ void ShenandoahBarrierC2Support::optimize_after_expansion(VectorSet &visited, No
       Node* n = heap_stable_tests.at(i);
       IdealLoopTree* loop = phase->get_loop(n);
       if (loop != phase->ltree_root() &&
-          loop->_child == NULL &&
+          loop->_child == nullptr &&
           !loop->_irreducible) {
         Node* head = loop->_head;
         if (head->is_Loop() &&
             (!head->is_CountedLoop() || head->as_CountedLoop()->is_main_loop() || head->as_CountedLoop()->is_normal_loop()) &&
             !seen.test_set(head->_idx)) {
           IfNode* iff = find_unswitching_candidate(loop, phase);
-          if (iff != NULL) {
+          if (iff != nullptr) {
             Node* bol = iff->in(1);
             if (head->as_Loop()->is_strip_mined()) {
               head->as_Loop()->verify_strip_mined(0);
@@ -1880,12 +1880,12 @@ void ShenandoahBarrierC2Support::optimize_after_expansion(VectorSet &visited, No
   }
 }
 
-ShenandoahIUBarrierNode::ShenandoahIUBarrierNode(Node* val) : Node(NULL, val) {
+ShenandoahIUBarrierNode::ShenandoahIUBarrierNode(Node* val) : Node(nullptr, val) {
   ShenandoahBarrierSetC2::bsc2()->state()->add_iu_barrier(this);
 }
 
 const Type* ShenandoahIUBarrierNode::bottom_type() const {
-  if (in(1) == NULL || in(1)->is_top()) {
+  if (in(1) == nullptr || in(1)->is_top()) {
     return Type::TOP;
   }
   const Type* t = in(1)->bottom_type();
@@ -1896,7 +1896,7 @@ const Type* ShenandoahIUBarrierNode::bottom_type() const {
 }
 
 const Type* ShenandoahIUBarrierNode::Value(PhaseGVN* phase) const {
-  if (in(1) == NULL) {
+  if (in(1) == nullptr) {
     return Type::TOP;
   }
   const Type* t = phase->type(in(1));
@@ -1910,11 +1910,11 @@ const Type* ShenandoahIUBarrierNode::Value(PhaseGVN* phase) const {
 }
 
 int ShenandoahIUBarrierNode::needed(Node* n) {
-  if (n == NULL ||
+  if (n == nullptr ||
       n->is_Allocate() ||
       n->Opcode() == Op_ShenandoahIUBarrier ||
       n->bottom_type() == TypePtr::NULL_PTR ||
-      (n->bottom_type()->make_oopptr() != NULL && n->bottom_type()->make_oopptr()->const_oop() != NULL)) {
+      (n->bottom_type()->make_oopptr() != nullptr && n->bottom_type()->make_oopptr()->const_oop() != nullptr)) {
     return NotNeeded;
   }
   if (n->is_Phi() ||
@@ -1926,11 +1926,11 @@ int ShenandoahIUBarrierNode::needed(Node* n) {
 
 Node* ShenandoahIUBarrierNode::next(Node* n) {
   for (;;) {
-    if (n == NULL) {
+    if (n == nullptr) {
       return n;
     } else if (n->bottom_type() == TypePtr::NULL_PTR) {
       return n;
-    } else if (n->bottom_type()->make_oopptr() != NULL && n->bottom_type()->make_oopptr()->const_oop() != NULL) {
+    } else if (n->bottom_type()->make_oopptr() != nullptr && n->bottom_type()->make_oopptr()->const_oop() != nullptr) {
       return n;
     } else if (n->is_ConstraintCast() ||
                n->Opcode() == Op_DecodeN ||
@@ -1943,7 +1943,7 @@ Node* ShenandoahIUBarrierNode::next(Node* n) {
     }
   }
   ShouldNotReachHere();
-  return NULL;
+  return nullptr;
 }
 
 Node* ShenandoahIUBarrierNode::Identity(PhaseGVN* phase) {
@@ -1956,7 +1956,7 @@ Node* ShenandoahIUBarrierNode::Identity(PhaseGVN* phase) {
   if (cont == NotNeeded) {
     return in(1);
   } else if (cont == MaybeNeeded) {
-    if (igvn == NULL) {
+    if (igvn == nullptr) {
       phase->record_for_igvn(this);
       return this;
     } else {
@@ -1968,7 +1968,7 @@ Node* ShenandoahIUBarrierNode::Identity(PhaseGVN* phase) {
         if (n->is_Phi()) {
           for (uint i = 1; i < n->req(); i++) {
             Node* m = n->in(i);
-            if (m != NULL) {
+            if (m != nullptr) {
               wq.push(m);
             }
           }
@@ -1979,7 +1979,7 @@ Node* ShenandoahIUBarrierNode::Identity(PhaseGVN* phase) {
           m = n->in(CMoveNode::IfTrue);
           wq.push(m);
         }
-        Node* orig_n = NULL;
+        Node* orig_n = nullptr;
         do {
           if (wq_i >= wq.size()) {
             return in(1);
@@ -2004,7 +2004,7 @@ Node* ShenandoahIUBarrierNode::Identity(PhaseGVN* phase) {
 static bool has_never_branch(Node* root) {
   for (uint i = 1; i < root->req(); i++) {
     Node* in = root->in(i);
-    if (in != NULL && in->Opcode() == Op_Halt && in->in(0)->is_Proj() && in->in(0)->in(0)->is_NeverBranch()) {
+    if (in != nullptr && in->Opcode() == Op_Halt && in->in(0)->is_Proj() && in->in(0)->in(0)->is_NeverBranch()) {
       return true;
     }
   }
@@ -2025,7 +2025,7 @@ void MemoryGraphFixer::collect_memory_nodes() {
     int opc = n->Opcode();
     uint i = stack.index();
     if (i < n->req()) {
-      Node* mem = NULL;
+      Node* mem = nullptr;
       if (opc == Op_Root) {
         Node* in = n->in(i);
         int in_opc = in->Opcode();
@@ -2066,7 +2066,7 @@ void MemoryGraphFixer::collect_memory_nodes() {
       }
       i++;
       stack.set_index(i);
-      if (mem == NULL) {
+      if (mem == nullptr) {
         continue;
       }
       for (;;) {
@@ -2119,7 +2119,7 @@ void MemoryGraphFixer::collect_memory_nodes() {
   if (trace) {
     for (int i = rpo_list.size() - 1; i >= 0; i--) {
       Node* c = rpo_list.at(i);
-      if (_memory_nodes[c->_idx] != NULL) {
+      if (_memory_nodes[c->_idx] != nullptr) {
         tty->print("X %d", c->_idx);  _memory_nodes[c->_idx]->dump();
       }
     }
@@ -2150,15 +2150,15 @@ void MemoryGraphFixer::collect_memory_nodes() {
       Node* prev_mem = _memory_nodes[c->_idx];
       if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
         Node* prev_region = regions[c->_idx];
-        Node* unique = NULL;
+        Node* unique = nullptr;
         for (uint j = 1; j < c->req() && unique != NodeSentinel; j++) {
           Node* m = _memory_nodes[c->in(j)->_idx];
-          assert(m != NULL || (c->is_Loop() && j == LoopNode::LoopBackControl && iteration == 1) || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root()), "expect memory state");
-          if (m != NULL) {
+          assert(m != nullptr || (c->is_Loop() && j == LoopNode::LoopBackControl && iteration == 1) || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root()), "expect memory state");
+          if (m != nullptr) {
             if (m == prev_region && ((c->is_Loop() && j == LoopNode::LoopBackControl) || (prev_region->is_Phi() && prev_region->in(0) == c))) {
               assert(c->is_Loop() && j == LoopNode::LoopBackControl || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root()), "");
               // continue
-            } else if (unique == NULL) {
+            } else if (unique == nullptr) {
               unique = m;
             } else if (m == unique) {
               // continue
@@ -2167,30 +2167,30 @@ void MemoryGraphFixer::collect_memory_nodes() {
             }
           }
         }
-        assert(unique != NULL, "empty phi???");
+        assert(unique != nullptr, "empty phi???");
         if (unique != NodeSentinel) {
-          if (prev_region != NULL && prev_region->is_Phi() && prev_region->in(0) == c) {
+          if (prev_region != nullptr && prev_region->is_Phi() && prev_region->in(0) == c) {
             dead_phis.push(prev_region);
           }
           regions.map(c->_idx, unique);
         } else {
-          Node* phi = NULL;
-          if (prev_region != NULL && prev_region->is_Phi() && prev_region->in(0) == c && prev_region->_idx >= last) {
+          Node* phi = nullptr;
+          if (prev_region != nullptr && prev_region->is_Phi() && prev_region->in(0) == c && prev_region->_idx >= last) {
             phi = prev_region;
             for (uint k = 1; k < c->req(); k++) {
               Node* m = _memory_nodes[c->in(k)->_idx];
-              assert(m != NULL, "expect memory state");
+              assert(m != nullptr, "expect memory state");
               phi->set_req(k, m);
             }
           } else {
-            for (DUIterator_Fast jmax, j = c->fast_outs(jmax); j < jmax && phi == NULL; j++) {
+            for (DUIterator_Fast jmax, j = c->fast_outs(jmax); j < jmax && phi == nullptr; j++) {
               Node* u = c->fast_out(j);
               if (u->is_Phi() && u->bottom_type() == Type::MEMORY &&
                   (u->adr_type() == TypePtr::BOTTOM || _phase->C->get_alias_index(u->adr_type()) == _alias)) {
                 phi = u;
-                for (uint k = 1; k < c->req() && phi != NULL; k++) {
+                for (uint k = 1; k < c->req() && phi != nullptr; k++) {
                   Node* m = _memory_nodes[c->in(k)->_idx];
-                  assert(m != NULL, "expect memory state");
+                  assert(m != nullptr, "expect memory state");
                   if (u->in(k) != m) {
                     phi = NodeSentinel;
                   }
@@ -2201,12 +2201,12 @@ void MemoryGraphFixer::collect_memory_nodes() {
               phi = new PhiNode(c, Type::MEMORY, _phase->C->get_adr_type(_alias));
               for (uint k = 1; k < c->req(); k++) {
                 Node* m = _memory_nodes[c->in(k)->_idx];
-                assert(m != NULL, "expect memory state");
+                assert(m != nullptr, "expect memory state");
                 phi->init_req(k, m);
               }
             }
           }
-          if (phi != NULL) {
+          if (phi != nullptr) {
             regions.map(c->_idx, phi);
           } else {
             assert(c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
@@ -2219,9 +2219,9 @@ void MemoryGraphFixer::collect_memory_nodes() {
             _memory_nodes.map(c->_idx, current_region);
           }
         }
-      } else if (prev_mem == NULL || prev_mem->is_Phi() || ctrl_or_self(prev_mem) != c) {
+      } else if (prev_mem == nullptr || prev_mem->is_Phi() || ctrl_or_self(prev_mem) != c) {
         Node* m = _memory_nodes[_phase->idom(c)->_idx];
-        assert(m != NULL || c->Opcode() == Op_Halt, "expect memory state");
+        assert(m != nullptr || c->Opcode() == Op_Halt, "expect memory state");
         if (m != prev_mem) {
           _memory_nodes.map(c->_idx, m);
           progress = true;
@@ -2245,8 +2245,8 @@ void MemoryGraphFixer::collect_memory_nodes() {
     Node* c = rpo_list.at(i);
     if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
       Node* n = regions[c->_idx];
-      assert(n != NULL || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
-      if (n != NULL && n->is_Phi() && n->_idx >= last && n->in(0) == c) {
+      assert(n != nullptr || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
+      if (n != nullptr && n->is_Phi() && n->_idx >= last && n->in(0) == c) {
         _phase->register_new_node(n, c);
       }
     }
@@ -2255,7 +2255,7 @@ void MemoryGraphFixer::collect_memory_nodes() {
     Node* c = rpo_list.at(i);
     if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
       Node* n = regions[c->_idx];
-      assert(n != NULL || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
+      assert(n != nullptr || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
       for (DUIterator_Fast imax, i = c->fast_outs(imax); i < imax; i++) {
         Node* u = c->fast_out(i);
         if (u->is_Phi() && u->bottom_type() == Type::MEMORY &&
@@ -2274,26 +2274,26 @@ void MemoryGraphFixer::collect_memory_nodes() {
 }
 
 Node* MemoryGraphFixer::collect_memory_for_infinite_loop(const Node* in) {
-  Node* mem = NULL;
+  Node* mem = nullptr;
   Node* head = in->in(0);
   assert(head->is_Region(), "unexpected infinite loop graph shape");
 
-  Node* phi_mem = NULL;
+  Node* phi_mem = nullptr;
   for (DUIterator_Fast jmax, j = head->fast_outs(jmax); j < jmax; j++) {
     Node* u = head->fast_out(j);
     if (u->is_Phi() && u->bottom_type() == Type::MEMORY) {
       if (_phase->C->get_alias_index(u->adr_type()) == _alias) {
-        assert(phi_mem == NULL || phi_mem->adr_type() == TypePtr::BOTTOM, "");
+        assert(phi_mem == nullptr || phi_mem->adr_type() == TypePtr::BOTTOM, "");
         phi_mem = u;
       } else if (u->adr_type() == TypePtr::BOTTOM) {
-        assert(phi_mem == NULL || _phase->C->get_alias_index(phi_mem->adr_type()) == _alias, "");
-        if (phi_mem == NULL) {
+        assert(phi_mem == nullptr || _phase->C->get_alias_index(phi_mem->adr_type()) == _alias, "");
+        if (phi_mem == nullptr) {
           phi_mem = u;
         }
       }
     }
   }
-  if (phi_mem == NULL) {
+  if (phi_mem == nullptr) {
     ResourceMark rm;
     Node_Stack stack(0);
     stack.push(head, 1);
@@ -2316,7 +2316,7 @@ Node* MemoryGraphFixer::collect_memory_for_infinite_loop(const Node* in) {
               if (m->is_MergeMem()) {
                 m = m->as_MergeMem()->memory_at(_alias);
               }
-              assert(mem == NULL || mem == m, "several memory states");
+              assert(mem == nullptr || mem == m, "several memory states");
               mem = m;
               break;
             } else {
@@ -2327,7 +2327,7 @@ Node* MemoryGraphFixer::collect_memory_for_infinite_loop(const Node* in) {
         }
       }
     } while (stack.size() > 0);
-    assert(mem != NULL, "should have found safepoint");
+    assert(mem != nullptr, "should have found safepoint");
   } else {
     mem = phi_mem;
   }
@@ -2336,12 +2336,12 @@ Node* MemoryGraphFixer::collect_memory_for_infinite_loop(const Node* in) {
 
 Node* MemoryGraphFixer::get_ctrl(Node* n) const {
   Node* c = _phase->get_ctrl(n);
-  if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Call()) {
+  if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Call()) {
     assert(c == n->in(0), "");
     CallNode* call = c->as_Call();
     CallProjections projs;
     call->extract_projections(&projs, true, false);
-    if (projs.catchall_memproj != NULL) {
+    if (projs.catchall_memproj != nullptr) {
       if (projs.fallthrough_memproj == n) {
         c = projs.fallthrough_catchproj;
       } else {
@@ -2363,11 +2363,11 @@ Node* MemoryGraphFixer::ctrl_or_self(Node* n) const {
 }
 
 bool MemoryGraphFixer::mem_is_valid(Node* m, Node* c) const {
-  return m != NULL && get_ctrl(m) == c;
+  return m != nullptr && get_ctrl(m) == c;
 }
 
 Node* MemoryGraphFixer::find_mem(Node* ctrl, Node* n) const {
-  assert(n == NULL || _phase->ctrl_or_self(n) == ctrl, "");
+  assert(n == nullptr || _phase->ctrl_or_self(n) == ctrl, "");
   assert(!ctrl->is_Call() || ctrl == n, "projection expected");
 #ifdef ASSERT
   if ((ctrl->is_Proj() && ctrl->in(0)->is_Call()) ||
@@ -2386,11 +2386,11 @@ Node* MemoryGraphFixer::find_mem(Node* ctrl, Node* n) const {
   Node* mem = _memory_nodes[ctrl->_idx];
   Node* c = ctrl;
   while (!mem_is_valid(mem, c) &&
-         (!c->is_CatchProj() || mem == NULL || c->in(0)->in(0)->in(0) != get_ctrl(mem))) {
+         (!c->is_CatchProj() || mem == nullptr || c->in(0)->in(0)->in(0) != get_ctrl(mem))) {
     c = _phase->idom(c);
     mem = _memory_nodes[c->_idx];
   }
-  if (n != NULL && mem_is_valid(mem, c)) {
+  if (n != nullptr && mem_is_valid(mem, c)) {
     while (!ShenandoahBarrierC2Support::is_dominator_same_ctrl(c, mem, n, _phase) && _phase->ctrl_or_self(mem) == ctrl) {
       mem = next_mem(mem, _alias);
     }
@@ -2402,7 +2402,7 @@ Node* MemoryGraphFixer::find_mem(Node* ctrl, Node* n) const {
         c = _phase->idom(c);
         mem = _memory_nodes[c->_idx];
       } while (!mem_is_valid(mem, c) &&
-               (!c->is_CatchProj() || mem == NULL || c->in(0)->in(0)->in(0) != get_ctrl(mem)));
+               (!c->is_CatchProj() || mem == nullptr || c->in(0)->in(0)->in(0) != get_ctrl(mem)));
     }
   }
   assert(mem->bottom_type() == Type::MEMORY, "");
@@ -2428,7 +2428,7 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
   GrowableArray<Node*> phis;
   if (mem_for_ctrl != mem) {
     Node* old = mem_for_ctrl;
-    Node* prev = NULL;
+    Node* prev = nullptr;
     while (old != mem) {
       prev = old;
       if (old->is_Store() || old->is_ClearArray() || old->is_LoadStore()) {
@@ -2441,7 +2441,7 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
         ShouldNotReachHere();
       }
     }
-    assert(prev != NULL, "");
+    assert(prev != nullptr, "");
     if (new_ctrl != ctrl) {
       _memory_nodes.map(ctrl->_idx, mem);
       _memory_nodes.map(new_ctrl->_idx, mem_for_ctrl);
@@ -2464,7 +2464,7 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
               !has_mem_phi(u) &&
               u->unique_ctrl_out()->Opcode() != Op_Halt) {
             DEBUG_ONLY(if (trace) { tty->print("ZZZ region"); u->dump(); });
-            DEBUG_ONLY(if (trace && m != NULL) { tty->print("ZZZ mem"); m->dump(); });
+            DEBUG_ONLY(if (trace && m != nullptr) { tty->print("ZZZ mem"); m->dump(); });
 
             if (!mem_is_valid(m, u) || !m->is_Phi()) {
               bool push = true;
@@ -2484,7 +2484,7 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
                   DEBUG_ONLY(if (trace) { tty->print("ZZZ NOT setting mem"); m->dump(); });
                   for (;;) {
                     assert(m->is_Mem() || m->is_LoadStore() || m->is_Proj(), "");
-                    Node* next = NULL;
+                    Node* next = nullptr;
                     if (m->is_Proj()) {
                       next = m->in(0);
                     } else {
@@ -2531,14 +2531,14 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
       Node* r = n->in(0);
       DEBUG_ONLY(if (trace) { tty->print("ZZZ fixing new phi"); n->dump(); });
       for (uint j = 1; j < n->req(); j++) {
-        Node* m = find_mem(r->in(j), NULL);
+        Node* m = find_mem(r->in(j), nullptr);
         _phase->igvn().replace_input_of(n, j, m);
         DEBUG_ONLY(if (trace) { tty->print("ZZZ fixing new phi: %d", j); m->dump(); });
       }
     }
   }
   uint last = _phase->C->unique();
-  MergeMemNode* mm = NULL;
+  MergeMemNode* mm = nullptr;
   int alias = _alias;
   DEBUG_ONLY(if (trace) { tty->print("ZZZ raw mem is"); mem->dump(); });
   // Process loads first to not miss an anti-dependency: if the memory
@@ -2570,7 +2570,7 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
       } else if (u->is_MergeMem()) {
         MergeMemNode* u_mm = u->as_MergeMem();
         if (u_mm->memory_at(alias) == mem) {
-          MergeMemNode* newmm = NULL;
+          MergeMemNode* newmm = nullptr;
           for (DUIterator_Fast jmax, j = u->fast_outs(jmax); j < jmax; j++) {
             Node* uu = u->fast_out(j);
             assert(!uu->is_MergeMem(), "chain of MergeMems?");
@@ -2580,7 +2580,7 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
               int nb = 0;
               for (uint k = 1; k < uu->req(); k++) {
                 if (uu->in(k) == u) {
-                  Node* m = find_mem(region->in(k), NULL);
+                  Node* m = find_mem(region->in(k), nullptr);
                   if (m != mem) {
                     DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of phi %d", k); uu->dump(); });
                     newmm = clone_merge_mem(u, mem, m, _phase->ctrl_or_self(m), i);
@@ -2615,7 +2615,7 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
           bool replaced = false;
           for (uint j = 1; j < u->req(); j++) {
             if (u->in(j) == mem) {
-              Node* m = find_mem(region->in(j), NULL);
+              Node* m = find_mem(region->in(j), nullptr);
               Node* nnew = m;
               if (m != mem) {
                 if (u->adr_type() == TypePtr::BOTTOM) {
@@ -2633,8 +2633,8 @@ void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_
           }
         }
       } else if ((u->adr_type() == TypePtr::BOTTOM && u->Opcode() != Op_StrInflatedCopy) ||
-                 u->adr_type() == NULL) {
-        assert(u->adr_type() != NULL ||
+                 u->adr_type() == nullptr) {
+        assert(u->adr_type() != nullptr ||
                u->Opcode() == Op_Rethrow ||
                u->Opcode() == Op_Return ||
                u->Opcode() == Op_SafePoint ||
@@ -2690,7 +2690,7 @@ MergeMemNode* MemoryGraphFixer::allocate_merge_mem(Node* mem, Node* rep_proj, No
 }
 
 MergeMemNode* MemoryGraphFixer::clone_merge_mem(Node* u, Node* mem, Node* rep_proj, Node* rep_ctrl, DUIterator& i) const {
-  MergeMemNode* newmm = NULL;
+  MergeMemNode* newmm = nullptr;
   MergeMemNode* u_mm = u->as_MergeMem();
   Node* c = _phase->get_ctrl(u);
   if (_phase->is_dominator(c, rep_ctrl)) {
@@ -2750,7 +2750,7 @@ bool MemoryGraphFixer::should_process_phi(Node* phi) const {
 
 void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_proj, Node* rep_ctrl) const {
   uint last = _phase-> C->unique();
-  MergeMemNode* mm = NULL;
+  MergeMemNode* mm = nullptr;
   assert(mem->bottom_type() == Type::MEMORY, "");
   for (DUIterator i = mem->outs(); mem->has_out(i); i++) {
     Node* u = mem->out(i);
@@ -2758,7 +2758,7 @@ void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_p
       if (u->is_MergeMem()) {
         MergeMemNode* u_mm = u->as_MergeMem();
         if (u_mm->memory_at(_alias) == mem) {
-          MergeMemNode* newmm = NULL;
+          MergeMemNode* newmm = nullptr;
           for (DUIterator_Fast jmax, j = u->fast_outs(jmax); j < jmax; j++) {
             Node* uu = u->fast_out(j);
             assert(!uu->is_MergeMem(), "chain of MergeMems?");
@@ -2768,7 +2768,7 @@ void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_p
                 int nb = 0;
                 for (uint k = 1; k < uu->req(); k++) {
                   if (uu->in(k) == u && _phase->is_dominator(rep_ctrl, region->in(k))) {
-                    if (newmm == NULL) {
+                    if (newmm == nullptr) {
                       newmm = clone_merge_mem(u, mem, rep_proj, rep_ctrl, i);
                     }
                     if (newmm != u) {
@@ -2784,7 +2784,7 @@ void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_p
               }
             } else {
               if (rep_ctrl != uu && ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(uu), replacement, uu, _phase)) {
-                if (newmm == NULL) {
+                if (newmm == nullptr) {
                   newmm = clone_merge_mem(u, mem, rep_proj, rep_ctrl, i);
                 }
                 if (newmm != u) {
@@ -2804,7 +2804,7 @@ void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_p
             if (u->in(j) == mem && _phase->is_dominator(rep_ctrl, region->in(j))) {
               Node* nnew = rep_proj;
               if (u->adr_type() == TypePtr::BOTTOM) {
-                if (mm == NULL) {
+                if (mm == nullptr) {
                   mm = allocate_merge_mem(mem, rep_proj, rep_ctrl);
                 }
                 nnew = mm;
@@ -2819,8 +2819,8 @@ void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_p
 
         }
       } else if ((u->adr_type() == TypePtr::BOTTOM && u->Opcode() != Op_StrInflatedCopy) ||
-                 u->adr_type() == NULL) {
-        assert(u->adr_type() != NULL ||
+                 u->adr_type() == nullptr) {
+        assert(u->adr_type() != nullptr ||
                u->Opcode() == Op_Rethrow ||
                u->Opcode() == Op_Return ||
                u->Opcode() == Op_SafePoint ||
@@ -2828,7 +2828,7 @@ void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_p
                (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) ||
                u->Opcode() == Op_CallLeaf, "%s", u->Name());
         if (ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
-          if (mm == NULL) {
+          if (mm == nullptr) {
             mm = allocate_merge_mem(mem, rep_proj, rep_ctrl);
           }
           _phase->igvn().replace_input_of(u, u->find_edge(mem), mm);
@@ -2873,7 +2873,7 @@ bool ShenandoahLoadReferenceBarrierNode::cmp( const Node &n ) const {
 }
 
 const Type* ShenandoahLoadReferenceBarrierNode::bottom_type() const {
-  if (in(ValueIn) == NULL || in(ValueIn)->is_top()) {
+  if (in(ValueIn) == nullptr || in(ValueIn)->is_top()) {
     return Type::TOP;
   }
   const Type* t = in(ValueIn)->bottom_type();
@@ -2918,7 +2918,7 @@ bool ShenandoahLoadReferenceBarrierNode::needs_barrier(PhaseGVN* phase, Node* n)
 }
 
 bool ShenandoahLoadReferenceBarrierNode::needs_barrier_impl(PhaseGVN* phase, Node* n, Unique_Node_List &visited) {
-  if (n == NULL) return false;
+  if (n == nullptr) return false;
   if (visited.member(n)) {
     return false; // Been there.
   }
@@ -2941,7 +2941,7 @@ bool ShenandoahLoadReferenceBarrierNode::needs_barrier_impl(PhaseGVN* phase, Nod
     // tty->print_cr("optimize barrier on null");
     return false;
   }
-  if (type->make_oopptr() && type->make_oopptr()->const_oop() != NULL) {
+  if (type->make_oopptr() && type->make_oopptr()->const_oop() != nullptr) {
     // tty->print_cr("optimize barrier on constant");
     return false;
   }
diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp
index c9404af5ff8..032f338aa88 100644
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp
@@ -49,7 +49,7 @@ class ShenandoahBarrierC2Support : public AllStatic {
   };
 
   static bool verify_helper(Node* in, Node_Stack& phis, VectorSet& visited, verify_type t, bool trace, Unique_Node_List& barriers_used);
-  static void report_verify_failure(const char* msg, Node* n1 = NULL, Node* n2 = NULL);
+  static void report_verify_failure(const char* msg, Node* n1 = nullptr, Node* n2 = nullptr);
 #endif
   static Node* dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase);
   static Node* no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase);
@@ -142,10 +142,10 @@ class ShenandoahCompareAndSwapPNode : public CompareAndSwapPNode {
     : CompareAndSwapPNode(c, mem, adr, val, ex, mem_ord) { }
 
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) {
-    if (in(ExpectedIn) != NULL && phase->type(in(ExpectedIn)) == TypePtr::NULL_PTR) {
+    if (in(ExpectedIn) != nullptr && phase->type(in(ExpectedIn)) == TypePtr::NULL_PTR) {
       return new CompareAndSwapPNode(in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), in(MemNode::ValueIn), in(ExpectedIn), order());
     }
-    return NULL;
+    return nullptr;
   }
 
   virtual int Opcode() const;
@@ -157,10 +157,10 @@ class ShenandoahCompareAndSwapNNode : public CompareAndSwapNNode {
     : CompareAndSwapNNode(c, mem, adr, val, ex, mem_ord) { }
 
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) {
-    if (in(ExpectedIn) != NULL && phase->type(in(ExpectedIn)) == TypeNarrowOop::NULL_PTR) {
+    if (in(ExpectedIn) != nullptr && phase->type(in(ExpectedIn)) == TypeNarrowOop::NULL_PTR) {
       return new CompareAndSwapNNode(in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), in(MemNode::ValueIn), in(ExpectedIn), order());
     }
-    return NULL;
+    return nullptr;
   }
 
   virtual int Opcode() const;
@@ -172,10 +172,10 @@ class ShenandoahWeakCompareAndSwapPNode : public WeakCompareAndSwapPNode {
     : WeakCompareAndSwapPNode(c, mem, adr, val, ex, mem_ord) { }
 
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) {
-    if (in(ExpectedIn) != NULL && phase->type(in(ExpectedIn)) == TypePtr::NULL_PTR) {
+    if (in(ExpectedIn) != nullptr && phase->type(in(ExpectedIn)) == TypePtr::NULL_PTR) {
       return new WeakCompareAndSwapPNode(in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), in(MemNode::ValueIn), in(ExpectedIn), order());
     }
-    return NULL;
+    return nullptr;
   }
 
   virtual int Opcode() const;
@@ -187,10 +187,10 @@ class ShenandoahWeakCompareAndSwapNNode : public WeakCompareAndSwapNNode {
     : WeakCompareAndSwapNNode(c, mem, adr, val, ex, mem_ord) { }
 
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) {
-    if (in(ExpectedIn) != NULL && phase->type(in(ExpectedIn)) == TypeNarrowOop::NULL_PTR) {
+    if (in(ExpectedIn) != nullptr && phase->type(in(ExpectedIn)) == TypeNarrowOop::NULL_PTR) {
       return new WeakCompareAndSwapNNode(in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), in(MemNode::ValueIn), in(ExpectedIn), order());
     }
-    return NULL;
+    return nullptr;
   }
 
   virtual int Opcode() const;
@@ -202,10 +202,10 @@ class ShenandoahCompareAndExchangePNode : public CompareAndExchangePNode {
     : CompareAndExchangePNode(c, mem, adr, val, ex, at, t, mem_ord) { }
 
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) {
-    if (in(ExpectedIn) != NULL && phase->type(in(ExpectedIn)) == TypePtr::NULL_PTR) {
+    if (in(ExpectedIn) != nullptr && phase->type(in(ExpectedIn)) == TypePtr::NULL_PTR) {
       return new CompareAndExchangePNode(in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), in(MemNode::ValueIn), in(ExpectedIn), adr_type(), bottom_type(), order());
     }
-    return NULL;
+    return nullptr;
   }
 
   virtual int Opcode() const;
@@ -217,10 +217,10 @@ class ShenandoahCompareAndExchangeNNode : public CompareAndExchangeNNode {
     : CompareAndExchangeNNode(c, mem, adr, val, ex, at, t, mem_ord) { }
 
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) {
-    if (in(ExpectedIn) != NULL && phase->type(in(ExpectedIn)) == TypeNarrowOop::NULL_PTR) {
+    if (in(ExpectedIn) != nullptr && phase->type(in(ExpectedIn)) == TypeNarrowOop::NULL_PTR) {
       return new CompareAndExchangeNNode(in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), in(MemNode::ValueIn), in(ExpectedIn), adr_type(), bottom_type(), order());
     }
-    return NULL;
+    return nullptr;
   }
 
   virtual int Opcode() const;
diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp
index e9e51c39bbe..f8576e8cd66 100644
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp
@@ -49,7 +49,7 @@ int ShenandoahHeuristics::compare_by_garbage(RegionData a, RegionData b) {
 
 ShenandoahHeuristics::ShenandoahHeuristics(ShenandoahGeneration* generation) :
   _generation(generation),
-  _region_data(NULL),
+  _region_data(nullptr),
   _degenerated_cycles_in_a_row(0),
   _successful_cycles_in_a_row(0),
   _guaranteed_gc_interval(0),
@@ -195,7 +195,7 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec
   collection_set->set_immediate_trash(immediate_garbage);
 
   if (immediate_percent <= ShenandoahImmediateThreshold) {
-    if (old_heuristics != NULL) {
+    if (old_heuristics != nullptr) {
       old_heuristics->prime_collection_set(collection_set);
     }
     // else, this is global collection and doesn't need to prime_collection_set
diff --git a/src/hotspot/share/gc/shenandoah/mode/shenandoahMode.cpp b/src/hotspot/share/gc/shenandoah/mode/shenandoahMode.cpp
index e542afaa7f9..b7775e9e9f8 100644
--- a/src/hotspot/share/gc/shenandoah/mode/shenandoahMode.cpp
+++ b/src/hotspot/share/gc/shenandoah/mode/shenandoahMode.cpp
@@ -31,7 +31,7 @@
 #include "gc/shenandoah/mode/shenandoahMode.hpp"
 
 ShenandoahHeuristics* ShenandoahMode::initialize_heuristics(ShenandoahGeneration* generation) const {
-  if (ShenandoahGCHeuristics == NULL) {
+  if (ShenandoahGCHeuristics == nullptr) {
     vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
   }
 
@@ -48,6 +48,6 @@ ShenandoahHeuristics* ShenandoahMode::initialize_heuristics(ShenandoahGeneration
   }
 
   ShouldNotReachHere();
-  return NULL;
+  return nullptr;
 }
 
diff --git a/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp b/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp
index 876732f6672..2e96479052b 100644
--- a/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp
+++ b/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp
@@ -56,7 +56,7 @@ void ShenandoahPassiveMode::initialize_flags() const {
   // No barriers are required to run.
 }
 ShenandoahHeuristics* ShenandoahPassiveMode::initialize_heuristics(ShenandoahGeneration* generation) const {
-  if (ShenandoahGCHeuristics == NULL) {
+  if (ShenandoahGCHeuristics == nullptr) {
     vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
   }
   return new ShenandoahPassiveHeuristics(generation);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
index a9b276a4a59..45ff4e1ca0b 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
@@ -40,7 +40,7 @@ void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
   if (!heap->is_in(loc)) return;
 
   ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
-  if (r != NULL && r->is_committed()) {
+  if (r != nullptr && r->is_committed()) {
     address start = MAX2((address) r->bottom(), (address) loc - 32);
     address end   = MIN2((address) r->end(),    (address) loc + 128);
     if (start >= end) return;
@@ -101,7 +101,7 @@ void ShenandoahAsserts::print_obj_safe(ShenandoahMessageBuffer& msg, void* loc)
   msg.append("  " PTR_FORMAT " - safe print, no details\n", p2i(loc));
   if (heap->is_in(loc)) {
     ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
-    if (r != NULL) {
+    if (r != nullptr) {
       stringStream ss;
       r->print_on(&ss);
       msg.append("  region: %s", ss.freeze());
@@ -116,12 +116,12 @@ void ShenandoahAsserts::print_failure(SafeLevel level, oop obj, void* interior_l
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   ResourceMark rm;
 
-  bool loc_in_heap = (loc != NULL && heap->is_in(loc));
+  bool loc_in_heap = (loc != nullptr && heap->is_in(loc));
 
   ShenandoahMessageBuffer msg("%s; %s\n\n", phase, label);
 
   msg.append("Referenced from:\n");
-  if (interior_loc != NULL) {
+  if (interior_loc != nullptr) {
     msg.append("  interior location: " PTR_FORMAT "\n", p2i(interior_loc));
     if (loc_in_heap) {
       print_obj(msg, loc);
@@ -173,7 +173,7 @@ void ShenandoahAsserts::assert_in_heap(void* interior_loc, oop obj, const char *
   ShenandoahHeap* heap = ShenandoahHeap::heap();
 
   if (!heap->is_in(obj)) {
-    print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_heap failed",
+    print_failure(_safe_unknown, obj, interior_loc, nullptr, "Shenandoah assert_in_heap failed",
                   "oop must point to a heap address",
                   file, line);
   }
@@ -182,8 +182,8 @@ void ShenandoahAsserts::assert_in_heap(void* interior_loc, oop obj, const char *
 void ShenandoahAsserts::assert_in_heap_or_null(void* interior_loc, oop obj, const char *file, int line) {
   ShenandoahHeap* heap = ShenandoahHeap::heap();
 
-  if (obj != NULL && !heap->is_in(obj)) {
-    print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_heap_or_null failed",
+  if (obj != nullptr && !heap->is_in(obj)) {
+    print_failure(_safe_unknown, obj, interior_loc, nullptr, "Shenandoah assert_in_heap_or_null failed",
                   "oop must point to a heap address",
                   file, line);
   }
@@ -195,20 +195,20 @@ void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char*
   // Step 1. Check that obj is correct.
   // After this step, it is safe to call heap_region_containing().
   if (!heap->is_in(obj)) {
-    print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
+    print_failure(_safe_unknown, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
                   "oop must point to a heap address",
                   file, line);
   }
 
   Klass* obj_klass = obj->klass_or_null();
-  if (obj_klass == NULL) {
-    print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
-                  "Object klass pointer should not be NULL",
+  if (obj_klass == nullptr) {
+    print_failure(_safe_unknown, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
+                  "Object klass pointer should not be null",
                   file,line);
   }
 
   if (!Metaspace::contains(obj_klass)) {
-    print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
+    print_failure(_safe_unknown, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
                   "Object klass pointer must go to metaspace",
                   file,line);
   }
@@ -220,27 +220,27 @@ void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char*
     // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr
     // that still points to the object itself.
     if (heap->is_full_gc_move_in_progress()) {
-      print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
+      print_failure(_safe_oop, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
                     "Non-trivial forwarding pointer during Full GC moves, probable bug.",
                     file, line);
     }
 
     // Step 2. Check that forwardee is correct
     if (!heap->is_in(fwd)) {
-      print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
+      print_failure(_safe_oop, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
                     "Forwardee must point to a heap address",
                     file, line);
     }
 
     if (obj_klass != fwd->klass()) {
-      print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
+      print_failure(_safe_oop, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
                     "Forwardee klass disagrees with object class",
                     file, line);
     }
 
     // Step 3. Check that forwardee points to correct region
     if (heap->heap_region_index_containing(fwd) == heap->heap_region_index_containing(obj)) {
-      print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
+      print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
                     "Non-trivial forwardee should in another region",
                     file, line);
     }
@@ -248,7 +248,7 @@ void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char*
     // Step 4. Check for multiple forwardings
     oop fwd2 = ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
     if (fwd != fwd2) {
-      print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
+      print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_correct failed",
                     "Multiple forwardings",
                     file, line);
     }
@@ -261,7 +261,7 @@ void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, co
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   ShenandoahHeapRegion* r = heap->heap_region_containing(obj);
   if (!r->is_active()) {
-    print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
+    print_failure(_safe_unknown, obj, interior_loc, nullptr, "Shenandoah assert_in_correct_region failed",
                   "Object must reside in active region",
                   file, line);
   }
@@ -273,12 +273,12 @@ void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, co
     for (size_t i = idx; i < idx + num_regions; i++) {
       ShenandoahHeapRegion* chain_reg = heap->get_region(i);
       if (i == idx && !chain_reg->is_humongous_start()) {
-        print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
+        print_failure(_safe_unknown, obj, interior_loc, nullptr, "Shenandoah assert_in_correct_region failed",
                       "Object must reside in humongous start",
                       file, line);
       }
       if (i != idx && !chain_reg->is_humongous_continuation()) {
-        print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
+        print_failure(_safe_oop, obj, interior_loc, nullptr, "Shenandoah assert_in_correct_region failed",
                       "Humongous continuation should be of proper size",
                       file, line);
       }
@@ -291,7 +291,7 @@ void ShenandoahAsserts::assert_forwarded(void* interior_loc, oop obj, const char
   oop fwd =   ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
 
   if (obj == fwd) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_forwarded failed",
+    print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_forwarded failed",
                   "Object should be forwarded",
                   file, line);
   }
@@ -302,7 +302,7 @@ void ShenandoahAsserts::assert_not_forwarded(void* interior_loc, oop obj, const
   oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
 
   if (obj != fwd) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_forwarded failed",
+    print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_not_forwarded failed",
                   "Object should not be forwarded",
                   file, line);
   }
@@ -313,7 +313,7 @@ void ShenandoahAsserts::assert_marked(void *interior_loc, oop obj, const char *f
 
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   if (!heap->marking_context()->is_marked(obj)) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked failed",
+    print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_marked failed",
                   "Object should be marked",
                   file, line);
   }
@@ -324,7 +324,7 @@ void ShenandoahAsserts::assert_marked_weak(void *interior_loc, oop obj, const ch
 
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   if (!heap->marking_context()->is_marked_weak(obj)) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_weak failed",
+    print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_marked_weak failed",
                   "Object should be marked weakly",
                   file, line);
   }
@@ -335,7 +335,7 @@ void ShenandoahAsserts::assert_marked_strong(void *interior_loc, oop obj, const
 
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   if (!heap->marking_context()->is_marked_strong(obj)) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_strong failed",
+    print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_marked_strong failed",
                   "Object should be marked strongly",
                   file, line);
   }
@@ -346,7 +346,7 @@ void ShenandoahAsserts::assert_in_cset(void* interior_loc, oop obj, const char*
 
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   if (!heap->in_collection_set(obj)) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_in_cset failed",
+    print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_in_cset failed",
                   "Object should be in collection set",
                   file, line);
   }
@@ -357,7 +357,7 @@ void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const ch
 
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   if (heap->in_collection_set(obj)) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_in_cset failed",
+    print_failure(_safe_all, obj, interior_loc, nullptr, "Shenandoah assert_not_in_cset failed",
                   "Object should not be in collection set",
                   file, line);
   }
@@ -366,7 +366,7 @@ void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const ch
 void ShenandoahAsserts::assert_not_in_cset_loc(void* interior_loc, const char* file, int line) {
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   if (heap->in_collection_set_loc(interior_loc)) {
-    print_failure(_safe_unknown, NULL, interior_loc, NULL, "Shenandoah assert_not_in_cset_loc failed",
+    print_failure(_safe_unknown, nullptr, interior_loc, nullptr, "Shenandoah assert_not_in_cset_loc failed",
                   "Interior location should not be in collection set",
                   file, line);
   }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp
index 688ea2a292b..92508f1a647 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp
@@ -45,7 +45,7 @@ ShenandoahBarrierSet::ShenandoahBarrierSet(ShenandoahHeap* heap, MemRegion heap_
   BarrierSet(make_barrier_set_assembler<ShenandoahBarrierSetAssembler>(),
              make_barrier_set_c1<ShenandoahBarrierSetC1>(),
              make_barrier_set_c2<ShenandoahBarrierSetC2>(),
-             ShenandoahNMethodBarrier ? new ShenandoahBarrierSetNMethod(heap) : NULL,
+             ShenandoahNMethodBarrier ? new ShenandoahBarrierSetNMethod(heap) : nullptr,
              new ShenandoahBarrierSetStackChunk(),
              BarrierSet::FakeRtti(BarrierSet::ShenandoahBarrierSet)),
   _heap(heap),
@@ -107,7 +107,7 @@ void ShenandoahBarrierSet::on_thread_attach(Thread *thread) {
     ShenandoahThreadLocalData::initialize_gclab(thread);
 
     BarrierSetNMethod* bs_nm = barrier_set_nmethod();
-    if (bs_nm != NULL) {
+    if (bs_nm != nullptr) {
       thread->set_nmethod_disarmed_guard_value(bs_nm->disarmed_guard_value());
     }
 
@@ -124,7 +124,7 @@ void ShenandoahBarrierSet::on_thread_detach(Thread *thread) {
   _satb_mark_queue_set.flush_queue(queue);
   if (thread->is_Java_thread()) {
     PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
-    if (gclab != NULL) {
+    if (gclab != nullptr) {
       gclab->retire();
     }
 
@@ -132,7 +132,7 @@ void ShenandoahBarrierSet::on_thread_detach(Thread *thread) {
     // CAUTION: retire_plab may register the remnant filler object with the remembered set scanner without a lock.
     // This is safe iff it is assured that each PLAB is a whole-number multiple of card-mark memory size and each
     // PLAB is aligned with the start of each card's memory range.
-    if (plab != NULL) {
+    if (plab != nullptr) {
       _heap->retire_plab(plab);
     }
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp
index 55e3d2df39b..ada51264aad 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp
@@ -46,7 +46,7 @@ inline oop ShenandoahBarrierSet::resolve_forwarded_not_null(oop p) {
 }
 
 inline oop ShenandoahBarrierSet::resolve_forwarded(oop p) {
-  if (p != NULL) {
+  if (p != nullptr) {
     return resolve_forwarded_not_null(p);
   } else {
     return p;
@@ -71,7 +71,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, T* load
     fwd = _heap->evacuate_object(obj, t);
   }
 
-  if (load_addr != NULL && fwd != obj) {
+  if (load_addr != nullptr && fwd != obj) {
     // Since we are here and we know the load address, update the reference.
     ShenandoahHeap::atomic_update_oop(fwd, load_addr, obj);
   }
@@ -84,8 +84,8 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(oop obj) {
     return obj;
   }
   if (_heap->has_forwarded_objects() &&
-      _heap->in_collection_set(obj)) { // Subsumes NULL-check
-    assert(obj != NULL, "cset check must have subsumed NULL-check");
+      _heap->in_collection_set(obj)) { // Subsumes null-check
+    assert(obj != nullptr, "cset check must have subsumed null-check");
     oop fwd = resolve_forwarded_not_null(obj);
     if (obj == fwd && _heap->is_evacuation_in_progress()) {
       Thread* t = Thread::current();
@@ -99,8 +99,8 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(oop obj) {
 
 template <class T>
 inline oop ShenandoahBarrierSet::load_reference_barrier(DecoratorSet decorators, oop obj, T* load_addr) {
-  if (obj == NULL) {
-    return NULL;
+  if (obj == nullptr) {
+    return nullptr;
   }
 
   // Prevent resurrection of unreachable phantom (i.e. weak-native) references.
@@ -108,7 +108,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(DecoratorSet decorators,
       _heap->is_concurrent_weak_root_in_progress() &&
       _heap->is_in_active_generation(obj) &&
       !_heap->marking_context()->is_marked(obj)) {
-    return NULL;
+    return nullptr;
   }
 
   // Prevent resurrection of unreachable weak references.
@@ -116,7 +116,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(DecoratorSet decorators,
       _heap->is_concurrent_weak_root_in_progress() &&
       _heap->is_in_active_generation(obj) &&
       !_heap->marking_context()->is_marked_strong(obj)) {
-    return NULL;
+    return nullptr;
   }
 
   // Prevent resurrection of unreachable objects that are visited during
@@ -128,7 +128,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(DecoratorSet decorators,
   }
 
   oop fwd = load_reference_barrier(obj);
-  if (ShenandoahSelfFixing && load_addr != NULL && fwd != obj) {
+  if (ShenandoahSelfFixing && load_addr != nullptr && fwd != obj) {
     // Since we are here and we know the load address, update the reference.
     ShenandoahHeap::atomic_update_oop(fwd, load_addr, obj);
   }
@@ -137,7 +137,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(DecoratorSet decorators,
 }
 
 inline void ShenandoahBarrierSet::enqueue(oop obj) {
-  assert(obj != NULL, "checked by caller");
+  assert(obj != nullptr, "checked by caller");
   assert(_satb_mark_queue_set.is_active(), "only get here when SATB active");
 
   // Filter marked objects before hitting the SATB queues. The same predicate would
@@ -164,13 +164,13 @@ inline void ShenandoahBarrierSet::satb_barrier(T *field) {
 }
 
 inline void ShenandoahBarrierSet::satb_enqueue(oop value) {
-  if (value != NULL && ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
+  if (value != nullptr && ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
     enqueue(value);
   }
 }
 
 inline void ShenandoahBarrierSet::iu_barrier(oop obj) {
-  if (ShenandoahIUBarrier && obj != NULL && _heap->is_concurrent_mark_in_progress()) {
+  if (ShenandoahIUBarrier && obj != nullptr && _heap->is_concurrent_mark_in_progress()) {
     enqueue(obj);
   }
 }
@@ -255,9 +255,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_loa
 template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
 inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_store_common(T* addr, oop value) {
-  shenandoah_assert_marked_if(NULL, value, !CompressedOops::is_null(value) && ShenandoahHeap::heap()->is_evacuation_in_progress() &&
+  shenandoah_assert_marked_if(nullptr, value, !CompressedOops::is_null(value) && ShenandoahHeap::heap()->is_evacuation_in_progress() &&
                               !(ShenandoahHeap::heap()->is_gc_generation_young() && ShenandoahHeap::heap()->heap_region_containing(value)->is_old()));
-  shenandoah_assert_not_in_cset_if(addr, value, value != NULL && !ShenandoahHeap::heap()->cancelled_gc());
+  shenandoah_assert_not_in_cset_if(addr, value, value != nullptr && !ShenandoahHeap::heap()->cancelled_gc());
   ShenandoahBarrierSet* const bs = ShenandoahBarrierSet::barrier_set();
   bs->iu_barrier(value);
   bs->satb_barrier<decorators>(addr);
@@ -274,7 +274,7 @@ template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
 inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_store_in_heap(T* addr, oop value) {
   shenandoah_assert_not_in_cset_loc_except(addr, ShenandoahHeap::heap()->cancelled_gc());
-  shenandoah_assert_not_forwarded_except  (addr, value, value == NULL || ShenandoahHeap::heap()->cancelled_gc() || !ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
+  shenandoah_assert_not_forwarded_except  (addr, value, value == nullptr || ShenandoahHeap::heap()->cancelled_gc() || !ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
 
   oop_store_common(addr, value);
   ShenandoahBarrierSet::barrier_set()->write_ref_field_post<decorators>(addr, value);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp
index 4b46b42d3f2..0ca2c6da539 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp
@@ -102,7 +102,7 @@ void ShenandoahBarrierSet::clone_update(oop obj) {
 
 void ShenandoahBarrierSet::clone_barrier(oop obj) {
   assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled");
-  shenandoah_assert_correct(NULL, obj);
+  shenandoah_assert_correct(nullptr, obj);
 
   // We only need to handle YOUNG_MARKING here because the clone barrier
   // is only invoked during marking if Shenandoah is in incremental update
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp
index 150179c1e05..20954156b9e 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp
@@ -37,7 +37,7 @@
 
 bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
   ShenandoahReentrantLock* lock = ShenandoahNMethod::lock_for_nmethod(nm);
-  assert(lock != NULL, "Must be");
+  assert(lock != nullptr, "Must be");
   ShenandoahReentrantLocker locker(lock);
 
   if (!is_armed(nm)) {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp
index bd04cc74944..d1c91d5bf0d 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp
@@ -47,7 +47,7 @@ bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {
     return false;
   }
   obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
-  shenandoah_assert_not_forwarded_if(NULL, obj, ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
+  shenandoah_assert_not_forwarded_if(nullptr, obj, ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
   return _mark_context->is_marked_or_old(obj);
 }
 
@@ -59,7 +59,7 @@ bool ShenandoahIsAliveClosure::do_object_b(oop obj) {
   if (CompressedOops::is_null(obj)) {
     return false;
   }
-  shenandoah_assert_not_forwarded(NULL, obj);
+  shenandoah_assert_not_forwarded(nullptr, obj);
   return _mark_context->is_marked_or_old(obj);
 }
 
@@ -111,7 +111,7 @@ void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
 
 template <bool concurrent, bool stable_thread>
 ShenandoahEvacuateUpdateRootClosureBase<concurrent, stable_thread>::ShenandoahEvacuateUpdateRootClosureBase() :
-  _heap(ShenandoahHeap::heap()), _thread(stable_thread ? Thread::current() : NULL) {
+  _heap(ShenandoahHeap::heap()), _thread(stable_thread ? Thread::current() : nullptr) {
 }
 
 template <bool concurrent, bool stable_thread>
@@ -199,7 +199,7 @@ ShenandoahCodeBlobAndDisarmClosure::ShenandoahCodeBlobAndDisarmClosure(OopClosur
 
 void ShenandoahCodeBlobAndDisarmClosure::do_code_blob(CodeBlob* cb) {
   nmethod* const nm = cb->as_nmethod_or_null();
-  if (nm != NULL) {
+  if (nm != nullptr) {
     assert(!ShenandoahNMethod::gc_data(nm)->is_unregistered(), "Should not be here");
     CodeBlobToOopClosure::do_code_blob(cb);
     _bs->disarm(nm);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp
index 2c6675c292a..932252f9ee1 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp
@@ -83,7 +83,7 @@ void ShenandoahParallelCodeHeapIterator::parallel_blobs_do(CodeBlobClosure* f) {
   int count = 0;
   bool process_block = true;
 
-  for (CodeBlob *cb = CodeCache::first_blob(_heap); cb != NULL; cb = CodeCache::next_blob(_heap, cb)) {
+  for (CodeBlob *cb = CodeCache::first_blob(_heap); cb != nullptr; cb = CodeCache::next_blob(_heap, cb)) {
     int current = count++;
     if ((current & stride_mask) == 0) {
       process_block = (current >= _claimed_idx) &&
@@ -119,7 +119,7 @@ void ShenandoahCodeRoots::unregister_nmethod(nmethod* nm) {
 }
 
 void ShenandoahCodeRoots::arm_nmethods() {
-  assert(BarrierSet::barrier_set()->barrier_set_nmethod() != NULL, "Sanity");
+  assert(BarrierSet::barrier_set()->barrier_set_nmethod() != nullptr, "Sanity");
   BarrierSet::barrier_set()->barrier_set_nmethod()->arm_all_nmethods();
 }
 
@@ -285,7 +285,7 @@ void ShenandoahCodeRoots::purge() {
 
 ShenandoahCodeRootsIterator::ShenandoahCodeRootsIterator() :
         _par_iterator(CodeCache::heaps()),
-        _table_snapshot(NULL) {
+        _table_snapshot(nullptr) {
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");
   MutexLocker locker(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   _table_snapshot = ShenandoahCodeRoots::table()->snapshot_for_iteration();
@@ -294,12 +294,12 @@ ShenandoahCodeRootsIterator::ShenandoahCodeRootsIterator() :
 ShenandoahCodeRootsIterator::~ShenandoahCodeRootsIterator() {
   MonitorLocker locker(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   ShenandoahCodeRoots::table()->finish_iteration(_table_snapshot);
-  _table_snapshot = NULL;
+  _table_snapshot = nullptr;
   locker.notify_all();
 }
 
 void ShenandoahCodeRootsIterator::possibly_parallel_blobs_do(CodeBlobClosure *f) {
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");
-  assert(_table_snapshot != NULL, "Sanity");
+  assert(_table_snapshot != nullptr, "Sanity");
   _table_snapshot->parallel_blobs_do(f);
 }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp
index 5c9558fff79..1b8aefadeee 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp
@@ -48,8 +48,8 @@ ShenandoahCollectionSet::ShenandoahCollectionSet(ShenandoahHeap* heap, ReservedS
   _current_index(0) {
 
   // The collection set map is reserved to cover the entire heap *and* zero addresses.
-  // This is needed to accept in-cset checks for both heap oops and NULLs, freeing
-  // high-performance code from checking for NULL first.
+  // This is needed to accept in-cset checks for both heap oops and nulls, freeing
+  // high-performance code from checking for null first.
   //
   // Since heap_base can be far away, committing the entire map would waste memory.
   // Therefore, we only commit the parts that are needed to operate: the heap view,
@@ -158,7 +158,7 @@ ShenandoahHeapRegion* ShenandoahCollectionSet::claim_next() {
       }
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 ShenandoahHeapRegion* ShenandoahCollectionSet::next() {
@@ -173,7 +173,7 @@ ShenandoahHeapRegion* ShenandoahCollectionSet::next() {
     }
   }
 
-  return NULL;
+  return nullptr;
 }
 
 void ShenandoahCollectionSet::print_on(outputStream* out) const {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.inline.hpp
index 0a9c27c4528..1c9d6a99d05 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.inline.hpp
@@ -41,12 +41,12 @@ bool ShenandoahCollectionSet::is_in(ShenandoahHeapRegion* r) const {
 }
 
 bool ShenandoahCollectionSet::is_in(oop p) const {
-  shenandoah_assert_in_heap_or_null(NULL, p);
+  shenandoah_assert_in_heap_or_null(nullptr, p);
   return is_in_loc(cast_from_oop<void*>(p));
 }
 
 bool ShenandoahCollectionSet::is_in_loc(void* p) const {
-  assert(p == NULL || _heap->is_in(p), "Must be in the heap");
+  assert(p == nullptr || _heap->is_in(p), "Must be in the heap");
   uintx index = ((uintx) p) >> _region_size_bytes_shift;
   // no need to subtract the bottom of the heap from p,
   // _biased_cset_map is biased
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp
index 9176b625d21..7a24d1696f4 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp
@@ -914,7 +914,7 @@ class ShenandoahIsNMethodAliveClosure: public NMethodClosure {
   }
 };
 
-// This task not only evacuates/updates marked weak roots, but also "NULL"
+// This task not only evacuates/updates marked weak roots, but also "null"
 // dead weak roots.
 class ShenandoahConcurrentWeakRootsEvacUpdateTask : public WorkerTask {
 private:
@@ -962,7 +962,7 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public WorkerTask {
     // cleanup the weak oops in CLD and determinate nmethod's unloading state, so that we
     // can cleanup immediate garbage sooner.
     if (ShenandoahHeap::heap()->unload_classes()) {
-      // Applies ShenandoahIsCLDAlive closure to CLDs, native barrier will either NULL the
+      // Applies ShenandoahIsCLDAlive closure to CLDs, native barrier will either null the
       // CLD's holder or evacuate it.
       {
         ShenandoahIsCLDAliveClosure is_cld_alive;
@@ -1135,7 +1135,7 @@ void ShenandoahUpdateThreadClosure::do_thread(Thread* thread) {
   if (thread->is_Java_thread()) {
     JavaThread* jt = JavaThread::cast(thread);
     ResourceMark rm;
-    jt->oops_do(&_cl, NULL);
+    jt->oops_do(&_cl, nullptr);
   }
 }
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp
index 4cdcdae5f03..25cb4eb678e 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp
@@ -63,7 +63,7 @@ class ShenandoahConcurrentMarkingTask : public WorkerTask {
     ShenandoahWorkerTimingsTracker timer(ShenandoahPhaseTimings::conc_mark, ShenandoahPhaseTimings::ParallelMark, worker_id, true);
     ShenandoahSuspendibleThreadSetJoiner stsj(ShenandoahSuspendibleWorkers);
     ShenandoahReferenceProcessor* rp = heap->active_generation()->ref_processor();
-    assert(rp != NULL, "need reference processor");
+    assert(rp != nullptr, "need reference processor");
     StringDedup::Requests requests;
     _cm->mark_loop(GENERATION, worker_id, _terminator, rp,
                    true /*cancellable*/,
@@ -87,9 +87,9 @@ class ShenandoahSATBAndRemarkThreadsClosure : public ThreadClosure {
     // Transfer any partial buffer to the qset for completed buffer processing.
     _satb_qset.flush_queue(ShenandoahThreadLocalData::satb_mark_queue(thread));
     if (thread->is_Java_thread()) {
-      if (_cl != NULL) {
+      if (_cl != nullptr) {
         ResourceMark rm;
-        thread->oops_do(_cl, NULL);
+        thread->oops_do(_cl, nullptr);
       }
     }
   }
@@ -126,7 +126,7 @@ class ShenandoahFinalMarkingTask : public WorkerTask {
 
       ShenandoahMarkRefsClosure<GENERATION> mark_cl(q, rp, old);
       ShenandoahSATBAndRemarkThreadsClosure tc(satb_mq_set,
-                                               ShenandoahIUBarrier ? &mark_cl : NULL);
+                                               ShenandoahIUBarrier ? &mark_cl : nullptr);
       Threads::possibly_parallel_threads_do(true /* is_par */, &tc);
     }
     _cm->mark_loop(GENERATION, worker_id, _terminator, rp,
@@ -177,7 +177,7 @@ template<GenerationMode GENERATION>
 void ShenandoahMarkConcurrentRootsTask<GENERATION>::work(uint worker_id) {
   ShenandoahConcurrentWorkerSession worker_session(worker_id);
   ShenandoahObjToScanQueue* q = _queue_set->queue(worker_id);
-  ShenandoahObjToScanQueue* old = _old_queue_set == NULL ? NULL : _old_queue_set->queue(worker_id);
+  ShenandoahObjToScanQueue* old = _old_queue_set == nullptr ? nullptr : _old_queue_set->queue(worker_id);
   ShenandoahMarkRefsClosure<GENERATION> cl(q, _rp, old);
   _root_scanner.roots_do(&cl, worker_id);
 }
@@ -196,7 +196,7 @@ void ShenandoahConcurrentMark::mark_concurrent_roots() {
       break;
     }
     case GLOBAL: {
-      assert(old_task_queues() == NULL, "Global mark should not have old gen mark queues.");
+      assert(old_task_queues() == nullptr, "Global mark should not have old gen mark queues.");
       ShenandoahMarkConcurrentRootsTask<GLOBAL> task(task_queues(), old_task_queues(), rp, ShenandoahPhaseTimings::conc_mark_roots, workers->active_workers());
       workers->run_task(&task);
       break;
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
index 80ca08f2989..8b09813ef40 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
@@ -62,7 +62,7 @@ ShenandoahControlThread::ShenandoahControlThread() :
   _requested_gc_cause(GCCause::_no_cause_specified),
   _requested_generation(GenerationMode::GLOBAL),
   _degen_point(ShenandoahGC::_degenerated_outside_cycle),
-  _degen_generation(NULL),
+  _degen_generation(nullptr),
   _allocs_seen(0),
   _mode(none) {
   set_name("Shenandoah Control Thread");
@@ -143,7 +143,7 @@ void ShenandoahControlThread::run_service() {
       if (degen_point == ShenandoahGC::_degenerated_outside_cycle) {
         _degen_generation = heap->mode()->is_generational() ? heap->young_generation() : heap->global_generation();
       } else {
-        assert(_degen_generation != NULL, "Need to know which generation to resume.");
+        assert(_degen_generation != nullptr, "Need to know which generation to resume.");
       }
 
       ShenandoahHeuristics* heuristics = _degen_generation->heuristics();
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp
index 3b5ce4622fd..249a75b8b05 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp
@@ -231,7 +231,7 @@ void ShenandoahDegenGC::op_degenerated() {
           heap->sync_pinned_region_status();
           heap->collection_set()->clear_current_index();
           ShenandoahHeapRegion* r;
-          while ((r = heap->collection_set()->next()) != NULL) {
+          while ((r = heap->collection_set()->next()) != nullptr) {
             if (r->is_pinned()) {
               heap->cancel_gc(GCCause::_shenandoah_upgrade_to_full_gc);
               op_degenerated_fail();
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp
index 08a9a4963cb..cf69eb67e47 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp
@@ -32,19 +32,19 @@
 #include "runtime/javaThread.hpp"
 
 inline oop ShenandoahForwarding::get_forwardee_raw(oop obj) {
-  shenandoah_assert_in_heap(NULL, obj);
+  shenandoah_assert_in_heap(nullptr, obj);
   return get_forwardee_raw_unchecked(obj);
 }
 
 inline oop ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
   // JVMTI and JFR code use mark words for marking objects for their needs.
-  // On this path, we can encounter the "marked" object, but with NULL
+  // On this path, we can encounter the "marked" object, but with null
   // fwdptr. That object is still not forwarded, and we need to return
   // the object itself.
   markWord mark = obj->mark();
   if (mark.is_marked()) {
     HeapWord* fwdptr = (HeapWord*) mark.clear_lock_bits().to_pointer();
-    if (fwdptr != NULL) {
+    if (fwdptr != nullptr) {
       return cast_to_oop(fwdptr);
     }
   }
@@ -52,14 +52,14 @@ inline oop ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
 }
 
 inline oop ShenandoahForwarding::get_forwardee_mutator(oop obj) {
-  // Same as above, but mutator thread cannot ever see NULL forwardee.
-  shenandoah_assert_correct(NULL, obj);
+  // Same as above, but mutator thread cannot ever see null forwardee.
+  shenandoah_assert_correct(nullptr, obj);
   assert(Thread::current()->is_Java_thread(), "Must be a mutator thread");
 
   markWord mark = obj->mark();
   if (mark.is_marked()) {
     HeapWord* fwdptr = (HeapWord*) mark.clear_lock_bits().to_pointer();
-    assert(fwdptr != NULL, "Forwarding pointer is never null here");
+    assert(fwdptr != nullptr, "Forwarding pointer is never null here");
     return cast_to_oop(fwdptr);
   } else {
     return obj;
@@ -67,7 +67,7 @@ inline oop ShenandoahForwarding::get_forwardee_mutator(oop obj) {
 }
 
 inline oop ShenandoahForwarding::get_forwardee(oop obj) {
-  shenandoah_assert_correct(NULL, obj);
+  shenandoah_assert_correct(nullptr, obj);
   return get_forwardee_raw_unchecked(obj);
 }
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp
index 5e31061151b..b3dee45c93a 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp
@@ -83,7 +83,7 @@ HeapWord* ShenandoahFreeSet::allocate_with_old_affiliation(ShenandoahAllocReques
     if (r->affiliation() == affiliation && !r->is_humongous()) {
       if (!r->is_cset() && !has_no_alloc_capacity(r)) {
         HeapWord* result = try_allocate_in(r, req, in_new_region);
-        if (result != NULL) {
+        if (result != nullptr) {
           return result;
         }
       }
@@ -100,13 +100,13 @@ HeapWord* ShenandoahFreeSet::allocate_with_affiliation(ShenandoahRegionAffiliati
       ShenandoahHeapRegion* r = _heap->get_region(idx);
       if (r->affiliation() == affiliation) {
         HeapWord* result = try_allocate_in(r, req, in_new_region);
-        if (result != NULL) {
+        if (result != nullptr) {
           return result;
         }
       }
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool& in_new_region) {
@@ -155,7 +155,7 @@ HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool&
         if (is_mutator_free(idx) && (allow_new_region || r->affiliation() != ShenandoahRegionAffiliation::FREE)) {
           // try_allocate_in() increases used if the allocation is successful.
           HeapWord* result = try_allocate_in(r, req, in_new_region);
-          if (result != NULL) {
+          if (result != nullptr) {
             return result;
           }
         }
@@ -180,20 +180,20 @@ HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool&
       } else {
         result = allocate_with_affiliation(req.affiliation(), req, in_new_region);
       }
-      if (result != NULL) {
+      if (result != nullptr) {
         return result;
       }
       if (allow_new_region) {
         // Then try a free region that is dedicated to GC allocations.
         result = allocate_with_affiliation(FREE, req, in_new_region);
-        if (result != NULL) {
+        if (result != nullptr) {
           return result;
         }
       }
 
       // No dice. Can we borrow space from mutator view?
       if (!ShenandoahEvacReserveOverflow) {
-        return NULL;
+        return nullptr;
       }
 
       if (allow_new_region) {
@@ -205,7 +205,7 @@ HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool&
             if (can_allocate_from(r)) {
               flip_to_gc(r);
               HeapWord *result = try_allocate_in(r, req, in_new_region);
-              if (result != NULL) {
+              if (result != nullptr) {
                 return result;
               }
             }
@@ -221,7 +221,7 @@ HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool&
     default:
       ShouldNotReachHere();
   }
-  return NULL;
+  return nullptr;
 }
 
 HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool& in_new_region) {
@@ -229,7 +229,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
 
   if (_heap->is_concurrent_weak_root_in_progress() &&
       r->is_trash()) {
-    return NULL;
+    return nullptr;
   }
   try_recycle_trashed(r);
   if (r->affiliation() == ShenandoahRegionAffiliation::FREE) {
@@ -255,11 +255,11 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
                   PTR_FORMAT " at transition from FREE to %s",
                   r->index(), p2i(ctx->top_bitmap(r)), affiliation_name(req.affiliation()));
   } else if (r->affiliation() != req.affiliation()) {
-    return NULL;
+    return nullptr;
   }
 
   in_new_region = r->is_empty();
-  HeapWord* result = NULL;
+  HeapWord* result = nullptr;
   size_t size = req.size();
 
   // req.size() is in words, r->free() is in bytes.
@@ -314,7 +314,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
           _heap->increase_used(padding);
         }
       }
-      // Otherwise, leave result == NULL because the adjusted size is smaller than min size.
+      // Otherwise, leave result == nullptr because the adjusted size is smaller than min size.
     } else {
       // This is a GCLAB or a TLAB allocation
       size_t free = align_down(r->free() >> LogHeapWordSize, MinObjAlignment);
@@ -327,7 +327,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
           // Record actual allocation size
           req.set_actual_size(size);
         }
-        assert (result != NULL, "Allocation must succeed: free " SIZE_FORMAT ", actual " SIZE_FORMAT, free, size);
+        assert (result != nullptr, "Allocation must succeed: free " SIZE_FORMAT ", actual " SIZE_FORMAT, free, size);
       } else {
         log_trace(gc, ergo)("Failed to shrink TLAB or GCLAB request (" SIZE_FORMAT ") in region " SIZE_FORMAT " to " SIZE_FORMAT
                            " because min_size() is " SIZE_FORMAT, req.size(), r->index(), size, req.min_size());
@@ -373,7 +373,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
     }
   }
 
-  if (result != NULL) {
+  if (result != nullptr) {
     // Allocation successful, bump stats:
     if (req.is_mutator_alloc()) {
       // Mutator allocations always pull from young gen.
@@ -401,7 +401,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
       }
     }
   }
-  if (result == NULL || has_no_alloc_capacity(r)) {
+  if (result == nullptr || has_no_alloc_capacity(r)) {
     // Region cannot afford this or future allocations. Retire it.
     //
     // While this seems a bit harsh, especially in the case when this large allocation does not
@@ -475,7 +475,7 @@ HeapWord* ShenandoahFreeSet::allocate_contiguous(ShenandoahAllocRequest& req) {
 
   // No regions left to satisfy allocation, bye.
   if (num > mutator_count() || (num > avail_young_regions)) {
-    return NULL;
+    return nullptr;
   }
 
   // Find the continuous interval of $num regions, starting from $beg and ending in $end,
@@ -487,7 +487,7 @@ HeapWord* ShenandoahFreeSet::allocate_contiguous(ShenandoahAllocRequest& req) {
   while (true) {
     if (end >= _max) {
       // Hit the end, goodbye
-      return NULL;
+      return nullptr;
     }
 
     // If regions are not adjacent, then current [beg; end] is useless, and we may fast-forward.
@@ -819,10 +819,10 @@ HeapWord* ShenandoahFreeSet::allocate(ShenandoahAllocRequest& req, bool& in_new_
         in_new_region = false;
         assert(false, "Trying to allocate TLAB larger than the humongous threshold: " SIZE_FORMAT " > " SIZE_FORMAT,
                req.size(), ShenandoahHeapRegion::humongous_threshold_words());
-        return NULL;
+        return nullptr;
       default:
         ShouldNotReachHere();
-        return NULL;
+        return nullptr;
     }
   } else {
     return allocate_single(req, in_new_region);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
index 9d110d7fb9f..ce2a80974c0 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
@@ -83,7 +83,7 @@ class ShenandoahReconstructRememberedSetTask : public WorkerTask {
     RememberedScanner* scanner = heap->card_scan();
     ShenandoahSetRememberedCardsToDirtyClosure dirty_cards_for_interesting_pointers;
 
-    while (r != NULL) {
+    while (r != nullptr) {
       if (r->is_old() && r->is_active()) {
         HeapWord* obj_addr = r->bottom();
         if (r->is_humongous_start()) {
@@ -467,7 +467,7 @@ class ShenandoahPrepareForGenerationalCompactionObjectClosure : public ObjectClo
       _empty_regions_pos(0),
       _old_to_region(old_to_region),
       _young_to_region(young_to_region),
-      _from_region(NULL),
+      _from_region(nullptr),
       _old_compact_point((old_to_region != nullptr)? old_to_region->bottom(): nullptr),
       _young_compact_point((young_to_region != nullptr)? young_to_region->bottom(): nullptr),
       _worker_id(worker_id) {}
@@ -523,7 +523,7 @@ class ShenandoahPrepareForGenerationalCompactionObjectClosure : public ObjectClo
   }
 
   void do_object(oop p) {
-    assert(_from_region != NULL, "must set before work");
+    assert(_from_region != nullptr, "must set before work");
     assert((_from_region->bottom() <= cast_from_oop<HeapWord*>(p)) && (cast_from_oop<HeapWord*>(p) < _from_region->top()),
            "Object must reside in _from_region");
     assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
@@ -557,7 +557,7 @@ class ShenandoahPrepareForGenerationalCompactionObjectClosure : public ObjectClo
     }
 
     if (promote_object || (_from_affiliation == ShenandoahRegionAffiliation::OLD_GENERATION)) {
-      assert(_old_to_region != nullptr, "_old_to_region should not be NULL when evacuating to OLD region");
+      assert(_old_to_region != nullptr, "_old_to_region should not be nullptr when evacuating to OLD region");
       if (_old_compact_point + obj_size > _old_to_region->end()) {
         ShenandoahHeapRegion* new_to_region;
 
@@ -579,21 +579,21 @@ class ShenandoahPrepareForGenerationalCompactionObjectClosure : public ObjectClo
         }
 
         assert(new_to_region != _old_to_region, "must not reuse same OLD to-region");
-        assert(new_to_region != NULL, "must not be NULL");
+        assert(new_to_region != nullptr, "must not be nullptr");
         _old_to_region = new_to_region;
         _old_compact_point = _old_to_region->bottom();
       }
 
       // Object fits into current region, record new location:
       assert(_old_compact_point + obj_size <= _old_to_region->end(), "must fit");
-      shenandoah_assert_not_forwarded(NULL, p);
+      shenandoah_assert_not_forwarded(nullptr, p);
       _preserved_marks->push_if_necessary(p, p->mark());
       p->forward_to(cast_to_oop(_old_compact_point));
       _old_compact_point += obj_size;
     } else {
       assert(_from_affiliation == ShenandoahRegionAffiliation::YOUNG_GENERATION,
              "_from_region must be OLD_GENERATION or YOUNG_GENERATION");
-      assert(_young_to_region != nullptr, "_young_to_region should not be NULL when compacting YOUNG _from_region");
+      assert(_young_to_region != nullptr, "_young_to_region should not be nullptr when compacting YOUNG _from_region");
 
       // After full gc compaction, all regions have age 0.  Embed the region's age into the object's age in order to preserve
       // tenuring progress.
@@ -624,14 +624,14 @@ class ShenandoahPrepareForGenerationalCompactionObjectClosure : public ObjectClo
         }
 
         assert(new_to_region != _young_to_region, "must not reuse same OLD to-region");
-        assert(new_to_region != NULL, "must not be NULL");
+        assert(new_to_region != nullptr, "must not be nullptr");
         _young_to_region = new_to_region;
         _young_compact_point = _young_to_region->bottom();
       }
 
       // Object fits into current region, record new location:
       assert(_young_compact_point + obj_size <= _young_to_region->end(), "must fit");
-      shenandoah_assert_not_forwarded(NULL, p);
+      shenandoah_assert_not_forwarded(nullptr, p);
       _preserved_marks->push_if_necessary(p, p->mark());
       p->forward_to(cast_to_oop(_young_compact_point));
       _young_compact_point += obj_size;
@@ -659,7 +659,7 @@ class ShenandoahPrepareForCompactionObjectClosure : public ObjectClosure {
     _empty_regions(empty_regions),
     _empty_regions_pos(0),
     _to_region(to_region),
-    _from_region(NULL),
+    _from_region(nullptr),
     _compact_point(to_region->bottom()) {}
 
   void set_from_region(ShenandoahHeapRegion* from_region) {
@@ -667,7 +667,7 @@ class ShenandoahPrepareForCompactionObjectClosure : public ObjectClosure {
   }
 
   void finish_region() {
-    assert(_to_region != NULL, "should not happen");
+    assert(_to_region != nullptr, "should not happen");
     assert(!_heap->mode()->is_generational(), "Generational GC should use different Closure");
     _to_region->set_new_top(_compact_point);
   }
@@ -681,7 +681,7 @@ class ShenandoahPrepareForCompactionObjectClosure : public ObjectClosure {
   }
 
   void do_object(oop p) {
-    assert(_from_region != NULL, "must set before work");
+    assert(_from_region != nullptr, "must set before work");
     assert(_heap->complete_marking_context()->is_marked(p), "must be marked");
     assert(!_heap->complete_marking_context()->allocated_after_mark_start(p), "must be truly marked");
 
@@ -700,14 +700,14 @@ class ShenandoahPrepareForCompactionObjectClosure : public ObjectClosure {
       }
 
       assert(new_to_region != _to_region, "must not reuse same to-region");
-      assert(new_to_region != NULL, "must not be NULL");
+      assert(new_to_region != nullptr, "must not be null");
       _to_region = new_to_region;
       _compact_point = _to_region->bottom();
     }
 
     // Object fits into current region, record new location:
     assert(_compact_point + obj_size <= _to_region->end(), "must fit");
-    shenandoah_assert_not_forwarded(NULL, p);
+    shenandoah_assert_not_forwarded(nullptr, p);
     _preserved_marks->push_if_necessary(p, p->mark());
     p->forward_to(cast_to_oop(_compact_point));
     _compact_point += obj_size;
@@ -729,7 +729,7 @@ void ShenandoahPrepareForCompactionTask::work(uint worker_id) {
   ShenandoahHeapRegionSetIterator it(slice);
   ShenandoahHeapRegion* from_region = it.next();
   // No work?
-  if (from_region == NULL) {
+  if (from_region == nullptr) {
     return;
   }
 
@@ -744,7 +744,7 @@ void ShenandoahPrepareForCompactionTask::work(uint worker_id) {
     ShenandoahHeapRegion* young_to_region = (from_region->is_young())? from_region: nullptr;
     ShenandoahPrepareForGenerationalCompactionObjectClosure cl(this, _preserved_marks->get(worker_id), empty_regions,
                                                                old_to_region, young_to_region, worker_id);
-    while (from_region != NULL) {
+    while (from_region != nullptr) {
       assert(is_candidate_region(from_region), "Sanity");
       log_debug(gc)("Worker %u compacting %s Region " SIZE_FORMAT " which had used " SIZE_FORMAT " and %s live",
                     worker_id, affiliation_name(from_region->affiliation()),
@@ -768,7 +768,7 @@ void ShenandoahPrepareForCompactionTask::work(uint worker_id) {
     }
   } else {
     ShenandoahPrepareForCompactionObjectClosure cl(_preserved_marks->get(worker_id), empty_regions, from_region);
-    while (from_region != NULL) {
+    while (from_region != nullptr) {
       assert(is_candidate_region(from_region), "Sanity");
       cl.set_from_region(from_region);
       if (from_region->has_live()) {
@@ -1031,7 +1031,7 @@ void ShenandoahFullGC::distribute_slices(ShenandoahHeapRegionSet** worker_slices
   for (size_t wid = 0; wid < n_workers; wid++) {
     ShenandoahHeapRegionSetIterator it(worker_slices[wid]);
     ShenandoahHeapRegion* r = it.next();
-    while (r != NULL) {
+    while (r != nullptr) {
       size_t idx = r->index();
       assert(ShenandoahPrepareForCompactionTask::is_candidate_region(r), "Sanity: " SIZE_FORMAT, idx);
       assert(!map.at(idx), "No region distributed twice: " SIZE_FORMAT, idx);
@@ -1153,7 +1153,7 @@ class ShenandoahAdjustPointersTask : public WorkerTask {
     ShenandoahParallelWorkerSession worker_session(worker_id);
     ShenandoahAdjustPointersObjectClosure obj_cl;
     ShenandoahHeapRegion* r = _regions.next();
-    while (r != NULL) {
+    while (r != nullptr) {
       if (!r->is_humongous_continuation() && r->has_live()) {
         _heap->marked_object_iterate(r, &obj_cl);
       }
@@ -1253,7 +1253,7 @@ class ShenandoahCompactObjectsTask : public WorkerTask {
 
     ShenandoahCompactObjectsClosure cl(worker_id);
     ShenandoahHeapRegion* r = slice.next();
-    while (r != NULL) {
+    while (r != nullptr) {
       assert(!r->is_humongous(), "must not get humongous regions here");
       if (r->has_live()) {
         _heap->marked_object_iterate(r, &cl);
@@ -1419,7 +1419,7 @@ class ShenandoahMCResetCompleteBitmapTask : public WorkerTask {
     ShenandoahHeapRegion* region = _regions.next();
     ShenandoahHeap* heap = ShenandoahHeap::heap();
     ShenandoahMarkingContext* const ctx = heap->complete_marking_context();
-    while (region != NULL) {
+    while (region != nullptr) {
       if (heap->is_bitmap_slice_committed(region) && !region->is_pinned() && region->has_live()) {
         ctx->clear_bitmap(region);
       }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp
index dcf5625ca5f..36dbb156201 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp
@@ -928,7 +928,7 @@ void ShenandoahGeneration::scan_remembered_set(bool is_concurrent) {
   heap->assert_gc_workers(nworkers);
   heap->workers()->run_task(&task);
   if (ShenandoahEnableCardStats) {
-    assert(heap->card_scan() != NULL, "Not generational");
+    assert(heap->card_scan() != nullptr, "Not generational");
     heap->card_scan()->log_card_stats(nworkers, CARD_STAT_SCAN_RS);
   }
 }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
index 8ffae9ea282..35798fdc101 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
@@ -112,7 +112,7 @@ class ShenandoahPretouchHeapTask : public WorkerTask {
 
   virtual void work(uint worker_id) {
     ShenandoahHeapRegion* r = _regions.next();
-    while (r != NULL) {
+    while (r != nullptr) {
       if (r->is_committed()) {
         os::pretouch_memory(r->bottom(), r->end(), _page_size);
       }
@@ -136,7 +136,7 @@ class ShenandoahPretouchBitmapTask : public WorkerTask {
 
   virtual void work(uint worker_id) {
     ShenandoahHeapRegion* r = _regions.next();
-    while (r != NULL) {
+    while (r != nullptr) {
       size_t start = r->index()       * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
       size_t end   = (r->index() + 1) * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
       assert (end <= _bitmap_size, "end is sane: " SIZE_FORMAT " < " SIZE_FORMAT, end, _bitmap_size);
@@ -237,7 +237,7 @@ jint ShenandoahHeap::initialize() {
   }
 
   _workers = new ShenandoahWorkerThreads("Shenandoah GC Threads", _max_workers);
-  if (_workers == NULL) {
+  if (_workers == nullptr) {
     vm_exit_during_initialization("Failed necessary allocation.");
   } else {
     _workers->initialize_workers();
@@ -347,7 +347,7 @@ jint ShenandoahHeap::initialize() {
       }
     }
 
-    if (_collection_set == NULL) {
+    if (_collection_set == nullptr) {
       ReservedSpace cset_rs(cset_size, cset_align, os::vm_page_size());
       _collection_set = new ShenandoahCollectionSet(this, cset_rs, sh_rs.base());
     }
@@ -437,7 +437,7 @@ jint ShenandoahHeap::initialize() {
     _pacer = new ShenandoahPacer(this);
     _pacer->setup_for_idle();
   } else {
-    _pacer = NULL;
+    _pacer = nullptr;
   }
 
   _control_thread = new ShenandoahControlThread();
@@ -487,7 +487,7 @@ void ShenandoahHeap::initialize_generations() {
 }
 
 void ShenandoahHeap::initialize_heuristics() {
-  if (ShenandoahGCMode != NULL) {
+  if (ShenandoahGCMode != nullptr) {
     if (strcmp(ShenandoahGCMode, "satb") == 0) {
       _gc_mode = new ShenandoahSATBMode();
     } else if (strcmp(ShenandoahGCMode, "iu") == 0) {
@@ -530,18 +530,18 @@ void ShenandoahHeap::initialize_heuristics() {
 
 ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) :
   CollectedHeap(),
-  _gc_generation(NULL),
+  _gc_generation(nullptr),
   _prepare_for_old_mark(false),
   _initial_size(0),
   _used(0),
   _committed(0),
   _max_workers(MAX3(ConcGCThreads, ParallelGCThreads, 1U)),
-  _workers(NULL),
-  _safepoint_workers(NULL),
+  _workers(nullptr),
+  _safepoint_workers(nullptr),
   _heap_region_special(false),
   _num_regions(0),
-  _regions(NULL),
-  _affiliations(NULL),
+  _regions(nullptr),
+  _affiliations(nullptr),
   _update_refs_iterator(this),
   _alloc_supplement_reserve(0),
   _promoted_reserve(0),
@@ -551,37 +551,37 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) :
   _captured_old_usage(0),
   _previous_promotion(0),
   _cancel_requested_time(0),
-  _young_generation(NULL),
-  _global_generation(NULL),
-  _old_generation(NULL),
-  _control_thread(NULL),
-  _regulator_thread(NULL),
+  _young_generation(nullptr),
+  _global_generation(nullptr),
+  _old_generation(nullptr),
+  _control_thread(nullptr),
+  _regulator_thread(nullptr),
   _shenandoah_policy(policy),
-  _free_set(NULL),
-  _pacer(NULL),
-  _verifier(NULL),
-  _phase_timings(NULL),
+  _free_set(nullptr),
+  _pacer(nullptr),
+  _verifier(nullptr),
+  _phase_timings(nullptr),
   _evac_tracker(new ShenandoahEvacuationTracker()),
   _mmu_tracker(),
   _generation_sizer(&_mmu_tracker),
-  _monitoring_support(NULL),
-  _memory_pool(NULL),
-  _young_gen_memory_pool(NULL),
-  _old_gen_memory_pool(NULL),
+  _monitoring_support(nullptr),
+  _memory_pool(nullptr),
+  _young_gen_memory_pool(nullptr),
+  _old_gen_memory_pool(nullptr),
   _stw_memory_manager("Shenandoah Pauses", "end of GC pause"),
   _cycle_memory_manager("Shenandoah Cycles", "end of GC cycle"),
   _gc_timer(new ConcurrentGCTimer()),
   _soft_ref_policy(),
   _log_min_obj_alignment_in_bytes(LogMinObjAlignmentInBytes),
-  _marking_context(NULL),
+  _marking_context(nullptr),
   _bitmap_size(0),
   _bitmap_regions_per_slice(0),
   _bitmap_bytes_per_slice(0),
   _bitmap_region_special(false),
   _aux_bitmap_region_special(false),
-  _liveness_cache(NULL),
-  _collection_set(NULL),
-  _card_scan(NULL)
+  _liveness_cache(nullptr),
+  _collection_set(nullptr),
+  _card_scan(nullptr)
 {
 }
 
@@ -628,11 +628,11 @@ void ShenandoahHeap::print_on(outputStream* st) const {
 
   ShenandoahCollectionSet* cset = collection_set();
   st->print_cr("Collection set:");
-  if (cset != NULL) {
+  if (cset != nullptr) {
     st->print_cr(" - map (vanilla): " PTR_FORMAT, p2i(cset->map_address()));
     st->print_cr(" - map (biased):  " PTR_FORMAT, p2i(cset->biased_map_address()));
   } else {
-    st->print_cr(" (NULL)");
+    st->print_cr(" (null)");
   }
 
   st->cr();
@@ -646,7 +646,7 @@ void ShenandoahHeap::print_on(outputStream* st) const {
 class ShenandoahInitWorkerGCLABClosure : public ThreadClosure {
 public:
   void do_thread(Thread* thread) {
-    assert(thread != NULL, "Sanity");
+    assert(thread != nullptr, "Sanity");
     assert(thread->is_Worker_thread(), "Only worker thread expected");
     ShenandoahThreadLocalData::initialize_gclab(thread);
   }
@@ -664,7 +664,7 @@ void ShenandoahHeap::post_initialize() {
   // gclab can not be initialized early during VM startup, as it can not determinate its max_size.
   // Now, we will let WorkerThreads to initialize gclab when new worker is created.
   _workers->set_initialize_gclab();
-  if (_safepoint_workers != NULL) {
+  if (_safepoint_workers != nullptr) {
     _safepoint_workers->threads_do(&init_gclabs);
     _safepoint_workers->set_initialize_gclab();
   }
@@ -688,7 +688,7 @@ bool ShenandoahHeap::is_old_bitmap_stable() const {
 }
 
 bool ShenandoahHeap::is_gc_generation_young() const {
-  return _gc_generation != NULL && _gc_generation->generation_mode() == YOUNG;
+  return _gc_generation != nullptr && _gc_generation->generation_mode() == YOUNG;
 }
 
 size_t ShenandoahHeap::used() const {
@@ -892,7 +892,7 @@ HeapWord* ShenandoahHeap::allocate_from_gclab_slow(Thread* thread, size_t size)
   if (new_size < size) {
     // New size still does not fit the object. Fall back to shared allocation.
     // This avoids retiring perfectly good GCLABs, when we encounter a large object.
-    return NULL;
+    return nullptr;
   }
 
   // Retire current GCLAB, and allocate a new one.
@@ -901,8 +901,8 @@ HeapWord* ShenandoahHeap::allocate_from_gclab_slow(Thread* thread, size_t size)
 
   size_t actual_size = 0;
   HeapWord* gclab_buf = allocate_new_gclab(min_size, new_size, &actual_size);
-  if (gclab_buf == NULL) {
-    return NULL;
+  if (gclab_buf == nullptr) {
+    return nullptr;
   }
 
   assert (size <= actual_size, "allocation should fit");
@@ -973,8 +973,8 @@ HeapWord* ShenandoahHeap::allocate_from_plab_slow(Thread* thread, size_t size, b
     // allocate_new_plab resets plab_evacuated and plab_promoted and disables promotions if old-gen available is
     // less than the remaining evacuation need.  It also adjusts plab_preallocated and expend_promoted if appropriate.
     HeapWord* plab_buf = allocate_new_plab(min_size, cur_size, &actual_size);
-    if (plab_buf == NULL) {
-      return NULL;
+    if (plab_buf == nullptr) {
+      return nullptr;
     } else {
       ShenandoahThreadLocalData::enable_plab_retries(thread);
     }
@@ -1032,7 +1032,7 @@ void ShenandoahHeap::retire_plab(PLAB* plab, Thread* thread) {
   size_t waste = plab->waste();
   HeapWord* top = plab->top();
   plab->retire();
-  if (top != NULL && plab->waste() > waste && is_in_old(top)) {
+  if (top != nullptr && plab->waste() > waste && is_in_old(top)) {
     // If retiring the plab created a filler object, then we
     // need to register it with our card scanner so it can
     // safely walk the region backing the plab.
@@ -1049,7 +1049,7 @@ void ShenandoahHeap::retire_plab(PLAB* plab) {
 
 void ShenandoahHeap::cancel_old_gc() {
   shenandoah_assert_safepoint();
-  assert(_old_generation != NULL, "Should only have mixed collections in generation mode.");
+  assert(_old_generation != nullptr, "Should only have mixed collections in generation mode.");
   log_info(gc)("Terminating old gc cycle.");
 
   // Stop marking
@@ -1107,7 +1107,7 @@ HeapWord* ShenandoahHeap::allocate_new_tlab(size_t min_size,
                                             size_t* actual_size) {
   ShenandoahAllocRequest req = ShenandoahAllocRequest::for_tlab(min_size, requested_size);
   HeapWord* res = allocate_memory(req, false);
-  if (res != NULL) {
+  if (res != nullptr) {
     *actual_size = req.actual_size();
   } else {
     *actual_size = 0;
@@ -1120,7 +1120,7 @@ HeapWord* ShenandoahHeap::allocate_new_gclab(size_t min_size,
                                              size_t* actual_size) {
   ShenandoahAllocRequest req = ShenandoahAllocRequest::for_gclab(min_size, word_size);
   HeapWord* res = allocate_memory(req, false);
-  if (res != NULL) {
+  if (res != nullptr) {
     *actual_size = req.actual_size();
   } else {
     *actual_size = 0;
@@ -1135,7 +1135,7 @@ HeapWord* ShenandoahHeap::allocate_new_plab(size_t min_size,
   // Note that allocate_memory() sets a thread-local flag to prohibit further promotions by this thread
   // if we are at risk of exceeding the old-gen evacuation budget.
   HeapWord* res = allocate_memory(req, false);
-  if (res != NULL) {
+  if (res != nullptr) {
     *actual_size = req.actual_size();
   } else {
     *actual_size = 0;
@@ -1148,7 +1148,7 @@ HeapWord* ShenandoahHeap::allocate_new_plab(size_t min_size,
 HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req, bool is_promotion) {
   intptr_t pacer_epoch = 0;
   bool in_new_region = false;
-  HeapWord* result = NULL;
+  HeapWord* result = nullptr;
 
   if (req.is_mutator_alloc()) {
     if (ShenandoahPacing) {
@@ -1170,12 +1170,12 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req, bool is_p
     // Then, we need to make sure the allocation was retried after at least one
     // Full GC, which means we want to try more than ShenandoahFullGCThreshold times.
     size_t tries = 0;
-    while (result == NULL && _progress_last_gc.is_set()) {
+    while (result == nullptr && _progress_last_gc.is_set()) {
       tries++;
       control_thread()->handle_alloc_failure(req);
       result = allocate_memory_under_lock(req, in_new_region, is_promotion);
     }
-    while (result == NULL && tries <= ShenandoahFullGCThreshold) {
+    while (result == nullptr && tries <= ShenandoahFullGCThreshold) {
       tries++;
       control_thread()->handle_alloc_failure(req);
       result = allocate_memory_under_lock(req, in_new_region, is_promotion);
@@ -1192,7 +1192,7 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req, bool is_p
     regulator_thread()->notify_heap_changed();
   }
 
-  if (result != NULL) {
+  if (result != nullptr) {
     ShenandoahGeneration* alloc_generation = generation_for(req.affiliation());
     size_t requested = req.size();
     size_t actual = req.actual_size();
@@ -1292,7 +1292,7 @@ HeapWord* ShenandoahHeap::allocate_memory_under_lock(ShenandoahAllocRequest& req
 
     if (!try_smaller_lab_size) {
       result = (allow_allocation)? _free_set->allocate(req, in_new_region): nullptr;
-      if (result != NULL) {
+      if (result != nullptr) {
         if (req.affiliation() == ShenandoahRegionAffiliation::OLD_GENERATION) {
           ShenandoahThreadLocalData::reset_plab_promoted(thread);
           if (req.is_gc_alloc()) {
@@ -1407,7 +1407,7 @@ MetaWord* ShenandoahHeap::satisfy_failed_metadata_allocation(ClassLoaderData* lo
 
   // Expand and retry allocation
   result = loader_data->metaspace_non_null()->expand_and_allocate(size, mdtype);
-  if (result != NULL) {
+  if (result != nullptr) {
     return result;
   }
 
@@ -1416,18 +1416,18 @@ MetaWord* ShenandoahHeap::satisfy_failed_metadata_allocation(ClassLoaderData* lo
 
   // Retry allocation
   result = loader_data->metaspace_non_null()->allocate(size, mdtype);
-  if (result != NULL) {
+  if (result != nullptr) {
     return result;
   }
 
   // Expand and retry allocation
   result = loader_data->metaspace_non_null()->expand_and_allocate(size, mdtype);
-  if (result != NULL) {
+  if (result != nullptr) {
     return result;
   }
 
   // Out of memory
-  return NULL;
+  return nullptr;
 }
 
 class ShenandoahConcurrentEvacuateRegionObjectClosure : public ObjectClosure {
@@ -1439,7 +1439,7 @@ class ShenandoahConcurrentEvacuateRegionObjectClosure : public ObjectClosure {
     _heap(heap), _thread(Thread::current()) {}
 
   void do_object(oop p) {
-    shenandoah_assert_marked(NULL, p);
+    shenandoah_assert_marked(nullptr, p);
     if (!p->is_forwarded()) {
       _heap->evacuate_object(p, _thread);
     }
@@ -1478,7 +1478,7 @@ class ShenandoahEvacuationTask : public WorkerTask {
   void do_work() {
     ShenandoahConcurrentEvacuateRegionObjectClosure cl(_sh);
     ShenandoahHeapRegion* r;
-    while ((r =_cs->claim_next()) != NULL) {
+    while ((r =_cs->claim_next()) != nullptr) {
       assert(r->has_live(), "Region " SIZE_FORMAT " should have been reclaimed early", r->index());
 
       _sh->marked_object_iterate(r, &cl);
@@ -1580,7 +1580,7 @@ void ShenandoahHeap::trash_cset_regions() {
   ShenandoahCollectionSet* set = collection_set();
   ShenandoahHeapRegion* r;
   set->clear_current_index();
-  while ((r = set->next()) != NULL) {
+  while ((r = set->next()) != nullptr) {
     r->make_trash();
   }
   collection_set()->clear();
@@ -1626,11 +1626,11 @@ class ShenandoahCheckCleanGCLABClosure : public ThreadClosure {
   ShenandoahCheckCleanGCLABClosure() {}
   void do_thread(Thread* thread) {
     PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
-    assert(gclab != NULL, "GCLAB should be initialized for %s", thread->name());
+    assert(gclab != nullptr, "GCLAB should be initialized for %s", thread->name());
     assert(gclab->words_remaining() == 0, "GCLAB should not need retirement");
 
     PLAB* plab = ShenandoahThreadLocalData::plab(thread);
-    assert(plab != NULL, "PLAB should be initialized for %s", thread->name());
+    assert(plab != nullptr, "PLAB should be initialized for %s", thread->name());
     assert(plab->words_remaining() == 0, "PLAB should not need retirement");
   }
 };
@@ -1642,14 +1642,14 @@ class ShenandoahRetireGCLABClosure : public ThreadClosure {
   ShenandoahRetireGCLABClosure(bool resize) : _resize(resize) {}
   void do_thread(Thread* thread) {
     PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
-    assert(gclab != NULL, "GCLAB should be initialized for %s", thread->name());
+    assert(gclab != nullptr, "GCLAB should be initialized for %s", thread->name());
     gclab->retire();
     if (_resize && ShenandoahThreadLocalData::gclab_size(thread) > 0) {
       ShenandoahThreadLocalData::set_gclab_size(thread, 0);
     }
 
     PLAB* plab = ShenandoahThreadLocalData::plab(thread);
-    assert(plab != NULL, "PLAB should be initialized for %s", thread->name());
+    assert(plab != nullptr, "PLAB should be initialized for %s", thread->name());
 
     // There are two reasons to retire all plabs between old-gen evacuation passes.
     //  1. We need to make the plab memory parseable by remembered-set scanning.
@@ -1710,7 +1710,7 @@ void ShenandoahHeap::gclabs_retire(bool resize) {
   }
   workers()->threads_do(&cl);
 
-  if (safepoint_workers() != NULL) {
+  if (safepoint_workers() != nullptr) {
     safepoint_workers()->threads_do(&cl);
   }
 }
@@ -1719,7 +1719,7 @@ class ShenandoahTagGCLABClosure : public ThreadClosure {
 public:
   void do_thread(Thread* thread) {
     PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
-    assert(gclab != NULL, "GCLAB should be initialized for %s", thread->name());
+    assert(gclab != nullptr, "GCLAB should be initialized for %s", thread->name());
     if (gclab->words_remaining() > 0) {
       ShenandoahHeapRegion* r = ShenandoahHeap::heap()->heap_region_containing(gclab->allocate(0));
       r->set_young_lab_flag();
@@ -1739,7 +1739,7 @@ void ShenandoahHeap::set_young_lab_region_flags() {
   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
     cl.do_thread(t);
     ThreadLocalAllocBuffer& tlab = t->tlab();
-    if (tlab.end() != NULL) {
+    if (tlab.end() != nullptr) {
       ShenandoahHeapRegion* r = heap_region_containing(tlab.start());
       r->set_young_lab_flag();
     }
@@ -1776,10 +1776,10 @@ void ShenandoahHeap::do_full_collection(bool clear_all_soft_refs) {
 
 HeapWord* ShenandoahHeap::block_start(const void* addr) const {
   ShenandoahHeapRegion* r = heap_region_containing(addr);
-  if (r != NULL) {
+  if (r != nullptr) {
     return r->block_start(addr);
   }
-  return NULL;
+  return nullptr;
 }
 
 bool ShenandoahHeap::block_is_obj(const HeapWord* addr) const {
@@ -1801,7 +1801,7 @@ void ShenandoahHeap::gc_threads_do(ThreadClosure* tcl) const {
   tcl->do_thread(_control_thread);
   tcl->do_thread(_regulator_thread);
   workers()->threads_do(tcl);
-  if (_safepoint_workers != NULL) {
+  if (_safepoint_workers != nullptr) {
     _safepoint_workers->threads_do(tcl);
   }
   if (ShenandoahStringDedup::is_enabled()) {
@@ -1970,7 +1970,7 @@ void ShenandoahHeap::scan_roots_for_iteration(ShenandoahScanObjectStack* oop_sta
   // This populates the work stack with initial objects
   // It is important to relinquish the associated locks before diving
   // into heap dumper
-  uint n_workers = safepoint_workers() != NULL ? safepoint_workers()->active_workers() : 1;
+  uint n_workers = safepoint_workers() != nullptr ? safepoint_workers()->active_workers() : 1;
   ShenandoahHeapIterationRootScanner rp(n_workers);
   rp.roots_do(oops);
 }
@@ -2049,16 +2049,16 @@ class ShenandoahParallelObjectIterator : public ParallelObjectIteratorImpl {
     // Reclaim bitmap
     _heap->reclaim_aux_bitmap_for_iteration();
     // Reclaim queue for workers
-    if (_task_queues!= NULL) {
+    if (_task_queues!= nullptr) {
       for (uint i = 0; i < _num_workers; ++i) {
         ShenandoahObjToScanQueue* q = _task_queues->queue(i);
-        if (q != NULL) {
+        if (q != nullptr) {
           delete q;
-          _task_queues->register_queue(i, NULL);
+          _task_queues->register_queue(i, nullptr);
         }
       }
       delete _task_queues;
-      _task_queues = NULL;
+      _task_queues = nullptr;
     }
   }
 
@@ -2098,10 +2098,10 @@ class ShenandoahParallelObjectIterator : public ParallelObjectIteratorImpl {
                                uint worker_id,
                                ShenandoahObjToScanQueueSet* queue_set) {
     assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
-    assert(queue_set != NULL, "task queue must not be NULL");
+    assert(queue_set != nullptr, "task queue must not be null");
 
     ShenandoahObjToScanQueue* q = queue_set->queue(worker_id);
-    assert(q != NULL, "object iterate queue must not be NULL");
+    assert(q != nullptr, "object iterate queue must not be null");
 
     ShenandoahMarkTask t;
     ShenandoahObjectIterateParScanClosure oops(_aux_bit_map, q);
@@ -2124,7 +2124,7 @@ ParallelObjectIteratorImpl* ShenandoahHeap::parallel_object_iterator(uint worker
 
 // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
 void ShenandoahHeap::keep_alive(oop obj) {
-  if (is_concurrent_mark_in_progress() && (obj != NULL)) {
+  if (is_concurrent_mark_in_progress() && (obj != nullptr)) {
     ShenandoahBarrierSet::barrier_set()->enqueue(obj);
   }
 }
@@ -2454,7 +2454,7 @@ bool ShenandoahHeap::unload_classes() const {
 
 address ShenandoahHeap::in_cset_fast_test_addr() {
   ShenandoahHeap* heap = ShenandoahHeap::heap();
-  assert(heap->collection_set() != NULL, "Sanity");
+  assert(heap->collection_set() != nullptr, "Sanity");
   return (address) heap->collection_set()->biased_map_address();
 }
 
@@ -2502,7 +2502,7 @@ void ShenandoahHeap::pin_object(JavaThread* thr, oop o) {
 
 void ShenandoahHeap::unpin_object(JavaThread* thr, oop o) {
   ShenandoahHeapRegion* r = heap_region_containing(o);
-  assert(r != NULL, "Sanity");
+  assert(r != nullptr, "Sanity");
   assert(r->pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", r->index());
   r->record_unpin();
 }
@@ -2586,7 +2586,7 @@ void ShenandoahHeap::assert_gc_workers(uint nworkers) {
 
 ShenandoahVerifier* ShenandoahHeap::verifier() {
   guarantee(ShenandoahVerify, "Should be enabled");
-  assert (_verifier != NULL, "sanity");
+  assert (_verifier != nullptr, "sanity");
   return _verifier;
 }
 
@@ -2627,7 +2627,7 @@ class ShenandoahUpdateHeapRefsTask : public WorkerTask {
     assert(_heap->active_generation()->is_mark_complete(), "Expected complete marking");
     ShenandoahMarkingContext* const ctx = _heap->marking_context();
     bool is_mixed = _heap->collection_set()->has_old_regions();
-    while (r != NULL) {
+    while (r != nullptr) {
       HeapWord* update_watermark = r->get_update_watermark();
       assert (update_watermark >= r->bottom(), "sanity");
 
@@ -2803,7 +2803,7 @@ void ShenandoahHeap::update_heap_references(bool concurrent) {
     ShenandoahUpdateHeapRefsTask<false> task(&_update_refs_iterator, &work_list);
     workers()->run_task(&task);
   }
-  if (ShenandoahEnableCardStats && card_scan()!=NULL) { // generational check proxy
+  if (ShenandoahEnableCardStats && card_scan()!=nullptr) { // generational check proxy
     card_scan()->log_card_stats(nworkers, CARD_STAT_UPDATE_REFS);
   }
 }
@@ -3061,7 +3061,7 @@ char ShenandoahHeap::gc_state() const {
 
 ShenandoahLiveData* ShenandoahHeap::get_liveness_cache(uint worker_id) {
 #ifdef ASSERT
-  assert(_liveness_cache != NULL, "sanity");
+  assert(_liveness_cache != nullptr, "sanity");
   assert(worker_id < _max_workers, "sanity");
   for (uint i = 0; i < num_regions(); i++) {
     assert(_liveness_cache[worker_id][i] == 0, "liveness cache should be empty");
@@ -3072,7 +3072,7 @@ ShenandoahLiveData* ShenandoahHeap::get_liveness_cache(uint worker_id) {
 
 void ShenandoahHeap::flush_liveness_cache(uint worker_id) {
   assert(worker_id < _max_workers, "sanity");
-  assert(_liveness_cache != NULL, "sanity");
+  assert(_liveness_cache != nullptr, "sanity");
   ShenandoahLiveData* ld = _liveness_cache[worker_id];
 
   for (uint i = 0; i < num_regions(); i++) {
@@ -3169,7 +3169,7 @@ void ShenandoahHeap::verify_rem_set_at_mark() {
         }
         // else, this humongous object is not marked so no need to verify its internal pointers
         if (!scanner->verify_registration(obj_addr, ctx)) {
-          ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, NULL,
+          ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, nullptr,
                                           "Verify init-mark remembered set violation", "object not properly registered", __FILE__, __LINE__);
         }
       } else if (!r->is_humongous()) {
@@ -3185,7 +3185,7 @@ void ShenandoahHeap::verify_rem_set_at_mark() {
             }
             // else, object's start is marked dirty and obj is not an objArray, so any interesting pointers are covered
             if (!scanner->verify_registration(obj_addr, ctx)) {
-              ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, NULL,
+              ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, nullptr,
                                                "Verify init-mark remembered set violation", "object not properly registered", __FILE__, __LINE__);
             }
             obj_addr += obj->size();
@@ -3221,7 +3221,7 @@ void ShenandoahHeap::help_verify_region_rem_set(ShenandoahHeapRegion* r, Shenand
     // else, this humongous object is not live so no need to verify its internal pointers
 
     if ((obj_addr < registration_watermark) && !scanner->verify_registration(obj_addr, ctx)) {
-      ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, NULL, message,
+      ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, nullptr, message,
                                        "object not properly registered", __FILE__, __LINE__);
     }
   } else if (!r->is_humongous()) {
@@ -3238,7 +3238,7 @@ void ShenandoahHeap::help_verify_region_rem_set(ShenandoahHeapRegion* r, Shenand
         // else, object's start is marked dirty and obj is not an objArray, so any interesting pointers are covered
 
         if ((obj_addr < registration_watermark) && !scanner->verify_registration(obj_addr, ctx)) {
-          ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, NULL, message,
+          ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, obj_addr, nullptr, message,
                                            "object not properly registered", __FILE__, __LINE__);
         }
         obj_addr += obj->size();
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
index 720515b1c45..940198ff1af 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
@@ -102,7 +102,7 @@ class ShenandoahRegionIterator : public StackObj {
   // Reset iterator to default state
   void reset();
 
-  // Returns next region, or NULL if there are no more regions.
+  // Returns next region, or null if there are no more regions.
   // This is multi-thread-safe.
   inline ShenandoahHeapRegion* next();
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
index 2e51e93097e..bdbfb6d05d2 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
@@ -60,7 +60,7 @@ inline ShenandoahHeap* ShenandoahHeap::heap() {
 
 inline ShenandoahHeapRegion* ShenandoahRegionIterator::next() {
   size_t new_index = Atomic::add(&_index, (size_t) 1, memory_order_relaxed);
-  // get_region() provides the bounds-check and returns NULL on OOB.
+  // get_region() provides the bounds-check and returns null on OOB.
   return _heap->get_region(new_index - 1);
 }
 
@@ -222,8 +222,8 @@ inline bool ShenandoahHeap::atomic_update_oop_check(oop update, narrowOop* addr,
   return CompressedOops::decode(Atomic::cmpxchg(addr, c, u, memory_order_release)) == compare;
 }
 
-// The memory ordering discussion above does not apply for methods that store NULLs:
-// then, there is no transitive reads in mutator (as we see NULLs), and we can do
+// The memory ordering discussion above does not apply for methods that store nulls:
+// then, there is no transitive reads in mutator (as we see nulls), and we can do
 // relaxed memory ordering there.
 
 inline void ShenandoahHeap::atomic_clear_oop(oop* addr, oop compare) {
@@ -285,14 +285,14 @@ inline HeapWord* ShenandoahHeap::allocate_from_gclab(Thread* thread, size_t size
   assert(UseTLAB, "TLABs should be enabled");
 
   PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
-  if (gclab == NULL) {
+  if (gclab == nullptr) {
     assert(!thread->is_Java_thread() && !thread->is_Worker_thread(),
            "Performance: thread should have GCLAB: %s", thread->name());
     // No GCLABs in this thread, fallback to shared allocation
-    return NULL;
+    return nullptr;
   }
   HeapWord* obj = gclab->allocate(size);
-  if (obj != NULL) {
+  if (obj != nullptr) {
     return obj;
   }
   return allocate_from_gclab_slow(thread, size);
@@ -303,7 +303,7 @@ inline HeapWord* ShenandoahHeap::allocate_from_plab(Thread* thread, size_t size,
 
   PLAB* plab = ShenandoahThreadLocalData::plab(thread);
   HeapWord* obj;
-  if (plab == NULL) {
+  if (plab == nullptr) {
     assert(!thread->is_Java_thread() && !thread->is_Worker_thread(), "Performance: thread should have PLAB: %s", thread->name());
     // No PLABs in this thread, fallback to shared allocation
     return nullptr;
@@ -355,7 +355,7 @@ inline oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) {
       // Skip the potential promotion attempt for this one.
     } else if (r->age() + mark.age() >= InitialTenuringThreshold) {
       oop result = try_evacuate_object(p, thread, r, OLD_GENERATION);
-      if (result != NULL) {
+      if (result != nullptr) {
         return result;
       }
       // If we failed to promote this aged object, we'll fall through to code below and evacuate to young-gen.
@@ -370,14 +370,14 @@ inline oop ShenandoahHeap::try_evacuate_object(oop p, Thread* thread, Shenandoah
                                                ShenandoahRegionAffiliation target_gen) {
   bool alloc_from_lab = true;
   bool has_plab = false;
-  HeapWord* copy = NULL;
+  HeapWord* copy = nullptr;
   size_t size = p->size();
   bool is_promotion = (target_gen == OLD_GENERATION) && from_region->is_young();
 
 #ifdef ASSERT
   if (ShenandoahOOMDuringEvacALot &&
       (os::random() & 1) == 0) { // Simulate OOM every ~2nd slow-path call
-        copy = NULL;
+        copy = nullptr;
   } else {
 #endif
     if (UseTLAB) {
@@ -429,14 +429,14 @@ inline oop ShenandoahHeap::try_evacuate_object(oop p, Thread* thread, Shenandoah
       }
     }
 
-    if (copy == NULL) {
+    if (copy == nullptr) {
       // If we failed to allocate in LAB, we'll try a shared allocation.
       if (!is_promotion || !has_plab || (size > PLAB::min_size())) {
         ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size, target_gen);
         copy = allocate_memory(req, is_promotion);
         alloc_from_lab = false;
       }
-      // else, we leave copy equal to NULL, signaling a promotion failure below if appropriate.
+      // else, we leave copy equal to nullptr, signaling a promotion failure below if appropriate.
       // We choose not to promote objects smaller than PLAB::min_size() by way of shared allocations, as this is too
       // costly.  Instead, we'll simply "evacuate" to young-gen memory (using a GCLAB) and will promote in a future
       // evacuation pass.  This condition is denoted by: is_promotion && has_plab && (size <= PLAB::min_size())
@@ -445,14 +445,14 @@ inline oop ShenandoahHeap::try_evacuate_object(oop p, Thread* thread, Shenandoah
   }
 #endif
 
-  if (copy == NULL) {
+  if (copy == nullptr) {
     if (target_gen == OLD_GENERATION) {
       assert(mode()->is_generational(), "Should only be here in generational mode.");
       if (from_region->is_young()) {
         // Signal that promotion failed. Will evacuate this old object somewhere in young gen.
         report_promotion_failure(thread, size);
         handle_promotion_failure();
-        return NULL;
+        return nullptr;
       } else {
         // Remember that evacuation to old gen failed. We'll want to trigger a full gc to recover from this
         // after the evacuation threads have finished.
@@ -487,7 +487,7 @@ inline oop ShenandoahHeap::try_evacuate_object(oop p, Thread* thread, Shenandoah
     if (mode()->is_generational() && target_gen == OLD_GENERATION) {
       handle_old_evacuation(copy, size, from_region->is_young());
     }
-    shenandoah_assert_correct(NULL, copy_val);
+    shenandoah_assert_correct(nullptr, copy_val);
     return copy_val;
   }  else {
     // Failed to evacuate. We need to deal with the object that is left behind. Since this
@@ -523,10 +523,10 @@ inline oop ShenandoahHeap::try_evacuate_object(oop p, Thread* thread, Shenandoah
       // have to explicitly overwrite the copy with the filler object. With that overwrite,
       // we have to keep the fwdptr initialized and pointing to our (stale) copy.
       fill_with_object(copy, size);
-      shenandoah_assert_correct(NULL, copy_val);
+      shenandoah_assert_correct(nullptr, copy_val);
       // For non-LAB allocations, the object has already been registered
     }
-    shenandoah_assert_correct(NULL, result);
+    shenandoah_assert_correct(nullptr, result);
     return result;
   }
 }
@@ -562,7 +562,7 @@ inline bool ShenandoahHeap::is_in_active_generation(oop obj) const {
     return true;
   }
 
-  if (active_generation() == NULL) {
+  if (active_generation() == nullptr) {
     // no collection is happening, only expect this to be called
     // when concurrent processing is active, but that could change
     return false;
@@ -652,12 +652,12 @@ inline bool ShenandoahHeap::requires_marking(const void* entry) const {
 }
 
 inline bool ShenandoahHeap::in_collection_set(oop p) const {
-  assert(collection_set() != NULL, "Sanity");
+  assert(collection_set() != nullptr, "Sanity");
   return collection_set()->is_in(p);
 }
 
 inline bool ShenandoahHeap::in_collection_set_loc(void* p) const {
-  assert(collection_set() != NULL, "Sanity");
+  assert(collection_set() != nullptr, "Sanity");
   return collection_set()->is_in_loc(p);
 }
 
@@ -945,7 +945,7 @@ inline ShenandoahHeapRegion* const ShenandoahHeap::get_region(size_t region_idx)
   if (region_idx < _num_regions) {
     return _regions[region_idx];
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
index 188b26ed797..fca5ce95498 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
@@ -67,7 +67,7 @@ ShenandoahHeapRegion::ShenandoahHeapRegion(HeapWord* start, size_t index, bool c
   _index(index),
   _bottom(start),
   _end(start + RegionSizeWords),
-  _new_top(NULL),
+  _new_top(nullptr),
   _empty_time(os::elapsedTime()),
   _state(committed ? _empty_committed : _empty_uncommitted),
   _top(start),
@@ -469,7 +469,7 @@ bool ShenandoahHeapRegion::oop_fill_and_coalesce_wo_cancel() {
   while (obj_addr < t) {
     oop obj = cast_to_oop(obj_addr);
     if (marking_context->is_marked(obj)) {
-      assert(obj->klass() != NULL, "klass should not be NULL");
+      assert(obj->klass() != nullptr, "klass should not be nullptr");
       obj_addr += obj->size();
     } else {
       // Object is not marked.  Coalesce and fill dead object with dead neighbors.
@@ -514,7 +514,7 @@ bool ShenandoahHeapRegion::oop_fill_and_coalesce() {
   while (obj_addr < t) {
     oop obj = cast_to_oop(obj_addr);
     if (marking_context->is_marked(obj)) {
-      assert(obj->klass() != NULL, "klass should not be NULL");
+      assert(obj->klass() != nullptr, "klass should not be nullptr");
       obj_addr += obj->size();
     } else {
       // Object is not marked.  Coalesce and fill dead object with dead neighbors.
@@ -564,7 +564,7 @@ void ShenandoahHeapRegion::global_oop_iterate_objects_and_fill_dead(OopIterateCl
   while (obj_addr < t) {
     oop obj = cast_to_oop(obj_addr);
     if (marking_context->is_marked(obj)) {
-      assert(obj->klass() != NULL, "klass should not be NULL");
+      assert(obj->klass() != nullptr, "klass should not be nullptr");
       // when promoting an entire region, we have to register the marked objects as well
       obj_addr += obj->oop_iterate_size(blk);
     } else {
@@ -701,7 +701,7 @@ HeapWord* ShenandoahHeapRegion::block_start(const void* p) const {
       last = cur;
       cur += cast_to_oop(cur)->size();
     }
-    shenandoah_assert_correct(NULL, cast_to_oop(last));
+    shenandoah_assert_correct(nullptr, cast_to_oop(last));
     return last;
   }
 }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp
index b1496ea5b83..d4e7d66d202 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp
@@ -347,10 +347,10 @@ class ShenandoahHeapRegion {
     return _index;
   }
 
-  // Allocation (return NULL if full)
+  // Allocation (return nullptr if full)
   inline HeapWord* allocate_aligned(size_t word_size, ShenandoahAllocRequest &req, size_t alignment_in_words);
 
-  // Allocation (return NULL if full)
+  // Allocation (return nullptr if full)
   inline HeapWord* allocate(size_t word_size, ShenandoahAllocRequest req);
 
   inline void clear_live_data();
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp
index 7e7539e5c74..45dc554275d 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp
@@ -96,7 +96,7 @@ HeapWord* ShenandoahHeapRegion::allocate_aligned(size_t size, ShenandoahAllocReq
     assert(is_aligned(aligned_obj, alignment_in_bytes), "obj is not aligned: " PTR_FORMAT, p2i(aligned_obj));
     return aligned_obj;
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -117,7 +117,7 @@ HeapWord* ShenandoahHeapRegion::allocate(size_t size, ShenandoahAllocRequest req
 
     return obj;
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp
index d36f5ce8dcf..209ca605d88 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp
@@ -78,7 +78,7 @@ ShenandoahHeapRegionCounters::ShenandoahHeapRegionCounters() :
 }
 
 ShenandoahHeapRegionCounters::~ShenandoahHeapRegionCounters() {
-  if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
+  if (_name_space != nullptr) FREE_C_HEAP_ARRAY(char, _name_space);
 }
 
 void ShenandoahHeapRegionCounters::write_snapshot(PerfLongVariable** regions,
@@ -177,7 +177,7 @@ jlong ShenandoahHeapRegionCounters::encode_heap_status(ShenandoahHeap* heap) {
   } else {
     int phase = encode_phase(heap);
     ShenandoahGeneration* generation = heap->active_generation();
-    assert(generation != NULL, "Expected active generation in this mode.");
+    assert(generation != nullptr, "Expected active generation in this mode.");
     int shift = get_generation_shift(generation);
     status |= ((phase & 0x3) << shift);
     if (heap->is_concurrent_old_mark_in_progress()) {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp
index fe34b629637..d18bfb0d625 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp
@@ -77,7 +77,7 @@ ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::next() {
       return _heap->get_region(index);
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 void ShenandoahHeapRegionSet::print_on(outputStream* out) const {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp b/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp
index eb645af3d8b..3a9b612860b 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp
@@ -44,7 +44,7 @@ void ShenandoahSimpleLock::unlock() {
 }
 
 ShenandoahReentrantLock::ShenandoahReentrantLock() :
-  ShenandoahSimpleLock(), _owner(NULL), _count(0) {
+  ShenandoahSimpleLock(), _owner(nullptr), _count(0) {
   assert(os::mutex_init_done(), "Too early!");
 }
 
@@ -71,7 +71,7 @@ void ShenandoahReentrantLock::unlock() {
   _count--;
 
   if (_count == 0) {
-    Atomic::store(&_owner, (Thread*)NULL);
+    Atomic::store(&_owner, (Thread*)nullptr);
     ShenandoahSimpleLock::unlock();
   }
 }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp b/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp
index 0dd700a2c5c..62376376195 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp
@@ -41,7 +41,7 @@ class ShenandoahLock  {
   shenandoah_padding(2);
 
 public:
-  ShenandoahLock() : _state(unlocked), _owner(NULL) {};
+  ShenandoahLock() : _state(unlocked), _owner(nullptr) {};
 
   void lock() {
 #ifdef ASSERT
@@ -50,7 +50,7 @@ class ShenandoahLock  {
     Thread::SpinAcquire(&_state, "Shenandoah Heap Lock");
 #ifdef ASSERT
     assert(_state == locked, "must be locked");
-    assert(_owner == NULL, "must not be owned");
+    assert(_owner == nullptr, "must not be owned");
     _owner = Thread::current();
 #endif
   }
@@ -58,7 +58,7 @@ class ShenandoahLock  {
   void unlock() {
 #ifdef ASSERT
     assert (_owner == Thread::current(), "sanity");
-    _owner = NULL;
+    _owner = nullptr;
 #endif
     Thread::SpinRelease(&_state);
   }
@@ -78,13 +78,13 @@ class ShenandoahLocker : public StackObj {
   ShenandoahLock* const _lock;
 public:
   ShenandoahLocker(ShenandoahLock* lock) : _lock(lock) {
-    if (_lock != NULL) {
+    if (_lock != nullptr) {
       _lock->lock();
     }
   }
 
   ~ShenandoahLocker() {
-    if (_lock != NULL) {
+    if (_lock != nullptr) {
       _lock->unlock();
     }
   }
@@ -123,13 +123,13 @@ class ShenandoahReentrantLocker : public StackObj {
 public:
   ShenandoahReentrantLocker(ShenandoahReentrantLock* lock) :
     _lock(lock) {
-    if (_lock != NULL) {
+    if (_lock != nullptr) {
       _lock->lock();
     }
   }
 
   ~ShenandoahReentrantLocker() {
-    if (_lock != NULL) {
+    if (_lock != nullptr) {
       assert(_lock->owned_by_self(), "Must be owner");
       _lock->unlock();
     }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp
index dbdc31ec903..3dfd7c91953 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp
@@ -158,7 +158,7 @@ void ShenandoahMark::mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint w
          "Need to reserve proper number of queues: reserved: %u, active: %u", queues->get_reserved(), heap->workers()->active_workers());
 
   q = queues->claim_next();
-  while (q != NULL) {
+  while (q != nullptr) {
     if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
       return;
     }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp
index 2d67dd17f0d..7828d372556 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp
@@ -64,9 +64,9 @@ void ShenandoahMark::do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveD
   // generations. I don't think it will break anything, but the young generation
   // scan might end up processing some old generation array chunks.
 
-  shenandoah_assert_not_forwarded(NULL, obj);
-  shenandoah_assert_marked(NULL, obj);
-  shenandoah_assert_not_in_cset_except(NULL, obj, ShenandoahHeap::heap()->cancelled_gc());
+  shenandoah_assert_not_forwarded(nullptr, obj);
+  shenandoah_assert_marked(nullptr, obj);
+  shenandoah_assert_not_in_cset_except(nullptr, obj, ShenandoahHeap::heap()->cancelled_gc());
 
   // Are we in weak subgraph scan?
   bool weak = task->is_weak();
@@ -126,7 +126,7 @@ inline void ShenandoahMark::count_liveness(ShenandoahLiveData* live_data, oop ob
       live_data[region_idx] = (ShenandoahLiveData) new_val;
     }
   } else {
-    shenandoah_assert_in_correct_region(NULL, obj);
+    shenandoah_assert_in_correct_region(nullptr, obj);
     size_t num_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
 
     assert(region->affiliation() != FREE, "Do not count live data within FREE Humongous Start Region " SIZE_FORMAT, region_idx);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp
index a3846b81c3a..affaf71be9c 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2020, Red Hat, Inc. and/or its affiliates.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -64,7 +64,7 @@ HeapWord* ShenandoahMarkBitMap::get_next_marked_addr(const HeapWord* addr,
   ShenandoahHeapRegion* r = heap->heap_region_containing(addr);
   ShenandoahMarkingContext* ctx = heap->marking_context();
   HeapWord* tams = ctx->top_at_mark_start(r);
-  assert(limit != NULL, "limit must not be NULL");
+  assert(limit != nullptr, "limit must not be null");
   assert(limit <= r->top(), "limit must be less than top");
   assert(addr <= tams, "addr must be less than TAMS");
 #endif
@@ -73,8 +73,7 @@ HeapWord* ShenandoahMarkBitMap::get_next_marked_addr(const HeapWord* addr,
   size_t const addr_offset = address_to_index(align_up(addr, HeapWordSize << LogMinObjAlignment));
   size_t const limit_offset = address_to_index(limit);
   size_t const nextOffset = get_next_one_offset(addr_offset, limit_offset);
-  HeapWord* result = index_to_address(nextOffset);
-  return result;
+  return index_to_address(nextOffset);
 }
 
 void ShenandoahMarkBitMap::clear_range_within_word(idx_t beg, idx_t end) {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.hpp
index 5e9280abcaf..b088d31c792 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2020, Red Hat, Inc. and/or its affiliates.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -162,8 +162,8 @@ class ShenandoahMarkBitMap {
   bool is_bitmap_clear_range(const HeapWord* start, const HeapWord* end) const;
 
   // Return the address corresponding to the next marked bit at or after
-  // "addr", and before "limit", if "limit" is non-NULL.  If there is no
-  // such bit, returns "limit" if that is non-NULL, or else "endWord()".
+  // "addr", and before "limit", if "limit" is non-null.  If there is no
+  // such bit, returns "limit" if that is non-null, or else "endWord()".
   HeapWord* get_next_marked_addr(const HeapWord* addr,
                                  const HeapWord* limit) const;
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp
index d02f552af26..edc66f657fb 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp
@@ -57,8 +57,8 @@ class ShenandoahGenerationCounters : public GenerationCounters {
 };
 
 ShenandoahMonitoringSupport::ShenandoahMonitoringSupport(ShenandoahHeap* heap) :
-        _partial_counters(NULL),
-        _full_counters(NULL)
+        _partial_counters(nullptr),
+        _full_counters(nullptr)
 {
   // Collection counters do not fit Shenandoah very well.
   // We record partial cycles as "young", and full cycles (including full STW GC) as "old".
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp
index 85031be43fa..65d61b6f744 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp
@@ -32,7 +32,7 @@
 #include "runtime/continuation.hpp"
 
 ShenandoahNMethod::ShenandoahNMethod(nmethod* nm, GrowableArray<oop*>& oops, bool non_immediate_oops) :
-  _nm(nm), _oops(NULL), _oops_count(0), _unregistered(false) {
+  _nm(nm), _oops(nullptr), _oops_count(0), _unregistered(false) {
 
   if (!oops.is_empty()) {
     _oops_count = oops.length();
@@ -47,7 +47,7 @@ ShenandoahNMethod::ShenandoahNMethod(nmethod* nm, GrowableArray<oop*>& oops, boo
 }
 
 ShenandoahNMethod::~ShenandoahNMethod() {
-  if (_oops != NULL) {
+  if (_oops != nullptr) {
     FREE_C_HEAP_ARRAY(oop*, _oops);
   }
 }
@@ -92,9 +92,9 @@ void ShenandoahNMethod::update() {
 
   detect_reloc_oops(nm(), oops, non_immediate_oops);
   if (oops.length() != _oops_count) {
-    if (_oops != NULL) {
+    if (_oops != nullptr) {
       FREE_C_HEAP_ARRAY(oop*, _oops);
-      _oops = NULL;
+      _oops = nullptr;
     }
 
     _oops_count = oops.length();
@@ -129,14 +129,14 @@ void ShenandoahNMethod::detect_reloc_oops(nmethod* nm, GrowableArray<oop*>& oops
     }
 
     oop value = r->oop_value();
-    if (value != NULL) {
+    if (value != nullptr) {
       oop* addr = r->oop_addr();
       shenandoah_assert_correct(addr, value);
       shenandoah_assert_not_in_cset_except(addr, value, ShenandoahHeap::heap()->cancelled_gc());
       shenandoah_assert_not_forwarded(addr, value);
-      // Non-NULL immediate oop found. NULL oops can safely be
+      // Non-null immediate oop found. null oops can safely be
       // ignored since the method will be re-registered if they
-      // are later patched to be non-NULL.
+      // are later patched to be non-null.
       oops.push(addr);
     }
   }
@@ -153,7 +153,7 @@ ShenandoahNMethod* ShenandoahNMethod::for_nmethod(nmethod* nm) {
 
 void ShenandoahNMethod::heal_nmethod(nmethod* nm) {
   ShenandoahNMethod* data = gc_data(nm);
-  assert(data != NULL, "Sanity");
+  assert(data != nullptr, "Sanity");
   assert(data->lock()->owned_by_self(), "Must hold the lock");
 
   ShenandoahHeap* const heap = ShenandoahHeap::heap();
@@ -178,7 +178,7 @@ void ShenandoahNMethod::assert_correct() {
     oop *loc = _oops[c];
     assert(_nm->code_contains((address) loc) || _nm->oops_contains(loc), "nmethod should contain the oop*");
     oop o = RawAccess<>::oop_load(loc);
-    shenandoah_assert_correct_except(loc, o, o == NULL || heap->is_full_gc_move_in_progress());
+    shenandoah_assert_correct_except(loc, o, o == nullptr || heap->is_full_gc_move_in_progress());
   }
 
   oop* const begin = _nm->oops_begin();
@@ -186,7 +186,7 @@ void ShenandoahNMethod::assert_correct() {
   for (oop* p = begin; p < end; p++) {
     if (*p != Universe::non_oop_word()) {
       oop o = RawAccess<>::oop_load(p);
-      shenandoah_assert_correct_except(p, o, o == NULL || heap->is_full_gc_move_in_progress());
+      shenandoah_assert_correct_except(p, o, o == nullptr || heap->is_full_gc_move_in_progress());
     }
   }
 }
@@ -263,7 +263,7 @@ ShenandoahNMethodTable::ShenandoahNMethodTable() :
 }
 
 ShenandoahNMethodTable::~ShenandoahNMethodTable() {
-  assert(_list != NULL, "Sanity");
+  assert(_list != nullptr, "Sanity");
   _list->release();
 }
 
@@ -273,7 +273,7 @@ void ShenandoahNMethodTable::register_nmethod(nmethod* nm) {
 
   ShenandoahNMethod* data = ShenandoahNMethod::gc_data(nm);
 
-  if (data != NULL) {
+  if (data != nullptr) {
     assert(contain(nm), "Must have been registered");
     assert(nm == data->nm(), "Must be same nmethod");
     // Prevent updating a nmethod while concurrent iteration is in progress.
@@ -284,7 +284,7 @@ void ShenandoahNMethodTable::register_nmethod(nmethod* nm) {
     // For a new nmethod, we can safely append it to the list, because
     // concurrent iteration will not touch it.
     data = ShenandoahNMethod::for_nmethod(nm);
-    assert(data != NULL, "Sanity");
+    assert(data != nullptr, "Sanity");
     ShenandoahNMethod::attach_gc_data(nm, data);
     ShenandoahLocker locker(&_lock);
     log_register_nmethod(nm);
@@ -298,14 +298,14 @@ void ShenandoahNMethodTable::unregister_nmethod(nmethod* nm) {
   assert_locked_or_safepoint(CodeCache_lock);
 
   ShenandoahNMethod* data = ShenandoahNMethod::gc_data(nm);
-  assert(data != NULL, "Sanity");
+  assert(data != nullptr, "Sanity");
   log_unregister_nmethod(nm);
   ShenandoahLocker locker(&_lock);
   assert(contain(nm), "Must have been registered");
 
   int idx = index_of(nm);
   assert(idx >= 0 && idx < _index, "Invalid index");
-  ShenandoahNMethod::attach_gc_data(nm, NULL);
+  ShenandoahNMethod::attach_gc_data(nm, nullptr);
   remove(idx);
 }
 
@@ -376,7 +376,7 @@ ShenandoahNMethodTableSnapshot* ShenandoahNMethodTable::snapshot_for_iteration()
 void ShenandoahNMethodTable::finish_iteration(ShenandoahNMethodTableSnapshot* snapshot) {
   assert(CodeCache_lock->owned_by_self(), "Must have CodeCache_lock held");
   assert(iteration_in_progress(), "Why we here?");
-  assert(snapshot != NULL, "No snapshot");
+  assert(snapshot != nullptr, "No snapshot");
   _itr_cnt--;
 
   delete snapshot;
@@ -429,7 +429,7 @@ ShenandoahNMethodList::ShenandoahNMethodList(int size) :
 }
 
 ShenandoahNMethodList::~ShenandoahNMethodList() {
-  assert(_list != NULL, "Sanity");
+  assert(_list != nullptr, "Sanity");
   assert(_ref_count == 0, "Must be");
   FREE_C_HEAP_ARRAY(ShenandoahNMethod*, _list);
 }
@@ -478,7 +478,7 @@ void ShenandoahNMethodTableSnapshot::parallel_blobs_do(CodeBlobClosure *f) {
 
     for (size_t idx = start; idx < end; idx++) {
       ShenandoahNMethod* nmr = list[idx];
-      assert(nmr != NULL, "Sanity");
+      assert(nmr != nullptr, "Sanity");
       if (nmr->is_unregistered()) {
         continue;
       }
@@ -502,7 +502,7 @@ void ShenandoahNMethodTableSnapshot::concurrent_nmethods_do(NMethodClosure* cl)
 
     for (size_t idx = start; idx < end; idx++) {
       ShenandoahNMethod* data = list[idx];
-      assert(data != NULL, "Should not be NULL");
+      assert(data != nullptr, "Should not be null");
       if (!data->is_unregistered()) {
         cl->do_nmethod(data->nm());
       }
@@ -511,7 +511,7 @@ void ShenandoahNMethodTableSnapshot::concurrent_nmethods_do(NMethodClosure* cl)
 }
 
 ShenandoahConcurrentNMethodIterator::ShenandoahConcurrentNMethodIterator(ShenandoahNMethodTable* table) :
-  _table(table), _table_snapshot(NULL) {
+  _table(table), _table_snapshot(nullptr) {
 }
 
 void ShenandoahConcurrentNMethodIterator::nmethods_do_begin() {
@@ -520,7 +520,7 @@ void ShenandoahConcurrentNMethodIterator::nmethods_do_begin() {
 }
 
 void ShenandoahConcurrentNMethodIterator::nmethods_do(NMethodClosure* cl) {
-  assert(_table_snapshot != NULL, "Must first call nmethod_do_begin()");
+  assert(_table_snapshot != nullptr, "Must first call nmethod_do_begin()");
   _table_snapshot->concurrent_nmethods_do(cl);
 }
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp
index dc559228ccf..eb9659219a2 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp
@@ -80,9 +80,9 @@ void ShenandoahNMethod::heal_nmethod_metadata(ShenandoahNMethod* nmethod_data) {
 
 void ShenandoahNMethod::disarm_nmethod(nmethod* nm) {
   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
-  assert(bs != NULL || !ShenandoahNMethodBarrier,
+  assert(bs != nullptr || !ShenandoahNMethodBarrier,
         "Must have nmethod barrier for concurrent GC");
-  if (bs != NULL && bs->is_armed(nm)) {
+  if (bs != nullptr && bs->is_armed(nm)) {
     bs->disarm(nm);
   }
 }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp
index a460f03edac..adeb6698932 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp
@@ -30,14 +30,14 @@
 HdrSeq::HdrSeq() {
   _hdr = NEW_C_HEAP_ARRAY(int*, MagBuckets, mtInternal);
   for (int c = 0; c < MagBuckets; c++) {
-    _hdr[c] = NULL;
+    _hdr[c] = nullptr;
   }
 }
 
 HdrSeq::~HdrSeq() {
   for (int c = 0; c < MagBuckets; c++) {
     int* sub = _hdr[c];
-    if (sub != NULL) {
+    if (sub != nullptr) {
       FREE_C_HEAP_ARRAY(int, sub);
     }
   }
@@ -93,7 +93,7 @@ void HdrSeq::add(double val) {
   }
 
   int* b = _hdr[bucket];
-  if (b == NULL) {
+  if (b == nullptr) {
     b = NEW_C_HEAP_ARRAY(int, ValBuckets, mtInternal);
     for (int c = 0; c < ValBuckets; c++) {
       b[c] = 0;
@@ -108,7 +108,7 @@ double HdrSeq::percentile(double level) const {
   int target = MAX2(1, (int) (level * num() / 100));
   int cnt = 0;
   for (int mag = 0; mag < MagBuckets; mag++) {
-    if (_hdr[mag] != NULL) {
+    if (_hdr[mag] != nullptr) {
       for (int val = 0; val < ValBuckets; val++) {
         cnt += _hdr[mag][val];
         if (cnt >= target) {
@@ -125,14 +125,14 @@ double HdrSeq::percentile(double level) const {
 // of any mutual exclusion as necessary.
 void HdrSeq::merge(HdrSeq& hdr2, bool clear_this) {
   for (int mag = 0; mag < MagBuckets; mag++) {
-    if (_hdr[mag] != NULL) {
+    if (_hdr[mag] != nullptr) {
       int* that_bucket = hdr2._hdr[mag];
-      if (that_bucket == NULL) {
+      if (that_bucket == nullptr) {
         if (clear_this) {
           // the target doesn't have any values, swap in ours.
           // Could this cause native memory fragmentation?
           hdr2._hdr[mag] = _hdr[mag];
-          _hdr[mag] = NULL;
+          _hdr[mag] = nullptr;
         } else {
           // We can't clear this, so we create the entries & add in below
           that_bucket = NEW_C_HEAP_ARRAY(int, ValBuckets, mtInternal);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp
index 1d3aaed65d1..5dd017793b0 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp
@@ -60,7 +60,7 @@ void ShenandoahOldGC::op_final_mark() {
 
     // Old collection is complete, the young generation no longer needs this
     // reference to the old concurrent mark so clean it up.
-    heap->young_generation()->set_old_gen_task_queues(NULL);
+    heap->young_generation()->set_old_gen_task_queues(nullptr);
 
     // We need to do this because weak root cleaning reports the number of dead handles
     JvmtiTagMap::set_needs_cleaning();
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp
index 9555a285b99..3ade5f175ef 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp
@@ -86,7 +86,7 @@ class ShenandoahProcessOldSATB : public SATBBufferClosure {
       oop *p = (oop *) &buffer[i];
       ShenandoahHeapRegion* region = _heap->heap_region_containing(*p);
       if (region->is_old() && region->is_active()) {
-          ShenandoahMark::mark_through_ref<oop, OLD>(p, _queue, NULL, _mark_context, false);
+          ShenandoahMark::mark_through_ref<oop, OLD>(p, _queue, nullptr, _mark_context, false);
       } else {
         ++_trashed_oops;
       }
@@ -417,7 +417,7 @@ bool ShenandoahOldGeneration::validate_transition(State new_state) {
 #endif
 
 ShenandoahHeuristics* ShenandoahOldGeneration::initialize_heuristics(ShenandoahMode* gc_mode) {
-  assert(ShenandoahOldGCHeuristics != NULL, "ShenandoahOldGCHeuristics should not equal NULL");
+  assert(ShenandoahOldGCHeuristics != nullptr, "ShenandoahOldGCHeuristics should not be unset");
   ShenandoahHeuristics* trigger;
   if (strcmp(ShenandoahOldGCHeuristics, "static") == 0) {
     trigger = new ShenandoahStaticHeuristics(this);
@@ -428,7 +428,7 @@ ShenandoahHeuristics* ShenandoahOldGeneration::initialize_heuristics(ShenandoahM
   } else {
     vm_exit_during_initialization("Unknown -XX:ShenandoahOldGCHeuristics option (must be one of: static, adaptive, compact)");
     ShouldNotReachHere();
-    return NULL;
+    return nullptr;
   }
   trigger->set_guaranteed_gc_interval(ShenandoahGuaranteedOldGCInterval);
   _old_heuristics = new ShenandoahOldHeuristics(this, trigger);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp
index 260f45337b9..af80f80af65 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp
@@ -51,7 +51,7 @@ class ShenandoahMarkRefsSuperClosure : public MetadataVisitingOopIterateClosure
   void work(T *p);
 
 public:
-  ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp,  ShenandoahObjToScanQueue* old_queue = NULL);
+  ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp,  ShenandoahObjToScanQueue* old_queue = nullptr);
 
   bool is_weak() const {
     return _weak;
@@ -75,7 +75,7 @@ class ShenandoahMarkUpdateRefsSuperClosure : public ShenandoahMarkRefsSuperClosu
   inline void work(T* p);
 
 public:
-  ShenandoahMarkUpdateRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old = NULL) :
+  ShenandoahMarkUpdateRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old = nullptr) :
     ShenandoahMarkRefsSuperClosure(q, rp, old),
     _heap(ShenandoahHeap::heap()) {
     assert(_heap->is_stw_gc_in_progress(), "Can only be used for STW GC");
@@ -89,7 +89,7 @@ class ShenandoahMarkUpdateRefsClosure : public ShenandoahMarkUpdateRefsSuperClos
   inline void do_oop_work(T* p)     { work<T, GENERATION>(p); }
 
 public:
-  ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old = NULL) :
+  ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old = nullptr) :
     ShenandoahMarkUpdateRefsSuperClosure(q, rp, old) {}
 
   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
@@ -103,7 +103,7 @@ class ShenandoahMarkRefsClosure : public ShenandoahMarkRefsSuperClosure {
   inline void do_oop_work(T* p)     { work<T, GENERATION>(p); }
 
 public:
-  ShenandoahMarkRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old = NULL) :
+  ShenandoahMarkRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp, ShenandoahObjToScanQueue* old = nullptr) :
     ShenandoahMarkRefsSuperClosure(q, rp, old) {};
 
   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp
index be4c2a2fa39..8a467019ad4 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp
@@ -62,10 +62,10 @@ inline void ShenandoahVerifyRemSetClosure::work(T* p) {
     if (_heap->is_in_young(obj)) {
       size_t card_index = _scanner->card_index_for_addr((HeapWord*) p);
       if (_init_mark && !_scanner->is_card_dirty(card_index)) {
-        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
+        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, nullptr,
                                         "Verify init-mark remembered set violation", "clean card should be dirty", __FILE__, __LINE__);
       } else if (!_init_mark && !_scanner->is_write_card_dirty(card_index)) {
-        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
+        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, nullptr,
                                         "Verify init-update-refs remembered set violation", "clean card should be dirty", __FILE__, __LINE__);
       }
     }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp
index 8beaa8f1155..d19f8f25451 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp
@@ -56,7 +56,7 @@ ShenandoahPhaseTimings::ShenandoahPhaseTimings(uint max_workers) :
   // Initialize everything to sane defaults
   for (uint i = 0; i < _num_phases; i++) {
 #define SHENANDOAH_WORKER_DATA_NULL(type, title) \
-    _worker_data[i] = NULL;
+    _worker_data[i] = nullptr;
     SHENANDOAH_PAR_PHASE_DO(,, SHENANDOAH_WORKER_DATA_NULL)
 #undef SHENANDOAH_WORKER_DATA_NULL
     _cycle_data[i] = uninitialized();
@@ -69,14 +69,14 @@ ShenandoahPhaseTimings::ShenandoahPhaseTimings(uint max_workers) :
     if (is_worker_phase(Phase(i))) {
       int c = 0;
 #define SHENANDOAH_WORKER_DATA_INIT(type, title) \
-      if (c++ != 0) _worker_data[i + c] = new ShenandoahWorkerData(NULL, title, _max_workers);
+      if (c++ != 0) _worker_data[i + c] = new ShenandoahWorkerData(nullptr, title, _max_workers);
       SHENANDOAH_PAR_PHASE_DO(,, SHENANDOAH_WORKER_DATA_INIT)
 #undef SHENANDOAH_WORKER_DATA_INIT
     }
   }
 
   _policy = ShenandoahHeap::heap()->shenandoah_policy();
-  assert(_policy != NULL, "Can not be NULL");
+  assert(_policy != nullptr, "Can not be null");
 }
 
 ShenandoahPhaseTimings::Phase ShenandoahPhaseTimings::worker_par_phase(Phase phase, ParPhase par_phase) {
@@ -89,7 +89,7 @@ ShenandoahPhaseTimings::Phase ShenandoahPhaseTimings::worker_par_phase(Phase pha
 ShenandoahWorkerData* ShenandoahPhaseTimings::worker_data(Phase phase, ParPhase par_phase) {
   Phase p = worker_par_phase(phase, par_phase);
   ShenandoahWorkerData* wd = _worker_data[p];
-  assert(wd != NULL, "Counter initialized: %s", phase_name(p));
+  assert(wd != nullptr, "Counter initialized: %s", phase_name(p));
   return wd;
 }
 
@@ -221,7 +221,7 @@ void ShenandoahPhaseTimings::flush_cycle_to_global() {
       _global_data[i].add(_cycle_data[i]);
       _cycle_data[i] = uninitialized();
     }
-    if (_worker_data[i] != NULL) {
+    if (_worker_data[i] != nullptr) {
       _worker_data[i]->reset();
     }
   }
@@ -245,7 +245,7 @@ void ShenandoahPhaseTimings::print_cycle_on(outputStream* out) const {
         }
       }
 
-      if (_worker_data[i] != NULL) {
+      if (_worker_data[i] != nullptr) {
         out->print(", workers (us): ");
         for (uint c = 0; c < _max_workers; c++) {
           double tv = _worker_data[i]->get(c);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp
index ed26e45c511..b06a7145475 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2020, 2021, Red Hat, Inc. and/or its affiliates.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -54,7 +54,7 @@ static const char* reference_type_name(ReferenceType type) {
 
     default:
       ShouldNotReachHere();
-      return NULL;
+      return nullptr;
   }
 }
 
@@ -72,7 +72,7 @@ void set_oop_field<narrowOop>(narrowOop* field, oop value) {
 }
 
 static oop lrb(oop obj) {
-  if (obj != NULL && ShenandoahHeap::heap()->marking_context()->is_marked(obj)) {
+  if (obj != nullptr && ShenandoahHeap::heap()->marking_context()->is_marked(obj)) {
     return ShenandoahBarrierSet::barrier_set()->load_reference_barrier(obj);
   } else {
     return obj;
@@ -121,7 +121,7 @@ void reference_set_discovered<narrowOop>(oop reference, oop discovered) {
 template<typename T>
 static bool reference_cas_discovered(oop reference, oop discovered) {
   T* addr = reinterpret_cast<T *>(java_lang_ref_Reference::discovered_addr_raw(reference));
-  return ShenandoahHeap::atomic_update_oop_check(discovered, addr, NULL);
+  return ShenandoahHeap::atomic_update_oop_check(discovered, addr, nullptr);
 }
 
 template <typename T>
@@ -145,15 +145,15 @@ static void soft_reference_update_clock() {
 }
 
 ShenandoahRefProcThreadLocal::ShenandoahRefProcThreadLocal() :
-  _discovered_list(NULL),
+  _discovered_list(nullptr),
   _encountered_count(),
   _discovered_count(),
   _enqueued_count() {
 }
 
 void ShenandoahRefProcThreadLocal::reset() {
-  _discovered_list = NULL;
-  _mark_closure = NULL;
+  _discovered_list = nullptr;
+  _mark_closure = nullptr;
   for (uint i = 0; i < reference_type_count; i++) {
     _encountered_count[i] = 0;
     _discovered_count[i] = 0;
@@ -187,9 +187,9 @@ void ShenandoahRefProcThreadLocal::set_discovered_list_head<oop>(oop head) {
 }
 
 ShenandoahReferenceProcessor::ShenandoahReferenceProcessor(uint max_workers) :
-  _soft_reference_policy(NULL),
+  _soft_reference_policy(nullptr),
   _ref_proc_thread_locals(NEW_C_HEAP_ARRAY(ShenandoahRefProcThreadLocal, max_workers, mtGC)),
-  _pending_list(NULL),
+  _pending_list(nullptr),
   _pending_list_tail(&_pending_list),
   _iterate_discovered_list_id(0U),
   _stats() {
@@ -228,11 +228,11 @@ bool ShenandoahReferenceProcessor::is_inactive(oop reference, oop referent, Refe
   if (type == REF_FINAL) {
     // A FinalReference is inactive if its next field is non-null. An application can't
     // call enqueue() or clear() on a FinalReference.
-    return reference_next<T>(reference) != NULL;
+    return reference_next<T>(reference) != nullptr;
   } else {
     // A non-FinalReference is inactive if the referent is null. The referent can only
     // be null if the application called Reference.enqueue() or Reference.clear().
-    return referent == NULL;
+    return referent == nullptr;
   }
 }
 
@@ -249,7 +249,7 @@ bool ShenandoahReferenceProcessor::is_softly_live(oop reference, ReferenceType t
   // Ask SoftReference policy
   const jlong clock = java_lang_ref_SoftReference::clock();
   assert(clock != 0, "Clock not initialized");
-  assert(_soft_reference_policy != NULL, "Policy not initialized");
+  assert(_soft_reference_policy != nullptr, "Policy not initialized");
   return !_soft_reference_policy->should_clear_reference(reference, clock);
 }
 
@@ -286,7 +286,7 @@ bool ShenandoahReferenceProcessor::should_discover(oop reference, ReferenceType
 template <typename T>
 bool ShenandoahReferenceProcessor::should_drop(oop reference, ReferenceType type) const {
   const oop referent = reference_referent<T>(reference);
-  if (referent == NULL) {
+  if (referent == nullptr) {
     // Reference has been cleared, by a call to Reference.enqueue()
     // or Reference.clear() from the application, which means we
     // should drop the reference.
@@ -309,7 +309,7 @@ void ShenandoahReferenceProcessor::make_inactive(oop reference, ReferenceType ty
     // to finalize(). A FinalReference is instead made inactive by self-looping the
     // next field. An application can't call FinalReference.enqueue(), so there is
     // no race to worry about when setting the next field.
-    assert(reference_next<T>(reference) == NULL, "Already inactive");
+    assert(reference_next<T>(reference) == nullptr, "Already inactive");
     assert(ShenandoahHeap::heap()->marking_context()->is_marked(reference_referent<T>(reference)), "only make inactive final refs with alive referents");
     reference_set_next(reference, reference);
   } else {
@@ -325,7 +325,7 @@ bool ShenandoahReferenceProcessor::discover(oop reference, ReferenceType type, u
     return false;
   }
 
-  if (reference_discovered<T>(reference) != NULL) {
+  if (reference_discovered<T>(reference) != nullptr) {
     // Already discovered. This can happen if the reference is marked finalizable first, and then strong,
     // in which case it will be seen 2x by marking.
     log_trace(gc,ref)("Reference already discovered: " PTR_FORMAT, p2i(reference));
@@ -347,9 +347,9 @@ bool ShenandoahReferenceProcessor::discover(oop reference, ReferenceType type, u
   // Add reference to discovered list
   ShenandoahRefProcThreadLocal& refproc_data = _ref_proc_thread_locals[worker_id];
   oop discovered_head = refproc_data.discovered_list_head<T>();
-  if (discovered_head == NULL) {
+  if (discovered_head == nullptr) {
     // Self-loop tail of list. We distinguish discovered from not-discovered references by looking at their
-    // discovered field: if it is NULL, then it is not-yet discovered, otherwise it is discovered
+    // discovered field: if it is null, then it is not-yet discovered, otherwise it is discovered
     discovered_head = reference;
   }
   if (reference_cas_discovered<T>(reference, discovered_head)) {
@@ -385,11 +385,11 @@ oop ShenandoahReferenceProcessor::drop(oop reference, ReferenceType type) {
 
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   oop referent = reference_referent<T>(reference);
-  assert(referent == NULL || heap->marking_context()->is_marked(referent), "only drop references with alive referents");
+  assert(referent == nullptr || heap->marking_context()->is_marked(referent), "only drop references with alive referents");
 
   // Unlink and return next in list
   oop next = reference_discovered<T>(reference);
-  reference_set_discovered<T>(reference, NULL);
+  reference_set_discovered<T>(reference, nullptr);
   // When this reference was discovered, it would not have been marked. If it ends up surviving
   // the cycle, we need to dirty the card if the reference is old and the referent is young.  Note
   // that if the reference is not dropped, then its pointer to the referent will be nulled before
@@ -428,7 +428,7 @@ void ShenandoahReferenceProcessor::process_references(ShenandoahRefProcThreadLoc
   T* p = list;
   while (true) {
     const oop reference = lrb(CompressedOops::decode(*p));
-    if (reference == NULL) {
+    if (reference == nullptr) {
       break;
     }
     log_trace(gc, ref)("Processing reference: " PTR_FORMAT, p2i(reference));
@@ -442,8 +442,8 @@ void ShenandoahReferenceProcessor::process_references(ShenandoahRefProcThreadLoc
 
     const oop discovered = lrb(reference_discovered<T>(reference));
     if (reference == discovered) {
-      // Reset terminating self-loop to NULL
-      reference_set_discovered<T>(reference, oop(NULL));
+      // Reset terminating self-loop to null
+      reference_set_discovered<T>(reference, oop(nullptr));
       break;
     }
   }
@@ -454,13 +454,13 @@ void ShenandoahReferenceProcessor::process_references(ShenandoahRefProcThreadLoc
     shenandoah_assert_not_in_cset_except(&head, head, ShenandoahHeap::heap()->cancelled_gc() || !ShenandoahLoadRefBarrier);
     oop prev = Atomic::xchg(&_pending_list, head);
     RawAccess<>::oop_store(p, prev);
-    if (prev == NULL) {
+    if (prev == nullptr) {
       // First to prepend to list, record tail
       _pending_list_tail = reinterpret_cast<void*>(p);
     }
 
     // Clear discovered list
-    set_oop_field(list, oop(NULL));
+    set_oop_field(list, oop(nullptr));
   }
 }
 
@@ -533,7 +533,7 @@ void ShenandoahReferenceProcessor::enqueue_references_locked() {
 }
 
 void ShenandoahReferenceProcessor::enqueue_references(bool concurrent) {
-  if (_pending_list == NULL) {
+  if (_pending_list == nullptr) {
     // Nothing to enqueue
     return;
   }
@@ -551,7 +551,7 @@ void ShenandoahReferenceProcessor::enqueue_references(bool concurrent) {
   }
 
   // Reset internal pending list
-  _pending_list = NULL;
+  _pending_list = nullptr;
   _pending_list_tail = &_pending_list;
 }
 
@@ -560,7 +560,7 @@ void ShenandoahReferenceProcessor::clean_discovered_list(T* list) {
   T discovered = *list;
   while (!CompressedOops::is_null(discovered)) {
     oop discovered_ref = CompressedOops::decode_not_null(discovered);
-    set_oop_field<T>(list, oop(NULL));
+    set_oop_field<T>(list, oop(nullptr));
     list = reference_discovered_addr<T>(discovered_ref);
     discovered = *list;
   }
@@ -575,9 +575,9 @@ void ShenandoahReferenceProcessor::abandon_partial_discovery() {
       clean_discovered_list<oop>(_ref_proc_thread_locals[index].discovered_list_addr<oop>());
     }
   }
-  if (_pending_list != NULL) {
+  if (_pending_list != nullptr) {
     oop pending = _pending_list;
-    _pending_list = NULL;
+    _pending_list = nullptr;
     if (UseCompressedOops) {
       narrowOop* list = reference_discovered_addr<narrowOop>(pending);
       clean_discovered_list<narrowOop>(list);
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp
index 597b0a8ba5b..c4ecf8d359a 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2020, 2021, Red Hat, Inc. and/or its affiliates.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -72,7 +72,7 @@ typedef size_t Counters[reference_type_count];
  *   be processed (e.g. enqueued in its ReferenceQueue) by the Java ReferenceHandler thread.
  *
  * In order to prevent resurrection by Java threads calling Reference.get() concurrently while we are clearing
- * referents, we employ a special barrier, the native LRB, which returns NULL when the referent is unreachable.
+ * referents, we employ a special barrier, the native LRB, which returns nullptr when the referent is unreachable.
  */
 
 class ShenandoahRefProcThreadLocal : public CHeapObj<mtGC> {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp
index 2891edb3a2c..fa18cdf5d0a 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp
@@ -33,7 +33,7 @@
 #include "logging/log.hpp"
 
 static ShenandoahHeuristics* get_heuristics(ShenandoahGeneration* nullable) {
-  return nullable != NULL ? nullable->heuristics() : NULL;
+  return nullable != nullptr ? nullable->heuristics() : nullptr;
 }
 
 ShenandoahRegulatorThread::ShenandoahRegulatorThread(ShenandoahControlThread* control_thread) :
@@ -65,8 +65,8 @@ void ShenandoahRegulatorThread::run_service() {
 }
 
 void ShenandoahRegulatorThread::regulate_concurrent_cycles() {
-  assert(_young_heuristics != NULL, "Need young heuristics.");
-  assert(_old_heuristics != NULL, "Need old heuristics.");
+  assert(_young_heuristics != nullptr, "Need young heuristics.");
+  assert(_old_heuristics != nullptr, "Need old heuristics.");
 
   while (!should_terminate()) {
     ShenandoahControlThread::GCMode mode = _control_thread->gc_mode();
@@ -93,8 +93,8 @@ void ShenandoahRegulatorThread::regulate_concurrent_cycles() {
 }
 
 void ShenandoahRegulatorThread::regulate_interleaved_cycles() {
-  assert(_young_heuristics != NULL, "Need young heuristics.");
-  assert(_global_heuristics != NULL, "Need global heuristics.");
+  assert(_young_heuristics != nullptr, "Need young heuristics.");
+  assert(_global_heuristics != nullptr, "Need global heuristics.");
 
   while (!should_terminate()) {
     if (_control_thread->gc_mode() == ShenandoahControlThread::none) {
@@ -110,7 +110,7 @@ void ShenandoahRegulatorThread::regulate_interleaved_cycles() {
 }
 
 void ShenandoahRegulatorThread::regulate_heap() {
-  assert(_global_heuristics != NULL, "Need global heuristics.");
+  assert(_global_heuristics != nullptr, "Need global heuristics.");
 
   while (!should_terminate()) {
     if (_control_thread->gc_mode() == ShenandoahControlThread::none) {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
index 848f92184d9..834db23147f 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
@@ -128,7 +128,7 @@ ShenandoahConcurrentRootScanner::ShenandoahConcurrentRootScanner(uint n_workers,
    _java_threads(phase, n_workers),
   _vm_roots(phase),
   _cld_roots(phase, n_workers, false /*heap iteration*/),
-  _codecache_snapshot(NULL),
+  _codecache_snapshot(nullptr),
   _phase(phase) {
   if (!ShenandoahHeap::heap()->unload_classes()) {
     MutexLocker locker(CodeCache_lock, Mutex::_no_safepoint_check_flag);
@@ -218,7 +218,7 @@ void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
 
   // Process heavy-weight/fully parallel roots the last
   _code_roots.code_blobs_do(adjust_code_closure, worker_id);
-  _thread_roots.oops_do(oops, NULL, worker_id);
+  _thread_roots.oops_do(oops, nullptr, worker_id);
 }
 
 ShenandoahHeapIterationRootScanner::ShenandoahHeapIterationRootScanner(uint n_workers) :
@@ -258,7 +258,7 @@ void ShenandoahHeapIterationRootScanner::roots_do(OopClosure* oops) {
   // Must use _claim_other to avoid interfering with concurrent CLDG iteration
   CLDToOopClosure clds(oops, ClassLoaderData::_claim_other);
   ShenandoahMarkCodeBlobClosure code(oops);
-  ShenandoahParallelOopsDoThreadClosure tc_cl(oops, &code, NULL);
+  ShenandoahParallelOopsDoThreadClosure tc_cl(oops, &code, nullptr);
 
   ResourceMark rm;
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
index 98a8c6522a0..8bbc742a556 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
@@ -134,7 +134,7 @@ class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
     _f(f), _cf(cf), _thread_cl(thread_cl) {}
 
   void do_thread(Thread* t) {
-    if (_thread_cl != NULL) {
+    if (_thread_cl != nullptr) {
       _thread_cl->do_thread(t);
     }
     t->oops_do(_f, _cf);
@@ -160,7 +160,7 @@ void ShenandoahSTWRootScanner::roots_do(T* oops, uint worker_id) {
     _thread_roots.oops_do(oops, &blobs_cl, worker_id);
     _cld_roots.always_strong_cld_do(&clds, worker_id);
   } else {
-    _thread_roots.oops_do(oops, NULL, worker_id);
+    _thread_roots.oops_do(oops, nullptr, worker_id);
     _code_roots.code_blobs_do(&blobs_cl, worker_id);
     _cld_roots.cld_do(&clds, worker_id);
   }
@@ -185,7 +185,7 @@ void ShenandoahRootUpdater::roots_do(uint worker_id, IsAlive* is_alive, KeepAliv
 
   // Process heavy-weight/fully parallel roots the last
   _code_roots.code_blobs_do(codes_cl, worker_id);
-  _thread_roots.oops_do(keep_alive, NULL, worker_id);
+  _thread_roots.oops_do(keep_alive, nullptr, worker_id);
 }
 
 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp
index b504d32e3d6..07360bcae68 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp
@@ -77,7 +77,7 @@ void ShenandoahRootVerifier::roots_do(OopIterateClosure* oops) {
   // Do thread roots the last. This allows verification code to find
   // any broken objects from those special roots first, not the accidental
   // dangling reference from the thread root.
-  Threads::possibly_parallel_oops_do(true, oops, NULL);
+  Threads::possibly_parallel_oops_do(true, oops, nullptr);
 }
 
 void ShenandoahRootVerifier::strong_roots_do(OopIterateClosure* oops) {
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp
index f7e4b5e1374..2c727de5857 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp
@@ -44,8 +44,8 @@ void ShenandoahRuntime::arraycopy_barrier_narrow_oop_entry(narrowOop* src, narro
 // Shenandoah pre write barrier slowpath
 JRT_LEAF(void, ShenandoahRuntime::write_ref_field_pre_entry(oopDesc* orig, JavaThread *thread))
   assert(thread == JavaThread::current(), "pre-condition");
-  assert(orig != NULL, "should be optimized out");
-  shenandoah_assert_correct(NULL, orig);
+  assert(orig != nullptr, "should be optimized out");
+  shenandoah_assert_correct(nullptr, orig);
   // store the original value that was in the field reference
   assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "Shouldn't be here otherwise");
   SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
@@ -64,7 +64,7 @@ JRT_END
 // in cloned objects.
 JRT_LEAF(void, ShenandoahRuntime::shenandoah_clone_barrier(oopDesc* src))
   oop s = oop(src);
-  shenandoah_assert_correct(NULL, s);
+  shenandoah_assert_correct(nullptr, s);
   ShenandoahBarrierSet::barrier_set()->clone_barrier(s);
 JRT_END
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp
index bf36ef1f7d7..fcd96548cb6 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp
@@ -72,7 +72,7 @@ void ShenandoahScanRememberedTask::do_work(uint worker_id) {
   ShenandoahWorkerTimingsTracker x(ShenandoahPhaseTimings::init_scan_rset, ShenandoahPhaseTimings::ScanClusters, worker_id);
 
   ShenandoahObjToScanQueue* q = _queue_set->queue(worker_id);
-  ShenandoahObjToScanQueue* old = _old_queue_set == NULL ? NULL : _old_queue_set->queue(worker_id);
+  ShenandoahObjToScanQueue* old = _old_queue_set == nullptr ? nullptr : _old_queue_set->queue(worker_id);
   ShenandoahMarkRefsClosure<YOUNG> cl(q, _rp, old);
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   RememberedScanner* scanner = heap->card_scan();
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSharedVariables.hpp b/src/hotspot/share/gc/shenandoah/shenandoahSharedVariables.hpp
index af8db83890f..80c1d3417b2 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahSharedVariables.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahSharedVariables.hpp
@@ -95,7 +95,7 @@ typedef struct ShenandoahSharedFlag {
 private:
   volatile ShenandoahSharedValue* operator&() {
     fatal("Use addr_of() instead");
-    return NULL;
+    return nullptr;
   }
 
   bool operator==(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
@@ -188,7 +188,7 @@ typedef struct ShenandoahSharedBitmap {
 private:
   volatile ShenandoahSharedValue* operator&() {
     fatal("Use addr_of() instead");
-    return NULL;
+    return nullptr;
   }
 
   bool operator==(ShenandoahSharedFlag& other) { fatal("Use is_set() instead"); return false; }
@@ -233,7 +233,7 @@ struct ShenandoahSharedEnumFlag {
 private:
   volatile T* operator&() {
     fatal("Use addr_of() instead");
-    return NULL;
+    return nullptr;
   }
 
   bool operator==(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahStackWatermark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahStackWatermark.cpp
index 7d92ba5a493..6628beecb32 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahStackWatermark.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahStackWatermark.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2021, Red Hat, Inc. All rights reserved.
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@ ShenandoahOnStackCodeBlobClosure::ShenandoahOnStackCodeBlobClosure() :
 
 void ShenandoahOnStackCodeBlobClosure::do_code_blob(CodeBlob* cb) {
   nmethod* const nm = cb->as_nmethod_or_null();
-  if (nm != NULL) {
+  if (nm != nullptr) {
     const bool result = _bs_nm->nmethod_entry_barrier(nm);
     assert(result, "NMethod on-stack must be alive");
   }
@@ -68,7 +68,7 @@ ShenandoahStackWatermark::ShenandoahStackWatermark(JavaThread* jt) :
   _cb_cl() {}
 
 OopClosure* ShenandoahStackWatermark::closure_from_context(void* context) {
-  if (context != NULL) {
+  if (context != nullptr) {
     assert(_heap->is_concurrent_weak_root_in_progress() ||
            _heap->is_concurrent_mark_in_progress(),
            "Only these two phases");
@@ -82,7 +82,7 @@ OopClosure* ShenandoahStackWatermark::closure_from_context(void* context) {
       return &_keep_alive_cl;
     } else {
       ShouldNotReachHere();
-      return NULL;
+      return nullptr;
     }
   }
 }
@@ -130,7 +130,7 @@ void ShenandoahStackWatermark::retire_tlab() {
 
 void ShenandoahStackWatermark::process(const frame& fr, RegisterMap& register_map, void* context) {
   OopClosure* oops = closure_from_context(context);
-  assert(oops != NULL, "Should not get to here");
+  assert(oops != nullptr, "Should not get to here");
   ShenandoahHeap* const heap = ShenandoahHeap::heap();
   assert((heap->is_concurrent_weak_root_in_progress() && heap->is_evacuation_in_progress()) ||
          heap->is_concurrent_mark_in_progress(),
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp
index a03c5a2cb12..3cddc0c6c0a 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp
@@ -34,7 +34,7 @@ void ShenandoahObjToScanQueueSet::clear() {
   uint size = GenericTaskQueueSet<ShenandoahObjToScanQueue, mtGC>::size();
   for (uint index = 0; index < size; index ++) {
     ShenandoahObjToScanQueue* q = queue(index);
-    assert(q != NULL, "Sanity");
+    assert(q != nullptr, "Sanity");
     q->clear();
   }
 }
@@ -43,7 +43,7 @@ bool ShenandoahObjToScanQueueSet::is_empty() {
   uint size = GenericTaskQueueSet<ShenandoahObjToScanQueue, mtGC>::size();
   for (uint index = 0; index < size; index ++) {
     ShenandoahObjToScanQueue* q = queue(index);
-    assert(q != NULL, "Sanity");
+    assert(q != nullptr, "Sanity");
     if (!q->is_empty()) {
       return false;
     }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp
index 5050ce4c4ec..8a84b4eaa66 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp
@@ -204,7 +204,7 @@ class ShenandoahMarkTask
   }
 
 public:
-  ShenandoahMarkTask(oop o = NULL, bool skip_live = false, bool weak = false) {
+  ShenandoahMarkTask(oop o = nullptr, bool skip_live = false, bool weak = false) {
     uintptr_t enc = encode_oop(o, skip_live, weak);
     assert(decode_oop(enc) == o,     "oop encoding should work: " PTR_FORMAT, p2i(o));
     assert(decode_cnt_live(enc) == !skip_live, "skip_live encoding should work");
@@ -265,7 +265,7 @@ class ShenandoahMarkTask
   int _pow;
 
 public:
-  ShenandoahMarkTask(oop o = NULL, bool skip_live = false, bool weak = false, int chunk = 0, int pow = 0):
+  ShenandoahMarkTask(oop o = nullptr, bool skip_live = false, bool weak = false, int chunk = 0, int pow = 0):
     _obj(o), _skip_live(skip_live), _weak(weak), _chunk(chunk), _pow(pow) {
     assert(0 <= chunk && chunk <= chunk_max, "chunk is in range: %d", chunk);
     assert(0 <= pow && pow <= pow_max, "pow is in range: %d", pow);
@@ -334,7 +334,7 @@ T* ParallelClaimableQueueSet<T, F>::claim_next() {
   jint size = (jint)GenericTaskQueueSet<T, F>::size();
 
   if (_claimed_index >= size) {
-    return NULL;
+    return nullptr;
   }
 
   jint index = Atomic::add(&_claimed_index, 1, memory_order_relaxed);
@@ -342,7 +342,7 @@ T* ParallelClaimableQueueSet<T, F>::claim_next() {
   if (index <= size) {
     return GenericTaskQueueSet<T, F>::queue((uint)index - 1);
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp
index 99664d9e1f2..6920e63b03b 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp
@@ -72,10 +72,10 @@ class ShenandoahThreadLocalData {
     _oom_scope_nesting_level(0),
     _oom_during_evac(false),
     _satb_mark_queue(&ShenandoahBarrierSet::satb_mark_queue_set()),
-    _gclab(NULL),
+    _gclab(nullptr),
     _gclab_size(0),
     _paced_time(0),
-    _plab(NULL),
+    _plab(nullptr),
     _plab_size(0),
     _plab_evacuated(0),
     _plab_promoted(0),
@@ -86,10 +86,10 @@ class ShenandoahThreadLocalData {
   }
 
   ~ShenandoahThreadLocalData() {
-    if (_gclab != NULL) {
+    if (_gclab != nullptr) {
       delete _gclab;
     }
-    if (_plab != NULL) {
+    if (_plab != nullptr) {
       ShenandoahHeap::heap()->retire_plab(_plab);
       delete _plab;
     }
@@ -131,7 +131,7 @@ class ShenandoahThreadLocalData {
 
   static void initialize_gclab(Thread* thread) {
     assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs");
-    assert(data(thread)->_gclab == NULL, "Only initialize once");
+    assert(data(thread)->_gclab == nullptr, "Only initialize once");
     data(thread)->_gclab = new PLAB(PLAB::min_size());
     data(thread)->_gclab_size = 0;
     data(thread)->_plab = new PLAB(PLAB::min_size());
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp
index 1c6c82cd1de..9987ef361ea 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp
@@ -92,7 +92,7 @@ class ShenandoahCompiledICProtectionBehaviour : public CompiledICProtectionBehav
   virtual bool lock(CompiledMethod* method) {
     nmethod* const nm = method->as_nmethod();
     ShenandoahReentrantLock* const lock = ShenandoahNMethod::lock_for_nmethod(nm);
-    assert(lock != NULL, "Not yet registered?");
+    assert(lock != nullptr, "Not yet registered?");
     lock->lock();
     return true;
   }
@@ -100,7 +100,7 @@ class ShenandoahCompiledICProtectionBehaviour : public CompiledICProtectionBehav
   virtual void unlock(CompiledMethod* method) {
     nmethod* const nm = method->as_nmethod();
     ShenandoahReentrantLock* const lock = ShenandoahNMethod::lock_for_nmethod(nm);
-    assert(lock != NULL, "Not yet registered?");
+    assert(lock != nullptr, "Not yet registered?");
     lock->unlock();
   }
 
@@ -111,7 +111,7 @@ class ShenandoahCompiledICProtectionBehaviour : public CompiledICProtectionBehav
 
     nmethod* const nm = method->as_nmethod();
     ShenandoahReentrantLock* const lock = ShenandoahNMethod::lock_for_nmethod(nm);
-    assert(lock != NULL, "Not yet registered?");
+    assert(lock != nullptr, "Not yet registered?");
     return lock->owned_by_self();
   }
 };
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp
index f2239a78b86..b43d2b9f490 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp
@@ -91,7 +91,7 @@ ShenandoahGCPauseMark::ShenandoahGCPauseMark(uint gc_id, SvcGCMarker::reason_typ
 
 ShenandoahPausePhase::ShenandoahPausePhase(const char* title, ShenandoahPhaseTimings::Phase phase, bool log_heap_usage) :
   ShenandoahTimingsTracker(phase),
-  _tracer(title, NULL, GCCause::_no_gc, log_heap_usage),
+  _tracer(title, nullptr, GCCause::_no_gc, log_heap_usage),
   _timer(ShenandoahHeap::heap()->gc_timer()) {
   _timer->register_gc_pause_start(title);
 }
@@ -102,7 +102,7 @@ ShenandoahPausePhase::~ShenandoahPausePhase() {
 
 ShenandoahConcurrentPhase::ShenandoahConcurrentPhase(const char* title, ShenandoahPhaseTimings::Phase phase, bool log_heap_usage) :
   ShenandoahTimingsTracker(phase),
-  _tracer(title, NULL, GCCause::_no_gc, log_heap_usage),
+  _tracer(title, nullptr, GCCause::_no_gc, log_heap_usage),
   _timer(ShenandoahHeap::heap()->gc_timer()) {
   _timer->register_gc_concurrent_start(title);
 }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp
index fb67530049d..8c2e903675b 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp
@@ -161,7 +161,7 @@ class ShenandoahSafepoint : public AllStatic {
 
     // Otherwise check we are at proper operation type
     VM_Operation* vm_op = VMThread::vm_operation();
-    if (vm_op == NULL) return false;
+    if (vm_op == nullptr) return false;
 
     VM_Operation::VMOp_Type type = vm_op->type();
     return type == VM_Operation::VMOp_ShenandoahInitMark ||
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
index 82f44b7a738..b3c93c9f4ab 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
@@ -82,9 +82,9 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
     _heap(ShenandoahHeap::heap()),
     _map(map),
     _ld(ld),
-    _interior_loc(NULL),
-    _loc(NULL),
-    _generation(NULL) {
+    _interior_loc(nullptr),
+    _loc(nullptr),
+    _generation(nullptr) {
     if (options._verify_marked == ShenandoahVerifier::_verify_marked_complete_except_references ||
         options._verify_marked == ShenandoahVerifier::_verify_marked_disable) {
       set_ref_discoverer_internal(new ShenandoahIgnoreReferenceDiscoverer());
@@ -92,7 +92,7 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
 
     if (_heap->mode()->is_generational()) {
       _generation = _heap->active_generation();
-      assert(_generation != NULL, "Expected active generation in this mode");
+      assert(_generation != nullptr, "Expected active generation in this mode");
     }
   }
 
@@ -125,7 +125,7 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
   }
 
   bool in_generation(oop obj) {
-    if (_generation == NULL) {
+    if (_generation == nullptr) {
       return true;
     }
 
@@ -149,8 +149,8 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
     // Verify that obj is not in dead space:
     {
       // Do this before touching obj->size()
-      check(ShenandoahAsserts::_safe_unknown, obj, obj_klass != NULL,
-             "Object klass pointer should not be NULL");
+      check(ShenandoahAsserts::_safe_unknown, obj, obj_klass != nullptr,
+             "Object klass pointer should not be null");
       check(ShenandoahAsserts::_safe_unknown, obj, Metaspace::contains(obj_klass),
              "Object klass pointer must go to metaspace");
 
@@ -194,7 +194,7 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
 
     oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
 
-    ShenandoahHeapRegion* fwd_reg = NULL;
+    ShenandoahHeapRegion* fwd_reg = nullptr;
 
     if (obj != fwd) {
       check(ShenandoahAsserts::_safe_oop, obj, _heap->is_in(fwd),
@@ -206,8 +206,8 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
 
       // Do this before touching fwd->size()
       Klass* fwd_klass = fwd->klass_or_null();
-      check(ShenandoahAsserts::_safe_oop, obj, fwd_klass != NULL,
-             "Forwardee klass pointer should not be NULL");
+      check(ShenandoahAsserts::_safe_oop, obj, fwd_klass != nullptr,
+             "Forwardee klass pointer should not be null");
       check(ShenandoahAsserts::_safe_oop, obj, Metaspace::contains(fwd_klass),
              "Forwardee klass pointer must go to metaspace");
       check(ShenandoahAsserts::_safe_oop, obj, obj_klass == fwd_klass,
@@ -311,7 +311,7 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
   void verify_oop_at(T* p, oop obj) {
     _interior_loc = p;
     verify_oop(obj);
-    _interior_loc = NULL;
+    _interior_loc = nullptr;
   }
 
   /**
@@ -321,9 +321,9 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
    * @param obj verified object
    */
   void verify_oop_standalone(oop obj) {
-    _interior_loc = NULL;
+    _interior_loc = nullptr;
     verify_oop(obj);
-    _interior_loc = NULL;
+    _interior_loc = nullptr;
   }
 
   /**
@@ -333,7 +333,7 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
   void verify_oops_from(oop obj) {
     _loc = obj;
     obj->oop_iterate(this);
-    _loc = NULL;
+    _loc = nullptr;
   }
 
   virtual void do_oop(oop* p) { do_oop_work(p); }
@@ -598,10 +598,10 @@ class ShenandoahVerifierMarkedRegionTask : public WorkerTask {
           _ld(ld),
           _claimed(0),
           _processed(0),
-          _generation(NULL) {
+          _generation(nullptr) {
     if (_heap->mode()->is_generational()) {
       _generation = _heap->active_generation();
-      assert(_generation != NULL, "Expected active generation in this mode.");
+      assert(_generation != nullptr, "Expected active generation in this mode.");
     }
   };
 
@@ -635,7 +635,7 @@ class ShenandoahVerifierMarkedRegionTask : public WorkerTask {
   }
 
   bool in_generation(ShenandoahHeapRegion* r) {
-    return _generation == NULL || _generation->contains(r);
+    return _generation == nullptr || _generation->contains(r);
   }
 
   virtual void work_humongous(ShenandoahHeapRegion* r, ShenandoahVerifierStack& stack, ShenandoahVerifyOopClosure& cl) {
@@ -812,12 +812,12 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label,
   ShenandoahGeneration* generation;
   if (_heap->mode()->is_generational()) {
     generation = _heap->active_generation();
-    guarantee(generation != NULL, "Need to know which generation to verify.");
+    guarantee(generation != nullptr, "Need to know which generation to verify.");
   } else {
-    generation = NULL;
+    generation = nullptr;
   }
 
-  if (generation != NULL) {
+  if (generation != nullptr) {
     ShenandoahHeapLocker lock(_heap->lock());
 
     if (remembered == _verify_remembered_for_marking) {
@@ -855,7 +855,7 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label,
   // Internal heap region checks
   if (ShenandoahVerifyLevel >= 1) {
     ShenandoahVerifyHeapRegionClosure cl(label, regions);
-    if (generation != NULL) {
+    if (generation != nullptr) {
       generation->heap_region_iterate(&cl);
     } else {
       _heap->heap_region_iterate(&cl);
@@ -915,7 +915,7 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label,
   if (ShenandoahVerifyLevel >= 4 && marked == _verify_marked_complete && liveness == _verify_liveness_complete) {
     for (size_t i = 0; i < _heap->num_regions(); i++) {
       ShenandoahHeapRegion* r = _heap->get_region(i);
-      if (generation != NULL && !generation->contains(r)) {
+      if (generation != nullptr && !generation->contains(r)) {
         continue;
       }
 
@@ -1115,7 +1115,7 @@ class ShenandoahVerifyNoForwared : public BasicOopIterateClosure {
       oop obj = CompressedOops::decode_not_null(o);
       oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
       if (obj != fwd) {
-        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
+        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, nullptr,
                                          "Verify Roots", "Should not be forwarded", __FILE__, __LINE__);
       }
     }
@@ -1136,18 +1136,18 @@ class ShenandoahVerifyInToSpaceClosure : public BasicOopIterateClosure {
       ShenandoahHeap* heap = ShenandoahHeap::heap();
 
       if (!heap->marking_context()->is_marked_or_old(obj)) {
-        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
+        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, nullptr,
                 "Verify Roots In To-Space", "Should be marked", __FILE__, __LINE__);
       }
 
       if (heap->in_collection_set(obj)) {
-        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
+        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, nullptr,
                 "Verify Roots In To-Space", "Should not be in collection set", __FILE__, __LINE__);
       }
 
       oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
       if (obj != fwd) {
-        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,
+        ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, nullptr,
                 "Verify Roots In To-Space", "Should not be forwarded", __FILE__, __LINE__);
       }
     }
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp
index e2f53eb7bdc..520df4d0128 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp
@@ -39,7 +39,7 @@ class ShenandoahHeap;
 
 class ShenandoahVerifierTask {
 public:
-  ShenandoahVerifierTask(oop o = NULL, int idx = 0): _obj(o) { }
+  ShenandoahVerifierTask(oop o = nullptr, int idx = 0): _obj(o) { }
   ShenandoahVerifierTask(oop o, size_t idx): _obj(o) { }
   // Trivially copyable.
 
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp b/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp
index 923a12a58b8..4a49d28ea86 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp
@@ -34,7 +34,7 @@
 
 ShenandoahWorkerScope::ShenandoahWorkerScope(WorkerThreads* workers, uint nworkers, const char* msg, bool check) :
   _workers(workers) {
-  assert(msg != NULL, "Missing message");
+  assert(msg != nullptr, "Missing message");
 
   _n_workers = _workers->set_active_workers(nworkers);
   assert(_n_workers <= nworkers, "Must be");
diff --git a/src/hotspot/share/jfr/metadata/metadata.xml b/src/hotspot/share/jfr/metadata/metadata.xml
index f273181e248..349f01793b8 100644
--- a/src/hotspot/share/jfr/metadata/metadata.xml
+++ b/src/hotspot/share/jfr/metadata/metadata.xml
@@ -723,7 +723,7 @@
 
   <Event name="NativeMemoryUsage" category="Java Virtual Machine, Memory" label="Native Memory Usage Per Type"
     description="Native memory usage for a given memory type in the JVM" period="everyChunk">
-    <Field type="string" name="type" label="Memory Type" description="Type used for the native memory allocation" />
+    <Field type="NMTType" name="type" label="Memory Type" description="Type used for the native memory allocation" />
     <Field type="ulong" contentType="bytes" name="reserved" label="Reserved Memory" description="Reserved bytes for this type" />
     <Field type="ulong" contentType="bytes" name="committed" label="Committed Memory" description="Committed bytes for this type" />
   </Event>
@@ -1378,6 +1378,10 @@
     <Field type="byte" array="true" name="payload" label="Payload" />
   </Type>
 
+  <Type name="NMTType" label="Native Memory Tracking Type">
+    <Field type="string" name="name" label="Name" />
+  </Type>
+
   <Relation name="JavaMonitorAddress"/>
   <Relation name="SafepointId"/>
   <Relation name="GcId"/>
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
index f284afaacc3..f3a7650968b 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,6 +53,7 @@
 #include "runtime/safepoint.hpp"
 #include "runtime/synchronizer.hpp"
 #include "runtime/vmOperations.hpp"
+#include "services/nmtCommon.hpp"
 #ifdef COMPILER2
 #include "opto/compile.hpp"
 #include "opto/node.hpp"
@@ -321,3 +322,12 @@ void CompilerTypeConstant::serialize(JfrCheckpointWriter& writer) {
     writer.write(compilertype2name((CompilerType)i));
   }
 }
+
+void NMTTypeConstant::serialize(JfrCheckpointWriter& writer) {
+  writer.write_count(mt_number_of_types);
+  for (int i = 0; i < mt_number_of_types; ++i) {
+    writer.write_key(i);
+    MEMFLAGS flag = NMTUtil::index_to_flag(i);
+    writer.write(NMTUtil::flag_to_name(flag));
+  }
+}
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp
index 731dee626c4..c26590b6a11 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -123,4 +123,9 @@ class CompilerTypeConstant : public JfrSerializer {
   void serialize(JfrCheckpointWriter& writer);
 };
 
+class NMTTypeConstant : public JfrSerializer {
+ public:
+  void serialize(JfrCheckpointWriter& writer);
+};
+
 #endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_JFRTYPE_HPP
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
index 5667c892aa8..f1692df5377 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
 #include "runtime/javaThread.hpp"
 #include "runtime/semaphore.hpp"
 #include "runtime/thread.inline.hpp"
+#include "services/memTracker.hpp"
 #include "utilities/macros.hpp"
 
 class JfrSerializerRegistration : public JfrCHeapObj {
@@ -237,6 +238,9 @@ bool JfrTypeManager::initialize() {
   register_static_type(TYPE_THREADSTATE, true, new ThreadStateConstant());
   register_static_type(TYPE_BYTECODE, true, new BytecodeConstant());
   register_static_type(TYPE_COMPILERTYPE, true, new CompilerTypeConstant());
+  if (MemTracker::enabled()) {
+    register_static_type(TYPE_NMTTYPE, true, new NMTTypeConstant());
+  }
   return load_thread_constants(JavaThread::current());
 }
 
diff --git a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp
index bc5c1a4f93e..4d6e6c9e25a 100644
--- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp
+++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp
@@ -185,8 +185,8 @@ class WriteContent : public StackObj {
     return (u4) _content.elements();
   }
 
-  u4 size() const {
-    return (u4)(end_offset() - start_offset());
+  u8 size() const {
+    return (u8)(end_offset() - start_offset());
   }
 
   void write_elements(int64_t offset) {
@@ -194,7 +194,7 @@ class WriteContent : public StackObj {
   }
 
   void write_size() {
-    _cw.write_padded_at_offset<u4>(size(), start_offset());
+    _cw.write_padded_at_offset<u8>(size(), start_offset());
   }
 
   void set_last_checkpoint() {
@@ -209,7 +209,7 @@ class WriteContent : public StackObj {
 static int64_t write_checkpoint_event_prologue(JfrChunkWriter& cw, u8 type_id) {
   const int64_t last_cp_offset = cw.last_checkpoint_offset();
   const int64_t delta_to_last_checkpoint = 0 == last_cp_offset ? 0 : last_cp_offset - cw.current_offset();
-  cw.reserve(sizeof(u4));
+  cw.reserve(sizeof(u8));
   cw.write<u8>(EVENT_CHECKPOINT);
   cw.write(JfrTicks::now());
   cw.write<u8>(0); // duration
diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
index bb21ee78fa8..f53da656e8b 100644
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
+++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
@@ -158,8 +158,8 @@
                                                                                                                                      \
   nonstatic_field(InstanceKlass,               _fields,                                       Array<u2>*)                            \
   nonstatic_field(InstanceKlass,               _constants,                                    ConstantPool*)                         \
-  nonstatic_field(InstanceKlass,               _init_state,                                   InstanceKlass::ClassState)             \
-  nonstatic_field(InstanceKlass,               _init_thread,                                  Thread*)                               \
+  volatile_nonstatic_field(InstanceKlass,      _init_state,                                   InstanceKlass::ClassState)             \
+  volatile_nonstatic_field(InstanceKlass,      _init_thread,                                  JavaThread*)                           \
   nonstatic_field(InstanceKlass,               _misc_flags._flags,                            u2)                                    \
   nonstatic_field(InstanceKlass,               _annotations,                                  Annotations*)                          \
                                                                                                                                      \
diff --git a/src/hotspot/share/oops/access.hpp b/src/hotspot/share/oops/access.hpp
index 983f7d8d793..79268a34749 100644
--- a/src/hotspot/share/oops/access.hpp
+++ b/src/hotspot/share/oops/access.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -309,7 +309,7 @@ class ArrayAccess: public HeapAccess<IS_ARRAY | decorators> {
                                          T* dst,
                                          size_t length) {
     AccessT::arraycopy(src_obj, src_offset_in_bytes, static_cast<const T*>(nullptr),
-                       NULL, 0, dst,
+                       nullptr, 0, dst,
                        length);
   }
 
@@ -317,7 +317,7 @@ class ArrayAccess: public HeapAccess<IS_ARRAY | decorators> {
   static inline void arraycopy_from_native(const T* src,
                                            arrayOop dst_obj, size_t dst_offset_in_bytes,
                                            size_t length) {
-    AccessT::arraycopy(NULL, 0, src,
+    AccessT::arraycopy(nullptr, 0, src,
                        dst_obj, dst_offset_in_bytes, static_cast<T*>(nullptr),
                        length);
   }
@@ -332,8 +332,8 @@ class ArrayAccess: public HeapAccess<IS_ARRAY | decorators> {
 
   template <typename T>
   static inline bool oop_arraycopy_raw(T* src, T* dst, size_t length) {
-    return AccessT::oop_arraycopy(NULL, 0, src,
-                                  NULL, 0, dst,
+    return AccessT::oop_arraycopy(nullptr, 0, src,
+                                  nullptr, 0, dst,
                                   length);
   }
 
diff --git a/src/hotspot/share/oops/access.inline.hpp b/src/hotspot/share/oops/access.inline.hpp
index 7b14503da67..b3f15f1168d 100644
--- a/src/hotspot/share/oops/access.inline.hpp
+++ b/src/hotspot/share/oops/access.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -211,7 +211,7 @@ namespace AccessInternal {
       FunctionPointerT>::type
     resolve_barrier_gc() {
       BarrierSet* bs = BarrierSet::barrier_set();
-      assert(bs != NULL, "GC barriers invoked before BarrierSet is set");
+      assert(bs != nullptr, "GC barriers invoked before BarrierSet is set");
       switch (bs->kind()) {
 #define BARRIER_SET_RESOLVE_BARRIER_CLOSURE(bs_name)                    \
         case BarrierSet::bs_name: {                                     \
@@ -224,7 +224,7 @@ namespace AccessInternal {
 
       default:
         fatal("BarrierSet AccessBarrier resolving not implemented");
-        return NULL;
+        return nullptr;
       };
     }
 
@@ -234,7 +234,7 @@ namespace AccessInternal {
       FunctionPointerT>::type
     resolve_barrier_gc() {
       BarrierSet* bs = BarrierSet::barrier_set();
-      assert(bs != NULL, "GC barriers invoked before BarrierSet is set");
+      assert(bs != nullptr, "GC barriers invoked before BarrierSet is set");
       switch (bs->kind()) {
 #define BARRIER_SET_RESOLVE_BARRIER_CLOSURE(bs_name)                    \
         case BarrierSet::bs_name: {                                       \
@@ -247,7 +247,7 @@ namespace AccessInternal {
 
       default:
         fatal("BarrierSet AccessBarrier resolving not implemented");
-        return NULL;
+        return nullptr;
       };
     }
 
diff --git a/src/hotspot/share/oops/annotations.cpp b/src/hotspot/share/oops/annotations.cpp
index ebe1477dd16..8b2b236960d 100644
--- a/src/hotspot/share/oops/annotations.cpp
+++ b/src/hotspot/share/oops/annotations.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@ Annotations* Annotations::allocate(ClassLoaderData* loader_data, TRAPS) {
 
 // helper
 void Annotations::free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p) {
-  if (p != NULL) {
+  if (p != nullptr) {
     for (int i = 0; i < p->length(); i++) {
       MetadataFactory::free_array<u1>(loader_data, p->at(i));
     }
@@ -49,12 +49,12 @@ void Annotations::free_contents(ClassLoaderData* loader_data, Array<AnnotationAr
 }
 
 void Annotations::deallocate_contents(ClassLoaderData* loader_data) {
-  if (class_annotations() != NULL) {
+  if (class_annotations() != nullptr) {
     MetadataFactory::free_array<u1>(loader_data, class_annotations());
   }
   free_contents(loader_data, fields_annotations());
 
-  if (class_type_annotations() != NULL) {
+  if (class_type_annotations() != nullptr) {
     MetadataFactory::free_array<u1>(loader_data, class_type_annotations());
   }
   free_contents(loader_data, fields_type_annotations());
@@ -64,7 +64,7 @@ void Annotations::deallocate_contents(ClassLoaderData* loader_data) {
 // The alternative to creating this array and adding to Java heap pressure
 // is to have a hashtable of the already created typeArrayOops
 typeArrayOop Annotations::make_java_array(AnnotationArray* annotations, TRAPS) {
-  if (annotations != NULL) {
+  if (annotations != nullptr) {
     int length = annotations->length();
     typeArrayOop copy = oopFactory::new_byteArray(length, CHECK_NULL);
     for (int i = 0; i< length; i++) {
@@ -72,7 +72,7 @@ typeArrayOop Annotations::make_java_array(AnnotationArray* annotations, TRAPS) {
     }
     return copy;
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -81,7 +81,7 @@ void Annotations::metaspace_pointers_do(MetaspaceClosure* it) {
   it->push(&_class_annotations);
   it->push(&_fields_annotations);
   it->push(&_class_type_annotations);
-  it->push(&_fields_type_annotations); // FIXME: need a test case where _fields_type_annotations != NULL
+  it->push(&_fields_type_annotations); // FIXME: need a test case where _fields_type_annotations != nullptr
 }
 
 void Annotations::print_value_on(outputStream* st) const {
diff --git a/src/hotspot/share/oops/annotations.hpp b/src/hotspot/share/oops/annotations.hpp
index e650b5f55c1..c7919ff0ff9 100644
--- a/src/hotspot/share/oops/annotations.hpp
+++ b/src/hotspot/share/oops/annotations.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,10 +70,10 @@ class Annotations: public MetaspaceObj {
   static bool is_read_only_by_default() { return true; }
 
   // Constructor to initialize to null
-  Annotations() : _class_annotations(NULL),
-                  _fields_annotations(NULL),
-                  _class_type_annotations(NULL),
-                  _fields_type_annotations(NULL) {}
+  Annotations() : _class_annotations(nullptr),
+                  _fields_annotations(nullptr),
+                  _class_type_annotations(nullptr),
+                  _fields_type_annotations(nullptr) {}
 
   AnnotationArray* class_annotations() const                       { return _class_annotations; }
   Array<AnnotationArray*>* fields_annotations() const              { return _fields_annotations; }
diff --git a/src/hotspot/share/oops/arrayKlass.cpp b/src/hotspot/share/oops/arrayKlass.cpp
index 9d7cd13177e..1243786aff2 100644
--- a/src/hotspot/share/oops/arrayKlass.cpp
+++ b/src/hotspot/share/oops/arrayKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@ int ArrayKlass::static_size(int header_size) {
 
 
 InstanceKlass* ArrayKlass::java_super() const {
-  if (super() == NULL)  return NULL;  // bootstrap case
+  if (super() == nullptr)  return nullptr;  // bootstrap case
   // Array klasses have primary supertypes which are not reported to Java.
   // Example super chain:  String[][] -> Object[][] -> Object[] -> Object
   return vmClasses::Object_klass();
@@ -61,7 +61,7 @@ InstanceKlass* ArrayKlass::java_super() const {
 
 oop ArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
   ShouldNotReachHere();
-  return NULL;
+  return nullptr;
 }
 
 // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
@@ -86,13 +86,13 @@ Method* ArrayKlass::uncached_lookup_method(const Symbol* name,
 ArrayKlass::ArrayKlass(Symbol* name, KlassKind kind) :
   Klass(kind),
   _dimension(1),
-  _higher_dimension(NULL),
-  _lower_dimension(NULL) {
+  _higher_dimension(nullptr),
+  _lower_dimension(nullptr) {
   // Arrays don't add any new methods, so their vtable is the same size as
   // the vtable of klass Object.
   set_vtable_length(Universe::base_vtable_size());
   set_name(name);
-  set_super(Universe::is_bootstrapping() ? NULL : vmClasses::Object_klass());
+  set_super(Universe::is_bootstrapping() ? nullptr : vmClasses::Object_klass());
   set_layout_helper(Klass::_lh_neutral_value);
   set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)
   JFR_ONLY(INIT_ID(this);)
@@ -102,15 +102,15 @@ ArrayKlass::ArrayKlass(Symbol* name, KlassKind kind) :
 // Initialization of vtables and mirror object is done separately from base_create_array_klass,
 // since a GC can happen. At this point all instance variables of the ArrayKlass must be setup.
 void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) {
-  k->initialize_supers(super_klass, NULL, CHECK);
+  k->initialize_supers(super_klass, nullptr, CHECK);
   k->vtable().initialize_vtable();
 
   // During bootstrapping, before java.base is defined, the module_entry may not be present yet.
   // These classes will be put on a fixup list and their module fields will be patched once
   // java.base is defined.
-  assert((module_entry != NULL) || ((module_entry == NULL) && !ModuleEntryTable::javabase_defined()),
+  assert((module_entry != nullptr) || ((module_entry == nullptr) && !ModuleEntryTable::javabase_defined()),
          "module entry not available post " JAVA_BASE_NAME " definition");
-  oop module = (module_entry != NULL) ? module_entry->module() : (oop)NULL;
+  oop module = (module_entry != nullptr) ? module_entry->module() : (oop)nullptr;
   java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module), Handle(), Handle(), CHECK);
 }
 
@@ -118,10 +118,10 @@ GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots,
                                                             Array<InstanceKlass*>* transitive_interfaces) {
   // interfaces = { cloneable_klass, serializable_klass };
   assert(num_extra_slots == 0, "sanity of primitive array type");
-  assert(transitive_interfaces == NULL, "sanity");
+  assert(transitive_interfaces == nullptr, "sanity");
   // Must share this for correct bootstrapping!
   set_secondary_supers(Universe::the_array_interfaces_array());
-  return NULL;
+  return nullptr;
 }
 
 objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
@@ -131,7 +131,7 @@ objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
   ArrayKlass* ak = ArrayKlass::cast(k);
   objArrayOop o = (objArrayOop)Universe::heap()->array_allocate(ak, size, length,
                                                                 /* do_zero */ true, CHECK_NULL);
-  // initialization to NULL not necessary, area already cleared
+  // initialization to null not necessary, area already cleared
   return o;
 }
 
@@ -159,7 +159,7 @@ void ArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) {
 #if INCLUDE_CDS
 void ArrayKlass::remove_unshareable_info() {
   Klass::remove_unshareable_info();
-  if (_higher_dimension != NULL) {
+  if (_higher_dimension != nullptr) {
     ArrayKlass *ak = ArrayKlass::cast(higher_dimension());
     ak->remove_unshareable_info();
   }
@@ -167,7 +167,7 @@ void ArrayKlass::remove_unshareable_info() {
 
 void ArrayKlass::remove_java_mirror() {
   Klass::remove_java_mirror();
-  if (_higher_dimension != NULL) {
+  if (_higher_dimension != nullptr) {
     ArrayKlass *ak = ArrayKlass::cast(higher_dimension());
     ak->remove_java_mirror();
   }
@@ -178,7 +178,7 @@ void ArrayKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle p
   Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);
   // Klass recreates the component mirror also
 
-  if (_higher_dimension != NULL) {
+  if (_higher_dimension != nullptr) {
     ArrayKlass *ak = ArrayKlass::cast(higher_dimension());
     ak->restore_unshareable_info(loader_data, protection_domain, CHECK);
   }
diff --git a/src/hotspot/share/oops/arrayOop.hpp b/src/hotspot/share/oops/arrayOop.hpp
index 100497f52cb..0d265ea70ad 100644
--- a/src/hotspot/share/oops/arrayOop.hpp
+++ b/src/hotspot/share/oops/arrayOop.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,12 +96,12 @@ class arrayOopDesc : public oopDesc {
 
   template <typename T>
   static T* obj_offset_to_raw(arrayOop obj, size_t offset_in_bytes, T* raw) {
-    if (obj != NULL) {
-      assert(raw == NULL, "either raw or in-heap");
+    if (obj != nullptr) {
+      assert(raw == nullptr, "either raw or in-heap");
       char* base = reinterpret_cast<char*>((void*) obj);
       raw = reinterpret_cast<T*>(base + offset_in_bytes);
     } else {
-      assert(raw != NULL, "either raw or in-heap");
+      assert(raw != nullptr, "either raw or in-heap");
     }
     return raw;
   }
diff --git a/src/hotspot/share/oops/compressedOops.cpp b/src/hotspot/share/oops/compressedOops.cpp
index a488df00b0e..84ab807e4fb 100644
--- a/src/hotspot/share/oops/compressedOops.cpp
+++ b/src/hotspot/share/oops/compressedOops.cpp
@@ -35,7 +35,7 @@
 #include "runtime/globals.hpp"
 
 // For UseCompressedOops.
-NarrowPtrStruct CompressedOops::_narrow_oop = { NULL, 0, true };
+NarrowPtrStruct CompressedOops::_narrow_oop = { nullptr, 0, true };
 MemRegion       CompressedOops::_heap_address_range;
 
 // Choose the heap base address and oop encoding mode
@@ -80,7 +80,7 @@ void CompressedOops::initialize(const ReservedHeapSpace& heap_space) {
 
   // base() is one page below the heap.
   assert((intptr_t)base() <= ((intptr_t)_heap_address_range.start() - (intptr_t)os::vm_page_size()) ||
-         base() == NULL, "invalid value");
+         base() == nullptr, "invalid value");
   assert(shift() == LogMinObjAlignmentInBytes ||
          shift() == 0, "invalid value");
 #endif
@@ -148,14 +148,14 @@ bool CompressedOops::is_disjoint_heap_base_address(address addr) {
 
 // Check for disjoint base compressed oops.
 bool CompressedOops::base_disjoint() {
-  return _narrow_oop._base != NULL && is_disjoint_heap_base_address(_narrow_oop._base);
+  return _narrow_oop._base != nullptr && is_disjoint_heap_base_address(_narrow_oop._base);
 }
 
 // Check for real heapbased compressed oops.
 // We must subtract the base as the bits overlap.
 // If we negate above function, we also get unscaled and zerobased.
 bool CompressedOops::base_overlaps() {
-  return _narrow_oop._base != NULL && !is_disjoint_heap_base_address(_narrow_oop._base);
+  return _narrow_oop._base != nullptr && !is_disjoint_heap_base_address(_narrow_oop._base);
 }
 
 void CompressedOops::print_mode(outputStream* st) {
@@ -179,7 +179,7 @@ void CompressedOops::print_mode(outputStream* st) {
 }
 
 // For UseCompressedClassPointers.
-NarrowPtrStruct CompressedKlassPointers::_narrow_klass = { NULL, 0, true };
+NarrowPtrStruct CompressedKlassPointers::_narrow_klass = { nullptr, 0, true };
 
 // CompressedClassSpaceSize set to 1GB, but appear 3GB away from _narrow_ptrs_base during CDS dump.
 // (Todo: we should #ifdef out CompressedKlassPointers for 32bit completely and fix all call sites which
diff --git a/src/hotspot/share/oops/compressedOops.hpp b/src/hotspot/share/oops/compressedOops.hpp
index bdcc1289899..d004c272fbb 100644
--- a/src/hotspot/share/oops/compressedOops.hpp
+++ b/src/hotspot/share/oops/compressedOops.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@ class ReservedHeapSpace;
 
 struct NarrowPtrStruct {
   // Base address for oop-within-java-object materialization.
-  // NULL if using wide oops or zero based narrow oops.
+  // null if using wide oops or zero based narrow oops.
   address _base;
   // Number of shift bits for encoding/decoding narrow ptrs.
   // 0 if using wide ptrs or zero based unscaled narrow ptrs,
@@ -116,7 +116,7 @@ class CompressedOops : public AllStatic {
 
   static void     print_mode(outputStream* st);
 
-  static bool is_null(oop v)       { return v == NULL; }
+  static bool is_null(oop v)       { return v == nullptr; }
   static bool is_null(narrowOop v) { return v == narrowOop::null; }
 
   static inline oop decode_raw_not_null(narrowOop v);
@@ -127,6 +127,7 @@ class CompressedOops : public AllStatic {
   static inline narrowOop encode(oop v);
 
   // No conversions needed for these overloads
+  static inline oop decode_raw_not_null(oop v);
   static inline oop decode_not_null(oop v);
   static inline oop decode(oop v);
   static inline narrowOop encode_not_null(narrowOop v);
@@ -178,7 +179,7 @@ class CompressedKlassPointers : public AllStatic {
   static size_t   range()              { return  _range; }
   static int      shift()              { return  _narrow_klass._shift; }
 
-  static bool is_null(Klass* v)      { return v == NULL; }
+  static bool is_null(Klass* v)      { return v == nullptr; }
   static bool is_null(narrowKlass v) { return v == 0; }
 
   static inline Klass* decode_raw(narrowKlass v, address base);
diff --git a/src/hotspot/share/oops/compressedOops.inline.hpp b/src/hotspot/share/oops/compressedOops.inline.hpp
index 7cc79a15ae5..3f33926aa6d 100644
--- a/src/hotspot/share/oops/compressedOops.inline.hpp
+++ b/src/hotspot/share/oops/compressedOops.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,7 @@ inline oop CompressedOops::decode_not_null(narrowOop v) {
 }
 
 inline oop CompressedOops::decode(narrowOop v) {
-  return is_null(v) ? (oop)NULL : decode_not_null(v);
+  return is_null(v) ? nullptr : decode_not_null(v);
 }
 
 inline narrowOop CompressedOops::encode_not_null(oop v) {
@@ -78,6 +78,11 @@ inline narrowOop CompressedOops::encode(oop v) {
   return is_null(v) ? narrowOop::null : encode_not_null(v);
 }
 
+inline oop CompressedOops::decode_raw_not_null(oop v) {
+  assert(v != nullptr, "object is null");
+  return v;
+}
+
 inline oop CompressedOops::decode_not_null(oop v) {
   assert(Universe::is_in_heap(v), "object not in heap " PTR_FORMAT, p2i(v));
   return v;
@@ -137,7 +142,7 @@ inline Klass* CompressedKlassPointers::decode_not_null(narrowKlass v, address na
 }
 
 inline Klass* CompressedKlassPointers::decode(narrowKlass v) {
-  return is_null(v) ? (Klass*)NULL : decode_not_null(v);
+  return is_null(v) ? nullptr : decode_not_null(v);
 }
 
 inline narrowKlass CompressedKlassPointers::encode_not_null(Klass* v) {
diff --git a/src/hotspot/share/oops/constMethod.cpp b/src/hotspot/share/oops/constMethod.cpp
index f0a35062c2d..456cc110b50 100644
--- a/src/hotspot/share/oops/constMethod.cpp
+++ b/src/hotspot/share/oops/constMethod.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,8 +53,8 @@ ConstMethod::ConstMethod(int byte_code_size,
 
   NoSafepointVerifier no_safepoint;
   init_fingerprint();
-  set_constants(NULL);
-  set_stackmap_data(NULL);
+  set_constants(nullptr);
+  set_stackmap_data(nullptr);
   set_code_size(byte_code_size);
   set_constMethod_size(size);
   set_inlined_tables_length(sizes); // sets _flags
@@ -62,7 +62,7 @@ ConstMethod::ConstMethod(int byte_code_size,
   assert(this->size() == size, "wrong size for object");
   set_name_index(0);
   set_signature_index(0);
-  set_constants(NULL);
+  set_constants(nullptr);
   set_max_stack(0);
   set_max_locals(0);
   set_method_idnum(0);
@@ -79,10 +79,10 @@ void ConstMethod::copy_stackmap_data(ClassLoaderData* loader_data,
 
 // Deallocate metadata fields associated with ConstMethod*
 void ConstMethod::deallocate_contents(ClassLoaderData* loader_data) {
-  if (stackmap_data() != NULL) {
+  if (stackmap_data() != nullptr) {
     MetadataFactory::free_array<u1>(loader_data, stackmap_data());
   }
-  set_stackmap_data(NULL);
+  set_stackmap_data(nullptr);
 
   // deallocate annotation arrays
   if (has_method_annotations())
@@ -432,7 +432,7 @@ void ConstMethod::print_on(outputStream* st) const {
   st->print_cr("%s", internal_name());
   Method* m = method();
   st->print(" - method:       " PTR_FORMAT " ", p2i(m));
-  if (m != NULL) {
+  if (m != nullptr) {
     m->print_value_on(st);
   }
   st->cr();
@@ -448,10 +448,10 @@ void ConstMethod::print_on(outputStream* st) const {
 void ConstMethod::print_value_on(outputStream* st) const {
   st->print(" const part of method " );
   Method* m = method();
-  if (m != NULL) {
+  if (m != nullptr) {
     m->print_value_on(st);
   } else {
-    st->print("NULL");
+    st->print("null");
   }
 }
 
@@ -460,7 +460,7 @@ void ConstMethod::print_value_on(outputStream* st) const {
 void ConstMethod::verify_on(outputStream* st) {
   // Verification can occur during oop construction before the method or
   // other fields have been initialized.
-  guarantee(method() != NULL && method()->is_method(), "should be method");
+  guarantee(method() != nullptr && method()->is_method(), "should be method");
 
   address m_end = (address)((intptr_t) this + size());
   address compressed_table_start = code_end();
diff --git a/src/hotspot/share/oops/constMethod.hpp b/src/hotspot/share/oops/constMethod.hpp
index f7c22f42fe0..cfe9b518aa2 100644
--- a/src/hotspot/share/oops/constMethod.hpp
+++ b/src/hotspot/share/oops/constMethod.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -276,7 +276,7 @@ class ConstMethod : public MetaspaceObj {
   Array<u1>* stackmap_data() const { return _stackmap_data; }
   void set_stackmap_data(Array<u1>* sd) { _stackmap_data = sd; }
   void copy_stackmap_data(ClassLoaderData* loader_data, u1* sd, int length, TRAPS);
-  bool has_stackmap_table() const { return _stackmap_data != NULL; }
+  bool has_stackmap_table() const { return _stackmap_data != nullptr; }
 
   void init_fingerprint() {
     const uint64_t initval = UCONST64(0x8000000000000000);
@@ -398,7 +398,7 @@ class ConstMethod : public MetaspaceObj {
 
   AnnotationArray** method_annotations_addr() const;
   AnnotationArray* method_annotations() const  {
-    return has_method_annotations() ? *(method_annotations_addr()) : NULL;
+    return has_method_annotations() ? *(method_annotations_addr()) : nullptr;
   }
   void set_method_annotations(AnnotationArray* anno) {
     *(method_annotations_addr()) = anno;
@@ -406,7 +406,7 @@ class ConstMethod : public MetaspaceObj {
 
   AnnotationArray** parameter_annotations_addr() const;
   AnnotationArray* parameter_annotations() const {
-    return has_parameter_annotations() ? *(parameter_annotations_addr()) : NULL;
+    return has_parameter_annotations() ? *(parameter_annotations_addr()) : nullptr;
   }
   void set_parameter_annotations(AnnotationArray* anno) {
     *(parameter_annotations_addr()) = anno;
@@ -414,7 +414,7 @@ class ConstMethod : public MetaspaceObj {
 
   AnnotationArray** type_annotations_addr() const;
   AnnotationArray* type_annotations() const {
-    return has_type_annotations() ? *(type_annotations_addr()) : NULL;
+    return has_type_annotations() ? *(type_annotations_addr()) : nullptr;
   }
   void set_type_annotations(AnnotationArray* anno) {
     *(type_annotations_addr()) = anno;
@@ -422,7 +422,7 @@ class ConstMethod : public MetaspaceObj {
 
   AnnotationArray** default_annotations_addr() const;
   AnnotationArray* default_annotations() const {
-    return has_default_annotations() ? *(default_annotations_addr()) : NULL;
+    return has_default_annotations() ? *(default_annotations_addr()) : nullptr;
   }
   void set_default_annotations(AnnotationArray* anno) {
     *(default_annotations_addr()) = anno;
diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp
index e30415fe087..7783e7388e5 100644
--- a/src/hotspot/share/oops/constantPool.cpp
+++ b/src/hotspot/share/oops/constantPool.cpp
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "cds/archiveHeapWriter.hpp"
 #include "cds/archiveHeapLoader.hpp"
 #include "cds/archiveBuilder.hpp"
 #include "cds/classPrelinker.hpp"
@@ -89,7 +90,7 @@ void ConstantPool::copy_fields(const ConstantPool* orig) {
 // MetaspaceObj allocation invariant is calloc equivalent memory
 // simple verification of this here (JVM_CONSTANT_Invalid == 0 )
 static bool tag_array_is_zero_initialized(Array<u1>* tags) {
-  assert(tags != NULL, "invariant");
+  assert(tags != nullptr, "invariant");
   const int length = tags->length();
   for (int index = 0; index < length; ++index) {
     if (JVM_CONSTANT_Invalid != tags->at(index)) {
@@ -105,31 +106,31 @@ ConstantPool::ConstantPool(Array<u1>* tags) :
   _tags(tags),
   _length(tags->length()) {
 
-    assert(_tags != NULL, "invariant");
+    assert(_tags != nullptr, "invariant");
     assert(tags->length() == _length, "invariant");
     assert(tag_array_is_zero_initialized(tags), "invariant");
     assert(0 == flags(), "invariant");
     assert(0 == version(), "invariant");
-    assert(NULL == _pool_holder, "invariant");
+    assert(nullptr == _pool_holder, "invariant");
 }
 
 void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
-  if (cache() != NULL) {
+  if (cache() != nullptr) {
     MetadataFactory::free_metadata(loader_data, cache());
-    set_cache(NULL);
+    set_cache(nullptr);
   }
 
   MetadataFactory::free_array<Klass*>(loader_data, resolved_klasses());
-  set_resolved_klasses(NULL);
+  set_resolved_klasses(nullptr);
 
   MetadataFactory::free_array<jushort>(loader_data, operands());
-  set_operands(NULL);
+  set_operands(nullptr);
 
   release_C_heap_structures();
 
   // free tag array
   MetadataFactory::free_array<u1>(loader_data, tags());
-  set_tags(NULL);
+  set_tags(nullptr);
 }
 
 void ConstantPool::release_C_heap_structures() {
@@ -164,8 +165,8 @@ objArrayOop ConstantPool::resolved_references() const {
 // Called from outside constant pool resolution where a resolved_reference array
 // may not be present.
 objArrayOop ConstantPool::resolved_references_or_null() const {
-  if (_cache == NULL) {
-    return NULL;
+  if (_cache == nullptr) {
+    return nullptr;
   } else {
     return _cache->resolved_references();
   }
@@ -224,7 +225,7 @@ void ConstantPool::allocate_resolved_klasses(ClassLoaderData* loader_data, int n
   // This allows us to use 0xffff (ConstantPool::_temp_resolved_klass_index) to indicate
   // UnresolvedKlass entries that are temporarily created during class redefinition.
   assert(num_klasses < CPKlassSlot::_temp_resolved_klass_index, "sanity");
-  assert(resolved_klasses() == NULL, "sanity");
+  assert(resolved_klasses() == nullptr, "sanity");
   Array<Klass*>* rk = MetadataFactory::new_array<Klass*>(loader_data, num_klasses, CHECK);
   set_resolved_klasses(rk);
 }
@@ -255,22 +256,22 @@ void ConstantPool::initialize_unresolved_klasses(ClassLoaderData* loader_data, T
 
 // Hidden class support:
 void ConstantPool::klass_at_put(int class_index, Klass* k) {
-  assert(k != NULL, "must be valid klass");
+  assert(k != nullptr, "must be valid klass");
   CPKlassSlot kslot = klass_slot_at(class_index);
   int resolved_klass_index = kslot.resolved_klass_index();
   Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
   Atomic::release_store(adr, k);
 
   // The interpreter assumes when the tag is stored, the klass is resolved
-  // and the Klass* non-NULL, so we need hardware store ordering here.
+  // and the Klass* non-null, so we need hardware store ordering here.
   release_tag_at_put(class_index, JVM_CONSTANT_Class);
 }
 
 #if INCLUDE_CDS_JAVA_HEAP
 // Returns the _resolved_reference array after removing unarchivable items from it.
-// Returns nullptr if this class is not supported, or _resolved_reference doesn't exist.
+// Returns null if this class is not supported, or _resolved_reference doesn't exist.
 objArrayOop ConstantPool::prepare_resolved_references_for_archiving() {
-  if (_cache == NULL) {
+  if (_cache == nullptr) {
     return nullptr; // nothing to do
   }
 
@@ -285,17 +286,16 @@ objArrayOop ConstantPool::prepare_resolved_references_for_archiving() {
   objArrayOop rr = resolved_references();
   if (rr != nullptr) {
     Array<u2>* ref_map = reference_map();
-    int ref_map_len = ref_map == NULL ? 0 : ref_map->length();
+    int ref_map_len = ref_map == nullptr ? 0 : ref_map->length();
     int rr_len = rr->length();
     for (int i = 0; i < rr_len; i++) {
       oop obj = rr->obj_at(i);
       rr->obj_at_put(i, nullptr);
-      if (obj != NULL && i < ref_map_len) {
+      if (obj != nullptr && i < ref_map_len) {
         int index = object_to_cp_index(i);
         if (tag_at(index).is_string()) {
           assert(java_lang_String::is_instance(obj), "must be");
-          typeArrayOop value = java_lang_String::value_no_keepalive(obj);
-          if (!HeapShared::is_too_large_to_archive(value)) {
+          if (!ArchiveHeapWriter::is_string_too_large_to_archive(obj)) {
             rr->obj_at_put(i, obj);
           }
         }
@@ -307,11 +307,12 @@ objArrayOop ConstantPool::prepare_resolved_references_for_archiving() {
 
 void ConstantPool::add_dumped_interned_strings() {
   objArrayOop rr = resolved_references();
-  if (rr != NULL) {
+  if (rr != nullptr) {
     int rr_len = rr->length();
     for (int i = 0; i < rr_len; i++) {
       oop p = rr->obj_at(i);
-      if (java_lang_String::is_instance(p)) {
+      if (java_lang_String::is_instance(p) &&
+          !ArchiveHeapWriter::is_string_too_large_to_archive(p)) {
         HeapShared::add_to_dumped_interned_strings(p);
       }
     }
@@ -328,16 +329,16 @@ void ConstantPool::restore_unshareable_info(TRAPS) {
   assert(is_constantPool(), "ensure C++ vtable is restored");
   assert(on_stack(), "should always be set for shared constant pools");
   assert(is_shared(), "should always be set for shared constant pools");
-  assert(_cache != NULL, "constant pool _cache should not be NULL");
+  assert(_cache != nullptr, "constant pool _cache should not be null");
 
   // Only create the new resolved references array if it hasn't been attempted before
-  if (resolved_references() != NULL) return;
+  if (resolved_references() != nullptr) return;
 
   if (vmClasses::Object_klass_loaded()) {
     ClassLoaderData* loader_data = pool_holder()->class_loader_data();
 #if INCLUDE_CDS_JAVA_HEAP
     if (ArchiveHeapLoader::is_fully_available() &&
-        _cache->archived_references() != NULL) {
+        _cache->archived_references() != nullptr) {
       oop archived = _cache->archived_references();
       // Create handle for the archived resolved reference array object
       Handle refs_handle(THREAD, archived);
@@ -374,7 +375,7 @@ void ConstantPool::remove_unshareable_info() {
   // re-creating the resolved reference array if archived heap data cannot be map
   // at runtime.
   set_resolved_reference_length(
-    resolved_references() != NULL ? resolved_references()->length() : 0);
+    resolved_references() != nullptr ? resolved_references()->length() : 0);
   set_resolved_references(OopHandle());
 
   bool archived = false;
@@ -399,8 +400,8 @@ void ConstantPool::remove_unshareable_info() {
     }
   }
 
-  if (cache() != NULL) {
-    // cache() is NULL if this class is not yet linked.
+  if (cache() != nullptr) {
+    // cache() is null if this class is not yet linked.
     cache()->remove_unshareable_info();
   }
 }
@@ -419,10 +420,10 @@ bool ConstantPool::maybe_archive_resolved_klass_at(int cp_index) {
   CPKlassSlot kslot = klass_slot_at(cp_index);
   int resolved_klass_index = kslot.resolved_klass_index();
   Klass* k = resolved_klasses()->at(resolved_klass_index);
-  // k could be NULL if the referenced class has been excluded via
+  // k could be null if the referenced class has been excluded via
   // SystemDictionaryShared::is_excluded_class().
 
-  if (k != NULL) {
+  if (k != nullptr) {
     ConstantPool* src_cp = ArchiveBuilder::current()->get_source_addr(this);
     if (ClassPrelinker::can_archive_resolved_klass(src_cp, cp_index)) {
       if (log_is_enabled(Debug, cds, resolve)) {
@@ -436,7 +437,7 @@ bool ConstantPool::maybe_archive_resolved_klass_at(int cp_index) {
 
   // This referenced class cannot be archived. Revert the tag to UnresolvedClass,
   // so that the proper class loading and initialization can happen at runtime.
-  resolved_klasses()->at_put(resolved_klass_index, NULL);
+  resolved_klasses()->at_put(resolved_klass_index, nullptr);
   tag_at_put(cp_index, JVM_CONSTANT_UnresolvedClass);
   return false;
 }
@@ -457,21 +458,21 @@ void ConstantPool::string_at_put(int which, int obj_index, oop str) {
 void ConstantPool::trace_class_resolution(const constantPoolHandle& this_cp, Klass* k) {
   ResourceMark rm;
   int line_number = -1;
-  const char * source_file = NULL;
+  const char * source_file = nullptr;
   if (JavaThread::current()->has_last_Java_frame()) {
     // try to identify the method which called this function.
     vframeStream vfst(JavaThread::current());
     if (!vfst.at_end()) {
       line_number = vfst.method()->line_number_from_bci(vfst.bci());
       Symbol* s = vfst.method()->method_holder()->source_file_name();
-      if (s != NULL) {
+      if (s != nullptr) {
         source_file = s->as_C_string();
       }
     }
   }
   if (k != this_cp->pool_holder()) {
     // only print something if the classes are different
-    if (source_file != NULL) {
+    if (source_file != nullptr) {
       log_debug(class, resolve)("%s %s %s:%d",
                  this_cp->pool_holder()->external_name(),
                  k->external_name(), source_file, line_number);
@@ -499,7 +500,7 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
   // the unresolved_klasses() array.
   if (this_cp->tag_at(which).is_klass()) {
     Klass* klass = this_cp->resolved_klasses()->at(resolved_klass_index);
-    if (klass != NULL) {
+    if (klass != nullptr) {
       return klass;
     }
   }
@@ -545,7 +546,7 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
     // some other thread has beaten us and has resolved the class.
     // To preserve old behavior, we return the resolved class.
     Klass* klass = this_cp->resolved_klasses()->at(resolved_klass_index);
-    assert(klass != NULL, "must be resolved if exception was cleared");
+    assert(klass != nullptr, "must be resolved if exception was cleared");
     return klass;
   }
 
@@ -557,7 +558,7 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
   Klass** adr = this_cp->resolved_klasses()->adr_at(resolved_klass_index);
   Atomic::release_store(adr, k);
   // The interpreter assumes when the tag is stored, the klass is resolved
-  // and the Klass* stored in _resolved_klasses is non-NULL, so we need
+  // and the Klass* stored in _resolved_klasses is non-null, so we need
   // hardware store ordering here.
   // We also need to CAS to not overwrite an error from a racing thread.
 
@@ -568,7 +569,7 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
   // We need to recheck exceptions from racing thread and return the same.
   if (old_tag == JVM_CONSTANT_UnresolvedClassInError) {
     // Remove klass.
-    this_cp->resolved_klasses()->at_put(resolved_klass_index, NULL);
+    this_cp->resolved_klasses()->at_put(resolved_klass_index, nullptr);
     throw_resolution_error(this_cp, which, CHECK_NULL);
   }
 
@@ -578,7 +579,7 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
 
 // Does not update ConstantPool* - to avoid any exception throwing. Used
 // by compiler and exception handling.  Also used to avoid classloads for
-// instanceof operations. Returns NULL if the class has not been loaded or
+// instanceof operations. Returns null if the class has not been loaded or
 // if the verification of constant pool failed
 Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int which) {
   CPKlassSlot kslot = this_cp->klass_slot_at(which);
@@ -588,10 +589,10 @@ Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int w
 
   if (this_cp->tag_at(which).is_klass()) {
     Klass* k = this_cp->resolved_klasses()->at(resolved_klass_index);
-    assert(k != NULL, "should be resolved");
+    assert(k != nullptr, "should be resolved");
     return k;
   } else if (this_cp->tag_at(which).is_unresolved_klass_in_error()) {
-    return NULL;
+    return nullptr;
   } else {
     Thread* current = Thread::current();
     Symbol* name = this_cp->symbol_at(name_index);
@@ -602,15 +603,15 @@ Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int w
     Klass* k = SystemDictionary::find_instance_klass(current, name, h_loader, h_prot);
 
     // Avoid constant pool verification at a safepoint, as it takes the Module_lock.
-    if (k != NULL && current->is_Java_thread()) {
+    if (k != nullptr && current->is_Java_thread()) {
       // Make sure that resolving is legal
       JavaThread* THREAD = JavaThread::cast(current); // For exception macros.
       ExceptionMark em(THREAD);
-      // return NULL if verification fails
+      // return null if verification fails
       verify_constant_pool_resolve(this_cp, k, THREAD);
       if (HAS_PENDING_EXCEPTION) {
         CLEAR_PENDING_EXCEPTION;
-        return NULL;
+        return nullptr;
       }
       return k;
     } else {
@@ -621,12 +622,12 @@ Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int w
 
 Method* ConstantPool::method_at_if_loaded(const constantPoolHandle& cpool,
                                                    int which) {
-  if (cpool->cache() == NULL)  return NULL;  // nothing to load yet
+  if (cpool->cache() == nullptr)  return nullptr;  // nothing to load yet
   int cache_index = decode_cpcache_index(which, true);
   if (!(cache_index >= 0 && cache_index < cpool->cache()->length())) {
     // FIXME: should be an assert
     log_debug(class, resolve)("bad operand %d in:", which); cpool->print();
-    return NULL;
+    return nullptr;
   }
   ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
   return e->method_if_resolved(cpool);
@@ -634,14 +635,14 @@ Method* ConstantPool::method_at_if_loaded(const constantPoolHandle& cpool,
 
 
 bool ConstantPool::has_appendix_at_if_loaded(const constantPoolHandle& cpool, int which) {
-  if (cpool->cache() == NULL)  return false;  // nothing to load yet
+  if (cpool->cache() == nullptr)  return false;  // nothing to load yet
   int cache_index = decode_cpcache_index(which, true);
   ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
   return e->has_appendix();
 }
 
 oop ConstantPool::appendix_at_if_loaded(const constantPoolHandle& cpool, int which) {
-  if (cpool->cache() == NULL)  return NULL;  // nothing to load yet
+  if (cpool->cache() == nullptr)  return nullptr;  // nothing to load yet
   int cache_index = decode_cpcache_index(which, true);
   ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
   return e->appendix_if_resolved(cpool);
@@ -649,7 +650,7 @@ oop ConstantPool::appendix_at_if_loaded(const constantPoolHandle& cpool, int whi
 
 
 bool ConstantPool::has_local_signature_at_if_loaded(const constantPoolHandle& cpool, int which) {
-  if (cpool->cache() == NULL)  return false;  // nothing to load yet
+  if (cpool->cache() == nullptr)  return false;  // nothing to load yet
   int cache_index = decode_cpcache_index(which, true);
   ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
   return e->has_local_signature();
@@ -668,7 +669,7 @@ Symbol* ConstantPool::impl_signature_ref_at(int which, bool uncached) {
 
 int ConstantPool::impl_name_and_type_ref_index_at(int which, bool uncached) {
   int i = which;
-  if (!uncached && cache() != NULL) {
+  if (!uncached && cache() != nullptr) {
     if (ConstantPool::is_invokedynamic_index(which)) {
       // Invokedynamic index is index into the constant pool cache
       int pool_index = invokedynamic_bootstrap_ref_index_at(which);
@@ -693,7 +694,7 @@ int ConstantPool::impl_name_and_type_ref_index_at(int which, bool uncached) {
 
 constantTag ConstantPool::impl_tag_ref_at(int which, bool uncached) {
   int pool_index = which;
-  if (!uncached && cache() != NULL) {
+  if (!uncached && cache() != nullptr) {
     if (ConstantPool::is_invokedynamic_index(which)) {
       // Invokedynamic index is index into resolved_references
       pool_index = invokedynamic_bootstrap_ref_index_at(which);
@@ -709,7 +710,7 @@ int ConstantPool::impl_klass_ref_index_at(int which, bool uncached) {
   guarantee(!ConstantPool::is_invokedynamic_index(which),
             "an invokedynamic instruction does not have a klass");
   int i = which;
-  if (!uncached && cache() != NULL) {
+  if (!uncached && cache() != nullptr) {
     // change byte-ordering and go via cache
     i = remap_instruction_operand_from_cache(which);
   }
@@ -788,7 +789,7 @@ void ConstantPool::resolve_string_constants_impl(const constantPoolHandle& this_
 static Symbol* exception_message(const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) {
   // Dig out the detailed message to reuse if possible
   Symbol* message = java_lang_Throwable::detail_message(pending_exception);
-  if (message != NULL) {
+  if (message != nullptr) {
     return message;
   }
 
@@ -824,9 +825,9 @@ static void add_resolution_error(const constantPoolHandle& this_cp, int which,
   oop cause = java_lang_Throwable::cause(pending_exception);
 
   // Also dig out the exception cause, if present.
-  Symbol* cause_sym = NULL;
-  Symbol* cause_msg = NULL;
-  if (cause != NULL && cause != pending_exception) {
+  Symbol* cause_sym = nullptr;
+  Symbol* cause_msg = nullptr;
+  if (cause != nullptr && cause != pending_exception) {
     cause_sym = cause->klass()->name();
     cause_msg = java_lang_Throwable::detail_message(cause);
   }
@@ -838,24 +839,24 @@ static void add_resolution_error(const constantPoolHandle& this_cp, int which,
 
 void ConstantPool::throw_resolution_error(const constantPoolHandle& this_cp, int which, TRAPS) {
   ResourceMark rm(THREAD);
-  Symbol* message = NULL;
-  Symbol* cause = NULL;
-  Symbol* cause_msg = NULL;
+  Symbol* message = nullptr;
+  Symbol* cause = nullptr;
+  Symbol* cause_msg = nullptr;
   Symbol* error = SystemDictionary::find_resolution_error(this_cp, which, &message, &cause, &cause_msg);
-  assert(error != NULL, "checking");
-  const char* cause_str = cause_msg != NULL ? cause_msg->as_C_string() : NULL;
+  assert(error != nullptr, "checking");
+  const char* cause_str = cause_msg != nullptr ? cause_msg->as_C_string() : nullptr;
 
   CLEAR_PENDING_EXCEPTION;
-  if (message != NULL) {
+  if (message != nullptr) {
     char* msg = message->as_C_string();
-    if (cause != NULL) {
+    if (cause != nullptr) {
       Handle h_cause = Exceptions::new_exception(THREAD, cause, cause_str);
       THROW_MSG_CAUSE(error, msg, h_cause);
     } else {
       THROW_MSG(error, msg);
     }
   } else {
-    if (cause != NULL) {
+    if (cause != nullptr) {
       Handle h_cause = Exceptions::new_exception(THREAD, cause, cause_str);
       THROW_CAUSE(error, h_cause);
     } else {
@@ -926,7 +927,7 @@ BasicType ConstantPool::basic_type_for_constant_at(int which) {
 oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
                                            int index, int cache_index,
                                            bool* status_return, TRAPS) {
-  oop result_oop = NULL;
+  oop result_oop = nullptr;
   Handle throw_exception;
 
   if (cache_index == _possible_index_sentinel) {
@@ -942,13 +943,13 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
 
   if (cache_index >= 0) {
     result_oop = this_cp->resolved_reference_at(cache_index);
-    if (result_oop != NULL) {
+    if (result_oop != nullptr) {
       if (result_oop == Universe::the_null_sentinel()) {
         DEBUG_ONLY(int temp_index = (index >= 0 ? index : this_cp->object_to_cp_index(cache_index)));
         assert(this_cp->tag_at(temp_index).is_dynamic_constant(), "only condy uses the null sentinel");
-        result_oop = NULL;
+        result_oop = nullptr;
       }
-      if (status_return != NULL)  (*status_return) = true;
+      if (status_return != nullptr)  (*status_return) = true;
       return result_oop;
       // That was easy...
     }
@@ -959,16 +960,16 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
 
   constantTag tag = this_cp->tag_at(index);
 
-  if (status_return != NULL) {
+  if (status_return != nullptr) {
     // don't trigger resolution if the constant might need it
     switch (tag.value()) {
     case JVM_CONSTANT_Class:
     {
       CPKlassSlot kslot = this_cp->klass_slot_at(index);
       int resolved_klass_index = kslot.resolved_klass_index();
-      if (this_cp->resolved_klasses()->at(resolved_klass_index) == NULL) {
+      if (this_cp->resolved_klasses()->at(resolved_klass_index) == nullptr) {
         (*status_return) = false;
-        return NULL;
+        return nullptr;
       }
       // the klass is waiting in the CP; go get it
       break;
@@ -982,7 +983,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
       break;
     default:
       (*status_return) = false;
-      return NULL;
+      return nullptr;
     }
     // from now on there is either success or an OOME
     (*status_return) = true;
@@ -1028,8 +1029,8 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
       if (!is_reference_type(type)) {
         // Make sure the primitive value is properly boxed.
         // This is a JDK responsibility.
-        const char* fail = NULL;
-        if (result_oop == NULL) {
+        const char* fail = nullptr;
+        if (result_oop == nullptr) {
           fail = "null result instead of box";
         } else if (!is_java_primitive(type)) {
           // FIXME: support value types via unboxing
@@ -1037,7 +1038,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
         } else if (!java_lang_boxing_object::is_instance(result_oop, type)) {
           fail = "primitive is not properly boxed";
         }
-        if (fail != NULL) {
+        if (fail != nullptr) {
           // Since this exception is not a LinkageError, throw exception
           // but do not save a DynamicInError resolution result.
           // See section 5.4.3 of the VM spec.
@@ -1163,7 +1164,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
     // The important thing here is that all threads pick up the same result.
     // It doesn't matter which racing thread wins, as long as only one
     // result is used by all threads, and all future queries.
-    oop new_result = (result_oop == NULL ? Universe::the_null_sentinel() : result_oop);
+    oop new_result = (result_oop == nullptr ? Universe::the_null_sentinel() : result_oop);
     oop old_result = this_cp->set_resolved_reference_at(cache_index, new_result);
     if (old_result == nullptr) {
       return result_oop;  // was installed
@@ -1171,7 +1172,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
       // Return the winning thread's result.  This can be different than
       // the result here for MethodHandles.
       if (old_result == Universe::the_null_sentinel())
-        old_result = NULL;
+        old_result = nullptr;
       return old_result;
     }
   } else {
@@ -1182,7 +1183,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
 
 oop ConstantPool::uncached_string_at(int which, TRAPS) {
   Symbol* sym = unresolved_string_at(which);
-  oop str = StringTable::intern(sym, CHECK_(NULL));
+  oop str = StringTable::intern(sym, CHECK_(nullptr));
   assert(java_lang_String::is_instance(str), "must be string");
   return str;
 }
@@ -1228,9 +1229,9 @@ oop ConstantPool::string_at_impl(const constantPoolHandle& this_cp, int which, i
   // If the string has already been interned, this entry will be non-null
   oop str = this_cp->resolved_reference_at(obj_index);
   assert(str != Universe::the_null_sentinel(), "");
-  if (str != NULL) return str;
+  if (str != nullptr) return str;
   Symbol* sym = this_cp->unresolved_string_at(which);
-  str = StringTable::intern(sym, CHECK_(NULL));
+  str = StringTable::intern(sym, CHECK_(nullptr));
   this_cp->string_at_put(which, obj_index, str);
   assert(java_lang_String::is_instance(str), "must be string");
   return str;
@@ -1480,7 +1481,7 @@ void ConstantPool::resize_operands(int delta_len, int delta_size, TRAPS) {
                                (min_size - 2*min_len) * sizeof(u2));
   // Explicitly deallocate old operands array.
   // Note, it is not needed for 7u backport.
-  if ( operands() != NULL) { // the safety check
+  if ( operands() != nullptr) { // the safety check
     MetadataFactory::free_array<u2>(loader_data, operands());
   }
   set_operands(new_ops);
@@ -2281,7 +2282,7 @@ void ConstantPool::print_on(outputStream* st) const {
     if (on_stack()) st->print(" on_stack");
     st->cr();
   }
-  if (pool_holder() != NULL) {
+  if (pool_holder() != nullptr) {
     st->print_cr(" - holder: " PTR_FORMAT, p2i(pool_holder()));
   }
   st->print_cr(" - cache: " PTR_FORMAT, p2i(cache()));
@@ -2311,7 +2312,7 @@ void ConstantPool::print_entry_on(const int index, outputStream* st) {
   switch (tag_at(index).value()) {
     case JVM_CONSTANT_Class :
       { Klass* k = klass_at(index, CATCH);
-        guarantee(k != NULL, "need klass");
+        guarantee(k != nullptr, "need klass");
         k->print_value_on(st);
         st->print(" {" PTR_FORMAT "}", p2i(k));
       }
@@ -2408,15 +2409,15 @@ void ConstantPool::print_value_on(outputStream* st) const {
   assert(is_constantPool(), "must be constantPool");
   st->print("constant pool [%d]", length());
   if (has_preresolution()) st->print("/preresolution");
-  if (operands() != NULL)  st->print("/operands[%d]", operands()->length());
+  if (operands() != nullptr)  st->print("/operands[%d]", operands()->length());
   print_address_on(st);
-  if (pool_holder() != NULL) {
+  if (pool_holder() != nullptr) {
     st->print(" for ");
     pool_holder()->print_value_on(st);
     bool extra = (pool_holder()->constants() != this);
     if (extra)  st->print(" (extra)");
   }
-  if (cache() != NULL) {
+  if (cache() != nullptr) {
     st->print(" cache=" PTR_FORMAT, p2i(cache()));
   }
 }
@@ -2437,8 +2438,8 @@ void ConstantPool::verify_on(outputStream* st) {
       guarantee(entry->refcount() != 0, "should have nonzero reference count");
     }
   }
-  if (pool_holder() != NULL) {
-    // Note: pool_holder() can be NULL in temporary constant pools
+  if (pool_holder() != nullptr) {
+    // Note: pool_holder() can be null in temporary constant pools
     // used during constant pool merging
     guarantee(pool_holder()->is_klass(),    "should be klass");
   }
diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp
index 9f9c88f0734..a98786a600a 100644
--- a/src/hotspot/share/oops/constantPool.hpp
+++ b/src/hotspot/share/oops/constantPool.hpp
@@ -186,7 +186,7 @@ class ConstantPool : public Metadata {
   // generics support
   Symbol* generic_signature() const {
     return (_generic_signature_index == 0) ?
-      (Symbol*)NULL : symbol_at(_generic_signature_index);
+      nullptr : symbol_at(_generic_signature_index);
   }
   u2 generic_signature_index() const                   { return _generic_signature_index; }
   void set_generic_signature_index(u2 sig_index)       { _generic_signature_index = sig_index; }
@@ -194,7 +194,7 @@ class ConstantPool : public Metadata {
   // source file name
   Symbol* source_file_name() const {
     return (_source_file_name_index == 0) ?
-      (Symbol*)NULL : symbol_at(_source_file_name_index);
+      nullptr : symbol_at(_source_file_name_index);
   }
   u2 source_file_name_index() const                    { return _source_file_name_index; }
   void set_source_file_name_index(u2 sourcefile_index) { _source_file_name_index = sourcefile_index; }
@@ -565,7 +565,7 @@ class ConstantPool : public Metadata {
     operands->at_put(n+1, extract_high_short_from_int(offset));
   }
   static int operand_array_length(Array<u2>* operands) {
-    if (operands == NULL || operands->length() == 0)  return 0;
+    if (operands == nullptr || operands->length() == 0)  return 0;
     int second_part = operand_offset_at(operands, 0);
     return (second_part / 2);
   }
@@ -716,17 +716,17 @@ class ConstantPool : public Metadata {
   // Resolve late bound constants.
   oop resolve_constant_at(int index, TRAPS) {
     constantPoolHandle h_this(THREAD, this);
-    return resolve_constant_at_impl(h_this, index, _no_index_sentinel, NULL, THREAD);
+    return resolve_constant_at_impl(h_this, index, _no_index_sentinel, nullptr, THREAD);
   }
 
   oop resolve_cached_constant_at(int cache_index, TRAPS) {
     constantPoolHandle h_this(THREAD, this);
-    return resolve_constant_at_impl(h_this, _no_index_sentinel, cache_index, NULL, THREAD);
+    return resolve_constant_at_impl(h_this, _no_index_sentinel, cache_index, nullptr, THREAD);
   }
 
   oop resolve_possibly_cached_constant_at(int pool_index, TRAPS) {
     constantPoolHandle h_this(THREAD, this);
-    return resolve_constant_at_impl(h_this, pool_index, _possible_index_sentinel, NULL, THREAD);
+    return resolve_constant_at_impl(h_this, pool_index, _possible_index_sentinel, nullptr, THREAD);
   }
 
   oop find_cached_constant_at(int pool_index, bool& found_it, TRAPS) {
@@ -811,7 +811,7 @@ class ConstantPool : public Metadata {
  private:
 
   void set_resolved_references(OopHandle s) { _cache->set_resolved_references(s); }
-  Array<u2>* reference_map() const        {  return (_cache == NULL) ? NULL :  _cache->reference_map(); }
+  Array<u2>* reference_map() const        {  return (_cache == nullptr) ? nullptr :  _cache->reference_map(); }
   void set_reference_map(Array<u2>* o)    { _cache->set_reference_map(o); }
 
   Symbol* impl_name_ref_at(int which, bool uncached);
diff --git a/src/hotspot/share/oops/cpCache.cpp b/src/hotspot/share/oops/cpCache.cpp
index 23fe7edf1fb..8a884b508a1 100644
--- a/src/hotspot/share/oops/cpCache.cpp
+++ b/src/hotspot/share/oops/cpCache.cpp
@@ -59,7 +59,7 @@
 void ConstantPoolCacheEntry::initialize_entry(int index) {
   assert(0 < index && index < 0x10000, "sanity check");
   _indices = index;
-  _f1 = NULL;
+  _f1 = nullptr;
   _f2 = _flags = 0;
   assert(constant_pool_index() == index, "");
 }
@@ -101,7 +101,7 @@ void ConstantPoolCacheEntry::set_bytecode_2(Bytecodes::Code code) {
 
 // Sets f1, ordering with previous writes.
 void ConstantPoolCacheEntry::release_set_f1(Metadata* f1) {
-  assert(f1 != NULL, "");
+  assert(f1 != nullptr, "");
   Atomic::release_store(&_f1, f1);
 }
 
@@ -158,12 +158,12 @@ void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_co
                                                        int vtable_index,
                                                        bool sender_is_interface) {
   bool is_vtable_call = (vtable_index >= 0);  // FIXME: split this method on this boolean
-  assert(method->interpreter_entry() != NULL, "should have been set at this point");
+  assert(method->interpreter_entry() != nullptr, "should have been set at this point");
   assert(!method->is_obsolete(),  "attempt to write obsolete method to cpCache");
 
   int byte_no = -1;
   bool change_to_virtual = false;
-  InstanceKlass* holder = NULL;  // have to declare this outside the switch
+  InstanceKlass* holder = nullptr;  // have to declare this outside the switch
   switch (invoke_code) {
     case Bytecodes::_invokeinterface:
       holder = method->method_holder();
@@ -251,7 +251,7 @@ void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_co
     }
     if (invoke_code == Bytecodes::_invokestatic) {
       assert(method->method_holder()->is_initialized() ||
-             method->method_holder()->is_init_thread(Thread::current()),
+             method->method_holder()->is_init_thread(JavaThread::current()),
              "invalid class initialization state for invoke_static");
 
       if (!VM_Version::supports_fast_class_init_checks() && method->needs_clinit_barrier()) {
@@ -396,7 +396,7 @@ void ConstantPoolCacheEntry::set_method_handle_common(const constantPoolHandle&
                    (                   1      << is_final_shift            ),
                    adapter->size_of_parameters());
 
-  LogStream* log_stream = NULL;
+  LogStream* log_stream = nullptr;
   LogStreamHandle(Debug, methodhandles, indy) lsh_indy;
   if (lsh_indy.is_enabled()) {
     ResourceMark rm;
@@ -443,7 +443,7 @@ void ConstantPoolCacheEntry::set_method_handle_common(const constantPoolHandle&
   set_bytecode_1(invoke_code);
   NOT_PRODUCT(verify(tty));
 
-  if (log_stream != NULL) {
+  if (log_stream != nullptr) {
     this->print(log_stream, 0, cpool->cache());
   }
 
@@ -483,7 +483,7 @@ Method* ConstantPoolCacheEntry::method_if_resolved(const constantPoolHandle& cpo
   Bytecodes::Code invoke_code = bytecode_1();
   if (invoke_code != (Bytecodes::Code)0) {
     Metadata* f1 = f1_ord();
-    if (f1 != NULL) {
+    if (f1 != nullptr) {
       switch (invoke_code) {
       case Bytecodes::_invokeinterface:
         assert(f1->is_klass(), "");
@@ -521,13 +521,13 @@ Method* ConstantPoolCacheEntry::method_if_resolved(const constantPoolHandle& cpo
       break;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 
 oop ConstantPoolCacheEntry::appendix_if_resolved(const constantPoolHandle& cpool) const {
   if (!has_appendix())
-    return NULL;
+    return nullptr;
   const int ref_index = f2_as_index();
   return cpool->resolved_reference_at(ref_index);
 }
@@ -563,7 +563,7 @@ void ConstantPoolCacheEntry::adjust_method_entry(Method* old_method,
     return;
   }
 
-  assert (_f1 != NULL, "should not call with uninteresting entry");
+  assert (_f1 != nullptr, "should not call with uninteresting entry");
 
   if (!(_f1->is_method())) {
     // _f1 is a Klass* for an interface, _f2 is the method
@@ -581,7 +581,7 @@ void ConstantPoolCacheEntry::adjust_method_entry(Method* old_method,
 bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() {
   Method* m = get_interesting_method_entry();
   // return false if m refers to a non-deleted old or obsolete method
-  if (m != NULL) {
+  if (m != nullptr) {
     assert(m->is_valid() && m->is_method(), "m is a valid method");
     return !m->is_old() && !m->is_obsolete(); // old is always set for old and obsolete
   } else {
@@ -592,15 +592,15 @@ bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() {
 Method* ConstantPoolCacheEntry::get_interesting_method_entry() {
   if (!is_method_entry()) {
     // not a method entry so not interesting by default
-    return NULL;
+    return nullptr;
   }
-  Method* m = NULL;
+  Method* m = nullptr;
   if (is_vfinal()) {
     // virtual and final so _f2 contains method ptr instead of vtable index
     m = f2_as_vfinal_method();
   } else if (is_f1_null()) {
-    // NULL _f1 means this is a virtual entry so also not interesting
-    return NULL;
+    // null _f1 means this is a virtual entry so also not interesting
+    return nullptr;
   } else {
     if (!(_f1->is_method())) {
       // _f1 is a Klass* for an interface
@@ -609,9 +609,9 @@ Method* ConstantPoolCacheEntry::get_interesting_method_entry() {
       m = f1_as_method();
     }
   }
-  assert(m != NULL && m->is_method(), "sanity check");
-  if (m == NULL || !m->is_method()) {
-    return NULL;
+  assert(m != nullptr && m->is_method(), "sanity check");
+  if (m == nullptr || !m->is_method()) {
+    return nullptr;
   }
   return m;
 }
@@ -729,14 +729,14 @@ void ConstantPoolCache::remove_unshareable_info() {
   // <this> is the copy to be written into the archive. It's in the ArchiveBuilder's "buffer space".
   // However, this->_initial_entries was not copied/relocated by the ArchiveBuilder, so it's
   // still pointing to the array allocated inside save_for_archive().
-  assert(_initial_entries != NULL, "archived cpcache must have been initialized");
+  assert(_initial_entries != nullptr, "archived cpcache must have been initialized");
   assert(!ArchiveBuilder::current()->is_in_buffer_space(_initial_entries), "must be");
   for (int i=0; i<length(); i++) {
     // Restore each entry to the initial state -- just after Rewriter::make_constant_pool_cache()
     // has finished.
     *entry_at(i) = _initial_entries->at(i);
   }
-  _initial_entries = NULL;
+  _initial_entries = nullptr;
 }
 #endif // INCLUDE_CDS
 
@@ -745,12 +745,12 @@ void ConstantPoolCache::deallocate_contents(ClassLoaderData* data) {
   data->remove_handle(_resolved_references);
   set_resolved_references(OopHandle());
   MetadataFactory::free_array<u2>(data, _reference_map);
-  set_reference_map(NULL);
+  set_reference_map(nullptr);
 #if INCLUDE_CDS
-  if (_initial_entries != NULL) {
+  if (_initial_entries != nullptr) {
     Arguments::assert_is_dumping_archive();
     MetadataFactory::free_array<ConstantPoolCacheEntry>(data, _initial_entries);
-    _initial_entries = NULL;
+    _initial_entries = nullptr;
   }
 #endif
 }
@@ -758,7 +758,7 @@ void ConstantPoolCache::deallocate_contents(ClassLoaderData* data) {
 #if INCLUDE_CDS_JAVA_HEAP
 oop ConstantPoolCache::archived_references() {
   if (_archived_references_index < 0) {
-    return NULL;
+    return nullptr;
   }
   return HeapShared::get_root(_archived_references_index);
 }
@@ -784,7 +784,7 @@ void ConstantPoolCache::adjust_method_entries(bool * trace_name_printed) {
   for (int i = 0; i < length(); i++) {
     ConstantPoolCacheEntry* entry = entry_at(i);
     Method* old_method = entry->get_interesting_method_entry();
-    if (old_method == NULL || !old_method->is_old()) {
+    if (old_method == nullptr || !old_method->is_old()) {
       continue; // skip uninteresting entries
     }
     if (old_method->is_deleted()) {
@@ -802,7 +802,7 @@ bool ConstantPoolCache::check_no_old_or_obsolete_entries() {
   ResourceMark rm;
   for (int i = 1; i < length(); i++) {
     Method* m = entry_at(i)->get_interesting_method_entry();
-    if (m != NULL && !entry_at(i)->check_no_old_or_obsolete_entries()) {
+    if (m != nullptr && !entry_at(i)->check_no_old_or_obsolete_entries()) {
       log_trace(redefine, class, update, constantpool)
         ("cpcache check found old method entry: class: %s, old: %d, obsolete: %d, method: %s",
          constant_pool()->pool_holder()->external_name(), m->is_old(), m->is_obsolete(), m->external_name());
@@ -814,7 +814,7 @@ bool ConstantPoolCache::check_no_old_or_obsolete_entries() {
 
 void ConstantPoolCache::dump_cache() {
   for (int i = 1; i < length(); i++) {
-    if (entry_at(i)->get_interesting_method_entry() != NULL) {
+    if (entry_at(i)->get_interesting_method_entry() != nullptr) {
       entry_at(i)->print(tty, i, this);
     }
   }
diff --git a/src/hotspot/share/oops/cpCache.hpp b/src/hotspot/share/oops/cpCache.hpp
index b4daaf1ee5b..3ba5cc17eaa 100644
--- a/src/hotspot/share/oops/cpCache.hpp
+++ b/src/hotspot/share/oops/cpCache.hpp
@@ -145,7 +145,7 @@ class ConstantPoolCacheEntry {
   void set_bytecode_2(Bytecodes::Code code);
   void set_f1(Metadata* f1) {
     Metadata* existing_f1 = _f1; // read once
-    assert(existing_f1 == NULL || existing_f1 == f1, "illegal field change");
+    assert(existing_f1 == nullptr || existing_f1 == f1, "illegal field change");
     _f1 = f1;
   }
   void release_set_f1(Metadata* f1);
@@ -226,7 +226,7 @@ class ConstantPoolCacheEntry {
  private:
   void set_direct_or_vtable_call(
     Bytecodes::Code invoke_code,                 // the bytecode used for invoking the method
-    const methodHandle& method,                  // the method/prototype if any (NULL, otherwise)
+    const methodHandle& method,                  // the method/prototype if any (null, otherwise)
     int             vtable_index,                // the vtable index if any, else negative
     bool            sender_is_interface
   );
@@ -442,7 +442,7 @@ class ConstantPoolCache: public MetaspaceObj {
   void metaspace_pointers_do(MetaspaceClosure* it);
   MetaspaceObj::Type type() const         { return ConstantPoolCacheType; }
 
-  oop  archived_references() NOT_CDS_JAVA_HEAP_RETURN_(NULL);
+  oop  archived_references() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
   void set_archived_references(int root_index) NOT_CDS_JAVA_HEAP_RETURN;
   void clear_archived_references() NOT_CDS_JAVA_HEAP_RETURN;
 
diff --git a/src/hotspot/share/oops/cpCache.inline.hpp b/src/hotspot/share/oops/cpCache.inline.hpp
index 259b99669e4..4befcb19498 100644
--- a/src/hotspot/share/oops/cpCache.inline.hpp
+++ b/src/hotspot/share/oops/cpCache.inline.hpp
@@ -57,16 +57,16 @@ inline Method* ConstantPoolCacheEntry::f2_as_interface_method() const {
 inline Metadata* ConstantPoolCacheEntry::f1_ord() const { return (Metadata *)Atomic::load_acquire(&_f1); }
 
 inline Method* ConstantPoolCacheEntry::f1_as_method() const {
-  Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_method(), "");
+  Metadata* f1 = f1_ord(); assert(f1 == nullptr || f1->is_method(), "");
   return (Method*)f1;
 }
 
 inline Klass* ConstantPoolCacheEntry::f1_as_klass() const {
-  Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_klass(), "");
+  Metadata* f1 = f1_ord(); assert(f1 == nullptr || f1->is_klass(), "");
   return (Klass*)f1;
 }
 
-inline bool ConstantPoolCacheEntry::is_f1_null() const { Metadata* f1 = f1_ord(); return f1 == NULL; }
+inline bool ConstantPoolCacheEntry::is_f1_null() const { Metadata* f1 = f1_ord(); return f1 == nullptr; }
 
 inline bool ConstantPoolCacheEntry::has_appendix() const {
   return (!is_f1_null()) && (_flags & (1 << has_appendix_shift)) != 0;
@@ -89,7 +89,7 @@ inline ConstantPoolCache::ConstantPoolCache(int length,
                                             const intStack& invokedynamic_inverse_index_map,
                                             const intStack& invokedynamic_references_map) :
                                                   _length(length),
-                                                  _constant_pool(NULL),
+                                                  _constant_pool(nullptr),
                                                   _gc_epoch(0) {
   CDS_JAVA_HEAP_ONLY(_archived_references_index = -1;)
   initialize(inverse_index_map, invokedynamic_inverse_index_map,
diff --git a/src/hotspot/share/oops/fieldStreams.hpp b/src/hotspot/share/oops/fieldStreams.hpp
index d2387531f29..c075e11fab6 100644
--- a/src/hotspot/share/oops/fieldStreams.hpp
+++ b/src/hotspot/share/oops/fieldStreams.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -126,7 +126,7 @@ class FieldStreamBase : public StackObj {
       int index = _fields->at(_generic_signature_slot);
       return _constants->symbol_at(index);
     } else {
-      return NULL;
+      return nullptr;
     }
   }
 
diff --git a/src/hotspot/share/oops/generateOopMap.cpp b/src/hotspot/share/oops/generateOopMap.cpp
index 70916b4aad9..cc8efdf8d1f 100644
--- a/src/hotspot/share/oops/generateOopMap.cpp
+++ b/src/hotspot/share/oops/generateOopMap.cpp
@@ -280,7 +280,7 @@ RetTableEntry* RetTable::find_jsrs_for_target(int targBci) {
     cur = cur->next();
   }
   ShouldNotReachHere();
-  return NULL;
+  return nullptr;
 }
 
 // The instruction at bci is changing size by "delta".  Update the return map.
@@ -418,7 +418,7 @@ void GenerateOopMap::mark_bbheaders_and_count_gc_points() {
   // First mark all exception handlers as start of a basic-block
   ExceptionTable excps(method());
   for(int i = 0; i < excps.length(); i ++) {
-    bb_mark_fct(this, excps.handler_pc(i), NULL);
+    bb_mark_fct(this, excps.handler_pc(i), nullptr);
   }
 
   // Then iterate through the code
@@ -429,19 +429,19 @@ void GenerateOopMap::mark_bbheaders_and_count_gc_points() {
     int bci = bcs.bci();
 
     if (!fellThrough)
-        bb_mark_fct(this, bci, NULL);
+        bb_mark_fct(this, bci, nullptr);
 
-    fellThrough = jump_targets_do(&bcs, &GenerateOopMap::bb_mark_fct, NULL);
+    fellThrough = jump_targets_do(&bcs, &GenerateOopMap::bb_mark_fct, nullptr);
 
      /* We will also mark successors of jsr's as basic block headers. */
     switch (bytecode) {
       case Bytecodes::_jsr:
         assert(!fellThrough, "should not happen");
-        bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
+        bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), nullptr);
         break;
       case Bytecodes::_jsr_w:
         assert(!fellThrough, "should not happen");
-        bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
+        bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), nullptr);
         break;
       default:
         break;
@@ -649,7 +649,7 @@ BasicBlock  *GenerateOopMap::get_basic_block_containing(int bci) const {
   }
 
   fatal("should have found BB");
-  return NULL;
+  return nullptr;
 }
 
 void GenerateOopMap::restore_state(BasicBlock *bb)
@@ -672,11 +672,11 @@ int GenerateOopMap::next_bb_start_pc(BasicBlock *bb) {
 //
 
 // Allocate memory and throw LinkageError if failure.
-#define ALLOC_RESOURCE_ARRAY(var, type, count) \
-  var = NEW_RESOURCE_ARRAY_RETURN_NULL(type, count);              \
-  if (var == NULL) {                                              \
+#define ALLOC_RESOURCE_ARRAY(var, type, count)                           \
+  var = NEW_RESOURCE_ARRAY_RETURN_NULL(type, count);                     \
+  if (var == nullptr) {                                                  \
     report_error("Cannot reserve enough memory to analyze this method"); \
-    return;                                                       \
+    return;                                                              \
   }
 
 
@@ -801,7 +801,7 @@ void GenerateOopMap::copy_state(CellTypeState *dst, CellTypeState *src) {
 // monitor matching is purely informational and doesn't say anything
 // about the correctness of the code.
 void GenerateOopMap::merge_state_into_bb(BasicBlock *bb) {
-  guarantee(bb != NULL, "null basicblock");
+  guarantee(bb != nullptr, "null basicblock");
   assert(bb->is_alive(), "merging state into a dead basicblock");
 
   if (_stack_top == bb->_stack_top) {
@@ -1157,13 +1157,13 @@ void GenerateOopMap::interp_bb(BasicBlock *bb) {
     }
     interp1(&itr);
 
-    bool fall_through = jump_targets_do(&itr, GenerateOopMap::merge_state, NULL);
+    bool fall_through = jump_targets_do(&itr, GenerateOopMap::merge_state, nullptr);
     if (_got_error)  return;
 
     if (itr.code() == Bytecodes::_ret) {
       assert(!fall_through, "cannot be set if ret instruction");
       // Automatically handles 'wide' ret indices
-      ret_jump_targets_do(&itr, GenerateOopMap::merge_state, itr.get_index(), NULL);
+      ret_jump_targets_do(&itr, GenerateOopMap::merge_state, itr.get_index(), nullptr);
     } else if (fall_through) {
      // Hit end of BB, but the instr. was a fall-through instruction,
      // so perform transition as if the BB ended in a "jump".
@@ -1226,7 +1226,7 @@ void GenerateOopMap::do_exception_edge(BytecodeStream* itr) {
 
       if (start_pc <= bci && bci < end_pc) {
         BasicBlock *excBB = get_basic_block_at(handler_pc);
-        guarantee(excBB != NULL, "no basic block for exception");
+        guarantee(excBB != nullptr, "no basic block for exception");
         CellTypeState *excStk = excBB->stack();
         CellTypeState *cOpStck = stack();
         CellTypeState cOpStck_0 = cOpStck[0];
@@ -1840,7 +1840,7 @@ void GenerateOopMap::do_monitorexit(int bci) {
     // possibility that this bytecode will throw an
     // exception.
     BasicBlock* bb = get_basic_block_containing(bci);
-    guarantee(bb != NULL, "no basic block for bci");
+    guarantee(bb != nullptr, "no basic block for bci");
     bb->set_changed(true);
     bb->_monitor_top = bad_monitors;
 
@@ -2067,7 +2067,7 @@ GenerateOopMap::GenerateOopMap(const methodHandle& method) {
   // We have to initialize all variables here, that can be queried directly
   _method = method;
   _max_locals=0;
-  _init_vars = NULL;
+  _init_vars = nullptr;
 
 #ifndef PRODUCT
   // If we are doing a detailed trace, include the regular trace information.
@@ -2088,7 +2088,7 @@ bool GenerateOopMap::compute_map(Thread* current) {
   }
 #endif
   TraceTime t_single("oopmap time", TimeOopMap2);
-  TraceTime t_all(NULL, &_total_oopmap_time, TimeOopMap);
+  TraceTime t_all(nullptr, &_total_oopmap_time, TimeOopMap);
 
   // Initialize values
   _got_error      = false;
@@ -2100,7 +2100,7 @@ bool GenerateOopMap::compute_map(Thread* current) {
   _init_vars      = new GrowableArray<intptr_t>(5);  // There are seldom more than 5 init_vars
   _report_result  = false;
   _report_result_for_send = false;
-  _new_var_map    = NULL;
+  _new_var_map    = nullptr;
   _ret_adr_tos    = new GrowableArray<intptr_t>(5);  // 5 seems like a good number;
   _did_rewriting  = false;
   _did_relocation = false;
@@ -2218,7 +2218,7 @@ void GenerateOopMap::result_for_basicblock(int bci) {
 
   // Find basicblock and report results
   BasicBlock* bb = get_basic_block_containing(bci);
-  guarantee(bb != NULL, "no basic block for bci");
+  guarantee(bb != nullptr, "no basic block for bci");
   assert(bb->is_reachable(), "getting result from unreachable basicblock");
   bb->set_changed(true);
   interp_bb(bb);
@@ -2278,7 +2278,7 @@ void GenerateOopMap::rewrite_refval_conflicts()
     method()->print_codes();
   }
 
-  assert(_new_var_map!=NULL, "nothing to rewrite");
+  assert(_new_var_map!=nullptr, "nothing to rewrite");
   assert(_conflict==true, "We should not be here");
 
   compute_ret_adr_at_TOS();
@@ -2302,7 +2302,7 @@ void GenerateOopMap::rewrite_refval_conflicts()
   _max_locals += _nof_refval_conflicts;
 
   // That was that...
-  _new_var_map = NULL;
+  _new_var_map = nullptr;
   _nof_refval_conflicts = 0;
 }
 
@@ -2502,7 +2502,7 @@ bool GenerateOopMap::stack_top_holds_ret_addr(int bci) {
 }
 
 void GenerateOopMap::compute_ret_adr_at_TOS() {
-  assert(_ret_adr_tos != NULL, "must be initialized");
+  assert(_ret_adr_tos != nullptr, "must be initialized");
   _ret_adr_tos->clear();
 
   for (int i = 0; i < bb_count(); i++) {
diff --git a/src/hotspot/share/oops/generateOopMap.hpp b/src/hotspot/share/oops/generateOopMap.hpp
index 8ab15c92b84..229aeffad4c 100644
--- a/src/hotspot/share/oops/generateOopMap.hpp
+++ b/src/hotspot/share/oops/generateOopMap.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,7 +77,7 @@ class RetTable {
 
   void add_jsr(int return_bci, int target_bci);   // Adds entry to list
  public:
-  RetTable()                                                  { _first = NULL; }
+  RetTable()                                                  { _first = nullptr; }
   void compute_ret_table(const methodHandle& method);
   void update_ret_table(int bci, int delta);
   RetTableEntry* find_jsrs_for_target(int targBci);
diff --git a/src/hotspot/share/oops/instanceClassLoaderKlass.inline.hpp b/src/hotspot/share/oops/instanceClassLoaderKlass.inline.hpp
index 0c644da0103..22eb7281654 100644
--- a/src/hotspot/share/oops/instanceClassLoaderKlass.inline.hpp
+++ b/src/hotspot/share/oops/instanceClassLoaderKlass.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@ inline void InstanceClassLoaderKlass::oop_oop_iterate(oop obj, OopClosureType* c
   if (Devirtualizer::do_metadata(closure)) {
     ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj);
     // cld can be null if we have a non-registered class loader.
-    if (cld != NULL) {
+    if (cld != nullptr) {
       Devirtualizer::do_cld(closure, cld);
     }
   }
@@ -64,7 +64,7 @@ inline void InstanceClassLoaderKlass::oop_oop_iterate_bounded(oop obj, OopClosur
     if (mr.contains(obj)) {
       ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj);
       // cld can be null if we have a non-registered class loader.
-      if (cld != NULL) {
+      if (cld != nullptr) {
         Devirtualizer::do_cld(closure, cld);
       }
     }
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
index a2d1e55e1f6..03ebf658553 100644
--- a/src/hotspot/share/oops/instanceKlass.cpp
+++ b/src/hotspot/share/oops/instanceKlass.cpp
@@ -111,10 +111,10 @@
 #define HOTSPOT_CLASS_INITIALIZATION_end HOTSPOT_CLASS_INITIALIZATION_END
 #define DTRACE_CLASSINIT_PROBE(type, thread_type)                \
   {                                                              \
-    char* data = NULL;                                           \
+    char* data = nullptr;                                        \
     int len = 0;                                                 \
     Symbol* clss_name = name();                                  \
-    if (clss_name != NULL) {                                     \
+    if (clss_name != nullptr) {                                  \
       data = (char*)clss_name->bytes();                          \
       len = clss_name->utf8_length();                            \
     }                                                            \
@@ -124,10 +124,10 @@
 
 #define DTRACE_CLASSINIT_PROBE_WAIT(type, thread_type, wait)     \
   {                                                              \
-    char* data = NULL;                                           \
+    char* data = nullptr;                                        \
     int len = 0;                                                 \
     Symbol* clss_name = name();                                  \
-    if (clss_name != NULL) {                                     \
+    if (clss_name != nullptr) {                                  \
       data = (char*)clss_name->bytes();                          \
       len = clss_name->utf8_length();                            \
     }                                                            \
@@ -146,7 +146,7 @@ bool InstanceKlass::_finalization_enabled = true;
 
 static inline bool is_class_loader(const Symbol* class_name,
                                    const ClassFileParser& parser) {
-  assert(class_name != NULL, "invariant");
+  assert(class_name != nullptr, "invariant");
 
   if (class_name == vmSymbols::java_lang_ClassLoader()) {
     return true;
@@ -154,7 +154,7 @@ static inline bool is_class_loader(const Symbol* class_name,
 
   if (vmClasses::ClassLoader_klass_loaded()) {
     const Klass* const super_klass = parser.super_klass();
-    if (super_klass != NULL) {
+    if (super_klass != nullptr) {
       if (super_klass->is_subtype_of(vmClasses::ClassLoader_klass())) {
         return true;
       }
@@ -174,7 +174,7 @@ static inline bool is_stack_chunk_class(const Symbol* class_name,
 // same classloader.
 bool InstanceKlass::has_nest_member(JavaThread* current, InstanceKlass* k) const {
   assert(!is_hidden(), "unexpected hidden class");
-  if (_nest_members == NULL || _nest_members == Universe::the_empty_short_array()) {
+  if (_nest_members == nullptr || _nest_members == Universe::the_empty_short_array()) {
     if (log_is_enabled(Trace, class, nestmates)) {
       ResourceMark rm(current);
       log_trace(class, nestmates)("Checked nest membership of %s in non-nest-host class %s",
@@ -206,8 +206,8 @@ bool InstanceKlass::has_nest_member(JavaThread* current, InstanceKlass* k) const
 // Called to verify that k is a permitted subclass of this class
 bool InstanceKlass::has_as_permitted_subclass(const InstanceKlass* k) const {
   Thread* current = Thread::current();
-  assert(k != NULL, "sanity check");
-  assert(_permitted_subclasses != NULL && _permitted_subclasses != Universe::the_empty_short_array(),
+  assert(k != nullptr, "sanity check");
+  assert(_permitted_subclasses != nullptr && _permitted_subclasses != Universe::the_empty_short_array(),
          "unexpected empty _permitted_subclasses array");
 
   if (log_is_enabled(Trace, class, sealed)) {
@@ -245,20 +245,20 @@ bool InstanceKlass::has_as_permitted_subclass(const InstanceKlass* k) const {
 
 // Return nest-host class, resolving, validating and saving it if needed.
 // In cases where this is called from a thread that cannot do classloading
-// (such as a native JIT thread) then we simply return NULL, which in turn
+// (such as a native JIT thread) then we simply return null, which in turn
 // causes the access check to return false. Such code will retry the access
 // from a more suitable environment later. Otherwise the _nest_host is always
 // set once this method returns.
 // Any errors from nest-host resolution must be preserved so they can be queried
 // from higher-level access checking code, and reported as part of access checking
 // exceptions.
-// VirtualMachineErrors are propagated with a NULL return.
-// Under any conditions where the _nest_host can be set to non-NULL the resulting
+// VirtualMachineErrors are propagated with a null return.
+// Under any conditions where the _nest_host can be set to non-null the resulting
 // value of it and, if applicable, the nest host resolution/validation error,
 // are idempotent.
 InstanceKlass* InstanceKlass::nest_host(TRAPS) {
   InstanceKlass* nest_host_k = _nest_host;
-  if (nest_host_k != NULL) {
+  if (nest_host_k != nullptr) {
     return nest_host_k;
   }
 
@@ -271,7 +271,7 @@ InstanceKlass* InstanceKlass::nest_host(TRAPS) {
     if (!can_resolve && !_constants->tag_at(_nest_host_index).is_klass()) {
       log_trace(class, nestmates)("Rejected resolution of nest-host of %s in unsuitable thread",
                                   this->external_name());
-      return NULL; // sentinel to say "try again from a different context"
+      return nullptr; // sentinel to say "try again from a different context"
     }
 
     log_trace(class, nestmates)("Resolving nest-host of %s using cp entry for %s",
@@ -281,7 +281,7 @@ InstanceKlass* InstanceKlass::nest_host(TRAPS) {
     Klass* k = _constants->klass_at(_nest_host_index, THREAD);
     if (HAS_PENDING_EXCEPTION) {
       if (PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass())) {
-        return NULL; // propagate VMEs
+        return nullptr; // propagate VMEs
       }
       stringStream ss;
       char* target_host_class = _constants->klass_name_at(_nest_host_index)->as_C_string();
@@ -298,7 +298,7 @@ InstanceKlass* InstanceKlass::nest_host(TRAPS) {
       // A valid nest-host is an instance class in the current package that lists this
       // class as a nest member. If any of these conditions are not met the class is
       // its own nest-host.
-      const char* error = NULL;
+      const char* error = nullptr;
 
       // JVMS 5.4.4 indicates package check comes first
       if (is_same_class_package(k)) {
@@ -360,11 +360,11 @@ InstanceKlass* InstanceKlass::nest_host(TRAPS) {
 // assert some of those facts.
 void InstanceKlass::set_nest_host(InstanceKlass* host) {
   assert(is_hidden(), "must be a hidden class");
-  assert(host != NULL, "NULL nest host specified");
-  assert(_nest_host == NULL, "current class has resolved nest-host");
-  assert(nest_host_error() == NULL, "unexpected nest host resolution error exists: %s",
+  assert(host != nullptr, "null nest host specified");
+  assert(_nest_host == nullptr, "current class has resolved nest-host");
+  assert(nest_host_error() == nullptr, "unexpected nest host resolution error exists: %s",
          nest_host_error());
-  assert((host->_nest_host == NULL && host->_nest_host_index == 0) ||
+  assert((host->_nest_host == nullptr && host->_nest_host_index == 0) ||
          (host->_nest_host == host), "proposed host is not a valid nest-host");
   // Can't assert this as package is not set yet:
   // assert(is_same_class_package(host), "proposed host is in wrong package");
@@ -375,7 +375,7 @@ void InstanceKlass::set_nest_host(InstanceKlass* host) {
     // a hidden class does not expect a statically defined nest-host
     if (_nest_host_index > 0) {
       msg = "(the NestHost attribute in the current class is ignored)";
-    } else if (_nest_members != NULL && _nest_members != Universe::the_empty_short_array()) {
+    } else if (_nest_members != nullptr && _nest_members != Universe::the_empty_short_array()) {
       msg = "(the NestMembers attribute in the current class is ignored)";
     }
     log_trace(class, nestmates)("Injected type %s into the nest of %s %s",
@@ -387,7 +387,7 @@ void InstanceKlass::set_nest_host(InstanceKlass* host) {
   _nest_host = host;
   // Record dependency to keep nest host from being unloaded before this class.
   ClassLoaderData* this_key = class_loader_data();
-  assert(this_key != NULL, "sanity");
+  assert(this_key != nullptr, "sanity");
   this_key->record_dependency(host);
 }
 
@@ -403,12 +403,12 @@ bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
   // the target class k.
 
   InstanceKlass* cur_host = nest_host(CHECK_false);
-  if (cur_host == NULL) {
+  if (cur_host == nullptr) {
     return false;
   }
 
   Klass* k_nest_host = k->nest_host(CHECK_false);
-  if (k_nest_host == NULL) {
+  if (k_nest_host == nullptr) {
     return false;
   }
 
@@ -424,7 +424,7 @@ bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
 
 const char* InstanceKlass::nest_host_error() {
   if (_nest_host_index == 0) {
-    return NULL;
+    return nullptr;
   } else {
     constantPoolHandle cph(Thread::current(), constants());
     return SystemDictionary::find_nest_host_error(cph, (int)_nest_host_index);
@@ -438,9 +438,9 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par
                                        parser.is_interface());
 
   const Symbol* const class_name = parser.class_name();
-  assert(class_name != NULL, "invariant");
+  assert(class_name != nullptr, "invariant");
   ClassLoaderData* loader_data = parser.loader_data();
-  assert(loader_data != NULL, "invariant");
+  assert(loader_data != nullptr, "invariant");
 
   InstanceKlass* ik;
 
@@ -465,7 +465,7 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par
   // Check for pending exception before adding to the loader data and incrementing
   // class count.  Can get OOM here.
   if (HAS_PENDING_EXCEPTION) {
-    return NULL;
+    return nullptr;
   }
 
   return ik;
@@ -474,7 +474,7 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par
 
 // copy method ordering from resource area to Metaspace
 void InstanceKlass::copy_method_ordering(const intArray* m, TRAPS) {
-  if (m != NULL) {
+  if (m != nullptr) {
     // allocate a new array and copy contents (memcpy?)
     _method_ordering = MetadataFactory::new_array<int>(class_loader_data(), m->length(), CHECK);
     for (int i = 0; i < m->length(); i++) {
@@ -488,7 +488,7 @@ void InstanceKlass::copy_method_ordering(const intArray* m, TRAPS) {
 // create a new array of vtable_indices for default methods
 Array<int>* InstanceKlass::create_new_default_vtable_indices(int len, TRAPS) {
   Array<int>* vtable_indices = MetadataFactory::new_array<int>(class_loader_data(), len, CHECK_NULL);
-  assert(default_vtable_indices() == NULL, "only create once");
+  assert(default_vtable_indices() == nullptr, "only create once");
   set_default_vtable_indices(vtable_indices);
   return vtable_indices;
 }
@@ -499,10 +499,10 @@ static Monitor* create_init_monitor(const char* name) {
 
 InstanceKlass::InstanceKlass(const ClassFileParser& parser, KlassKind kind, ReferenceType reference_type) :
   Klass(kind),
-  _nest_members(NULL),
-  _nest_host(NULL),
-  _permitted_subclasses(NULL),
-  _record_components(NULL),
+  _nest_members(nullptr),
+  _nest_host(nullptr),
+  _permitted_subclasses(nullptr),
+  _record_components(nullptr),
   _static_field_size(parser.static_field_size()),
   _nonstatic_oop_map_size(nonstatic_oop_map_size(parser.total_oop_map_count())),
   _itable_len(parser.itable_size()),
@@ -510,7 +510,7 @@ InstanceKlass::InstanceKlass(const ClassFileParser& parser, KlassKind kind, Refe
   _init_state(allocated),
   _reference_type(reference_type),
   _init_monitor(create_init_monitor("InstanceKlassInitMonitor_lock")),
-  _init_thread(NULL)
+  _init_thread(nullptr)
 {
   set_vtable_length(parser.vtable_size());
   set_access_flags(parser.access_flags());
@@ -518,18 +518,18 @@ InstanceKlass::InstanceKlass(const ClassFileParser& parser, KlassKind kind, Refe
   set_layout_helper(Klass::instance_layout_helper(parser.layout_size(),
                                                     false));
 
-  assert(NULL == _methods, "underlying memory not zeroed?");
+  assert(nullptr == _methods, "underlying memory not zeroed?");
   assert(is_instance_klass(), "is layout incorrect?");
   assert(size_helper() == parser.layout_size(), "incorrect size_helper?");
 }
 
 void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,
                                        Array<Method*>* methods) {
-  if (methods != NULL && methods != Universe::the_empty_method_array() &&
+  if (methods != nullptr && methods != Universe::the_empty_method_array() &&
       !methods->is_shared()) {
     for (int i = 0; i < methods->length(); i++) {
       Method* method = methods->at(i);
-      if (method == NULL) continue;  // maybe null if error processing
+      if (method == nullptr) continue;  // maybe null if error processing
       // Only want to delete methods that are not executing for RedefineClasses.
       // The previous version will point to them so they're not totally dangling
       assert (!method->on_stack(), "shouldn't be called with methods on stack");
@@ -548,23 +548,23 @@ void InstanceKlass::deallocate_interfaces(ClassLoaderData* loader_data,
   Array<InstanceKlass*>* ti = transitive_interfaces;
   if (ti != Universe::the_empty_instance_klass_array() && ti != local_interfaces) {
     // check that the interfaces don't come from super class
-    Array<InstanceKlass*>* sti = (super_klass == NULL) ? NULL :
+    Array<InstanceKlass*>* sti = (super_klass == nullptr) ? nullptr :
                     InstanceKlass::cast(super_klass)->transitive_interfaces();
-    if (ti != sti && ti != NULL && !ti->is_shared()) {
+    if (ti != sti && ti != nullptr && !ti->is_shared()) {
       MetadataFactory::free_array<InstanceKlass*>(loader_data, ti);
     }
   }
 
   // local interfaces can be empty
   if (local_interfaces != Universe::the_empty_instance_klass_array() &&
-      local_interfaces != NULL && !local_interfaces->is_shared()) {
+      local_interfaces != nullptr && !local_interfaces->is_shared()) {
     MetadataFactory::free_array<InstanceKlass*>(loader_data, local_interfaces);
   }
 }
 
 void InstanceKlass::deallocate_record_components(ClassLoaderData* loader_data,
                                                  Array<RecordComponent*>* record_components) {
-  if (record_components != NULL && !record_components->is_shared()) {
+  if (record_components != nullptr && !record_components->is_shared()) {
     for (int i = 0; i < record_components->length(); i++) {
       RecordComponent* record_component = record_components->at(i);
       MetadataFactory::free_metadata(loader_data, record_component);
@@ -577,8 +577,8 @@ void InstanceKlass::deallocate_record_components(ClassLoaderData* loader_data,
 // InstanceKlass points to.
 void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
   // Orphan the mirror first, CMS thinks it's still live.
-  if (java_mirror() != NULL) {
-    java_lang_Class::set_klass(java_mirror(), NULL);
+  if (java_mirror() != nullptr) {
+    java_lang_Class::set_klass(java_mirror(), nullptr);
   }
 
   // Also remove mirror from handles
@@ -591,7 +591,7 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
   // For class redefinition, we keep the original class so this scratch class
   // doesn't have an array class.  Either way, assert that there is nothing
   // to deallocate.
-  assert(array_klasses() == NULL, "array classes shouldn't be created for this class yet");
+  assert(array_klasses() == nullptr, "array classes shouldn't be created for this class yet");
 
   // Release C heap allocated data that this points to, which includes
   // reference counting symbol names.
@@ -601,59 +601,59 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
   release_C_heap_structures(/* release_sub_metadata */ false);
 
   deallocate_methods(loader_data, methods());
-  set_methods(NULL);
+  set_methods(nullptr);
 
   deallocate_record_components(loader_data, record_components());
-  set_record_components(NULL);
+  set_record_components(nullptr);
 
-  if (method_ordering() != NULL &&
+  if (method_ordering() != nullptr &&
       method_ordering() != Universe::the_empty_int_array() &&
       !method_ordering()->is_shared()) {
     MetadataFactory::free_array<int>(loader_data, method_ordering());
   }
-  set_method_ordering(NULL);
+  set_method_ordering(nullptr);
 
   // default methods can be empty
-  if (default_methods() != NULL &&
+  if (default_methods() != nullptr &&
       default_methods() != Universe::the_empty_method_array() &&
       !default_methods()->is_shared()) {
     MetadataFactory::free_array<Method*>(loader_data, default_methods());
   }
   // Do NOT deallocate the default methods, they are owned by superinterfaces.
-  set_default_methods(NULL);
+  set_default_methods(nullptr);
 
   // default methods vtable indices can be empty
-  if (default_vtable_indices() != NULL &&
+  if (default_vtable_indices() != nullptr &&
       !default_vtable_indices()->is_shared()) {
     MetadataFactory::free_array<int>(loader_data, default_vtable_indices());
   }
-  set_default_vtable_indices(NULL);
+  set_default_vtable_indices(nullptr);
 
 
   // This array is in Klass, but remove it with the InstanceKlass since
   // this place would be the only caller and it can share memory with transitive
   // interfaces.
-  if (secondary_supers() != NULL &&
+  if (secondary_supers() != nullptr &&
       secondary_supers() != Universe::the_empty_klass_array() &&
       // see comments in compute_secondary_supers about the following cast
       (address)(secondary_supers()) != (address)(transitive_interfaces()) &&
       !secondary_supers()->is_shared()) {
     MetadataFactory::free_array<Klass*>(loader_data, secondary_supers());
   }
-  set_secondary_supers(NULL);
+  set_secondary_supers(nullptr);
 
   deallocate_interfaces(loader_data, super(), local_interfaces(), transitive_interfaces());
-  set_transitive_interfaces(NULL);
-  set_local_interfaces(NULL);
+  set_transitive_interfaces(nullptr);
+  set_local_interfaces(nullptr);
 
-  if (fields() != NULL && !fields()->is_shared()) {
+  if (fields() != nullptr && !fields()->is_shared()) {
     MetadataFactory::free_array<jushort>(loader_data, fields());
   }
-  set_fields(NULL, 0);
+  set_fields(nullptr, 0);
 
   // If a method from a redefined class is using this constant pool, don't
   // delete it, yet.  The new class's previous version will point to this.
-  if (constants() != NULL) {
+  if (constants() != nullptr) {
     assert (!constants()->on_stack(), "shouldn't be called if anything is onstack");
     if (!constants()->is_shared()) {
       MetadataFactory::free_metadata(loader_data, constants());
@@ -661,35 +661,35 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
     // Delete any cached resolution errors for the constant pool
     SystemDictionary::delete_resolution_error(constants());
 
-    set_constants(NULL);
+    set_constants(nullptr);
   }
 
-  if (inner_classes() != NULL &&
+  if (inner_classes() != nullptr &&
       inner_classes() != Universe::the_empty_short_array() &&
       !inner_classes()->is_shared()) {
     MetadataFactory::free_array<jushort>(loader_data, inner_classes());
   }
-  set_inner_classes(NULL);
+  set_inner_classes(nullptr);
 
-  if (nest_members() != NULL &&
+  if (nest_members() != nullptr &&
       nest_members() != Universe::the_empty_short_array() &&
       !nest_members()->is_shared()) {
     MetadataFactory::free_array<jushort>(loader_data, nest_members());
   }
-  set_nest_members(NULL);
+  set_nest_members(nullptr);
 
-  if (permitted_subclasses() != NULL &&
+  if (permitted_subclasses() != nullptr &&
       permitted_subclasses() != Universe::the_empty_short_array() &&
       !permitted_subclasses()->is_shared()) {
     MetadataFactory::free_array<jushort>(loader_data, permitted_subclasses());
   }
-  set_permitted_subclasses(NULL);
+  set_permitted_subclasses(nullptr);
 
   // We should deallocate the Annotations instance if it's not in shared spaces.
-  if (annotations() != NULL && !annotations()->is_shared()) {
+  if (annotations() != nullptr && !annotations()->is_shared()) {
     MetadataFactory::free_metadata(loader_data, annotations());
   }
-  set_annotations(NULL);
+  set_annotations(nullptr);
 
   SystemDictionaryShared::handle_class_unloading(this);
 
@@ -701,13 +701,13 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
 }
 
 bool InstanceKlass::is_record() const {
-  return _record_components != NULL &&
+  return _record_components != nullptr &&
          is_final() &&
          java_super() == vmClasses::Record_klass();
 }
 
 bool InstanceKlass::is_sealed() const {
-  return _permitted_subclasses != NULL &&
+  return _permitted_subclasses != nullptr &&
          _permitted_subclasses != Universe::the_empty_short_array();
 }
 
@@ -816,7 +816,7 @@ bool InstanceKlass::link_class_impl(TRAPS) {
 
   // link super class before linking this class
   Klass* super_klass = super();
-  if (super_klass != NULL) {
+  if (super_klass != nullptr) {
     if (super_klass->is_interface()) {  // check if super class is an interface
       ResourceMark rm(THREAD);
       Exceptions::fthrow(
@@ -1043,7 +1043,7 @@ void InstanceKlass::initialize_impl(TRAPS) {
       wait = true;
       jt->set_class_to_be_initialized(this);
       ml.wait();
-      jt->set_class_to_be_initialized(NULL);
+      jt->set_class_to_be_initialized(nullptr);
     }
 
     // Step 3
@@ -1090,7 +1090,7 @@ void InstanceKlass::initialize_impl(TRAPS) {
   // interfaces.
   if (!is_interface()) {
     Klass* super_klass = super();
-    if (super_klass != NULL && super_klass->should_be_initialized()) {
+    if (super_klass != nullptr && super_klass->should_be_initialized()) {
       super_klass->initialize(THREAD);
     }
     // If C implements any interface that declares a non-static, concrete method,
@@ -1121,7 +1121,7 @@ void InstanceKlass::initialize_impl(TRAPS) {
   // Step 8
   {
     DTRACE_CLASSINIT_PROBE_WAIT(clinit, -1, wait);
-    if (class_initializer() != NULL) {
+    if (class_initializer() != nullptr) {
       // Timer includes any side effects of class initialization (resolution,
       // etc), but not recursive entry into call_class_initializer().
       PerfClassTraceTime timer(ClassLoader::perf_class_init_time(),
@@ -1183,12 +1183,12 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, JavaTh
   if (state == linked && UseVtableBasedCHA && Universe::is_fully_initialized()) {
     MutexLocker ml(current, Compile_lock);
 
-    set_init_thread(NULL); // reset _init_thread before changing _init_state
+    set_init_thread(nullptr); // reset _init_thread before changing _init_state
     set_init_state(state);
 
     CodeCache::flush_dependents_on(this);
   } else {
-    set_init_thread(NULL); // reset _init_thread before changing _init_state
+    set_init_thread(nullptr); // reset _init_thread before changing _init_state
     set_init_state(state);
   }
   ml.notify_all();
@@ -1196,13 +1196,13 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, JavaTh
 
 InstanceKlass* InstanceKlass::implementor() const {
   InstanceKlass* volatile* ik = adr_implementor();
-  if (ik == NULL) {
-    return NULL;
+  if (ik == nullptr) {
+    return nullptr;
   } else {
     // This load races with inserts, and therefore needs acquire.
     InstanceKlass* ikls = Atomic::load_acquire(ik);
-    if (ikls != NULL && !ikls->is_loader_alive()) {
-      return NULL;  // don't return unloaded class
+    if (ikls != nullptr && !ikls->is_loader_alive()) {
+      return nullptr;  // don't return unloaded class
     } else {
       return ikls;
     }
@@ -1214,15 +1214,15 @@ void InstanceKlass::set_implementor(InstanceKlass* ik) {
   assert_locked_or_safepoint(Compile_lock);
   assert(is_interface(), "not interface");
   InstanceKlass* volatile* addr = adr_implementor();
-  assert(addr != NULL, "null addr");
-  if (addr != NULL) {
+  assert(addr != nullptr, "null addr");
+  if (addr != nullptr) {
     Atomic::release_store(addr, ik);
   }
 }
 
 int  InstanceKlass::nof_implementors() const {
   InstanceKlass* ik = implementor();
-  if (ik == NULL) {
+  if (ik == nullptr) {
     return 0;
   } else if (ik != this) {
     return 1;
@@ -1235,7 +1235,7 @@ int  InstanceKlass::nof_implementors() const {
 // When there are more than one implementors, the _implementor field
 // is set to the interface Klass* itself. Following are the possible
 // values for the _implementor field:
-//   NULL                  - no implementor
+//   null                  - no implementor
 //   implementor Klass*    - one implementor
 //   self                  - more than one implementor
 //
@@ -1253,14 +1253,14 @@ void InstanceKlass::add_implementor(InstanceKlass* ik) {
   // (Note: CHA must walk subclasses of direct implementors
   // in order to locate indirect implementors.)
   InstanceKlass* super_ik = ik->java_super();
-  if (super_ik != NULL && super_ik->implements_interface(this))
+  if (super_ik != nullptr && super_ik->implements_interface(this))
     // We only need to check one immediate superclass, since the
     // implements_interface query looks at transitive_interfaces.
     // Any supers of the super have the same (or fewer) transitive_interfaces.
     return;
 
   InstanceKlass* iklass = implementor();
-  if (iklass == NULL) {
+  if (iklass == nullptr) {
     set_implementor(ik);
   } else if (iklass != this && iklass != ik) {
     // There is already an implementor. Use itself as an indicator of
@@ -1276,7 +1276,7 @@ void InstanceKlass::add_implementor(InstanceKlass* ik) {
 
 void InstanceKlass::init_implementor() {
   if (is_interface()) {
-    set_implementor(NULL);
+    set_implementor(nullptr);
   }
 }
 
@@ -1306,7 +1306,7 @@ GrowableArray<Klass*>* InstanceKlass::compute_secondary_supers(int num_extra_slo
   if (num_secondaries == 0) {
     // Must share this for correct bootstrapping!
     set_secondary_supers(Universe::the_empty_klass_array());
-    return NULL;
+    return nullptr;
   } else if (num_extra_slots == 0) {
     // The secondary super list is exactly the same as the transitive interfaces, so
     // let's use it instead of making a copy.
@@ -1314,7 +1314,7 @@ GrowableArray<Klass*>* InstanceKlass::compute_secondary_supers(int num_extra_slo
     // We need the cast because Array<Klass*> is NOT a supertype of Array<InstanceKlass*>,
     // (but it's safe to do here because we won't write into _secondary_supers from this point on).
     set_secondary_supers((Array<Klass*>*)(address)interfaces);
-    return NULL;
+    return nullptr;
   } else {
     // Copy transitive interfaces to a temporary growable array to be constructed
     // into the secondary super list with extra slots.
@@ -1406,7 +1406,7 @@ void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) {
 
 Klass* InstanceKlass::array_klass(int n, TRAPS) {
   // Need load-acquire for lock-free read
-  if (array_klasses_acquire() == NULL) {
+  if (array_klasses_acquire() == nullptr) {
     ResourceMark rm(THREAD);
     JavaThread *jt = THREAD;
     {
@@ -1414,7 +1414,7 @@ Klass* InstanceKlass::array_klass(int n, TRAPS) {
       MutexLocker ma(THREAD, MultiArray_lock);
 
       // Check if update has already taken place
-      if (array_klasses() == NULL) {
+      if (array_klasses() == nullptr) {
         ObjArrayKlass* k = ObjArrayKlass::allocate_objArray_klass(class_loader_data(), 1, this, CHECK_NULL);
         // use 'release' to pair with lock-free load
         release_set_array_klasses(k);
@@ -1429,8 +1429,8 @@ Klass* InstanceKlass::array_klass(int n, TRAPS) {
 Klass* InstanceKlass::array_klass_or_null(int n) {
   // Need load-acquire for lock-free read
   ObjArrayKlass* oak = array_klasses_acquire();
-  if (oak == NULL) {
-    return NULL;
+  if (oak == nullptr) {
+    return nullptr;
   } else {
     return oak->array_klass_or_null(n);
   }
@@ -1449,16 +1449,16 @@ static int call_class_initializer_counter = 0;   // for debugging
 Method* InstanceKlass::class_initializer() const {
   Method* clinit = find_method(
       vmSymbols::class_initializer_name(), vmSymbols::void_method_signature());
-  if (clinit != NULL && clinit->has_valid_initializer_flags()) {
+  if (clinit != nullptr && clinit->has_valid_initializer_flags()) {
     return clinit;
   }
-  return NULL;
+  return nullptr;
 }
 
 void InstanceKlass::call_class_initializer(TRAPS) {
   if (ReplayCompiles &&
       (ReplaySuppressInitializers == 1 ||
-       (ReplaySuppressInitializers >= 2 && class_loader() != NULL))) {
+       (ReplaySuppressInitializers >= 2 && class_loader() != nullptr))) {
     // Hide the existence of the initializer for the purpose of replaying the compile
     return;
   }
@@ -1482,9 +1482,9 @@ void InstanceKlass::call_class_initializer(TRAPS) {
     LogStream ls(lt);
     ls.print("%d Initializing ", call_class_initializer_counter++);
     name()->print_value_on(&ls);
-    ls.print_cr("%s (" PTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this));
+    ls.print_cr("%s (" PTR_FORMAT ")", h_method() == nullptr ? "(no method)" : "", p2i(this));
   }
-  if (h_method() != NULL) {
+  if (h_method() != nullptr) {
     JavaCallArguments args; // No arguments
     JavaValue result(T_VOID);
     JavaCalls::call(&result, h_method, &args, CHECK); // Static call (no args)
@@ -1497,10 +1497,10 @@ void InstanceKlass::mask_for(const methodHandle& method, int bci,
   // Lazily create the _oop_map_cache at first request
   // Lock-free access requires load_acquire.
   OopMapCache* oop_map_cache = Atomic::load_acquire(&_oop_map_cache);
-  if (oop_map_cache == NULL) {
+  if (oop_map_cache == nullptr) {
     MutexLocker x(OopMapCacheAlloc_lock);
     // Check if _oop_map_cache was allocated while we were waiting for this lock
-    if ((oop_map_cache = _oop_map_cache) == NULL) {
+    if ((oop_map_cache = _oop_map_cache) == nullptr) {
       oop_map_cache = new OopMapCache();
       // Ensure _oop_map_cache is stable, since it is examined without a lock
       Atomic::release_store(&_oop_map_cache, oop_map_cache);
@@ -1540,10 +1540,10 @@ Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescr
     }
     // search for field in direct superinterfaces
     Klass* intf2 = InstanceKlass::cast(intf1)->find_interface_field(name, sig, fd);
-    if (intf2 != NULL) return intf2;
+    if (intf2 != nullptr) return intf2;
   }
   // otherwise field lookup fails
-  return NULL;
+  return nullptr;
 }
 
 
@@ -1555,14 +1555,14 @@ Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd)
   }
   // 2) search for field recursively in direct superinterfaces
   { Klass* intf = find_interface_field(name, sig, fd);
-    if (intf != NULL) return intf;
+    if (intf != nullptr) return intf;
   }
   // 3) apply field lookup recursively if superclass exists
   { Klass* supr = super();
-    if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, fd);
+    if (supr != nullptr) return InstanceKlass::cast(supr)->find_field(name, sig, fd);
   }
   // 4) otherwise field lookup fails
-  return NULL;
+  return nullptr;
 }
 
 
@@ -1575,14 +1575,14 @@ Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, bool is_static, fiel
   // 2) search for field recursively in direct superinterfaces
   if (is_static) {
     Klass* intf = find_interface_field(name, sig, fd);
-    if (intf != NULL) return intf;
+    if (intf != nullptr) return intf;
   }
   // 3) apply field lookup recursively if superclass exists
   { Klass* supr = super();
-    if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, is_static, fd);
+    if (supr != nullptr) return InstanceKlass::cast(supr)->find_field(name, sig, is_static, fd);
   }
   // 4) otherwise field lookup fails
-  return NULL;
+  return nullptr;
 }
 
 
@@ -1599,7 +1599,7 @@ bool InstanceKlass::find_local_field_from_offset(int offset, bool is_static, fie
 
 bool InstanceKlass::find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const {
   Klass* klass = const_cast<InstanceKlass*>(this);
-  while (klass != NULL) {
+  while (klass != nullptr) {
     if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) {
       return true;
     }
@@ -1647,7 +1647,7 @@ void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAP
 
 void InstanceKlass::do_nonstatic_fields(FieldClosure* cl) {
   InstanceKlass* super = superklass();
-  if (super != NULL) {
+  if (super != nullptr) {
     super->do_nonstatic_fields(cl);
   }
   fieldDescriptor fd;
@@ -1667,7 +1667,7 @@ static int compare_fields_by_offset(Pair<int,int>* a, Pair<int,int>* b) {
 
 void InstanceKlass::print_nonstatic_fields(FieldClosure* cl) {
   InstanceKlass* super = superklass();
-  if (super != NULL) {
+  if (super != nullptr) {
     super->print_nonstatic_fields(cl);
   }
   ResourceMark rm;
@@ -1793,7 +1793,7 @@ Method* InstanceKlass::find_instance_method(const Array<Method*>* methods,
                                                  OverpassLookupMode::find,
                                                  StaticLookupMode::skip,
                                                  private_mode);
-  assert(((meth == NULL) || !meth->is_static()),
+  assert(((meth == nullptr) || !meth->is_static()),
     "find_instance_method should have skipped statics");
   return meth;
 }
@@ -1861,7 +1861,7 @@ Method* InstanceKlass::find_method_impl(const Array<Method*>* methods,
                                         StaticLookupMode static_mode,
                                         PrivateLookupMode private_mode) {
   int hit = find_method_index(methods, name, signature, overpass_mode, static_mode, private_mode);
-  return hit >= 0 ? methods->at(hit): NULL;
+  return hit >= 0 ? methods->at(hit): nullptr;
 }
 
 // true if method matches signature and conforms to skipping_X conditions.
@@ -1947,7 +1947,7 @@ int InstanceKlass::find_method_by_name(const Symbol* name, int* end) const {
 int InstanceKlass::find_method_by_name(const Array<Method*>* methods,
                                        const Symbol* name,
                                        int* end_ptr) {
-  assert(end_ptr != NULL, "just checking");
+  assert(end_ptr != nullptr, "just checking");
   int start = quick_search(methods, name);
   int end = start + 1;
   if (start != -1) {
@@ -1968,19 +1968,19 @@ Method* InstanceKlass::uncached_lookup_method(const Symbol* name,
                                               PrivateLookupMode private_mode) const {
   OverpassLookupMode overpass_local_mode = overpass_mode;
   const Klass* klass = this;
-  while (klass != NULL) {
+  while (klass != nullptr) {
     Method* const method = InstanceKlass::cast(klass)->find_method_impl(name,
                                                                         signature,
                                                                         overpass_local_mode,
                                                                         StaticLookupMode::find,
                                                                         private_mode);
-    if (method != NULL) {
+    if (method != nullptr) {
       return method;
     }
     klass = klass->super();
     overpass_local_mode = OverpassLookupMode::skip;   // Always ignore overpass methods in superclasses
   }
-  return NULL;
+  return nullptr;
 }
 
 #ifdef ASSERT
@@ -1988,7 +1988,7 @@ Method* InstanceKlass::uncached_lookup_method(const Symbol* name,
 // one of the superclasses was redefined
 bool InstanceKlass::has_redefined_this_or_super() const {
   const Klass* klass = this;
-  while (klass != NULL) {
+  while (klass != nullptr) {
     if (InstanceKlass::cast(klass)->has_been_redefined()) {
       return true;
     }
@@ -2002,12 +2002,12 @@ bool InstanceKlass::has_redefined_this_or_super() const {
 // Do NOT return private or static methods
 Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
                                                          Symbol* signature) const {
-  Method* m = NULL;
-  if (default_methods() != NULL) {
+  Method* m = nullptr;
+  if (default_methods() != nullptr) {
     m = find_method(default_methods(), name, signature);
   }
   // Look up interfaces
-  if (m == NULL) {
+  if (m == nullptr) {
     m = lookup_method_in_all_interfaces(name, signature, DefaultsLookupMode::find);
   }
   return m;
@@ -2021,16 +2021,16 @@ Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
                                                        DefaultsLookupMode defaults_mode) const {
   Array<InstanceKlass*>* all_ifs = transitive_interfaces();
   int num_ifs = all_ifs->length();
-  InstanceKlass *ik = NULL;
+  InstanceKlass *ik = nullptr;
   for (int i = 0; i < num_ifs; i++) {
     ik = all_ifs->at(i);
     Method* m = ik->lookup_method(name, signature);
-    if (m != NULL && m->is_public() && !m->is_static() &&
+    if (m != nullptr && m->is_public() && !m->is_static() &&
         ((defaults_mode != DefaultsLookupMode::skip) || !m->is_default_method())) {
       return m;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 PrintClassClosure::PrintClassClosure(outputStream* st, bool verbose)
@@ -2082,8 +2082,8 @@ void PrintClassClosure::do_klass(Klass* k)  {
 /* jni_id_for for jfieldIds only */
 JNIid* InstanceKlass::jni_id_for(int offset) {
   MutexLocker ml(JfieldIdCreation_lock);
-  JNIid* probe = jni_ids() == NULL ? NULL : jni_ids()->find(offset);
-  if (probe == NULL) {
+  JNIid* probe = jni_ids() == nullptr ? nullptr : jni_ids()->find(offset);
+  if (probe == nullptr) {
     // Allocate new static field identifier
     probe = new JNIid(this, offset, jni_ids());
     set_jni_ids(probe);
@@ -2093,7 +2093,7 @@ JNIid* InstanceKlass::jni_id_for(int offset) {
 
 u2 InstanceKlass::enclosing_method_data(int offset) const {
   const Array<jushort>* const inner_class_list = inner_classes();
-  if (inner_class_list == NULL) {
+  if (inner_class_list == nullptr) {
     return 0;
   }
   const int length = inner_class_list->length();
@@ -2108,7 +2108,7 @@ u2 InstanceKlass::enclosing_method_data(int offset) const {
 void InstanceKlass::set_enclosing_method_indices(u2 class_index,
                                                  u2 method_index) {
   Array<jushort>* inner_class_list = inner_classes();
-  assert (inner_class_list != NULL, "_inner_classes list is not set up");
+  assert (inner_class_list != nullptr, "_inner_classes list is not set up");
   int length = inner_class_list->length();
   if (length % inner_class_next_offset == enclosing_method_attribute_size) {
     int index = length - enclosing_method_attribute_size;
@@ -2128,11 +2128,11 @@ jmethodID InstanceKlass::get_jmethod_id(const methodHandle& method_h) {
   size_t idnum = (size_t)method_h->method_idnum();
   jmethodID* jmeths = methods_jmethod_ids_acquire();
   size_t length = 0;
-  jmethodID id = NULL;
+  jmethodID id = nullptr;
 
   // We use a double-check locking idiom here because this cache is
   // performance sensitive. In the normal system, this cache only
-  // transitions from NULL to non-NULL which is safe because we use
+  // transitions from null to non-null which is safe because we use
   // release_set_methods_jmethod_ids() to advertise the new cache.
   // A partially constructed cache should never be seen by a racing
   // thread. We also use release_store() to save a new jmethodID
@@ -2143,12 +2143,12 @@ jmethodID InstanceKlass::get_jmethod_id(const methodHandle& method_h) {
   // generally acquired in those two cases.
   //
   // If the RedefineClasses() API has been used, then this cache can
-  // grow and we'll have transitions from non-NULL to bigger non-NULL.
+  // grow and we'll have transitions from non-null to bigger non-null.
   // Cache creation requires no leaks and we require safety between all
   // cache accesses and freeing of the old cache so a lock is generally
   // acquired when the RedefineClasses() API has been used.
 
-  if (jmeths != NULL) {
+  if (jmeths != nullptr) {
     // the cache already exists
     if (!idnum_can_increment()) {
       // the cache can't grow so we can just get the current values
@@ -2161,20 +2161,20 @@ jmethodID InstanceKlass::get_jmethod_id(const methodHandle& method_h) {
   // implied else:
   // we need to allocate a cache so default length and id values are good
 
-  if (jmeths == NULL ||   // no cache yet
-      length <= idnum ||  // cache is too short
-      id == NULL) {       // cache doesn't contain entry
+  if (jmeths == nullptr ||   // no cache yet
+      length <= idnum ||     // cache is too short
+      id == nullptr) {       // cache doesn't contain entry
 
     // This function can be called by the VMThread or GC worker threads so we
     // have to do all things that might block on a safepoint before grabbing the lock.
     // Otherwise, we can deadlock with the VMThread or have a cache
     // consistency issue. These vars keep track of what we might have
     // to free after the lock is dropped.
-    jmethodID  to_dealloc_id     = NULL;
-    jmethodID* to_dealloc_jmeths = NULL;
+    jmethodID  to_dealloc_id     = nullptr;
+    jmethodID* to_dealloc_jmeths = nullptr;
 
     // may not allocate new_jmeths or use it if we allocate it
-    jmethodID* new_jmeths = NULL;
+    jmethodID* new_jmeths = nullptr;
     if (length <= idnum) {
       // allocate a new cache that might be used
       size_t size = MAX2(idnum+1, (size_t)idnum_allocated_count());
@@ -2187,11 +2187,11 @@ jmethodID InstanceKlass::get_jmethod_id(const methodHandle& method_h) {
     // allocate a new jmethodID that might be used
     {
       MutexLocker ml(JmethodIdCreation_lock, Mutex::_no_safepoint_check_flag);
-      jmethodID new_id = NULL;
+      jmethodID new_id = nullptr;
       if (method_h->is_old() && !method_h->is_obsolete()) {
         // The method passed in is old (but not obsolete), we need to use the current version
         Method* current_method = method_with_idnum((int)idnum);
-        assert(current_method != NULL, "old and but not obsolete, so should exist");
+        assert(current_method != nullptr, "old and but not obsolete, so should exist");
         new_id = Method::make_jmethod_id(class_loader_data(), current_method);
       } else {
         // It is the current version of the method or an obsolete method,
@@ -2205,11 +2205,11 @@ jmethodID InstanceKlass::get_jmethod_id(const methodHandle& method_h) {
 
     // The lock has been dropped so we can free resources.
     // Free up either the old cache or the new cache if we allocated one.
-    if (to_dealloc_jmeths != NULL) {
+    if (to_dealloc_jmeths != nullptr) {
       FreeHeap(to_dealloc_jmeths);
     }
     // free up the new ID since it wasn't needed
-    if (to_dealloc_id != NULL) {
+    if (to_dealloc_id != nullptr) {
       Method::destroy_jmethod_id(class_loader_data(), to_dealloc_id);
     }
   }
@@ -2227,7 +2227,7 @@ void InstanceKlass::ensure_space_for_methodids(int start_offset) {
   for (int index = start_offset; index < length; index++) {
     Method* m = methods()->at(index);
     jmethodID id = m->find_jmethod_id_or_null();
-    if (id == NULL) {
+    if (id == nullptr) {
       new_jmeths++;
     }
   }
@@ -2245,19 +2245,19 @@ jmethodID InstanceKlass::get_jmethod_id_fetch_or_update(
             size_t idnum, jmethodID new_id,
             jmethodID* new_jmeths, jmethodID* to_dealloc_id_p,
             jmethodID** to_dealloc_jmeths_p) {
-  assert(new_id != NULL, "sanity check");
-  assert(to_dealloc_id_p != NULL, "sanity check");
-  assert(to_dealloc_jmeths_p != NULL, "sanity check");
+  assert(new_id != nullptr, "sanity check");
+  assert(to_dealloc_id_p != nullptr, "sanity check");
+  assert(to_dealloc_jmeths_p != nullptr, "sanity check");
   assert(JmethodIdCreation_lock->owned_by_self(), "sanity check");
 
   // reacquire the cache - we are locked, single threaded or at a safepoint
   jmethodID* jmeths = methods_jmethod_ids_acquire();
-  jmethodID  id     = NULL;
+  jmethodID  id     = nullptr;
   size_t     length = 0;
 
-  if (jmeths == NULL ||                         // no cache yet
+  if (jmeths == nullptr ||                      // no cache yet
       (length = (size_t)jmeths[0]) <= idnum) {  // cache is too short
-    if (jmeths != NULL) {
+    if (jmeths != nullptr) {
       // copy any existing entries from the old cache
       for (size_t index = 0; index < length; index++) {
         new_jmeths[index+1] = jmeths[index+1];
@@ -2270,7 +2270,7 @@ jmethodID InstanceKlass::get_jmethod_id_fetch_or_update(
     id = jmeths[idnum+1];
     *to_dealloc_jmeths_p = new_jmeths;  // save new cache for later delete
   }
-  if (id == NULL) {
+  if (id == nullptr) {
     // No matching jmethodID in the existing cache or we have a new
     // cache or we just grew the cache. This cache write is done here
     // by the first thread to win the foot race because a jmethodID
@@ -2293,29 +2293,29 @@ jmethodID InstanceKlass::get_jmethod_id_fetch_or_update(
 //
 void InstanceKlass::get_jmethod_id_length_value(jmethodID* cache,
        size_t idnum, size_t *length_p, jmethodID* id_p) {
-  assert(cache != NULL, "sanity check");
-  assert(length_p != NULL, "sanity check");
-  assert(id_p != NULL, "sanity check");
+  assert(cache != nullptr, "sanity check");
+  assert(length_p != nullptr, "sanity check");
+  assert(id_p != nullptr, "sanity check");
 
   // cache size is stored in element[0], other elements offset by one
   *length_p = (size_t)cache[0];
   if (*length_p <= idnum) {  // cache is too short
-    *id_p = NULL;
+    *id_p = nullptr;
   } else {
     *id_p = cache[idnum+1];  // fetch jmethodID (if any)
   }
 }
 
 
-// Lookup a jmethodID, NULL if not found.  Do no blocking, no allocations, no handles
+// Lookup a jmethodID, null if not found.  Do no blocking, no allocations, no handles
 jmethodID InstanceKlass::jmethod_id_or_null(Method* method) {
   size_t idnum = (size_t)method->method_idnum();
   jmethodID* jmeths = methods_jmethod_ids_acquire();
   size_t length;                                // length assigned as debugging crumb
-  jmethodID id = NULL;
-  if (jmeths != NULL &&                         // If there is a cache
+  jmethodID id = nullptr;
+  if (jmeths != nullptr &&                      // If there is a cache
       (length = (size_t)jmeths[0]) > idnum) {   // and if it is long enough,
-    id = jmeths[idnum+1];                       // Look up the id (may be NULL)
+    id = jmeths[idnum+1];                       // Look up the id (may be null)
   }
   return id;
 }
@@ -2359,10 +2359,10 @@ void InstanceKlass::clean_implementors_list() {
     for (;;) {
       // Use load_acquire due to competing with inserts
       InstanceKlass* impl = Atomic::load_acquire(adr_implementor());
-      if (impl != NULL && !impl->is_loader_alive()) {
-        // NULL this field, might be an unloaded instance klass or NULL
+      if (impl != nullptr && !impl->is_loader_alive()) {
+        // null this field, might be an unloaded instance klass or null
         InstanceKlass* volatile* iklass = adr_implementor();
-        if (Atomic::cmpxchg(iklass, impl, (InstanceKlass*)NULL) == impl) {
+        if (Atomic::cmpxchg(iklass, impl, (InstanceKlass*)nullptr) == impl) {
           // Successfully unlinking implementor.
           if (log_is_enabled(Trace, class, unload)) {
             ResourceMark rm;
@@ -2380,8 +2380,8 @@ void InstanceKlass::clean_implementors_list() {
 void InstanceKlass::clean_method_data() {
   for (int m = 0; m < methods()->length(); m++) {
     MethodData* mdo = methods()->at(m)->method_data();
-    if (mdo != NULL) {
-      MutexLocker ml(SafepointSynchronize::is_at_safepoint() ? NULL : mdo->extra_data_lock());
+    if (mdo != nullptr) {
+      MutexLocker ml(SafepointSynchronize::is_at_safepoint() ? nullptr : mdo->extra_data_lock());
       mdo->clean_method_data(/*always_clean*/false);
     }
   }
@@ -2427,7 +2427,7 @@ void InstanceKlass::metaspace_pointers_do(MetaspaceClosure* it) {
                          / itableOffsetEntry::size();
 
     for (int i = 0; i < nof_interfaces; i ++, ioe ++) {
-      if (ioe->interface_klass() != NULL) {
+      if (ioe->interface_klass() != nullptr) {
         it->push(ioe->interface_klass_addr());
         itableMethodEntry* ime = ioe->first_method_entry(this);
         int n = klassItable::method_count_for_interface(ioe->interface_klass());
@@ -2480,54 +2480,54 @@ void InstanceKlass::remove_unshareable_info() {
   }
 
   // do array classes also.
-  if (array_klasses() != NULL) {
+  if (array_klasses() != nullptr) {
     array_klasses()->remove_unshareable_info();
   }
 
-  // These are not allocated from metaspace. They are safe to set to NULL.
-  _source_debug_extension = NULL;
-  _dep_context = NULL;
-  _osr_nmethods_head = NULL;
+  // These are not allocated from metaspace. They are safe to set to null.
+  _source_debug_extension = nullptr;
+  _dep_context = nullptr;
+  _osr_nmethods_head = nullptr;
 #if INCLUDE_JVMTI
-  _breakpoints = NULL;
-  _previous_versions = NULL;
-  _cached_class_file = NULL;
-  _jvmti_cached_class_field_map = NULL;
+  _breakpoints = nullptr;
+  _previous_versions = nullptr;
+  _cached_class_file = nullptr;
+  _jvmti_cached_class_field_map = nullptr;
 #endif
 
-  _init_thread = NULL;
-  _methods_jmethod_ids = NULL;
-  _jni_ids = NULL;
-  _oop_map_cache = NULL;
+  _init_thread = nullptr;
+  _methods_jmethod_ids = nullptr;
+  _jni_ids = nullptr;
+  _oop_map_cache = nullptr;
   // clear _nest_host to ensure re-load at runtime
-  _nest_host = NULL;
+  _nest_host = nullptr;
   init_shared_package_entry();
   _dep_context_last_cleaned = 0;
-  _init_monitor = NULL;
+  _init_monitor = nullptr;
 }
 
 void InstanceKlass::remove_java_mirror() {
   Klass::remove_java_mirror();
 
   // do array classes also.
-  if (array_klasses() != NULL) {
+  if (array_klasses() != nullptr) {
     array_klasses()->remove_java_mirror();
   }
 }
 
 void InstanceKlass::init_shared_package_entry() {
 #if !INCLUDE_CDS_JAVA_HEAP
-  _package_entry = NULL;
+  _package_entry = nullptr;
 #else
   if (!MetaspaceShared::use_full_module_graph()) {
-    _package_entry = NULL;
+    _package_entry = nullptr;
   } else if (DynamicDumpSharedSpaces) {
     if (!MetaspaceShared::is_in_shared_metaspace(_package_entry)) {
-      _package_entry = NULL;
+      _package_entry = nullptr;
     }
   } else {
     if (is_shared_unregistered_class()) {
-      _package_entry = NULL;
+      _package_entry = nullptr;
     } else {
       _package_entry = PackageEntry::get_archived_entry(_package_entry);
     }
@@ -2570,7 +2570,7 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl
   // restore constant pool resolved references
   constants()->restore_unshareable_info(CHECK);
 
-  if (array_klasses() != NULL) {
+  if (array_klasses() != nullptr) {
     // To get a consistent list of classes we need MultiArray_lock to ensure
     // array classes aren't observed while they are being restored.
      MutexLocker ml(MultiArray_lock);
@@ -2602,7 +2602,7 @@ bool InstanceKlass::can_be_verified_at_dumptime() const {
   if (major_version() < 50 /*JAVA_6_VERSION*/) {
     return false;
   }
-  if (java_super() != NULL && !java_super()->can_be_verified_at_dumptime()) {
+  if (java_super() != nullptr && !java_super()->can_be_verified_at_dumptime()) {
     return false;
   }
   Array<InstanceKlass*>* interfaces = local_interfaces();
@@ -2644,7 +2644,7 @@ void InstanceKlass::unload_class(InstanceKlass* ik) {
   Events::log_class_unloading(Thread::current(), ik);
 
 #if INCLUDE_JFR
-  assert(ik != NULL, "invariant");
+  assert(ik != nullptr, "invariant");
   EventClassUnload event;
   event.set_unloadedClass(ik);
   event.set_definingClassLoader(ik->class_loader_data());
@@ -2670,22 +2670,22 @@ void InstanceKlass::release_C_heap_structures(bool release_sub_metadata) {
   delete _init_monitor;
 
   // Deallocate oop map cache
-  if (_oop_map_cache != NULL) {
+  if (_oop_map_cache != nullptr) {
     delete _oop_map_cache;
-    _oop_map_cache = NULL;
+    _oop_map_cache = nullptr;
   }
 
   // Deallocate JNI identifiers for jfieldIDs
   JNIid::deallocate(jni_ids());
-  set_jni_ids(NULL);
+  set_jni_ids(nullptr);
 
   jmethodID* jmeths = methods_jmethod_ids_acquire();
-  if (jmeths != (jmethodID*)NULL) {
-    release_set_methods_jmethod_ids(NULL);
+  if (jmeths != (jmethodID*)nullptr) {
+    release_set_methods_jmethod_ids(nullptr);
     FreeHeap(jmeths);
   }
 
-  assert(_dep_context == NULL,
+  assert(_dep_context == nullptr,
          "dependencies should already be cleaned");
 
 #if INCLUDE_JVMTI
@@ -2696,9 +2696,9 @@ void InstanceKlass::release_C_heap_structures(bool release_sub_metadata) {
   }
 
   // deallocate the cached class file
-  if (_cached_class_file != NULL) {
+  if (_cached_class_file != nullptr) {
     os::free(_cached_class_file);
-    _cached_class_file = NULL;
+    _cached_class_file = nullptr;
   }
 #endif
 
@@ -2710,8 +2710,8 @@ void InstanceKlass::release_C_heap_structures(bool release_sub_metadata) {
 }
 
 void InstanceKlass::set_source_debug_extension(const char* array, int length) {
-  if (array == NULL) {
-    _source_debug_extension = NULL;
+  if (array == nullptr) {
+    _source_debug_extension = nullptr;
   } else {
     // Adding one to the attribute length in order to store a null terminator
     // character could cause an overflow because the attribute length is
@@ -2753,7 +2753,7 @@ const char* InstanceKlass::signature_name() const {
     }
   }
 
-  // Add the semicolon and the NULL
+  // Add the semicolon and the null
   dest[dest_index++] = JVM_SIGNATURE_ENDCLASS;
   dest[dest_index] = '\0';
   return dest;
@@ -2796,53 +2796,53 @@ void InstanceKlass::set_package(ClassLoaderData* loader_data, PackageEntry* pkg_
     check_prohibited_package(name(), loader_data, CHECK);
   }
 
-  if (is_shared() && _package_entry != NULL) {
+  if (is_shared() && _package_entry != nullptr) {
     if (MetaspaceShared::use_full_module_graph() && _package_entry == pkg_entry) {
       // we can use the saved package
       assert(MetaspaceShared::is_in_shared_metaspace(_package_entry), "must be");
       return;
     } else {
-      _package_entry = NULL;
+      _package_entry = nullptr;
     }
   }
 
   // ClassLoader::package_from_class_name has already incremented the refcount of the symbol
   // it returns, so we need to decrement it when the current function exits.
   TempNewSymbol from_class_name =
-      (pkg_entry != NULL) ? NULL : ClassLoader::package_from_class_name(name());
+      (pkg_entry != nullptr) ? nullptr : ClassLoader::package_from_class_name(name());
 
   Symbol* pkg_name;
-  if (pkg_entry != NULL) {
+  if (pkg_entry != nullptr) {
     pkg_name = pkg_entry->name();
   } else {
     pkg_name = from_class_name;
   }
 
-  if (pkg_name != NULL && loader_data != NULL) {
+  if (pkg_name != nullptr && loader_data != nullptr) {
 
     // Find in class loader's package entry table.
-    _package_entry = pkg_entry != NULL ? pkg_entry : loader_data->packages()->lookup_only(pkg_name);
+    _package_entry = pkg_entry != nullptr ? pkg_entry : loader_data->packages()->lookup_only(pkg_name);
 
     // If the package name is not found in the loader's package
     // entry table, it is an indication that the package has not
     // been defined. Consider it defined within the unnamed module.
-    if (_package_entry == NULL) {
+    if (_package_entry == nullptr) {
 
       if (!ModuleEntryTable::javabase_defined()) {
         // Before java.base is defined during bootstrapping, define all packages in
         // the java.base module.  If a non-java.base package is erroneously placed
         // in the java.base module it will be caught later when java.base
         // is defined by ModuleEntryTable::verify_javabase_packages check.
-        assert(ModuleEntryTable::javabase_moduleEntry() != NULL, JAVA_BASE_NAME " module is NULL");
+        assert(ModuleEntryTable::javabase_moduleEntry() != nullptr, JAVA_BASE_NAME " module is null");
         _package_entry = loader_data->packages()->create_entry_if_absent(pkg_name, ModuleEntryTable::javabase_moduleEntry());
       } else {
-        assert(loader_data->unnamed_module() != NULL, "unnamed module is NULL");
+        assert(loader_data->unnamed_module() != nullptr, "unnamed module is null");
         _package_entry = loader_data->packages()->create_entry_if_absent(pkg_name, loader_data->unnamed_module());
       }
 
       // A package should have been successfully created
       DEBUG_ONLY(ResourceMark rm(THREAD));
-      assert(_package_entry != NULL, "Package entry for class %s not found, loader %s",
+      assert(_package_entry != nullptr, "Package entry for class %s not found, loader %s",
              name()->as_C_string(), loader_data->loader_name_and_id());
     }
 
@@ -2859,7 +2859,7 @@ void InstanceKlass::set_package(ClassLoaderData* loader_data, PackageEntry* pkg_
     ResourceMark rm(THREAD);
     log_trace(module)("Setting package: class: %s, package: unnamed, loader: %s, module: %s",
                       external_name(),
-                      (loader_data != NULL) ? loader_data->loader_name_and_id() : "NULL",
+                      (loader_data != nullptr) ? loader_data->loader_name_and_id() : "null",
                       UNNAMED_MODULE);
   }
 }
@@ -2874,7 +2874,7 @@ void InstanceKlass::set_package(ClassLoaderData* loader_data, PackageEntry* pkg_
 // classes are loaded by the boot loader) that at least one of the package's
 // classes has been loaded.
 void InstanceKlass::set_classpath_index(s2 path_index) {
-  if (_package_entry != NULL) {
+  if (_package_entry != nullptr) {
     DEBUG_ONLY(PackageEntryTable* pkg_entry_tbl = ClassLoaderData::the_null_class_loader_data()->packages();)
     assert(pkg_entry_tbl->lookup_only(_package_entry->name()) == _package_entry, "Should be same");
     assert(path_index != -1, "Unexpected classpath_index");
@@ -2898,8 +2898,8 @@ bool InstanceKlass::is_same_class_package(const Klass* class2) const {
     classpkg2 = class2->package();
   } else {
     assert(class2->is_typeArray_klass(), "should be type array");
-    classloader2 = NULL;
-    classpkg2 = NULL;
+    classloader2 = nullptr;
+    classpkg2 = nullptr;
   }
 
   // Same package is determined by comparing class loader
@@ -2932,13 +2932,13 @@ bool InstanceKlass::is_same_class_package(oop other_class_loader,
     if (bad_class_name) {
       return false;
     }
-    // Check that package_from_class_name() returns NULL, not "", if there is no package.
-    assert(other_pkg == NULL || other_pkg->utf8_length() > 0, "package name is empty string");
+    // Check that package_from_class_name() returns null, not "", if there is no package.
+    assert(other_pkg == nullptr || other_pkg->utf8_length() > 0, "package name is empty string");
 
     const Symbol* const this_package_name =
-      this->package() != NULL ? this->package()->name() : NULL;
+      this->package() != nullptr ? this->package()->name() : nullptr;
 
-    if (this_package_name == NULL || other_pkg == NULL) {
+    if (this_package_name == nullptr || other_pkg == nullptr) {
       // One of the two doesn't have a package.  Only return true if the other
       // one also doesn't have a package.
       return this_package_name == other_pkg;
@@ -2967,7 +2967,7 @@ void InstanceKlass::check_prohibited_package(Symbol* class_name,
                                              TRAPS) {
   if (!loader_data->is_boot_class_loader_data() &&
       !loader_data->is_platform_class_loader_data() &&
-      class_name != NULL && class_name->utf8_length() >= 5) {
+      class_name != nullptr && class_name->utf8_length() >= 5) {
     ResourceMark rm(THREAD);
     bool prohibited;
     const u1* base = class_name->base();
@@ -2979,7 +2979,7 @@ void InstanceKlass::check_prohibited_package(Symbol* class_name,
     }
     if (prohibited) {
       TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name);
-      assert(pkg_name != NULL, "Error in parsing package name starting with 'java/'");
+      assert(pkg_name != nullptr, "Error in parsing package name starting with 'java/'");
       char* name = pkg_name->as_C_string();
       const char* class_loader_name = loader_data->loader_name_and_id();
       StringUtils::replace_no_expand(name, "/", ".");
@@ -3015,7 +3015,7 @@ bool InstanceKlass::find_inner_classes_attr(int* ooff, int* noff, TRAPS) const {
 }
 
 InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRAPS) const {
-  InstanceKlass* outer_klass = NULL;
+  InstanceKlass* outer_klass = nullptr;
   *inner_is_member = false;
   int ooff = 0, noff = 0;
   bool has_inner_classes_attr = find_inner_classes_attr(&ooff, &noff, THREAD);
@@ -3033,12 +3033,12 @@ InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRA
           "%s and %s disagree on InnerClasses attribute",
           ok->external_name(),
           external_name());
-        return NULL;
+        return nullptr;
       }
       outer_klass = InstanceKlass::cast(ok);
       *inner_is_member = true;
     }
-    if (NULL == outer_klass) {
+    if (nullptr == outer_klass) {
       // It may be a local class; try for that.
       int encl_method_class_idx = enclosing_method_class_index();
       if (encl_method_class_idx != 0) {
@@ -3050,7 +3050,7 @@ InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRA
   }
 
   // If no inner class attribute found for this class.
-  if (NULL == outer_klass) return NULL;
+  if (nullptr == outer_klass) return nullptr;
 
   // Throws an exception if outer klass has not declared k as an inner klass
   // We need evidence that each klass knows about the other, or else
@@ -3104,7 +3104,7 @@ Method* InstanceKlass::method_at_itable(InstanceKlass* holder, int index, TRAPS)
   bool implements_interface; // initialized by method_at_itable_or_null
   Method* m = method_at_itable_or_null(holder, index,
                                        implements_interface); // out parameter
-  if (m != NULL) {
+  if (m != nullptr) {
     assert(implements_interface, "sanity");
     return m;
   } else if (implements_interface) {
@@ -3139,7 +3139,7 @@ Method* InstanceKlass::method_at_itable_or_null(InstanceKlass* holder, int index
     }
   }
   implements_interface = false;
-  return NULL; // offset entry not found
+  return nullptr; // offset entry not found
 }
 
 int InstanceKlass::vtable_index_of_interface_method(Method* intf_method) {
@@ -3152,7 +3152,7 @@ int InstanceKlass::vtable_index_of_interface_method(Method* intf_method) {
   Symbol* signature = intf_method->signature();
 
   // First check in default method array
-  if (!intf_method->is_abstract() && default_methods() != NULL) {
+  if (!intf_method->is_abstract() && default_methods() != nullptr) {
     int index = find_method_index(default_methods(),
                                   name, signature,
                                   Klass::OverpassLookupMode::find,
@@ -3177,10 +3177,10 @@ int InstanceKlass::vtable_index_of_interface_method(Method* intf_method) {
 // Note: those in the vtable, should have been updated via adjust_method_entries
 void InstanceKlass::adjust_default_methods(bool* trace_name_printed) {
   // search the default_methods for uses of either obsolete or EMCP methods
-  if (default_methods() != NULL) {
+  if (default_methods() != nullptr) {
     for (int index = 0; index < default_methods()->length(); index ++) {
       Method* old_method = default_methods()->at(index);
-      if (old_method == NULL || !old_method->is_old()) {
+      if (old_method == nullptr || !old_method->is_old()) {
         continue; // skip uninteresting entries
       }
       assert(!old_method->is_deleted(), "default methods may not be deleted");
@@ -3209,7 +3209,7 @@ void InstanceKlass::add_osr_nmethod(nmethod* n) {
   assert_lock_strong(CompiledMethod_lock);
 #ifndef PRODUCT
   nmethod* prev = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), n->comp_level(), true);
-  assert(prev == NULL || !prev->is_in_use() COMPILER2_PRESENT(|| StressRecompilation),
+  assert(prev == nullptr || !prev->is_in_use() COMPILER2_PRESENT(|| StressRecompilation),
       "redundant OSR recompilation detected. memory leak in CodeCache!");
 #endif
   // only one compilation can be active
@@ -3222,7 +3222,7 @@ void InstanceKlass::add_osr_nmethod(nmethod* n) {
   // Get rid of the osr methods for the same bci that have lower levels.
   for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) {
     nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true);
-    if (inv != NULL && inv->is_in_use()) {
+    if (inv != nullptr && inv->is_in_use()) {
       inv->make_not_entrant();
     }
   }
@@ -3231,16 +3231,16 @@ void InstanceKlass::add_osr_nmethod(nmethod* n) {
 // Remove osr nmethod from the list. Return true if found and removed.
 bool InstanceKlass::remove_osr_nmethod(nmethod* n) {
   // This is a short non-blocking critical region, so the no safepoint check is ok.
-  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock
+  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? nullptr : CompiledMethod_lock
                  , Mutex::_no_safepoint_check_flag);
   assert(n->is_osr_method(), "wrong kind of nmethod");
-  nmethod* last = NULL;
+  nmethod* last = nullptr;
   nmethod* cur  = osr_nmethods_head();
   int max_level = CompLevel_none;  // Find the max comp level excluding n
   Method* m = n->method();
   // Search for match
   bool found = false;
-  while(cur != NULL && cur != n) {
+  while(cur != nullptr && cur != n) {
     if (m == cur->method()) {
       // Find max level before n
       max_level = MAX2(max_level, cur->comp_level());
@@ -3248,20 +3248,20 @@ bool InstanceKlass::remove_osr_nmethod(nmethod* n) {
     last = cur;
     cur = cur->osr_link();
   }
-  nmethod* next = NULL;
+  nmethod* next = nullptr;
   if (cur == n) {
     found = true;
     next = cur->osr_link();
-    if (last == NULL) {
+    if (last == nullptr) {
       // Remove first element
       set_osr_nmethods_head(next);
     } else {
       last->set_osr_link(next);
     }
   }
-  n->set_osr_link(NULL);
+  n->set_osr_link(nullptr);
   cur = next;
-  while (cur != NULL) {
+  while (cur != nullptr) {
     // Find max level after n
     if (m == cur->method()) {
       max_level = MAX2(max_level, cur->comp_level());
@@ -3273,11 +3273,11 @@ bool InstanceKlass::remove_osr_nmethod(nmethod* n) {
 }
 
 int InstanceKlass::mark_osr_nmethods(const Method* m) {
-  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock,
+  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? nullptr : CompiledMethod_lock,
                  Mutex::_no_safepoint_check_flag);
   nmethod* osr = osr_nmethods_head();
   int found = 0;
-  while (osr != NULL) {
+  while (osr != nullptr) {
     assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
     if (osr->method() == m) {
       osr->mark_for_deoptimization();
@@ -3289,11 +3289,11 @@ int InstanceKlass::mark_osr_nmethods(const Method* m) {
 }
 
 nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const {
-  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock,
+  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? nullptr : CompiledMethod_lock,
                  Mutex::_no_safepoint_check_flag);
   nmethod* osr = osr_nmethods_head();
-  nmethod* best = NULL;
-  while (osr != NULL) {
+  nmethod* best = nullptr;
+  while (osr != nullptr) {
     assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
     // There can be a time when a c1 osr method exists but we are waiting
     // for a c2 version. When c2 completes its osr nmethod we will trash
@@ -3309,7 +3309,7 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le
           return osr;
         }
       } else {
-        if (best == NULL || (osr->comp_level() > best->comp_level())) {
+        if (best == nullptr || (osr->comp_level() > best->comp_level())) {
           if (osr->comp_level() == CompilationPolicy::highest_compile_level()) {
             // Found the best possible - return it.
             return osr;
@@ -3321,11 +3321,11 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le
     osr = osr->osr_link();
   }
 
-  assert(match_level == false || best == NULL, "shouldn't pick up anything if match_level is set");
-  if (best != NULL && best->comp_level() >= comp_level) {
+  assert(match_level == false || best == nullptr, "shouldn't pick up anything if match_level is set");
+  if (best != nullptr && best->comp_level() >= comp_level) {
     return best;
   }
-  return NULL;
+  return nullptr;
 }
 
 // -----------------------------------------------------------------------------------------------------
@@ -3354,7 +3354,7 @@ static void print_vtable(vtableEntry* start, int len, outputStream* st) {
 }
 
 const char* InstanceKlass::init_state_name() const {
-  return state_names[_init_state];
+  return state_names[init_state()];
 }
 
 void InstanceKlass::print_on(outputStream* st) const {
@@ -3370,7 +3370,7 @@ void InstanceKlass::print_on(outputStream* st) const {
   st->print(BULLET"sub:               ");
   Klass* sub = subklass();
   int n;
-  for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) {
+  for (n = 0; sub != nullptr; n++, sub = sub->next_sibling()) {
     if (n < MaxSubklassPrintSize) {
       sub->print_value_on(st);
       st->print("   ");
@@ -3399,29 +3399,29 @@ void InstanceKlass::print_on(outputStream* st) const {
   }
   st->print(BULLET"method ordering:   "); method_ordering()->print_value_on(st);      st->cr();
   st->print(BULLET"default_methods:   "); default_methods()->print_value_on(st);      st->cr();
-  if (Verbose && default_methods() != NULL) {
+  if (Verbose && default_methods() != nullptr) {
     Array<Method*>* method_array = default_methods();
     for (int i = 0; i < method_array->length(); i++) {
       st->print("%d : ", i); method_array->at(i)->print_value(); st->cr();
     }
   }
-  if (default_vtable_indices() != NULL) {
+  if (default_vtable_indices() != nullptr) {
     st->print(BULLET"default vtable indices:   "); default_vtable_indices()->print_value_on(st);       st->cr();
   }
   st->print(BULLET"local interfaces:  "); local_interfaces()->print_value_on(st);      st->cr();
   st->print(BULLET"trans. interfaces: "); transitive_interfaces()->print_value_on(st); st->cr();
   st->print(BULLET"constants:         "); constants()->print_value_on(st);         st->cr();
-  if (class_loader_data() != NULL) {
+  if (class_loader_data() != nullptr) {
     st->print(BULLET"class loader data:  ");
     class_loader_data()->print_value_on(st);
     st->cr();
   }
-  if (source_file_name() != NULL) {
+  if (source_file_name() != nullptr) {
     st->print(BULLET"source file:       ");
     source_file_name()->print_value_on(st);
     st->cr();
   }
-  if (source_debug_extension() != NULL) {
+  if (source_debug_extension() != nullptr) {
     st->print(BULLET"source debug extension:       ");
     st->print("%s", source_debug_extension());
     st->cr();
@@ -3434,7 +3434,7 @@ void InstanceKlass::print_on(outputStream* st) const {
     bool have_pv = false;
     // previous versions are linked together through the InstanceKlass
     for (InstanceKlass* pv_node = previous_versions();
-         pv_node != NULL;
+         pv_node != nullptr;
          pv_node = pv_node->previous_versions()) {
       if (!have_pv)
         st->print(BULLET"previous version:  ");
@@ -3444,23 +3444,23 @@ void InstanceKlass::print_on(outputStream* st) const {
     if (have_pv) st->cr();
   }
 
-  if (generic_signature() != NULL) {
+  if (generic_signature() != nullptr) {
     st->print(BULLET"generic signature: ");
     generic_signature()->print_value_on(st);
     st->cr();
   }
   st->print(BULLET"inner classes:     "); inner_classes()->print_value_on(st);     st->cr();
   st->print(BULLET"nest members:     "); nest_members()->print_value_on(st);     st->cr();
-  if (record_components() != NULL) {
+  if (record_components() != nullptr) {
     st->print(BULLET"record components:     "); record_components()->print_value_on(st);     st->cr();
   }
   st->print(BULLET"permitted subclasses:     "); permitted_subclasses()->print_value_on(st);     st->cr();
-  if (java_mirror() != NULL) {
+  if (java_mirror() != nullptr) {
     st->print(BULLET"java mirror:       ");
     java_mirror()->print_value_on(st);
     st->cr();
   } else {
-    st->print_cr(BULLET"java mirror:       NULL");
+    st->print_cr(BULLET"java mirror:       null");
   }
   st->print(BULLET"vtable length      %d  (start addr: " PTR_FORMAT ")", vtable_length(), p2i(start_of_vtable())); st->cr();
   if (vtable_length() > 0 && (Verbose || WizardMode))  print_vtable(start_of_vtable(), vtable_length(), st);
@@ -3492,7 +3492,7 @@ void InstanceKlass::print_value_on(outputStream* st) const {
 
 void FieldPrinter::do_field(fieldDescriptor* fd) {
   _st->print(BULLET);
-   if (_obj == NULL) {
+   if (_obj == nullptr) {
      fd->print_on(_st);
      _st->cr();
    } else {
@@ -3508,7 +3508,7 @@ void InstanceKlass::oop_print_on(oop obj, outputStream* st) {
   if (this == vmClasses::String_klass()) {
     typeArrayOop value  = java_lang_String::value(obj);
     juint        length = java_lang_String::length(obj);
-    if (value != NULL &&
+    if (value != nullptr &&
         value->is_typeArray() &&
         length <= (juint) value->length()) {
       st->print(BULLET"string: ");
@@ -3526,7 +3526,7 @@ void InstanceKlass::oop_print_on(oop obj, outputStream* st) {
     java_lang_Class::print_signature(obj, st);
     st->cr();
     Klass* real_klass = java_lang_Class::as_Klass(obj);
-    if (real_klass != NULL && real_klass->is_instance_klass()) {
+    if (real_klass != nullptr && real_klass->is_instance_klass()) {
       st->print_cr(BULLET"---- static fields (%d):", java_lang_Class::static_oop_field_count(obj));
       InstanceKlass::cast(real_klass)->do_local_static_fields(&print_field);
     }
@@ -3552,7 +3552,7 @@ void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) {
   name()->print_value_on(st);
   obj->print_address_on(st);
   if (this == vmClasses::String_klass()
-      && java_lang_String::value(obj) != NULL) {
+      && java_lang_String::value(obj) != nullptr) {
     ResourceMark rm;
     int len = java_lang_String::length(obj);
     int plen = (len < 24 ? len : 12);
@@ -3563,7 +3563,7 @@ void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) {
   } else if (this == vmClasses::Class_klass()) {
     Klass* k = java_lang_Class::as_Klass(obj);
     st->print(" = ");
-    if (k != NULL) {
+    if (k != nullptr) {
       k->print_value_on(st);
     } else {
       const char* tname = type2name(java_lang_Class::primitive_type(obj));
@@ -3577,28 +3577,28 @@ void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) {
     java_lang_boxing_object::print(obj, st);
   } else if (this == vmClasses::LambdaForm_klass()) {
     oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj);
-    if (vmentry != NULL) {
+    if (vmentry != nullptr) {
       st->print(" => ");
       vmentry->print_value_on(st);
     }
   } else if (this == vmClasses::MemberName_klass()) {
     Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj);
-    if (vmtarget != NULL) {
+    if (vmtarget != nullptr) {
       st->print(" = ");
       vmtarget->print_value_on(st);
     } else {
       oop clazz = java_lang_invoke_MemberName::clazz(obj);
       oop name  = java_lang_invoke_MemberName::name(obj);
-      if (clazz != NULL) {
+      if (clazz != nullptr) {
         clazz->print_value_on(st);
       } else {
-        st->print("NULL");
+        st->print("null");
       }
       st->print(".");
-      if (name != NULL) {
+      if (name != nullptr) {
         name->print_value_on(st);
       } else {
-        st->print("NULL");
+        st->print("null");
       }
     }
   }
@@ -3627,10 +3627,10 @@ void InstanceKlass::print_class_load_logging(ClassLoaderData* loader_data,
   info_stream.print("%s", external_name());
 
   // Source
-  if (cfs != NULL) {
-    if (cfs->source() != NULL) {
-      const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string();
-      if (module_name != NULL) {
+  if (cfs != nullptr) {
+    if (cfs->source() != nullptr) {
+      const char* module_name = (module_entry->name() == nullptr) ? UNNAMED_MODULE : module_entry->name()->as_C_string();
+      if (module_name != nullptr) {
         // When the boot loader created the stream, it didn't know the module name
         // yet. Let's format it now.
         if (cfs->from_boot_loader_modules_image()) {
@@ -3645,9 +3645,9 @@ void InstanceKlass::print_class_load_logging(ClassLoaderData* loader_data,
       Thread* current = Thread::current();
       Klass* caller = current->is_Java_thread() ?
         JavaThread::cast(current)->security_get_caller_class(1):
-        NULL;
-      // caller can be NULL, for example, during a JVMTI VM_Init hook
-      if (caller != NULL) {
+        nullptr;
+      // caller can be null, for example, during a JVMTI VM_Init hook
+      if (caller != nullptr) {
         info_stream.print(" source: instance of %s", caller->external_name());
       } else {
         // source is unknown
@@ -3675,7 +3675,7 @@ void InstanceKlass::print_class_load_logging(ClassLoaderData* loader_data,
                        p2i(this),  p2i(superklass()));
 
     // Interfaces
-    if (local_interfaces() != NULL && local_interfaces()->length() > 0) {
+    if (local_interfaces() != nullptr && local_interfaces()->length() > 0) {
       debug_stream.print(" interfaces:");
       int length = local_interfaces()->length();
       for (int i = 0; i < length; i++) {
@@ -3740,14 +3740,14 @@ void InstanceKlass::verify_on(outputStream* st) {
   }
 
   // Verify first subklass
-  if (subklass() != NULL) {
+  if (subklass() != nullptr) {
     guarantee(subklass()->is_klass(), "should be klass");
   }
 
   // Verify siblings
   Klass* super = this->super();
   Klass* sib = next_sibling();
-  if (sib != NULL) {
+  if (sib != nullptr) {
     if (sib == this) {
       fatal("subclass points to itself " PTR_FORMAT, p2i(sib));
     }
@@ -3766,7 +3766,7 @@ void InstanceKlass::verify_on(outputStream* st) {
   }
 
   // Verify transitive interfaces
-  if (transitive_interfaces() != NULL) {
+  if (transitive_interfaces() != nullptr) {
     Array<InstanceKlass*>* transitive_interfaces = this->transitive_interfaces();
     for (int j = 0; j < transitive_interfaces->length(); j++) {
       InstanceKlass* e = transitive_interfaces->at(j);
@@ -3775,7 +3775,7 @@ void InstanceKlass::verify_on(outputStream* st) {
   }
 
   // Verify methods
-  if (methods() != NULL) {
+  if (methods() != nullptr) {
     Array<Method*>* methods = this->methods();
     for (int j = 0; j < methods->length(); j++) {
       guarantee(methods->at(j)->is_method(), "non-method in methods array");
@@ -3788,7 +3788,7 @@ void InstanceKlass::verify_on(outputStream* st) {
   }
 
   // Verify method ordering
-  if (method_ordering() != NULL) {
+  if (method_ordering() != nullptr) {
     Array<int>* method_ordering = this->method_ordering();
     int length = method_ordering->length();
     if (JvmtiExport::can_maintain_original_method_order() ||
@@ -3809,7 +3809,7 @@ void InstanceKlass::verify_on(outputStream* st) {
   }
 
   // Verify default methods
-  if (default_methods() != NULL) {
+  if (default_methods() != nullptr) {
     Array<Method*>* methods = this->default_methods();
     for (int j = 0; j < methods->length(); j++) {
       guarantee(methods->at(j)->is_method(), "non-method in methods array");
@@ -3822,12 +3822,12 @@ void InstanceKlass::verify_on(outputStream* st) {
   }
 
   // Verify JNI static field identifiers
-  if (jni_ids() != NULL) {
+  if (jni_ids() != nullptr) {
     jni_ids()->verify(this);
   }
 
   // Verify other fields
-  if (constants() != NULL) {
+  if (constants() != nullptr) {
     guarantee(constants()->is_constantPool(), "should be constant pool");
   }
 }
@@ -3853,15 +3853,15 @@ JNIid::JNIid(Klass* holder, int offset, JNIid* next) {
 
 JNIid* JNIid::find(int offset) {
   JNIid* current = this;
-  while (current != NULL) {
+  while (current != nullptr) {
     if (current->offset() == offset) return current;
     current = current->next();
   }
-  return NULL;
+  return nullptr;
 }
 
 void JNIid::deallocate(JNIid* current) {
-  while (current != NULL) {
+  while (current != nullptr) {
     JNIid* next = current->next();
     delete current;
     current = next;
@@ -3875,7 +3875,7 @@ void JNIid::verify(Klass* holder) {
   end_field_offset = first_field_offset + (InstanceKlass::cast(holder)->static_field_size() * wordSize);
 
   JNIid* current = this;
-  while (current != NULL) {
+  while (current != nullptr) {
     guarantee(current->holder() == holder, "Invalid klass in JNIid");
 #ifdef ASSERT
     int o = current->offset();
@@ -3897,8 +3897,8 @@ void InstanceKlass::set_init_state(ClassState state) {
   bool link_failed = _init_state == being_linked && state == loaded;
   assert(good_state || state == allocated || link_failed, "illegal state transition");
 #endif
-  assert(_init_thread == NULL, "should be cleared before state change");
-  _init_state = state;
+  assert(_init_thread == nullptr, "should be cleared before state change");
+  Atomic::store(&_init_state, state);
 }
 
 #if INCLUDE_JVMTI
@@ -3930,7 +3930,7 @@ void InstanceKlass::purge_previous_version_list() {
   assert(has_been_redefined(), "Should only be called for main class");
 
   // Quick exit.
-  if (previous_versions() == NULL) {
+  if (previous_versions() == nullptr) {
     return;
   }
 
@@ -3940,7 +3940,7 @@ void InstanceKlass::purge_previous_version_list() {
   int deleted_count = 0;    // leave debugging breadcrumbs
   int live_count = 0;
   ClassLoaderData* loader_data = class_loader_data();
-  assert(loader_data != NULL, "should never be null");
+  assert(loader_data != nullptr, "should never be null");
 
   ResourceMark rm;
   log_trace(redefine, class, iklass, purge)("%s: previous versions", external_name());
@@ -3951,10 +3951,10 @@ void InstanceKlass::purge_previous_version_list() {
   int version = 0;
 
   // check the previous versions list
-  for (; pv_node != NULL; ) {
+  for (; pv_node != nullptr; ) {
 
     ConstantPool* pvcp = pv_node->constants();
-    assert(pvcp != NULL, "cp ref was unexpectedly cleared");
+    assert(pvcp != nullptr, "cp ref was unexpectedly cleared");
 
     if (!pvcp->on_stack()) {
       // If the constant pool isn't on stack, none of the methods
@@ -3966,7 +3966,7 @@ void InstanceKlass::purge_previous_version_list() {
       // Unlink from previous version list.
       assert(pv_node->class_loader_data() == loader_data, "wrong loader_data");
       InstanceKlass* next = pv_node->previous_versions();
-      pv_node->link_previous_versions(NULL);   // point next to NULL
+      pv_node->link_previous_versions(nullptr);   // point next to null
       last->link_previous_versions(next);
       // Delete this node directly. Nothing is referring to it and we don't
       // want it to increase the counter for metadata to delete in CLDG.
@@ -3977,7 +3977,7 @@ void InstanceKlass::purge_previous_version_list() {
       continue;
     } else {
       log_trace(redefine, class, iklass, purge)("previous version " PTR_FORMAT " is alive", p2i(pv_node));
-      assert(pvcp->pool_holder() != NULL, "Constant pool with no holder");
+      assert(pvcp->pool_holder() != nullptr, "Constant pool with no holder");
       guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack");
       live_count++;
       // found a previous version for next time we do class unloading
@@ -3998,7 +3998,7 @@ void InstanceKlass::mark_newly_obsolete_methods(Array<Method*>* old_methods,
   int obsolete_method_count = old_methods->length() - emcp_method_count;
 
   if (emcp_method_count != 0 && obsolete_method_count != 0 &&
-      _previous_versions != NULL) {
+      _previous_versions != nullptr) {
     // We have a mix of obsolete and EMCP methods so we have to
     // clear out any matching EMCP method entries the hard way.
     int local_count = 0;
@@ -4012,7 +4012,7 @@ void InstanceKlass::mark_newly_obsolete_methods(Array<Method*>* old_methods,
         // previous versions are linked together through the InstanceKlass
         int j = 0;
         for (InstanceKlass* prev_version = _previous_versions;
-             prev_version != NULL;
+             prev_version != nullptr;
              prev_version = prev_version->previous_versions(), j++) {
 
           Array<Method*>* method_refs = prev_version->methods();
@@ -4085,7 +4085,7 @@ void InstanceKlass::add_previous_version(InstanceKlass* scratch_class,
   // Set has_previous_version flag for processing during class unloading.
   _has_previous_versions = true;
   log_trace(redefine, class, iklass, add) ("scratch class added; one of its methods is on_stack.");
-  assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version");
+  assert(scratch_class->previous_versions() == nullptr, "shouldn't have a previous version");
   scratch_class->link_previous_versions(previous_versions());
   link_previous_versions(scratch_class);
 } // end add_previous_version()
@@ -4093,11 +4093,11 @@ void InstanceKlass::add_previous_version(InstanceKlass* scratch_class,
 #endif // INCLUDE_JVMTI
 
 Method* InstanceKlass::method_with_idnum(int idnum) {
-  Method* m = NULL;
+  Method* m = nullptr;
   if (idnum < methods()->length()) {
     m = methods()->at(idnum);
   }
-  if (m == NULL || m->method_idnum() != idnum) {
+  if (m == nullptr || m->method_idnum() != idnum) {
     for (int index = 0; index < methods()->length(); ++index) {
       m = methods()->at(index);
       if (m->method_idnum() == idnum) {
@@ -4105,7 +4105,7 @@ Method* InstanceKlass::method_with_idnum(int idnum) {
       }
     }
     // None found, return null for the caller to handle.
-    return NULL;
+    return nullptr;
   }
   return m;
 }
@@ -4113,10 +4113,10 @@ Method* InstanceKlass::method_with_idnum(int idnum) {
 
 Method* InstanceKlass::method_with_orig_idnum(int idnum) {
   if (idnum >= methods()->length()) {
-    return NULL;
+    return nullptr;
   }
   Method* m = methods()->at(idnum);
-  if (m != NULL && m->orig_method_idnum() == idnum) {
+  if (m != nullptr && m->orig_method_idnum() == idnum) {
     return m;
   }
   // Obsolete method idnum does not match the original idnum
@@ -4127,14 +4127,14 @@ Method* InstanceKlass::method_with_orig_idnum(int idnum) {
     }
   }
   // None found, return null for the caller to handle.
-  return NULL;
+  return nullptr;
 }
 
 
 Method* InstanceKlass::method_with_orig_idnum(int idnum, int version) {
   InstanceKlass* holder = get_klass_version(version);
-  if (holder == NULL) {
-    return NULL; // The version of klass is gone, no method is found
+  if (holder == nullptr) {
+    return nullptr; // The version of klass is gone, no method is found
   }
   Method* method = holder->method_with_orig_idnum(idnum);
   return method;
@@ -4157,18 +4157,18 @@ unsigned char * InstanceKlass::get_cached_class_file_bytes() {
 // Make a step iterating over the class hierarchy under the root class.
 // Skips subclasses if requested.
 void ClassHierarchyIterator::next() {
-  assert(_current != NULL, "required");
-  if (_visit_subclasses && _current->subklass() != NULL) {
+  assert(_current != nullptr, "required");
+  if (_visit_subclasses && _current->subklass() != nullptr) {
     _current = _current->subklass();
     return; // visit next subclass
   }
   _visit_subclasses = true; // reset
-  while (_current->next_sibling() == NULL && _current != _root) {
+  while (_current->next_sibling() == nullptr && _current != _root) {
     _current = _current->superklass(); // backtrack; no more sibling subclasses left
   }
   if (_current == _root) {
     // Iteration is over (back at root after backtracking). Invalidate the iterator.
-    _current = NULL;
+    _current = nullptr;
     return;
   }
   _current = _current->next_sibling();
diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp
index d2531de8378..3264113e597 100644
--- a/src/hotspot/share/oops/instanceKlass.hpp
+++ b/src/hotspot/share/oops/instanceKlass.hpp
@@ -78,12 +78,12 @@ class FieldClosure: public StackObj {
 };
 
 // Print fields.
-// If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields.
+// If "obj" argument to constructor is null, prints static fields, otherwise prints non-static fields.
 class FieldPrinter: public FieldClosure {
    oop _obj;
    outputStream* _st;
  public:
-   FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {}
+   FieldPrinter(outputStream* st, oop obj = nullptr) : _obj(obj), _st(st) {}
    void do_field(fieldDescriptor* fd);
 };
 
@@ -201,9 +201,9 @@ class InstanceKlass: public Klass {
   // The contents of the Record attribute.
   Array<RecordComponent*>* _record_components;
 
-  // the source debug extension for this klass, NULL if not specified.
+  // the source debug extension for this klass, null if not specified.
   // Specified as UTF-8 string without terminating zero byte in the classfile,
-  // it is stored in the instanceklass as a NULL-terminated UTF-8 string
+  // it is stored in the instanceklass as a null-terminated UTF-8 string
   const char*     _source_debug_extension;
 
   // Number of heapOopSize words used by non-static fields in this klass
@@ -226,19 +226,19 @@ class InstanceKlass: public Klass {
   // _misc_flags right now.
   bool            _is_marked_dependent;     // used for marking during flushing and deoptimization
 
-  ClassState      _init_state;              // state of class
+  volatile ClassState _init_state;          // state of class
 
   u1              _reference_type;          // reference type
 
   // State is set while executing, eventually atomically to not disturb other state
   InstanceKlassFlags _misc_flags;
 
-  Monitor*        _init_monitor;         // mutual exclusion to _init_state and _init_thread.
-  Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recursive initialization)
+  Monitor*             _init_monitor;       // mutual exclusion to _init_state and _init_thread.
+  JavaThread* volatile _init_thread;        // Pointer to current thread doing initialization (to handle recursive initialization)
 
   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
-  jmethodID*      volatile _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
+  jmethodID*      volatile _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or null if none
   nmethodBucket*  volatile _dep_context;          // packed DependencyContext structure
   uint64_t        volatile _dep_context_last_cleaned;
   nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
@@ -294,7 +294,7 @@ class InstanceKlass: public Klass {
   //   The embedded implementor only exists if the current klass is an
   //   interface. The possible values of the implementor fall into following
   //   three cases:
-  //     NULL: no implementor.
+  //     null: no implementor.
   //     A Klass* that's not itself: one implementor.
   //     Itself: more than one implementors.
   //
@@ -382,12 +382,12 @@ class InstanceKlass: public Klass {
   // interfaces
   Array<InstanceKlass*>* local_interfaces() const          { return _local_interfaces; }
   void set_local_interfaces(Array<InstanceKlass*>* a)      {
-    guarantee(_local_interfaces == NULL || a == NULL, "Just checking");
+    guarantee(_local_interfaces == nullptr || a == nullptr, "Just checking");
     _local_interfaces = a; }
 
   Array<InstanceKlass*>* transitive_interfaces() const     { return _transitive_interfaces; }
   void set_transitive_interfaces(Array<InstanceKlass*>* a) {
-    guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");
+    guarantee(_transitive_interfaces == nullptr || a == nullptr, "Just checking");
     _transitive_interfaces = a;
   }
 
@@ -406,7 +406,7 @@ class InstanceKlass: public Klass {
 
   Array<u2>* fields() const            { return _fields; }
   void set_fields(Array<u2>* f, u2 java_fields_count) {
-    guarantee(_fields == NULL || f == NULL, "Just checking");
+    guarantee(_fields == nullptr || f == nullptr, "Just checking");
     _fields = f;
     _java_fields_count = java_fields_count;
   }
@@ -444,15 +444,15 @@ class InstanceKlass: public Klass {
 public:
   // Call this only if you know that the nest host has been initialized.
   InstanceKlass* nest_host_not_null() {
-    assert(_nest_host != NULL, "must be");
+    assert(_nest_host != nullptr, "must be");
     return _nest_host;
   }
   // Used to construct informative IllegalAccessError messages at a higher level,
   // if there was an issue resolving or validating the nest host.
-  // Returns NULL if there was no error.
+  // Returns null if there was no error.
   const char* nest_host_error();
   // Returns nest-host class, resolving and validating it if needed.
-  // Returns NULL if resolution is not possible from the calling context.
+  // Returns null if resolution is not possible from the calling context.
   InstanceKlass* nest_host(TRAPS);
   // Check if this klass is a nestmate of k - resolves this nest-host and k's
   bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
@@ -478,7 +478,7 @@ class InstanceKlass: public Klass {
   // package
   PackageEntry* package() const     { return _package_entry; }
   ModuleEntry* module() const;
-  bool in_unnamed_package() const   { return (_package_entry == NULL); }
+  bool in_unnamed_package() const   { return (_package_entry == nullptr); }
   void set_package(ClassLoaderData* loader_data, PackageEntry* pkg_entry, TRAPS);
   // If the package for the InstanceKlass is in the boot loader's package entry
   // table then sets the classpath_index field so that
@@ -511,7 +511,7 @@ class InstanceKlass: public Klass {
   bool is_not_initialized() const          { return init_state() <  being_initialized; }
   bool is_being_initialized() const        { return init_state() == being_initialized; }
   bool is_in_error_state() const           { return init_state() == initialization_error; }
-  bool is_init_thread(Thread *thread)      { return thread == _init_thread; }
+  bool is_init_thread(JavaThread *thread)  { return thread == Atomic::load(&_init_thread); }
   ClassState  init_state() const           { return Atomic::load(&_init_state); }
   const char* init_state_name() const;
   bool is_rewritten() const                { return _misc_flags.rewritten(); }
@@ -583,7 +583,7 @@ class InstanceKlass: public Klass {
     _disable_method_binary_search = true;
   }
 
-  // find a local method (returns NULL if not found)
+  // find a local method (returns null if not found)
   Method* find_method(const Symbol* name, const Symbol* signature) const;
   static Method* find_method(const Array<Method*>* methods,
                              const Symbol* name,
@@ -597,14 +597,14 @@ class InstanceKlass: public Klass {
                                       const Symbol* signature,
                                       PrivateLookupMode private_mode);
 
-  // find a local method (returns NULL if not found)
+  // find a local method (returns null if not found)
   Method* find_local_method(const Symbol* name,
                             const Symbol* signature,
                             OverpassLookupMode overpass_mode,
                             StaticLookupMode static_mode,
                             PrivateLookupMode private_mode) const;
 
-  // find a local method from given methods array (returns NULL if not found)
+  // find a local method from given methods array (returns null if not found)
   static Method* find_local_method(const Array<Method*>* methods,
                                    const Symbol* name,
                                    const Symbol* signature,
@@ -620,18 +620,18 @@ class InstanceKlass: public Klass {
                                StaticLookupMode static_mode,
                                PrivateLookupMode private_mode);
 
-  // lookup operation (returns NULL if not found)
+  // lookup operation (returns null if not found)
   Method* uncached_lookup_method(const Symbol* name,
                                  const Symbol* signature,
                                  OverpassLookupMode overpass_mode,
                                  PrivateLookupMode private_mode = PrivateLookupMode::find) const;
 
   // lookup a method in all the interfaces that this class implements
-  // (returns NULL if not found)
+  // (returns null if not found)
   Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, DefaultsLookupMode defaults_mode) const;
 
   // lookup a method in local defaults then in all interfaces
-  // (returns NULL if not found)
+  // (returns null if not found)
   Method* lookup_method_in_ordered_interfaces(Symbol* name, Symbol* signature) const;
 
   // Find method indices by name.  If a method with the specified name is
@@ -706,16 +706,16 @@ class InstanceKlass: public Klass {
 
   InstanceKlass* previous_versions() const { return _previous_versions; }
 #else
-  InstanceKlass* previous_versions() const { return NULL; }
+  InstanceKlass* previous_versions() const { return nullptr; }
 #endif
 
   InstanceKlass* get_klass_version(int version) {
-    for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) {
+    for (InstanceKlass* ik = this; ik != nullptr; ik = ik->previous_versions()) {
       if (ik->constants()->version() == version) {
         return ik;
       }
     }
-    return NULL;
+    return nullptr;
   }
 
   bool has_been_redefined() const { return _misc_flags.has_been_redefined(); }
@@ -736,7 +736,7 @@ class InstanceKlass: public Klass {
 #if INCLUDE_JVMTI
 
   void init_previous_versions() {
-    _previous_versions = NULL;
+    _previous_versions = nullptr;
   }
 
  private:
@@ -772,9 +772,9 @@ class InstanceKlass: public Klass {
   static bool has_previous_versions_and_reset() { return false; }
 
   void set_cached_class_file(JvmtiCachedClassFileData *data) {
-    assert(data == NULL, "unexpected call with JVMTI disabled");
+    assert(data == nullptr, "unexpected call with JVMTI disabled");
   }
-  JvmtiCachedClassFileData * get_cached_class_file() { return (JvmtiCachedClassFileData *)NULL; }
+  JvmtiCachedClassFileData * get_cached_class_file() { return (JvmtiCachedClassFileData *)nullptr; }
 
 #endif // INCLUDE_JVMTI
 
@@ -819,16 +819,16 @@ class InstanceKlass: public Klass {
   void set_annotations(Annotations* anno)   { _annotations = anno; }
 
   AnnotationArray* class_annotations() const {
-    return (_annotations != NULL) ? _annotations->class_annotations() : NULL;
+    return (_annotations != nullptr) ? _annotations->class_annotations() : nullptr;
   }
   Array<AnnotationArray*>* fields_annotations() const {
-    return (_annotations != NULL) ? _annotations->fields_annotations() : NULL;
+    return (_annotations != nullptr) ? _annotations->fields_annotations() : nullptr;
   }
   AnnotationArray* class_type_annotations() const {
-    return (_annotations != NULL) ? _annotations->class_type_annotations() : NULL;
+    return (_annotations != nullptr) ? _annotations->class_type_annotations() : nullptr;
   }
   Array<AnnotationArray*>* fields_type_annotations() const {
-    return (_annotations != NULL) ? _annotations->fields_type_annotations() : NULL;
+    return (_annotations != nullptr) ? _annotations->fields_type_annotations() : nullptr;
   }
   // allocation
   instanceOop allocate_instance(TRAPS);
@@ -925,13 +925,13 @@ class InstanceKlass: public Klass {
   }
 
   static const InstanceKlass* cast(const Klass* k) {
-    assert(k != NULL, "k should not be null");
+    assert(k != nullptr, "k should not be null");
     assert(k->is_instance_klass(), "cast to InstanceKlass");
     return static_cast<const InstanceKlass*>(k);
   }
 
   virtual InstanceKlass* java_super() const {
-    return (super() == NULL) ? NULL : cast(super());
+    return (super() == nullptr) ? nullptr : cast(super());
   }
 
   // Sizing (in words)
@@ -1077,15 +1077,16 @@ class InstanceKlass: public Klass {
   // initialization state
   void set_init_state(ClassState state);
   void set_rewritten()                  { _misc_flags.set_rewritten(true); }
-  void set_init_thread(Thread *thread)  {
-    assert(thread == nullptr || _init_thread == nullptr, "Only one thread is allowed to own initialization");
-    _init_thread = thread;
+  void set_init_thread(JavaThread *thread)  {
+    assert((thread == JavaThread::current() && _init_thread == nullptr) ||
+           (thread == nullptr && _init_thread == JavaThread::current()), "Only one thread is allowed to own initialization");
+    Atomic::store(&_init_thread, thread);
   }
 
   // The RedefineClasses() API can cause new method idnums to be needed
   // which will cause the caches to grow. Safety requires different
   // cache management logic if the caches can grow instead of just
-  // going from NULL to non-NULL.
+  // going from null to non-null.
   bool idnum_can_increment() const      { return has_been_redefined(); }
   inline jmethodID* methods_jmethod_ids_acquire() const;
   inline void release_set_methods_jmethod_ids(jmethodID* jmeths);
@@ -1113,7 +1114,7 @@ class InstanceKlass: public Klass {
   void add_initialization_error(JavaThread* current, Handle exception);
   oop get_initialization_error(JavaThread* current);
 
-  // find a local method (returns NULL if not found)
+  // find a local method (returns null if not found)
   Method* find_method_impl(const Symbol* name,
                            const Symbol* signature,
                            OverpassLookupMode overpass_mode,
@@ -1246,7 +1247,7 @@ class InnerClassesIterator : public StackObj {
 
   InnerClassesIterator(const InstanceKlass* k) {
     _inner_classes = k->inner_classes();
-    if (k->inner_classes() != NULL) {
+    if (k->inner_classes() != nullptr) {
       _length = _inner_classes->length();
       // The inner class array's length should be the multiple of
       // inner_class_next_offset if it only contains the InnerClasses
@@ -1332,7 +1333,7 @@ class ClassHierarchyIterator : public StackObj {
   }
 
   bool done() {
-    return (_current == NULL);
+    return (_current == nullptr);
   }
 
   // Make a step iterating over the class hierarchy under the root class.
diff --git a/src/hotspot/share/oops/instanceKlass.inline.hpp b/src/hotspot/share/oops/instanceKlass.inline.hpp
index 6af358aeca7..b7a31400333 100644
--- a/src/hotspot/share/oops/instanceKlass.inline.hpp
+++ b/src/hotspot/share/oops/instanceKlass.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@ inline InstanceKlass* volatile* InstanceKlass::adr_implementor() const {
   if (is_interface()) {
     return (InstanceKlass* volatile*)end_of_nonstatic_oop_maps();
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -187,9 +187,9 @@ ALWAYSINLINE void InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType
 
 inline instanceOop InstanceKlass::allocate_instance(oop java_class, TRAPS) {
   Klass* k = java_lang_Class::as_Klass(java_class);
-  if (k == NULL) {
+  if (k == nullptr) {
     ResourceMark rm(THREAD);
-    THROW_(vmSymbols::java_lang_InstantiationException(), NULL);
+    THROW_(vmSymbols::java_lang_InstantiationException(), nullptr);
   }
   InstanceKlass* ik = cast(k);
   ik->check_valid_for_instantiation(false, CHECK_NULL);
diff --git a/src/hotspot/share/oops/instanceMirrorKlass.cpp b/src/hotspot/share/oops/instanceMirrorKlass.cpp
index 058e28b469a..2cb0b953d14 100644
--- a/src/hotspot/share/oops/instanceMirrorKlass.cpp
+++ b/src/hotspot/share/oops/instanceMirrorKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 int InstanceMirrorKlass::_offset_of_static_fields = 0;
 
 size_t InstanceMirrorKlass::instance_size(Klass* k) {
-  if (k != NULL && k->is_instance_klass()) {
+  if (k != nullptr && k->is_instance_klass()) {
     return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());
   }
   return size_helper();
@@ -61,7 +61,7 @@ size_t InstanceMirrorKlass::oop_size(oop obj) const {
 
 int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
   Klass* k = java_lang_Class::as_Klass(obj);
-  if (k != NULL && k->is_instance_klass()) {
+  if (k != nullptr && k->is_instance_klass()) {
     return InstanceKlass::cast(k)->static_oop_field_count();
   }
   return 0;
diff --git a/src/hotspot/share/oops/instanceMirrorKlass.inline.hpp b/src/hotspot/share/oops/instanceMirrorKlass.inline.hpp
index 6cc53f8c302..1d5113f5a8e 100644
--- a/src/hotspot/share/oops/instanceMirrorKlass.inline.hpp
+++ b/src/hotspot/share/oops/instanceMirrorKlass.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,9 +52,9 @@ void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
 
   if (Devirtualizer::do_metadata(closure)) {
     Klass* klass = java_lang_Class::as_Klass(obj);
-    // We'll get NULL for primitive mirrors.
-    if (klass != NULL) {
-      if (klass->class_loader_data() == NULL) {
+    // We'll get null for primitive mirrors.
+    if (klass != nullptr) {
+      if (klass->class_loader_data() == nullptr) {
         // This is a mirror that belongs to a shared class that has not be loaded yet.
         // It's only reachable via HeapShared::roots(). All of its fields should be zero
         // so there's no need to scan.
@@ -71,7 +71,7 @@ void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
         Devirtualizer::do_klass(closure, klass);
       }
     } else {
-      // We would like to assert here (as below) that if klass has been NULL, then
+      // We would like to assert here (as below) that if klass has been null, then
       // this has been a mirror for a primitive type that we do not need to follow
       // as they are always strong roots.
       // However, we might get across a klass that just changed during CMS concurrent
@@ -125,8 +125,8 @@ void InstanceMirrorKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closu
   if (Devirtualizer::do_metadata(closure)) {
     if (mr.contains(obj)) {
       Klass* klass = java_lang_Class::as_Klass(obj);
-      // We'll get NULL for primitive mirrors.
-      if (klass != NULL) {
+      // We'll get null for primitive mirrors.
+      if (klass != nullptr) {
         Devirtualizer::do_klass(closure, klass);
       }
     }
diff --git a/src/hotspot/share/oops/instanceRefKlass.cpp b/src/hotspot/share/oops/instanceRefKlass.cpp
index d14bbebfb30..3af465d718a 100644
--- a/src/hotspot/share/oops/instanceRefKlass.cpp
+++ b/src/hotspot/share/oops/instanceRefKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,12 +112,12 @@ void InstanceRefKlass::oop_verify_on(oop obj, outputStream* st) {
   InstanceKlass::oop_verify_on(obj, st);
   // Verify referent field
   oop referent = java_lang_ref_Reference::unknown_referent_no_keepalive(obj);
-  if (referent != NULL) {
+  if (referent != nullptr) {
     guarantee(oopDesc::is_oop(referent), "referent field heap failed");
   }
   // Additional verification for next field, which must be a Reference or null
   oop next = java_lang_ref_Reference::next(obj);
-  if (next != NULL) {
+  if (next != nullptr) {
     guarantee(oopDesc::is_oop(next), "next field should be an oop");
     guarantee(next->is_instanceRef(), "next field verify failed");
   }
diff --git a/src/hotspot/share/oops/instanceRefKlass.inline.hpp b/src/hotspot/share/oops/instanceRefKlass.inline.hpp
index 978234cd0a1..af20b0fe14a 100644
--- a/src/hotspot/share/oops/instanceRefKlass.inline.hpp
+++ b/src/hotspot/share/oops/instanceRefKlass.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,9 +66,9 @@ static inline oop load_referent(oop obj, ReferenceType type) {
 template <typename T, class OopClosureType>
 bool InstanceRefKlass::try_discover(oop obj, ReferenceType type, OopClosureType* closure) {
   ReferenceDiscoverer* rd = closure->ref_discoverer();
-  if (rd != NULL) {
+  if (rd != nullptr) {
     oop referent = load_referent(obj, type);
-    if (referent != NULL) {
+    if (referent != nullptr) {
       if (!referent->is_gc_marked()) {
         // Only try to discover if not yet marked.
         return rd->discover_reference(obj, type);
@@ -100,14 +100,14 @@ void InstanceRefKlass::oop_oop_iterate_discovered_and_discovery(oop obj, Referen
 
 template <typename T, class OopClosureType, class Contains>
 void InstanceRefKlass::oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains) {
-  assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
+  assert(closure->ref_discoverer() == nullptr, "ReferenceDiscoverer should not be set");
   do_referent<T>(obj, closure, contains);
   do_discovered<T>(obj, closure, contains);
 }
 
 template <typename T, class OopClosureType, class Contains>
 void InstanceRefKlass::oop_oop_iterate_fields_except_referent(oop obj, OopClosureType* closure, Contains& contains) {
-  assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
+  assert(closure->ref_discoverer() == nullptr, "ReferenceDiscoverer should not be set");
   do_discovered<T>(obj, closure, contains);
 }
 
diff --git a/src/hotspot/share/oops/instanceStackChunkKlass.cpp b/src/hotspot/share/oops/instanceStackChunkKlass.cpp
index 37512d332b4..62c9c89767e 100644
--- a/src/hotspot/share/oops/instanceStackChunkKlass.cpp
+++ b/src/hotspot/share/oops/instanceStackChunkKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -235,7 +235,7 @@ class PrintStackChunkClosure {
 
 void InstanceStackChunkKlass::print_chunk(const stackChunkOop c, bool verbose, outputStream* st) {
   if (c == nullptr) {
-    st->print_cr("CHUNK NULL");
+    st->print_cr("CHUNK null");
     return;
   }
 
diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp
index 0d936759f59..d4855886c48 100644
--- a/src/hotspot/share/oops/klass.cpp
+++ b/src/hotspot/share/oops/klass.cpp
@@ -83,7 +83,7 @@ void Klass::set_is_cloneable() {
 
 void Klass::set_name(Symbol* n) {
   _name = n;
-  if (_name != NULL) _name->increment_refcount();
+  if (_name != nullptr) _name->increment_refcount();
 
   if (Arguments::is_dumping_archive() && is_instance_klass()) {
     SystemDictionaryShared::init_dumptime_info(InstanceKlass::cast(this));
@@ -96,7 +96,7 @@ bool Klass::is_subclass_of(const Klass* k) const {
 
   Klass* t = const_cast<Klass*>(this)->super();
 
-  while (t != NULL) {
+  while (t != nullptr) {
     if (t == k) return true;
     t = t->super();
   }
@@ -104,7 +104,7 @@ bool Klass::is_subclass_of(const Klass* k) const {
 }
 
 void Klass::release_C_heap_structures(bool release_constant_pool) {
-  if (_name != NULL) _name->decrement_refcount();
+  if (_name != nullptr) _name->decrement_refcount();
 }
 
 bool Klass::search_secondary_supers(Klass* k) const {
@@ -131,7 +131,7 @@ Klass *Klass::up_cast_abstract() {
   Klass *r = this;
   while( r->is_abstract() ) {   // Receiver is abstract?
     Klass *s = r->subklass();   // Check for exactly 1 subklass
-    if (s == NULL || s->next_sibling() != NULL) // Oops; wrong count; give up
+    if (s == nullptr || s->next_sibling() != nullptr) // Oops; wrong count; give up
       return this;              // Return 'this' as a no-progress flag
     r = s;                    // Loop till find concrete class
   }
@@ -159,7 +159,7 @@ void Klass::check_valid_for_instantiation(bool throwError, TRAPS) {
 
 void Klass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) {
   ResourceMark rm(THREAD);
-  assert(s != NULL, "Throw NPE!");
+  assert(s != nullptr, "Throw NPE!");
   THROW_MSG(vmSymbols::java_lang_ArrayStoreException(),
             err_msg("arraycopy: source type %s is not an array", s->klass()->external_name()));
 }
@@ -176,7 +176,7 @@ Klass* Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
                 " wrap return value in a mirror object.");
 #endif
   ShouldNotReachHere();
-  return NULL;
+  return nullptr;
 }
 
 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
@@ -188,7 +188,7 @@ Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signatur
                 " wrap return value in a mirror object.");
 #endif
   ShouldNotReachHere();
-  return NULL;
+  return nullptr;
 }
 
 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
@@ -228,7 +228,7 @@ jint Klass::array_layout_helper(BasicType etype) {
 }
 
 bool Klass::can_be_primary_super_slow() const {
-  if (super() == NULL)
+  if (super() == nullptr)
     return true;
   else if (super()->super_depth() >= primary_super_limit()-1)
     return false;
@@ -237,12 +237,12 @@ bool Klass::can_be_primary_super_slow() const {
 }
 
 void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS) {
-  if (k == NULL) {
-    set_super(NULL);
+  if (k == nullptr) {
+    set_super(nullptr);
     _primary_supers[0] = this;
     assert(super_depth() == 0, "Object must already be initialized properly");
   } else if (k != super() || k == vmClasses::Object_klass()) {
-    assert(super() == NULL || super() == vmClasses::Object_klass(),
+    assert(super() == nullptr || super() == vmClasses::Object_klass(),
            "initialize this only once to a non-trivial value");
     set_super(k);
     Klass* sup = k;
@@ -273,9 +273,9 @@ void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interf
         j = t->super_depth();
       }
       for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
-        assert(primary_super_of_depth(j1) == NULL, "super list padding");
+        assert(primary_super_of_depth(j1) == nullptr, "super list padding");
       }
-      while (t != NULL) {
+      while (t != nullptr) {
         assert(primary_super_of_depth(j) == t, "super list initialization");
         t = t->super();
         --j;
@@ -285,14 +285,14 @@ void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interf
 #endif
   }
 
-  if (secondary_supers() == NULL) {
+  if (secondary_supers() == nullptr) {
 
     // Now compute the list of secondary supertypes.
     // Secondaries can occasionally be on the super chain,
     // if the inline "_primary_supers" array overflows.
     int extras = 0;
     Klass* p;
-    for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
+    for (p = super(); !(p == nullptr || p->can_be_primary_super()); p = p->super()) {
       ++extras;
     }
 
@@ -300,14 +300,14 @@ void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interf
 
     // Compute the "real" non-extra secondaries.
     GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras, transitive_interfaces);
-    if (secondaries == NULL) {
+    if (secondaries == nullptr) {
       // secondary_supers set by compute_secondary_supers
       return;
     }
 
     GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras);
 
-    for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
+    for (p = super(); !(p == nullptr || p->can_be_primary_super()); p = p->super()) {
       int i;                    // Scan for overflow primaries being duplicates of 2nd'arys
 
       // This happens frequently for very deeply nested arrays: the
@@ -339,9 +339,9 @@ void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interf
     }
 
   #ifdef ASSERT
-      // We must not copy any NULL placeholders left over from bootstrap.
+      // We must not copy any null placeholders left over from bootstrap.
     for (int j = 0; j < s2->length(); j++) {
-      assert(s2->at(j) != NULL, "correct bootstrapping order");
+      assert(s2->at(j) != nullptr, "correct bootstrapping order");
     }
   #endif
 
@@ -352,16 +352,16 @@ void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interf
 GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots,
                                                        Array<InstanceKlass*>* transitive_interfaces) {
   assert(num_extra_slots == 0, "override for complex klasses");
-  assert(transitive_interfaces == NULL, "sanity");
+  assert(transitive_interfaces == nullptr, "sanity");
   set_secondary_supers(Universe::the_empty_klass_array());
-  return NULL;
+  return nullptr;
 }
 
 
 // superklass links
 InstanceKlass* Klass::superklass() const {
-  assert(super() == NULL || super()->is_instance_klass(), "must be instance klass");
-  return _super == NULL ? NULL : InstanceKlass::cast(_super);
+  assert(super() == nullptr || super()->is_instance_klass(), "must be instance klass");
+  return _super == nullptr ? nullptr : InstanceKlass::cast(_super);
 }
 
 // subklass links.  Used by the compiler (and vtable initialization)
@@ -371,7 +371,7 @@ Klass* Klass::subklass(bool log) const {
   // Need load_acquire on the _subklass, because it races with inserts that
   // publishes freshly initialized data.
   for (Klass* chain = Atomic::load_acquire(&_subklass);
-       chain != NULL;
+       chain != nullptr;
        // Do not need load_acquire on _next_sibling, because inserts never
        // create _next_sibling edges to dead data.
        chain = Atomic::load(&chain->_next_sibling))
@@ -385,14 +385,14 @@ Klass* Klass::subklass(bool log) const {
       }
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 Klass* Klass::next_sibling(bool log) const {
   // Do not need load_acquire on _next_sibling, because inserts never
   // create _next_sibling edges to dead data.
   for (Klass* chain = Atomic::load(&_next_sibling);
-       chain != NULL;
+       chain != nullptr;
        chain = Atomic::load(&chain->_next_sibling)) {
     // Only return alive klass, there may be stale klass
     // in this chain if cleaned concurrently.
@@ -405,7 +405,7 @@ Klass* Klass::next_sibling(bool log) const {
       }
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 void Klass::set_subklass(Klass* s) {
@@ -428,9 +428,9 @@ void Klass::append_to_sibling_list() {
   debug_only(verify();)
   // add ourselves to superklass' subklass list
   InstanceKlass* super = superklass();
-  if (super == NULL) return;        // special case: class Object
+  if (super == nullptr) return;     // special case: class Object
   assert((!super->is_interface()    // interfaces cannot be supers
-          && (super->superklass() == NULL || !is_interface())),
+          && (super->superklass() == nullptr || !is_interface())),
          "an interface can only be a subklass of Object");
 
   // Make sure there is no stale subklass head
@@ -438,7 +438,7 @@ void Klass::append_to_sibling_list() {
 
   for (;;) {
     Klass* prev_first_subklass = Atomic::load_acquire(&_super->_subklass);
-    if (prev_first_subklass != NULL) {
+    if (prev_first_subklass != nullptr) {
       // set our sibling to be the superklass' previous first subklass
       assert(prev_first_subklass->is_loader_alive(), "May not attach not alive klasses");
       set_next_sibling(prev_first_subklass);
@@ -457,7 +457,7 @@ void Klass::clean_subklass() {
   for (;;) {
     // Need load_acquire, due to contending with concurrent inserts
     Klass* subklass = Atomic::load_acquire(&_subklass);
-    if (subklass == NULL || subklass->is_loader_alive()) {
+    if (subklass == nullptr || subklass->is_loader_alive()) {
       return;
     }
     // Try to fix _subklass until it points at something not dead.
@@ -482,14 +482,14 @@ void Klass::clean_weak_klass_links(bool unloading_occurred, bool clean_alive_kla
     // Find and set the first alive subklass
     Klass* sub = current->subklass(true);
     current->clean_subklass();
-    if (sub != NULL) {
+    if (sub != nullptr) {
       stack.push(sub);
     }
 
     // Find and set the first alive sibling
     Klass* sibling = current->next_sibling(true);
     current->set_next_sibling(sibling);
-    if (sibling != NULL) {
+    if (sibling != nullptr) {
       stack.push(sibling);
     }
 
@@ -500,7 +500,7 @@ void Klass::clean_weak_klass_links(bool unloading_occurred, bool clean_alive_kla
 
       // JVMTI RedefineClasses creates previous versions that are not in
       // the class hierarchy, so process them here.
-      while ((ik = ik->previous_versions()) != NULL) {
+      while ((ik = ik->previous_versions()) != nullptr) {
         ik->clean_weak_instanceklass_links();
       }
     }
@@ -522,7 +522,7 @@ void Klass::metaspace_pointers_do(MetaspaceClosure* it) {
   it->push(&_super);
   if (!Arguments::is_dumping_archive()) {
     // If dumping archive, these may point to excluded classes. There's no need
-    // to follow these pointers anyway, as they will be set to NULL in
+    // to follow these pointers anyway, as they will be set to null in
     // remove_unshareable_info().
     it->push((Klass**)&_subklass);
     it->push((Klass**)&_next_sibling);
@@ -545,12 +545,12 @@ void Klass::remove_unshareable_info() {
     log_trace(cds, unshareable)("remove: %s", external_name());
   }
 
-  set_subklass(NULL);
-  set_next_sibling(NULL);
-  set_next_link(NULL);
+  set_subklass(nullptr);
+  set_next_sibling(nullptr);
+  set_next_link(nullptr);
 
   // Null out class_loader_data because we don't share that yet.
-  set_class_loader_data(NULL);
+  set_class_loader_data(nullptr);
   set_is_shared();
 }
 
@@ -576,7 +576,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
   // If an exception happened during CDS restore, some of these fields may already be
   // set.  We leave the class on the CLD list, even if incomplete so that we don't
   // modify the CLD list outside a safepoint.
-  if (class_loader_data() == NULL) {
+  if (class_loader_data() == nullptr) {
     set_class_loader_data(loader_data);
 
     // Add to class loader list first before creating the mirror
@@ -585,7 +585,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
   }
 
   Handle loader(THREAD, loader_data->class_loader());
-  ModuleEntry* module_entry = NULL;
+  ModuleEntry* module_entry = nullptr;
   Klass* k = this;
   if (k->is_objArray_klass()) {
     k = ObjArrayKlass::cast(k)->bottom_klass();
@@ -598,7 +598,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
     module_entry = ModuleEntryTable::javabase_moduleEntry();
   }
   // Obtain java.lang.Module, if available
-  Handle module_handle(THREAD, ((module_entry != NULL) ? module_entry->module() : (oop)NULL));
+  Handle module_handle(THREAD, ((module_entry != nullptr) ? module_entry->module() : (oop)nullptr));
 
   if (this->has_archived_mirror_index()) {
     ResourceMark rm(THREAD);
@@ -620,7 +620,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
 
   // Only recreate it if not present.  A previous attempt to restore may have
   // gotten an OOM later but keep the mirror if it was created.
-  if (java_mirror() == NULL) {
+  if (java_mirror() == nullptr) {
     ResourceMark rm(THREAD);
     log_trace(cds, mirror)("Recreate mirror for %s", external_name());
     java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, Handle(), CHECK);
@@ -689,12 +689,12 @@ const char* Klass::external_name() const {
     char* result = convert_hidden_name_to_java(name());
     return result;
   }
-  if (name() == NULL)  return "<unknown>";
+  if (name() == nullptr)  return "<unknown>";
   return name()->as_klass_external_name();
 }
 
 const char* Klass::signature_name() const {
-  if (name() == NULL)  return "<unknown>";
+  if (name() == nullptr)  return "<unknown>";
   if (is_objArray_klass() && ObjArrayKlass::cast(this)->bottom_klass()->is_hidden()) {
     size_t name_len = name()->utf8_length();
     char* result = NEW_RESOURCE_ARRAY(char, name_len + 1);
@@ -769,21 +769,21 @@ void Klass::verify_on(outputStream* st) {
 
   guarantee(this->is_klass(),"should be klass");
 
-  if (super() != NULL) {
+  if (super() != nullptr) {
     guarantee(super()->is_klass(), "should be klass");
   }
-  if (secondary_super_cache() != NULL) {
+  if (secondary_super_cache() != nullptr) {
     Klass* ko = secondary_super_cache();
     guarantee(ko->is_klass(), "should be klass");
   }
   for ( uint i = 0; i < primary_super_limit(); i++ ) {
     Klass* ko = _primary_supers[i];
-    if (ko != NULL) {
+    if (ko != nullptr) {
       guarantee(ko->is_klass(), "should be klass");
     }
   }
 
-  if (java_mirror_no_keepalive() != NULL) {
+  if (java_mirror_no_keepalive() != nullptr) {
     guarantee(java_lang_Class::is_instance(java_mirror_no_keepalive()), "should be instance");
   }
 }
@@ -846,7 +846,7 @@ const char* Klass::joint_in_module_of_loader(const Klass* class2, bool include_p
   char* joint_description = NEW_RESOURCE_ARRAY_RETURN_NULL(char, len);
 
   // Just return the FQN if error when allocating string
-  if (joint_description == NULL) {
+  if (joint_description == nullptr) {
     return class1_name;
   }
 
@@ -905,7 +905,7 @@ const char* Klass::class_in_module_of_loader(bool use_are, bool include_parent_l
 
   // 3. class loader's name_and_id
   ClassLoaderData* cld = class_loader_data();
-  assert(cld != NULL, "class_loader_data should not be null");
+  assert(cld != nullptr, "class_loader_data should not be null");
   const char* loader_name_and_id = cld->loader_name_and_id();
   len += strlen(loader_name_and_id);
 
@@ -919,9 +919,9 @@ const char* Klass::class_in_module_of_loader(bool use_are, bool include_parent_l
     // The parent loader's ClassLoaderData could be null if it is
     // a delegating class loader that has never defined a class.
     // In this case the loader's name must be obtained via the parent loader's oop.
-    if (parent_cld == NULL) {
+    if (parent_cld == nullptr) {
       oop cl_name_and_id = java_lang_ClassLoader::nameAndId(parent_loader);
-      if (cl_name_and_id != NULL) {
+      if (cl_name_and_id != nullptr) {
         parent_loader_name_and_id = java_lang_String::as_utf8_string(cl_name_and_id);
       }
     } else {
@@ -938,7 +938,7 @@ const char* Klass::class_in_module_of_loader(bool use_are, bool include_parent_l
   char* class_description = NEW_RESOURCE_ARRAY_RETURN_NULL(char, len);
 
   // Just return the FQN if error when allocating string
-  if (class_description == NULL) {
+  if (class_description == nullptr) {
     return klass_name;
   }
 
diff --git a/src/hotspot/share/oops/klass.hpp b/src/hotspot/share/oops/klass.hpp
index b2bd5866647..acb9a41730f 100644
--- a/src/hotspot/share/oops/klass.hpp
+++ b/src/hotspot/share/oops/klass.hpp
@@ -145,9 +145,9 @@ class Klass : public Metadata {
   OopHandle   _java_mirror;
   // Superclass
   Klass*      _super;
-  // First subclass (NULL if none); _subklass->next_sibling() is next one
+  // First subclass (null if none); _subklass->next_sibling() is next one
   Klass* volatile _subklass;
-  // Sibling link (or NULL); links all subklasses of a klass
+  // Sibling link (or null); links all subklasses of a klass
   Klass* volatile _next_sibling;
 
   // All klasses loaded by a class loader are chained through these links
@@ -220,7 +220,7 @@ class Klass : public Metadata {
                                                           Array<InstanceKlass*>* transitive_interfaces);
 
   // java_super is the Java-level super type as specified by Class.getSuperClass.
-  virtual InstanceKlass* java_super() const  { return NULL; }
+  virtual InstanceKlass* java_super() const  { return nullptr; }
 
   juint    super_check_offset() const  { return _super_check_offset; }
   void set_super_check_offset(juint o) { _super_check_offset = o; }
@@ -232,11 +232,11 @@ class Klass : public Metadata {
   void set_secondary_supers(Array<Klass*>* k) { _secondary_supers = k; }
 
   // Return the element of the _super chain of the given depth.
-  // If there is no such element, return either NULL or this.
+  // If there is no such element, return either null or this.
   Klass* primary_super_of_depth(juint i) const {
     assert(i < primary_super_limit(), "oob");
     Klass* super = _primary_supers[i];
-    assert(super == NULL || super->super_depth() == i, "correct display");
+    assert(super == nullptr || super->super_depth() == i, "correct display");
     return super;
   }
 
@@ -265,14 +265,14 @@ class Klass : public Metadata {
   oop java_mirror_no_keepalive() const;
   void set_java_mirror(Handle m);
 
-  oop archived_java_mirror() NOT_CDS_JAVA_HEAP_RETURN_(NULL);
+  oop archived_java_mirror() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
   void set_archived_java_mirror(int mirror_index) NOT_CDS_JAVA_HEAP_RETURN;
 
   // Temporary mirror switch used by RedefineClasses
   OopHandle java_mirror_handle() const { return _java_mirror; }
   void swap_java_mirror_handle(OopHandle& mirror) { _java_mirror.swap(mirror); }
 
-  // Set java mirror OopHandle to NULL for CDS
+  // Set java mirror OopHandle to null for CDS
   // This leaves the OopHandle in the CLD, but that's ok, you can't release them.
   void clear_java_mirror_handle() { _java_mirror = OopHandle(); }
 
@@ -528,7 +528,7 @@ class Klass : public Metadata {
   // array class with this klass as element type
   virtual Klass* array_klass(TRAPS) = 0;
 
-  // These will return NULL instead of allocating on the heap:
+  // These will return null instead of allocating on the heap:
   virtual Klass* array_klass_or_null(int rank) = 0;
   virtual Klass* array_klass_or_null() = 0;
 
@@ -567,7 +567,7 @@ class Klass : public Metadata {
     if (has_archived_mirror_index()) {
       // _java_mirror is not a valid OopHandle but rather an encoded reference in the shared heap
       return false;
-    } else if (_java_mirror.ptr_raw() == NULL) {
+    } else if (_java_mirror.ptr_raw() == nullptr) {
       return false;
     } else {
       return true;
diff --git a/src/hotspot/share/oops/klassVtable.cpp b/src/hotspot/share/oops/klassVtable.cpp
index c1b8e1f538f..7cfca5cdf24 100644
--- a/src/hotspot/share/oops/klassVtable.cpp
+++ b/src/hotspot/share/oops/klassVtable.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,7 @@ void klassVtable::compute_vtable_size_and_num_mirandas(
   int vtable_length = 0;
 
   // start off with super's vtable length
-  vtable_length = super == NULL ? 0 : super->vtable_length();
+  vtable_length = super == nullptr ? 0 : super->vtable_length();
 
   // go thru each method in the methods table to see if it needs a new entry
   int len = methods->length();
@@ -90,7 +90,7 @@ void klassVtable::compute_vtable_size_and_num_mirandas(
 
   GrowableArray<Method*> new_mirandas(20);
   // compute the number of mirandas methods that must be added to the end
-  get_mirandas(&new_mirandas, all_mirandas, super, methods, NULL, local_interfaces,
+  get_mirandas(&new_mirandas, all_mirandas, super, methods, nullptr, local_interfaces,
                class_flags.is_interface());
   *num_new_mirandas = new_mirandas.length();
 
@@ -106,7 +106,7 @@ void klassVtable::compute_vtable_size_and_num_mirandas(
     vtable_length = Universe::base_vtable_size();
   }
 
-  if (super == NULL && vtable_length != Universe::base_vtable_size()) {
+  if (super == nullptr && vtable_length != Universe::base_vtable_size()) {
     if (Universe::is_bootstrapping()) {
       // Someone is attempting to override java.lang.Object incorrectly on the
       // bootclasspath.  The JVM cannot recover from this error including throwing
@@ -131,7 +131,7 @@ void klassVtable::compute_vtable_size_and_num_mirandas(
 // and return the number of entries copied.  Expects that 'super' is the Java
 // super class (arrays can have "array" super classes that must be skipped).
 int klassVtable::initialize_from_super(Klass* super) {
-  if (super == NULL) {
+  if (super == nullptr) {
     return 0;
   } else if (is_preinitialized_vtable()) {
     // A shared class' vtable is preinitialized at dump time. No need to copy
@@ -212,11 +212,11 @@ void klassVtable::initialize_vtable(GrowableArray<InstanceKlass*>* supers) {
 
     // update vtable with default_methods
     Array<Method*>* default_methods = ik()->default_methods();
-    if (default_methods != NULL) {
+    if (default_methods != nullptr) {
       len = default_methods->length();
       if (len > 0) {
         Array<int>* def_vtable_indices = ik()->default_vtable_indices();
-        assert(def_vtable_indices != NULL, "should be created");
+        assert(def_vtable_indices != nullptr, "should be created");
         assert(def_vtable_indices->length() == len, "reinit vtable len?");
         for (int i = 0; i < len; i++) {
           bool needs_new_entry;
@@ -314,7 +314,7 @@ InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper
                                                      Symbol* target_classname) {
 
   InstanceKlass* superk = initialsuper;
-  while (superk != NULL && superk->super() != NULL) {
+  while (superk != nullptr && superk->super() != nullptr) {
     klassVtable ssVtable = (superk->super())->vtable();
     if (vtable_index < ssVtable.length()) {
       Method* super_method = ssVtable.method_at(vtable_index);
@@ -343,11 +343,11 @@ InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper
       }
     } else  {
       // super class has no vtable entry here, stop transitive search
-      superk = (InstanceKlass*)NULL;
+      superk = (InstanceKlass*)nullptr;
       break;
     }
     // if no override found yet, continue to search up
-    superk = superk->super() == NULL ? NULL : InstanceKlass::cast(superk->super());
+    superk = superk->super() == nullptr ? nullptr : InstanceKlass::cast(superk->super());
   }
 
   return superk;
@@ -388,7 +388,7 @@ bool klassVtable::update_inherited_vtable(Thread* current,
 
   InstanceKlass* klass = ik();
 
-  Array<int>* def_vtable_indices = NULL;
+  Array<int>* def_vtable_indices = nullptr;
   bool is_default = false;
 
   // default methods are non-private concrete methods in superinterfaces which are added
@@ -400,7 +400,7 @@ bool klassVtable::update_inherited_vtable(Thread* current,
     is_default = true;
     def_vtable_indices = klass->default_vtable_indices();
     assert(!target_method->is_private(), "private interface method flagged as default");
-    assert(def_vtable_indices != NULL, "def vtable alloc?");
+    assert(def_vtable_indices != nullptr, "def vtable alloc?");
     assert(default_index <= def_vtable_indices->length(), "def vtable len?");
   } else {
     assert(klass == target_method->method_holder(), "caller resp.");
@@ -438,7 +438,7 @@ bool klassVtable::update_inherited_vtable(Thread* current,
 
   // we need a new entry if there is no superclass
   Klass* super = klass->super();
-  if (super == NULL) {
+  if (super == nullptr) {
     return allocate_new;
   }
 
@@ -451,8 +451,8 @@ bool klassVtable::update_inherited_vtable(Thread* current,
   Symbol* signature = target_method->signature();
 
   Klass* target_klass = target_method->method_holder();
-  assert(target_klass != NULL, "impossible");
-  if (target_klass == NULL) {
+  assert(target_klass != nullptr, "impossible");
+  if (target_klass == nullptr) {
     target_klass = _klass;
   }
 
@@ -491,7 +491,7 @@ bool klassVtable::update_inherited_vtable(Thread* current,
            (klass->major_version() >= VTABLE_TRANSITIVE_OVERRIDE_VERSION &&
              (super_klass = find_transitive_override(super_klass,
                                                      target_method, i, target_loader,
-                                                     target_classname)) != NULL))) {
+                                                     target_classname)) != nullptr))) {
 
         // Package private methods always need a new entry to root their own
         // overriding. They may also override other methods.
@@ -504,7 +504,7 @@ bool klassVtable::update_inherited_vtable(Thread* current,
         // super class or interface.
         put_method_at(target_method(), i);
         // Save super for constraint checking.
-        if (supers != NULL) {
+        if (supers != nullptr) {
           supers->at_put(i, super_klass);
         }
 
@@ -512,7 +512,7 @@ bool klassVtable::update_inherited_vtable(Thread* current,
         if (!is_default) {
           target_method->set_vtable_index(i);
         } else {
-          if (def_vtable_indices != NULL) {
+          if (def_vtable_indices != nullptr) {
             if (is_preinitialized_vtable()) {
               // At runtime initialize_vtable is rerun as part of link_class_impl()
               // for a shared class loaded by the non-boot loader.
@@ -550,9 +550,9 @@ void klassVtable::put_method_at(Method* m, int index) {
       ResourceMark rm;
       LogTarget(Trace, vtables) lt;
       LogStream ls(lt);
-      const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
+      const char* sig = (m != nullptr) ? m->name_and_sig_as_C_string() : "<null>";
       ls.print("adding %s at index %d, flags: ", sig, index);
-      if (m != NULL) {
+      if (m != nullptr) {
         m->print_linkage_flags(&ls);
       }
       ls.cr();
@@ -568,7 +568,7 @@ void klassVtable::check_constraints(GrowableArray<InstanceKlass*>* supers, TRAPS
   for (int i = 0; i < length(); i++) {
     methodHandle target_method(THREAD, unchecked_method_at(i));
     InstanceKlass* super_klass = supers->at(i);
-    if (target_method() != NULL && super_klass != NULL) {
+    if (target_method() != nullptr && super_klass != nullptr) {
       // Do not check loader constraints for overpass methods because overpass
       // methods are created by the jvm to throw exceptions.
       if (!target_method->is_overpass()) {
@@ -589,7 +589,7 @@ void klassVtable::check_constraints(GrowableArray<InstanceKlass*>* supers, TRAPS
                                                       _klass,
                                                       target_loader, super_loader,
                                                       true);
-          if (failed_type_symbol != NULL) {
+          if (failed_type_symbol != nullptr) {
             stringStream ss;
             ss.print("loader constraint violation for class %s: when selecting "
                      "overriding method '", _klass->external_name());
@@ -615,7 +615,7 @@ void klassVtable::check_constraints(GrowableArray<InstanceKlass*>* supers, TRAPS
 void klassVtable::initialize_vtable_and_check_constraints(TRAPS) {
   // Save a superclass from each vtable entry to do constraint checking
   ResourceMark rm(THREAD);
-  GrowableArray<InstanceKlass*>* supers = new GrowableArray<InstanceKlass*>(_length, _length, NULL);
+  GrowableArray<InstanceKlass*>* supers = new GrowableArray<InstanceKlass*>(_length, _length, nullptr);
   initialize_vtable(supers);
   check_constraints(supers, CHECK);
 }
@@ -660,7 +660,7 @@ bool klassVtable::needs_new_vtable_entry(Method* target_method,
 
   // Concrete interface methods do not need new entries, they override
   // abstract method entries using default inheritance rules
-  if (target_method->method_holder() != NULL &&
+  if (target_method->method_holder() != nullptr &&
       target_method->method_holder()->is_interface()  &&
       !target_method->is_abstract()) {
     assert(target_method->is_default_method(),
@@ -669,7 +669,7 @@ bool klassVtable::needs_new_vtable_entry(Method* target_method,
   }
 
   // we need a new entry if there is no superclass
-  if (super == NULL) {
+  if (super == nullptr) {
     return true;
   }
 
@@ -684,14 +684,14 @@ bool klassVtable::needs_new_vtable_entry(Method* target_method,
   Symbol* name = target_method->name();
   Symbol* signature = target_method->signature();
   const Klass* k = super;
-  Method* super_method = NULL;
-  InstanceKlass *holder = NULL;
-  Method* recheck_method =  NULL;
+  Method* super_method = nullptr;
+  InstanceKlass *holder = nullptr;
+  Method* recheck_method =  nullptr;
   bool found_pkg_prvt_method = false;
-  while (k != NULL) {
+  while (k != nullptr) {
     // lookup through the hierarchy for a method with matching name and sign.
     super_method = InstanceKlass::cast(k)->lookup_method(name, signature);
-    if (super_method == NULL) {
+    if (super_method == nullptr) {
       break; // we still have to search for a matching miranda method
     }
     // get the class holding the matching method
@@ -743,7 +743,7 @@ bool klassVtable::needs_new_vtable_entry(Method* target_method,
   // this check for all access permissions.
   const InstanceKlass *sk = InstanceKlass::cast(super);
   if (sk->has_miranda_methods()) {
-    if (sk->lookup_method_in_all_interfaces(name, signature, Klass::DefaultsLookupMode::find) != NULL) {
+    if (sk->lookup_method_in_all_interfaces(name, signature, Klass::DefaultsLookupMode::find) != nullptr) {
       return false; // found a matching miranda; we do not need a new entry
     }
   }
@@ -849,14 +849,14 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
   if (InstanceKlass::find_local_method(class_methods, name, signature,
                                        Klass::OverpassLookupMode::find,
                                        Klass::StaticLookupMode::skip,
-                                       Klass::PrivateLookupMode::skip) != NULL)
+                                       Klass::PrivateLookupMode::skip) != nullptr)
   {
     return false;
   }
 
   // Check local default methods
-  if ((default_methods != NULL) &&
-    (InstanceKlass::find_method(default_methods, name, signature) != NULL))
+  if ((default_methods != nullptr) &&
+    (InstanceKlass::find_method(default_methods, name, signature) != nullptr))
    {
      return false;
    }
@@ -866,14 +866,14 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
   // Overpasses may or may not exist for supers for pass 1,
   // they should have been created for pass 2 and later.
 
-  for (const Klass* cursuper = super; cursuper != NULL; cursuper = cursuper->super())
+  for (const Klass* cursuper = super; cursuper != nullptr; cursuper = cursuper->super())
   {
      Method* found_mth = InstanceKlass::cast(cursuper)->find_local_method(name, signature,
                                                                           Klass::OverpassLookupMode::find,
                                                                           Klass::StaticLookupMode::skip,
                                                                           Klass::PrivateLookupMode::skip);
      // Ignore non-public methods in java.lang.Object if klass is an interface.
-     if (found_mth != NULL && (!is_interface ||
+     if (found_mth != nullptr && (!is_interface ||
          !SystemDictionary::is_nonpublic_Object_method(found_mth))) {
        return false;
      }
@@ -915,10 +915,10 @@ void klassVtable::add_new_mirandas_to_lists(
       if (is_miranda(im, class_methods, default_methods, super, is_interface)) { // is it a miranda at all?
         const InstanceKlass *sk = InstanceKlass::cast(super);
         // check if it is a duplicate of a super's miranda
-        if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::DefaultsLookupMode::find) == NULL) {
+        if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::DefaultsLookupMode::find) == nullptr) {
           new_mirandas->append(im);
         }
-        if (all_mirandas != NULL) {
+        if (all_mirandas != nullptr) {
           all_mirandas->append(im);
         }
       }
@@ -962,7 +962,7 @@ void klassVtable::get_mirandas(GrowableArray<Method*>* new_mirandas,
 int klassVtable::fill_in_mirandas(Thread* current, int initialized) {
   ResourceMark rm(current);
   GrowableArray<Method*> mirandas(20);
-  get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
+  get_mirandas(&mirandas, nullptr, ik()->super(), ik()->methods(),
                ik()->default_methods(), ik()->local_interfaces(),
                klass()->is_interface());
   for (int i = 0; i < mirandas.length(); i++) {
@@ -970,7 +970,7 @@ int klassVtable::fill_in_mirandas(Thread* current, int initialized) {
       Method* meth = mirandas.at(i);
       LogTarget(Trace, vtables) lt;
       LogStream ls(lt);
-      if (meth != NULL) {
+      if (meth != nullptr) {
         char* sig = meth->name_and_sig_as_C_string();
         ls.print("fill in mirandas with %s index %d, flags: ",
                      sig, initialized);
@@ -997,7 +997,7 @@ bool klassVtable::adjust_default_method(int vtable_index, Method* old_method, Me
   bool updated = false;
 
   Array<Method*>* default_methods = ik()->default_methods();
-  if (default_methods != NULL) {
+  if (default_methods != nullptr) {
     int len = default_methods->length();
     for (int idx = 0; idx < len; idx++) {
       if (vtable_index == ik()->default_vtable_indices()->at(idx)) {
@@ -1019,7 +1019,7 @@ void klassVtable::adjust_method_entries(bool * trace_name_printed) {
 
   for (int index = 0; index < length(); index++) {
     Method* old_method = unchecked_method_at(index);
-    if (old_method == NULL || !old_method->is_old()) {
+    if (old_method == nullptr || !old_method->is_old()) {
       continue; // skip uninteresting entries
     }
     assert(!old_method->is_deleted(), "vtable methods may not be deleted");
@@ -1052,7 +1052,7 @@ bool klassVtable::check_no_old_or_obsolete_entries() {
 
   for (int i = 0; i < length(); i++) {
     Method* m = unchecked_method_at(i);
-    if (m != NULL &&
+    if (m != nullptr &&
         (NOT_PRODUCT(!m->is_valid() ||) m->is_old() || m->is_obsolete())) {
       log_trace(redefine, class, update, vtables)
         ("vtable check found old method entry: class: %s old: %d obsolete: %d, method: %s",
@@ -1067,7 +1067,7 @@ void klassVtable::dump_vtable() {
   tty->print_cr("vtable dump --");
   for (int i = 0; i < length(); i++) {
     Method* m = unchecked_method_at(i);
-    if (m != NULL) {
+    if (m != nullptr) {
       tty->print("      (%5d)  ", i);
       m->access_flags().print_on(tty);
       if (m->is_default_method()) {
@@ -1089,7 +1089,7 @@ void klassVtable::dump_vtable() {
 
 // Initialize a itableMethodEntry
 void itableMethodEntry::initialize(InstanceKlass* klass, Method* m) {
-  if (m == NULL) return;
+  if (m == nullptr) return;
 
 #ifdef ASSERT
   if (MetaspaceShared::is_in_shared_metaspace((void*)&_method) &&
@@ -1112,7 +1112,7 @@ klassItable::klassItable(InstanceKlass* klass) {
 
   if (klass->itable_length() > 0) {
     itableOffsetEntry* offset_entry = (itableOffsetEntry*)klass->start_of_itable();
-    if (offset_entry  != NULL && offset_entry->interface_klass() != NULL) { // Check that itable is initialized
+    if (offset_entry  != nullptr && offset_entry->interface_klass() != nullptr) { // Check that itable is initialized
       // First offset entry points to the first method_entry
       intptr_t* method_entry  = (intptr_t *)(((address)klass) + offset_entry->offset());
       intptr_t* end         = klass->end_of_itable();
@@ -1161,14 +1161,14 @@ void klassItable::initialize_itable(GrowableArray<Method*>* supers) {
     for(int i = 0; i < num_interfaces; i++) {
       itableOffsetEntry* ioe = offset_entry(i);
       InstanceKlass* interf = ioe->interface_klass();
-      assert(interf != NULL && ioe->offset() != 0, "bad offset entry in itable");
+      assert(interf != nullptr && ioe->offset() != 0, "bad offset entry in itable");
       initialize_itable_for_interface(ioe->offset(), interf, supers,
                        (ioe->offset() - offset_entry(0)->offset())/wordSize);
     }
   }
   // Check that the last entry is empty
   itableOffsetEntry* ioe = offset_entry(size_offset_table() - 1);
-  guarantee(ioe->interface_klass() == NULL && ioe->offset() == 0, "terminator entry missing");
+  guarantee(ioe->interface_klass() == nullptr && ioe->offset() == 0, "terminator entry missing");
 }
 
 void klassItable::check_constraints(GrowableArray<Method*>* supers, TRAPS) {
@@ -1179,7 +1179,7 @@ void klassItable::check_constraints(GrowableArray<Method*>* supers, TRAPS) {
     Method* target = ime->method();
     Method* interface_method = supers->at(i); // method overridden
 
-    if (target != NULL && interface_method != NULL) {
+    if (target != nullptr && interface_method != nullptr) {
       InstanceKlass* method_holder = target->method_holder();
       InstanceKlass* interf = interface_method->method_holder();
       HandleMark hm(THREAD);
@@ -1194,7 +1194,7 @@ void klassItable::check_constraints(GrowableArray<Method*>* supers, TRAPS) {
                                                     method_holder_loader,
                                                     interface_loader,
                                                     true);
-        if (failed_type_symbol != NULL) {
+        if (failed_type_symbol != nullptr) {
           stringStream ss;
           ss.print("loader constraint violation in interface itable"
                    " initialization for class %s: when selecting method '",
@@ -1223,7 +1223,7 @@ void klassItable::initialize_itable_and_check_constraints(TRAPS) {
   // Save a super interface from each itable entry to do constraint checking
   ResourceMark rm(THREAD);
   GrowableArray<Method*>* supers =
-    new GrowableArray<Method*>(_size_method_table, _size_method_table, NULL);
+    new GrowableArray<Method*>(_size_method_table, _size_method_table, nullptr);
   initialize_itable(supers);
   check_constraints(supers, CHECK);
 }
@@ -1259,7 +1259,7 @@ int klassItable::assign_itable_indices_for_interface(InstanceKlass* klass) {
         ResourceMark rm;
         LogTarget(Trace, itables) lt;
         LogStream ls(lt);
-        assert(m != NULL, "methods can never be null");
+        assert(m != nullptr, "methods can never be null");
         const char* sig = m->name_and_sig_as_C_string();
         if (m->has_vtable_index()) {
           ls.print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
@@ -1321,7 +1321,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Insta
   int ime_count = method_count_for_interface(interf);
   for (int i = 0; i < nof_methods; i++) {
     Method* m = methods->at(i);
-    Method* target = NULL;
+    Method* target = nullptr;
     if (m->has_itable_index()) {
       // This search must match the runtime resolution, i.e. selection search for invokeinterface
       // to correctly enforce loader constraints for interface method inheritance.
@@ -1332,11 +1332,11 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Insta
       target = LinkResolver::lookup_instance_method_in_klasses(_klass, m->name(), m->signature(),
                                                                Klass::PrivateLookupMode::skip);
     }
-    if (target == NULL || !target->is_public() || target->is_abstract() || target->is_overpass()) {
-      assert(target == NULL || !target->is_overpass() || target->is_public(),
+    if (target == nullptr || !target->is_public() || target->is_abstract() || target->is_overpass()) {
+      assert(target == nullptr || !target->is_overpass() || target->is_public(),
              "Non-public overpass method!");
       // Entry does not resolve. Leave it empty for AbstractMethodError or other error.
-      if (!(target == NULL) && !target->is_public()) {
+      if (!(target == nullptr) && !target->is_public()) {
         // Stuff an IllegalAccessError throwing method in there instead.
         itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()].
             initialize(_klass, Universe::throw_illegal_access_error());
@@ -1348,14 +1348,14 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Insta
 
       // Save super interface method to perform constraint checks.
       // The method is in the error message, that's why.
-      if (supers != NULL) {
+      if (supers != nullptr) {
         supers->at_put(start_offset + ime_num, m);
       }
 
       itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(_klass, target);
       if (log_develop_is_enabled(Trace, itables)) {
         ResourceMark rm;
-        if (target != NULL) {
+        if (target != nullptr) {
           LogTarget(Trace, itables) lt;
           LogStream ls(lt);
           char* sig = target->name_and_sig_as_C_string();
@@ -1379,7 +1379,7 @@ void klassItable::adjust_method_entries(bool * trace_name_printed) {
 
   for (int i = 0; i < _size_method_table; i++, ime++) {
     Method* old_method = ime->method();
-    if (old_method == NULL || !old_method->is_old()) {
+    if (old_method == nullptr || !old_method->is_old()) {
       continue; // skip uninteresting entries
     }
     assert(!old_method->is_deleted(), "itable methods may not be deleted");
@@ -1402,7 +1402,7 @@ bool klassItable::check_no_old_or_obsolete_entries() {
 
   for (int i = 0; i < _size_method_table; i++) {
     Method* m = ime->method();
-    if (m != NULL &&
+    if (m != nullptr &&
         (NOT_PRODUCT(!m->is_valid() ||) m->is_old() || m->is_obsolete())) {
       log_trace(redefine, class, update, itables)
         ("itable check found old method entry: class: %s old: %d obsolete: %d, method: %s",
@@ -1419,7 +1419,7 @@ void klassItable::dump_itable() {
   tty->print_cr("itable dump --");
   for (int i = 0; i < _size_method_table; i++) {
     Method* m = ime->method();
-    if (m != NULL) {
+    if (m != nullptr) {
       tty->print("      (%5d)  ", i);
       m->access_flags().print_on(tty);
       if (m->is_default_method()) {
@@ -1570,7 +1570,7 @@ void klassVtable::verify(outputStream* st, bool forced) {
   for (int i = 0; i < _length; i++) table()[i].verify(this, st);
   // verify consistency with superKlass vtable
   Klass* super = _klass->super();
-  if (super != NULL) {
+  if (super != nullptr) {
     InstanceKlass* sk = InstanceKlass::cast(super);
     klassVtable vt = sk->vtable();
     for (int i = 0; i < vt.length(); i++) {
@@ -1602,9 +1602,9 @@ void vtableEntry::verify(klassVtable* vt, outputStream* st) {
   Klass* vtklass = vt->klass();
   if (vtklass->is_instance_klass() &&
      (InstanceKlass::cast(vtklass)->major_version() >= klassVtable::VTABLE_TRANSITIVE_OVERRIDE_VERSION)) {
-    assert(method() != NULL, "must have set method");
+    assert(method() != nullptr, "must have set method");
   }
-  if (method() != NULL) {
+  if (method() != nullptr) {
     method()->verify();
     // we sub_type, because it could be a miranda method
     if (!vtklass->is_subtype_of(method()->method_holder())) {
diff --git a/src/hotspot/share/oops/klassVtable.hpp b/src/hotspot/share/oops/klassVtable.hpp
index 73dd9ae61fa..256268236a8 100644
--- a/src/hotspot/share/oops/klassVtable.hpp
+++ b/src/hotspot/share/oops/klassVtable.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@ class klassVtable {
   int index_of_miranda(Symbol* name, Symbol* signature);
 
   // initialize vtable of a new klass
-  void initialize_vtable(GrowableArray<InstanceKlass*>* supers = NULL);
+  void initialize_vtable(GrowableArray<InstanceKlass*>* supers = nullptr);
   void initialize_vtable_and_check_constraints(TRAPS);
 
   // computes vtable length (in words) and the number of miranda methods
@@ -190,8 +190,8 @@ class vtableEntry {
 
  private:
   Method* _method;
-  void set(Method* method)  { assert(method != NULL, "use clear"); _method = method; }
-  void clear()                { _method = NULL; }
+  void set(Method* method)  { assert(method != nullptr, "use clear"); _method = method; }
+  void clear()                { _method = nullptr; }
   void print()                                        PRODUCT_RETURN;
   void verify(klassVtable* vt, outputStream* st);
 
@@ -201,7 +201,7 @@ class vtableEntry {
 
 inline Method* klassVtable::method_at(int i) const {
   assert(i >= 0 && i < _length, "index out of bounds");
-  assert(table()[i].method() != NULL, "should not be null");
+  assert(table()[i].method() != nullptr, "should not be null");
   assert(((Metadata*)table()[i].method())->is_method(), "should be method");
   return table()[i].method();
 }
@@ -246,7 +246,7 @@ class itableMethodEntry {
   Method* method() const { return _method; }
   Method**method_addr() { return &_method; }
 
-  void clear()             { _method = NULL; }
+  void clear()             { _method = nullptr; }
 
   void initialize(InstanceKlass* klass, Method* method);
 
@@ -298,7 +298,7 @@ class klassItable {
 
   // Initialization
   void initialize_itable_and_check_constraints(TRAPS);
-  void initialize_itable(GrowableArray<Method*>* supers = NULL);
+  void initialize_itable(GrowableArray<Method*>* supers = nullptr);
 
 #if INCLUDE_JVMTI
   // RedefineClasses() API support:
diff --git a/src/hotspot/share/oops/markWord.cpp b/src/hotspot/share/oops/markWord.cpp
index 30dd8f55a11..ad49fea3076 100644
--- a/src/hotspot/share/oops/markWord.cpp
+++ b/src/hotspot/share/oops/markWord.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,8 +69,8 @@ void markWord::print_on(outputStream* st, bool print_monitor_info) const {
     st->print(" monitor(" INTPTR_FORMAT ")=", value());
     if (print_monitor_info) {
       ObjectMonitor* mon = monitor();
-      if (mon == NULL) {
-        st->print("NULL (this should never be seen!)");
+      if (mon == nullptr) {
+        st->print("null (this should never be seen!)");
       } else {
         mon->print_on(st);
       }
diff --git a/src/hotspot/share/oops/metadata.hpp b/src/hotspot/share/oops/metadata.hpp
index 7e6192b56e2..c118ade8586 100644
--- a/src/hotspot/share/oops/metadata.hpp
+++ b/src/hotspot/share/oops/metadata.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,8 +54,8 @@ class Metadata : public MetaspaceObj {
   void print_value() const;
 
   static void print_value_on_maybe_null(outputStream* st, const Metadata* m) {
-    if (NULL == m)
-      st->print("NULL");
+    if (nullptr == m)
+      st->print("null");
     else
       m->print_value_on(st);
   }
diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp
index b5355a156bb..90fb0c2616b 100644
--- a/src/hotspot/share/oops/method.cpp
+++ b/src/hotspot/share/oops/method.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -107,18 +107,18 @@ Method::Method(ConstMethod* xconst, AccessFlags access_flags, Symbol* name) {
   set_dont_inline(false);
   set_changes_current_thread(false);
   set_has_injected_profile(false);
-  set_method_data(NULL);
+  set_method_data(nullptr);
   clear_method_counters();
   set_vtable_index(Method::garbage_vtable_index);
 
   // Fix and bury in Method*
-  set_interpreter_entry(NULL); // sets i2i entry and from_int
-  set_adapter_entry(NULL);
+  set_interpreter_entry(nullptr); // sets i2i entry and from_int
+  set_adapter_entry(nullptr);
   Method::clear_code(); // from_c/from_i get set to c2i/i2i
 
   if (access_flags.is_native()) {
     clear_native_function();
-    set_signature_handler(NULL);
+    set_signature_handler(nullptr);
   }
 
   NOT_PRODUCT(set_compiled_invocation_count(0);)
@@ -130,13 +130,13 @@ Method::Method(ConstMethod* xconst, AccessFlags access_flags, Symbol* name) {
 // we've walked the code cache.
 void Method::deallocate_contents(ClassLoaderData* loader_data) {
   MetadataFactory::free_metadata(loader_data, constMethod());
-  set_constMethod(NULL);
+  set_constMethod(nullptr);
   MetadataFactory::free_metadata(loader_data, method_data());
-  set_method_data(NULL);
+  set_method_data(nullptr);
   MetadataFactory::free_metadata(loader_data, method_counters());
   clear_method_counters();
   // The nmethod will be gone when we get here.
-  if (code() != NULL) _code = NULL;
+  if (code() != nullptr) _code = nullptr;
 }
 
 void Method::release_C_heap_structures() {
@@ -149,23 +149,23 @@ void Method::release_C_heap_structures() {
 }
 
 address Method::get_i2c_entry() {
-  assert(adapter() != NULL, "must have");
+  assert(adapter() != nullptr, "must have");
   return adapter()->get_i2c_entry();
 }
 
 address Method::get_c2i_entry() {
-  assert(adapter() != NULL, "must have");
+  assert(adapter() != nullptr, "must have");
   return adapter()->get_c2i_entry();
 }
 
 address Method::get_c2i_unverified_entry() {
-  assert(adapter() != NULL, "must have");
+  assert(adapter() != nullptr, "must have");
   return adapter()->get_c2i_unverified_entry();
 }
 
 address Method::get_c2i_no_clinit_check_entry() {
   assert(VM_Version::supports_fast_class_init_checks(), "");
-  assert(adapter() != NULL, "must have");
+  assert(adapter() != nullptr, "must have");
   return adapter()->get_c2i_no_clinit_check_entry();
 }
 
@@ -233,7 +233,7 @@ int Method::fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_kla
   if (log_is_enabled(Debug, exceptions)) {
     ResourceMark rm(THREAD);
     log_debug(exceptions)("Looking for catch handler for exception of type \"%s\" in method \"%s\"",
-                          ex_klass == NULL ? "NULL" : ex_klass->external_name(), mh->name()->as_C_string());
+                          ex_klass == nullptr ? "null" : ex_klass->external_name(), mh->name()->as_C_string());
   }
   // exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index)
   // access exception table
@@ -260,14 +260,14 @@ int Method::fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_kla
         if (log_is_enabled(Info, exceptions)) {
           ResourceMark rm(THREAD);
           log_info(exceptions)("Found catch-all handler for exception of type \"%s\" in method \"%s\" at BCI: %d",
-                               ex_klass == NULL ? "NULL" : ex_klass->external_name(), mh->name()->as_C_string(), handler_bci);
+                               ex_klass == nullptr ? "null" : ex_klass->external_name(), mh->name()->as_C_string(), handler_bci);
         }
         return handler_bci;
-      } else if (ex_klass == NULL) {
+      } else if (ex_klass == nullptr) {
         // Is this even possible?
         if (log_is_enabled(Info, exceptions)) {
           ResourceMark rm(THREAD);
-          log_info(exceptions)("NULL exception class is implicitly caught by handler in method \"%s\" at BCI: %d",
+          log_info(exceptions)("null exception class is implicitly caught by handler in method \"%s\" at BCI: %d",
                                mh()->name()->as_C_string(), handler_bci);
         }
         return handler_bci;
@@ -289,12 +289,12 @@ int Method::fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_kla
           }
           return handler_bci;
         }
-        assert(k != NULL, "klass not loaded");
+        assert(k != nullptr, "klass not loaded");
         if (ex_klass->is_subtype_of(k)) {
           if (log_is_enabled(Info, exceptions)) {
             ResourceMark rm(THREAD);
             log_info(exceptions)("Found matching handler for exception of type \"%s\" in method \"%s\" at BCI: %d",
-                                 ex_klass == NULL ? "NULL" : ex_klass->external_name(), mh->name()->as_C_string(), handler_bci);
+                                 ex_klass == nullptr ? "null" : ex_klass->external_name(), mh->name()->as_C_string(), handler_bci);
           }
           return handler_bci;
         }
@@ -369,7 +369,7 @@ address Method::bcp_from(int bci) const {
 }
 
 address Method::bcp_from(address bcp) const {
-  if (is_native() && bcp == NULL) {
+  if (is_native() && bcp == nullptr) {
     return code_base();
   } else {
     return bcp;
@@ -464,11 +464,11 @@ static Method* find_prefixed_native(Klass* k, Symbol* name, Symbol* signature, T
     strcpy(trial_name_str, prefix);
     strcat(trial_name_str, name_str);
     TempNewSymbol trial_name = SymbolTable::probe(trial_name_str, trial_len);
-    if (trial_name == NULL) {
+    if (trial_name == nullptr) {
       continue; // no such symbol, so this prefix wasn't used, try the next prefix
     }
     method = k->lookup_method(trial_name, signature);
-    if (method == NULL) {
+    if (method == nullptr) {
       continue; // signature doesn't match, try the next prefix
     }
     if (method->is_native()) {
@@ -480,12 +480,12 @@ static Method* find_prefixed_native(Klass* k, Symbol* name, Symbol* signature, T
     name_str = trial_name_str;
   }
 #endif // INCLUDE_JVMTI
-  return NULL; // not found
+  return nullptr; // not found
 }
 
 bool Method::register_native(Klass* k, Symbol* name, Symbol* signature, address entry, TRAPS) {
   Method* method = k->lookup_method(name, signature);
-  if (method == NULL) {
+  if (method == nullptr) {
     ResourceMark rm(THREAD);
     stringStream st;
     st.print("Method '");
@@ -496,7 +496,7 @@ bool Method::register_native(Klass* k, Symbol* name, Symbol* signature, address
   if (!method->is_native()) {
     // trying to register to a non-native method, see if a JVM TI agent has added prefix(es)
     method = find_prefixed_native(k, name, signature, THREAD);
-    if (method == NULL) {
+    if (method == nullptr) {
       ResourceMark rm(THREAD);
       stringStream st;
       st.print("Method '");
@@ -506,7 +506,7 @@ bool Method::register_native(Klass* k, Symbol* name, Symbol* signature, address
     }
   }
 
-  if (entry != NULL) {
+  if (entry != nullptr) {
     method->set_native_function(entry, native_bind_event_is_interesting);
   } else {
     method->clear_native_function();
@@ -524,14 +524,14 @@ bool Method::was_executed_more_than(int n) {
   // Invocation counter is reset when the Method* is compiled.
   // If the method has compiled code we therefore assume it has
   // be executed more than n times.
-  if (is_accessor() || is_empty_method() || (code() != NULL)) {
+  if (is_accessor() || is_empty_method() || (code() != nullptr)) {
     // interpreter doesn't bump invocation counter of trivial methods
     // compiler does not bump invocation counter of compiled methods
     return true;
   }
-  else if ((method_counters() != NULL &&
+  else if ((method_counters() != nullptr &&
             method_counters()->invocation_counter()->carry()) ||
-           (method_data() != NULL &&
+           (method_data() != nullptr &&
             method_data()->invocation_counter()->carry())) {
     // The carry bit is set when the counter overflows and causes
     // a compilation to occur.  We don't know how many times
@@ -568,7 +568,7 @@ void Method::print_invocation_count() {
   tty->print_cr ("  invocation_counter:           " INT32_FORMAT_W(11), invocation_count());
   tty->print_cr ("  backedge_counter:             " INT32_FORMAT_W(11), backedge_count());
 
-  if (method_data() != NULL) {
+  if (method_data() != nullptr) {
     tty->print_cr ("  decompile_count:              " UINT32_FORMAT_W(11), method_data()->decompile_count());
   }
 
@@ -614,7 +614,7 @@ void Method::build_profiling_method_data(const methodHandle& method, TRAPS) {
 MethodCounters* Method::build_method_counters(Thread* current, Method* m) {
   // Do not profile the method if metaspace has hit an OOM previously
   if (ClassLoaderDataGraph::has_metaspace_oom()) {
-    return NULL;
+    return nullptr;
   }
 
   methodHandle mh(current, m);
@@ -633,10 +633,10 @@ MethodCounters* Method::build_method_counters(Thread* current, Method* m) {
     counters = MethodCounters::allocate_no_exception(mh);
   }
 
-  if (counters == NULL) {
+  if (counters == nullptr) {
     CompileBroker::log_metaspace_failure();
     ClassLoaderDataGraph::set_metaspace_oom(true);
-    return NULL;
+    return nullptr;
   }
 
   if (!mh->init_method_counters(counters)) {
@@ -793,7 +793,7 @@ bool Method::is_final_method() const {
 }
 
 bool Method::is_default_method() const {
-  if (method_holder() != NULL &&
+  if (method_holder() != nullptr &&
       method_holder()->is_interface() &&
       !is_abstract() && !is_private()) {
     return true;
@@ -971,7 +971,7 @@ bool Method::is_klass_loaded_by_klass_index(int klass_index) const {
     Symbol* klass_name = constants()->klass_name_at(klass_index);
     Handle loader(thread, method_holder()->class_loader());
     Handle prot  (thread, method_holder()->protection_domain());
-    return SystemDictionary::find_instance_klass(thread, klass_name, loader, prot) != NULL;
+    return SystemDictionary::find_instance_klass(thread, klass_name, loader, prot) != nullptr;
   } else {
     return true;
   }
@@ -989,7 +989,7 @@ bool Method::is_klass_loaded(int refinfo_index, bool must_be_resolved) const {
 
 
 void Method::set_native_function(address function, bool post_event_flag) {
-  assert(function != NULL, "use clear_native_function to unregister natives");
+  assert(function != nullptr, "use clear_native_function to unregister natives");
   assert(!is_special_native_intrinsic() || function == SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), "");
   address* native_function = native_function_addr();
 
@@ -998,7 +998,7 @@ void Method::set_native_function(address function, bool post_event_flag) {
   address current = *native_function;
   if (current == function) return;
   if (post_event_flag && JvmtiExport::should_post_native_method_bind() &&
-      function != NULL) {
+      function != nullptr) {
     // native_method_throw_unsatisfied_link_error_entry() should only
     // be passed when post_event_flag is false.
     assert(function !=
@@ -1013,7 +1013,7 @@ void Method::set_native_function(address function, bool post_event_flag) {
   // use the latest registered method -> check if a stub already has been generated.
   // If so, we have to make it not_entrant.
   CompiledMethod* nm = code(); // Put it into local variable to guard against concurrent updates
-  if (nm != NULL) {
+  if (nm != nullptr) {
     nm->make_not_entrant();
   }
 }
@@ -1023,7 +1023,7 @@ bool Method::has_native_function() const {
   if (is_special_native_intrinsic())
     return false;  // special-cased in SharedRuntime::generate_native_wrapper
   address func = native_function();
-  return (func != NULL && func != SharedRuntime::native_method_throw_unsatisfied_link_error_entry());
+  return (func != nullptr && func != SharedRuntime::native_method_throw_unsatisfied_link_error_entry());
 }
 
 
@@ -1043,7 +1043,7 @@ void Method::set_signature_handler(address handler) {
 
 
 void Method::print_made_not_compilable(int comp_level, bool is_osr, bool report, const char* reason) {
-  assert(reason != NULL, "must provide a reason");
+  assert(reason != nullptr, "must provide a reason");
   if (PrintCompilation && report) {
     ttyLocker ttyl;
     tty->print("made not %scompilable on ", is_osr ? "OSR " : "");
@@ -1057,16 +1057,16 @@ void Method::print_made_not_compilable(int comp_level, bool is_osr, bool report,
     if (size > 0) {
       tty->print(" (%d bytes)", size);
     }
-    if (reason != NULL) {
+    if (reason != nullptr) {
       tty->print("   %s", reason);
     }
     tty->cr();
   }
-  if ((TraceDeoptimization || LogCompilation) && (xtty != NULL)) {
+  if ((TraceDeoptimization || LogCompilation) && (xtty != nullptr)) {
     ttyLocker ttyl;
     xtty->begin_elem("make_not_compilable thread='" UINTX_FORMAT "' osr='%d' level='%d'",
                      os::current_thread_id(), is_osr, comp_level);
-    if (reason != NULL) {
+    if (reason != nullptr) {
       xtty->print(" reason=\'%s\'", reason);
     }
     xtty->method(this);
@@ -1147,21 +1147,21 @@ void Method::set_not_osr_compilable(const char* reason, int comp_level, bool rep
 
 // Revert to using the interpreter and clear out the nmethod
 void Method::clear_code() {
-  // this may be NULL if c2i adapters have not been made yet
+  // this may be null if c2i adapters have not been made yet
   // Only should happen at allocate time.
-  if (adapter() == NULL) {
-    _from_compiled_entry    = NULL;
+  if (adapter() == nullptr) {
+    _from_compiled_entry    = nullptr;
   } else {
     _from_compiled_entry    = adapter()->get_c2i_entry();
   }
   OrderAccess::storestore();
   _from_interpreted_entry = _i2i_entry;
   OrderAccess::storestore();
-  _code = NULL;
+  _code = nullptr;
 }
 
 void Method::unlink_code(CompiledMethod *compare) {
-  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
+  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? nullptr : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
   // We need to check if either the _code or _from_compiled_code_entry_point
   // refer to this nmethod because there is a race in setting these two fields
   // in Method* as seen in bugid 4947125.
@@ -1172,7 +1172,7 @@ void Method::unlink_code(CompiledMethod *compare) {
 }
 
 void Method::unlink_code() {
-  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
+  MutexLocker ml(CompiledMethod_lock->owned_by_self() ? nullptr : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
   clear_code();
 }
 
@@ -1180,19 +1180,19 @@ void Method::unlink_code() {
 // Called by class data sharing to remove any entry points (which are not shared)
 void Method::unlink_method() {
   Arguments::assert_is_dumping_archive();
-  _code = NULL;
-  _adapter = NULL;
-  _i2i_entry = NULL;
-  _from_compiled_entry = NULL;
-  _from_interpreted_entry = NULL;
+  _code = nullptr;
+  _adapter = nullptr;
+  _i2i_entry = nullptr;
+  _from_compiled_entry = nullptr;
+  _from_interpreted_entry = nullptr;
 
   if (is_native()) {
-    *native_function_addr() = NULL;
-    set_signature_handler(NULL);
+    *native_function_addr() = nullptr;
+    set_signature_handler(nullptr);
   }
   NOT_PRODUCT(set_compiled_invocation_count(0);)
 
-  set_method_data(NULL);
+  set_method_data(nullptr);
   clear_method_counters();
 }
 #endif
@@ -1202,17 +1202,17 @@ void Method::unlink_method() {
 void Method::link_method(const methodHandle& h_method, TRAPS) {
   // If the code cache is full, we may reenter this function for the
   // leftover methods that weren't linked.
-  if (adapter() != NULL) {
+  if (adapter() != nullptr) {
     return;
   }
-  assert( _code == NULL, "nothing compiled yet" );
+  assert( _code == nullptr, "nothing compiled yet" );
 
   // Setup interpreter entrypoint
   assert(this == h_method(), "wrong h_method()" );
 
-  assert(adapter() == NULL, "init'd to NULL");
+  assert(adapter() == nullptr, "init'd to null");
   address entry = Interpreter::entry_for_method(h_method);
-  assert(entry != NULL, "interpreter entry must be non-null");
+  assert(entry != nullptr, "interpreter entry must be non-null");
   // Sets both _i2i_entry and _from_interpreted_entry
   set_interpreter_entry(entry);
 
@@ -1237,9 +1237,9 @@ void Method::link_method(const methodHandle& h_method, TRAPS) {
 
   if (h_method->is_continuation_native_intrinsic()) {
     // the entry points to this method will be set in set_code, called when first resolving this method
-    _from_interpreted_entry = NULL;
-    _from_compiled_entry = NULL;
-    _i2i_entry = NULL;
+    _from_interpreted_entry = nullptr;
+    _from_compiled_entry = nullptr;
+    _i2i_entry = nullptr;
   }
 }
 
@@ -1248,7 +1248,7 @@ address Method::make_adapters(const methodHandle& mh, TRAPS) {
   // small (generally < 100 bytes) and quick to make (and cached and shared)
   // so making them eagerly shouldn't be too expensive.
   AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
-  if (adapter == NULL ) {
+  if (adapter == nullptr ) {
     if (!is_init_completed()) {
       // Don't throw exceptions during VM initialization because java.lang.* classes
       // might not have been initialized, causing problems when constructing the
@@ -1273,7 +1273,7 @@ address Method::make_adapters(const methodHandle& mh, TRAPS) {
 // This function must not hit a safepoint!
 address Method::verified_code_entry() {
   debug_only(NoSafepointVerifier nsv;)
-  assert(_from_compiled_entry != NULL, "must be set");
+  assert(_from_compiled_entry != nullptr, "must be set");
   return _from_compiled_entry;
 }
 
@@ -1283,7 +1283,7 @@ address Method::verified_code_entry() {
 bool Method::check_code() const {
   // cached in a register or local.  There's a race on the value of the field.
   CompiledMethod *code = Atomic::load_acquire(&_code);
-  return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
+  return code == nullptr || (code->method() == nullptr) || (code->method() == (Method*)this && !code->is_osr_method());
 }
 
 // Install compiled code.  Instantly it can execute.
@@ -1292,7 +1292,7 @@ void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
   assert( code, "use clear_code to remove code" );
   assert( mh->check_code(), "" );
 
-  guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
+  guarantee(mh->adapter() != nullptr, "Adapter blob must already exist!");
 
   // These writes must happen in this order, because the interpreter will
   // directly jump to from_interpreted_entry which jumps to an i2c adapter
@@ -1311,7 +1311,7 @@ void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
   OrderAccess::storestore();
 
   if (mh->is_continuation_native_intrinsic()) {
-    assert(mh->_from_interpreted_entry == NULL, "initialized incorrectly"); // see link_method
+    assert(mh->_from_interpreted_entry == nullptr, "initialized incorrectly"); // see link_method
 
     if (mh->is_continuation_enter_intrinsic()) {
       // This is the entry used when we're in interpreter-only mode; see InterpreterMacroAssembler::jump_from_interpreted
@@ -1339,7 +1339,7 @@ bool Method::is_overridden_in(Klass* k) const {
   // is a miranda method
   if (method_holder()->is_interface()) {
     // Check that method is not a miranda method
-    if (ik->lookup_method(name(), signature()) == NULL) {
+    if (ik->lookup_method(name(), signature()) == nullptr) {
       // No implementation exist - so miranda method
       return false;
     }
@@ -1496,12 +1496,12 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
 }
 
 Klass* Method::check_non_bcp_klass(Klass* klass) {
-  if (klass != NULL && klass->class_loader() != NULL) {
+  if (klass != nullptr && klass->class_loader() != nullptr) {
     if (klass->is_objArray_klass())
       klass = ObjArrayKlass::cast(klass)->bottom_klass();
     return klass;
   }
-  return NULL;
+  return nullptr;
 }
 
 
@@ -1614,12 +1614,12 @@ methodHandle Method::clone_with_new_data(const methodHandle& m, u_char* new_code
 }
 
 vmSymbolID Method::klass_id_for_intrinsics(const Klass* holder) {
-  // if loader is not the default loader (i.e., != NULL), we can't know the intrinsics
+  // if loader is not the default loader (i.e., non-null), we can't know the intrinsics
   // because we are not loading from core libraries
   // exception: the AES intrinsics come from lib/ext/sunjce_provider.jar
   // which does not use the class default class loader so we check for its loader here
   const InstanceKlass* ik = InstanceKlass::cast(holder);
-  if ((ik->class_loader() != NULL) && !SystemDictionary::is_platform_class_loader(ik->class_loader())) {
+  if ((ik->class_loader() != nullptr) && !SystemDictionary::is_platform_class_loader(ik->class_loader())) {
     return vmSymbolID::NO_SID;   // regardless of name, no intrinsics here
   }
 
@@ -1713,7 +1713,7 @@ bool Method::load_signature_classes(const methodHandle& m, TRAPS) {
           return false;
         }
       }
-      if( klass == NULL) { sig_is_loaded = false; }
+      if( klass == nullptr) { sig_is_loaded = false; }
     }
   }
   return sig_is_loaded;
@@ -1744,7 +1744,7 @@ static int method_comparator(Method* a, Method* b) {
 void Method::sort_methods(Array<Method*>* methods, bool set_idnums, method_comparator_func func) {
   int length = methods->length();
   if (length > 1) {
-    if (func == NULL) {
+    if (func == nullptr) {
       func = method_comparator;
     }
     {
@@ -1845,7 +1845,7 @@ bool CompressedLineNumberReadStream::read_pair() {
 
 Bytecodes::Code Method::orig_bytecode_at(int bci) const {
   BreakpointInfo* bp = method_holder()->breakpoints();
-  for (; bp != NULL; bp = bp->next()) {
+  for (; bp != nullptr; bp = bp->next()) {
     if (bp->match(this, bci)) {
       return bp->orig_bytecode();
     }
@@ -1860,7 +1860,7 @@ Bytecodes::Code Method::orig_bytecode_at(int bci) const {
 void Method::set_orig_bytecode_at(int bci, Bytecodes::Code code) {
   assert(code != Bytecodes::_breakpoint, "cannot patch breakpoints this way");
   BreakpointInfo* bp = method_holder()->breakpoints();
-  for (; bp != NULL; bp = bp->next()) {
+  for (; bp != nullptr; bp = bp->next()) {
     if (bp->match(this, bci)) {
       bp->set_orig_bytecode(code);
       // and continue, in case there is more than one
@@ -1879,16 +1879,16 @@ void Method::set_breakpoint(int bci) {
 
 static void clear_matches(Method* m, int bci) {
   InstanceKlass* ik = m->method_holder();
-  BreakpointInfo* prev_bp = NULL;
+  BreakpointInfo* prev_bp = nullptr;
   BreakpointInfo* next_bp;
-  for (BreakpointInfo* bp = ik->breakpoints(); bp != NULL; bp = next_bp) {
+  for (BreakpointInfo* bp = ik->breakpoints(); bp != nullptr; bp = next_bp) {
     next_bp = bp->next();
     // bci value of -1 is used to delete all breakpoints in method m (ex: clear_all_breakpoint).
     if (bci >= 0 ? bp->match(m, bci) : bp->match(m)) {
       // do this first:
       bp->clear(m);
       // unhook it
-      if (prev_bp != NULL)
+      if (prev_bp != nullptr)
         prev_bp->set_next(next_bp);
       else
         ik->set_breakpoints(next_bp);
@@ -1927,30 +1927,30 @@ void Method::clear_all_breakpoints() {
 int Method::invocation_count() const {
   MethodCounters* mcs = method_counters();
   MethodData* mdo = method_data();
-  if (((mcs != NULL) ? mcs->invocation_counter()->carry() : false) ||
-      ((mdo != NULL) ? mdo->invocation_counter()->carry() : false)) {
+  if (((mcs != nullptr) ? mcs->invocation_counter()->carry() : false) ||
+      ((mdo != nullptr) ? mdo->invocation_counter()->carry() : false)) {
     return InvocationCounter::count_limit;
   } else {
-    return ((mcs != NULL) ? mcs->invocation_counter()->count() : 0) +
-           ((mdo != NULL) ? mdo->invocation_counter()->count() : 0);
+    return ((mcs != nullptr) ? mcs->invocation_counter()->count() : 0) +
+           ((mdo != nullptr) ? mdo->invocation_counter()->count() : 0);
   }
 }
 
 int Method::backedge_count() const {
   MethodCounters* mcs = method_counters();
   MethodData* mdo = method_data();
-  if (((mcs != NULL) ? mcs->backedge_counter()->carry() : false) ||
-      ((mdo != NULL) ? mdo->backedge_counter()->carry() : false)) {
+  if (((mcs != nullptr) ? mcs->backedge_counter()->carry() : false) ||
+      ((mdo != nullptr) ? mdo->backedge_counter()->carry() : false)) {
     return InvocationCounter::count_limit;
   } else {
-    return ((mcs != NULL) ? mcs->backedge_counter()->count() : 0) +
-           ((mdo != NULL) ? mdo->backedge_counter()->count() : 0);
+    return ((mcs != nullptr) ? mcs->backedge_counter()->count() : 0) +
+           ((mdo != nullptr) ? mdo->backedge_counter()->count() : 0);
   }
 }
 
 int Method::highest_comp_level() const {
   const MethodCounters* mcs = method_counters();
-  if (mcs != NULL) {
+  if (mcs != nullptr) {
     return mcs->highest_comp_level();
   } else {
     return CompLevel_none;
@@ -1959,7 +1959,7 @@ int Method::highest_comp_level() const {
 
 int Method::highest_osr_comp_level() const {
   const MethodCounters* mcs = method_counters();
-  if (mcs != NULL) {
+  if (mcs != nullptr) {
     return mcs->highest_osr_comp_level();
   } else {
     return CompLevel_none;
@@ -1968,14 +1968,14 @@ int Method::highest_osr_comp_level() const {
 
 void Method::set_highest_comp_level(int level) {
   MethodCounters* mcs = method_counters();
-  if (mcs != NULL) {
+  if (mcs != nullptr) {
     mcs->set_highest_comp_level(level);
   }
 }
 
 void Method::set_highest_osr_comp_level(int level) {
   MethodCounters* mcs = method_counters();
-  if (mcs != NULL) {
+  if (mcs != nullptr) {
     mcs->set_highest_osr_comp_level(level);
   }
 }
@@ -1989,7 +1989,7 @@ BreakpointInfo::BreakpointInfo(Method* m, int bci) {
   _orig_bytecode = (Bytecodes::Code) *m->bcp_from(_bci);
   if (_orig_bytecode == Bytecodes::_breakpoint)
     _orig_bytecode = m->orig_bytecode_at(_bci);
-  _next = NULL;
+  _next = nullptr;
 }
 
 void BreakpointInfo::set(Method* method) {
@@ -2049,7 +2049,7 @@ class JNIMethodBlockNode : public CHeapObj<mtClass> {
         return;
       }
     }
-    if (_next == NULL) {
+    if (_next == nullptr) {
       _next = new JNIMethodBlockNode(MAX2(num_addl_methods, min_block_size));
     } else {
       _next->ensure_methods(num_addl_methods);
@@ -2071,7 +2071,7 @@ class JNIMethodBlock : public CHeapObj<mtClass> {
   }
 
   Method** add_method(Method* m) {
-    for (JNIMethodBlockNode* b = _last_free; b != NULL; b = b->_next) {
+    for (JNIMethodBlockNode* b = _last_free; b != nullptr; b = b->_next) {
       if (b->_top < b->_number_of_methods) {
         // top points to the next free entry.
         int i = b->_top;
@@ -2093,17 +2093,17 @@ class JNIMethodBlock : public CHeapObj<mtClass> {
         b->_top++;
       }
       // need to allocate a next block.
-      if (b->_next == NULL) {
+      if (b->_next == nullptr) {
         b->_next = _last_free = new JNIMethodBlockNode();
       }
     }
     guarantee(false, "Should always allocate a free block");
-    return NULL;
+    return nullptr;
   }
 
   bool contains(Method** m) {
-    if (m == NULL) return false;
-    for (JNIMethodBlockNode* b = &_head; b != NULL; b = b->_next) {
+    if (m == nullptr) return false;
+    for (JNIMethodBlockNode* b = &_head; b != nullptr; b = b->_next) {
       if (b->_methods <= m && m < b->_methods + b->_number_of_methods) {
         // This is a bit of extra checking, for two reasons.  One is
         // that contains() deals with pointers that are passed in by
@@ -2133,9 +2133,9 @@ class JNIMethodBlock : public CHeapObj<mtClass> {
   // During class unloading the methods are cleared, which is different
   // than freed.
   void clear_all_methods() {
-    for (JNIMethodBlockNode* b = &_head; b != NULL; b = b->_next) {
+    for (JNIMethodBlockNode* b = &_head; b != nullptr; b = b->_next) {
       for (int i = 0; i< b->_number_of_methods; i++) {
-        b->_methods[i] = NULL;
+        b->_methods[i] = nullptr;
       }
     }
   }
@@ -2143,7 +2143,7 @@ class JNIMethodBlock : public CHeapObj<mtClass> {
   int count_methods() {
     // count all allocated methods
     int count = 0;
-    for (JNIMethodBlockNode* b = &_head; b != NULL; b = b->_next) {
+    for (JNIMethodBlockNode* b = &_head; b != nullptr; b = b->_next) {
       for (int i = 0; i< b->_number_of_methods; i++) {
         if (b->_methods[i] != _free_method) count++;
       }
@@ -2156,7 +2156,7 @@ class JNIMethodBlock : public CHeapObj<mtClass> {
 // Something that can't be mistaken for an address or a markWord
 Method* const JNIMethodBlock::_free_method = (Method*)55;
 
-JNIMethodBlockNode::JNIMethodBlockNode(int num_methods) : _top(0), _next(NULL) {
+JNIMethodBlockNode::JNIMethodBlockNode(int num_methods) : _top(0), _next(nullptr) {
   _number_of_methods = MAX2(num_methods, min_block_size);
   _methods = NEW_C_HEAP_ARRAY(Method*, _number_of_methods, mtInternal);
   for (int i = 0; i < _number_of_methods; i++) {
@@ -2169,7 +2169,7 @@ void Method::ensure_jmethod_ids(ClassLoaderData* cld, int capacity) {
   // Also have to add the method to the list safely, which the lock
   // protects as well.
   MutexLocker ml(JmethodIdCreation_lock,  Mutex::_no_safepoint_check_flag);
-  if (cld->jmethod_ids() == NULL) {
+  if (cld->jmethod_ids() == nullptr) {
     cld->set_jmethod_ids(new JNIMethodBlock(capacity));
   } else {
     cld->jmethod_ids()->ensure_methods(capacity);
@@ -2182,7 +2182,7 @@ jmethodID Method::make_jmethod_id(ClassLoaderData* cld, Method* m) {
   // Also have to add the method to the list safely, which the lock
   // protects as well.
   assert(JmethodIdCreation_lock->owned_by_self(), "sanity check");
-  if (cld->jmethod_ids() == NULL) {
+  if (cld->jmethod_ids() == nullptr) {
     cld->set_jmethod_ids(new JNIMethodBlock());
   }
   // jmethodID is a pointer to Method*
@@ -2198,7 +2198,7 @@ jmethodID Method::jmethod_id() {
 // InstanceKlass while creating the jmethodID cache.
 void Method::destroy_jmethod_id(ClassLoaderData* cld, jmethodID m) {
   Method** ptr = (Method**)m;
-  assert(cld->jmethod_ids() != NULL, "should have method handles");
+  assert(cld->jmethod_ids() != nullptr, "should have method handles");
   cld->jmethod_ids()->destroy_method(ptr);
 }
 
@@ -2207,7 +2207,7 @@ void Method::change_method_associated_with_jmethod_id(jmethodID jmid, Method* ne
   // scratch method holder.
   assert(resolve_jmethod_id(jmid)->method_holder()->class_loader()
            == new_method->method_holder()->class_loader() ||
-           new_method->method_holder()->class_loader() == NULL, // allow Unsafe substitution
+           new_method->method_holder()->class_loader() == nullptr, // allow Unsafe substitution
          "changing to a different class loader");
   // Just change the method in place, jmethodID pointer doesn't change.
   *((Method**)jmid) = new_method;
@@ -2215,25 +2215,25 @@ void Method::change_method_associated_with_jmethod_id(jmethodID jmid, Method* ne
 
 bool Method::is_method_id(jmethodID mid) {
   Method* m = resolve_jmethod_id(mid);
-  assert(m != NULL, "should be called with non-null method");
+  assert(m != nullptr, "should be called with non-null method");
   InstanceKlass* ik = m->method_holder();
   ClassLoaderData* cld = ik->class_loader_data();
-  if (cld->jmethod_ids() == NULL) return false;
+  if (cld->jmethod_ids() == nullptr) return false;
   return (cld->jmethod_ids()->contains((Method**)mid));
 }
 
 Method* Method::checked_resolve_jmethod_id(jmethodID mid) {
-  if (mid == NULL) return NULL;
+  if (mid == nullptr) return nullptr;
   Method* o = resolve_jmethod_id(mid);
-  if (o == NULL || o == JNIMethodBlock::_free_method) {
-    return NULL;
+  if (o == nullptr || o == JNIMethodBlock::_free_method) {
+    return nullptr;
   }
   // Method should otherwise be valid. Assert for testing.
   assert(is_valid_method(o), "should be valid jmethodid");
   // If the method's class holder object is unreferenced, but not yet marked as
-  // unloaded, we need to return NULL here too because after a safepoint, its memory
+  // unloaded, we need to return null here too because after a safepoint, its memory
   // will be reclaimed.
-  return o->method_holder()->is_loader_alive() ? o : NULL;
+  return o->method_holder()->is_loader_alive() ? o : nullptr;
 };
 
 void Method::set_on_stack(const bool value) {
@@ -2268,7 +2268,7 @@ bool Method::has_method_vptr(const void* ptr) {
 
 // Check that this pointer is valid by checking that the vtbl pointer matches
 bool Method::is_valid_method(const Method* m) {
-  if (m == NULL) {
+  if (m == nullptr) {
     return false;
   } else if ((intptr_t(m) & (wordSize-1)) != 0) {
     // Quick sanity check on pointer.
@@ -2318,7 +2318,7 @@ void Method::print_on(outputStream* st) const {
   st->print_cr(" - i2i entry:         " PTR_FORMAT, p2i(interpreter_entry()));
   st->print(   " - adapters:          ");
   AdapterHandlerEntry* a = ((Method*)this)->adapter();
-  if (a == NULL)
+  if (a == nullptr)
     st->print_cr(PTR_FORMAT, p2i(a));
   else
     a->print_adapter_on(st);
@@ -2328,7 +2328,7 @@ void Method::print_on(outputStream* st) const {
     st->print_cr(" - code start:        " PTR_FORMAT, p2i(code_base()));
     st->print_cr(" - code end (excl):   " PTR_FORMAT, p2i(code_base() + code_size()));
   }
-  if (method_data() != NULL) {
+  if (method_data() != nullptr) {
     st->print_cr(" - method data:       " PTR_FORMAT, p2i(method_data()));
   }
   st->print_cr(" - checked ex length: %d",   checked_exceptions_length());
@@ -2366,7 +2366,7 @@ void Method::print_on(outputStream* st) const {
       }
     }
   }
-  if (code() != NULL) {
+  if (code() != nullptr) {
     st->print   (" - compiled code: ");
     code()->print_value_on(st);
   }
@@ -2399,7 +2399,7 @@ void Method::print_value_on(outputStream* st) const {
   method_holder()->print_value_on(st);
   if (WizardMode) st->print("#%d", _vtable_index);
   if (WizardMode) st->print("[%d,%d]", size_of_parameters(), max_locals());
-  if (WizardMode && code() != NULL) st->print(" ((nmethod*)%p)", code());
+  if (WizardMode && code() != nullptr) st->print(" ((nmethod*)%p)", code());
 }
 
 // Verification
@@ -2408,6 +2408,6 @@ void Method::verify_on(outputStream* st) {
   guarantee(is_method(), "object must be method");
   guarantee(constants()->is_constantPool(), "should be constant pool");
   MethodData* md = method_data();
-  guarantee(md == NULL ||
+  guarantee(md == nullptr ||
       md->is_methodData(), "should be method data");
 }
diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp
index 4a5df8134cc..4a154373654 100644
--- a/src/hotspot/share/oops/method.hpp
+++ b/src/hotspot/share/oops/method.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -111,9 +111,9 @@ class Method : public Metadata {
   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
   // The entry point for calling both from and to compiled code is
   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
-  // field can come and go.  It can transition from NULL to not-null at any
+  // field can come and go.  It can transition from null to not-null at any
   // time (whenever a compile completes).  It can transition from not-null to
-  // NULL only at safepoints (because of a de-opt).
+  // null only at safepoints (because of a de-opt).
   CompiledMethod* volatile _code;                       // Points to the corresponding piece of native code
   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 
@@ -164,7 +164,7 @@ class Method : public Metadata {
   void set_signature_index(int index)            { constMethod()->set_signature_index(index);       }
 
   // generics support
-  Symbol* generic_signature() const              { int idx = generic_signature_index(); return ((idx != 0) ? constants()->symbol_at(idx) : (Symbol*)NULL); }
+  Symbol* generic_signature() const              { int idx = generic_signature_index(); return ((idx != 0) ? constants()->symbol_at(idx) : nullptr); }
   int generic_signature_index() const            { return constMethod()->generic_signature_index(); }
   void set_generic_signature_index(int index)    { constMethod()->set_generic_signature_index(index); }
 
@@ -232,7 +232,7 @@ class Method : public Metadata {
   // Only mutated by VM thread.
   u2   number_of_breakpoints() const {
     MethodCounters* mcs = method_counters();
-    if (mcs == NULL) {
+    if (mcs == nullptr) {
       return 0;
     } else {
       return mcs->number_of_breakpoints();
@@ -240,20 +240,20 @@ class Method : public Metadata {
   }
   void incr_number_of_breakpoints(Thread* current) {
     MethodCounters* mcs = get_method_counters(current);
-    if (mcs != NULL) {
+    if (mcs != nullptr) {
       mcs->incr_number_of_breakpoints();
     }
   }
   void decr_number_of_breakpoints(Thread* current) {
     MethodCounters* mcs = get_method_counters(current);
-    if (mcs != NULL) {
+    if (mcs != nullptr) {
       mcs->decr_number_of_breakpoints();
     }
   }
   // Initialization only
   void clear_number_of_breakpoints() {
     MethodCounters* mcs = method_counters();
-    if (mcs != NULL) {
+    if (mcs != nullptr) {
       mcs->clear_number_of_breakpoints();
     }
   }
@@ -296,7 +296,7 @@ class Method : public Metadata {
   // Count of times method was exited via exception while interpreting
   void interpreter_throwout_increment(Thread* current) {
     MethodCounters* mcs = get_method_counters(current);
-    if (mcs != NULL) {
+    if (mcs != nullptr) {
       mcs->interpreter_throwout_increment();
     }
   }
@@ -304,7 +304,7 @@ class Method : public Metadata {
 
   int  interpreter_throwout_count() const        {
     MethodCounters* mcs = method_counters();
-    if (mcs == NULL) {
+    if (mcs == nullptr) {
       return 0;
     } else {
       return mcs->interpreter_throwout_count();
@@ -339,7 +339,7 @@ class Method : public Metadata {
                              { return constMethod()->exception_table_start(); }
 
   // Finds the first entry point bci of an exception handler for an
-  // exception of klass ex_klass thrown at throw_bci. A value of NULL
+  // exception of klass ex_klass thrown at throw_bci. A value of null
   // for ex_klass indicates that the exception klass is not known; in
   // this case it matches any constraint class. Returns -1 if the
   // exception cannot be handled in this method. The handler
@@ -370,38 +370,38 @@ class Method : public Metadata {
   }
 
   void clear_method_counters() {
-    _method_counters = NULL;
+    _method_counters = nullptr;
   }
 
   bool init_method_counters(MethodCounters* counters);
 
   int prev_event_count() const {
     MethodCounters* mcs = method_counters();
-    return mcs == NULL ? 0 : mcs->prev_event_count();
+    return mcs == nullptr ? 0 : mcs->prev_event_count();
   }
   void set_prev_event_count(int count) {
     MethodCounters* mcs = method_counters();
-    if (mcs != NULL) {
+    if (mcs != nullptr) {
       mcs->set_prev_event_count(count);
     }
   }
   jlong prev_time() const {
     MethodCounters* mcs = method_counters();
-    return mcs == NULL ? 0 : mcs->prev_time();
+    return mcs == nullptr ? 0 : mcs->prev_time();
   }
   void set_prev_time(jlong time) {
     MethodCounters* mcs = method_counters();
-    if (mcs != NULL) {
+    if (mcs != nullptr) {
       mcs->set_prev_time(time);
     }
   }
   float rate() const {
     MethodCounters* mcs = method_counters();
-    return mcs == NULL ? 0 : mcs->rate();
+    return mcs == nullptr ? 0 : mcs->rate();
   }
   void set_rate(float rate) {
     MethodCounters* mcs = method_counters();
-    if (mcs != NULL) {
+    if (mcs != nullptr) {
       mcs->set_rate(rate);
     }
   }
@@ -506,7 +506,7 @@ class Method : public Metadata {
   };
   address native_function() const                { return *(native_function_addr()); }
 
-  // Must specify a real function (not NULL).
+  // Must specify a real function (not null).
   // Use clear_native_function() to unregister.
   void set_native_function(address function, bool post_event_flag);
   bool has_native_function() const;
@@ -773,7 +773,7 @@ class Method : public Metadata {
   // once created they are never reclaimed.  The methods to which they refer,
   // however, can be GC'ed away if the class is unloaded or if the method is
   // made obsolete or deleted -- in these cases, the jmethodID
-  // refers to NULL (as is the case for any weak reference).
+  // refers to null (as is the case for any weak reference).
   static jmethodID make_jmethod_id(ClassLoaderData* cld, Method* mh);
   static void destroy_jmethod_id(ClassLoaderData* cld, jmethodID mid);
 
@@ -784,14 +784,14 @@ class Method : public Metadata {
 
   // Use resolve_jmethod_id() in situations where the caller is expected
   // to provide a valid jmethodID; the only sanity checks are in asserts;
-  // result guaranteed not to be NULL.
+  // result guaranteed not to be null.
   inline static Method* resolve_jmethod_id(jmethodID mid) {
-    assert(mid != NULL, "JNI method id should not be null");
+    assert(mid != nullptr, "JNI method id should not be null");
     return *((Method**)mid);
   }
 
   // Use checked_resolve_jmethod_id() in situations where the caller
-  // should provide a valid jmethodID, but might not. NULL is returned
+  // should provide a valid jmethodID, but might not. Null is returned
   // when the jmethodID does not refer to a valid method.
   static Method* checked_resolve_jmethod_id(jmethodID mid);
 
@@ -805,7 +805,7 @@ class Method : public Metadata {
   // Get this method's jmethodID -- allocate if it doesn't exist
   jmethodID jmethod_id();
 
-  // Lookup the jmethodID for this method.  Return NULL if not found.
+  // Lookup the jmethodID for this method.  Return null if not found.
   // NOTE that this function can be called from a signal handler
   // (see AsyncGetCallTrace support for Forte Analyzer) and this
   // needs to be async-safe. No allocation should be done and
@@ -902,7 +902,7 @@ class Method : public Metadata {
 
   // On-stack replacement support
   bool has_osr_nmethod(int level, bool match_level) {
-   return method_holder()->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL;
+   return method_holder()->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != nullptr;
   }
 
   int mark_osr_nmethods() {
@@ -937,7 +937,7 @@ class Method : public Metadata {
 
  public:
   MethodCounters* get_method_counters(Thread* current) {
-    if (_method_counters == NULL) {
+    if (_method_counters == nullptr) {
       build_method_counters(current, this);
     }
     return _method_counters;
@@ -976,7 +976,7 @@ class Method : public Metadata {
   typedef int (*method_comparator_func)(Method* a, Method* b);
 
   // Helper routine used for method sorting
-  static void sort_methods(Array<Method*>* methods, bool set_idnums = true, method_comparator_func func = NULL);
+  static void sort_methods(Array<Method*>* methods, bool set_idnums = true, method_comparator_func func = nullptr);
 
   // Deallocation function for redefine classes or if an error occurs
   void deallocate_contents(ClassLoaderData* loader_data);
@@ -987,7 +987,7 @@ class Method : public Metadata {
     InstanceKlass* holder = method_holder();
     Method* new_method = holder->method_with_idnum(orig_method_idnum());
 
-    assert(new_method != NULL, "method_with_idnum() should not be NULL");
+    assert(new_method != nullptr, "method_with_idnum() should not be null");
     assert(this != new_method, "sanity check");
     return new_method;
   }
@@ -1122,7 +1122,7 @@ class ExceptionTable : public StackObj {
       _table = m->exception_table_start();
       _length = m->exception_table_length();
     } else {
-      _table = NULL;
+      _table = nullptr;
       _length = 0;
     }
   }
diff --git a/src/hotspot/share/oops/method.inline.hpp b/src/hotspot/share/oops/method.inline.hpp
index 2b30f3297ad..50c85733da9 100644
--- a/src/hotspot/share/oops/method.inline.hpp
+++ b/src/hotspot/share/oops/method.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,7 +83,7 @@ inline void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
   write_pair_inline(bci, line);
 }
 
-inline bool Method::has_compiled_code() const { return code() != NULL; }
+inline bool Method::has_compiled_code() const { return code() != nullptr; }
 
 inline bool Method::is_empty_method() const {
   return  code_size() == 1
diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp
index bd0bd707d78..e5d6f250592 100644
--- a/src/hotspot/share/oops/methodData.cpp
+++ b/src/hotspot/share/oops/methodData.cpp
@@ -88,7 +88,7 @@ void DataLayout::clean_weak_klass_links(bool always_clean) {
 
 // Constructor for invalid ProfileData.
 ProfileData::ProfileData() {
-  _data = NULL;
+  _data = nullptr;
 }
 
 char* ProfileData::print_data_on_helper(const MethodData* md) const {
@@ -118,7 +118,7 @@ char* ProfileData::print_data_on_helper(const MethodData* md) const {
       fatal("unexpected tag %d", dp->tag());
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 void ProfileData::print_data_on(outputStream* st, const MethodData* md) const {
@@ -135,7 +135,7 @@ void ProfileData::print_shared(outputStream* st, const char* name, const char* e
     char buf[100];
     st->print("trap(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap));
   }
-  if (extra != NULL) {
+  if (extra != nullptr) {
     st->print("%s", extra);
   }
   int flags = data()->flags();
@@ -317,8 +317,8 @@ void TypeStackSlotEntries::clean_weak_klass_links(bool always_clean) {
   for (int i = 0; i < _number_of_entries; i++) {
     intptr_t p = type(i);
     Klass* k = (Klass*)klass_part(p);
-    if (k != NULL && (always_clean || !k->is_loader_alive())) {
-      set_type(i, with_status((Klass*)NULL, p));
+    if (k != nullptr && (always_clean || !k->is_loader_alive())) {
+      set_type(i, with_status((Klass*)nullptr, p));
     }
   }
 }
@@ -326,8 +326,8 @@ void TypeStackSlotEntries::clean_weak_klass_links(bool always_clean) {
 void ReturnTypeEntry::clean_weak_klass_links(bool always_clean) {
   intptr_t p = type();
   Klass* k = (Klass*)klass_part(p);
-  if (k != NULL && (always_clean || !k->is_loader_alive())) {
-    set_type(with_status((Klass*)NULL, p));
+  if (k != nullptr && (always_clean || !k->is_loader_alive())) {
+    set_type(with_status((Klass*)nullptr, p));
   }
 }
 
@@ -406,7 +406,7 @@ void VirtualCallTypeData::print_data_on(outputStream* st, const char* extra) con
 void ReceiverTypeData::clean_weak_klass_links(bool always_clean) {
     for (uint row = 0; row < row_limit(); row++) {
     Klass* p = receiver(row);
-    if (p != NULL && (always_clean || !p->is_loader_alive())) {
+    if (p != nullptr && (always_clean || !p->is_loader_alive())) {
       clear_row(row);
     }
   }
@@ -416,7 +416,7 @@ void ReceiverTypeData::print_receiver_data_on(outputStream* st) const {
   uint row;
   int entries = 0;
   for (row = 0; row < row_limit(); row++) {
-    if (receiver(row) != NULL)  entries++;
+    if (receiver(row) != nullptr)  entries++;
   }
 #if INCLUDE_JVMCI
   st->print_cr("count(%u) nonprofiled_count(%u) entries(%u)", count(), nonprofiled_count(), entries);
@@ -425,12 +425,12 @@ void ReceiverTypeData::print_receiver_data_on(outputStream* st) const {
 #endif
   int total = count();
   for (row = 0; row < row_limit(); row++) {
-    if (receiver(row) != NULL) {
+    if (receiver(row) != nullptr) {
       total += receiver_count(row);
     }
   }
   for (row = 0; row < row_limit(); row++) {
-    if (receiver(row) != NULL) {
+    if (receiver(row) != nullptr) {
       tab(st);
       receiver(row)->print_value_on(st);
       st->print_cr("(%u %4.2f)", receiver_count(row), (float) receiver_count(row) / (float) total);
@@ -805,7 +805,7 @@ void* FailedSpeculation::operator new(size_t size, size_t fs_size) throw() {
   return CHeapObj<mtCompiler>::operator new(fs_size, std::nothrow);
 }
 
-FailedSpeculation::FailedSpeculation(address speculation, int speculation_len) : _data_len(speculation_len), _next(NULL) {
+FailedSpeculation::FailedSpeculation(address speculation, int speculation_len) : _data_len(speculation_len), _next(nullptr) {
   memcpy(data(), speculation, speculation_len);
 }
 
@@ -814,15 +814,15 @@ static void guarantee_failed_speculations_alive(nmethod* nm, FailedSpeculation**
   jlong head = (jlong)(address) *failed_speculations_address;
   if ((head & 0x1) == 0x1) {
     stringStream st;
-    if (nm != NULL) {
+    if (nm != nullptr) {
       st.print("%d", nm->compile_id());
       Method* method = nm->method();
       st.print_raw("{");
-      if (method != NULL) {
+      if (method != nullptr) {
         method->print_name(&st);
       } else {
         const char* jvmci_name = nm->jvmci_name();
-        if (jvmci_name != NULL) {
+        if (jvmci_name != nullptr) {
           st.print_raw(jvmci_name);
         }
       }
@@ -835,10 +835,10 @@ static void guarantee_failed_speculations_alive(nmethod* nm, FailedSpeculation**
 }
 
 bool FailedSpeculation::add_failed_speculation(nmethod* nm, FailedSpeculation** failed_speculations_address, address speculation, int speculation_len) {
-  assert(failed_speculations_address != NULL, "must be");
+  assert(failed_speculations_address != nullptr, "must be");
   size_t fs_size = sizeof(FailedSpeculation) + speculation_len;
   FailedSpeculation* fs = new (fs_size) FailedSpeculation(speculation, speculation_len);
-  if (fs == NULL) {
+  if (fs == nullptr) {
     // no memory -> ignore failed speculation
     return false;
   }
@@ -848,9 +848,9 @@ bool FailedSpeculation::add_failed_speculation(nmethod* nm, FailedSpeculation**
 
   FailedSpeculation** cursor = failed_speculations_address;
   do {
-    if (*cursor == NULL) {
-      FailedSpeculation* old_fs = Atomic::cmpxchg(cursor, (FailedSpeculation*) NULL, fs);
-      if (old_fs == NULL) {
+    if (*cursor == nullptr) {
+      FailedSpeculation* old_fs = Atomic::cmpxchg(cursor, (FailedSpeculation*) nullptr, fs);
+      if (old_fs == nullptr) {
         // Successfully appended fs to end of the list
         return true;
       }
@@ -862,9 +862,9 @@ bool FailedSpeculation::add_failed_speculation(nmethod* nm, FailedSpeculation**
 }
 
 void FailedSpeculation::free_failed_speculations(FailedSpeculation** failed_speculations_address) {
-  assert(failed_speculations_address != NULL, "must be");
+  assert(failed_speculations_address != nullptr, "must be");
   FailedSpeculation* fs = *failed_speculations_address;
-  while (fs != NULL) {
+  while (fs != nullptr) {
     FailedSpeculation* next = fs->next();
     delete fs;
     fs = next;
@@ -1099,7 +1099,7 @@ int MethodData::initialize_data(BytecodeStream* stream,
 // Get the data at an arbitrary (sort of) data index.
 ProfileData* MethodData::data_at(int data_index) const {
   if (out_of_bounds(data_index)) {
-    return NULL;
+    return nullptr;
   }
   DataLayout* data_layout = data_layout_at(data_index);
   return data_layout->data_in();
@@ -1144,7 +1144,7 @@ ProfileData* DataLayout::data_in() {
   case DataLayout::no_tag:
   default:
     ShouldNotReachHere();
-    return NULL;
+    return nullptr;
   case DataLayout::bit_data_tag:
     return new BitData(this);
   case DataLayout::counter_data_tag:
@@ -1186,7 +1186,7 @@ DataLayout* MethodData::next_data_layout(DataLayout* current) const {
   int current_index = dp_to_di((address)current);
   int next_index = current_index + current->size_in_bytes();
   if (out_of_bounds(next_index)) {
-    return NULL;
+    return nullptr;
   }
   DataLayout* next = data_layout_at(next_index);
   return next;
@@ -1203,7 +1203,7 @@ void MethodData::post_initialize(BytecodeStream* stream) {
     data->post_initialize(stream, this);
   }
   if (_parameters_type_data_di != no_parameters) {
-    parameters_type_data()->post_initialize(NULL, this);
+    parameters_type_data()->post_initialize(nullptr, this);
   }
 }
 
@@ -1310,7 +1310,7 @@ void MethodData::init() {
 
 #if INCLUDE_JVMCI
   _jvmci_ir_size = 0;
-  _failed_speculations = NULL;
+  _failed_speculations = nullptr;
 #endif
 
 #if INCLUDE_RTM_OPT
@@ -1345,11 +1345,11 @@ bool MethodData::is_mature() const {
 address MethodData::bci_to_dp(int bci) {
   ResourceMark rm;
   DataLayout* data = data_layout_before(bci);
-  DataLayout* prev = NULL;
+  DataLayout* prev = nullptr;
   for ( ; is_valid(data); data = next_data_layout(data)) {
     if (data->bci() >= bci) {
       if (data->bci() == bci)  set_hint_di(dp_to_di((address)data));
-      else if (prev != NULL)   set_hint_di(dp_to_di((address)prev));
+      else if (prev != nullptr)   set_hint_di(dp_to_di((address)prev));
       return (address)data;
     }
     prev = data;
@@ -1357,7 +1357,7 @@ address MethodData::bci_to_dp(int bci) {
   return (address)limit_data_position();
 }
 
-// Translate a bci to its corresponding data, or NULL.
+// Translate a bci to its corresponding data, or null.
 ProfileData* MethodData::bci_to_data(int bci) {
   DataLayout* data = data_layout_before(bci);
   for ( ; is_valid(data); data = next_data_layout(data)) {
@@ -1368,7 +1368,7 @@ ProfileData* MethodData::bci_to_data(int bci) {
       break;
     }
   }
-  return bci_to_extra_data(bci, NULL, false);
+  return bci_to_extra_data(bci, nullptr, false);
 }
 
 DataLayout* MethodData::next_extra(DataLayout* dp) {
@@ -1396,25 +1396,25 @@ ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout
     // since the data structure is monotonic.
     switch(dp->tag()) {
     case DataLayout::no_tag:
-      return NULL;
+      return nullptr;
     case DataLayout::arg_info_data_tag:
       dp = end;
-      return NULL; // ArgInfoData is at the end of extra data section.
+      return nullptr; // ArgInfoData is at the end of extra data section.
     case DataLayout::bit_data_tag:
-      if (m == NULL && dp->bci() == bci) {
+      if (m == nullptr && dp->bci() == bci) {
         return new BitData(dp);
       }
       break;
     case DataLayout::speculative_trap_data_tag:
-      if (m != NULL) {
+      if (m != nullptr) {
         SpeculativeTrapData* data = new SpeculativeTrapData(dp);
         // data->method() may be null in case of a concurrent
         // allocation. Maybe it's for the same method. Try to use that
         // entry in that case.
         if (dp->bci() == bci) {
-          if (data->method() == NULL) {
+          if (data->method() == nullptr) {
             assert(concurrent, "impossible because no concurrent allocation");
-            return NULL;
+            return nullptr;
           } else if (data->method() == m) {
             return data;
           }
@@ -1425,11 +1425,11 @@ ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout
       fatal("unexpected tag %d", dp->tag());
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 
-// Translate a bci to its corresponding extra data, or NULL.
+// Translate a bci to its corresponding extra data, or null.
 ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_missing) {
   // This code assumes an entry for a SpeculativeTrapData is 2 cells
   assert(2*DataLayout::compute_size_in_bytes(BitData::static_cell_count()) ==
@@ -1437,8 +1437,8 @@ ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_mi
          "code needs to be adjusted");
 
   // Do not create one of these if method has been redefined.
-  if (m != NULL && m->is_old()) {
-    return NULL;
+  if (m != nullptr && m->is_old()) {
+    return nullptr;
   }
 
   DataLayout* dp  = extra_data_base();
@@ -1448,7 +1448,7 @@ ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_mi
   // all entries have the same size and non atomic concurrent
   // allocation would result in a corrupted extra data space.
   ProfileData* result = bci_to_extra_data_helper(bci, m, dp, true);
-  if (result != NULL) {
+  if (result != nullptr) {
     return result;
   }
 
@@ -1457,16 +1457,16 @@ ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_mi
     // Check again now that we have the lock. Another thread may
     // have added extra data entries.
     ProfileData* result = bci_to_extra_data_helper(bci, m, dp, false);
-    if (result != NULL || dp >= end) {
+    if (result != nullptr || dp >= end) {
       return result;
     }
 
-    assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != NULL), "should be free");
+    assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != nullptr), "should be free");
     assert(next_extra(dp)->tag() == DataLayout::no_tag || next_extra(dp)->tag() == DataLayout::arg_info_data_tag, "should be free or arg info");
-    u1 tag = m == NULL ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag;
+    u1 tag = m == nullptr ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag;
     // SpeculativeTrapData is 2 slots. Make sure we have room.
-    if (m != NULL && next_extra(dp)->tag() != DataLayout::no_tag) {
-      return NULL;
+    if (m != nullptr && next_extra(dp)->tag() != DataLayout::no_tag) {
+      return nullptr;
     }
     DataLayout temp;
     temp.initialize(tag, bci, 0);
@@ -1482,7 +1482,7 @@ ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_mi
       return data;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 ArgInfoData *MethodData::arg_info() {
@@ -1492,7 +1492,7 @@ ArgInfoData *MethodData::arg_info() {
     if (dp->tag() == DataLayout::arg_info_data_tag)
       return new ArgInfoData(dp);
   }
-  return NULL;
+  return nullptr;
 }
 
 // Printing
@@ -1737,7 +1737,7 @@ void MethodData::clean_extra_data(CleanExtraDataClosure* cl) {
     case DataLayout::speculative_trap_data_tag: {
       SpeculativeTrapData* data = new SpeculativeTrapData(dp);
       Method* m = data->method();
-      assert(m != NULL, "should have a method");
+      assert(m != nullptr, "should have a method");
       if (!cl->is_live(m)) {
         // "shift" accumulates the number of cells for dead
         // SpeculativeTrapData entries that have been seen so
@@ -1781,7 +1781,7 @@ void MethodData::verify_extra_data_clean(CleanExtraDataClosure* cl) {
     case DataLayout::speculative_trap_data_tag: {
       SpeculativeTrapData* data = new SpeculativeTrapData(dp);
       Method* m = data->method();
-      assert(m != NULL && cl->is_live(m), "Method should exist");
+      assert(m != nullptr && cl->is_live(m), "Method should exist");
       break;
     }
     case DataLayout::bit_data_tag:
@@ -1804,7 +1804,7 @@ void MethodData::clean_method_data(bool always_clean) {
     data->clean_weak_klass_links(always_clean);
   }
   ParametersTypeData* parameters = parameters_type_data();
-  if (parameters != NULL) {
+  if (parameters != nullptr) {
     parameters->clean_weak_klass_links(always_clean);
   }
 
diff --git a/src/hotspot/share/oops/methodData.hpp b/src/hotspot/share/oops/methodData.hpp
index 508278e6d74..775d0907492 100644
--- a/src/hotspot/share/oops/methodData.hpp
+++ b/src/hotspot/share/oops/methodData.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -401,59 +401,59 @@ class ProfileData : public ResourceObj {
 
   BitData* as_BitData() const {
     assert(is_BitData(), "wrong type");
-    return is_BitData()         ? (BitData*)        this : NULL;
+    return is_BitData()         ? (BitData*)        this : nullptr;
   }
   CounterData* as_CounterData() const {
     assert(is_CounterData(), "wrong type");
-    return is_CounterData()     ? (CounterData*)    this : NULL;
+    return is_CounterData()     ? (CounterData*)    this : nullptr;
   }
   JumpData* as_JumpData() const {
     assert(is_JumpData(), "wrong type");
-    return is_JumpData()        ? (JumpData*)       this : NULL;
+    return is_JumpData()        ? (JumpData*)       this : nullptr;
   }
   ReceiverTypeData* as_ReceiverTypeData() const {
     assert(is_ReceiverTypeData(), "wrong type");
-    return is_ReceiverTypeData() ? (ReceiverTypeData*)this : NULL;
+    return is_ReceiverTypeData() ? (ReceiverTypeData*)this : nullptr;
   }
   VirtualCallData* as_VirtualCallData() const {
     assert(is_VirtualCallData(), "wrong type");
-    return is_VirtualCallData() ? (VirtualCallData*)this : NULL;
+    return is_VirtualCallData() ? (VirtualCallData*)this : nullptr;
   }
   RetData* as_RetData() const {
     assert(is_RetData(), "wrong type");
-    return is_RetData()         ? (RetData*)        this : NULL;
+    return is_RetData()         ? (RetData*)        this : nullptr;
   }
   BranchData* as_BranchData() const {
     assert(is_BranchData(), "wrong type");
-    return is_BranchData()      ? (BranchData*)     this : NULL;
+    return is_BranchData()      ? (BranchData*)     this : nullptr;
   }
   ArrayData* as_ArrayData() const {
     assert(is_ArrayData(), "wrong type");
-    return is_ArrayData()       ? (ArrayData*)      this : NULL;
+    return is_ArrayData()       ? (ArrayData*)      this : nullptr;
   }
   MultiBranchData* as_MultiBranchData() const {
     assert(is_MultiBranchData(), "wrong type");
-    return is_MultiBranchData() ? (MultiBranchData*)this : NULL;
+    return is_MultiBranchData() ? (MultiBranchData*)this : nullptr;
   }
   ArgInfoData* as_ArgInfoData() const {
     assert(is_ArgInfoData(), "wrong type");
-    return is_ArgInfoData() ? (ArgInfoData*)this : NULL;
+    return is_ArgInfoData() ? (ArgInfoData*)this : nullptr;
   }
   CallTypeData* as_CallTypeData() const {
     assert(is_CallTypeData(), "wrong type");
-    return is_CallTypeData() ? (CallTypeData*)this : NULL;
+    return is_CallTypeData() ? (CallTypeData*)this : nullptr;
   }
   VirtualCallTypeData* as_VirtualCallTypeData() const {
     assert(is_VirtualCallTypeData(), "wrong type");
-    return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : NULL;
+    return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : nullptr;
   }
   ParametersTypeData* as_ParametersTypeData() const {
     assert(is_ParametersTypeData(), "wrong type");
-    return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL;
+    return is_ParametersTypeData() ? (ParametersTypeData*)this : nullptr;
   }
   SpeculativeTrapData* as_SpeculativeTrapData() const {
     assert(is_SpeculativeTrapData(), "wrong type");
-    return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : NULL;
+    return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : nullptr;
   }
 
 
@@ -470,7 +470,7 @@ class ProfileData : public ResourceObj {
   // translation here, and the required translators are in the ci subclasses.
   virtual void translate_from(const ProfileData* data) {}
 
-  virtual void print_data_on(outputStream* st, const char* extra = NULL) const {
+  virtual void print_data_on(outputStream* st, const char* extra = nullptr) const {
     ShouldNotReachHere();
   }
 
@@ -533,7 +533,7 @@ class BitData : public ProfileData {
     return cell_offset(bit_cell_count);
   }
 
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // CounterData
@@ -583,7 +583,7 @@ class CounterData : public BitData {
     set_int_at(count_off, count);
   }
 
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // JumpData
@@ -656,7 +656,7 @@ class JumpData : public ProfileData {
   // Specific initialization.
   void post_initialize(BytecodeStream* stream, MethodData* mdo);
 
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // Entries in a ProfileData object to record types: it can either be
@@ -714,10 +714,10 @@ class TypeEntries {
     if (!is_type_none(k) &&
         !is_type_unknown(k)) {
       Klass* res = (Klass*)klass_part(k);
-      assert(res != NULL, "invalid");
+      assert(res != nullptr, "invalid");
       return res;
     } else {
-      return NULL;
+      return nullptr;
     }
   }
 
@@ -738,7 +738,7 @@ class TypeEntries {
   const int _base_off;
 
   TypeEntries(int base_off)
-    : _pd(NULL), _base_off(base_off) {}
+    : _pd(nullptr), _base_off(base_off) {}
 
   void set_intptr_at(int index, intptr_t value) {
     _pd->set_intptr_at(index, value);
@@ -1074,7 +1074,7 @@ class CallTypeData : public CounterData {
     }
   }
 
-  virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
+  virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // ReceiverTypeData
@@ -1139,7 +1139,7 @@ class ReceiverTypeData : public CounterData {
     assert(row < row_limit(), "oob");
 
     Klass* recv = (Klass*)intptr_at(receiver_cell_index(row));
-    assert(recv == NULL || recv->is_klass(), "wrong type");
+    assert(recv == nullptr || recv->is_klass(), "wrong type");
     return recv;
   }
 
@@ -1177,7 +1177,7 @@ class ReceiverTypeData : public CounterData {
     // We do sorting a profiling info (ciCallProfile) for compilation.
     //
     set_count(0);
-    set_receiver(row, NULL);
+    set_receiver(row, nullptr);
     set_receiver_count(row, 0);
 #if INCLUDE_JVMCI
     if (!this->is_VirtualCallData()) {
@@ -1214,7 +1214,7 @@ class ReceiverTypeData : public CounterData {
   virtual void clean_weak_klass_links(bool always_clean);
 
   void print_receiver_data_on(outputStream* st) const;
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // VirtualCallData
@@ -1246,7 +1246,7 @@ class VirtualCallData : public ReceiverTypeData {
   }
 
   void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // VirtualCallTypeData
@@ -1378,7 +1378,7 @@ class VirtualCallTypeData : public VirtualCallData {
     }
   }
 
-  virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
+  virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // RetData
@@ -1470,7 +1470,7 @@ class RetData : public CounterData {
   // Specific initialization.
   void post_initialize(BytecodeStream* stream, MethodData* mdo);
 
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // BranchData
@@ -1534,7 +1534,7 @@ class BranchData : public JumpData {
   // Specific initialization.
   void post_initialize(BytecodeStream* stream, MethodData* mdo);
 
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // ArrayData
@@ -1693,7 +1693,7 @@ class MultiBranchData : public ArrayData {
   // Specific initialization.
   void post_initialize(BytecodeStream* stream, MethodData* mdo);
 
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 class ArgInfoData : public ArrayData {
@@ -1718,7 +1718,7 @@ class ArgInfoData : public ArrayData {
     array_set_int_at(arg, val);
   }
 
-  void print_data_on(outputStream* st, const char* extra = NULL) const;
+  void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // ParametersTypeData
@@ -1777,7 +1777,7 @@ class ParametersTypeData : public ArrayData {
     _parameters.clean_weak_klass_links(always_clean);
   }
 
-  virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
+  virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
 
   static ByteSize stack_slot_offset(int i) {
     return cell_offset(stack_slot_local_offset(i));
@@ -1847,7 +1847,7 @@ class SpeculativeTrapData : public ProfileData {
     return cell_offset(speculative_trap_method);
   }
 
-  virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
+  virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
 };
 
 // MethodData*
@@ -1883,7 +1883,7 @@ class SpeculativeTrapData : public ProfileData {
 // interpretation, when a bytecode is encountered that has profile data
 // associated with it, the entry pointed to by mdp is updated, then the
 // mdp is adjusted to point to the next appropriate DataLayout.  If mdp
-// is NULL to begin with, the interpreter assumes that the current method
+// is null to begin with, the interpreter assumes that the current method
 // is not (yet) being profiled.
 //
 // In MethodData* parlance, "dp" is a "data pointer", the actual address
@@ -2132,7 +2132,7 @@ class MethodData : public Metadata {
   DataLayout* data_layout_before(int bci) {
     // avoid SEGV on this edge case
     if (data_size() == 0)
-      return NULL;
+      return nullptr;
     DataLayout* layout = data_layout_at(hint_di());
     if (layout->bci() <= bci)
       return layout;
@@ -2283,7 +2283,7 @@ class MethodData : public Metadata {
   intx arg_stack()                               { return _arg_stack; }
   intx arg_returned()                            { return _arg_returned; }
   uint arg_modified(int a)                       { ArgInfoData *aid = arg_info();
-                                                   assert(aid != NULL, "arg_info must be not null");
+                                                   assert(aid != nullptr, "arg_info must be not null");
                                                    assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
                                                    return aid->arg_modified(a); }
 
@@ -2292,7 +2292,7 @@ class MethodData : public Metadata {
   void set_arg_stack(intx v)                     { _arg_stack = v; }
   void set_arg_returned(intx v)                  { _arg_returned = v; }
   void set_arg_modified(int a, uint v)           { ArgInfoData *aid = arg_info();
-                                                   assert(aid != NULL, "arg_info must be not null");
+                                                   assert(aid != nullptr, "arg_info must be not null");
                                                    assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
                                                    aid->set_arg_modified(a, v); }
 
@@ -2308,7 +2308,7 @@ class MethodData : public Metadata {
 
   int parameters_size_in_bytes() const {
     ParametersTypeData* param = parameters_type_data();
-    return param == NULL ? 0 : param->size_in_bytes();
+    return param == nullptr ? 0 : param->size_in_bytes();
   }
 
   // Accessors
@@ -2321,8 +2321,8 @@ class MethodData : public Metadata {
   ProfileData* first_data() const { return data_at(first_di()); }
   ProfileData* next_data(ProfileData* current) const;
   DataLayout*  next_data_layout(DataLayout* current) const;
-  bool is_valid(ProfileData* current) const { return current != NULL; }
-  bool is_valid(DataLayout*  current) const { return current != NULL; }
+  bool is_valid(ProfileData* current) const { return current != nullptr; }
+  bool is_valid(DataLayout*  current) const { return current != nullptr; }
 
   // Convert a dp (data pointer) to a di (data index).
   int dp_to_di(address dp) const {
@@ -2335,30 +2335,30 @@ class MethodData : public Metadata {
     return dp_to_di(bci_to_dp(bci));
   }
 
-  // Get the data at an arbitrary bci, or NULL if there is none.
+  // Get the data at an arbitrary bci, or null if there is none.
   ProfileData* bci_to_data(int bci);
 
   // Same, but try to create an extra_data record if one is needed:
   ProfileData* allocate_bci_to_data(int bci, Method* m) {
-    ProfileData* data = NULL;
-    // If m not NULL, try to allocate a SpeculativeTrapData entry
-    if (m == NULL) {
+    ProfileData* data = nullptr;
+    // If m not null, try to allocate a SpeculativeTrapData entry
+    if (m == nullptr) {
       data = bci_to_data(bci);
     }
-    if (data != NULL) {
+    if (data != nullptr) {
       return data;
     }
     data = bci_to_extra_data(bci, m, true);
-    if (data != NULL) {
+    if (data != nullptr) {
       return data;
     }
     // If SpeculativeTrapData allocation fails try to allocate a
     // regular entry
     data = bci_to_data(bci);
-    if (data != NULL) {
+    if (data != nullptr) {
       return data;
     }
-    return bci_to_extra_data(bci, NULL, true);
+    return bci_to_extra_data(bci, nullptr, true);
   }
 
   // Add a handful of extra data records, for trap tracking.
@@ -2409,7 +2409,7 @@ class MethodData : public Metadata {
   // Return pointer to area dedicated to parameters in MDO
   ParametersTypeData* parameters_type_data() const {
     assert(_parameters_type_data_di != parameters_uninitialized, "called too early");
-    return _parameters_type_data_di != no_parameters ? data_layout_at(_parameters_type_data_di)->data_in()->as_ParametersTypeData() : NULL;
+    return _parameters_type_data_di != no_parameters ? data_layout_at(_parameters_type_data_di)->data_in()->as_ParametersTypeData() : nullptr;
   }
 
   int parameters_type_data_di() const {
diff --git a/src/hotspot/share/oops/objArrayKlass.cpp b/src/hotspot/share/oops/objArrayKlass.cpp
index a43816476e8..a0e3661e555 100644
--- a/src/hotspot/share/oops/objArrayKlass.cpp
+++ b/src/hotspot/share/oops/objArrayKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,26 +58,26 @@ ObjArrayKlass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_da
                                                       int n, Klass* element_klass, TRAPS) {
 
   // Eagerly allocate the direct array supertype.
-  Klass* super_klass = NULL;
+  Klass* super_klass = nullptr;
   if (!Universe::is_bootstrapping() || vmClasses::Object_klass_loaded()) {
     Klass* element_super = element_klass->super();
-    if (element_super != NULL) {
+    if (element_super != nullptr) {
       // The element type has a direct super.  E.g., String[] has direct super of Object[].
       super_klass = element_super->array_klass_or_null();
-      bool supers_exist = super_klass != NULL;
+      bool supers_exist = super_klass != nullptr;
       // Also, see if the element has secondary supertypes.
       // We need an array type for each.
       const Array<Klass*>* element_supers = element_klass->secondary_supers();
       for( int i = element_supers->length()-1; i >= 0; i-- ) {
         Klass* elem_super = element_supers->at(i);
-        if (elem_super->array_klass_or_null() == NULL) {
+        if (elem_super->array_klass_or_null() == nullptr) {
           supers_exist = false;
           break;
         }
       }
       if (!supers_exist) {
         // Oops.  Not allocated yet.  Back out, allocate it, and retry.
-        Klass* ek = NULL;
+        Klass* ek = nullptr;
         {
           MutexUnlocker mu(MultiArray_lock);
           super_klass = element_super->array_klass(CHECK_NULL);
@@ -97,7 +97,7 @@ ObjArrayKlass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_da
   }
 
   // Create type name for klass.
-  Symbol* name = NULL;
+  Symbol* name = nullptr;
   {
     ResourceMark rm(THREAD);
     char *name_str = element_klass->name()->as_C_string();
@@ -121,13 +121,13 @@ ObjArrayKlass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_da
   ObjArrayKlass* oak = ObjArrayKlass::allocate(loader_data, n, element_klass, name, CHECK_NULL);
 
   ModuleEntry* module = oak->module();
-  assert(module != NULL, "No module entry for array");
+  assert(module != nullptr, "No module entry for array");
 
   // Call complete_create_array_klass after all instance variables has been initialized.
   ArrayKlass::complete_create_array_klass(oak, super_klass, module, CHECK_NULL);
 
   // Add all classes to our internal class loader list here,
-  // including classes in the bootstrap (NULL) class loader.
+  // including classes in the bootstrap (null) class loader.
   // Do this step after creating the mirror so that if the
   // mirror creation fails, loaded_classes_do() doesn't find
   // an array class without a mirror.
@@ -146,7 +146,7 @@ ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayK
   } else {
     bk = element_klass;
   }
-  assert(bk != NULL && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
+  assert(bk != nullptr && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
   set_bottom_klass(bk);
   set_class_loader_data(bk->class_loader_data());
 
@@ -291,17 +291,17 @@ void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
   if (UseCompressedOops) {
     size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos);
     size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos);
-    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) ==
+    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, nullptr) ==
            objArrayOop(s)->obj_at_addr<narrowOop>(src_pos), "sanity");
-    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) ==
+    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, nullptr) ==
            objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos), "sanity");
     do_copy(s, src_offset, d, dst_offset, length, CHECK);
   } else {
     size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos);
     size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos);
-    assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) ==
+    assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, nullptr) ==
            objArrayOop(s)->obj_at_addr<oop>(src_pos), "sanity");
-    assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) ==
+    assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, nullptr) ==
            objArrayOop(d)->obj_at_addr<oop>(dst_pos), "sanity");
     do_copy(s, src_offset, d, dst_offset, length, CHECK);
   }
@@ -315,7 +315,7 @@ Klass* ObjArrayKlass::array_klass(int n, TRAPS) {
   if (dim == n) return this;
 
   // lock-free read needs acquire semantics
-  if (higher_dimension_acquire() == NULL) {
+  if (higher_dimension_acquire() == nullptr) {
 
     ResourceMark rm(THREAD);
     {
@@ -323,7 +323,7 @@ Klass* ObjArrayKlass::array_klass(int n, TRAPS) {
       MutexLocker mu(THREAD, MultiArray_lock);
 
       // Check if another thread beat us
-      if (higher_dimension() == NULL) {
+      if (higher_dimension() == nullptr) {
 
         // Create multi-dim klass object and link them together
         Klass* k =
@@ -349,8 +349,8 @@ Klass* ObjArrayKlass::array_klass_or_null(int n) {
   if (dim == n) return this;
 
   // lock-free read needs acquire semantics
-  if (higher_dimension_acquire() == NULL) {
-    return NULL;
+  if (higher_dimension_acquire() == nullptr) {
+    return nullptr;
   }
 
   ObjArrayKlass *ak = ObjArrayKlass::cast(higher_dimension());
@@ -375,15 +375,15 @@ bool ObjArrayKlass::can_be_primary_super_slow() const {
 
 GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots,
                                                                Array<InstanceKlass*>* transitive_interfaces) {
-  assert(transitive_interfaces == NULL, "sanity");
+  assert(transitive_interfaces == nullptr, "sanity");
   // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
   const Array<Klass*>* elem_supers = element_klass()->secondary_supers();
-  int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
+  int num_elem_supers = elem_supers == nullptr ? 0 : elem_supers->length();
   int num_secondaries = num_extra_slots + 2 + num_elem_supers;
   if (num_secondaries == 2) {
     // Must share this for correct bootstrapping!
     set_secondary_supers(Universe::the_array_interfaces_array());
-    return NULL;
+    return nullptr;
   } else {
     GrowableArray<Klass*>* secondaries = new GrowableArray<Klass*>(num_elem_supers+2);
     secondaries->push(vmClasses::Cloneable_klass());
@@ -391,7 +391,7 @@ GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slo
     for (int i = 0; i < num_elem_supers; i++) {
       Klass* elem_super = elem_supers->at(i);
       Klass* array_super = elem_super->array_klass_or_null();
-      assert(array_super != NULL, "must already have been created");
+      assert(array_super != nullptr, "must already have been created");
       secondaries->push(array_super);
     }
     return secondaries;
@@ -410,7 +410,7 @@ void ObjArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) {
 
 jint ObjArrayKlass::compute_modifier_flags() const {
   // The modifier for an objectArray is the same as its element
-  if (element_klass() == NULL) {
+  if (element_klass() == nullptr) {
     assert(Universe::is_bootstrapping(), "partial objArray only at startup");
     return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
   }
@@ -422,13 +422,13 @@ jint ObjArrayKlass::compute_modifier_flags() const {
 }
 
 ModuleEntry* ObjArrayKlass::module() const {
-  assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
+  assert(bottom_klass() != nullptr, "ObjArrayKlass returned unexpected null bottom_klass");
   // The array is defined in the module of its bottom class
   return bottom_klass()->module();
 }
 
 PackageEntry* ObjArrayKlass::package() const {
-  assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
+  assert(bottom_klass() != nullptr, "ObjArrayKlass returned unexpected null bottom_klass");
   return bottom_klass()->package();
 }
 
@@ -459,11 +459,11 @@ void ObjArrayKlass::oop_print_on(oop obj, outputStream* st) {
   int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
   for(int index = 0; index < print_len; index++) {
     st->print(" - %3d : ", index);
-    if (oa->obj_at(index) != NULL) {
+    if (oa->obj_at(index) != nullptr) {
       oa->obj_at(index)->print_value_on(st);
       st->cr();
     } else {
-      st->print_cr("NULL");
+      st->print_cr("null");
     }
   }
   int remaining = oa->length() - print_len;
@@ -480,10 +480,10 @@ void ObjArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
   element_klass()->print_value_on(st);
   int len = objArrayOop(obj)->length();
   st->print("[%d] ", len);
-  if (obj != NULL) {
+  if (obj != nullptr) {
     obj->print_address_on(st);
   } else {
-    st->print_cr("NULL");
+    st->print_cr("null");
   }
 }
 
diff --git a/src/hotspot/share/oops/objArrayOop.hpp b/src/hotspot/share/oops/objArrayOop.hpp
index 445568233c6..de6d4d3d042 100644
--- a/src/hotspot/share/oops/objArrayOop.hpp
+++ b/src/hotspot/share/oops/objArrayOop.hpp
@@ -35,6 +35,7 @@ class Klass;
 // Evaluating "String arg[10]" will create an objArrayOop.
 
 class objArrayOopDesc : public arrayOopDesc {
+  friend class ArchiveHeapWriter;
   friend class ObjArrayKlass;
   friend class Runtime1;
   friend class psPromotionManager;
diff --git a/src/hotspot/share/oops/oop.cpp b/src/hotspot/share/oops/oop.cpp
index caa70f6ee66..f64d76145fd 100644
--- a/src/hotspot/share/oops/oop.cpp
+++ b/src/hotspot/share/oops/oop.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@ void oopDesc::print_value_on(outputStream* st) const {
 
 
 void oopDesc::verify_on(outputStream* st, oopDesc* oop_desc) {
-  if (oop_desc != NULL) {
+  if (oop_desc != nullptr) {
     oop_desc->klass()->oop_verify_on(oop_desc, st);
   }
 }
@@ -123,7 +123,7 @@ bool oopDesc::is_oop(oop obj, bool ignore_mark_word) {
 
 // used only for asserts and guarantees
 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
-  return obj == NULL ? true : is_oop(obj, ignore_mark_word);
+  return obj == nullptr ? true : is_oop(obj, ignore_mark_word);
 }
 
 VerifyOopClosure VerifyOopClosure::verify_oop;
@@ -160,7 +160,7 @@ void oopDesc::set_narrow_klass(narrowKlass nk) {
 void* oopDesc::load_klass_raw(oop obj) {
   if (UseCompressedClassPointers) {
     narrowKlass narrow_klass = obj->_metadata._compressed_klass;
-    if (narrow_klass == 0) return NULL;
+    if (narrow_klass == 0) return nullptr;
     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
   } else {
     return obj->_metadata._klass;
@@ -171,7 +171,7 @@ void* oopDesc::load_oop_raw(oop obj, int offset) {
   uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
   if (UseCompressedOops) {
     narrowOop narrow_oop = *(narrowOop*)addr;
-    if (CompressedOops::is_null(narrow_oop)) return NULL;
+    if (CompressedOops::is_null(narrow_oop)) return nullptr;
     return (void*)CompressedOops::decode_raw(narrow_oop);
   } else {
     return *(void**)addr;
diff --git a/src/hotspot/share/oops/oop.hpp b/src/hotspot/share/oops/oop.hpp
index 6cf6719e324..b0ef4ef03af 100644
--- a/src/hotspot/share/oops/oop.hpp
+++ b/src/hotspot/share/oops/oop.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,6 +85,8 @@ class oopDesc {
   inline Klass* klass() const;
   inline Klass* klass_or_null() const;
   inline Klass* klass_or_null_acquire() const;
+  // Get the raw value without any checks.
+  inline Klass* klass_raw() const;
 
   void set_narrow_klass(narrowKlass nk) NOT_CDS_JAVA_HEAP_RETURN;
   inline void set_klass(Klass* k);
@@ -260,7 +262,7 @@ class oopDesc {
 
   // Like "forward_to", but inserts the forwarding pointer atomically.
   // Exactly one thread succeeds in inserting the forwarding pointer, and
-  // this call returns "NULL" for that thread; any other thread has the
+  // this call returns null for that thread; any other thread has the
   // value of the forwarding pointer returned and does not modify "this".
   inline oop forward_to_atomic(oop p, markWord compare, atomic_memory_order order = memory_order_conservative);
 
diff --git a/src/hotspot/share/oops/oop.inline.hpp b/src/hotspot/share/oops/oop.inline.hpp
index 0d528d64f54..cf05750e862 100644
--- a/src/hotspot/share/oops/oop.inline.hpp
+++ b/src/hotspot/share/oops/oop.inline.hpp
@@ -107,8 +107,16 @@ Klass* oopDesc::klass_or_null_acquire() const {
   }
 }
 
+Klass* oopDesc::klass_raw() const {
+  if (UseCompressedClassPointers) {
+    return CompressedKlassPointers::decode_raw(_metadata._compressed_klass);
+  } else {
+    return _metadata._klass;
+  }
+}
+
 void oopDesc::set_klass(Klass* k) {
-  assert(Universe::is_bootstrapping() || (k != NULL && k->is_klass()), "incorrect Klass");
+  assert(Universe::is_bootstrapping() || (k != nullptr && k->is_klass()), "incorrect Klass");
   if (UseCompressedClassPointers) {
     _metadata._compressed_klass = CompressedKlassPointers::encode_not_null(k);
   } else {
@@ -117,7 +125,7 @@ void oopDesc::set_klass(Klass* k) {
 }
 
 void oopDesc::release_set_klass(HeapWord* mem, Klass* k) {
-  assert(Universe::is_bootstrapping() || (k != NULL && k->is_klass()), "incorrect Klass");
+  assert(Universe::is_bootstrapping() || (k != nullptr && k->is_klass()), "incorrect Klass");
   char* raw_mem = ((char*)mem + klass_offset_in_bytes());
   if (UseCompressedClassPointers) {
     Atomic::release_store((narrowKlass*)raw_mem,
@@ -270,7 +278,7 @@ oop oopDesc::forward_to_atomic(oop p, markWord compare, atomic_memory_order orde
   assert(m.decode_pointer() == p, "encoding must be reversible");
   markWord old_mark = cas_set_mark(m, compare, order);
   if (old_mark == compare) {
-    return NULL;
+    return nullptr;
   } else {
     return cast_to_oop(old_mark.decode_pointer());
   }
@@ -341,7 +349,7 @@ void oopDesc::oop_iterate_backwards(OopClosureType* cl, Klass* k) {
 }
 
 bool oopDesc::is_instanceof_or_null(oop obj, Klass* klass) {
-  return obj == NULL || obj->klass()->is_subtype_of(klass);
+  return obj == nullptr || obj->klass()->is_subtype_of(klass);
 }
 
 intptr_t oopDesc::identity_hash() {
diff --git a/src/hotspot/share/oops/oopHandle.hpp b/src/hotspot/share/oops/oopHandle.hpp
index 490c9f9eec4..ae631fd7d53 100644
--- a/src/hotspot/share/oops/oopHandle.hpp
+++ b/src/hotspot/share/oops/oopHandle.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@ class OopHandle {
   oop* _obj;
 
 public:
-  OopHandle() : _obj(NULL) {}
+  OopHandle() : _obj(nullptr) {}
   explicit OopHandle(oop* w) : _obj(w) {}
   OopHandle(OopStorage* storage, oop obj);
 
@@ -64,7 +64,7 @@ class OopHandle {
   inline oop resolve() const;
   inline oop peek() const;
 
-  bool is_empty() const { return _obj == NULL; }
+  bool is_empty() const { return _obj == nullptr; }
 
   inline void release(OopStorage* storage);
 
diff --git a/src/hotspot/share/oops/oopHandle.inline.hpp b/src/hotspot/share/oops/oopHandle.inline.hpp
index 20de5146ec3..6c7c0275aa7 100644
--- a/src/hotspot/share/oops/oopHandle.inline.hpp
+++ b/src/hotspot/share/oops/oopHandle.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,16 +31,16 @@
 #include "gc/shared/oopStorage.inline.hpp"
 
 inline oop OopHandle::resolve() const {
-  return (_obj == NULL) ? (oop)NULL : NativeAccess<>::oop_load(_obj);
+  return (_obj == nullptr) ? (oop)nullptr : NativeAccess<>::oop_load(_obj);
 }
 
 inline oop OopHandle::peek() const {
-  return (_obj == NULL) ? (oop)NULL : NativeAccess<AS_NO_KEEPALIVE>::oop_load(_obj);
+  return (_obj == nullptr) ? (oop)nullptr : NativeAccess<AS_NO_KEEPALIVE>::oop_load(_obj);
 }
 
 inline OopHandle::OopHandle(OopStorage* storage, oop obj) :
     _obj(storage->allocate()) {
-  if (_obj == NULL) {
+  if (_obj == nullptr) {
     vm_exit_out_of_memory(sizeof(oop), OOM_MALLOC_ERROR,
                           "Cannot create oop handle");
   }
@@ -48,16 +48,16 @@ inline OopHandle::OopHandle(OopStorage* storage, oop obj) :
 }
 
 inline void OopHandle::release(OopStorage* storage) {
-  if (_obj != NULL) {
+  if (_obj != nullptr) {
     // Clear the OopHandle first
-    NativeAccess<>::oop_store(_obj, (oop)NULL);
+    NativeAccess<>::oop_store(_obj, nullptr);
     storage->release(_obj);
   }
 }
 
 inline void OopHandle::replace(oop obj) {
   oop* ptr = ptr_raw();
-  assert(ptr != NULL, "should not use replace");
+  assert(ptr != nullptr, "should not use replace");
   NativeAccess<>::oop_store(ptr, obj);
 }
 
diff --git a/src/hotspot/share/oops/oopsHierarchy.cpp b/src/hotspot/share/oops/oopsHierarchy.cpp
index 057bfbf3e77..779ca1777d1 100644
--- a/src/hotspot/share/oops/oopsHierarchy.cpp
+++ b/src/hotspot/share/oops/oopsHierarchy.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@ void oop::register_oop() {
   if (!Universe::is_fully_initialized()) return;
   // This gets expensive, which is why checking unhandled oops is on a switch.
   Thread* t = Thread::current_or_null();
-  if (t != NULL && t->is_Java_thread()) {
+  if (t != nullptr && t->is_Java_thread()) {
      t->unhandled_oops()->register_unhandled_oop(this);
   }
 }
@@ -45,7 +45,7 @@ void oop::unregister_oop() {
   if (!Universe::is_fully_initialized()) return;
   // This gets expensive, which is why checking unhandled oops is on a switch.
   Thread* t = Thread::current_or_null();
-  if (t != NULL && t->is_Java_thread()) {
+  if (t != nullptr && t->is_Java_thread()) {
     t->unhandled_oops()->unregister_unhandled_oop(this);
   }
 }
diff --git a/src/hotspot/share/oops/oopsHierarchy.hpp b/src/hotspot/share/oops/oopsHierarchy.hpp
index bdfb47fe38d..a5886a005b2 100644
--- a/src/hotspot/share/oops/oopsHierarchy.hpp
+++ b/src/hotspot/share/oops/oopsHierarchy.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@ typedef class     typeArrayOopDesc*           typeArrayOop;
 // a conversion to or from an oop to a numerical type is needed,
 // use the inline template methods, cast_*_oop, defined below.
 //
-// Converting NULL to oop to Handle implicit is no longer accepted by the
+// Converting null to oop to Handle implicit is no longer accepted by the
 // compiler because there are too many steps in the conversion.  Use Handle()
 // instead, which generates less code anyway.
 
diff --git a/src/hotspot/share/oops/recordComponent.cpp b/src/hotspot/share/oops/recordComponent.cpp
index db4426fc950..5d4d072a7e0 100644
--- a/src/hotspot/share/oops/recordComponent.cpp
+++ b/src/hotspot/share/oops/recordComponent.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,10 +43,10 @@ RecordComponent* RecordComponent::allocate(ClassLoaderData* loader_data,
 }
 
 void RecordComponent::deallocate_contents(ClassLoaderData* loader_data) {
-  if (annotations() != NULL) {
+  if (annotations() != nullptr) {
     MetadataFactory::free_array<u1>(loader_data, annotations());
   }
-  if (type_annotations() != NULL) {
+  if (type_annotations() != nullptr) {
     MetadataFactory::free_array<u1>(loader_data, type_annotations());
   }
 }
@@ -70,11 +70,11 @@ void RecordComponent::print_on(outputStream* st) const {
     st->print(" - generic_signature_index: %d", _generic_signature_index);
   }
   st->cr();
-  if (_annotations != NULL) {
+  if (_annotations != nullptr) {
     st->print_cr("record component annotations");
     _annotations->print_value_on(st);
   }
-  if (_type_annotations != NULL) {
+  if (_type_annotations != nullptr) {
     st->print_cr("record component type annotations");
     _type_annotations->print_value_on(st);
   }
diff --git a/src/hotspot/share/oops/stackChunkOop.hpp b/src/hotspot/share/oops/stackChunkOop.hpp
index c1c0aee8f24..36b06ecd324 100644
--- a/src/hotspot/share/oops/stackChunkOop.hpp
+++ b/src/hotspot/share/oops/stackChunkOop.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -193,8 +193,8 @@ class stackChunkOopDesc : public instanceOopDesc {
   void print_on(bool verbose, outputStream* st) const;
 
   // Verifies the consistency of the chunk's data
-  bool verify(size_t* out_size = NULL, int* out_oops = NULL,
-              int* out_frames = NULL, int* out_interpreted_frames = NULL) NOT_DEBUG({ return true; });
+  bool verify(size_t* out_size = nullptr, int* out_oops = nullptr,
+              int* out_frames = nullptr, int* out_interpreted_frames = nullptr) NOT_DEBUG({ return true; });
 
 private:
   template <BarrierType barrier, ChunkFrames frames = ChunkFrames::Mixed, typename RegisterMapT>
diff --git a/src/hotspot/share/oops/symbol.cpp b/src/hotspot/share/oops/symbol.cpp
index cd4c827adb1..5aa5f4e5dcf 100644
--- a/src/hotspot/share/oops/symbol.cpp
+++ b/src/hotspot/share/oops/symbol.cpp
@@ -132,7 +132,7 @@ int Symbol::index_of_at(int i, const char* substr, int substr_len) const {
     return -1;
   for (; scan <= limit; scan++) {
     scan = (address) memchr(scan, first_char, (limit + 1 - scan));
-    if (scan == NULL)
+    if (scan == nullptr)
       return -1;  // not found
     assert(scan >= bytes+i && scan <= limit, "scan oob");
     if (substr_len <= 2
@@ -145,7 +145,7 @@ int Symbol::index_of_at(int i, const char* substr, int substr_len) const {
 }
 
 bool Symbol::is_star_match(const char* pattern) const {
-  if (strchr(pattern, '*') == NULL) {
+  if (strchr(pattern, '*') == nullptr) {
     return equals(pattern);
   } else {
     ResourceMark rm;
@@ -185,7 +185,7 @@ void Symbol::print_symbol_on(outputStream* st) const {
     s = as_quoted_ascii();
     s = os::strdup(s);
   }
-  if (s == NULL) {
+  if (s == nullptr) {
     st->print("(null)");
   } else {
     st->print("%s", s);
diff --git a/src/hotspot/share/oops/symbol.hpp b/src/hotspot/share/oops/symbol.hpp
index 7e3657acd4b..2773b9b6c29 100644
--- a/src/hotspot/share/oops/symbol.hpp
+++ b/src/hotspot/share/oops/symbol.hpp
@@ -173,12 +173,12 @@ class Symbol : public MetaspaceObj {
   void make_permanent();
 
   static void maybe_increment_refcount(Symbol* s) {
-    if (s != NULL) {
+    if (s != nullptr) {
       s->increment_refcount();
     }
   }
   static void maybe_decrement_refcount(Symbol* s) {
-    if (s != NULL) {
+    if (s != nullptr) {
       s->decrement_refcount();
     }
   }
@@ -228,7 +228,7 @@ class Symbol : public MetaspaceObj {
   // Tests if the symbol contains the given utf8 substring
   // at the given byte position.
   bool contains_utf8_at(int position, const char* substring, int len) const {
-    assert(len >= 0 && substring != NULL, "substring must be valid");
+    assert(len >= 0 && substring != nullptr, "substring must be valid");
     if (position < 0)  return false;  // can happen with ends_with
     if (position + len > utf8_length()) return false;
     return (memcmp((char*)base() + position, substring, len) == 0);
@@ -281,7 +281,7 @@ class Symbol : public MetaspaceObj {
   MetaspaceObj::Type type() const { return SymbolType; }
 
   // Printing
-  void print_symbol_on(outputStream* st = NULL) const;
+  void print_symbol_on(outputStream* st = nullptr) const;
   void print_utf8_on(outputStream* st) const;
   void print_on(outputStream* st) const;         // First level print
   void print_value_on(outputStream* st) const;   // Second level print.
diff --git a/src/hotspot/share/oops/symbolHandle.hpp b/src/hotspot/share/oops/symbolHandle.hpp
index b12ba59cace..249da936761 100644
--- a/src/hotspot/share/oops/symbolHandle.hpp
+++ b/src/hotspot/share/oops/symbolHandle.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,14 +46,13 @@ class SymbolHandleBase : public StackObj {
   Symbol* _temp;
 
 public:
-  SymbolHandleBase() : _temp(NULL) { }
+  SymbolHandleBase() : _temp(nullptr) { }
 
   // Conversion from a Symbol* to a SymbolHandleBase.
   // Does not increment the current reference count if temporary.
   SymbolHandleBase(Symbol *s) : _temp(s) {
     if (!TEMP) {
-      assert(s != nullptr, "must not be null");
-      s->increment_refcount();
+      Symbol::maybe_increment_refcount(_temp);
     }
   }
 
diff --git a/src/hotspot/share/oops/typeArrayKlass.cpp b/src/hotspot/share/oops/typeArrayKlass.cpp
index fa67b4876d9..899531d33cd 100644
--- a/src/hotspot/share/oops/typeArrayKlass.cpp
+++ b/src/hotspot/share/oops/typeArrayKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,8 +44,8 @@
 
 TypeArrayKlass* TypeArrayKlass::create_klass(BasicType type,
                                       const char* name_str, TRAPS) {
-  Symbol* sym = NULL;
-  if (name_str != NULL) {
+  Symbol* sym = nullptr;
+  if (name_str != nullptr) {
     sym = SymbolTable::new_permanent_symbol(name_str);
   }
 
@@ -57,7 +57,7 @@ TypeArrayKlass* TypeArrayKlass::create_klass(BasicType type,
   complete_create_array_klass(ak, ak->super(), ModuleEntryTable::javabase_moduleEntry(), CHECK_NULL);
 
   // Add all classes to our internal class loader list here,
-  // including classes in the bootstrap (NULL) class loader.
+  // including classes in the bootstrap (null) class loader.
   // Do this step after creating the mirror so that if the
   // mirror creation fails, loaded_classes_do() doesn't find
   // an array class without a mirror.
@@ -178,7 +178,7 @@ Klass* TypeArrayKlass::array_klass(int n, TRAPS) {
       return this;
 
   // lock-free read needs acquire semantics
-  if (higher_dimension_acquire() == NULL) {
+  if (higher_dimension_acquire() == nullptr) {
 
     ResourceMark rm;
     JavaThread *jt = THREAD;
@@ -186,7 +186,7 @@ Klass* TypeArrayKlass::array_klass(int n, TRAPS) {
       // Atomic create higher dimension and link into list
       MutexLocker mu(THREAD, MultiArray_lock);
 
-      if (higher_dimension() == NULL) {
+      if (higher_dimension() == nullptr) {
         Klass* oak = ObjArrayKlass::allocate_objArray_klass(
               class_loader_data(), dim + 1, this, CHECK_NULL);
         ObjArrayKlass* h_ak = ObjArrayKlass::cast(oak);
@@ -211,8 +211,8 @@ Klass* TypeArrayKlass::array_klass_or_null(int n) {
       return this;
 
   // lock-free read needs acquire semantics
-  if (higher_dimension_acquire() == NULL) {
-    return NULL;
+  if (higher_dimension_acquire() == nullptr) {
+    return nullptr;
   }
 
   ObjArrayKlass* h_ak = ObjArrayKlass::cast(higher_dimension());
@@ -250,7 +250,7 @@ const char* TypeArrayKlass::external_name(BasicType type) {
     case T_LONG:    return "[J";
     default: ShouldNotReachHere();
   }
-  return NULL;
+  return nullptr;
 }
 
 
@@ -372,5 +372,5 @@ ModuleEntry* TypeArrayKlass::module() const {
 }
 
 PackageEntry* TypeArrayKlass::package() const {
-  return NULL;
+  return nullptr;
 }
diff --git a/src/hotspot/share/oops/typeArrayKlass.hpp b/src/hotspot/share/oops/typeArrayKlass.hpp
index 389c5ddbd74..5d4a739936f 100644
--- a/src/hotspot/share/oops/typeArrayKlass.hpp
+++ b/src/hotspot/share/oops/typeArrayKlass.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@ class TypeArrayKlass : public ArrayKlass {
   typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); }
   oop multi_allocate(int rank, jint* sizes, TRAPS);
 
-  oop protection_domain() const { return NULL; }
+  oop protection_domain() const { return nullptr; }
 
   // Copying
   void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
diff --git a/src/hotspot/share/oops/weakHandle.cpp b/src/hotspot/share/oops/weakHandle.cpp
index 48bb2a1368d..84a230fdf48 100644
--- a/src/hotspot/share/oops/weakHandle.cpp
+++ b/src/hotspot/share/oops/weakHandle.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,9 +35,9 @@ WeakHandle::WeakHandle(OopStorage* storage, Handle obj) :
 
 WeakHandle::WeakHandle(OopStorage* storage, oop obj) :
     _obj(storage->allocate()) {
-  assert(obj != NULL, "no need to create weak null oop");
+  assert(obj != nullptr, "no need to create weak null oop");
 
-  if (_obj == NULL) {
+  if (_obj == nullptr) {
     vm_exit_out_of_memory(sizeof(oop*), OOM_MALLOC_ERROR,
                           "Unable to create new weak oop handle in OopStorage %s",
                           storage->name());
@@ -48,10 +48,10 @@ WeakHandle::WeakHandle(OopStorage* storage, oop obj) :
 
 void WeakHandle::release(OopStorage* storage) const {
   // Only release if the pointer to the object has been created.
-  if (_obj != NULL) {
+  if (_obj != nullptr) {
     // Clear the WeakHandle.  For race in creating ClassLoaderData, we can release this
     // WeakHandle before it is cleared by GC.
-    NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(_obj, (oop)NULL);
+    NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(_obj, nullptr);
     storage->release(_obj);
   }
 }
diff --git a/src/hotspot/share/oops/weakHandle.hpp b/src/hotspot/share/oops/weakHandle.hpp
index c2b589958d2..95328d27aef 100644
--- a/src/hotspot/share/oops/weakHandle.hpp
+++ b/src/hotspot/share/oops/weakHandle.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@ class OopStorage;
 // processed weakly by GC.  The runtime structures that point to the oop must
 // either peek or resolve the oop, the latter will keep the oop alive for
 // the GC cycle.  The runtime structures that reference the oop must test
-// if the value is NULL.  If it is NULL, it has been cleaned out by GC.
+// if the value is null.  If it is null, it has been cleaned out by GC.
 // This is the vm version of jweak but has different GC lifetimes and policies,
 // depending on the type.
 
@@ -46,21 +46,21 @@ class WeakHandle {
 
   WeakHandle(oop* w) : _obj(w) {}
  public:
-  WeakHandle() : _obj(NULL) {} // needed for init
+  WeakHandle() : _obj(nullptr) {} // needed for init
   WeakHandle(OopStorage* storage, Handle obj);
   WeakHandle(OopStorage* storage, oop obj);
 
   inline oop resolve() const;
   inline oop peek() const;
   void release(OopStorage* storage) const;
-  bool is_null() const { return _obj == NULL; }
+  bool is_null() const { return _obj == nullptr; }
 
   void replace(oop with_obj);
 
   void print() const;
   void print_on(outputStream* st) const;
 
-  bool is_empty() const { return _obj == NULL; }
+  bool is_empty() const { return _obj == nullptr; }
   oop* ptr_raw() const { return _obj; }
 };
 
diff --git a/src/hotspot/share/opto/bytecodeInfo.cpp b/src/hotspot/share/opto/bytecodeInfo.cpp
index 13f58b90c44..461866f69d8 100644
--- a/src/hotspot/share/opto/bytecodeInfo.cpp
+++ b/src/hotspot/share/opto/bytecodeInfo.cpp
@@ -114,7 +114,7 @@ static bool is_unboxing_method(ciMethod* callee_method, Compile* C) {
 
 // positive filter: should callee be inlined?
 bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
-                               int caller_bci, NOT_PRODUCT_ARG(bool& should_delay) ciCallProfile& profile) {
+                               int caller_bci, bool& should_delay, ciCallProfile& profile) {
   // Allows targeted inlining
   if (C->directive()->should_inline(callee_method)) {
     set_msg("force inline by CompileCommand");
@@ -128,7 +128,6 @@ bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
     return true;
   }
 
-#ifndef PRODUCT
   int inline_depth = inline_level() + 1;
   if (ciReplay::should_inline(C->replay_inline_data(), callee_method, caller_bci, inline_depth, should_delay)) {
     if (should_delay) {
@@ -139,7 +138,6 @@ bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
     _forced_inline = true;
     return true;
   }
-#endif
 
   int size = callee_method->code_size_for_inlining();
 
@@ -199,7 +197,7 @@ bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
 
 // negative filter: should callee NOT be inlined?
 bool InlineTree::should_not_inline(ciMethod* callee_method, ciMethod* caller_method,
-                                   int caller_bci, NOT_PRODUCT_ARG(bool& should_delay) ciCallProfile& profile) {
+                                   int caller_bci, bool& should_delay, ciCallProfile& profile) {
   const char* fail_msg = NULL;
 
   // First check all inlining restrictions which are required for correctness
@@ -243,7 +241,6 @@ bool InlineTree::should_not_inline(ciMethod* callee_method, ciMethod* caller_met
     return true;
   }
 
-#ifndef PRODUCT
   int inline_depth = inline_level() + 1;
   if (ciReplay::should_inline(C->replay_inline_data(), callee_method, caller_bci, inline_depth, should_delay)) {
     if (should_delay) {
@@ -263,7 +260,6 @@ bool InlineTree::should_not_inline(ciMethod* callee_method, ciMethod* caller_met
     set_msg("disallowed by ciReplay");
     return true;
   }
-#endif
 
   if (callee_method->force_inline()) {
     set_msg("force inline by annotation");
@@ -379,11 +375,11 @@ bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,
   _forced_inline = false; // Reset
 
   // 'should_delay' can be overridden during replay compilation
-  if (!should_inline(callee_method, caller_method, caller_bci, NOT_PRODUCT_ARG(should_delay) profile)) {
+  if (!should_inline(callee_method, caller_method, caller_bci, should_delay, profile)) {
     return false;
   }
   // 'should_delay' can be overridden during replay compilation
-  if (should_not_inline(callee_method, caller_method, caller_bci, NOT_PRODUCT_ARG(should_delay) profile)) {
+  if (should_not_inline(callee_method, caller_method, caller_bci, should_delay, profile)) {
     return false;
   }
 
diff --git a/src/hotspot/share/opto/c2compiler.cpp b/src/hotspot/share/opto/c2compiler.cpp
index 2399ab8bdbf..a6fa097bdee 100644
--- a/src/hotspot/share/opto/c2compiler.cpp
+++ b/src/hotspot/share/opto/c2compiler.cpp
@@ -782,6 +782,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
   case vmIntrinsics::_VectorExtract:
   case vmIntrinsics::_VectorMaskOp:
   case vmIntrinsics::_IndexVector:
+  case vmIntrinsics::_IndexPartiallyInUpperRange:
     return EnableVectorSupport;
   case vmIntrinsics::_blackhole:
     break;
diff --git a/src/hotspot/share/opto/constantTable.cpp b/src/hotspot/share/opto/constantTable.cpp
index 91452408c2b..d5b20c3334a 100644
--- a/src/hotspot/share/opto/constantTable.cpp
+++ b/src/hotspot/share/opto/constantTable.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -269,6 +269,7 @@ ConstantTable::Constant ConstantTable::add(MachConstantNode* n, MachOper* oper)
   BasicType type = oper->type()->basic_type();
   switch (type) {
   case T_LONG:    value.j = oper->constantL(); break;
+  case T_INT:     value.i = oper->constant();  break;
   case T_FLOAT:   value.f = oper->constantF(); break;
   case T_DOUBLE:  value.d = oper->constantD(); break;
   case T_OBJECT:
diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp
index 73a3566136f..a481045dc1f 100644
--- a/src/hotspot/share/opto/library_call.cpp
+++ b/src/hotspot/share/opto/library_call.cpp
@@ -725,6 +725,8 @@ bool LibraryCallKit::try_to_inline(int predicate) {
     return inline_vector_compress_expand();
   case vmIntrinsics::_IndexVector:
     return inline_index_vector();
+  case vmIntrinsics::_IndexPartiallyInUpperRange:
+    return inline_index_partially_in_upper_range();
 
   case vmIntrinsics::_getObjectSize:
     return inline_getObjectSize();
diff --git a/src/hotspot/share/opto/library_call.hpp b/src/hotspot/share/opto/library_call.hpp
index 0293338ca82..97feb431dbf 100644
--- a/src/hotspot/share/opto/library_call.hpp
+++ b/src/hotspot/share/opto/library_call.hpp
@@ -357,6 +357,7 @@ class LibraryCallKit : public GraphKit {
   bool inline_vector_insert();
   bool inline_vector_compress_expand();
   bool inline_index_vector();
+  bool inline_index_partially_in_upper_range();
 
   Node* gen_call_to_svml(int vector_api_op_id, BasicType bt, int num_elem, Node* opd1, Node* opd2);
 
diff --git a/src/hotspot/share/opto/parse.hpp b/src/hotspot/share/opto/parse.hpp
index 919f731c0de..f06e242f444 100644
--- a/src/hotspot/share/opto/parse.hpp
+++ b/src/hotspot/share/opto/parse.hpp
@@ -76,12 +76,12 @@ class InlineTree : public AnyObj {
   bool        should_inline(ciMethod* callee_method,
                             ciMethod* caller_method,
                             int caller_bci,
-                            NOT_PRODUCT_ARG(bool& should_delay)
+                            bool& should_delay,
                             ciCallProfile& profile);
   bool        should_not_inline(ciMethod* callee_method,
                                 ciMethod* caller_method,
                                 int caller_bci,
-                                NOT_PRODUCT_ARG(bool& should_delay)
+                                bool& should_delay,
                                 ciCallProfile& profile);
   bool        is_not_reached(ciMethod* callee_method,
                              ciMethod* caller_method,
diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp
index 201d947264e..d088cfb1d0f 100644
--- a/src/hotspot/share/opto/vectorIntrinsics.cpp
+++ b/src/hotspot/share/opto/vectorIntrinsics.cpp
@@ -3006,3 +3006,131 @@ bool LibraryCallKit::inline_index_vector() {
   C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt))));
   return true;
 }
+
+// public static
+// <E,
+//  M extends VectorMask<E>>
+// M indexPartiallyInUpperRange(Class<? extends M> mClass, Class<E> eClass, int length,
+//                              long offset, long limit,
+//                              IndexPartiallyInUpperRangeOperation<E, M> defaultImpl)
+bool LibraryCallKit::inline_index_partially_in_upper_range() {
+  const TypeInstPtr* mask_klass   = gvn().type(argument(0))->isa_instptr();
+  const TypeInstPtr* elem_klass   = gvn().type(argument(1))->isa_instptr();
+  const TypeInt*     vlen         = gvn().type(argument(2))->isa_int();
+
+  if (mask_klass == NULL || elem_klass == NULL || vlen == NULL ||
+      mask_klass->const_oop() == NULL || elem_klass->const_oop() == NULL || !vlen->is_con()) {
+    if (C->print_intrinsics()) {
+      tty->print_cr("  ** missing constant: mclass=%s etype=%s vlen=%s",
+                    NodeClassNames[argument(0)->Opcode()],
+                    NodeClassNames[argument(1)->Opcode()],
+                    NodeClassNames[argument(2)->Opcode()]);
+    }
+    return false; // not enough info for intrinsification
+  }
+
+  if (!is_klass_initialized(mask_klass)) {
+    if (C->print_intrinsics()) {
+      tty->print_cr("  ** klass argument not initialized");
+    }
+    return false;
+  }
+
+  ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type();
+  if (!elem_type->is_primitive_type()) {
+    if (C->print_intrinsics()) {
+      tty->print_cr("  ** not a primitive bt=%d", elem_type->basic_type());
+    }
+    return false; // should be primitive type
+  }
+
+  int num_elem = vlen->get_con();
+  BasicType elem_bt = elem_type->basic_type();
+
+  // Check whether the necessary ops are supported by current hardware.
+  bool supports_mask_gen = arch_supports_vector(Op_VectorMaskGen, num_elem, elem_bt, VecMaskUseStore);
+  if (!supports_mask_gen) {
+    if (!arch_supports_vector(Op_VectorLoadConst, num_elem, elem_bt, VecMaskNotUsed) ||
+        !arch_supports_vector(VectorNode::replicate_opcode(elem_bt), num_elem, elem_bt, VecMaskNotUsed) ||
+        !arch_supports_vector(Op_VectorMaskCmp, num_elem, elem_bt, VecMaskUseStore)) {
+      if (C->print_intrinsics()) {
+        tty->print_cr("  ** not supported: vlen=%d etype=%s", num_elem, type2name(elem_bt));
+      }
+      return false; // not supported
+    }
+
+    // Check whether the scalar cast operation is supported by current hardware.
+    if (elem_bt != T_LONG) {
+      int cast_op = is_integral_type(elem_bt) ? Op_ConvL2I
+                                              : (elem_bt == T_FLOAT ? Op_ConvL2F : Op_ConvL2D);
+      if (!Matcher::match_rule_supported(cast_op)) {
+        if (C->print_intrinsics()) {
+          tty->print_cr("  ** Rejected op (%s) because architecture does not support it",
+                        NodeClassNames[cast_op]);
+        }
+        return false; // not supported
+      }
+    }
+  }
+
+  Node* offset = argument(3);
+  Node* limit = argument(5);
+  if (offset == NULL || limit == NULL) {
+    if (C->print_intrinsics()) {
+      tty->print_cr("  ** offset or limit argument is NULL");
+    }
+    return false; // not supported
+  }
+
+  ciKlass* box_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass();
+  assert(is_vector_mask(box_klass), "argument(0) should be a mask class");
+  const TypeInstPtr* box_type = TypeInstPtr::make_exact(TypePtr::NotNull, box_klass);
+
+  // We assume "offset > 0 && limit >= offset && limit - offset < num_elem".
+  // So directly get indexLimit with "indexLimit = limit - offset".
+  Node* indexLimit = gvn().transform(new SubLNode(limit, offset));
+  Node* mask = NULL;
+  if (supports_mask_gen) {
+    mask = gvn().transform(VectorMaskGenNode::make(indexLimit, elem_bt, num_elem));
+  } else {
+    // Generate the vector mask based on "mask = iota < indexLimit".
+    // Broadcast "indexLimit" to a vector.
+    switch (elem_bt) {
+      case T_BOOLEAN: // fall-through
+      case T_BYTE:    // fall-through
+      case T_SHORT:   // fall-through
+      case T_CHAR:    // fall-through
+      case T_INT: {
+        indexLimit = gvn().transform(new ConvL2INode(indexLimit));
+        break;
+      }
+      case T_DOUBLE: {
+        indexLimit = gvn().transform(new ConvL2DNode(indexLimit));
+        break;
+      }
+      case T_FLOAT: {
+        indexLimit = gvn().transform(new ConvL2FNode(indexLimit));
+        break;
+      }
+      case T_LONG: {
+        // no conversion needed
+        break;
+      }
+      default: fatal("%s", type2name(elem_bt));
+    }
+    indexLimit = gvn().transform(VectorNode::scalar2vector(indexLimit, num_elem, Type::get_const_basic_type(elem_bt)));
+
+    // Load the "iota" vector.
+    const TypeVect* vt = TypeVect::make(elem_bt, num_elem);
+    Node* iota = gvn().transform(new VectorLoadConstNode(gvn().makecon(TypeInt::ZERO), vt));
+
+    // Compute the vector mask with "mask = iota < indexLimit".
+    ConINode* pred_node = (ConINode*)gvn().makecon(TypeInt::make(BoolTest::lt));
+    const TypeVect* vmask_type = TypeVect::makemask(elem_bt, num_elem);
+    mask = gvn().transform(new VectorMaskCmpNode(BoolTest::lt, iota, indexLimit, pred_node, vmask_type));
+  }
+  Node* vbox = box_vector(mask, box_type, elem_bt, num_elem);
+  set_result(vbox);
+  C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt))));
+  return true;
+}
diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp
index a2917f1b5b9..37bd3a19729 100644
--- a/src/hotspot/share/prims/jvmtiEnv.cpp
+++ b/src/hotspot/share/prims/jvmtiEnv.cpp
@@ -149,7 +149,7 @@ jvmtiError
 JvmtiEnv::SetThreadLocalStorage(jthread thread, const void* data) {
   JavaThread* current = JavaThread::current();
   JvmtiThreadState* state = nullptr;
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current);
 
   JavaThread* java_thread = nullptr;
@@ -202,7 +202,7 @@ JvmtiEnv::GetThreadLocalStorage(jthread thread, void** data_ptr) {
     VM_ENTRY_BASE(jvmtiError, JvmtiEnv::GetThreadLocalStorage , current_thread)
     debug_only(VMNativeEntryWrapper __vew;)
 
-    JvmtiVTMSTransitionDisabler disabler;
+    JvmtiVTMSTransitionDisabler disabler(thread);
     ThreadsListHandle tlh(current_thread);
 
     JavaThread* java_thread = nullptr;
@@ -575,7 +575,7 @@ JvmtiEnv::SetEventNotificationMode(jvmtiEventMode mode, jvmtiEvent event_type, j
   if (event_type == JVMTI_EVENT_CLASS_FILE_LOAD_HOOK && enabled) {
     record_class_file_load_hook_enabled();
   }
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(event_thread);
 
   if (event_thread == nullptr) {
     // Can be called at Agent_OnLoad() time with event_thread == nullptr
@@ -856,7 +856,7 @@ JvmtiEnv::GetJLocationFormat(jvmtiJlocationFormat* format_ptr) {
 jvmtiError
 JvmtiEnv::GetThreadState(jthread thread, jint* thread_state_ptr) {
   JavaThread* current_thread = JavaThread::current();
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1181,7 +1181,7 @@ jvmtiError
 JvmtiEnv::StopThread(jthread thread, jobject exception) {
   JavaThread* current_thread = JavaThread::current();
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
   JavaThread* java_thread = nullptr;
   oop thread_oop = nullptr;
@@ -1213,7 +1213,7 @@ JvmtiEnv::InterruptThread(jthread thread) {
   JavaThread* current_thread  = JavaThread::current();
   HandleMark hm(current_thread);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1258,7 +1258,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) {
   JavaThread* java_thread = nullptr;
   oop thread_oop = nullptr;
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   // if thread is null the current thread is used
@@ -1358,7 +1358,7 @@ JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, job
   GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
       new (mtServiceability) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, mtServiceability);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(calling_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1431,7 +1431,7 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count
   GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
          new (mtServiceability) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, mtServiceability);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(calling_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1501,7 +1501,7 @@ JvmtiEnv::GetCurrentContendedMonitor(jthread thread, jobject* monitor_ptr) {
   JavaThread* calling_thread = JavaThread::current();
   HandleMark hm(calling_thread);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(calling_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1715,7 +1715,7 @@ JvmtiEnv::GetStackTrace(jthread thread, jint start_depth, jint max_frame_count,
   JavaThread* current_thread = JavaThread::current();
   HandleMark hm(current_thread);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1833,7 +1833,7 @@ JvmtiEnv::GetFrameCount(jthread thread, jint* count_ptr) {
   JavaThread* current_thread = JavaThread::current();
   HandleMark hm(current_thread);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1877,7 +1877,7 @@ JvmtiEnv::PopFrame(jthread thread) {
   if (thread == nullptr) {
     return JVMTI_ERROR_INVALID_THREAD;
   }
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1925,7 +1925,7 @@ JvmtiEnv::GetFrameLocation(jthread thread, jint depth, jmethodID* method_ptr, jl
   JavaThread* current_thread = JavaThread::current();
   HandleMark hm(current_thread);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -1965,7 +1965,7 @@ JvmtiEnv::GetFrameLocation(jthread thread, jint depth, jmethodID* method_ptr, jl
 jvmtiError
 JvmtiEnv::NotifyFramePop(jthread thread, jint depth) {
   ResourceMark rm;
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh;
 
   JavaThread* java_thread = nullptr;
@@ -2243,7 +2243,7 @@ JvmtiEnv::GetLocalObject(jthread thread, jint depth, jint slot, jobject* value_p
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2284,7 +2284,7 @@ JvmtiEnv::GetLocalInstance(jthread thread, jint depth, jobject* value_ptr){
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2326,7 +2326,7 @@ JvmtiEnv::GetLocalInt(jthread thread, jint depth, jint slot, jint* value_ptr) {
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2368,7 +2368,7 @@ JvmtiEnv::GetLocalLong(jthread thread, jint depth, jint slot, jlong* value_ptr)
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2410,7 +2410,7 @@ JvmtiEnv::GetLocalFloat(jthread thread, jint depth, jint slot, jfloat* value_ptr
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2452,7 +2452,7 @@ JvmtiEnv::GetLocalDouble(jthread thread, jint depth, jint slot, jdouble* value_p
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2493,7 +2493,7 @@ JvmtiEnv::SetLocalObject(jthread thread, jint depth, jint slot, jobject value) {
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2530,7 +2530,7 @@ JvmtiEnv::SetLocalInt(jthread thread, jint depth, jint slot, jint value) {
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2567,7 +2567,7 @@ JvmtiEnv::SetLocalLong(jthread thread, jint depth, jint slot, jlong value) {
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2604,7 +2604,7 @@ JvmtiEnv::SetLocalFloat(jthread thread, jint depth, jint slot, jfloat value) {
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
@@ -2641,7 +2641,7 @@ JvmtiEnv::SetLocalDouble(jthread thread, jint depth, jint slot, jdouble value) {
   // doit_prologue(), but after doit() is finished with it.
   ResourceMark rm(current_thread);
   HandleMark hm(current_thread);
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp
index 37541bcfcff..6753328d22d 100644
--- a/src/hotspot/share/prims/jvmtiEnvBase.cpp
+++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp
@@ -680,7 +680,7 @@ JvmtiEnvBase::check_and_skip_hidden_frames(oop vthread, javaVFrame* jvf) {
     // nothing to skip
     return jvf;
   }
-  jvf = check_and_skip_hidden_frames(state->is_in_VTMS_transition(), jvf);
+  jvf = check_and_skip_hidden_frames(java_lang_Thread::is_in_VTMS_transition(vthread), jvf);
   return jvf;
 }
 
@@ -1912,7 +1912,7 @@ JvmtiEnvBase::force_early_return(jthread thread, jvalue value, TosState tos) {
   JavaThread* current_thread = JavaThread::current();
   HandleMark hm(current_thread);
 
-  JvmtiVTMSTransitionDisabler disabler;
+  JvmtiVTMSTransitionDisabler disabler(thread);
   ThreadsListHandle tlh(current_thread);
 
   JavaThread* java_thread = nullptr;
diff --git a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp
index d847c60d103..6044cd1ec76 100644
--- a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp
+++ b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp
@@ -376,7 +376,6 @@ void JvmtiEnvThreadState::reset_current_location(jvmtiEvent event_type, bool ena
     JavaThread* thread = get_thread_or_saved();
 
     oop thread_oop = jvmti_thread_state()->get_thread_oop();
-    assert(!jvmti_thread_state()->is_in_VTMS_transition(), "sanity check");
 
     if (thread == nullptr && event_type == JVMTI_EVENT_SINGLE_STEP && is_virtual()) {
       // Handle the unmounted virtual thread case.
diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp
index 9c247eb7505..97699648613 100644
--- a/src/hotspot/share/prims/jvmtiThreadState.cpp
+++ b/src/hotspot/share/prims/jvmtiThreadState.cpp
@@ -82,9 +82,7 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop)
   _earlyret_tos = ilgl;
   _earlyret_value.j = 0L;
   _earlyret_oop = nullptr;
-
   _jvmti_event_queue = nullptr;
-  _is_in_VTMS_transition = false;
   _is_virtual = false;
 
   _thread_oop_h = OopHandle(JvmtiExport::jvmti_oop_storage(), thread_oop);
@@ -218,8 +216,11 @@ JvmtiThreadState::periodic_clean_up() {
 // VTMS transitions cannot be disabled while this counter is positive.
 volatile int JvmtiVTMSTransitionDisabler::_VTMS_transition_count = 0;
 
-// VTMS transitions is disabled while this counter is positive
-volatile int JvmtiVTMSTransitionDisabler::_VTMS_transition_disable_count = 0;
+// VTMS transitions for one virtual thread are disabled while it is positive
+volatile int JvmtiVTMSTransitionDisabler::_VTMS_transition_disable_for_one_count = 0;
+
+// VTMs transitions for all virtual threads are disabled while it is positive
+volatile int JvmtiVTMSTransitionDisabler::_VTMS_transition_disable_for_all_count = 0;
 
 // There is an active suspender or resumer.
 volatile bool JvmtiVTMSTransitionDisabler::_SR_mode = false;
@@ -228,8 +229,9 @@ volatile bool JvmtiVTMSTransitionDisabler::_SR_mode = false;
 #ifdef ASSERT
 void
 JvmtiVTMSTransitionDisabler::print_info() {
-  log_error(jvmti)("_VTMS_transition_disable_count: %d _VTMS_transition_count: %d\n\n",
-                   _VTMS_transition_disable_count, _VTMS_transition_count);
+  log_error(jvmti)("_VTMS_transition_count: %d\n", _VTMS_transition_count);
+  log_error(jvmti)("_VTMS_transition_disable_for_one_count: %d\n", _VTMS_transition_disable_for_one_count);
+  log_error(jvmti)("_VTMS_transition_disable_for_all_count: %d\n\n", _VTMS_transition_disable_for_all_count);
   int attempts = 10000;
   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *java_thread = jtiwh.next(); ) {
     ResourceMark rm;
@@ -240,15 +242,35 @@ JvmtiVTMSTransitionDisabler::print_info() {
 }
 #endif
 
-JvmtiVTMSTransitionDisabler::JvmtiVTMSTransitionDisabler(bool is_SR) {
+// disable VTMS transitions for one virtual thread
+// no-op if thread is non-NULL and not a virtual thread
+JvmtiVTMSTransitionDisabler::JvmtiVTMSTransitionDisabler(jthread thread)
+  : _is_SR(false), _thread(thread)
+{
   if (!Continuations::enabled()) {
     return; // JvmtiVTMSTransitionDisabler is no-op without virtual threads
   }
   if (Thread::current_or_null() == nullptr) {
     return;  // Detached thread, can be a call from Agent_OnLoad.
   }
-  _is_SR = is_SR;
-  disable_VTMS_transitions();
+  if (_thread != nullptr) {
+    VTMS_transition_disable_for_one(); // disable VTMS transitions for one virtual thread
+  } else {
+    VTMS_transition_disable_for_all(); // disable VTMS transitions for all virtual threads
+  }
+}
+
+// disable VTMS transitions for all virtual threads
+JvmtiVTMSTransitionDisabler::JvmtiVTMSTransitionDisabler(bool is_SR)
+  : _is_SR(is_SR), _thread(nullptr)
+{
+  if (!Continuations::enabled()) {
+    return; // JvmtiVTMSTransitionDisabler is no-op without virtual threads
+  }
+  if (Thread::current_or_null() == nullptr) {
+    return;  // Detached thread, can be a call from Agent_OnLoad.
+  }
+  VTMS_transition_disable_for_all();
 }
 
 JvmtiVTMSTransitionDisabler::~JvmtiVTMSTransitionDisabler() {
@@ -258,11 +280,43 @@ JvmtiVTMSTransitionDisabler::~JvmtiVTMSTransitionDisabler() {
   if (Thread::current_or_null() == nullptr) {
     return;  // Detached thread, can be a call from Agent_OnLoad.
   }
-  enable_VTMS_transitions();
+  if (_thread != nullptr) {
+    VTMS_transition_enable_for_one(); // enable VTMS transitions for one virtual thread
+  } else {
+    VTMS_transition_enable_for_all(); // enable VTMS transitions for all virtual threads
+  }
 }
 
+// disable VTMS transitions for one virtual thread
 void
-JvmtiVTMSTransitionDisabler::disable_VTMS_transitions() {
+JvmtiVTMSTransitionDisabler::VTMS_transition_disable_for_one() {
+  assert(_thread != NULL, "sanity check");
+  JavaThread* thread = JavaThread::current();
+  HandleMark hm(thread);
+  Handle vth = Handle(thread, JNIHandles::resolve_external_guard(_thread));
+  if (!java_lang_VirtualThread::is_instance(vth())) {
+    return; // no-op if _thread is not a virtual thread
+  }
+  ThreadBlockInVM tbivm(thread);
+  MonitorLocker ml(JvmtiVTMSTransition_lock, Mutex::_no_safepoint_check_flag);
+
+  while (_SR_mode) { // suspender or resumer is a JvmtiVTMSTransitionDisabler monopolist
+    ml.wait(10); // wait while there is an active suspender or resumer
+  }
+  Atomic::inc(&_VTMS_transition_disable_for_one_count);
+  java_lang_Thread::inc_VTMS_transition_disable_count(vth());
+
+  while (java_lang_Thread::is_in_VTMS_transition(vth())) {
+    ml.wait(10); // wait while the virtual thread is in transition
+  }
+#ifdef ASSERT
+  thread->set_is_VTMS_transition_disabler(true);
+#endif
+}
+
+// disable VTMS transitions for all virtual threads
+void
+JvmtiVTMSTransitionDisabler::VTMS_transition_disable_for_all() {
   JavaThread* thread = JavaThread::current();
   int attempts = 50000;
   {
@@ -276,11 +330,11 @@ JvmtiVTMSTransitionDisabler::disable_VTMS_transitions() {
     }
     if (_is_SR) {
       _SR_mode = true;
-      while (_VTMS_transition_disable_count > 0) {
+      while (_VTMS_transition_disable_for_all_count > 0) {
         ml.wait(10);   // Wait while there is any active jvmtiVTMSTransitionDisabler.
       }
     }
-    Atomic::inc(&_VTMS_transition_disable_count);
+    Atomic::inc(&_VTMS_transition_disable_for_all_count);
 
     // Block while some mount/unmount transitions are in progress.
     // Debug version fails and prints diagnostic information.
@@ -300,23 +354,44 @@ JvmtiVTMSTransitionDisabler::disable_VTMS_transitions() {
 #ifdef ASSERT
     if (attempts == 0) {
       print_info();
-      fatal("stuck in JvmtiVTMSTransitionDisabler::disable_VTMS_transitions");
+      fatal("stuck in JvmtiVTMSTransitionDisabler::VTMS_transition_disable");
     }
 #endif
 }
 
+// enable VTMS transitions for one virtual thread
+void
+JvmtiVTMSTransitionDisabler::VTMS_transition_enable_for_one() {
+  JavaThread* thread = JavaThread::current();
+  HandleMark hm(thread);
+  Handle vth = Handle(thread, JNIHandles::resolve_external_guard(_thread));
+  if (!java_lang_VirtualThread::is_instance(vth())) {
+    return; // no-op if _thread is not a virtual thread
+  }
+  MonitorLocker ml(JvmtiVTMSTransition_lock, Mutex::_no_safepoint_check_flag);
+  java_lang_Thread::dec_VTMS_transition_disable_count(vth());
+  Atomic::dec(&_VTMS_transition_disable_for_one_count);
+  if (_VTMS_transition_disable_for_one_count == 0 || _is_SR) {
+    ml.notify_all();
+  }
+#ifdef ASSERT
+  thread->set_is_VTMS_transition_disabler(false);
+#endif
+}
+
+// enable VTMS transitions for all virtual threads
 void
-JvmtiVTMSTransitionDisabler::enable_VTMS_transitions() {
+JvmtiVTMSTransitionDisabler::VTMS_transition_enable_for_all() {
   JavaThread* current = JavaThread::current();
   {
     MonitorLocker ml(JvmtiVTMSTransition_lock, Mutex::_no_safepoint_check_flag);
-    assert(_VTMS_transition_disable_count > 0, "VTMS_transition sanity check");
+    assert(_VTMS_transition_disable_for_all_count > 0, "VTMS_transition sanity check");
 
     if (_is_SR) {  // Disabler is suspender or resumer.
       _SR_mode = false;
     }
-    Atomic::dec(&_VTMS_transition_disable_count);
-    if (_VTMS_transition_disable_count == 0 || _is_SR) {
+    Atomic::dec(&_VTMS_transition_disable_for_all_count);
+    if (_VTMS_transition_disable_for_all_count == 0 || _is_SR) {
       ml.notify_all();
     }
 #ifdef ASSERT
@@ -335,17 +410,21 @@ JvmtiVTMSTransitionDisabler::start_VTMS_transition(jthread vthread, bool is_moun
   // Avoid using MonitorLocker on performance critical path, use
   // two-level synchronization with lock-free operations on counters.
   Atomic::inc(&_VTMS_transition_count); // Try to enter VTMS transition section optmistically.
+  java_lang_Thread::set_is_in_VTMS_transition(vth(), true);
 
   // Do not allow suspends inside VTMS transitions.
   // Block while transitions are disabled or there are suspend requests.
   int64_t thread_id = java_lang_Thread::thread_id(vth());  // Cannot use oops while blocked.
-  if (_VTMS_transition_disable_count > 0 ||
+
+  if (_VTMS_transition_disable_for_all_count > 0 ||
+      java_lang_Thread::VTMS_transition_disable_count(vth()) > 0 ||
       thread->is_suspended() ||
       JvmtiVTSuspender::is_vthread_suspended(thread_id)
   ) {
     // Slow path: undo unsuccessful optimistic counter incrementation.
     // It can cause an extra waiting cycle for VTMS transition disablers.
     Atomic::dec(&_VTMS_transition_count);
+    java_lang_Thread::set_is_in_VTMS_transition(vth(), false);
 
     while (true) {
       ThreadBlockInVM tbivm(thread);
@@ -353,7 +432,8 @@ JvmtiVTMSTransitionDisabler::start_VTMS_transition(jthread vthread, bool is_moun
 
       // Do not allow suspends inside VTMS transitions.
       // Block while transitions are disabled or there are suspend requests.
-      if (_VTMS_transition_disable_count > 0 ||
+      if (_VTMS_transition_disable_for_all_count > 0 ||
+          java_lang_Thread::VTMS_transition_disable_count(vth()) > 0 ||
           thread->is_suspended() ||
           JvmtiVTSuspender::is_vthread_suspended(thread_id)
       ) {
@@ -365,6 +445,7 @@ JvmtiVTMSTransitionDisabler::start_VTMS_transition(jthread vthread, bool is_moun
         continue;  // ~ThreadBlockInVM has handshake-based suspend point.
       }
       Atomic::inc(&_VTMS_transition_count);
+      java_lang_Thread::set_is_in_VTMS_transition(vth(), true);
       break;
     }
   }
@@ -379,10 +460,6 @@ JvmtiVTMSTransitionDisabler::start_VTMS_transition(jthread vthread, bool is_moun
   // Enter VTMS transition section.
   assert(!thread->is_in_VTMS_transition(), "VTMS_transition sanity check");
   thread->set_is_in_VTMS_transition(true);
-  JvmtiThreadState* vstate = java_lang_Thread::jvmti_thread_state(vth());
-  if (vstate != nullptr) {
-    vstate->set_is_in_VTMS_transition(true);
-  }
 }
 
 void
@@ -393,15 +470,13 @@ JvmtiVTMSTransitionDisabler::finish_VTMS_transition(jthread vthread, bool is_mou
   thread->set_is_in_VTMS_transition(false);
   oop vt = JNIHandles::resolve_external_guard(vthread);
   int64_t thread_id = java_lang_Thread::thread_id(vt);
-  JvmtiThreadState* vstate = java_lang_Thread::jvmti_thread_state(vt);
-  if (vstate != nullptr) {
-    vstate->set_is_in_VTMS_transition(false);
-  }
+  java_lang_Thread::set_is_in_VTMS_transition(vt, false);
 
   Atomic::dec(&_VTMS_transition_count);
 
   // Unblock waiting VTMS transition disablers.
-  if (_VTMS_transition_disable_count > 0) {
+  if (_VTMS_transition_disable_for_one_count > 0 ||
+      _VTMS_transition_disable_for_all_count > 0) {
     MonitorLocker ml(JvmtiVTMSTransition_lock, Mutex::_no_safepoint_check_flag);
     ml.notify_all();
   }
diff --git a/src/hotspot/share/prims/jvmtiThreadState.hpp b/src/hotspot/share/prims/jvmtiThreadState.hpp
index 029f2852eef..1e8bb19c125 100644
--- a/src/hotspot/share/prims/jvmtiThreadState.hpp
+++ b/src/hotspot/share/prims/jvmtiThreadState.hpp
@@ -79,19 +79,24 @@ class JvmtiEnvThreadStateIterator : public StackObj {
 //
 class JvmtiVTMSTransitionDisabler {
  private:
-  static volatile bool _SR_mode;                      // there is an active suspender or resumer
-  static volatile int _VTMS_transition_count;         // current number of VTMS transitions
-  static volatile int _VTMS_transition_disable_count; // VTMS transitions are disabled while it is non-zero
+  static volatile int _VTMS_transition_disable_for_one_count; // transitions for one virtual thread are disabled while it is positive
+  static volatile int _VTMS_transition_disable_for_all_count; // transitions for all virtual threads are disabled while it is positive
+  static volatile bool _SR_mode;                         // there is an active suspender or resumer
+  static volatile int _VTMS_transition_count;            // current number of VTMS transitions
 
-  bool _is_SR;                                        // is suspender or resumer
-
-  void disable_VTMS_transitions();
-  void enable_VTMS_transitions();
+  bool _is_SR;                                           // is suspender or resumer
+  jthread _thread;                                       // virtual thread to disable transitions for, no-op if it is a platform thread
 
   DEBUG_ONLY(static void print_info();)
+  void VTMS_transition_disable_for_one();
+  void VTMS_transition_disable_for_all();
+  void VTMS_transition_enable_for_one();
+  void VTMS_transition_enable_for_all();
+
  public:
   // parameter is_SR: suspender or resumer
   JvmtiVTMSTransitionDisabler(bool is_SR = false);
+  JvmtiVTMSTransitionDisabler(jthread thread);
   ~JvmtiVTMSTransitionDisabler();
 
   static void start_VTMS_transition(jthread vthread, bool is_mount);
@@ -153,7 +158,6 @@ class JvmtiThreadState : public CHeapObj<mtInternal> {
   OopHandle         _thread_oop_h;
   // Jvmti Events that cannot be posted in their current context.
   JvmtiDeferredEventQueue* _jvmti_event_queue;
-  bool              _is_in_VTMS_transition; // saved JavaThread.is_in_VTMS_transition()
   bool              _is_virtual;            // state belongs to a virtual thread
   bool              _hide_single_stepping;
   bool              _pending_interp_only_mode;
@@ -270,9 +274,6 @@ class JvmtiThreadState : public CHeapObj<mtInternal> {
   void set_thread(JavaThread* thread);
   oop get_thread_oop();
 
-  // The JavaThread is_in_VTMS_transition() bit saved at unmount to restore at mount.
-  inline bool is_in_VTMS_transition() { return _is_in_VTMS_transition; }
-  inline void set_is_in_VTMS_transition(bool val) { _is_in_VTMS_transition = val; }
   inline bool is_virtual() { return _is_virtual; } // the _thread is virtual
 
   inline bool is_exception_detected()  { return _exception_state == ES_DETECTED;  }
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
index 5950e7fe6e3..e93a36c630d 100644
--- a/src/hotspot/share/runtime/arguments.cpp
+++ b/src/hotspot/share/runtime/arguments.cpp
@@ -555,6 +555,9 @@ static SpecialFlag const special_jvm_flags[] = {
   { "G1UseAdaptiveConcRefinement",  JDK_Version::undefined(), JDK_Version::jdk(20), JDK_Version::undefined() },
   { "G1ConcRefinementServiceIntervalMillis", JDK_Version::undefined(), JDK_Version::jdk(20), JDK_Version::undefined() },
 
+  { "G1ConcRSLogCacheSize",    JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() },
+  { "G1ConcRSHotCardLimit",   JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() },
+
 #ifdef ASSERT
   { "DummyObsoleteTestFlag",        JDK_Version::undefined(), JDK_Version::jdk(18), JDK_Version::undefined() },
 #endif
diff --git a/src/hotspot/share/runtime/continuation.cpp b/src/hotspot/share/runtime/continuation.cpp
index 8cbe32502e7..03c0af1a572 100644
--- a/src/hotspot/share/runtime/continuation.cpp
+++ b/src/hotspot/share/runtime/continuation.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 #include "classfile/vmSymbols.hpp"
 #include "gc/shared/barrierSetNMethod.hpp"
 #include "oops/method.inline.hpp"
-#include "runtime/arguments.hpp"
 #include "runtime/continuation.hpp"
 #include "runtime/continuationEntry.inline.hpp"
 #include "runtime/continuationHelper.inline.hpp"
@@ -411,9 +410,8 @@ void Continuations::init() {
   Continuation::init();
 }
 
-// While virtual threads are in Preview, there are some VM mechanisms we disable if continuations aren't used
 bool Continuations::enabled() {
-  return VMContinuations && Arguments::enable_preview();
+  return VMContinuations;
 }
 
 #define CC (char*)  /*cast a literal from (const char*)*/
diff --git a/src/hotspot/share/runtime/continuation.hpp b/src/hotspot/share/runtime/continuation.hpp
index f55c9d1ccd8..e579e993f07 100644
--- a/src/hotspot/share/runtime/continuation.hpp
+++ b/src/hotspot/share/runtime/continuation.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@ class RegisterMap;
 class Continuations : public AllStatic {
 public:
   static void init();
-  static bool enabled(); // TODO: used while virtual threads are in Preview; remove when GA
+  static bool enabled();
 };
 
 void continuations_init();
diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
index 32cec61962d..94025cc4353 100644
--- a/src/hotspot/share/runtime/globals.hpp
+++ b/src/hotspot/share/runtime/globals.hpp
@@ -1311,9 +1311,6 @@ const int ObjectAlignmentInBytes = 8;
   develop(intx, MallocCatchPtr, -1,                                         \
           "Hit breakpoint when mallocing/freeing this pointer")             \
                                                                             \
-  notproduct(ccstrlist, SuppressErrorAt, "",                                \
-          "List of assertions (file:line) to muzzle")                       \
-                                                                            \
   develop(intx, StackPrintLimit, 100,                                       \
           "number of stack frames to print in VM-level stack dump")         \
                                                                             \
@@ -1423,7 +1420,7 @@ const int ObjectAlignmentInBytes = 8;
           "Force the class space to be allocated at this address or "       \
           "fails VM initialization (requires -Xshare=off.")                 \
                                                                             \
-  product(ccstr, MetaspaceReclaimPolicy, "balanced",                        \
+  product(ccstr, MetaspaceReclaimPolicy, "balanced", DIAGNOSTIC,            \
           "options: balanced, aggressive, none")                            \
                                                                             \
   product(bool, PrintMetaspaceStatisticsAtExit, false, DIAGNOSTIC,          \
diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp
index f24d9573236..eb43fde5d71 100644
--- a/src/hotspot/share/runtime/os.cpp
+++ b/src/hotspot/share/runtime/os.cpp
@@ -60,6 +60,7 @@
 #include "runtime/threadSMR.hpp"
 #include "runtime/vmOperations.hpp"
 #include "runtime/vm_version.hpp"
+#include "sanitizers/address.hpp"
 #include "services/attachListener.hpp"
 #include "services/mallocTracker.hpp"
 #include "services/mallocHeader.inline.hpp"
@@ -694,7 +695,7 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCa
 
   // Special handling for NMT preinit phase before arguments are parsed
   void* rc = nullptr;
-  if (NMTPreInit::handle_realloc(&rc, memblock, size)) {
+  if (NMTPreInit::handle_realloc(&rc, memblock, size, memflags)) {
     return rc;
   }
 
@@ -727,6 +728,8 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCa
     // Perform integrity checks on and mark the old block as dead *before* calling the real realloc(3) since it
     // may invalidate the old block, including its header.
     MallocHeader* header = MallocHeader::resolve_checked(memblock);
+    assert(memflags == header->flags(), "weird NMT flags mismatch (new:\"%s\" != old:\"%s\")\n",
+           NMTUtil::flag_to_name(memflags), NMTUtil::flag_to_name(header->flags()));
     const MallocHeader::FreeInfo free_info = header->free_info();
     header->mark_block_as_dead();
 
@@ -940,6 +943,16 @@ bool os::print_function_and_library_name(outputStream* st,
   return have_function_name || have_library_name;
 }
 
+ATTRIBUTE_NO_ASAN static void print_hex_readable_pointer(outputStream* st, address p,
+                                                         int unitsize) {
+  switch (unitsize) {
+    case 1: st->print("%02x", *(u1*)p); break;
+    case 2: st->print("%04x", *(u2*)p); break;
+    case 4: st->print("%08x", *(u4*)p); break;
+    case 8: st->print("%016" FORMAT64_MODIFIER "x", *(u8*)p); break;
+  }
+}
+
 void os::print_hex_dump(outputStream* st, address start, address end, int unitsize,
                         int bytes_per_line, address logical_start) {
   assert(unitsize == 1 || unitsize == 2 || unitsize == 4 || unitsize == 8, "just checking");
@@ -958,12 +971,7 @@ void os::print_hex_dump(outputStream* st, address start, address end, int unitsi
   st->print(PTR_FORMAT ":   ", p2i(logical_p));
   while (p < end) {
     if (is_readable_pointer(p)) {
-      switch (unitsize) {
-        case 1: st->print("%02x", *(u1*)p); break;
-        case 2: st->print("%04x", *(u2*)p); break;
-        case 4: st->print("%08x", *(u4*)p); break;
-        case 8: st->print("%016" FORMAT64_MODIFIER "x", *(u8*)p); break;
-      }
+      print_hex_readable_pointer(st, p, unitsize);
     } else {
       st->print("%*.*s", 2*unitsize, 2*unitsize, "????????????????");
     }
diff --git a/src/hotspot/share/runtime/vframe.cpp b/src/hotspot/share/runtime/vframe.cpp
index 5e69cd230ba..2dc2d5a9281 100644
--- a/src/hotspot/share/runtime/vframe.cpp
+++ b/src/hotspot/share/runtime/vframe.cpp
@@ -482,8 +482,7 @@ MonitorInfo::MonitorInfo(oop owner, BasicLock* lock, bool eliminated, bool owner
 void vframeStreamCommon::found_bad_method_frame() const {
   // 6379830 Cut point for an assertion that occasionally fires when
   // we are using the performance analyzer.
-  // Disable this assert when testing the analyzer with fastdebug.
-  // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number)
+  // Disable this when testing the analyzer with fastdebug.
   fatal("invalid bci or invalid scope desc");
 }
 #endif
diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp
index d62342578f6..96623646ac9 100644
--- a/src/hotspot/share/runtime/vmStructs.cpp
+++ b/src/hotspot/share/runtime/vmStructs.cpp
@@ -235,8 +235,8 @@
   nonstatic_field(InstanceKlass,               _static_oop_field_count,                       u2)                                    \
   nonstatic_field(InstanceKlass,               _nonstatic_oop_map_size,                       int)                                   \
   nonstatic_field(InstanceKlass,               _is_marked_dependent,                          bool)                                  \
-  nonstatic_field(InstanceKlass,               _init_state,                                   InstanceKlass::ClassState)             \
-  nonstatic_field(InstanceKlass,               _init_thread,                                  Thread*)                               \
+  volatile_nonstatic_field(InstanceKlass,      _init_state,                                   InstanceKlass::ClassState)             \
+  volatile_nonstatic_field(InstanceKlass,      _init_thread,                                  JavaThread*)                           \
   nonstatic_field(InstanceKlass,               _itable_len,                                   int)                                   \
   nonstatic_field(InstanceKlass,               _reference_type,                               u1)                                    \
   volatile_nonstatic_field(InstanceKlass,      _oop_map_cache,                                OopMapCache*)                          \
diff --git a/src/hotspot/share/sanitizers/address.hpp b/src/hotspot/share/sanitizers/address.hpp
index 8519de1a849..5186053f1c9 100644
--- a/src/hotspot/share/sanitizers/address.hpp
+++ b/src/hotspot/share/sanitizers/address.hpp
@@ -29,6 +29,25 @@
 #include <sanitizer/asan_interface.h>
 #endif
 
+// ATTRIBUTE_NO_ASAN
+//
+// Function attribute which informs the compiler to not instrument memory accesses in the function.
+// Useful if the function is known to do something dangerous, such as reading previous stack frames
+// or reading arbitrary regions of memory when dumping during a crash.
+#ifdef ADDRESS_SANITIZER
+#if defined(TARGET_COMPILER_gcc)
+// GCC-like, including Clang.
+#define ATTRIBUTE_NO_ASAN __attribute__((no_sanitize_address))
+#elif defined(TARGET_COMPILER_visCPP)
+// Microsoft Visual C++
+#define ATTRIBUTE_NO_ASAN __declspec(no_sanitize_address)
+#endif
+#endif
+
+#ifndef ATTRIBUTE_NO_ASAN
+#define ATTRIBUTE_NO_ASAN
+#endif
+
 // ASAN_POISON_MEMORY_REGION()/ASAN_UNPOISON_MEMORY_REGION()
 //
 // Poisons/unpoisons the specified memory region. When ASan is available this is the macro of the
diff --git a/src/hotspot/share/services/memJfrReporter.cpp b/src/hotspot/share/services/memJfrReporter.cpp
index 014fcb09b7f..9d6e27ada63 100644
--- a/src/hotspot/share/services/memJfrReporter.cpp
+++ b/src/hotspot/share/services/memJfrReporter.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,10 +85,10 @@ void MemJFRReporter::send_total_event() {
   event.commit();
 }
 
-void MemJFRReporter::send_type_event(const Ticks& starttime, const char* type, size_t reserved, size_t committed) {
+void MemJFRReporter::send_type_event(const Ticks& starttime, MEMFLAGS flag, size_t reserved, size_t committed) {
   EventNativeMemoryUsage event(UNTIMED);
   event.set_starttime(starttime);
-  event.set_type(type);
+  event.set_type(NMTUtil::flag_to_index(flag));
   event.set_reserved(reserved);
   event.set_committed(committed);
   event.commit();
@@ -108,6 +108,6 @@ void MemJFRReporter::send_type_events() {
       // Skip mtNone since it is not really used.
       continue;
     }
-    send_type_event(timestamp, NMTUtil::flag_to_name(flag), usage->reserved(flag), usage->committed(flag));
+    send_type_event(timestamp, flag, usage->reserved(flag), usage->committed(flag));
   }
 }
diff --git a/src/hotspot/share/services/memJfrReporter.hpp b/src/hotspot/share/services/memJfrReporter.hpp
index 2c1e4450488..25bb64e2583 100644
--- a/src/hotspot/share/services/memJfrReporter.hpp
+++ b/src/hotspot/share/services/memJfrReporter.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 // so no more synchronization is needed.
 class MemJFRReporter : public AllStatic {
 private:
-  static void send_type_event(const Ticks& starttime, const char* tag, size_t reserved, size_t committed);
+  static void send_type_event(const Ticks& starttime, MEMFLAGS flag, size_t reserved, size_t committed);
  public:
   static void send_total_event();
   static void send_type_events();
diff --git a/src/hotspot/share/services/nmtPreInit.cpp b/src/hotspot/share/services/nmtPreInit.cpp
index c63aaac6cf2..ff29195b5cf 100644
--- a/src/hotspot/share/services/nmtPreInit.cpp
+++ b/src/hotspot/share/services/nmtPreInit.cpp
@@ -172,8 +172,8 @@ void NMTPreInit::create_table() {
 }
 
 // Allocate with os::malloc (hidden to prevent having to include os.hpp)
-void* NMTPreInit::do_os_malloc(size_t size) {
-  return os::malloc(size, mtNMT);
+void* NMTPreInit::do_os_malloc(size_t size, MEMFLAGS memflags) {
+  return os::malloc(size, memflags);
 }
 
 // Switches from NMT pre-init state to NMT post-init state;
diff --git a/src/hotspot/share/services/nmtPreInit.hpp b/src/hotspot/share/services/nmtPreInit.hpp
index 19e87a44679..30e67ffcbec 100644
--- a/src/hotspot/share/services/nmtPreInit.hpp
+++ b/src/hotspot/share/services/nmtPreInit.hpp
@@ -248,7 +248,7 @@ class NMTPreInit : public AllStatic {
   }
 
   // Just a wrapper for os::malloc to avoid including os.hpp here.
-  static void* do_os_malloc(size_t size);
+  static void* do_os_malloc(size_t size, MEMFLAGS memflags);
 
 public:
 
@@ -276,7 +276,7 @@ class NMTPreInit : public AllStatic {
   // Called from os::realloc.
   // Returns true if reallocation was handled here; in that case,
   // *rc contains the return address.
-  static bool handle_realloc(void** rc, void* old_p, size_t new_size) {
+  static bool handle_realloc(void** rc, void* old_p, size_t new_size, MEMFLAGS memflags) {
     if (old_p == nullptr) {                  // realloc(null, n)
       return handle_malloc(rc, new_size);
     }
@@ -305,7 +305,7 @@ class NMTPreInit : public AllStatic {
       //   and confusing us.
       const NMTPreInitAllocation* a = find_in_map(old_p);
       if (a != nullptr) { // this was originally a pre-init allocation
-        void* p_new = do_os_malloc(new_size);
+        void* p_new = do_os_malloc(new_size, memflags);
         ::memcpy(p_new, a->payload(), MIN2(a->size, new_size));
         (*rc) = p_new;
         return true;
diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp
index d33387c2ad8..afa472cf0de 100644
--- a/src/hotspot/share/utilities/debug.cpp
+++ b/src/hotspot/share/utilities/debug.cpp
@@ -131,111 +131,6 @@ void warning(const char* format, ...) {
   }
 }
 
-#ifndef PRODUCT
-
-#define is_token_break(ch) (isspace(ch) || (ch) == ',')
-
-static const char* last_file_name = nullptr;
-static int         last_line_no   = -1;
-
-// assert/guarantee/... may happen very early during VM initialization.
-// Don't rely on anything that is initialized by Threads::create_vm(). For
-// example, don't use tty.
-bool error_is_suppressed(const char* file_name, int line_no) {
-  // The following 1-element cache requires that passed-in
-  // file names are always only constant literals.
-  if (file_name == last_file_name && line_no == last_line_no)  return true;
-
-  int file_name_len = (int)strlen(file_name);
-  char separator = os::file_separator()[0];
-  const char* base_name = strrchr(file_name, separator);
-  if (base_name == nullptr)
-    base_name = file_name;
-
-  // scan the SuppressErrorAt option
-  const char* cp = SuppressErrorAt;
-  for (;;) {
-    const char* sfile;
-    int sfile_len;
-    int sline;
-    bool noisy;
-    while ((*cp) != '\0' && is_token_break(*cp))  cp++;
-    if ((*cp) == '\0')  break;
-    sfile = cp;
-    while ((*cp) != '\0' && !is_token_break(*cp) && (*cp) != ':')  cp++;
-    sfile_len = cp - sfile;
-    if ((*cp) == ':')  cp++;
-    sline = 0;
-    while ((*cp) != '\0' && isdigit(*cp)) {
-      sline *= 10;
-      sline += (*cp) - '0';
-      cp++;
-    }
-    // "file:line!" means the assert suppression is not silent
-    noisy = ((*cp) == '!');
-    while ((*cp) != '\0' && !is_token_break(*cp))  cp++;
-    // match the line
-    if (sline != 0) {
-      if (sline != line_no)  continue;
-    }
-    // match the file
-    if (sfile_len > 0) {
-      const char* look = file_name;
-      const char* look_max = file_name + file_name_len - sfile_len;
-      const char* foundp;
-      bool match = false;
-      while (!match
-             && (foundp = strchr(look, sfile[0])) != nullptr
-             && foundp <= look_max) {
-        match = true;
-        for (int i = 1; i < sfile_len; i++) {
-          if (sfile[i] != foundp[i]) {
-            match = false;
-            break;
-          }
-        }
-        look = foundp + 1;
-      }
-      if (!match)  continue;
-    }
-    // got a match!
-    if (noisy) {
-      fdStream out(defaultStream::output_fd());
-      out.print_raw("[error suppressed at ");
-      out.print_raw(base_name);
-      char buf[16];
-      jio_snprintf(buf, sizeof(buf), ":%d]", line_no);
-      out.print_raw_cr(buf);
-    } else {
-      // update 1-element cache for fast silent matches
-      last_file_name = file_name;
-      last_line_no   = line_no;
-    }
-    return true;
-  }
-
-  if (!VMError::is_error_reported() && !SuppressFatalErrorMessage) {
-    // print a friendly hint:
-    fdStream out(defaultStream::output_fd());
-    out.print_raw_cr("# To suppress the following error report, specify this argument");
-    out.print_raw   ("# after -XX: or in .hotspotrc:  SuppressErrorAt=");
-    out.print_raw   (base_name);
-    char buf[16];
-    jio_snprintf(buf, sizeof(buf), ":%d", line_no);
-    out.print_raw_cr(buf);
-  }
-  return false;
-}
-
-#undef is_token_break
-
-#else
-
-// Place-holder for non-existent suppression check:
-#define error_is_suppressed(file_name, line_no) (false)
-
-#endif // !PRODUCT
-
 void report_vm_error(const char* file, int line, const char* error_msg)
 {
   report_vm_error(file, line, error_msg, "%s", "");
@@ -271,7 +166,7 @@ static void print_error_for_unit_test(const char* message, const char* detail_fm
 
 void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...)
 {
-  if (Debugging || error_is_suppressed(file, line)) return;
+  if (Debugging) return;
   va_list detail_args;
   va_start(detail_args, detail_fmt);
   void* context = nullptr;
@@ -293,7 +188,7 @@ void report_vm_status_error(const char* file, int line, const char* error_msg,
 }
 
 void report_fatal(VMErrorType error_type, const char* file, int line, const char* detail_fmt, ...) {
-  if (Debugging || error_is_suppressed(file, line)) return;
+  if (Debugging) return;
   va_list detail_args;
   va_start(detail_args, detail_fmt);
   void* context = nullptr;
diff --git a/src/hotspot/share/utilities/elfFile.hpp b/src/hotspot/share/utilities/elfFile.hpp
index 9d5780a5016..32ce0882162 100644
--- a/src/hotspot/share/utilities/elfFile.hpp
+++ b/src/hotspot/share/utilities/elfFile.hpp
@@ -797,7 +797,7 @@ class DwarfFile : public ElfFile {
       uint32_t _line;
 
       // A column number within a source line. Columns are numbered beginning at 1. The value 0 is reserved to indicate
-      // that a statement begins at the “left edge” of the line.
+      // that a statement begins at the "left edge" of the line.
       uint32_t _column;
 
       // Indicates that the current instruction is a recommended breakpoint location.
diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp
index 66e9c1faab5..fcff76668a5 100644
--- a/src/hotspot/share/utilities/vmError.hpp
+++ b/src/hotspot/share/utilities/vmError.hpp
@@ -188,7 +188,7 @@ class VMError : public AllStatic {
   DEBUG_ONLY(static void controlled_crash(int how);)
 
   // Non-null address guaranteed to generate a SEGV mapping error on read, for test purposes.
-  static constexpr intptr_t segfault_address = (1 * K) AIX_ONLY(+ (4 * K));
+  static constexpr intptr_t segfault_address = AIX_ONLY(-1) NOT_AIX(1 * K);
 
   // Max value for the ErrorLogPrintCodeLimit flag.
   static const int max_error_log_print_code = 10;
diff --git a/src/java.base/share/classes/java/io/BufferedInputStream.java b/src/java.base/share/classes/java/io/BufferedInputStream.java
index 9ad68e366cf..8a7bdfad966 100644
--- a/src/java.base/share/classes/java/io/BufferedInputStream.java
+++ b/src/java.base/share/classes/java/io/BufferedInputStream.java
@@ -96,7 +96,7 @@ public class BufferedInputStream extends FilterInputStream {
 
     /**
      * The current position in the buffer. This is the index of the next
-     * character to be read from the {@code buf} array.
+     * byte to be read from the {@code buf} array.
      * <p>
      * This value is always in the range {@code 0}
      * through {@code count}. If it is less
@@ -297,7 +297,7 @@ private int implRead() throws IOException {
     }
 
     /**
-     * Read characters into a portion of an array, reading from the underlying
+     * Read bytes into a portion of an array, reading from the underlying
      * stream at most once if necessary.
      */
     private int read1(byte[] b, int off, int len) throws IOException {
@@ -614,7 +614,11 @@ private long implTransferTo(OutputStream out) throws IOException {
                 out.write(buffer);
                 pos = count;
             }
-            return avail + getInIfOpen().transferTo(out);
+            try {
+                return Math.addExact(avail, getInIfOpen().transferTo(out));
+            } catch (ArithmeticException ignore) {
+                return Long.MAX_VALUE;
+            }
         } else {
             return super.transferTo(out);
         }
diff --git a/src/java.base/share/classes/java/io/ByteArrayInputStream.java b/src/java.base/share/classes/java/io/ByteArrayInputStream.java
index 11f207787bd..08a3ec982d1 100644
--- a/src/java.base/share/classes/java/io/ByteArrayInputStream.java
+++ b/src/java.base/share/classes/java/io/ByteArrayInputStream.java
@@ -56,7 +56,7 @@ public class ByteArrayInputStream extends InputStream {
     protected byte[] buf;
 
     /**
-     * The index of the next character to read from the input stream buffer.
+     * The index of the next byte to read from the input stream buffer.
      * This value should always be nonnegative
      * and not larger than the value of {@code count}.
      * The next byte to be read from the input stream buffer
@@ -80,7 +80,7 @@ public class ByteArrayInputStream extends InputStream {
     protected int mark = 0;
 
     /**
-     * The index one greater than the last valid character in the input
+     * The index one greater than the last valid byte in the input
      * stream buffer.
      * This value should always be nonnegative
      * and not larger than the length of {@code buf}.
diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java
index ba1d06a1f1b..e882946cf74 100644
--- a/src/java.base/share/classes/java/io/FileInputStream.java
+++ b/src/java.base/share/classes/java/io/FileInputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -392,7 +392,11 @@ public long transferTo(OutputStream out) throws IOException {
                 return transferred;
             }
         }
-        return transferred + super.transferTo(out);
+        try {
+            return Math.addExact(transferred, super.transferTo(out));
+        } catch (ArithmeticException ignore) {
+            return Long.MAX_VALUE;
+        }
     }
 
     private long length() throws IOException {
diff --git a/src/java.base/share/classes/java/io/InputStream.java b/src/java.base/share/classes/java/io/InputStream.java
index c79109b8cb5..a2f309323ce 100644
--- a/src/java.base/share/classes/java/io/InputStream.java
+++ b/src/java.base/share/classes/java/io/InputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -769,6 +769,9 @@ public boolean markSupported() {
      * interrupted during the transfer, is highly input and output stream
      * specific, and therefore not specified.
      * <p>
+     * If the total number of bytes transferred is greater than {@linkplain
+     * Long#MAX_VALUE}, then {@code Long.MAX_VALUE} will be returned.
+     * <p>
      * If an I/O error occurs reading from the input stream or writing to the
      * output stream, then it may do so after some bytes have been read or
      * written. Consequently the input stream may not be at end of stream and
@@ -789,7 +792,13 @@ public long transferTo(OutputStream out) throws IOException {
         int read;
         while ((read = this.read(buffer, 0, DEFAULT_BUFFER_SIZE)) >= 0) {
             out.write(buffer, 0, read);
-            transferred += read;
+            if (transferred < Long.MAX_VALUE) {
+                try {
+                    transferred = Math.addExact(transferred, read);
+                } catch (ArithmeticException ignore) {
+                    transferred = Long.MAX_VALUE;
+                }
+            }
         }
         return transferred;
     }
diff --git a/src/java.base/share/classes/java/io/ObjectInputFilter.java b/src/java.base/share/classes/java/io/ObjectInputFilter.java
index ab16c8cf1a3..e40a2407206 100644
--- a/src/java.base/share/classes/java/io/ObjectInputFilter.java
+++ b/src/java.base/share/classes/java/io/ObjectInputFilter.java
@@ -187,8 +187,11 @@
  *
  * This class shows how an application provided filter factory can combine filters
  * to check every deserialization operation that takes place in a thread.
- * It defines a thread-local variable to hold the thread-specific filter, and constructs a filter factory
- * that composes that filter with the static JVM-wide filter and the stream-specific filter.
+ * It defines a thread-local variable to hold the thread-specific filter, and construct a filter factory
+ * that composes that filter with the static JVM-wide filter and the stream-specific filter,
+ * rejecting any classes not handled by those two filters.
+ * If a stream specific filter is set and does not accept or reject a class,
+ * the combined JVM-wide filter and thread filter is applied.
  * The {@code doWithSerialFilter} method does the setup of the thread-specific filter
  * and invokes the application provided {@link Runnable Runnable}.
  *
@@ -207,26 +210,18 @@
  *             // Called from the OIS constructor or perhaps OIS.setObjectInputFilter with no current filter
  *             var filter = filterThreadLocal.get();
  *             if (filter != null) {
- *                 // Wrap the filter to reject UNDECIDED results
- *                 filter = ObjectInputFilter.rejectUndecidedClass(filter);
+ *                 // Merge to invoke the thread local filter and then the JVM-wide filter (if any)
+ *                 filter = ObjectInputFilter.merge(filter, next);
+ *                 return ObjectInputFilter.rejectUndecidedClass(filter);
  *             }
- *             if (next != null) {
- *                 // Merge the next filter with the thread filter, if any
- *                 // Initially this is the static JVM-wide filter passed from the OIS constructor
- *                 // Wrap the filter to reject UNDECIDED results
- *                 filter = ObjectInputFilter.merge(next, filter);
- *                 filter = ObjectInputFilter.rejectUndecidedClass(filter);
- *             }
- *             return filter;
+ *             return (next == null) ? null : ObjectInputFilter.rejectUndecidedClass(next);
  *         } else {
  *             // Called from OIS.setObjectInputFilter with a current filter and a stream-specific filter.
  *             // The curr filter already incorporates the thread filter and static JVM-wide filter
  *             // and rejection of undecided classes
- *             // If there is a stream-specific filter wrap it and a filter to recheck for undecided
+ *             // If there is a stream-specific filter merge to invoke it and then the current filter.
  *             if (next != null) {
- *                 next = ObjectInputFilter.merge(next, curr);
- *                 next = ObjectInputFilter.rejectUndecidedClass(next);
- *                 return next;
+ *                 return ObjectInputFilter.merge(next, curr);
  *             }
  *             return curr;
  *         }
diff --git a/src/java.base/share/classes/java/io/PushbackInputStream.java b/src/java.base/share/classes/java/io/PushbackInputStream.java
index b3a858ae1f4..0c74205ba0e 100644
--- a/src/java.base/share/classes/java/io/PushbackInputStream.java
+++ b/src/java.base/share/classes/java/io/PushbackInputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -421,7 +421,11 @@ public long transferTo(OutputStream out) throws IOException {
                 out.write(buffer);
                 pos = buffer.length;
             }
-            return avail + in.transferTo(out);
+            try {
+                return Math.addExact(avail, in.transferTo(out));
+            } catch (ArithmeticException ignore) {
+                return Long.MAX_VALUE;
+            }
         } else {
             return super.transferTo(out);
         }
diff --git a/src/java.base/share/classes/java/io/Reader.java b/src/java.base/share/classes/java/io/Reader.java
index 9fabadd4c1d..b29a8c05f97 100644
--- a/src/java.base/share/classes/java/io/Reader.java
+++ b/src/java.base/share/classes/java/io/Reader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -421,6 +421,9 @@ public void reset() throws IOException {
      * interrupted during the transfer, is highly reader and writer
      * specific, and therefore not specified.
      * <p>
+     * If the total number of characters transferred is greater than {@linkplain
+     * Long#MAX_VALUE}, then {@code Long.MAX_VALUE} will be returned.
+     * <p>
      * If an I/O error occurs reading from the reader or writing to the
      * writer, then it may do so after some characters have been read or
      * written. Consequently the reader may not be at end of the stream and
@@ -441,7 +444,13 @@ public long transferTo(Writer out) throws IOException {
         int nRead;
         while ((nRead = read(buffer, 0, TRANSFER_BUFFER_SIZE)) >= 0) {
             out.write(buffer, 0, nRead);
-            transferred += nRead;
+            if (transferred < Long.MAX_VALUE) {
+                try {
+                    transferred = Math.addExact(transferred, nRead);
+                } catch (ArithmeticException ignore) {
+                    transferred = Long.MAX_VALUE;
+                }
+            }
         }
         return transferred;
     }
diff --git a/src/java.base/share/classes/java/io/SequenceInputStream.java b/src/java.base/share/classes/java/io/SequenceInputStream.java
index 466091958f8..de3fafc884d 100644
--- a/src/java.base/share/classes/java/io/SequenceInputStream.java
+++ b/src/java.base/share/classes/java/io/SequenceInputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -134,7 +134,7 @@ public int available() throws IOException {
      * {@inheritDoc}
      * <p>
      * This method
-     * tries to read one character from the current substream. If it
+     * tries to read one byte from the current substream. If it
      * reaches the end of the stream, it calls the {@code close}
      * method of the current substream and begins reading from the next
      * substream.
@@ -163,7 +163,7 @@ public int read() throws IOException {
      * <p>
      * The {@code read} method of {@code SequenceInputStream}
      * tries to read the data from the current substream. If it fails to
-     * read any characters because the substream has reached the end of
+     * read any bytes because the substream has reached the end of
      * the stream, it calls the {@code close} method of the current
      * substream and begins reading from the next substream.
      *
@@ -240,12 +240,18 @@ public void close() throws IOException {
     public long transferTo(OutputStream out) throws IOException {
         Objects.requireNonNull(out, "out");
         if (getClass() == SequenceInputStream.class) {
-            long c = 0;
+            long transferred = 0;
             while (in != null) {
-                c += in.transferTo(out);
+                if (transferred < Long.MAX_VALUE) {
+                    try {
+                        transferred = Math.addExact(transferred, in.transferTo(out));
+                    } catch (ArithmeticException ignore) {
+                        return Long.MAX_VALUE;
+                    }
+                }
                 nextStream();
             }
-            return c;
+            return transferred;
         } else {
             return super.transferTo(out);
         }
diff --git a/src/java.base/share/classes/java/lang/FdLibm.java b/src/java.base/share/classes/java/lang/FdLibm.java
index 94bda83df6c..460353d4156 100644
--- a/src/java.base/share/classes/java/lang/FdLibm.java
+++ b/src/java.base/share/classes/java/lang/FdLibm.java
@@ -747,6 +747,146 @@ public static double compute(double x) {
         }
     }
 
+    /**
+     * Return the (natural) logarithm of x
+     *
+     * Method :
+     *   1. Argument Reduction: find k and f such that
+     *                      x = 2^k * (1+f),
+     *         where  sqrt(2)/2 < 1+f < sqrt(2) .
+     *
+     *   2. Approximation of log(1+f).
+     *      Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+     *               = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+     *               = 2s + s*R
+     *      We use a special Reme algorithm on [0,0.1716] to generate
+     *      a polynomial of degree 14 to approximate R The maximum error
+     *      of this polynomial approximation is bounded by 2**-58.45. In
+     *      other words,
+     *                      2      4      6      8      10      12      14
+     *          R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s  +Lg6*s  +Lg7*s
+     *      (the values of Lg1 to Lg7 are listed in the program)
+     *      and
+     *          |      2          14          |     -58.45
+     *          | Lg1*s +...+Lg7*s    -  R(z) | <= 2
+     *          |                             |
+     *      Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+     *      In order to guarantee error in log below 1ulp, we compute log
+     *      by
+     *              log(1+f) = f - s*(f - R)        (if f is not too large)
+     *              log(1+f) = f - (hfsq - s*(hfsq+R)).     (better accuracy)
+     *
+     *      3. Finally,  log(x) = k*ln2 + log(1+f).
+     *                          = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+     *         Here ln2 is split into two floating point number:
+     *                      ln2_hi + ln2_lo,
+     *         where n*ln2_hi is always exact for |n| < 2000.
+     *
+     * Special cases:
+     *      log(x) is NaN with signal if x < 0 (including -INF) ;
+     *      log(+INF) is +INF; log(0) is -INF with signal;
+     *      log(NaN) is that NaN with no signal.
+     *
+     * Accuracy:
+     *      according to an error analysis, the error is always less than
+     *      1 ulp (unit in the last place).
+     *
+     * Constants:
+     * The hexadecimal values are the intended ones for the following
+     * constants. The decimal values may be used, provided that the
+     * compiler will convert from decimal to binary accurately enough
+     * to produce the hexadecimal values shown.
+     */
+    static final class Log {
+        private Log() {throw new UnsupportedOperationException();}
+
+        private static final double
+            ln2_hi = 0x1.62e42feep-1,       // 6.93147180369123816490e-01
+            ln2_lo = 0x1.a39ef35793c76p-33, // 1.90821492927058770002e-10
+
+            Lg1    = 0x1.5555555555593p-1,  // 6.666666666666735130e-01
+            Lg2    = 0x1.999999997fa04p-2,  // 3.999999999940941908e-01
+            Lg3    = 0x1.2492494229359p-2,  // 2.857142874366239149e-01
+            Lg4    = 0x1.c71c51d8e78afp-3,  // 2.222219843214978396e-01
+            Lg5    = 0x1.7466496cb03dep-3,  // 1.818357216161805012e-01
+            Lg6    = 0x1.39a09d078c69fp-3,  // 1.531383769920937332e-01
+            Lg7    = 0x1.2f112df3e5244p-3;  // 1.479819860511658591e-01
+
+        private static final double zero = 0.0;
+
+        static double compute(double x) {
+            double hfsq, f, s, z, R, w, t1, t2, dk;
+            int k, hx, i, j;
+            /*unsigned*/ int lx;
+
+            hx = __HI(x);           // high word of x
+            lx = __LO(x);           // low  word of x
+
+            k=0;
+            if (hx < 0x0010_0000) {                  // x < 2**-1022
+                if (((hx & 0x7fff_ffff) | lx) == 0) { // log(+-0) = -inf
+                    return -TWO54/zero;
+                }
+                if (hx < 0) {                        // log(-#) = NaN
+                    return (x - x)/zero;
+                }
+                k -= 54;
+                x *= TWO54;    // subnormal number, scale up x
+                hx = __HI(x);  // high word of x
+            }
+            if (hx >= 0x7ff0_0000) {
+                return x + x;
+            }
+            k += (hx >> 20) - 1023;
+            hx &= 0x000f_ffff;
+            i = (hx + 0x9_5f64) & 0x10_0000;
+            x =__HI(x, hx | (i ^ 0x3ff0_0000));  // normalize x or x/2
+            k += (i >> 20);
+            f = x - 1.0;
+            if ((0x000f_ffff & (2 + hx)) < 3) {// |f| < 2**-20
+                if (f == zero) {
+                    if (k == 0) {
+                        return zero;
+                    } else {
+                        dk = (double)k;
+                        return dk*ln2_hi + dk*ln2_lo;
+                    }
+                }
+                R = f*f*(0.5 - 0.33333333333333333*f);
+                if (k == 0) {
+                    return f - R;
+                } else {
+                    dk = (double)k;
+                    return dk*ln2_hi - ((R - dk*ln2_lo) - f);
+                }
+            }
+            s = f/(2.0 + f);
+            dk = (double)k;
+            z = s*s;
+            i = hx - 0x6_147a;
+            w = z*z;
+            j = 0x6b851 - hx;
+            t1= w*(Lg2 + w*(Lg4 + w*Lg6));
+            t2= z*(Lg1 + w*(Lg3 + w*(Lg5 + w*Lg7)));
+            i |= j;
+            R = t2 + t1;
+            if (i > 0) {
+                hfsq = 0.5*f*f;
+                if (k == 0) {
+                    return f-(hfsq - s*(hfsq + R));
+                } else {
+                    return dk*ln2_hi - ((hfsq - (s*(hfsq + R) + dk*ln2_lo)) - f);
+                }
+            } else {
+                if (k == 0) {
+                    return f - s*(f - R);
+                } else {
+                    return dk*ln2_hi - ((s*(f - R) - dk*ln2_lo) - f);
+                }
+            }
+        }
+    }
+
     /**
      * Return the base 10 logarithm of x
      *
diff --git a/src/java.base/share/classes/java/lang/Math.java b/src/java.base/share/classes/java/lang/Math.java
index 958073c7bd2..fd5c8bb0491 100644
--- a/src/java.base/share/classes/java/lang/Math.java
+++ b/src/java.base/share/classes/java/lang/Math.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2191,6 +2191,135 @@ public static double min(double a, double b) {
         return (a <= b) ? a : b;
     }
 
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned.
+     * <p>
+     * While the original value of type long may not fit into the int type,
+     * the bounds have the int type, so the result always fits the int type.
+     * This allows to use method to safely cast long value to int with
+     * saturation.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if {@code min > max}
+     *
+     * @since 21
+     */
+    public static int clamp(long value, int min, int max) {
+        if (min > max) {
+            throw new IllegalArgumentException(min + " > " + max);
+        }
+        return (int) Math.min(max, Math.max(value, min));
+    }
+
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if {@code min > max}
+     *
+     * @since 21
+     */
+    public static long clamp(long value, long min, long max) {
+        if (min > max) {
+            throw new IllegalArgumentException(min + " > " + max);
+        }
+        return Math.min(max, Math.max(value, min));
+    }
+
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned. If value is NaN, the result is also NaN.
+     * <p>
+     * Unlike the numerical comparison operators, this method considers
+     * negative zero to be strictly smaller than positive zero.
+     * E.g., {@code clamp(-0.0, 0.0, 1.0)} returns 0.0.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if either of {@code min} and {@code max}
+     * arguments is NaN, or {@code min > max}, or {@code min} is +0.0, and
+     * {@code max} is -0.0.
+     *
+     * @since 21
+     */
+    public static double clamp(double value, double min, double max) {
+        // This unusual condition allows keeping only one branch
+        // on common path when min < max and neither of them is NaN.
+        // If min == max, we should additionally check for +0.0/-0.0 case,
+        // so we're still visiting the if statement.
+        if (!(min < max)) { // min greater than, equal to, or unordered with respect to max; NaN values are unordered
+            if (Double.isNaN(min)) {
+                throw new IllegalArgumentException("min is NaN");
+            }
+            if (Double.isNaN(max)) {
+                throw new IllegalArgumentException("max is NaN");
+            }
+            if (Double.compare(min, max) > 0) {
+                throw new IllegalArgumentException(min + " > " + max);
+            }
+            // Fall-through if min and max are exactly equal (or min = -0.0 and max = +0.0)
+            // and none of them is NaN
+        }
+        return Math.min(max, Math.max(value, min));
+    }
+
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned. If value is NaN, the result is also NaN.
+     * <p>
+     * Unlike the numerical comparison operators, this method considers
+     * negative zero to be strictly smaller than positive zero.
+     * E.g., {@code clamp(-0.0f, 0.0f, 1.0f)} returns 0.0f.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if either of {@code min} and {@code max}
+     * arguments is NaN, or {@code min > max}, or {@code min} is +0.0f, and
+     * {@code max} is -0.0f.
+     *
+     * @since 21
+     */
+    public static float clamp(float value, float min, float max) {
+        // This unusual condition allows keeping only one branch
+        // on common path when min < max and neither of them is NaN.
+        // If min == max, we should additionally check for +0.0/-0.0 case,
+        // so we're still visiting the if statement.
+        if (!(min < max)) { // min greater than, equal to, or unordered with respect to max; NaN values are unordered
+            if (Float.isNaN(min)) {
+                throw new IllegalArgumentException("min is NaN");
+            }
+            if (Float.isNaN(max)) {
+                throw new IllegalArgumentException("max is NaN");
+            }
+            if (Float.compare(min, max) > 0) {
+                throw new IllegalArgumentException(min + " > " + max);
+            }
+            // Fall-through if min and max are exactly equal (or min = -0.0 and max = +0.0)
+            // and none of them is NaN
+        }
+        return Math.min(max, Math.max(value, min));
+    }
+
     /**
      * Returns the fused multiply add of the three arguments; that is,
      * returns the exact product of the first two arguments summed
diff --git a/src/java.base/share/classes/java/lang/Module.java b/src/java.base/share/classes/java/lang/Module.java
index 6f4da2219c1..aafe1b89a4b 100644
--- a/src/java.base/share/classes/java/lang/Module.java
+++ b/src/java.base/share/classes/java/lang/Module.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,6 +57,7 @@
 import jdk.internal.loader.BootLoader;
 import jdk.internal.loader.ClassLoaders;
 import jdk.internal.misc.CDS;
+import jdk.internal.misc.Unsafe;
 import jdk.internal.module.ModuleBootstrap;
 import jdk.internal.module.ModuleLoaderMap;
 import jdk.internal.module.ServicesCatalog;
@@ -113,6 +114,8 @@ public final class Module implements AnnotatedElement {
     private final ModuleDescriptor descriptor;
 
     // true, if this module allows restricted native access
+    // Accessing this variable is made through Unsafe in order to use the
+    // memory semantics that preserves ordering and visibility across threads.
     @Stable
     private boolean enableNativeAccess;
 
@@ -258,8 +261,8 @@ public ModuleLayer getLayer() {
     /**
      * Update this module to allow access to restricted methods.
      */
-    synchronized Module implAddEnableNativeAccess() {
-        enableNativeAccess = true;
+    Module implAddEnableNativeAccess() {
+        EnableNativeAccess.trySetEnableNativeAccess(this);
         return this;
     }
 
@@ -267,15 +270,34 @@ synchronized Module implAddEnableNativeAccess() {
      * Returns {@code true} if this module can access
      * <a href="foreign/package-summary.html#restricted"><em>restricted</em></a> methods.
      *
-     * @since 20
-     *
      * @return {@code true} if this module can access <em>restricted</em> methods.
+     * @since 20
      */
-    @PreviewFeature(feature=PreviewFeature.Feature.FOREIGN)
+    @PreviewFeature(feature = PreviewFeature.Feature.FOREIGN)
     public boolean isNativeAccessEnabled() {
         Module target = moduleForNativeAccess();
-        synchronized(target) {
-            return target.enableNativeAccess;
+        return EnableNativeAccess.isNativeAccessEnabled(target);
+    }
+
+    /**
+     * This class is used to be able to bootstrap without using Unsafe
+     * in the outer Module class as that would create a circular initializer dependency.
+     */
+    private static final class EnableNativeAccess {
+
+        private EnableNativeAccess() {}
+
+        private static final Unsafe UNSAFE = Unsafe.getUnsafe();
+        private static final long FIELD_OFFSET = UNSAFE.objectFieldOffset(Module.class, "enableNativeAccess");
+
+        private static boolean isNativeAccessEnabled(Module target) {
+            return UNSAFE.getBooleanVolatile(target, FIELD_OFFSET);
+        }
+
+        // Atomically sets enableNativeAccess if not already set
+        // returning if the value was updated
+        private static boolean trySetEnableNativeAccess(Module target) {
+            return UNSAFE.compareAndSetBoolean(target, FIELD_OFFSET, false, true);
         }
     }
 
@@ -289,46 +311,30 @@ private Module moduleForNativeAccess() {
     void ensureNativeAccess(Class<?> owner, String methodName) {
         // The target module whose enableNativeAccess flag is ensured
         Module target = moduleForNativeAccess();
-        // racy read of the enable native access flag
-        boolean isNativeAccessEnabled = target.enableNativeAccess;
-        if (!isNativeAccessEnabled) {
-            synchronized (target) {
-                // safe read of the enableNativeAccess of the target module
-                isNativeAccessEnabled = target.enableNativeAccess;
-
-                // check again with the safely read flag
-                if (isNativeAccessEnabled) {
-                    // another thread beat us to it - nothing to do
-                    return;
-                } else if (ModuleBootstrap.hasEnableNativeAccessFlag()) {
-                    throw new IllegalCallerException("Illegal native access from: " + this);
-                } else {
-                    // warn and set flag, so that only one warning is reported per module
-                    String cls = owner.getName();
-                    String mtd = cls + "::" + methodName;
-                    String mod = isNamed() ? "module " + getName() : "the unnamed module";
-                    String modflag = isNamed() ? getName() : "ALL-UNNAMED";
-                    System.err.printf("""
+        if (!EnableNativeAccess.isNativeAccessEnabled(target)) {
+            if (ModuleBootstrap.hasEnableNativeAccessFlag()) {
+                throw new IllegalCallerException("Illegal native access from: " + this);
+            }
+            if (EnableNativeAccess.trySetEnableNativeAccess(target)) {
+                // warn and set flag, so that only one warning is reported per module
+                String cls = owner.getName();
+                String mtd = cls + "::" + methodName;
+                String mod = isNamed() ? "module " + getName() : "the unnamed module";
+                String modflag = isNamed() ? getName() : "ALL-UNNAMED";
+                System.err.printf("""
                         WARNING: A restricted method in %s has been called
                         WARNING: %s has been called by %s
                         WARNING: Use --enable-native-access=%s to avoid a warning for this module
                         %n""", cls, mtd, mod, modflag);
-
-                    // set the flag
-                    target.enableNativeAccess = true;
-                }
             }
         }
     }
 
-
     /**
      * Update all unnamed modules to allow access to restricted methods.
      */
     static void implAddEnableNativeAccessToAllUnnamed() {
-        synchronized (ALL_UNNAMED_MODULE) {
-            ALL_UNNAMED_MODULE.enableNativeAccess = true;
-        }
+        EnableNativeAccess.trySetEnableNativeAccess(ALL_UNNAMED_MODULE);
     }
 
     // --
diff --git a/src/java.base/share/classes/java/lang/StrictMath.java b/src/java.base/share/classes/java/lang/StrictMath.java
index 71b79a26891..f08b016b629 100644
--- a/src/java.base/share/classes/java/lang/StrictMath.java
+++ b/src/java.base/share/classes/java/lang/StrictMath.java
@@ -259,7 +259,9 @@ public static double exp(double a) {
      * @return  the value ln&nbsp;{@code a}, the natural logarithm of
      *          {@code a}.
      */
-    public static native double log(double a);
+    public static double log(double a) {
+        return FdLibm.Log.compute(a);
+    }
 
     /**
      * Returns the base 10 logarithm of a {@code double} value.
@@ -1757,6 +1759,95 @@ public static double min(double a, double b) {
         return Math.min(a, b);
     }
 
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned.
+     * <p>
+     * While the original value of type long may not fit into the int type,
+     * the bounds have the int type, so the result always fits the int type.
+     * This allows to use method to safely cast long value to int with
+     * saturation.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if {@code min > max}
+     *
+     * @since 21
+     */
+    public static int clamp(long value, int min, int max) {
+        return Math.clamp(value, min, max);
+    }
+
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if {@code min > max}
+     *
+     * @since 21
+     */
+    public static long clamp(long value, long min, long max) {
+        return Math.clamp(value, min, max);
+    }
+
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned. If value is NaN, the result is also NaN.
+     * <p>
+     * Unlike the numerical comparison operators, this method considers
+     * negative zero to be strictly smaller than positive zero.
+     * E.g., {@code clamp(-0.0, 0.0, 1.0)} returns 0.0.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if either of {@code min} and {@code max}
+     * arguments is NaN, or {@code min > max}, or {@code min} is +0.0, and
+     * {@code max} is -0.0.
+     *
+     * @since 21
+     */
+    public static double clamp(double value, double min, double max) {
+        return Math.clamp(value, min, max);
+    }
+
+    /**
+     * Clamps the value to fit between min and max. If the value is less
+     * than {@code min}, then {@code min} is returned. If the value is greater
+     * than {@code max}, then {@code max} is returned. Otherwise, the original
+     * value is returned. If value is NaN, the result is also NaN.
+     * <p>
+     * Unlike the numerical comparison operators, this method considers
+     * negative zero to be strictly smaller than positive zero.
+     * E.g., {@code clamp(-0.0f, 0.0f, 1.0f)} returns 0.0f.
+     *
+     * @param value value to clamp
+     * @param min minimal allowed value
+     * @param max maximal allowed value
+     * @return a clamped value that fits into {@code min..max} interval
+     * @throws IllegalArgumentException if either of {@code min} and {@code max}
+     * arguments is NaN, or {@code min > max}, or {@code min} is +0.0f, and
+     * {@code max} is -0.0f.
+     *
+     * @since 21
+     */
+    public static float clamp(float value, float min, float max) {
+        return Math.clamp(value, min, max);
+    }
+
     /**
      * Returns the fused multiply add of the three arguments; that is,
      * returns the exact product of the first two arguments summed
diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java
index 1897a06cd60..1b5b5efb72b 100644
--- a/src/java.base/share/classes/java/lang/String.java
+++ b/src/java.base/share/classes/java/lang/String.java
@@ -51,6 +51,7 @@
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
+import jdk.internal.util.ArraysSupport;
 import jdk.internal.util.Preconditions;
 import jdk.internal.vm.annotation.ForceInline;
 import jdk.internal.vm.annotation.IntrinsicCandidate;
@@ -1272,8 +1273,7 @@ private static void throwUnmappable(int off) {
     }
 
     private static void throwUnmappable(byte[] val) {
-        int dp = 0;
-        while (dp < val.length && val[dp] >=0) { dp++; }
+        int dp = StringCoding.countPositives(val, 0, val.length);
         throwUnmappable(dp);
     }
 
@@ -1870,23 +1870,17 @@ private boolean nonSyncContentEquals(AbstractStringBuilder sb) {
         if (len != sb.length()) {
             return false;
         }
-        byte v1[] = value;
-        byte v2[] = sb.getValue();
+        byte[] v1 = value;
+        byte[] v2 = sb.getValue();
         byte coder = coder();
         if (coder == sb.getCoder()) {
-            int n = v1.length;
-            for (int i = 0; i < n; i++) {
-                if (v1[i] != v2[i]) {
-                    return false;
-                }
-            }
+            return v1.length <= v2.length && ArraysSupport.mismatch(v1, v2, v1.length) < 0;
         } else {
             if (coder != LATIN1) {  // utf16 str and latin1 abs can never be "equal"
                 return false;
             }
             return StringUTF16.contentEquals(v1, v2, len);
         }
-        return true;
     }
 
     /**
@@ -2024,8 +2018,8 @@ public boolean equalsIgnoreCase(String anotherString) {
      *          lexicographically greater than the string argument.
      */
     public int compareTo(String anotherString) {
-        byte v1[] = value;
-        byte v2[] = anotherString.value;
+        byte[] v1 = value;
+        byte[] v2 = anotherString.value;
         byte coder = coder();
         if (coder == anotherString.coder()) {
             return coder == LATIN1 ? StringLatin1.compareTo(v1, v2)
@@ -2060,8 +2054,8 @@ private static class CaseInsensitiveComparator
         private static final long serialVersionUID = 8575799808933029326L;
 
         public int compare(String s1, String s2) {
-            byte v1[] = s1.value;
-            byte v2[] = s2.value;
+            byte[] v1 = s1.value;
+            byte[] v2 = s2.value;
             byte coder = s1.coder();
             if (coder == s2.coder()) {
                 return coder == LATIN1 ? StringLatin1.compareToCI(v1, v2)
@@ -2136,26 +2130,23 @@ public int compareToIgnoreCase(String str) {
      *          {@code false} otherwise.
      */
     public boolean regionMatches(int toffset, String other, int ooffset, int len) {
-        byte tv[] = value;
-        byte ov[] = other.value;
         // Note: toffset, ooffset, or len might be near -1>>>1.
         if ((ooffset < 0) || (toffset < 0) ||
              (toffset > (long)length() - len) ||
              (ooffset > (long)other.length() - len)) {
             return false;
         }
+        byte[] tv = value;
+        byte[] ov = other.value;
         byte coder = coder();
         if (coder == other.coder()) {
-            if (!isLatin1() && (len > 0)) {
-                toffset = toffset << 1;
-                ooffset = ooffset << 1;
-                len = len << 1;
-            }
-            while (len-- > 0) {
-                if (tv[toffset++] != ov[ooffset++]) {
-                    return false;
-                }
+            if (coder == UTF16) {
+                toffset <<= UTF16;
+                ooffset <<= UTF16;
+                len <<= UTF16;
             }
+            return ArraysSupport.mismatch(tv, toffset,
+                    ov, ooffset, len) < 0;
         } else {
             if (coder == LATIN1) {
                 while (len-- > 0) {
@@ -2235,8 +2226,8 @@ public boolean regionMatches(boolean ignoreCase, int toffset,
                 || (ooffset > (long)other.length() - len)) {
             return false;
         }
-        byte tv[] = value;
-        byte ov[] = other.value;
+        byte[] tv = value;
+        byte[] ov = other.value;
         byte coder = coder();
         if (coder == other.coder()) {
             return coder == LATIN1
@@ -2270,18 +2261,17 @@ public boolean startsWith(String prefix, int toffset) {
         if (toffset < 0 || toffset > length() - prefix.length()) {
             return false;
         }
-        byte ta[] = value;
-        byte pa[] = prefix.value;
+        byte[] ta = value;
+        byte[] pa = prefix.value;
         int po = 0;
         int pc = pa.length;
         byte coder = coder();
         if (coder == prefix.coder()) {
-            int to = (coder == LATIN1) ? toffset : toffset << 1;
-            while (po < pc) {
-                if (ta[to++] != pa[po++]) {
-                    return false;
-                }
+            if (coder == UTF16) {
+                toffset <<= UTF16;
             }
+            return ArraysSupport.mismatch(ta, toffset,
+                    pa, 0, pc) < 0;
         } else {
             if (coder == LATIN1) {  // && pcoder == UTF16
                 return false;
diff --git a/src/java.base/share/classes/java/lang/StringLatin1.java b/src/java.base/share/classes/java/lang/StringLatin1.java
index 526d752f058..7749597a24a 100644
--- a/src/java.base/share/classes/java/lang/StringLatin1.java
+++ b/src/java.base/share/classes/java/lang/StringLatin1.java
@@ -109,12 +109,8 @@ public static int compareTo(byte[] value, byte[] other) {
 
     public static int compareTo(byte[] value, byte[] other, int len1, int len2) {
         int lim = Math.min(len1, len2);
-        for (int k = 0; k < lim; k++) {
-            if (value[k] != other[k]) {
-                return getChar(value, k) - getChar(other, k);
-            }
-        }
-        return len1 - len2;
+        int k = ArraysSupport.mismatch(value, other, lim);
+        return (k < 0) ? len1 - len2 : getChar(value, k) - getChar(other, k);
     }
 
     @IntrinsicCandidate
diff --git a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
index e174115850b..879bee964a1 100644
--- a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
+++ b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
@@ -233,7 +233,7 @@ final BoundMethodHandle copyWith(MethodType mt, LambdaForm lf) {
         /*non-public*/
         final BoundMethodHandle copyWithExtendL(MethodType mt, LambdaForm lf, Object narg) {
             try {
-                return (BoundMethodHandle) BMH_SPECIES.extendWith(L_TYPE_NUM).factory().invokeBasic(mt, lf, argL0, narg);
+                return (BoundMethodHandle) BMH_SPECIES.extendWith(L_TYPE).factory().invokeBasic(mt, lf, argL0, narg);
             } catch (Throwable ex) {
                 throw uncaughtException(ex);
             }
@@ -242,7 +242,7 @@ final BoundMethodHandle copyWithExtendL(MethodType mt, LambdaForm lf, Object nar
         /*non-public*/
         final BoundMethodHandle copyWithExtendI(MethodType mt, LambdaForm lf, int narg) {
             try {
-                return (BoundMethodHandle) BMH_SPECIES.extendWith(I_TYPE_NUM).factory().invokeBasic(mt, lf, argL0, narg);
+                return (BoundMethodHandle) BMH_SPECIES.extendWith(I_TYPE).factory().invokeBasic(mt, lf, argL0, narg);
             } catch (Throwable ex) {
                 throw uncaughtException(ex);
             }
@@ -251,7 +251,7 @@ final BoundMethodHandle copyWithExtendI(MethodType mt, LambdaForm lf, int narg)
         /*non-public*/
         final BoundMethodHandle copyWithExtendJ(MethodType mt, LambdaForm lf, long narg) {
             try {
-                return (BoundMethodHandle) BMH_SPECIES.extendWith(J_TYPE_NUM).factory().invokeBasic(mt, lf, argL0, narg);
+                return (BoundMethodHandle) BMH_SPECIES.extendWith(J_TYPE).factory().invokeBasic(mt, lf, argL0, narg);
             } catch (Throwable ex) {
                 throw uncaughtException(ex);
             }
@@ -260,7 +260,7 @@ final BoundMethodHandle copyWithExtendJ(MethodType mt, LambdaForm lf, long narg)
         /*non-public*/
         final BoundMethodHandle copyWithExtendF(MethodType mt, LambdaForm lf, float narg) {
             try {
-                return (BoundMethodHandle) BMH_SPECIES.extendWith(F_TYPE_NUM).factory().invokeBasic(mt, lf, argL0, narg);
+                return (BoundMethodHandle) BMH_SPECIES.extendWith(F_TYPE).factory().invokeBasic(mt, lf, argL0, narg);
             } catch (Throwable ex) {
                 throw uncaughtException(ex);
             }
@@ -269,7 +269,7 @@ final BoundMethodHandle copyWithExtendF(MethodType mt, LambdaForm lf, float narg
         /*non-public*/
         final BoundMethodHandle copyWithExtendD(MethodType mt, LambdaForm lf, double narg) {
             try {
-                return (BoundMethodHandle) BMH_SPECIES.extendWith(D_TYPE_NUM).factory().invokeBasic(mt, lf, argL0, narg);
+                return (BoundMethodHandle) BMH_SPECIES.extendWith(D_TYPE).factory().invokeBasic(mt, lf, argL0, narg);
             } catch (Throwable ex) {
                 throw uncaughtException(ex);
             }
@@ -319,7 +319,7 @@ protected MethodHandle deriveTransformHelper(MemberName transform, int whichtm)
             if (whichtm == Specializer.TN_COPY_NO_EXTEND) {
                 return factory();
             } else if (whichtm < ARG_TYPE_LIMIT) {
-                return extendWith((byte) whichtm).factory();
+                return extendWith(BasicType.basicType((byte) whichtm)).factory();
             } else {
                 throw newInternalError("bad transform");
             }
@@ -353,10 +353,11 @@ private boolean verifyTHAargs(MemberName transform, int whichtm, List<?> args, L
         }
 
         /*non-public*/
-        SpeciesData extendWith(byte typeNum) {
+        SpeciesData extendWith(BasicType basicType) {
+            int typeNum = basicType.ordinal();
             SpeciesData sd = extensions[typeNum];
             if (sd != null)  return sd;
-            sd = SPECIALIZER.findSpecies(key() + BasicType.basicType(typeNum).basicTypeChar());
+            sd = SPECIALIZER.findSpecies(key() + basicType.basicTypeChar());
             extensions[typeNum] = sd;
             return sd;
         }
@@ -406,7 +407,7 @@ protected BoundMethodHandle.SpeciesData newSpeciesData(String key) {
         }
 
         static final List<MemberName> BMH_TRANSFORMS;
-        static final int TN_COPY_NO_EXTEND = V_TYPE_NUM;
+        static final int TN_COPY_NO_EXTEND = V_TYPE.ordinal();
         static {
             final Class<BoundMethodHandle> BMH = BoundMethodHandle.class;
             // copyWithExtendLIJFD + copyWith
diff --git a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
index 1e150654e12..0d47547a9a7 100644
--- a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
@@ -150,16 +150,6 @@ enum BasicType {
         static final int ARG_TYPE_LIMIT = ARG_TYPES.length;
         static final int TYPE_LIMIT = ALL_TYPES.length;
 
-        // Derived int constants, which (unlike the enums) can be constant folded.
-        // We can remove them when JDK-8161245 is fixed.
-        static final byte
-                L_TYPE_NUM = (byte) L_TYPE.ordinal(),
-                I_TYPE_NUM = (byte) I_TYPE.ordinal(),
-                J_TYPE_NUM = (byte) J_TYPE.ordinal(),
-                F_TYPE_NUM = (byte) F_TYPE.ordinal(),
-                D_TYPE_NUM = (byte) D_TYPE.ordinal(),
-                V_TYPE_NUM = (byte) V_TYPE.ordinal();
-
         final char btChar;
         final Class<?> btClass;
         final Wrapper btWrapper;
diff --git a/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java b/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
index cad6b9b5e40..1b2d44f91fa 100644
--- a/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
@@ -513,7 +513,7 @@ private BoundMethodHandle.SpeciesData oldSpeciesData() {
     }
 
     private BoundMethodHandle.SpeciesData newSpeciesData(BasicType type) {
-        return oldSpeciesData().extendWith((byte) type.ordinal());
+        return oldSpeciesData().extendWith(type);
     }
 
     BoundMethodHandle bindArgumentL(BoundMethodHandle mh, int pos, Object value) {
diff --git a/src/java.base/share/classes/java/lang/invoke/SimpleMethodHandle.java b/src/java.base/share/classes/java/lang/invoke/SimpleMethodHandle.java
index 9cff0fcb55d..6621acb84db 100644
--- a/src/java.base/share/classes/java/lang/invoke/SimpleMethodHandle.java
+++ b/src/java.base/share/classes/java/lang/invoke/SimpleMethodHandle.java
@@ -74,7 +74,7 @@ final BoundMethodHandle copyWithExtendL(MethodType mt, LambdaForm lf, Object nar
     /*non-public*/
     final BoundMethodHandle copyWithExtendI(MethodType mt, LambdaForm lf, int narg) {
         try {
-            return (BoundMethodHandle) BMH_SPECIES.extendWith(I_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
+            return (BoundMethodHandle) BMH_SPECIES.extendWith(I_TYPE).factory().invokeBasic(mt, lf, narg);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
@@ -83,7 +83,7 @@ final BoundMethodHandle copyWithExtendI(MethodType mt, LambdaForm lf, int narg)
     /*non-public*/
     final BoundMethodHandle copyWithExtendJ(MethodType mt, LambdaForm lf, long narg) {
         try {
-            return (BoundMethodHandle) BMH_SPECIES.extendWith(J_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
+            return (BoundMethodHandle) BMH_SPECIES.extendWith(J_TYPE).factory().invokeBasic(mt, lf, narg);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
@@ -92,7 +92,7 @@ final BoundMethodHandle copyWithExtendJ(MethodType mt, LambdaForm lf, long narg)
     /*non-public*/
     final BoundMethodHandle copyWithExtendF(MethodType mt, LambdaForm lf, float narg) {
         try {
-            return (BoundMethodHandle) BMH_SPECIES.extendWith(F_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
+            return (BoundMethodHandle) BMH_SPECIES.extendWith(F_TYPE).factory().invokeBasic(mt, lf, narg);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
@@ -101,7 +101,7 @@ final BoundMethodHandle copyWithExtendF(MethodType mt, LambdaForm lf, float narg
     /*non-public*/
     final BoundMethodHandle copyWithExtendD(MethodType mt, LambdaForm lf, double narg) {
         try {
-            return (BoundMethodHandle) BMH_SPECIES.extendWith(D_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
+            return (BoundMethodHandle) BMH_SPECIES.extendWith(D_TYPE).factory().invokeBasic(mt, lf, narg);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
diff --git a/src/java.base/share/classes/java/lang/invoke/VarHandles.java b/src/java.base/share/classes/java/lang/invoke/VarHandles.java
index c15136ced44..404cdb53f61 100644
--- a/src/java.base/share/classes/java/lang/invoke/VarHandles.java
+++ b/src/java.base/share/classes/java/lang/invoke/VarHandles.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,52 +114,53 @@ else if (type == double.class) {
             if (UNSAFE.shouldBeInitialized(refc))
                 UNSAFE.ensureClassInitialized(refc);
 
+            Class<?> decl = f.getDeclaringClass();
             Object base = MethodHandleNatives.staticFieldBase(f);
             long foffset = MethodHandleNatives.staticFieldOffset(f);
             if (!type.isPrimitive()) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleReferences.FieldStaticReadOnly(refc, base, foffset, type)
-                       : new VarHandleReferences.FieldStaticReadWrite(refc, base, foffset, type));
+                       ? new VarHandleReferences.FieldStaticReadOnly(decl, base, foffset, type)
+                       : new VarHandleReferences.FieldStaticReadWrite(decl, base, foffset, type));
             }
             else if (type == boolean.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleBooleans.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleBooleans.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleBooleans.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleBooleans.FieldStaticReadWrite(decl, base, foffset));
             }
             else if (type == byte.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleBytes.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleBytes.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleBytes.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleBytes.FieldStaticReadWrite(decl, base, foffset));
             }
             else if (type == short.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleShorts.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleShorts.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleShorts.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleShorts.FieldStaticReadWrite(decl, base, foffset));
             }
             else if (type == char.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleChars.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleChars.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleChars.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleChars.FieldStaticReadWrite(decl, base, foffset));
             }
             else if (type == int.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleInts.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleInts.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleInts.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleInts.FieldStaticReadWrite(decl, base, foffset));
             }
             else if (type == long.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleLongs.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleLongs.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleLongs.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleLongs.FieldStaticReadWrite(decl, base, foffset));
             }
             else if (type == float.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleFloats.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleFloats.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleFloats.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleFloats.FieldStaticReadWrite(decl, base, foffset));
             }
             else if (type == double.class) {
                 return maybeAdapt(f.isFinal() && !isWriteAllowedOnFinalFields
-                       ? new VarHandleDoubles.FieldStaticReadOnly(refc, base, foffset)
-                       : new VarHandleDoubles.FieldStaticReadWrite(refc, base, foffset));
+                       ? new VarHandleDoubles.FieldStaticReadOnly(decl, base, foffset)
+                       : new VarHandleDoubles.FieldStaticReadWrite(decl, base, foffset));
             }
             else {
                 throw new UnsupportedOperationException();
@@ -183,10 +184,10 @@ static Field getFieldFromReceiverAndOffset(Class<?> receiverType,
     }
 
     // Required by instance static field handles
-    static Field getStaticFieldFromBaseAndOffset(Class<?> receiverType,
+    static Field getStaticFieldFromBaseAndOffset(Class<?> declaringClass,
                                                  long offset,
                                                  Class<?> fieldType) {
-        for (Field f : receiverType.getDeclaredFields()) {
+        for (Field f : declaringClass.getDeclaredFields()) {
             if (!Modifier.isStatic(f.getModifiers())) continue;
 
             if (offset == UNSAFE.staticFieldOffset(f)) {
diff --git a/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
index fdde3aef663..36a646e6398 100644
--- a/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
+++ b/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -382,21 +382,21 @@ final class VarHandle$Type$s {
 
 
     static sealed class FieldStaticReadOnly extends VarHandle {
-        final Class<?> receiverType;
+        final Class<?> declaringClass;
         final Object base;
         final long fieldOffset;
 #if[Object]
         final Class<?> fieldType;
 #end[Object]
 
-        FieldStaticReadOnly(Class<?> receiverType, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
-            this(receiverType, base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadOnly.FORM, false);
+        FieldStaticReadOnly(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
+            this(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadOnly.FORM, false);
         }
 
-        protected FieldStaticReadOnly(Class<?> receiverType, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
+        protected FieldStaticReadOnly(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
                                       VarForm form, boolean exact) {
             super(form, exact);
-            this.receiverType = receiverType;
+            this.declaringClass = declaringClass;
             this.base = base;
             this.fieldOffset = fieldOffset;
 #if[Object]
@@ -408,14 +408,14 @@ final class VarHandle$Type$s {
         public FieldStaticReadOnly withInvokeExactBehavior() {
             return hasInvokeExactBehavior()
                 ? this
-                : new FieldStaticReadOnly(receiverType, base, fieldOffset{#if[Object]?, fieldType}, vform, true);
+                : new FieldStaticReadOnly(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, vform, true);
         }
 
         @Override
         public FieldStaticReadOnly withInvokeBehavior() {
             return !hasInvokeExactBehavior()
                 ? this
-                : new FieldStaticReadOnly(receiverType, base, fieldOffset{#if[Object]?, fieldType}, vform, false);
+                : new FieldStaticReadOnly(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, vform, false);
         }
 
         @Override
@@ -426,11 +426,11 @@ final class VarHandle$Type$s {
 
             // Reflect on this VarHandle to extract the field name
             var staticField = VarHandles.getStaticFieldFromBaseAndOffset(
-                receiverType, fieldOffset, {#if[Object]?fieldType:$type$.class});
-            var receiverTypeRef = staticField.getDeclaringClass().describeConstable();
-            if (!receiverTypeRef.isPresent())
+                declaringClass, fieldOffset, {#if[Object]?fieldType:$type$.class});
+            var declaringTypeRef = declaringClass.describeConstable();
+            if (!declaringTypeRef.isPresent())
                 return Optional.empty();
-            return Optional.of(VarHandleDesc.ofStaticField(receiverTypeRef.get(), staticField.getName(), fieldTypeRef.get()));
+            return Optional.of(VarHandleDesc.ofStaticField(declaringTypeRef.get(), staticField.getName(), fieldTypeRef.get()));
         }
 
         @Override
@@ -471,27 +471,27 @@ final class VarHandle$Type$s {
 
     static final class FieldStaticReadWrite extends FieldStaticReadOnly {
 
-        FieldStaticReadWrite(Class<?> receiverType, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
-            this(receiverType, base, fieldOffset{#if[Object]?, fieldType}, false);
+        FieldStaticReadWrite(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
+            this(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, false);
         }
 
-        private FieldStaticReadWrite(Class<?> receiverType, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
+        private FieldStaticReadWrite(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
                                      boolean exact) {
-            super(receiverType, base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM, exact);
+            super(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM, exact);
         }
 
         @Override
         public FieldStaticReadWrite withInvokeExactBehavior() {
             return hasInvokeExactBehavior()
                 ? this
-                : new FieldStaticReadWrite(receiverType, base, fieldOffset{#if[Object]?, fieldType}, true);
+                : new FieldStaticReadWrite(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, true);
         }
 
         @Override
         public FieldStaticReadWrite withInvokeBehavior() {
             return !hasInvokeExactBehavior()
                 ? this
-                : new FieldStaticReadWrite(receiverType, base, fieldOffset{#if[Object]?, fieldType}, false);
+                : new FieldStaticReadWrite(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, false);
         }
 
         @ForceInline
diff --git a/src/java.base/share/classes/java/net/DatagramSocket.java b/src/java.base/share/classes/java/net/DatagramSocket.java
index aed07960c8e..9a104349e4a 100644
--- a/src/java.base/share/classes/java/net/DatagramSocket.java
+++ b/src/java.base/share/classes/java/net/DatagramSocket.java
@@ -1350,7 +1350,6 @@ public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)
         delegate().leaveGroup(mcastaddr, netIf);
     }
 
-    // Temporary solution until JDK-8237352 is addressed
     private static final SocketAddress NO_DELEGATE = new SocketAddress() {};
 
     /**
@@ -1393,7 +1392,6 @@ private static SocketException toSocketException(IOException e) {
     static <T extends DatagramSocket> T createDelegate(SocketAddress bindaddr, Class<T> type)
             throws SocketException {
 
-        // Temporary solution until JDK-8237352 is addressed
         if (bindaddr == NO_DELEGATE) return null;
 
         assert type == DatagramSocket.class || type == MulticastSocket.class;
diff --git a/src/java.base/share/classes/java/util/Arrays.java b/src/java.base/share/classes/java/util/Arrays.java
index f92cfd4fb68..7f7fc43327a 100644
--- a/src/java.base/share/classes/java/util/Arrays.java
+++ b/src/java.base/share/classes/java/util/Arrays.java
@@ -26,6 +26,7 @@
 package java.util;
 
 import jdk.internal.util.ArraysSupport;
+import jdk.internal.vm.annotation.ForceInline;
 import jdk.internal.vm.annotation.IntrinsicCandidate;
 
 import java.io.Serializable;
@@ -3534,12 +3535,22 @@ public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]>
      * @since 1.6
      */
     public static byte[] copyOf(byte[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         byte[] copy = new byte[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static byte[] copyOf(byte[] original) {
+        byte[] copy = new byte[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified array, truncating or padding with zeros (if necessary)
      * so the copy has the specified length.  For all indices that are
@@ -3558,12 +3569,22 @@ public static byte[] copyOf(byte[] original, int newLength) {
      * @since 1.6
      */
     public static short[] copyOf(short[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         short[] copy = new short[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static short[] copyOf(short[] original) {
+        short[] copy = new short[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified array, truncating or padding with zeros (if necessary)
      * so the copy has the specified length.  For all indices that are
@@ -3582,12 +3603,22 @@ public static short[] copyOf(short[] original, int newLength) {
      * @since 1.6
      */
     public static int[] copyOf(int[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         int[] copy = new int[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static int[] copyOf(int[] original) {
+        int[] copy = new int[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified array, truncating or padding with zeros (if necessary)
      * so the copy has the specified length.  For all indices that are
@@ -3606,12 +3637,22 @@ public static int[] copyOf(int[] original, int newLength) {
      * @since 1.6
      */
     public static long[] copyOf(long[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         long[] copy = new long[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static long[] copyOf(long[] original) {
+        long[] copy = new long[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified array, truncating or padding with null characters (if necessary)
      * so the copy has the specified length.  For all indices that are valid
@@ -3630,12 +3671,22 @@ public static long[] copyOf(long[] original, int newLength) {
      * @since 1.6
      */
     public static char[] copyOf(char[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         char[] copy = new char[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static char[] copyOf(char[] original) {
+        char[] copy = new char[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified array, truncating or padding with zeros (if necessary)
      * so the copy has the specified length.  For all indices that are
@@ -3654,12 +3705,22 @@ public static char[] copyOf(char[] original, int newLength) {
      * @since 1.6
      */
     public static float[] copyOf(float[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         float[] copy = new float[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static float[] copyOf(float[] original) {
+        float[] copy = new float[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified array, truncating or padding with zeros (if necessary)
      * so the copy has the specified length.  For all indices that are
@@ -3678,12 +3739,22 @@ public static float[] copyOf(float[] original, int newLength) {
      * @since 1.6
      */
     public static double[] copyOf(double[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         double[] copy = new double[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static double[] copyOf(double[] original) {
+        double[] copy = new double[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified array, truncating or padding with {@code false} (if necessary)
      * so the copy has the specified length.  For all indices that are
@@ -3702,12 +3773,22 @@ public static double[] copyOf(double[] original, int newLength) {
      * @since 1.6
      */
     public static boolean[] copyOf(boolean[] original, int newLength) {
+        if (newLength == original.length) {
+            return copyOf(original);
+        }
         boolean[] copy = new boolean[newLength];
         System.arraycopy(original, 0, copy, 0,
                          Math.min(original.length, newLength));
         return copy;
     }
 
+    @ForceInline
+    private static boolean[] copyOf(boolean[] original) {
+        boolean[] copy = new boolean[original.length];
+        System.arraycopy(original, 0, copy, 0, original.length);
+        return copy;
+    }
+
     /**
      * Copies the specified range of the specified array into a new array.
      * The initial index of the range ({@code from}) must lie between zero
@@ -3789,6 +3870,13 @@ public static <T,U> T[] copyOfRange(U[] original, int from, int to, Class<? exte
         return copy;
     }
 
+    @ForceInline
+    private static void checkLength(int from, int to) {
+        if (to < from) {
+            throw new IllegalArgumentException(from + " > " + to);
+        }
+    }
+
     /**
      * Copies the specified range of the specified array into a new array.
      * The initial index of the range ({@code from}) must lie between zero
@@ -3816,9 +3904,17 @@ public static <T,U> T[] copyOfRange(U[] original, int from, int to, Class<? exte
      * @since 1.6
      */
     public static byte[] copyOfRange(byte[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeByte(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static byte[] copyOfRangeByte(byte[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         byte[] copy = new byte[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -3852,9 +3948,17 @@ public static byte[] copyOfRange(byte[] original, int from, int to) {
      * @since 1.6
      */
     public static short[] copyOfRange(short[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeShort(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static short[] copyOfRangeShort(short[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         short[] copy = new short[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -3888,9 +3992,17 @@ public static short[] copyOfRange(short[] original, int from, int to) {
      * @since 1.6
      */
     public static int[] copyOfRange(int[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeInt(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static int[] copyOfRangeInt(int[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         int[] copy = new int[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -3924,9 +4036,17 @@ public static int[] copyOfRange(int[] original, int from, int to) {
      * @since 1.6
      */
     public static long[] copyOfRange(long[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeLong(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static long[] copyOfRangeLong(long[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         long[] copy = new long[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -3960,9 +4080,17 @@ public static long[] copyOfRange(long[] original, int from, int to) {
      * @since 1.6
      */
     public static char[] copyOfRange(char[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeChar(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static char[] copyOfRangeChar(char[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         char[] copy = new char[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -3996,9 +4124,17 @@ public static char[] copyOfRange(char[] original, int from, int to) {
      * @since 1.6
      */
     public static float[] copyOfRange(float[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeFloat(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static float[] copyOfRangeFloat(float[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         float[] copy = new float[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -4032,9 +4168,17 @@ public static float[] copyOfRange(float[] original, int from, int to) {
      * @since 1.6
      */
     public static double[] copyOfRange(double[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeDouble(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static double[] copyOfRangeDouble(double[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         double[] copy = new double[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -4068,9 +4212,17 @@ public static double[] copyOfRange(double[] original, int from, int to) {
      * @since 1.6
      */
     public static boolean[] copyOfRange(boolean[] original, int from, int to) {
+        // Tickle the JIT to fold special cases optimally
+        if (from != 0 || to != original.length)
+            return copyOfRangeBoolean(original, from, to);
+        else // from == 0 && to == original.length
+            return copyOf(original);
+    }
+
+    @ForceInline
+    private static boolean[] copyOfRangeBoolean(boolean[] original, int from, int to) {
+        checkLength(from, to);
         int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
         boolean[] copy = new boolean[newLength];
         System.arraycopy(original, from, copy, 0,
                          Math.min(original.length - from, newLength));
@@ -5614,8 +5766,8 @@ public static int compare(boolean[] a, boolean[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(boolean[], int, int, boolean[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -5749,8 +5901,8 @@ public static int compare(byte[] a, byte[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(byte[], int, int, byte[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -6004,8 +6156,8 @@ public static int compare(short[] a, short[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(short[], int, int, short[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -6258,8 +6410,8 @@ public static int compare(char[] a, char[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(char[], int, int, char[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -6393,8 +6545,8 @@ public static int compare(int[] a, int[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(int[], int, int, int[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -6647,8 +6799,8 @@ public static int compare(long[] a, long[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(long[], int, int, long[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -6901,8 +7053,8 @@ public static int compare(float[] a, float[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(float[], int, int, float[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -7036,8 +7188,8 @@ public static int compare(double[] a, double[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(double[], int, int, double[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -7195,8 +7347,8 @@ public static <T extends Comparable<? super T>> int compare(T[] a, T[] b) {
      * <p>The comparison is consistent with
      * {@link #equals(Object[], int, int, Object[], int, int) equals}, more
      * specifically the following holds for arrays {@code a} and {@code b} with
-     * specified ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively:
+     * specified ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively:
      * <pre>{@code
      *     Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) ==
      *         (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0)
@@ -7478,8 +7630,8 @@ public static int mismatch(boolean[] a, boolean[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -7491,8 +7643,8 @@ public static int mismatch(boolean[] a, boolean[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -7605,8 +7757,8 @@ public static int mismatch(byte[] a, byte[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -7618,8 +7770,8 @@ public static int mismatch(byte[] a, byte[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -7732,8 +7884,8 @@ public static int mismatch(char[] a, char[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -7745,8 +7897,8 @@ public static int mismatch(char[] a, char[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -7859,8 +8011,8 @@ public static int mismatch(short[] a, short[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -7872,8 +8024,8 @@ public static int mismatch(short[] a, short[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -7986,8 +8138,8 @@ public static int mismatch(int[] a, int[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -7999,8 +8151,8 @@ public static int mismatch(int[] a, int[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -8113,8 +8265,8 @@ public static int mismatch(long[] a, long[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -8126,8 +8278,8 @@ public static int mismatch(long[] a, long[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -8240,8 +8392,8 @@ public static int mismatch(float[] a, float[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -8253,8 +8405,8 @@ public static int mismatch(float[] a, float[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -8367,8 +8519,8 @@ public static int mismatch(double[] a, double[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -8380,8 +8532,8 @@ public static int mismatch(double[] a, double[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -8498,8 +8650,8 @@ public static int mismatch(Object[] a, Object[] b) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -8511,8 +8663,8 @@ public static int mismatch(Object[] a, Object[] b) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
@@ -8644,8 +8796,8 @@ public static <T> int mismatch(T[] a, T[] b, Comparator<? super T> cmp) {
      * Otherwise, there is no mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a common
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a common
      * prefix of length {@code pl} if the following expression is true:
      * <pre>{@code
      *     pl >= 0 &&
@@ -8657,8 +8809,8 @@ public static <T> int mismatch(T[] a, T[] b, Comparator<? super T> cmp) {
      * elements from each array mismatch.
      *
      * <p>Two non-{@code null} arrays, {@code a} and {@code b} with specified
-     * ranges [{@code aFromIndex}, {@code atoIndex}) and
-     * [{@code bFromIndex}, {@code btoIndex}) respectively, share a proper
+     * ranges [{@code aFromIndex}, {@code aToIndex}) and
+     * [{@code bFromIndex}, {@code bToIndex}) respectively, share a proper
      * prefix if the following expression is true:
      * <pre>{@code
      *     (aToIndex - aFromIndex) != (bToIndex - bFromIndex) &&
diff --git a/src/java.base/share/classes/java/util/zip/ZipInputStream.java b/src/java.base/share/classes/java/util/zip/ZipInputStream.java
index b99cd2fe18d..9e265fd668e 100644
--- a/src/java.base/share/classes/java/util/zip/ZipInputStream.java
+++ b/src/java.base/share/classes/java/util/zip/ZipInputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -350,6 +350,9 @@ public void skipNBytes(long n) throws IOException {
      * interrupted during the transfer, is highly input and output stream
      * specific, and therefore not specified.
      * <p>
+     * If the total number of bytes transferred is greater than {@linkplain
+     * Long#MAX_VALUE}, then {@code Long.MAX_VALUE} will be returned.
+     * <p>
      * If an I/O error occurs reading from the input stream or writing to the
      * output stream, then it may do so after some bytes have been read or
      * written. Consequently, the input stream may not be at end of stream and
diff --git a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template
index 220dd6f1f5c..0e2a3f577f9 100644
--- a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template
+++ b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template
@@ -235,7 +235,11 @@ final class JceSecurity {
 
     // return whether this provider is properly signed and can be used by JCE
     static boolean canUseProvider(Provider p) {
-        return getVerificationResult(p) == null;
+        Exception e = getVerificationResult(p);
+        if (debug != null && e != null) {
+            debug.println("Provider verification result: " + e);
+        }
+        return e == null;
     }
 
     // dummy object to represent null
diff --git a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java
index dc61572fc3f..a38b72a3b35 100644
--- a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java
+++ b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -210,6 +210,23 @@ VM fromBitsCoerced(Class<? extends VM> vmClass, Class<E> eClass,
         return defaultImpl.fromBits(bits, s);
     }
 
+    /* ============================================================================ */
+    public interface IndexPartiallyInUpperRangeOperation<E,
+                                                         M extends VectorMask<E>> {
+        M apply(long offset, long limit);
+    }
+
+    @IntrinsicCandidate
+    public static
+    <E,
+     M extends VectorMask<E>>
+    M indexPartiallyInUpperRange(Class<? extends M> mClass, Class<E> eClass,
+                                 int length, long offset, long limit,
+                                 IndexPartiallyInUpperRangeOperation<E, M> defaultImpl) {
+        assert isNonCapturingLambda(defaultImpl) : defaultImpl;
+        return defaultImpl.apply(offset, limit);
+    }
+
     /* ============================================================================ */
     public interface ShuffleIotaOperation<S extends VectorSpecies<?>,
                                           SH extends VectorShuffle<?>> {
diff --git a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java
index ef39341158a..6706e24e22a 100644
--- a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java
@@ -326,45 +326,36 @@ public SSLPossession createPossession(HandshakeContext context) {
             }
 
             /*
-             * 768 bits ephemeral DH private keys were used to be used in
+             * 768 bit ephemeral DH private keys used to be used in
              * ServerKeyExchange except that exportable ciphers max out at 512
-             * bits modulus values. We still adhere to this behavior in legacy
+             * bit modulus values. We still adhere to this behavior in legacy
              * mode (system property "jdk.tls.ephemeralDHKeySize" is defined
              * as "legacy").
              *
-             * Old JDK (JDK 7 and previous) releases don't support DH keys
-             * bigger than 1024 bits. We have to consider the compatibility
-             * requirement. 1024 bits DH key is always used for non-exportable
-             * cipher suites in default mode (system property
+             * Only very old JDK releases don't support DH keys bigger than
+             * 1024 bits (JDK 1.5 and 6u/7u releases prior to adding support
+             * for DH keys > 1024 bits - see JDK-8062834). A 2048 bit
+             * DH key is always used for non-exportable cipher suites in
+             * default mode (when the system property
              * "jdk.tls.ephemeralDHKeySize" is not defined).
              *
-             * However, if applications want stronger strength, setting
-             * system property "jdk.tls.ephemeralDHKeySize" to "matched"
-             * is a workaround to use ephemeral DH key which size matches the
-             * corresponding authentication key. For example, if the public key
-             * size of an authentication certificate is 2048 bits, then the
-             * ephemeral DH key size should be 2048 bits accordingly unless
-             * the cipher suite is exportable.  This key sizing scheme keeps
-             * the cryptographic strength consistent between authentication
-             * keys and key-exchange keys.
-             *
              * Applications may also want to customize the ephemeral DH key
              * size to a fixed length for non-exportable cipher suites. This
-             * can be approached by setting system property
+             * can be done by setting the system property
              * "jdk.tls.ephemeralDHKeySize" to a valid positive integer between
              * 1024 and 8192 bits, inclusive.
              *
-             * Note that the minimum acceptable key size is 1024 bits except
-             * exportable cipher suites or legacy mode.
+             * Note that the minimum acceptable key size is 2048 bits except
+             * for exportable cipher suites or legacy mode.
              *
              * Note that per RFC 2246, the key size limit of DH is 512 bits for
              * exportable cipher suites.  Because of the weakness, exportable
              * cipher suites are deprecated since TLS v1.1 and they are not
              * enabled by default in Oracle provider. The legacy behavior is
-             * reserved and 512 bits DH key is always used for exportable
+             * preserved and a 512 bit DH key is always used for exportable
              * cipher suites.
              */
-            int keySize = exportable ? 512 : 1024;           // default mode
+            int keySize = exportable ? 512 : 2048;           // default mode
             if (!exportable) {
                 if (useLegacyEphemeralDHKeys) {          // legacy mode
                     keySize = 768;
@@ -390,7 +381,7 @@ public SSLPossession createPossession(HandshakeContext context) {
                         // limit in the future when the compatibility and
                         // interoperability impact is limited.
                         keySize = ks <= 1024 ? 1024 : 2048;
-                    } // Otherwise, anonymous cipher suites, 1024-bit is used.
+                    } // Otherwise, anonymous cipher suites, 2048-bit is used.
                 } else if (customizedDHKeySize > 0) {    // customized mode
                     keySize = customizedDHKeySize;
                 }
diff --git a/src/java.base/share/conf/security/java.security b/src/java.base/share/conf/security/java.security
index 8156eea7e11..c6a7f0d8115 100644
--- a/src/java.base/share/conf/security/java.security
+++ b/src/java.base/share/conf/security/java.security
@@ -943,10 +943,16 @@ crypto.policy=crypto.policydir-tbd
 
 #
 # The policy for the XML Signature secure validation mode. Validation of
-# XML Signatures that violate any of these constraints will fail. The
-# mode is enforced by default. The mode can be disabled by setting the
-# property "org.jcp.xml.dsig.secureValidation" to Boolean.FALSE with the
-# javax.xml.crypto.XMLCryptoContext.setProperty() method.
+# XML Signatures that violate any of these constraints will fail.
+# The mode can be enabled or disabled by setting the property
+# "org.jcp.xml.dsig.secureValidation" to Boolean.TRUE or Boolean.FALSE with
+# the javax.xml.crypto.XMLCryptoContext.setProperty() method, or by setting
+# the system property "org.jcp.xml.dsig.secureValidation" to "true" or
+# "false". Any other value for the system property is also treated as "false".
+# If the system property is set, it supersedes the XMLCryptoContext property
+# value.
+#
+# The secure validation mode is enabled by default.
 #
 #   Policy:
 #       Constraint {"," Constraint }
diff --git a/src/java.base/share/data/cacerts/certignaca b/src/java.base/share/data/cacerts/certignaca
new file mode 100644
index 00000000000..9e506339e84
--- /dev/null
+++ b/src/java.base/share/data/cacerts/certignaca
@@ -0,0 +1,29 @@
+Owner: CN=Certigna, O=Dhimyotis, C=FR
+Issuer: CN=Certigna, O=Dhimyotis, C=FR
+Serial number: fedce3010fc948ff
+Valid from: Fri Jun 29 15:13:05 GMT 2007 until: Tue Jun 29 15:13:05 GMT 2027
+Signature algorithm name: SHA1withRSA
+Subject Public Key Algorithm: 2048-bit RSA key
+Version: 3
+-----BEGIN CERTIFICATE-----
+MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNV
+BAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4X
+DTA3MDYyOTE1MTMwNVoXDTI3MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQ
+BgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwIQ2VydGlnbmEwggEiMA0GCSqGSIb3
+DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7qXOEm7RFHYeGifBZ4
+QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyHGxny
+gQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbw
+zBfsV1/pogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q
+130yGLMLLGq/jj8UEYkgDncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2
+JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKfIrjxwo1p3Po6WAbfAgMBAAGjgbwwgbkw
+DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQtCRZvgHyUtVF9lo53BEw
+ZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJBgNVBAYT
+AkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzj
+AQ/JSP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG
+9w0BAQUFAAOCAQEAhQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8h
+bV6lUmPOEvjvKtpv6zf+EwLHyzs+ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFnc
+fca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1kluPBS1xp81HlDQwY9qcEQCYsuu
+HWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY1gkIl2PlwS6w
+t0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
+WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
+-----END CERTIFICATE-----
diff --git a/src/java.base/share/native/libjimage/imageFile.cpp b/src/java.base/share/native/libjimage/imageFile.cpp
index 0f45a023eed..4a8f35cd6fa 100644
--- a/src/java.base/share/native/libjimage/imageFile.cpp
+++ b/src/java.base/share/native/libjimage/imageFile.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -130,6 +130,9 @@ void ImageLocation::set_data(u1* data) {
         // Extract kind from header byte.
         u1 kind = attribute_kind(byte);
         assert(kind < ATTRIBUTE_COUNT && "invalid image location attribute");
+        if (kind == ATTRIBUTE_END) {
+            break;
+        }
         // Extract length of data (in bytes).
         u1 n = attribute_length(byte);
         // Read value (most significant first.)
diff --git a/src/java.base/share/native/libjimage/imageFile.hpp b/src/java.base/share/native/libjimage/imageFile.hpp
index 9cb0038ff71..78b37a38b7f 100644
--- a/src/java.base/share/native/libjimage/imageFile.hpp
+++ b/src/java.base/share/native/libjimage/imageFile.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -203,8 +203,8 @@ class ImageStrings {
 // 'length' less 1 (lower 3 bits of header) of bytes that follow containing the
 // attribute value.  Attribute values present as most significant byte first.
 //
-// Ex. Container offset (ATTRIBUTE_OFFSET) 0x33562 would be represented as 0x22
-// (kind = 4, length = 3), 0x03, 0x35, 0x62.
+// Ex. Container offset (ATTRIBUTE_OFFSET) 0x33562 would be represented as 0x2A
+// (kind = 5, length = 3), 0x03, 0x35, 0x62.
 //
 // An attribute stream is terminated with a header kind of ATTRIBUTE_END (header
 // byte of zero.)
@@ -214,10 +214,10 @@ class ImageStrings {
 // direct indexing. Unspecified values default to zero.
 //
 // Notes:
-//  - Even though ATTRIBUTE_END is used to mark the end of the attribute stream,
-//      streams will contain zero byte values to represent lesser significant bits.
-//      Thus, detecting a zero byte is not sufficient to detect the end of an attribute
-//      stream.
+//  - Even though ATTRIBUTE_END (which might be encoded with a zero byte) is used to
+//      mark the end of the attribute stream, streams will contain zero byte values
+//      in the non-header portion of the attribute data. Thus, detecting a zero byte
+//      is not sufficient to detect the end of an attribute stream.
 //  - ATTRIBUTE_OFFSET represents the number of bytes from the beginning of the region
 //      storing the resources.  Thus, in an image this represents the number of bytes
 //      after the index.
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
index 72f68fc59e7..f35ae683812 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -2243,23 +2243,20 @@ public void eventDispatched(AWTEvent ev) {
                     }
                 }
             }
-            /* Activate a JInternalFrame if necessary. */
-            if (eventID == MouseEvent.MOUSE_PRESSED) {
-                Object object = ev.getSource();
-                if (!(object instanceof Component)) {
-                    return;
-                }
-                Component component = (Component)object;
-                if (component != null) {
-                    Component parent = component;
-                    while (parent != null && !(parent instanceof Window)) {
-                        if (parent instanceof JInternalFrame) {
+
+            // Activate a JInternalFrame if necessary.
+            if (eventID == MouseEvent.MOUSE_PRESSED
+                    && ev.getSource() instanceof Component parent) {
+                while (parent != null && !(parent instanceof Window)) {
+                    if (parent instanceof JInternalFrame internalFrame) {
+                        try {
                             // Activate the frame.
-                            try { ((JInternalFrame)parent).setSelected(true); }
-                            catch (PropertyVetoException e1) { }
+                            internalFrame.setSelected(true);
+                        } catch (PropertyVetoException ignored) {
                         }
-                        parent = parent.getParent();
                     }
+
+                    parent = parent.getParent();
                 }
             }
         }
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java
index c7ebc992166..df2af1aee09 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java
@@ -235,33 +235,32 @@ public Insets getBorderInsets(Component c, Insets newInsets) {
         }
     }
 
-    /**
-     * The class represents the border of a {@code JInternalFrame}.
-     */
-    @SuppressWarnings("serial") // Superclass is not serializable across versions
-    public static class InternalFrameBorder extends AbstractBorder implements UIResource {
-        private static final int CORNER = 14;
+    @SuppressWarnings("serial")
+    private abstract static sealed class AbstractMetalWindowBorder
+            extends AbstractBorder
+            implements UIResource
+            permits FrameBorder, DialogBorder, InternalFrameBorderImpl {
 
-        /**
-         * Constructs a {@code InternalFrameBorder}.
-         */
-        public InternalFrameBorder() {}
+        protected Color background;
+        protected Color highlight;
+        protected Color shadow;
 
-        public void paintBorder(Component c, Graphics g, int x, int y,
-                                int w, int h) {
+        private static final int CORNER = 14;
+
+        @Override
+        public final void paintBorder(Component c, Graphics g,
+                                      int x, int y, int w, int h) {
             SwingUtilities3.paintBorder(c, g,
                                         x, y, w, h,
                                         this::paintUnscaledBorder);
         }
 
-        private void paintUnscaledBorder(Component c, Graphics g,
-                                         int width, int height,
-                                         double scaleFactor) {
-            Color background;
-            Color highlight;
-            Color shadow;
+        protected abstract boolean isActive(Component c);
+
+        protected abstract boolean isResizable(Component c);
 
-            if (c instanceof JInternalFrame && ((JInternalFrame)c).isSelected()) {
+        protected void updateColors(Component c) {
+            if (isActive(c)) {
                 background = MetalLookAndFeel.getPrimaryControlDarkShadow();
                 highlight = MetalLookAndFeel.getPrimaryControlShadow();
                 shadow = MetalLookAndFeel.getPrimaryControlInfo();
@@ -270,29 +269,41 @@ private void paintUnscaledBorder(Component c, Graphics g,
                 highlight = MetalLookAndFeel.getControlShadow();
                 shadow = MetalLookAndFeel.getControlInfo();
             }
+        }
 
-            // scaled border
-            int thickness = (int) Math.ceil(4 * scaleFactor);
+        private void paintUnscaledBorder(Component c, Graphics g,
+                                         int width, int height,
+                                         double scaleFactor) {
+            updateColors(c);
 
+            // scaled thickness
+            int thickness = (int) Math.ceil(4 * scaleFactor);
             g.setColor(background);
             // Draw the bulk of the border
             for (int i = 0; i <= thickness; i++) {
                 g.drawRect(i, i, width - (i * 2), height - (i * 2));
             }
 
-            if (c instanceof JInternalFrame && ((JInternalFrame)c).isResizable()) {
-                // midpoint at which highlight & shadow lines
-                // are positioned on the border
+            if (isResizable(c)) {
+                //midpoint at which highlight & shadow lines
+                //are positioned on the border
                 int midPoint = thickness / 2;
-                int stkWidth = clipRound(scaleFactor);
-                int offset = (((scaleFactor - stkWidth) >= 0) && ((stkWidth % 2) != 0)) ? 1 : 0;
-                int loc1 = thickness % 2 == 0 ? midPoint + stkWidth / 2 - stkWidth : midPoint;
-                int loc2 = thickness % 2 == 0 ? midPoint + stkWidth / 2 : midPoint + stkWidth;
+                int strokeWidth = clipRound(scaleFactor);
+                int offset = (((scaleFactor - strokeWidth) >= 0)
+                              && ((strokeWidth % 2) != 0)) ? 1 : 0;
+
+                int loc1 = (thickness % 2 == 0)
+                           ? midPoint + strokeWidth / 2 - strokeWidth
+                           : midPoint;
+                int loc2 = (thickness % 2 == 0)
+                           ? midPoint + strokeWidth / 2
+                           : midPoint + strokeWidth;
+
                 // scaled corner
                 int corner = (int) Math.round(CORNER * scaleFactor);
 
                 if (g instanceof Graphics2D) {
-                    ((Graphics2D) g).setStroke(new BasicStroke((float) stkWidth));
+                    ((Graphics2D) g).setStroke(new BasicStroke((float) strokeWidth));
                 }
 
                 // Draw the Long highlight lines
@@ -315,72 +326,74 @@ private void paintUnscaledBorder(Component c, Graphics g,
             }
         }
 
-        public Insets getBorderInsets(Component c, Insets newInsets) {
+        @Override
+        public final Insets getBorderInsets(Component c, Insets newInsets) {
             newInsets.set(4, 4, 4, 4);
             return newInsets;
         }
     }
 
+    @SuppressWarnings("serial")
+    private static final class InternalFrameBorderImpl extends AbstractMetalWindowBorder {
+
+        @Override
+        protected boolean isActive(Component c) {
+            return (c instanceof JInternalFrame
+                    && ((JInternalFrame)c).isSelected());
+        }
+
+        @Override
+        protected boolean isResizable(Component c) {
+            return ((c instanceof JInternalFrame
+                    && ((JInternalFrame) c).isResizable()));
+        }
+    }
+
     /**
-     * Border for a Frame.
-     * @since 1.4
+     * The class represents the border of a {@code JInternalFrame}.
      */
     @SuppressWarnings("serial") // Superclass is not serializable across versions
-    static class FrameBorder extends AbstractBorder implements UIResource {
-        private static final int corner = 14;
-
-        public void paintBorder(Component c, Graphics g, int x, int y,
-            int w, int h) {
-
-            Color background;
-            Color highlight;
-            Color shadow;
+    public static class InternalFrameBorder extends AbstractBorder implements UIResource {
 
-            Window window = SwingUtilities.getWindowAncestor(c);
-            if (window != null && window.isActive()) {
-                background = MetalLookAndFeel.getPrimaryControlDarkShadow();
-                highlight = MetalLookAndFeel.getPrimaryControlShadow();
-                shadow = MetalLookAndFeel.getPrimaryControlInfo();
-            } else {
-                background = MetalLookAndFeel.getControlDarkShadow();
-                highlight = MetalLookAndFeel.getControlShadow();
-                shadow = MetalLookAndFeel.getControlInfo();
-            }
+        private final InternalFrameBorderImpl border;
 
-            g.setColor(background);
-            // Draw outermost lines
-            g.drawLine( x+1, y+0, x+w-2, y+0);
-            g.drawLine( x+0, y+1, x+0, y +h-2);
-            g.drawLine( x+w-1, y+1, x+w-1, y+h-2);
-            g.drawLine( x+1, y+h-1, x+w-2, y+h-1);
+        /**
+         * Constructs a {@code InternalFrameBorder}.
+         */
+        public InternalFrameBorder() {
+            border = new InternalFrameBorderImpl();
+        }
 
-            // Draw the bulk of the border
-            for (int i = 1; i < 5; i++) {
-                g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
-            }
+        @Override
+        public void paintBorder(Component c, Graphics g, int x, int y,
+                                int w, int h) {
+            border.paintBorder(c, g, x, y, w, h);
+        }
 
-            if ((window instanceof Frame) && ((Frame) window).isResizable()) {
-                g.setColor(highlight);
-                // Draw the Long highlight lines
-                g.drawLine( corner+1, 3, w-corner, 3);
-                g.drawLine( 3, corner+1, 3, h-corner);
-                g.drawLine( w-2, corner+1, w-2, h-corner);
-                g.drawLine( corner+1, h-2, w-corner, h-2);
+        @Override
+        public Insets getBorderInsets(Component c, Insets newInsets) {
+            return border.getBorderInsets(c, newInsets);
+        }
+    }
 
-                g.setColor(shadow);
-                // Draw the Long shadow lines
-                g.drawLine( corner, 2, w-corner-1, 2);
-                g.drawLine( 2, corner, 2, h-corner-1);
-                g.drawLine( w-3, corner, w-3, h-corner-1);
-                g.drawLine( corner, h-3, w-corner-1, h-3);
-            }
+    /**
+     * Border for a Frame.
+     * @since 1.4
+     */
+    @SuppressWarnings("serial") // Superclass is not serializable across versions
+    static final class FrameBorder extends AbstractMetalWindowBorder implements UIResource {
 
+        @Override
+        protected boolean isActive(Component c) {
+            Window window = SwingUtilities.getWindowAncestor(c);
+            return (window != null && window.isActive());
         }
 
-        public Insets getBorderInsets(Component c, Insets newInsets)
-        {
-            newInsets.set(5, 5, 5, 5);
-            return newInsets;
+        @Override
+        protected boolean isResizable(Component c) {
+            Window window = SwingUtilities.getWindowAncestor(c);
+            return ((window instanceof Frame)
+                    && ((Frame) window).isResizable());
         }
     }
 
@@ -389,48 +402,38 @@ public Insets getBorderInsets(Component c, Insets newInsets)
      * @since 1.4
      */
     @SuppressWarnings("serial") // Superclass is not serializable across versions
-    static class DialogBorder extends AbstractBorder implements UIResource
-    {
-        private static final int corner = 14;
+    static sealed class DialogBorder
+            extends AbstractMetalWindowBorder
+            implements UIResource
+            permits ErrorDialogBorder, QuestionDialogBorder, WarningDialogBorder {
 
-        protected Color getActiveBackground()
-        {
+        protected Color getActiveBackground() {
             return MetalLookAndFeel.getPrimaryControlDarkShadow();
         }
 
-        protected Color getActiveHighlight()
-        {
+        protected final Color getActiveHighlight() {
             return MetalLookAndFeel.getPrimaryControlShadow();
         }
 
-        protected Color getActiveShadow()
-        {
+        protected final Color getActiveShadow() {
             return MetalLookAndFeel.getPrimaryControlInfo();
         }
 
-        protected Color getInactiveBackground()
-        {
+        protected final Color getInactiveBackground() {
             return MetalLookAndFeel.getControlDarkShadow();
         }
 
-        protected Color getInactiveHighlight()
-        {
+        protected final Color getInactiveHighlight() {
             return MetalLookAndFeel.getControlShadow();
         }
 
-        protected Color getInactiveShadow()
-        {
+        protected final Color getInactiveShadow() {
             return MetalLookAndFeel.getControlInfo();
         }
 
-        public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
-        {
-            Color background;
-            Color highlight;
-            Color shadow;
-
-            Window window = SwingUtilities.getWindowAncestor(c);
-            if (window != null && window.isActive()) {
+        @Override
+        protected final void updateColors(Component c) {
+            if (isActive(c)) {
                 background = getActiveBackground();
                 highlight = getActiveHighlight();
                 shadow = getActiveShadow();
@@ -439,42 +442,19 @@ public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
                 highlight = getInactiveHighlight();
                 shadow = getInactiveShadow();
             }
+        }
 
-            g.setColor(background);
-            // Draw outermost lines
-            g.drawLine( x + 1, y + 0, x + w-2, y + 0);
-            g.drawLine( x + 0, y + 1, x + 0, y + h - 2);
-            g.drawLine( x + w - 1, y + 1, x + w - 1, y + h - 2);
-            g.drawLine( x + 1, y + h - 1, x + w - 2, y + h - 1);
-
-            // Draw the bulk of the border
-            for (int i = 1; i < 5; i++) {
-                g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
-            }
-
-
-            if ((window instanceof Dialog) && ((Dialog) window).isResizable()) {
-                g.setColor(highlight);
-                // Draw the Long highlight lines
-                g.drawLine( corner+1, 3, w-corner, 3);
-                g.drawLine( 3, corner+1, 3, h-corner);
-                g.drawLine( w-2, corner+1, w-2, h-corner);
-                g.drawLine( corner+1, h-2, w-corner, h-2);
-
-                g.setColor(shadow);
-                // Draw the Long shadow lines
-                g.drawLine( corner, 2, w-corner-1, 2);
-                g.drawLine( 2, corner, 2, h-corner-1);
-                g.drawLine( w-3, corner, w-3, h-corner-1);
-                g.drawLine( corner, h-3, w-corner-1, h-3);
-            }
-
+        @Override
+        protected final boolean isActive(Component c) {
+            Window window = SwingUtilities.getWindowAncestor(c);
+            return (window != null && window.isActive());
         }
 
-        public Insets getBorderInsets(Component c, Insets newInsets)
-        {
-            newInsets.set(5, 5, 5, 5);
-            return newInsets;
+        @Override
+        protected final boolean isResizable(Component c) {
+            Window window = SwingUtilities.getWindowAncestor(c);
+            return ((window instanceof Dialog)
+                    && ((Dialog) window).isResizable());
         }
     }
 
@@ -483,7 +463,7 @@ public Insets getBorderInsets(Component c, Insets newInsets)
      * @since 1.4
      */
     @SuppressWarnings("serial") // Superclass is not serializable across versions
-    static class ErrorDialogBorder extends DialogBorder implements UIResource
+    static final class ErrorDialogBorder extends DialogBorder implements UIResource
     {
         protected Color getActiveBackground() {
             return UIManager.getColor("OptionPane.errorDialog.border.background");
@@ -497,7 +477,7 @@ protected Color getActiveBackground() {
      * @since 1.4
      */
     @SuppressWarnings("serial") // Superclass is not serializable across versions
-    static class QuestionDialogBorder extends DialogBorder implements UIResource
+    static final class QuestionDialogBorder extends DialogBorder implements UIResource
     {
         protected Color getActiveBackground() {
             return UIManager.getColor("OptionPane.questionDialog.border.background");
@@ -510,7 +490,7 @@ protected Color getActiveBackground() {
      * @since 1.4
      */
     @SuppressWarnings("serial") // Superclass is not serializable across versions
-    static class WarningDialogBorder extends DialogBorder implements UIResource
+    static final class WarningDialogBorder extends DialogBorder implements UIResource
     {
         protected Color getActiveBackground() {
             return UIManager.getColor("OptionPane.warningDialog.border.background");
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
index 3fafcba2b59..9c36b63b7a3 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -272,6 +272,7 @@ protected void initClassDefaults(UIDefaults table)
               "FileChooserUI", metalPackageName + "MetalFileChooserUI",
             "InternalFrameUI", metalPackageName + "MetalInternalFrameUI",
                     "LabelUI", metalPackageName + "MetalLabelUI",
+                  "MenuBarUI", metalPackageName + "MetalMenuBarUI",
        "PopupMenuSeparatorUI", metalPackageName + "MetalPopupMenuSeparatorUI",
               "ProgressBarUI", metalPackageName + "MetalProgressBarUI",
               "RadioButtonUI", metalPackageName + "MetalRadioButtonUI",
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java
index 1dae0142c46..fd9c07d588b 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java
@@ -244,8 +244,6 @@ public Object createValue(UIDefaults table) {
 
             "List.focusCellHighlightBorder", focusBorder,
 
-            "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
-
             "OptionPane.errorIcon",
                    getIconResource("icons/ocean/error.png"),
             "OptionPane.informationIcon",
diff --git a/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java b/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java
index c96811202d7..b6825c3d0c9 100644
--- a/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java
+++ b/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1050,7 +1050,7 @@ public void setBlinkRate(int rate) {
             throw new IllegalArgumentException("Invalid blink rate: " + rate);
         }
         if (rate != 0) {
-            if (component.isEditable()) {
+            if (component != null && component.isEditable()) {
                 if (flasher == null) {
                     flasher = new Timer(rate, handler);
                 }
@@ -1065,7 +1065,7 @@ public void setBlinkRate(int rate) {
                 flasher.removeActionListener(handler);
                 flasher = null;
             }
-            if (component.isEditable() && isBlinkRateSaved) {
+            if ((component == null || component.isEditable()) && isBlinkRateSaved) {
                 savedBlinkRate = 0;
                 isBlinkRateSaved = false;
             }
diff --git a/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java b/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java
index bbe0eec8563..9e28875b5e4 100644
--- a/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java
+++ b/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,10 +32,12 @@
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 import java.awt.image.VolatileImage;
+
 import sun.awt.DisplayChangedListener;
 import sun.java2d.SunGraphicsEnvironment;
 import sun.java2d.SurfaceData;
-import static sun.java2d.pipe.hw.AccelSurface.*;
+
+import static sun.java2d.pipe.hw.AccelSurface.UNDEFINED;
 
 /**
  * This SurfaceManager variant manages an accelerated volatile surface, if it
@@ -307,6 +309,9 @@ public void initContents() {
      * primary SurfaceData object.
      */
     public SurfaceData restoreContents() {
+        // We're asked to restore contents by the accelerated surface, which
+        // means that it had been lost
+        acceleratedSurfaceLost();
         return getBackupSurface();
     }
 
diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java
index b0fe3878cc3..4aac1c248a6 100644
--- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java
+++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java
@@ -40,10 +40,14 @@
 import sun.awt.windows.WComponentPeer;
 import sun.java2d.InvalidPipeException;
 import sun.java2d.SurfaceData;
-import static sun.java2d.pipe.hw.AccelSurface.*;
-import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
 import sun.java2d.windows.GDIWindowSurfaceData;
 
+import static sun.java2d.d3d.D3DContext.D3DContextCaps.CAPS_RT_PLAIN_ALPHA;
+import static sun.java2d.d3d.D3DContext.D3DContextCaps.CAPS_RT_TEXTURE_ALPHA;
+import static sun.java2d.pipe.hw.AccelSurface.RT_TEXTURE;
+import static sun.java2d.pipe.hw.AccelSurface.TEXTURE;
+import static sun.java2d.pipe.hw.AccelSurface.UNDEFINED;
+
 public class D3DVolatileSurfaceManager
     extends VolatileSurfaceManager
 {
@@ -160,16 +164,6 @@ protected void restoreAcceleratedSurface() {
         }
     }
 
-    /**
-     * We're asked to restore contents by the accelerated surface, which means
-     * that it had been lost.
-     */
-    @Override
-    public SurfaceData restoreContents() {
-        acceleratedSurfaceLost();
-        return super.restoreContents();
-    }
-
     /**
      * If the destination surface's peer can potentially handle accelerated
      * on-screen rendering then it is likely that the condition which resulted
diff --git a/src/java.desktop/windows/native/libawt/java2d/d3d/D3DResourceManager.h b/src/java.desktop/windows/native/libawt/java2d/d3d/D3DResourceManager.h
index 8adaa655b63..25939897465 100644
--- a/src/java.desktop/windows/native/libawt/java2d/d3d/D3DResourceManager.h
+++ b/src/java.desktop/windows/native/libawt/java2d/d3d/D3DResourceManager.h
@@ -211,4 +211,4 @@ static
 
     IManagedResource* pHead;
 };
-#endif _D3DRESOURCEMANAGER_H_
+#endif // _D3DRESOURCEMANAGER_H_
diff --git a/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp b/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp
index 5b8a791d7ca..b37c3f4d393 100644
--- a/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp
+++ b/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp
@@ -259,8 +259,8 @@ HRESULT D3DVertexCacher::DrawLine(int x1, int y1, int x2, int y2)
         } else {
             // diagonal
             if (x1 > x2 && y1 > y2) {
-                // ^
-                //  \ case -> inverse
+                /* ^
+                    \ case -> inverse */
                 fx1 = (float)x2;
                 fy1 = (float)y2;
                 fx2 = (float)x1;
@@ -273,8 +273,8 @@ HRESULT D3DVertexCacher::DrawLine(int x1, int y1, int x2, int y2)
                 fx2 = (float)x1;
                 fy2 = (float)y1;
             } else {
-                // \      ^
-                //  v or /  - leave as is
+                /* \      ^
+                    v or /  - leave as is */
                 fx1 = (float)x1;
                 fy1 = (float)y1;
                 fx2 = (float)x2;
@@ -282,8 +282,8 @@ HRESULT D3DVertexCacher::DrawLine(int x1, int y1, int x2, int y2)
             }
 
             if (fx2 > fx1 && fy2 > fy1) {
-                // \
-                //  v
+                /* \
+                    v */
                 fx1 += DD_FX1;
                 fy1 += DD_FY1;
                 fx2 += DD_FX2;
diff --git a/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h b/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h
index a954874e9c8..2825d495e04 100644
--- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h
+++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h
@@ -256,4 +256,4 @@ GDIWindowSurfaceData_GetComp(JNIEnv *env, GDIWinSDOps *wsdo);
 } /* extern "C" */
 
 
-#endif _WIN32SURFACEDATA_H_
+#endif // _WIN32SURFACEDATA_H_
diff --git a/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h b/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h
index 1a3f0418a6f..85ba1657000 100644
--- a/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h
+++ b/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h
@@ -37,4 +37,4 @@ void SetD3DEnabledFlag(JNIEnv *env, BOOL d3dEnabled, BOOL d3dSet);
 BOOL IsD3DEnabled();
 BOOL IsD3DForced();
 
-#endif WINDOWSFLAGS_H
+#endif // WINDOWSFLAGS_H
diff --git a/src/java.desktop/windows/native/libawt/windows/Devices.h b/src/java.desktop/windows/native/libawt/windows/Devices.h
index 108ae7c963f..b6fd56a777f 100644
--- a/src/java.desktop/windows/native/libawt/windows/Devices.h
+++ b/src/java.desktop/windows/native/libawt/windows/Devices.h
@@ -74,4 +74,4 @@ static CriticalSection          arrayLock;
 
 BOOL WINAPI MonitorBounds (HMONITOR, RECT*);
 
-#endif _DEVICES_H_
+#endif // _DEVICES_H_
diff --git a/src/java.desktop/windows/native/libawt/windows/awt_CustomPaletteDef.h b/src/java.desktop/windows/native/libawt/windows/awt_CustomPaletteDef.h
index 17053dfca22..bc99e13ec1e 100644
--- a/src/java.desktop/windows/native/libawt/windows/awt_CustomPaletteDef.h
+++ b/src/java.desktop/windows/native/libawt/windows/awt_CustomPaletteDef.h
@@ -271,4 +271,4 @@ PALETTEENTRY AwtPalette::customPalette[] = {
     { 0xf8, 0xf8, 0xf8, PC_NOCOLLAPSE },
 };
 
-#endif _AWT_CUSTOMPALETTEDEF_H
+#endif // _AWT_CUSTOMPALETTEDEF_H
diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Palette.h b/src/java.desktop/windows/native/libawt/windows/awt_Palette.h
index 9dee84dcb42..b156f784a84 100644
--- a/src/java.desktop/windows/native/libawt/windows/awt_Palette.h
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Palette.h
@@ -101,4 +101,4 @@ class AwtPalette {
 
 
 
-#endif AWT_PALETTE_H
+#endif // AWT_PALETTE_H
diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp
index 10ef983aaa6..316a5834bd7 100644
--- a/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp
@@ -266,7 +266,7 @@ extern "C" BOOL APIENTRY DllMain(HANDLE hInstance, DWORD ul_reason_for_call,
 #ifdef DEBUG
         DTrace_DisableMutex();
         DMem_DisableMutex();
-#endif DEBUG
+#endif // DEBUG
         break;
     }
     return TRUE;
@@ -628,7 +628,7 @@ BOOL AwtToolkit::Initialize(BOOL localPump) {
     // Set up operator new/malloc out of memory handler.
     NewHandler::init();
 
-        //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+        //*************************************************************************
         // Bugs 4032109, 4047966, and 4071991 to fix AWT
         //      crash in 16 color display mode.  16 color mode is supported.  Less
         //      than 16 color is not.
diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.h b/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.h
index f298aad68da..91d5bda76da 100644
--- a/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.h
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.h
@@ -129,4 +129,4 @@ class AwtWin32GraphicsDevice {
     static int              ClipRound(double value);
 };
 
-#endif AWT_WIN32GRAPHICSDEVICE_H
+#endif // AWT_WIN32GRAPHICSDEVICE_H
diff --git a/src/java.management/share/native/libmanagement/VMManagementImpl.c b/src/java.management/share/native/libmanagement/VMManagementImpl.c
index 38a5b6af0cc..46f3b03b18e 100644
--- a/src/java.management/share/native/libmanagement/VMManagementImpl.c
+++ b/src/java.management/share/native/libmanagement/VMManagementImpl.c
@@ -44,7 +44,7 @@ Java_sun_management_VMManagementImpl_getVersion0
     // for internal use
     unsigned int micro = (unsigned int) jmm_version & 0xFF;
 
-    sprintf(buf, "%d.%d", major, minor);
+    snprintf(buf, sizeof(buf), "%d.%d", major, minor);
     version_string = (*env)->NewStringUTF(env, buf);
     return version_string;
 }
diff --git a/src/java.management/share/native/libmanagement/management.c b/src/java.management/share/native/libmanagement/management.c
index 281e3d0ffac..4553a02c086 100644
--- a/src/java.management/share/native/libmanagement/management.c
+++ b/src/java.management/share/native/libmanagement/management.c
@@ -57,6 +57,6 @@ JNIEXPORT jint JNICALL
 void throw_internal_error(JNIEnv* env, const char* msg) {
     char errmsg[128];
 
-    sprintf(errmsg, "errno: %d error: %s\n", errno, msg);
+    snprintf(errmsg, sizeof(errmsg), "errno: %d error: %s\n", errno, msg);
     JNU_ThrowInternalError(env, errmsg);
 }
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java b/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java
index c787959b069..dc659d5f971 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -137,6 +137,7 @@ class Stream<T> extends ExchangeImpl<T> {
     private volatile boolean remotelyClosed;
     private volatile boolean closed;
     private volatile boolean endStreamSent;
+    private volatile boolean finalResponseCodeReceived;
     // Indicates the first reason that was invoked when sending a ResetFrame
     // to the server. A streamState of 0 indicates that no reset was sent.
     // (see markStream(int code)
@@ -504,30 +505,44 @@ DecodingCallback rspHeadersConsumer() {
 
     protected void handleResponse() throws IOException {
         HttpHeaders responseHeaders = responseHeadersBuilder.build();
-        responseCode = (int)responseHeaders
-                .firstValueAsLong(":status")
-                .orElseThrow(() -> new IOException("no statuscode in response"));
 
-        response = new Response(
-                request, exchange, responseHeaders, connection(),
-                responseCode, HttpClient.Version.HTTP_2);
+        if (!finalResponseCodeReceived) {
+            responseCode = (int) responseHeaders
+                    .firstValueAsLong(":status")
+                    .orElseThrow(() -> new IOException("no statuscode in response"));
+            // If informational code, response is partially complete
+            if (responseCode < 100 || responseCode > 199)
+                this.finalResponseCodeReceived = true;
+
+            response = new Response(
+                    request, exchange, responseHeaders, connection(),
+                    responseCode, HttpClient.Version.HTTP_2);
 
         /* TODO: review if needs to be removed
            the value is not used, but in case `content-length` doesn't parse as
            long, there will be NumberFormatException. If left as is, make sure
            code up the stack handles NFE correctly. */
-        responseHeaders.firstValueAsLong("content-length");
+            responseHeaders.firstValueAsLong("content-length");
 
-        if (Log.headers()) {
-            StringBuilder sb = new StringBuilder("RESPONSE HEADERS:\n");
-            Log.dumpHeaders(sb, "    ", responseHeaders);
-            Log.logHeaders(sb.toString());
-        }
+            if (Log.headers()) {
+                StringBuilder sb = new StringBuilder("RESPONSE HEADERS:\n");
+                Log.dumpHeaders(sb, "    ", responseHeaders);
+                Log.logHeaders(sb.toString());
+            }
+
+            // this will clear the response headers
+            rspHeadersConsumer.reset();
 
-        // this will clear the response headers
-        rspHeadersConsumer.reset();
+            completeResponse(response);
+        } else {
+            if (Log.headers()) {
+                StringBuilder sb = new StringBuilder("TRAILING HEADERS:\n");
+                Log.dumpHeaders(sb, "    ", responseHeaders);
+                Log.logHeaders(sb.toString());
+            }
+            rspHeadersConsumer.reset();
+        }
 
-        completeResponse(response);
     }
 
     void incoming_reset(ResetFrame frame) {
@@ -1376,6 +1391,7 @@ static class PushedStream<T> extends Stream<T> {
         CompletableFuture<HttpResponse<T>> responseCF;
         final HttpRequestImpl pushReq;
         HttpResponse.BodyHandler<T> pushHandler;
+        private volatile boolean finalPushResponseCodeReceived;
 
         PushedStream(PushGroup<T> pushGroup,
                      Http2Connection connection,
@@ -1472,35 +1488,48 @@ void completeResponseExceptionally(Throwable t) {
         @Override
         protected void handleResponse() {
             HttpHeaders responseHeaders = responseHeadersBuilder.build();
-            responseCode = (int)responseHeaders
-                .firstValueAsLong(":status")
-                .orElse(-1);
 
-            if (responseCode == -1) {
-                completeResponseExceptionally(new IOException("No status code"));
-            }
+            if (!finalPushResponseCodeReceived) {
+                responseCode = (int)responseHeaders
+                    .firstValueAsLong(":status")
+                    .orElse(-1);
 
-            this.response = new Response(
-                pushReq, exchange, responseHeaders, connection(),
-                responseCode, HttpClient.Version.HTTP_2);
+                if (responseCode == -1) {
+                    completeResponseExceptionally(new IOException("No status code"));
+                }
 
-            /* TODO: review if needs to be removed
-               the value is not used, but in case `content-length` doesn't parse
-               as long, there will be NumberFormatException. If left as is, make
-               sure code up the stack handles NFE correctly. */
-            responseHeaders.firstValueAsLong("content-length");
+                this.finalPushResponseCodeReceived = true;
 
-            if (Log.headers()) {
-                StringBuilder sb = new StringBuilder("RESPONSE HEADERS");
-                sb.append(" (streamid=").append(streamid).append("):\n");
-                Log.dumpHeaders(sb, "    ", responseHeaders);
-                Log.logHeaders(sb.toString());
-            }
+                this.response = new Response(
+                        pushReq, exchange, responseHeaders, connection(),
+                        responseCode, HttpClient.Version.HTTP_2);
 
-            rspHeadersConsumer.reset();
+                /* TODO: review if needs to be removed
+                   the value is not used, but in case `content-length` doesn't parse
+                   as long, there will be NumberFormatException. If left as is, make
+                   sure code up the stack handles NFE correctly. */
+                responseHeaders.firstValueAsLong("content-length");
 
-            // different implementations for normal streams and pushed streams
-            completeResponse(response);
+                if (Log.headers()) {
+                    StringBuilder sb = new StringBuilder("RESPONSE HEADERS");
+                    sb.append(" (streamid=").append(streamid).append("):\n");
+                    Log.dumpHeaders(sb, "    ", responseHeaders);
+                    Log.logHeaders(sb.toString());
+                }
+
+                rspHeadersConsumer.reset();
+
+                // different implementations for normal streams and pushed streams
+                completeResponse(response);
+            } else {
+                if (Log.headers()) {
+                    StringBuilder sb = new StringBuilder("TRAILING HEADERS");
+                    sb.append(" (streamid=").append(streamid).append("):\n");
+                    Log.dumpHeaders(sb, "    ", responseHeaders);
+                    Log.logHeaders(sb.toString());
+                }
+                rspHeadersConsumer.reset();
+            }
         }
     }
 
diff --git a/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp b/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp
index 4659b437768..52d2af92507 100644
--- a/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp
+++ b/src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp
@@ -23,12 +23,14 @@
  * questions.
  */
 
-// This library is client-side only, and only supports the default credentials.
-// It speaks krb5 and SPNEGO. NTLM is excluded from SPNEGO negotiation.
-//
-// This library can be built directly with the following command:
-//   cl -I %OPENJDK%\src\java.security.jgss\share\native\libj2gss\ sspi.cpp \
-//      -link -dll -out:sspi_bridge.dll
+/*
+ * This library is client-side only, and only supports the default credentials.
+ * It speaks krb5 and SPNEGO. NTLM is excluded from SPNEGO negotiation.
+ *
+ * This library can be built directly with the following command:
+ *   cl -I %OPENJDK%\src\java.security.jgss\share\native\libj2gss\ sspi.cpp \
+ *      -link -dll -out:sspi_bridge.dll
+ */
 
 #define UNICODE
 #define _UNICODE
diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java
index bbe94ec334f..8e63305d177 100644
--- a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java
+++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,6 +58,12 @@
  * method). When enabled, validation of XML signatures are subject to
  * stricter checking of algorithms and other constraints as specified by the
  * <code>jdk.xml.dsig.secureValidationPolicy</code> security property.
+ * The mode can be disabled by setting the property to {@code Boolean.FALSE}.
+ * The mode can also be enabled or disabled by setting the
+ * {@systemProperty org.jcp.xml.dsig.secureValidation} system property to
+ * "true" or "false". Any other value for the system property is also treated
+ * as "false". If the system property is set, it supersedes the
+ * {@code DOMValidateContext} property value.
  *
  * @author Sean Mullan
  * @author JSR 105 Expert Group
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
index bcf28d0afe2..0e2a832e145 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
@@ -21,13 +21,15 @@
  * under the License.
  */
 /*
- * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 package org.jcp.xml.dsig.internal.dom;
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.*;
 import javax.xml.crypto.XMLCryptoContext;
 import org.w3c.dom.NamedNodeMap;
@@ -39,6 +41,21 @@
  */
 public final class Utils {
 
+    private static final com.sun.org.slf4j.internal.Logger LOG =
+        com.sun.org.slf4j.internal.LoggerFactory.getLogger(Utils.class);
+    private static final String SECVAL_PROP_NAME =
+        "org.jcp.xml.dsig.secureValidation";
+    private static final boolean SECVAL_SYSPROP_SET;
+    private static final boolean SECVAL_SYSPROP;
+    static {
+        String sysProp = privilegedGetProperty(SECVAL_PROP_NAME);
+        SECVAL_SYSPROP_SET = sysProp != null;
+        SECVAL_SYSPROP = Boolean.parseBoolean(sysProp);
+        if (SECVAL_SYSPROP_SET && !SECVAL_SYSPROP) {
+            LOG.warn("Secure validation mode disabled");
+        }
+    }
+
     private Utils() {}
 
     public static byte[] readBytesFromStream(InputStream is)
@@ -108,11 +125,25 @@ public static boolean sameDocumentURI(String uri) {
         return uri != null && (uri.length() == 0 || uri.charAt(0) == '#');
     }
 
+    @SuppressWarnings("removal")
+    private static String privilegedGetProperty(String theProp) {
+        if (System.getSecurityManager() == null) {
+            return System.getProperty(theProp);
+        } else {
+            return AccessController.doPrivileged(
+                 (PrivilegedAction<String>) () -> System.getProperty(theProp));
+        }
+    }
+
     static boolean secureValidation(XMLCryptoContext xc) {
+        // If set, system property supersedes XMLCryptoContext property
+        if (SECVAL_SYSPROP_SET) {
+            return SECVAL_SYSPROP;
+        }
         if (xc == null) {
             return false;
         }
-        return getBoolean(xc, "org.jcp.xml.dsig.secureValidation");
+        return getBoolean(xc, SECVAL_PROP_NAME);
     }
 
     private static boolean getBoolean(XMLCryptoContext xc, String name) {
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java
index a4c7a51a2a6..bca72ab3f95 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Const.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,2416 +26,3218 @@
  * Constants for the project, mostly defined in the JVM specification.
  *
  * @since 6.0 (intended to replace the Constants interface)
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public final class Const {
 
-  /**
-   * Java class file format Magic number (0xCAFEBABE)
-   *
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1-200-A">
-   * The ClassFile Structure in The Java Virtual Machine Specification</a>
-   */
-  public static final int JVM_CLASSFILE_MAGIC = 0xCAFEBABE;
-
-  /** Major version number of class files for Java 1.1.
-   *  @see #MINOR_1_1
-   *  */
-  public static final short MAJOR_1_1 = 45;
-
-  /** Minor version number of class files for Java 1.1.
-   *  @see #MAJOR_1_1
-   *  */
-  public static final short MINOR_1_1 = 3;
-
-  /** Major version number of class files for Java 1.2.
-   *  @see #MINOR_1_2
-   *  */
-  public static final short MAJOR_1_2 = 46;
-
-  /** Minor version number of class files for Java 1.2.
-   *  @see #MAJOR_1_2
-   *  */
-  public static final short MINOR_1_2 = 0;
-
-  /** Major version number of class files for Java 1.2.
-   *  @see #MINOR_1_2
-   *  */
-  public static final short MAJOR_1_3 = 47;
-
-  /** Minor version number of class files for Java 1.3.
-   *  @see #MAJOR_1_3
-   *  */
-  public static final short MINOR_1_3 = 0;
-
-  /** Major version number of class files for Java 1.3.
-   *  @see #MINOR_1_3
-   *  */
-  public static final short MAJOR_1_4 = 48;
-
-  /** Minor version number of class files for Java 1.4.
-   *  @see #MAJOR_1_4
-   *  */
-  public static final short MINOR_1_4 = 0;
-
-  /** Major version number of class files for Java 1.4.
-   *  @see #MINOR_1_4
-   *  */
-  public static final short MAJOR_1_5 = 49;
-
-  /** Minor version number of class files for Java 1.5.
-   *  @see #MAJOR_1_5
-   *  */
-  public static final short MINOR_1_5 = 0;
-
-  /** Major version number of class files for Java 1.6.
-   *  @see #MINOR_1_6
-   *  */
-  public static final short MAJOR_1_6 = 50;
-
-  /** Minor version number of class files for Java 1.6.
-   *  @see #MAJOR_1_6
-   *  */
-  public static final short MINOR_1_6 = 0;
-
-  /** Major version number of class files for Java 1.7.
-   *  @see #MINOR_1_7
-   *  */
-  public static final short MAJOR_1_7 = 51;
-
-  /** Minor version number of class files for Java 1.7.
-   *  @see #MAJOR_1_7
-   *  */
-  public static final short MINOR_1_7 = 0;
-
-  /** Major version number of class files for Java 1.8.
-   *  @see #MINOR_1_8
-   *  */
-  public static final short MAJOR_1_8 = 52;
-
-  /** Minor version number of class files for Java 1.8.
-   *  @see #MAJOR_1_8
-   *  */
-  public static final short MINOR_1_8 = 0;
-
-  /** Major version number of class files for Java 9.
-   *  @see #MINOR_9
-   *  */
-  public static final short MAJOR_9 = 53;
-
-  /** Minor version number of class files for Java 9.
-   *  @see #MAJOR_9
-   *  */
-  public static final short MINOR_9 = 0;
-
-  /**
-   * @deprecated Use {@link #MAJOR_9} instead
-   */
-  @Deprecated
-  public static final short MAJOR_1_9 = MAJOR_9;
-
-  /**
-   * @deprecated Use {@link #MINOR_9} instead
-   */
-  @Deprecated
-  public static final short MINOR_1_9 = MINOR_9;
-
-  /** Major version number of class files for Java 10.
-   *  @see #MINOR_10
-   *  */
-  public static final short MAJOR_10 = 54;
-
-  /** Minor version number of class files for Java 10.
-   *  @see #MAJOR_10
-   *  */
-  public static final short MINOR_10 = 0;
-
-  /** Major version number of class files for Java 11.
-   *  @see #MINOR_11
-   *  */
-  public static final short MAJOR_11 = 55;
-
-  /** Minor version number of class files for Java 11.
-   *  @see #MAJOR_11
-   *  */
-  public static final short MINOR_11 = 0;
-
-  /** Major version number of class files for Java 12.
-   *  @see #MINOR_12
-   *  */
-  public static final short MAJOR_12 = 56;
-
-  /** Minor version number of class files for Java 12.
-   *  @see #MAJOR_12
-   *  */
-  public static final short MINOR_12 = 0;
-
-  /** Major version number of class files for Java 13.
-   *  @see #MINOR_13
-   *  */
-  public static final short MAJOR_13 = 57;
-
-  /** Minor version number of class files for Java 13.
-   *  @see #MAJOR_13
-   *  */
-  public static final short MINOR_13 = 0;
-
-  /** Major version number of class files for Java 14.
-   *  @see #MINOR_14
-   *  @since 6.4.0
-   *  */
-  public static final short MAJOR_14 = 58;
-
-  /** Minor version number of class files for Java 14.
-   *  @see #MAJOR_14
-   *  @since 6.4.0
-   *  */
-  public static final short MINOR_14 = 0;
-
-  /** Default major version number.  Class file is for Java 1.1.
-   *  @see #MAJOR_1_1
-   *  */
-  public static final short MAJOR = MAJOR_1_1;
-
-  /** Default major version number.  Class file is for Java 1.1.
-   *  @see #MAJOR_1_1
-   *  */
-  public static final short MINOR     = MINOR_1_1;
-
-  /** Maximum value for an unsigned short.
-   */
-  public static final int MAX_SHORT = 65535; // 2^16 - 1
-
-  /** Maximum value for an unsigned byte.
-   */
-  public static final int MAX_BYTE  = 255; // 2^8 - 1
-
-  /** One of the access flags for fields, methods, or classes.
-   *
-   *  @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1-200-E.1">
-   *  Flag definitions for Classes in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
-   *  @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.5">
-   *  Flag definitions for Fields in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
-   *  @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.6">
-   *  Flag definitions for Methods in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
-   *  @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.6-300-D.1-D.1">
-   *  Flag definitions for Inner Classes in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
-   */
-  public static final short ACC_PUBLIC       = 0x0001;
-
-  /** One of the access flags for fields, methods, or classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_PRIVATE      = 0x0002;
-
-  /** One of the access flags for fields, methods, or classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_PROTECTED    = 0x0004;
-
-  /** One of the access flags for fields, methods, or classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_STATIC       = 0x0008;
-
-  /** One of the access flags for fields, methods, or classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_FINAL        = 0x0010;
-
-  /** One of the access flags for the Module attribute.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_OPEN         = 0x0020;
-
-  /** One of the access flags for classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_SUPER        = 0x0020;
-
-  /** One of the access flags for methods.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_SYNCHRONIZED = 0x0020;
-
-  /** One of the access flags for the Module attribute.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_TRANSITIVE   = 0x0020;
-
-  /** One of the access flags for methods.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_BRIDGE       = 0x0040;
-
-  /** One of the access flags for the Module attribute.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_STATIC_PHASE = 0x0040;
-
-  /** One of the access flags for fields.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_VOLATILE     = 0x0040;
-
-  /** One of the access flags for fields.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_TRANSIENT    = 0x0080;
-
-  /** One of the access flags for methods.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_VARARGS      = 0x0080;
-
-  /** One of the access flags for methods.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_NATIVE       = 0x0100;
-
-  /** One of the access flags for classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_INTERFACE    = 0x0200;
-
-  /** One of the access flags for methods or classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_ABSTRACT     = 0x0400;
-
-  /** One of the access flags for methods.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_STRICT       = 0x0800;
-
-  /** One of the access flags for fields, methods, classes, MethodParameter attribute, or Module attribute.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_SYNTHETIC    = 0x1000;
-
-  /** One of the access flags for classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_ANNOTATION   = 0x2000;
-
-  /** One of the access flags for fields or classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_ENUM         = 0x4000;
-
-  // Applies to classes compiled by new compilers only
-  /** One of the access flags for MethodParameter or Module attributes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_MANDATED     = (short) 0x8000;
-
-  /** One of the access flags for classes.
-   *  @see #ACC_PUBLIC
-   */
-  public static final short ACC_MODULE       = (short) 0x8000;
-
-  /** One of the access flags for fields, methods, or classes.
-   *  @see #ACC_PUBLIC
-   *  @deprecated Use {@link #MAX_ACC_FLAG_I}
-   */
-  @Deprecated
-  public static final short MAX_ACC_FLAG     = ACC_ENUM;
-
-  /** One of the access flags for fields, methods, or classes.
-   * ACC_MODULE is negative as a short.
-   * @see #ACC_PUBLIC
-   * @since 6.4.0
-   */
-  public static final int MAX_ACC_FLAG_I = 0x8000; // ACC_MODULE is negative as a short
-
-  // Note that do to overloading:
-  // 'synchronized' is for methods, might be 'open' (if Module), 'super' (if class), or 'transitive' (if Module).
-  // 'volatile'     is for fields,  might be 'bridge' (if method) or 'static_phase' (if Module)
-  // 'transient'    is for fields,  might be 'varargs' (if method)
-  // 'module'       is for classes, might be 'mandated' (if Module or MethodParameters)
-  /**
-   * The names of the access flags.
-   */
-  private static final String[] ACCESS_NAMES = {
-    "public", "private", "protected", "static", "final", "synchronized",
-    "volatile", "transient", "native", "interface", "abstract", "strictfp",
-    "synthetic", "annotation", "enum", "module"
-  };
-
-  /** @since 6.0 */
-  public static final int ACCESS_NAMES_LENGTH = ACCESS_NAMES.length;
-
-  /**
-   * @param index
-   * @return the ACCESS_NAMES entry at the given index
-   * @since 6.0
-   */
-  public static String getAccessName(final int index) {
-      return ACCESS_NAMES[index];
-  }
-
-  /*
-   * The description of the constant pool is at:
-   * http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4
-   * References below are to the individual sections
-   */
-
-  /**
-   * Marks a constant pool entry as type UTF-8.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.7">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_Utf8               = 1;
-
-  /**
-   * Marks a constant pool entry as type Integer.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_Integer            = 3;
-
-  /**
-   * Marks a constant pool entry as type Float.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_Float              = 4;
-
-  /**
-   * Marks a constant pool entry as type Long.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_Long               = 5;
-
-  /**
-   * Marks a constant pool entry as type Double.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_Double             = 6;
-
-  /**
-   * Marks a constant pool entry as a Class
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.1">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_Class              = 7;
-
-  /**
-   * Marks a constant pool entry as a Field Reference.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_Fieldref           = 9;
-
-  /**
-   * Marks a constant pool entry as type String
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.3">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_String             = 8;
-
-  /** Marks a constant pool entry as a Method Reference.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2">
-   * The Constant Pool in The Java Virtual Machine Specification</a> */
-  public static final byte CONSTANT_Methodref          = 10;
-
-  /**
-   * Marks a constant pool entry as an Interface Method Reference.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_InterfaceMethodref = 11;
-
-  /** Marks a constant pool entry as a name and type.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.6">
-   * The Constant Pool in The Java Virtual Machine Specification</a> */
-  public static final byte CONSTANT_NameAndType        = 12;
-
-  /**
-   * Marks a constant pool entry as a Method Handle.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.8">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_MethodHandle       = 15;
-
-  /**
-   * Marks a constant pool entry as a Method Type.
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.9">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_MethodType         = 16;
-
-  /**
-   * Marks a constant pool entry as dynamically computed.
-   * @see  <a href="https://bugs.openjdk.org/secure/attachment/74618/constant-dynamic.html">
-   * Change request for JEP 309</a>
-   * @since 6.3
-   */
-  public static final byte CONSTANT_Dynamic            = 17;
-
-  /**
-   * Marks a constant pool entry as an Invoke Dynamic
-   * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.10">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   */
-  public static final byte CONSTANT_InvokeDynamic      = 18;
-
-  /**
-   * Marks a constant pool entry as a Module Reference.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.11">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   * @since 6.1
-   */
-  public static final byte CONSTANT_Module             = 19;
-
-  /**
-   * Marks a constant pool entry as a Package Reference.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.12">
-   * The Constant Pool in The Java Virtual Machine Specification</a>
-   * @since 6.1
-   */
-  public static final byte CONSTANT_Package            = 20;
-
-  /**
-   * The names of the types of entries in a constant pool.
-   * Use getConstantName instead
-   */
-  private static final String[] CONSTANT_NAMES = {
-    "", "CONSTANT_Utf8", "", "CONSTANT_Integer",
-    "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double",
-    "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref",
-    "CONSTANT_Methodref", "CONSTANT_InterfaceMethodref",
-    "CONSTANT_NameAndType", "", "", "CONSTANT_MethodHandle",
-    "CONSTANT_MethodType", "CONSTANT_Dynamic", "CONSTANT_InvokeDynamic",
-    "CONSTANT_Module", "CONSTANT_Package"};
-
-  /**
-   *
-   * @param index
-   * @return the CONSTANT_NAMES entry at the given index
-   * @since 6.0
-   */
-  public static String getConstantName(final int index) {
-      return CONSTANT_NAMES[index];
-  }
-
-  /** The name of the static initializer, also called &quot;class
-   *  initialization method&quot; or &quot;interface initialization
-   *   method&quot;. This is &quot;&lt;clinit&gt;&quot;.
-   */
-  public static final String STATIC_INITIALIZER_NAME = "<clinit>";
-
-  /** The name of every constructor method in a class, also called
-   * &quot;instance initialization method&quot;. This is &quot;&lt;init&gt;&quot;.
-   */
-  public static final String CONSTRUCTOR_NAME = "<init>";
-
-  /**
-   * The names of the interfaces implemented by arrays
-   */
-  private static final String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"};
-
-  /**
-   * @since 6.0
-   */
-  public static Iterable<String> getInterfacesImplementedByArrays() {
-      return Collections.unmodifiableList(Arrays.asList(INTERFACES_IMPLEMENTED_BY_ARRAYS));
-  }
-
-  /**
-   * Maximum Constant Pool entries.
-   * One of the limitations of the Java Virtual Machine.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.11-100-A">
-   * The Java Virtual Machine Specification, Java SE 8 Edition, page 330, chapter 4.11.</a>
-   */
-  public static final int MAX_CP_ENTRIES     = 65535;
-
-  /**
-   * Maximum code size (plus one; the code size must be LESS than this)
-   * One of the limitations of the Java Virtual Machine.
-   * Note vmspec2 page 152 ("Limitations") says:
-   * "The amount of code per non-native, non-abstract method is limited to 65536 bytes by
-   * the sizes of the indices in the exception_table of the Code attribute (4.7.3),
-   * in the LineNumberTable attribute (4.7.8), and in the LocalVariableTable attribute (4.7.9)."
-   * However this should be taken as an upper limit rather than the defined maximum.
-   * On page 134 (4.8.1 Static Constants) of the same spec, it says:
-   * "The value of the code_length item must be less than 65536."
-   * The entry in the Limitations section has been removed from later versions of the spec;
-   * it is not present in the Java SE 8 edition.
-   *
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3-300-E">
-   * The Java Virtual Machine Specification, Java SE 8 Edition, page 104, chapter 4.7.</a>
-   */
-  public static final int MAX_CODE_SIZE      = 65536; //bytes
-
-  /**
-   * The maximum number of dimensions in an array ({@value}).
-   * One of the limitations of the Java Virtual Machine.
-   *
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.3.2-150">
-   * Field Descriptors in The Java Virtual Machine Specification</a>
-   */
-  public static final int MAX_ARRAY_DIMENSIONS = 255;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.nop">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short NOP              = 0;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aconst_null">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ACONST_NULL      = 1;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ICONST_M1        = 2;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ICONST_0         = 3;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ICONST_1         = 4;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ICONST_2         = 5;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ICONST_3         = 6;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ICONST_4         = 7;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ICONST_5         = 8;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lconst_l">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LCONST_0         = 9;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lconst_l">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LCONST_1         = 10;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fconst_f">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FCONST_0         = 11;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fconst_f">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FCONST_1         = 12;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fconst_f">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FCONST_2         = 13;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dconst_d">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DCONST_0         = 14;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dconst_d">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DCONST_1         = 15;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.bipush">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short BIPUSH           = 16;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.sipush">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short SIPUSH           = 17;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldc">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LDC              = 18;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldc_w">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LDC_W            = 19;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldc2_w">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LDC2_W           = 20;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ILOAD            = 21;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LLOAD            = 22;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FLOAD            = 23;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DLOAD            = 24;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ALOAD            = 25;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ILOAD_0          = 26;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ILOAD_1          = 27;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ILOAD_2          = 28;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ILOAD_3          = 29;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LLOAD_0          = 30;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LLOAD_1          = 31;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LLOAD_2          = 32;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LLOAD_3          = 33;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FLOAD_0          = 34;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FLOAD_1          = 35;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FLOAD_2          = 36;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FLOAD_3          = 37;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DLOAD_0          = 38;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DLOAD_1          = 39;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DLOAD_2          = 40;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DLOAD_3          = 41;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ALOAD_0          = 42;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ALOAD_1          = 43;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ALOAD_2          = 44;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ALOAD_3          = 45;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iaload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IALOAD           = 46;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.laload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LALOAD           = 47;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.faload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FALOAD           = 48;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.daload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DALOAD           = 49;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aaload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short AALOAD           = 50;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.baload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short BALOAD           = 51;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.caload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short CALOAD           = 52;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.saload">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short SALOAD           = 53;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISTORE           = 54;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSTORE           = 55;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FSTORE           = 56;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DSTORE           = 57;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ASTORE           = 58;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISTORE_0         = 59;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISTORE_1         = 60;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISTORE_2         = 61;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISTORE_3         = 62;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSTORE_0         = 63;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSTORE_1         = 64;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSTORE_2         = 65;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSTORE_3         = 66;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FSTORE_0         = 67;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FSTORE_1         = 68;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FSTORE_2         = 69;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FSTORE_3         = 70;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DSTORE_0         = 71;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DSTORE_1         = 72;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DSTORE_2         = 73;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DSTORE_3         = 74;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ASTORE_0         = 75;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ASTORE_1         = 76;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ASTORE_2         = 77;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ASTORE_3         = 78;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iastore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IASTORE          = 79;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lastore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LASTORE          = 80;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fastore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FASTORE          = 81;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dastore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DASTORE          = 82;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aastore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short AASTORE          = 83;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.bastore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short BASTORE          = 84;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.castore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short CASTORE          = 85;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.sastore">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short SASTORE          = 86;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.pop">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short POP              = 87;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.pop2">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short POP2             = 88;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DUP              = 89;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup_x1">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DUP_X1           = 90;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup_x2">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DUP_X2           = 91;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup2">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DUP2             = 92;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup2_x1">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DUP2_X1          = 93;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup2_x2">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DUP2_X2          = 94;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.swap">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short SWAP             = 95;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iadd">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IADD             = 96;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ladd">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LADD             = 97;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fadd">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FADD             = 98;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dadd">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DADD             = 99;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.isub">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISUB             = 100;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lsub">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSUB             = 101;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fsub">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FSUB             = 102;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dsub">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DSUB             = 103;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.imul">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IMUL             = 104;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lmul">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LMUL             = 105;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fmul">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FMUL             = 106;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dmul">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DMUL             = 107;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.idiv">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IDIV             = 108;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldiv">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LDIV             = 109;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fdiv">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FDIV             = 110;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ddiv">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DDIV             = 111;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.irem">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IREM             = 112;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lrem">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LREM             = 113;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.frem">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FREM             = 114;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.drem">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DREM             = 115;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ineg">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INEG             = 116;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lneg">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LNEG             = 117;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fneg">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FNEG             = 118;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dneg">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DNEG             = 119;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ishl">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISHL             = 120;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lshl">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSHL             = 121;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ishr">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ISHR             = 122;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lshr">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LSHR             = 123;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iushr">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IUSHR            = 124;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lushr">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LUSHR            = 125;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iand">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IAND             = 126;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.land">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LAND             = 127;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ior">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IOR              = 128;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lor">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LOR              = 129;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ixor">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IXOR             = 130;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lxor">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LXOR             = 131;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iinc">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IINC             = 132;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2l">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short I2L              = 133;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2f">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short I2F              = 134;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2d">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short I2D              = 135;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.l2i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short L2I              = 136;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.l2f">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short L2F              = 137;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.l2d">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short L2D              = 138;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.f2i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short F2I              = 139;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.f2l">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short F2L              = 140;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.f2d">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short F2D              = 141;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.d2i">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short D2I              = 142;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.d2l">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short D2L              = 143;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.d2f">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short D2F              = 144;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2b">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short I2B              = 145;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INT2BYTE         = 145; // Old notation
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2c">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short I2C              = 146;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INT2CHAR         = 146; // Old notation
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2s">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short I2S              = 147;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INT2SHORT        = 147; // Old notation
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lcmp">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LCMP             = 148;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fcmpl">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FCMPL            = 149;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fcmpg">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FCMPG            = 150;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dcmpl">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DCMPL            = 151;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dcmpg">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DCMPG            = 152;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifeq">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFEQ             = 153;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifne">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFNE             = 154;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iflt">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFLT             = 155;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifge">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFGE             = 156;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifgt">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFGT             = 157;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifle">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFLE             = 158;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ICMPEQ        = 159;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ICMPNE        = 160;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ICMPLT        = 161;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ICMPGE        = 162;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ICMPGT        = 163;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ICMPLE        = 164;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_acmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ACMPEQ        = 165;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_acmp_cond">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IF_ACMPNE        = 166;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.goto">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short GOTO             = 167;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.jsr">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short JSR              = 168;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ret">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short RET              = 169;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.tableswitch">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short TABLESWITCH      = 170;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lookupswitch">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LOOKUPSWITCH     = 171;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ireturn">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IRETURN          = 172;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lreturn">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short LRETURN          = 173;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.freturn">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short FRETURN          = 174;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dreturn">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short DRETURN          = 175;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.areturn">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ARETURN          = 176;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.return">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short RETURN           = 177;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.getstatic">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short GETSTATIC        = 178;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.putstatic">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short PUTSTATIC        = 179;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.getfield">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short GETFIELD         = 180;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.putfield">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short PUTFIELD         = 181;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokevirtual">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INVOKEVIRTUAL    = 182;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokespecial">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INVOKESPECIAL    = 183;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokestatic">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INVOKESTATIC     = 184;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokeinterface">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INVOKEINTERFACE  = 185;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokedynamic">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INVOKEDYNAMIC    = 186;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.new">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short NEW              = 187;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.newarray">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short NEWARRAY         = 188;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.anewarray">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ANEWARRAY        = 189;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.arraylength">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ARRAYLENGTH      = 190;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.athrow">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short ATHROW           = 191;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.checkcast">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short CHECKCAST        = 192;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.instanceof">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short INSTANCEOF       = 193;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.monitorenter">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short MONITORENTER     = 194;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.monitorexit">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short MONITOREXIT      = 195;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.wide">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short WIDE             = 196;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.multianewarray">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short MULTIANEWARRAY   = 197;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifnull">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFNULL           = 198;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifnonnull">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short IFNONNULL        = 199;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.goto_w">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short GOTO_W           = 200;
-
-  /** Java VM opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.jsr_w">
-   * Opcode definitions in The Java Virtual Machine Specification</a> */
-  public static final short JSR_W            = 201;
-
-  /** JVM internal opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.2">
-   * Reserved opcodes in the Java Virtual Machine Specification</a> */
-  public static final short BREAKPOINT                = 202;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short LDC_QUICK                 = 203;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short LDC_W_QUICK               = 204;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short LDC2_W_QUICK              = 205;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short GETFIELD_QUICK            = 206;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short PUTFIELD_QUICK            = 207;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short GETFIELD2_QUICK           = 208;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short PUTFIELD2_QUICK           = 209;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short GETSTATIC_QUICK           = 210;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short PUTSTATIC_QUICK           = 211;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short GETSTATIC2_QUICK          = 212;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short PUTSTATIC2_QUICK          = 213;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INVOKEVIRTUAL_QUICK       = 214;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INVOKENONVIRTUAL_QUICK    = 215;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INVOKESUPER_QUICK         = 216;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INVOKESTATIC_QUICK        = 217;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INVOKEINTERFACE_QUICK     = 218;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INVOKEVIRTUALOBJECT_QUICK = 219;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short NEW_QUICK                 = 221;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short ANEWARRAY_QUICK           = 222;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short MULTIANEWARRAY_QUICK      = 223;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short CHECKCAST_QUICK           = 224;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INSTANCEOF_QUICK          = 225;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short INVOKEVIRTUAL_QUICK_W     = 226;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short GETFIELD_QUICK_W          = 227;
-
-  /** JVM internal opcode.
-   * @see <a href="https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
-   * Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885">
-   * Why the _quick opcodes were removed from the second version of the Java Virtual Machine Specification.</a> */
-  public static final short PUTFIELD_QUICK_W          = 228;
-
-  /** JVM internal opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.2">
-   * Reserved opcodes in the Java Virtual Machine Specification</a> */
-  public static final short IMPDEP1                   = 254;
-
-  /** JVM internal opcode.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.2">
-   * Reserved opcodes in the Java Virtual Machine Specification</a> */
-  public static final short IMPDEP2                   = 255;
-
-  /**
-   * BCEL virtual instruction for pushing an arbitrary data type onto the stack.  Will be converted to the appropriate JVM
-   * opcode when the class is dumped.
-   */
-  public static final short PUSH             = 4711;
-
-  /**
-   * BCEL virtual instruction for either LOOKUPSWITCH or TABLESWITCH.  Will be converted to the appropriate JVM
-   * opcode when the class is dumped.
-   */
-  public static final short SWITCH           = 4712;
-
-  /** Illegal opcode. */
-  public static final short  UNDEFINED      = -1;
-
-  /** Illegal opcode. */
-  public static final short  UNPREDICTABLE  = -2;
-
-  /** Illegal opcode. */
-  public static final short  RESERVED       = -3;
-
-  /** Mnemonic for an illegal opcode. */
-  public static final String ILLEGAL_OPCODE = "<illegal opcode>";
-
-  /** Mnemonic for an illegal type. */
-  public static final String ILLEGAL_TYPE   = "<illegal type>";
-
-  /** Boolean data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_BOOLEAN = 4;
-
-  /** Char data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_CHAR    = 5;
-
-  /** Float data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_FLOAT   = 6;
-
-  /** Double data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_DOUBLE  = 7;
-
-  /** Byte data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_BYTE    = 8;
-
-  /** Short data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_SHORT   = 9;
-
-  /** Int data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_INT     = 10;
-
-  /** Long data type.
-   * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P">
-   * Static Constraints in the Java Virtual Machine Specification</a> */
-  public static final byte T_LONG    = 11;
-
-  /** Void data type (non-standard). */
-  public static final byte T_VOID      = 12; // Non-standard
-
-  /** Array data type. */
-  public static final byte T_ARRAY     = 13;
-
-  /** Object data type. */
-  public static final byte T_OBJECT    = 14;
-
-  /** Reference data type (deprecated). */
-  public static final byte T_REFERENCE = 14; // Deprecated
-
-  /** Unknown data type. */
-  public static final byte T_UNKNOWN   = 15;
-
-  /** Address data type. */
-  public static final byte T_ADDRESS   = 16;
-
-  /** The primitive type names corresponding to the T_XX constants,
-   * e.g., TYPE_NAMES[T_INT] = "int"
-   */
-  private static final String[] TYPE_NAMES = {
-    ILLEGAL_TYPE, ILLEGAL_TYPE,  ILLEGAL_TYPE, ILLEGAL_TYPE,
-    "boolean", "char", "float", "double", "byte", "short", "int", "long",
-    "void", "array", "object", "unknown", "address"
-  };
-
-  /**
-   * The primitive type names corresponding to the T_XX constants,
-   * e.g., TYPE_NAMES[T_INT] = "int"
-   * @param index
-   * @return the type name
-   * @since 6.0
-   */
-  public static String getTypeName(final int index) {
-      return TYPE_NAMES[index];
-  }
-
-  /** The primitive class names corresponding to the T_XX constants,
-   * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
-   */
-  private static final String[] CLASS_TYPE_NAMES = {
-    ILLEGAL_TYPE, ILLEGAL_TYPE,  ILLEGAL_TYPE, ILLEGAL_TYPE,
-    "java.lang.Boolean", "java.lang.Character", "java.lang.Float",
-    "java.lang.Double", "java.lang.Byte", "java.lang.Short",
-    "java.lang.Integer", "java.lang.Long", "java.lang.Void",
-    ILLEGAL_TYPE, ILLEGAL_TYPE,  ILLEGAL_TYPE,  ILLEGAL_TYPE
-  };
-
-  /**
-   * The primitive class names corresponding to the T_XX constants,
-   * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
-   * @param index
-   * @return the class name
-   * @since 6.0
-   */
-  public static String getClassTypeName(final int index) {
-      return CLASS_TYPE_NAMES[index];
-  }
-
-  /** The signature characters corresponding to primitive types,
-   * e.g., SHORT_TYPE_NAMES[T_INT] = "I"
-   */
-  private static final String[] SHORT_TYPE_NAMES = {
-    ILLEGAL_TYPE, ILLEGAL_TYPE,  ILLEGAL_TYPE, ILLEGAL_TYPE,
-    "Z", "C", "F", "D", "B", "S", "I", "J",
-    "V", ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE
-  };
-
-  /**
-   *
-   * @param index
-   * @return the short type name
-   * @since 6.0
-   */
-  public static String getShortTypeName(final int index) {
-      return SHORT_TYPE_NAMES[index];
-  }
-
-
-  /**
-   * Number of byte code operands for each opcode, i.e., number of bytes after the tag byte
-   * itself.  Indexed by opcode, so NO_OF_OPERANDS[BIPUSH] = the number of operands for a bipush
-   * instruction.
-   */
-  private static final short[] NO_OF_OPERANDS = {
-    0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/,
-    0/*iconst_1*/, 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/,
-    0/*iconst_5*/, 0/*lconst_0*/, 0/*lconst_1*/, 0/*fconst_0*/,
-    0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/, 0/*dconst_1*/,
-    1/*bipush*/, 2/*sipush*/, 1/*ldc*/, 2/*ldc_w*/, 2/*ldc2_w*/,
-    1/*iload*/, 1/*lload*/, 1/*fload*/, 1/*dload*/, 1/*aload*/,
-    0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/, 0/*iload_3*/,
-    0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/,
-    0/*fload_0*/, 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/,
-    0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/, 0/*dload_3*/,
-    0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/,
-    0/*iaload*/, 0/*laload*/, 0/*faload*/, 0/*daload*/,
-    0/*aaload*/, 0/*baload*/, 0/*caload*/, 0/*saload*/,
-    1/*istore*/, 1/*lstore*/, 1/*fstore*/, 1/*dstore*/,
-    1/*astore*/, 0/*istore_0*/, 0/*istore_1*/, 0/*istore_2*/,
-    0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/, 0/*lstore_2*/,
-    0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/,
-    0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/,
-    0/*dstore_3*/, 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/,
-    0/*astore_3*/, 0/*iastore*/, 0/*lastore*/, 0/*fastore*/,
-    0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/,
-    0/*sastore*/, 0/*pop*/, 0/*pop2*/, 0/*dup*/, 0/*dup_x1*/,
-    0/*dup_x2*/, 0/*dup2*/, 0/*dup2_x1*/, 0/*dup2_x2*/, 0/*swap*/,
-    0/*iadd*/, 0/*ladd*/, 0/*fadd*/, 0/*dadd*/, 0/*isub*/,
-    0/*lsub*/, 0/*fsub*/, 0/*dsub*/, 0/*imul*/, 0/*lmul*/,
-    0/*fmul*/, 0/*dmul*/, 0/*idiv*/, 0/*ldiv*/, 0/*fdiv*/,
-    0/*ddiv*/, 0/*irem*/, 0/*lrem*/, 0/*frem*/, 0/*drem*/,
-    0/*ineg*/, 0/*lneg*/, 0/*fneg*/, 0/*dneg*/, 0/*ishl*/,
-    0/*lshl*/, 0/*ishr*/, 0/*lshr*/, 0/*iushr*/, 0/*lushr*/,
-    0/*iand*/, 0/*land*/, 0/*ior*/, 0/*lor*/, 0/*ixor*/, 0/*lxor*/,
-    2/*iinc*/, 0/*i2l*/, 0/*i2f*/, 0/*i2d*/, 0/*l2i*/, 0/*l2f*/,
-    0/*l2d*/, 0/*f2i*/, 0/*f2l*/, 0/*f2d*/, 0/*d2i*/, 0/*d2l*/,
-    0/*d2f*/, 0/*i2b*/, 0/*i2c*/, 0/*i2s*/, 0/*lcmp*/, 0/*fcmpl*/,
-    0/*fcmpg*/, 0/*dcmpl*/, 0/*dcmpg*/, 2/*ifeq*/, 2/*ifne*/,
-    2/*iflt*/, 2/*ifge*/, 2/*ifgt*/, 2/*ifle*/, 2/*if_icmpeq*/,
-    2/*if_icmpne*/, 2/*if_icmplt*/, 2/*if_icmpge*/, 2/*if_icmpgt*/,
-    2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/, 2/*goto*/,
-    2/*jsr*/, 1/*ret*/, UNPREDICTABLE/*tableswitch*/, UNPREDICTABLE/*lookupswitch*/,
-    0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
-    0/*dreturn*/, 0/*areturn*/, 0/*return*/,
-    2/*getstatic*/, 2/*putstatic*/, 2/*getfield*/,
-    2/*putfield*/, 2/*invokevirtual*/, 2/*invokespecial*/, 2/*invokestatic*/,
-    4/*invokeinterface*/, 4/*invokedynamic*/, 2/*new*/,
-    1/*newarray*/, 2/*anewarray*/,
-    0/*arraylength*/, 0/*athrow*/, 2/*checkcast*/,
-    2/*instanceof*/, 0/*monitorenter*/,
-    0/*monitorexit*/, UNPREDICTABLE/*wide*/, 3/*multianewarray*/,
-    2/*ifnull*/, 2/*ifnonnull*/, 4/*goto_w*/,
-    4/*jsr_w*/, 0/*breakpoint*/, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, RESERVED/*impdep1*/, RESERVED/*impdep2*/
-  };
-
-  /**
-   *
-   * @param index
-   * @return Number of byte code operands
-   * @since 6.0
-   */
-  public static short getNoOfOperands(final int index) {
-      return NO_OF_OPERANDS[index];
-  }
-
-  /**
-   * How the byte code operands are to be interpreted for each opcode.
-   * Indexed by opcode.  TYPE_OF_OPERANDS[ILOAD] = an array of shorts
-   * describing the data types for the instruction.
-   */
-  private static final short[][] TYPE_OF_OPERANDS = {
-    {}/*nop*/, {}/*aconst_null*/, {}/*iconst_m1*/, {}/*iconst_0*/,
-    {}/*iconst_1*/, {}/*iconst_2*/, {}/*iconst_3*/, {}/*iconst_4*/,
-    {}/*iconst_5*/, {}/*lconst_0*/, {}/*lconst_1*/, {}/*fconst_0*/,
-    {}/*fconst_1*/, {}/*fconst_2*/, {}/*dconst_0*/, {}/*dconst_1*/,
-    {T_BYTE}/*bipush*/, {T_SHORT}/*sipush*/, {T_BYTE}/*ldc*/,
-    {T_SHORT}/*ldc_w*/, {T_SHORT}/*ldc2_w*/,
-    {T_BYTE}/*iload*/, {T_BYTE}/*lload*/, {T_BYTE}/*fload*/,
-    {T_BYTE}/*dload*/, {T_BYTE}/*aload*/, {}/*iload_0*/,
-    {}/*iload_1*/, {}/*iload_2*/, {}/*iload_3*/, {}/*lload_0*/,
-    {}/*lload_1*/, {}/*lload_2*/, {}/*lload_3*/, {}/*fload_0*/,
-    {}/*fload_1*/, {}/*fload_2*/, {}/*fload_3*/, {}/*dload_0*/,
-    {}/*dload_1*/, {}/*dload_2*/, {}/*dload_3*/, {}/*aload_0*/,
-    {}/*aload_1*/, {}/*aload_2*/, {}/*aload_3*/, {}/*iaload*/,
-    {}/*laload*/, {}/*faload*/, {}/*daload*/, {}/*aaload*/,
-    {}/*baload*/, {}/*caload*/, {}/*saload*/, {T_BYTE}/*istore*/,
-    {T_BYTE}/*lstore*/, {T_BYTE}/*fstore*/, {T_BYTE}/*dstore*/,
-    {T_BYTE}/*astore*/, {}/*istore_0*/, {}/*istore_1*/,
-    {}/*istore_2*/, {}/*istore_3*/, {}/*lstore_0*/, {}/*lstore_1*/,
-    {}/*lstore_2*/, {}/*lstore_3*/, {}/*fstore_0*/, {}/*fstore_1*/,
-    {}/*fstore_2*/, {}/*fstore_3*/, {}/*dstore_0*/, {}/*dstore_1*/,
-    {}/*dstore_2*/, {}/*dstore_3*/, {}/*astore_0*/, {}/*astore_1*/,
-    {}/*astore_2*/, {}/*astore_3*/, {}/*iastore*/, {}/*lastore*/,
-    {}/*fastore*/, {}/*dastore*/, {}/*aastore*/, {}/*bastore*/,
-    {}/*castore*/, {}/*sastore*/, {}/*pop*/, {}/*pop2*/, {}/*dup*/,
-    {}/*dup_x1*/, {}/*dup_x2*/, {}/*dup2*/, {}/*dup2_x1*/,
-    {}/*dup2_x2*/, {}/*swap*/, {}/*iadd*/, {}/*ladd*/, {}/*fadd*/,
-    {}/*dadd*/, {}/*isub*/, {}/*lsub*/, {}/*fsub*/, {}/*dsub*/,
-    {}/*imul*/, {}/*lmul*/, {}/*fmul*/, {}/*dmul*/, {}/*idiv*/,
-    {}/*ldiv*/, {}/*fdiv*/, {}/*ddiv*/, {}/*irem*/, {}/*lrem*/,
-    {}/*frem*/, {}/*drem*/, {}/*ineg*/, {}/*lneg*/, {}/*fneg*/,
-    {}/*dneg*/, {}/*ishl*/, {}/*lshl*/, {}/*ishr*/, {}/*lshr*/,
-    {}/*iushr*/, {}/*lushr*/, {}/*iand*/, {}/*land*/, {}/*ior*/,
-    {}/*lor*/, {}/*ixor*/, {}/*lxor*/, {T_BYTE, T_BYTE}/*iinc*/,
-    {}/*i2l*/, {}/*i2f*/, {}/*i2d*/, {}/*l2i*/, {}/*l2f*/, {}/*l2d*/,
-    {}/*f2i*/, {}/*f2l*/, {}/*f2d*/, {}/*d2i*/, {}/*d2l*/, {}/*d2f*/,
-    {}/*i2b*/, {}/*i2c*/, {}/*i2s*/, {}/*lcmp*/, {}/*fcmpl*/,
-    {}/*fcmpg*/, {}/*dcmpl*/, {}/*dcmpg*/, {T_SHORT}/*ifeq*/,
-    {T_SHORT}/*ifne*/, {T_SHORT}/*iflt*/, {T_SHORT}/*ifge*/,
-    {T_SHORT}/*ifgt*/, {T_SHORT}/*ifle*/, {T_SHORT}/*if_icmpeq*/,
-    {T_SHORT}/*if_icmpne*/, {T_SHORT}/*if_icmplt*/,
-    {T_SHORT}/*if_icmpge*/, {T_SHORT}/*if_icmpgt*/,
-    {T_SHORT}/*if_icmple*/, {T_SHORT}/*if_acmpeq*/,
-    {T_SHORT}/*if_acmpne*/, {T_SHORT}/*goto*/, {T_SHORT}/*jsr*/,
-    {T_BYTE}/*ret*/, {}/*tableswitch*/, {}/*lookupswitch*/,
-    {}/*ireturn*/, {}/*lreturn*/, {}/*freturn*/, {}/*dreturn*/,
-    {}/*areturn*/, {}/*return*/, {T_SHORT}/*getstatic*/,
-    {T_SHORT}/*putstatic*/, {T_SHORT}/*getfield*/,
-    {T_SHORT}/*putfield*/, {T_SHORT}/*invokevirtual*/,
-    {T_SHORT}/*invokespecial*/, {T_SHORT}/*invokestatic*/,
-    {T_SHORT, T_BYTE, T_BYTE}/*invokeinterface*/, {T_SHORT, T_BYTE, T_BYTE}/*invokedynamic*/,
-    {T_SHORT}/*new*/, {T_BYTE}/*newarray*/,
-    {T_SHORT}/*anewarray*/, {}/*arraylength*/, {}/*athrow*/,
-    {T_SHORT}/*checkcast*/, {T_SHORT}/*instanceof*/,
-    {}/*monitorenter*/, {}/*monitorexit*/, {T_BYTE}/*wide*/,
-    {T_SHORT, T_BYTE}/*multianewarray*/, {T_SHORT}/*ifnull*/,
-    {T_SHORT}/*ifnonnull*/, {T_INT}/*goto_w*/, {T_INT}/*jsr_w*/,
-    {}/*breakpoint*/, {}, {}, {}, {}, {}, {}, {},
-    {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
-    {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
-    {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
-    {}/*impdep1*/, {}/*impdep2*/
-  };
-
-  /**
-   * @since 6.0
-   */
-  public static short getOperandType(final int opcode, final int index) {
-      return TYPE_OF_OPERANDS[opcode][index];
-  }
-
-  /**
-   * @since 6.0
-   */
-  public static long getOperandTypeCount(final int opcode) {
-      return TYPE_OF_OPERANDS[opcode].length;
-  }
-
-  /**
-   * Names of opcodes.  Indexed by opcode.  OPCODE_NAMES[ALOAD] = "aload".
-   */
-  private static final String[] OPCODE_NAMES = {
-    "nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1",
-    "iconst_2", "iconst_3", "iconst_4", "iconst_5", "lconst_0",
-    "lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0",
-    "dconst_1", "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload",
-    "lload", "fload", "dload", "aload", "iload_0", "iload_1", "iload_2",
-    "iload_3", "lload_0", "lload_1", "lload_2", "lload_3", "fload_0",
-    "fload_1", "fload_2", "fload_3", "dload_0", "dload_1", "dload_2",
-    "dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload",
-    "laload", "faload", "daload", "aaload", "baload", "caload", "saload",
-    "istore", "lstore", "fstore", "dstore", "astore", "istore_0",
-    "istore_1", "istore_2", "istore_3", "lstore_0", "lstore_1",
-    "lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2",
-    "fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3",
-    "astore_0", "astore_1", "astore_2", "astore_3", "iastore", "lastore",
-    "fastore", "dastore", "aastore", "bastore", "castore", "sastore",
-    "pop", "pop2", "dup", "dup_x1", "dup_x2", "dup2", "dup2_x1",
-    "dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub",
-    "fsub", "dsub", "imul", "lmul", "fmul", "dmul", "idiv", "ldiv",
-    "fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg",
-    "fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr",
-    "iand", "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f",
-    "i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", "d2f",
-    "i2b", "i2c", "i2s", "lcmp", "fcmpl", "fcmpg",
-    "dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle",
-    "if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge", "if_icmpgt",
-    "if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret",
-    "tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn",
-    "dreturn", "areturn", "return", "getstatic", "putstatic", "getfield",
-    "putfield", "invokevirtual", "invokespecial", "invokestatic",
-    "invokeinterface", "invokedynamic", "new", "newarray", "anewarray",
-    "arraylength", "athrow", "checkcast", "instanceof", "monitorenter",
-    "monitorexit", "wide", "multianewarray", "ifnull", "ifnonnull",
-    "goto_w", "jsr_w", "breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
-    ILLEGAL_OPCODE, "impdep1", "impdep2"
-  };
-
-  /**
-   * @since 6.0
-   */
-  public static final int OPCODE_NAMES_LENGTH = OPCODE_NAMES.length;
-
-
-  /**
-   * @since 6.0
-   */
-  public static String getOpcodeName(final int index) {
-      return OPCODE_NAMES[index];
-  }
-
-  /**
-   * Number of words consumed on operand stack by instructions.
-   * Indexed by opcode.  CONSUME_STACK[FALOAD] = number of words
-   * consumed from the stack by a faload instruction.
-   */
-  private static final int[] CONSUME_STACK = {
-    0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/, 0/*iconst_1*/,
-    0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/, 0/*iconst_5*/, 0/*lconst_0*/,
-    0/*lconst_1*/, 0/*fconst_0*/, 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/,
-    0/*dconst_1*/, 0/*bipush*/, 0/*sipush*/, 0/*ldc*/, 0/*ldc_w*/, 0/*ldc2_w*/, 0/*iload*/,
-    0/*lload*/, 0/*fload*/, 0/*dload*/, 0/*aload*/, 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/,
-    0/*iload_3*/, 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/, 0/*fload_0*/,
-    0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/, 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/,
-    0/*dload_3*/, 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/, 2/*iaload*/,
-    2/*laload*/, 2/*faload*/, 2/*daload*/, 2/*aaload*/, 2/*baload*/, 2/*caload*/, 2/*saload*/,
-    1/*istore*/, 2/*lstore*/, 1/*fstore*/, 2/*dstore*/, 1/*astore*/, 1/*istore_0*/,
-    1/*istore_1*/, 1/*istore_2*/, 1/*istore_3*/, 2/*lstore_0*/, 2/*lstore_1*/,
-    2/*lstore_2*/, 2/*lstore_3*/, 1/*fstore_0*/, 1/*fstore_1*/, 1/*fstore_2*/,
-    1/*fstore_3*/, 2/*dstore_0*/, 2/*dstore_1*/, 2/*dstore_2*/, 2/*dstore_3*/,
-    1/*astore_0*/, 1/*astore_1*/, 1/*astore_2*/, 1/*astore_3*/, 3/*iastore*/, 4/*lastore*/,
-    3/*fastore*/, 4/*dastore*/, 3/*aastore*/, 3/*bastore*/, 3/*castore*/, 3/*sastore*/,
-    1/*pop*/, 2/*pop2*/, 1/*dup*/, 2/*dup_x1*/, 3/*dup_x2*/, 2/*dup2*/, 3/*dup2_x1*/,
-    4/*dup2_x2*/, 2/*swap*/, 2/*iadd*/, 4/*ladd*/, 2/*fadd*/, 4/*dadd*/, 2/*isub*/, 4/*lsub*/,
-    2/*fsub*/, 4/*dsub*/, 2/*imul*/, 4/*lmul*/, 2/*fmul*/, 4/*dmul*/, 2/*idiv*/, 4/*ldiv*/,
-    2/*fdiv*/, 4/*ddiv*/, 2/*irem*/, 4/*lrem*/, 2/*frem*/, 4/*drem*/, 1/*ineg*/, 2/*lneg*/,
-    1/*fneg*/, 2/*dneg*/, 2/*ishl*/, 3/*lshl*/, 2/*ishr*/, 3/*lshr*/, 2/*iushr*/, 3/*lushr*/,
-    2/*iand*/, 4/*land*/, 2/*ior*/, 4/*lor*/, 2/*ixor*/, 4/*lxor*/, 0/*iinc*/,
-    1/*i2l*/, 1/*i2f*/, 1/*i2d*/, 2/*l2i*/, 2/*l2f*/, 2/*l2d*/, 1/*f2i*/, 1/*f2l*/,
-    1/*f2d*/, 2/*d2i*/, 2/*d2l*/, 2/*d2f*/, 1/*i2b*/, 1/*i2c*/, 1/*i2s*/,
-    4/*lcmp*/, 2/*fcmpl*/, 2/*fcmpg*/, 4/*dcmpl*/, 4/*dcmpg*/, 1/*ifeq*/, 1/*ifne*/,
-    1/*iflt*/, 1/*ifge*/, 1/*ifgt*/, 1/*ifle*/, 2/*if_icmpeq*/, 2/*if_icmpne*/, 2/*if_icmplt*/,
-    2 /*if_icmpge*/, 2/*if_icmpgt*/, 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/,
-    0/*goto*/, 0/*jsr*/, 0/*ret*/, 1/*tableswitch*/, 1/*lookupswitch*/, 1/*ireturn*/,
-    2/*lreturn*/, 1/*freturn*/, 2/*dreturn*/, 1/*areturn*/, 0/*return*/, 0/*getstatic*/,
-    UNPREDICTABLE/*putstatic*/, 1/*getfield*/, UNPREDICTABLE/*putfield*/,
-    UNPREDICTABLE/*invokevirtual*/, UNPREDICTABLE/*invokespecial*/,
-    UNPREDICTABLE/*invokestatic*/,
-    UNPREDICTABLE/*invokeinterface*/, UNPREDICTABLE/*invokedynamic*/, 0/*new*/, 1/*newarray*/, 1/*anewarray*/,
-    1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 1/*monitorenter*/,
-    1/*monitorexit*/, 0/*wide*/, UNPREDICTABLE/*multianewarray*/, 1/*ifnull*/, 1/*ifnonnull*/,
-    0/*goto_w*/, 0/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
-  };
-
-  /**
-   *
-   * @param index
-   * @return Number of words consumed on operand stack
-   * @since 6.0
-   */
-  public static int getConsumeStack(final int index) {
-      return CONSUME_STACK[index];
-  }
-
-
-  /**
-   * Number of words produced onto operand stack by instructions.
-   * Indexed by opcode.  CONSUME_STACK[DALOAD] = number of words
-   * consumed from the stack by a daload instruction.
-   */
-  private static final int[] PRODUCE_STACK = {
-    0/*nop*/, 1/*aconst_null*/, 1/*iconst_m1*/, 1/*iconst_0*/, 1/*iconst_1*/,
-    1/*iconst_2*/, 1/*iconst_3*/, 1/*iconst_4*/, 1/*iconst_5*/, 2/*lconst_0*/,
-    2/*lconst_1*/, 1/*fconst_0*/, 1/*fconst_1*/, 1/*fconst_2*/, 2/*dconst_0*/,
-    2/*dconst_1*/, 1/*bipush*/, 1/*sipush*/, 1/*ldc*/, 1/*ldc_w*/, 2/*ldc2_w*/, 1/*iload*/,
-    2/*lload*/, 1/*fload*/, 2/*dload*/, 1/*aload*/, 1/*iload_0*/, 1/*iload_1*/, 1/*iload_2*/,
-    1/*iload_3*/, 2/*lload_0*/, 2/*lload_1*/, 2/*lload_2*/, 2/*lload_3*/, 1/*fload_0*/,
-    1/*fload_1*/, 1/*fload_2*/, 1/*fload_3*/, 2/*dload_0*/, 2/*dload_1*/, 2/*dload_2*/,
-    2/*dload_3*/, 1/*aload_0*/, 1/*aload_1*/, 1/*aload_2*/, 1/*aload_3*/, 1/*iaload*/,
-    2/*laload*/, 1/*faload*/, 2/*daload*/, 1/*aaload*/, 1/*baload*/, 1/*caload*/, 1/*saload*/,
-    0/*istore*/, 0/*lstore*/, 0/*fstore*/, 0/*dstore*/, 0/*astore*/, 0/*istore_0*/,
-    0/*istore_1*/, 0/*istore_2*/, 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/,
-    0/*lstore_2*/, 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/,
-    0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, 0/*dstore_3*/,
-    0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/,
-    0/*fastore*/, 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, 0/*sastore*/,
-    0/*pop*/, 0/*pop2*/, 2/*dup*/, 3/*dup_x1*/, 4/*dup_x2*/, 4/*dup2*/, 5/*dup2_x1*/,
-    6/*dup2_x2*/, 2/*swap*/, 1/*iadd*/, 2/*ladd*/, 1/*fadd*/, 2/*dadd*/, 1/*isub*/, 2/*lsub*/,
-    1/*fsub*/, 2/*dsub*/, 1/*imul*/, 2/*lmul*/, 1/*fmul*/, 2/*dmul*/, 1/*idiv*/, 2/*ldiv*/,
-    1/*fdiv*/, 2/*ddiv*/, 1/*irem*/, 2/*lrem*/, 1/*frem*/, 2/*drem*/, 1/*ineg*/, 2/*lneg*/,
-    1/*fneg*/, 2/*dneg*/, 1/*ishl*/, 2/*lshl*/, 1/*ishr*/, 2/*lshr*/, 1/*iushr*/, 2/*lushr*/,
-    1/*iand*/, 2/*land*/, 1/*ior*/, 2/*lor*/, 1/*ixor*/, 2/*lxor*/,
-    0/*iinc*/, 2/*i2l*/, 1/*i2f*/, 2/*i2d*/, 1/*l2i*/, 1/*l2f*/, 2/*l2d*/, 1/*f2i*/,
-    2/*f2l*/, 2/*f2d*/, 1/*d2i*/, 2/*d2l*/, 1/*d2f*/,
-    1/*i2b*/, 1/*i2c*/, 1/*i2s*/, 1/*lcmp*/, 1/*fcmpl*/, 1/*fcmpg*/,
-    1/*dcmpl*/, 1/*dcmpg*/, 0/*ifeq*/, 0/*ifne*/, 0/*iflt*/, 0/*ifge*/, 0/*ifgt*/, 0/*ifle*/,
-    0/*if_icmpeq*/, 0/*if_icmpne*/, 0/*if_icmplt*/, 0/*if_icmpge*/, 0/*if_icmpgt*/,
-    0/*if_icmple*/, 0/*if_acmpeq*/, 0/*if_acmpne*/, 0/*goto*/, 1/*jsr*/, 0/*ret*/,
-    0/*tableswitch*/, 0/*lookupswitch*/, 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
-    0/*dreturn*/, 0/*areturn*/, 0/*return*/, UNPREDICTABLE/*getstatic*/, 0/*putstatic*/,
-    UNPREDICTABLE/*getfield*/, 0/*putfield*/, UNPREDICTABLE/*invokevirtual*/,
-    UNPREDICTABLE/*invokespecial*/, UNPREDICTABLE/*invokestatic*/,
-    UNPREDICTABLE/*invokeinterface*/, UNPREDICTABLE/*invokedynamic*/, 1/*new*/, 1/*newarray*/, 1/*anewarray*/,
-    1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 0/*monitorenter*/,
-    0/*monitorexit*/, 0/*wide*/, 1/*multianewarray*/, 0/*ifnull*/, 0/*ifnonnull*/,
-    0/*goto_w*/, 1/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
-    UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
-  };
-
-  /**
-   *
-   * @param index
-   * @return Number of words produced onto operand stack
-   * @since 6.0
-   */
-  public static int getProduceStack(final int index) {
-      return PRODUCE_STACK[index];
-  }
-
-  /** Attributes and their corresponding names.
-   */
-  public static final byte ATTR_UNKNOWN                                 = -1;
-  public static final byte ATTR_SOURCE_FILE                             = 0;
-  public static final byte ATTR_CONSTANT_VALUE                          = 1;
-  public static final byte ATTR_CODE                                    = 2;
-  public static final byte ATTR_EXCEPTIONS                              = 3;
-  public static final byte ATTR_LINE_NUMBER_TABLE                       = 4;
-  public static final byte ATTR_LOCAL_VARIABLE_TABLE                    = 5;
-  public static final byte ATTR_INNER_CLASSES                           = 6;
-  public static final byte ATTR_SYNTHETIC                               = 7;
-  public static final byte ATTR_DEPRECATED                              = 8;
-  public static final byte ATTR_PMG                                     = 9;
-  public static final byte ATTR_SIGNATURE                               = 10;
-  public static final byte ATTR_STACK_MAP                               = 11;
-  public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS             = 12;
-  public static final byte ATTR_RUNTIME_INVISIBLE_ANNOTATIONS           = 13;
-  public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS   = 14;
-  public static final byte ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = 15;
-  public static final byte ATTR_ANNOTATION_DEFAULT                      = 16;
-  public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE               = 17;
-  public static final byte ATTR_ENCLOSING_METHOD                        = 18;
-  public static final byte ATTR_STACK_MAP_TABLE                         = 19;
-  public static final byte ATTR_BOOTSTRAP_METHODS                       = 20;
-  public static final byte ATTR_METHOD_PARAMETERS                       = 21;
-  public static final byte ATTR_MODULE                                  = 22;
-  public static final byte ATTR_MODULE_PACKAGES                         = 23;
-  public static final byte ATTR_MODULE_MAIN_CLASS                       = 24;
-  public static final byte ATTR_NEST_HOST                               = 25;
-  public static final byte ATTR_NEST_MEMBERS                            = 26;
-
-  public static final short KNOWN_ATTRIBUTES = 27; // count of attributes
-
-  private static final String[] ATTRIBUTE_NAMES = {
-    "SourceFile", "ConstantValue", "Code", "Exceptions",
-    "LineNumberTable", "LocalVariableTable",
-    "InnerClasses", "Synthetic", "Deprecated",
-    "PMGClass", "Signature", "StackMap",
-    "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
-    "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
-    "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod", "StackMapTable",
-    "BootstrapMethods", "MethodParameters", "Module", "ModulePackages",
-    "ModuleMainClass", "NestHost", "NestMembers"
-  };
-
-  /**
-   *
-   * @param index
-   * @return the attribute name
-   * @since 6.0
-   */
-  public static String getAttributeName(final int index) {
-      return ATTRIBUTE_NAMES[index];
-  }
-
-  /** Constants used in the StackMap attribute.
-   */
-  public static final byte ITEM_Bogus      = 0;
-  public static final byte ITEM_Integer    = 1;
-  public static final byte ITEM_Float      = 2;
-  public static final byte ITEM_Double     = 3;
-  public static final byte ITEM_Long       = 4;
-  public static final byte ITEM_Null       = 5;
-  public static final byte ITEM_InitObject = 6;
-  public static final byte ITEM_Object     = 7;
-  public static final byte ITEM_NewObject  = 8;
-
-  private static final String[] ITEM_NAMES = {
-    "Bogus", "Integer", "Float", "Double", "Long",
-    "Null", "InitObject", "Object", "NewObject"
-  };
-
-  /**
-   *
-   * @param index
-   * @return the item name
-   * @since 6.0
-   */
-  public static String getItemName(final int index) {
-      return ITEM_NAMES[index];
-  }
-
-  /** Constants used to identify StackMapEntry types.
-   *
-   * For those types which can specify a range, the
-   * constant names the lowest value.
-   */
-  public static final int SAME_FRAME = 0;
-  public static final int SAME_LOCALS_1_STACK_ITEM_FRAME = 64;
-  public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED = 247;
-  public static final int CHOP_FRAME = 248;
-  public static final int SAME_FRAME_EXTENDED = 251;
-  public static final int APPEND_FRAME = 252;
-  public static final int FULL_FRAME = 255;
-
-  /** Constants that define the maximum value of
-   * those constants which store ranges. */
-
-  public static final int SAME_FRAME_MAX = 63;
-  public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_MAX = 127;
-  public static final int CHOP_FRAME_MAX = 250;
-  public static final int APPEND_FRAME_MAX = 254;
-
-
-  // Constants defining the behavior of the Method Handles (JVMS 5.4.3.5)
-
-  public static final byte REF_getField         = 1;
-  public static final byte REF_getStatic        = 2;
-  public static final byte REF_putField         = 3;
-  public static final byte REF_putStatic        = 4;
-  public static final byte REF_invokeVirtual    = 5;
-  public static final byte REF_invokeStatic     = 6;
-  public static final byte REF_invokeSpecial    = 7;
-  public static final byte REF_newInvokeSpecial = 8;
-  public static final byte REF_invokeInterface  = 9;
-
-  /**
-   * The names of the reference_kinds of a CONSTANT_MethodHandle_info.
-   */
-  private static final String[] METHODHANDLE_NAMES = {
-      "", "getField", "getStatic", "putField", "putStatic", "invokeVirtual",
-      "invokeStatic", "invokeSpecial", "newInvokeSpecial", "invokeInterface" };
-
-  /**
-   *
-   * @param index
-   * @return the method handle name
-   * @since 6.0
-   */
-  public static String getMethodHandleName(final int index) {
-      return METHODHANDLE_NAMES[index];
-  }
-
-  private Const() { } // not instantiable
+    /**
+     * Java class file format Magic number (0xCAFEBABE)
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1-200-A"> The ClassFile Structure
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final int JVM_CLASSFILE_MAGIC = 0xCAFEBABE;
+
+    /**
+     * Major version number of class files for Java 1.1.
+     *
+     * @see #MINOR_1_1
+     */
+    public static final short MAJOR_1_1 = 45;
+
+    /**
+     * Minor version number of class files for Java 1.1.
+     *
+     * @see #MAJOR_1_1
+     */
+    public static final short MINOR_1_1 = 3;
+
+    /**
+     * Major version number of class files for Java 1.2.
+     *
+     * @see #MINOR_1_2
+     */
+    public static final short MAJOR_1_2 = 46;
+
+    /**
+     * Minor version number of class files for Java 1.2.
+     *
+     * @see #MAJOR_1_2
+     */
+    public static final short MINOR_1_2 = 0;
+
+    /**
+     * Major version number of class files for Java 1.2.
+     *
+     * @see #MINOR_1_2
+     */
+    public static final short MAJOR_1_3 = 47;
+
+    /**
+     * Minor version number of class files for Java 1.3.
+     *
+     * @see #MAJOR_1_3
+     */
+    public static final short MINOR_1_3 = 0;
+
+    /**
+     * Major version number of class files for Java 1.3.
+     *
+     * @see #MINOR_1_3
+     */
+    public static final short MAJOR_1_4 = 48;
+
+    /**
+     * Minor version number of class files for Java 1.4.
+     *
+     * @see #MAJOR_1_4
+     */
+    public static final short MINOR_1_4 = 0;
+
+    /**
+     * Major version number of class files for Java 1.4.
+     *
+     * @see #MINOR_1_4
+     */
+    public static final short MAJOR_1_5 = 49;
+
+    /**
+     * Minor version number of class files for Java 1.5.
+     *
+     * @see #MAJOR_1_5
+     */
+    public static final short MINOR_1_5 = 0;
+
+    /**
+     * Major version number of class files for Java 1.6.
+     *
+     * @see #MINOR_1_6
+     */
+    public static final short MAJOR_1_6 = 50;
+
+    /**
+     * Minor version number of class files for Java 1.6.
+     *
+     * @see #MAJOR_1_6
+     */
+    public static final short MINOR_1_6 = 0;
+
+    /**
+     * Major version number of class files for Java 1.7.
+     *
+     * @see #MINOR_1_7
+     */
+    public static final short MAJOR_1_7 = 51;
+
+    /**
+     * Minor version number of class files for Java 1.7.
+     *
+     * @see #MAJOR_1_7
+     */
+    public static final short MINOR_1_7 = 0;
+
+    /**
+     * Major version number of class files for Java 1.8.
+     *
+     * @see #MINOR_1_8
+     */
+    public static final short MAJOR_1_8 = 52;
+
+    /**
+     * Minor version number of class files for Java 1.8.
+     *
+     * @see #MAJOR_1_8
+     */
+    public static final short MINOR_1_8 = 0;
+
+    /**
+     * Major version number of class files for Java 9.
+     *
+     * @see #MINOR_9
+     */
+    public static final short MAJOR_9 = 53;
+
+    /**
+     * Minor version number of class files for Java 9.
+     *
+     * @see #MAJOR_9
+     */
+    public static final short MINOR_9 = 0;
+
+    /**
+     * @deprecated Use {@link #MAJOR_9} instead
+     */
+    @Deprecated
+    public static final short MAJOR_1_9 = MAJOR_9;
+
+    /**
+     * @deprecated Use {@link #MINOR_9} instead
+     */
+    @Deprecated
+    public static final short MINOR_1_9 = MINOR_9;
+
+    /**
+     * Major version number of class files for Java 10.
+     *
+     * @see #MINOR_10
+     */
+    public static final short MAJOR_10 = 54;
+
+    /**
+     * Minor version number of class files for Java 10.
+     *
+     * @see #MAJOR_10
+     */
+    public static final short MINOR_10 = 0;
+
+    /**
+     * Major version number of class files for Java 11.
+     *
+     * @see #MINOR_11
+     */
+    public static final short MAJOR_11 = 55;
+
+    /**
+     * Minor version number of class files for Java 11.
+     *
+     * @see #MAJOR_11
+     */
+    public static final short MINOR_11 = 0;
+
+    /**
+     * Major version number of class files for Java 12.
+     *
+     * @see #MINOR_12
+     */
+    public static final short MAJOR_12 = 56;
+
+    /**
+     * Minor version number of class files for Java 12.
+     *
+     * @see #MAJOR_12
+     */
+    public static final short MINOR_12 = 0;
+
+    /**
+     * Major version number of class files for Java 13.
+     *
+     * @see #MINOR_13
+     */
+    public static final short MAJOR_13 = 57;
+
+    /**
+     * Minor version number of class files for Java 13.
+     *
+     * @see #MAJOR_13
+     */
+    public static final short MINOR_13 = 0;
+
+    /**
+     * Minor version number of class files for Java 14.
+     *
+     * @see #MAJOR_14
+     * @since 6.4.0
+     */
+    public static final short MINOR_14 = 0;
+
+    /**
+     * Minor version number of class files for Java 15.
+     *
+     * @see #MAJOR_15
+     * @since 6.6.0
+     */
+    public static final short MINOR_15 = 0;
+
+    /**
+     * Minor version number of class files for Java 16.
+     *
+     * @see #MAJOR_16
+     * @since 6.6.0
+     */
+    public static final short MINOR_16 = 0;
+
+    /**
+     * Minor version number of class files for Java 17.
+     *
+     * @see #MAJOR_17
+     * @since 6.6.0
+     */
+    public static final short MINOR_17 = 0;
+
+    /**
+     * Minor version number of class files for Java 18.
+     *
+     * @see #MAJOR_18
+     * @since 6.6.0
+     */
+    public static final short MINOR_18 = 0;
+
+    /**
+     * Minor version number of class files for Java 19.
+     *
+     * @see #MAJOR_19
+     * @since 6.6.0
+     */
+    public static final short MINOR_19 = 0;
+
+    /**
+     * Major version number of class files for Java 14.
+     *
+     * @see #MINOR_14
+     * @since 6.4.0
+     */
+    public static final short MAJOR_14 = 58;
+
+    /**
+     * Major version number of class files for Java 15.
+     *
+     * @see #MINOR_15
+     * @since 6.6.0
+     */
+    public static final short MAJOR_15 = 59;
+
+    /**
+     * Major version number of class files for Java 16.
+     *
+     * @see #MINOR_16
+     * @since 6.6.0
+     */
+    public static final short MAJOR_16 = 60;
+
+    /**
+     * Major version number of class files for Java 17.
+     *
+     * @see #MINOR_17
+     * @since 6.6.0
+     */
+    public static final short MAJOR_17 = 61;
+
+    /**
+     * Major version number of class files for Java 18.
+     *
+     * @see #MINOR_18
+     * @since 6.6.0
+     */
+    public static final short MAJOR_18 = 62;
+
+    /**
+     * Major version number of class files for Java 19.
+     *
+     * @see #MINOR_19
+     * @since 6.6.0
+     */
+    public static final short MAJOR_19 = 63;
+
+    /**
+     * Default major version number. Class file is for Java 1.1.
+     *
+     * @see #MAJOR_1_1
+     */
+    public static final short MAJOR = MAJOR_1_1;
+
+    /**
+     * Default major version number. Class file is for Java 1.1.
+     *
+     * @see #MAJOR_1_1
+     */
+    public static final short MINOR = MINOR_1_1;
+
+    /**
+     * Maximum value for an unsigned short.
+     */
+    public static final int MAX_SHORT = 65535; // 2^16 - 1
+
+    /**
+     * Maximum value for an unsigned byte.
+     */
+    public static final int MAX_BYTE = 255; // 2^8 - 1
+
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1-200-E.1"> Flag definitions for
+     *      Classes in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.5"> Flag definitions for Fields
+     *      in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.6"> Flag definitions for Methods
+     *      in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.6-300-D.1-D.1"> Flag
+     *      definitions for Inner Classes in the Java Virtual Machine Specification (Java SE 9 Edition).</a>
+     */
+    public static final short ACC_PUBLIC = 0x0001;
+
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_PRIVATE = 0x0002;
+
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_PROTECTED = 0x0004;
+
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_STATIC = 0x0008;
+
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_FINAL = 0x0010;
+
+    /**
+     * One of the access flags for the Module attribute.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_OPEN = 0x0020;
+
+    /**
+     * One of the access flags for classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_SUPER = 0x0020;
+
+    /**
+     * One of the access flags for methods.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_SYNCHRONIZED = 0x0020;
+
+    /**
+     * One of the access flags for the Module attribute.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_TRANSITIVE = 0x0020;
+
+    /**
+     * One of the access flags for methods.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_BRIDGE = 0x0040;
+
+    /**
+     * One of the access flags for the Module attribute.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_STATIC_PHASE = 0x0040;
+
+    /**
+     * One of the access flags for fields.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_VOLATILE = 0x0040;
+
+    /**
+     * One of the access flags for fields.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_TRANSIENT = 0x0080;
+
+    /**
+     * One of the access flags for methods.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_VARARGS = 0x0080;
+
+    /**
+     * One of the access flags for methods.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_NATIVE = 0x0100;
+
+    /**
+     * One of the access flags for classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_INTERFACE = 0x0200;
+
+    /**
+     * One of the access flags for methods or classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_ABSTRACT = 0x0400;
+
+    /**
+     * One of the access flags for methods.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_STRICT = 0x0800;
+
+    /**
+     * One of the access flags for fields, methods, classes, MethodParameter attribute, or Module attribute.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_SYNTHETIC = 0x1000;
+
+    /**
+     * One of the access flags for classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_ANNOTATION = 0x2000;
+
+    /**
+     * One of the access flags for fields or classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_ENUM = 0x4000;
+
+    // Applies to classes compiled by new compilers only
+    /**
+     * One of the access flags for MethodParameter or Module attributes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_MANDATED = (short) 0x8000;
+
+    /**
+     * One of the access flags for classes.
+     *
+     * @see #ACC_PUBLIC
+     */
+    public static final short ACC_MODULE = (short) 0x8000;
+
+    /**
+     * One of the access flags for fields, methods, or classes.
+     *
+     * @see #ACC_PUBLIC
+     * @deprecated Use {@link #MAX_ACC_FLAG_I}
+     */
+    @Deprecated
+    public static final short MAX_ACC_FLAG = ACC_ENUM;
+
+    /**
+     * One of the access flags for fields, methods, or classes. ACC_MODULE is negative as a short.
+     *
+     * @see #ACC_PUBLIC
+     * @since 6.4.0
+     */
+    public static final int MAX_ACC_FLAG_I = 0x8000; // ACC_MODULE is negative as a short
+
+    // Note that do to overloading:
+    // 'synchronized' is for methods, might be 'open' (if Module), 'super' (if class), or 'transitive' (if Module).
+    // 'volatile' is for fields, might be 'bridge' (if method) or 'static_phase' (if Module)
+    // 'transient' is for fields, might be 'varargs' (if method)
+    // 'module' is for classes, might be 'mandated' (if Module or MethodParameters)
+    /**
+     * The names of the access flags.
+     */
+    private static final String[] ACCESS_NAMES = {"public", "private", "protected", "static", "final", "synchronized", "volatile", "transient", "native",
+        "interface", "abstract", "strictfp", "synthetic", "annotation", "enum", "module"};
+
+    /** @since 6.0 */
+    public static final int ACCESS_NAMES_LENGTH = ACCESS_NAMES.length;
+
+    /**
+     * Marks a constant pool entry as type UTF-8.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.7"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Utf8 = 1;
+
+    /*
+     * The description of the constant pool is at: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4
+     * References below are to the individual sections
+     */
+
+    /**
+     * Marks a constant pool entry as type Integer.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Integer = 3;
+
+    /**
+     * Marks a constant pool entry as type Float.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.4"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Float = 4;
+
+    /**
+     * Marks a constant pool entry as type Long.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Long = 5;
+
+    /**
+     * Marks a constant pool entry as type Double.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.5"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Double = 6;
+
+    /**
+     * Marks a constant pool entry as a Class
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.1"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Class = 7;
+
+    /**
+     * Marks a constant pool entry as a Field Reference.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Fieldref = 9;
+
+    /**
+     * Marks a constant pool entry as type String
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.3"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_String = 8;
+
+    /**
+     * Marks a constant pool entry as a Method Reference.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_Methodref = 10;
+
+    /**
+     * Marks a constant pool entry as an Interface Method Reference.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.2"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_InterfaceMethodref = 11;
+
+    /**
+     * Marks a constant pool entry as a name and type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.6"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_NameAndType = 12;
+
+    /**
+     * Marks a constant pool entry as a Method Handle.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.8"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_MethodHandle = 15;
+
+    /**
+     * Marks a constant pool entry as a Method Type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.9"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_MethodType = 16;
+
+    /**
+     * Marks a constant pool entry as dynamically computed.
+     *
+     * @see <a href="https://bugs.openjdk.java.net/secure/attachment/74618/constant-dynamic.html"> Change request for JEP
+     *      309</a>
+     * @since 6.3
+     */
+    public static final byte CONSTANT_Dynamic = 17;
+
+    /**
+     * Marks a constant pool entry as an Invoke Dynamic
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.10"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final byte CONSTANT_InvokeDynamic = 18;
+
+    /**
+     * Marks a constant pool entry as a Module Reference.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.11"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     * @since 6.1
+     */
+    public static final byte CONSTANT_Module = 19;
+
+    /**
+     * Marks a constant pool entry as a Package Reference.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.12"> The Constant Pool in The
+     *      Java Virtual Machine Specification</a>
+     * @since 6.1
+     */
+    public static final byte CONSTANT_Package = 20;
+
+    /**
+     * The names of the types of entries in a constant pool. Use getConstantName instead
+     */
+    private static final String[] CONSTANT_NAMES = {"", "CONSTANT_Utf8", "", "CONSTANT_Integer", "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double",
+        "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref", "CONSTANT_Methodref", "CONSTANT_InterfaceMethodref", "CONSTANT_NameAndType", "", "",
+        "CONSTANT_MethodHandle", "CONSTANT_MethodType", "CONSTANT_Dynamic", "CONSTANT_InvokeDynamic", "CONSTANT_Module", "CONSTANT_Package"};
+
+    /**
+     * The name of the static initializer, also called &quot;class initialization method&quot; or &quot;interface
+     * initialization method&quot;. This is &quot;&lt;clinit&gt;&quot;.
+     */
+    public static final String STATIC_INITIALIZER_NAME = "<clinit>";
+
+    /**
+     * The name of every constructor method in a class, also called &quot;instance initialization method&quot;. This is
+     * &quot;&lt;init&gt;&quot;.
+     */
+    public static final String CONSTRUCTOR_NAME = "<init>";
+
+    /**
+     * The names of the interfaces implemented by arrays
+     */
+    private static final String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"};
+
+    /**
+     * Maximum Constant Pool entries. One of the limitations of the Java Virtual Machine.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.11-100-A"> The Java Virtual
+     *      Machine Specification, Java SE 8 Edition, page 330, chapter 4.11.</a>
+     */
+    public static final int MAX_CP_ENTRIES = 65535;
+
+    /**
+     * Maximum code size (plus one; the code size must be LESS than this) One of the limitations of the Java Virtual
+     * Machine. Note vmspec2 page 152 ("Limitations") says: "The amount of code per non-native, non-abstract method is
+     * limited to 65536 bytes by the sizes of the indices in the exception_table of the Code attribute (4.7.3), in the
+     * LineNumberTable attribute (4.7.8), and in the LocalVariableTable attribute (4.7.9)." However this should be taken
+     * as an upper limit rather than the defined maximum. On page 134 (4.8.1 Static Constants) of the same spec, it says:
+     * "The value of the code_length item must be less than 65536." The entry in the Limitations section has been removed
+     * from later versions of the spec; it is not present in the Java SE 8 edition.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3-300-E"> The Java Virtual
+     *      Machine Specification, Java SE 8 Edition, page 104, chapter 4.7.</a>
+     */
+    public static final int MAX_CODE_SIZE = 65536; // bytes
+
+    /**
+     * The maximum number of dimensions in an array ({@value}). One of the limitations of the Java Virtual Machine.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.3.2-150"> Field Descriptors in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final int MAX_ARRAY_DIMENSIONS = 255;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.nop"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short NOP = 0;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aconst_null"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short ACONST_NULL = 1;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ICONST_M1 = 2;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ICONST_0 = 3;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ICONST_1 = 4;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ICONST_2 = 5;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ICONST_3 = 6;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ICONST_4 = 7;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iconst_i"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ICONST_5 = 8;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lconst_l"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short LCONST_0 = 9;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lconst_l"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short LCONST_1 = 10;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fconst_f"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short FCONST_0 = 11;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fconst_f"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short FCONST_1 = 12;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fconst_f"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short FCONST_2 = 13;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dconst_d"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short DCONST_0 = 14;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dconst_d"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short DCONST_1 = 15;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.bipush"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short BIPUSH = 16;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.sipush"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short SIPUSH = 17;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldc"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short LDC = 18;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldc_w"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LDC_W = 19;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldc2_w"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LDC2_W = 20;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ILOAD = 21;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LLOAD = 22;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FLOAD = 23;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DLOAD = 24;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ALOAD = 25;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ILOAD_0 = 26;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ILOAD_1 = 27;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ILOAD_2 = 28;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ILOAD_3 = 29;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LLOAD_0 = 30;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LLOAD_1 = 31;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LLOAD_2 = 32;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LLOAD_3 = 33;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FLOAD_0 = 34;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FLOAD_1 = 35;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FLOAD_2 = 36;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FLOAD_3 = 37;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DLOAD_0 = 38;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DLOAD_1 = 39;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DLOAD_2 = 40;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DLOAD_3 = 41;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ALOAD_0 = 42;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ALOAD_1 = 43;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ALOAD_2 = 44;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aload_n"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ALOAD_3 = 45;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iaload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IALOAD = 46;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.laload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LALOAD = 47;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.faload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FALOAD = 48;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.daload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DALOAD = 49;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aaload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short AALOAD = 50;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.baload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short BALOAD = 51;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.caload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short CALOAD = 52;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.saload"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short SALOAD = 53;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ISTORE = 54;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LSTORE = 55;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FSTORE = 56;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DSTORE = 57;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ASTORE = 58;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ISTORE_0 = 59;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ISTORE_1 = 60;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ISTORE_2 = 61;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.istore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ISTORE_3 = 62;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short LSTORE_0 = 63;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short LSTORE_1 = 64;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short LSTORE_2 = 65;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short LSTORE_3 = 66;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short FSTORE_0 = 67;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short FSTORE_1 = 68;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short FSTORE_2 = 69;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short FSTORE_3 = 70;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short DSTORE_0 = 71;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short DSTORE_1 = 72;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short DSTORE_2 = 73;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dstore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short DSTORE_3 = 74;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ASTORE_0 = 75;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ASTORE_1 = 76;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ASTORE_2 = 77;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.astore_n"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ASTORE_3 = 78;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iastore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IASTORE = 79;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lastore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LASTORE = 80;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fastore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FASTORE = 81;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dastore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DASTORE = 82;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aastore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short AASTORE = 83;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.bastore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short BASTORE = 84;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.castore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short CASTORE = 85;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.sastore"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short SASTORE = 86;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.pop"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short POP = 87;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.pop2"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short POP2 = 88;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short DUP = 89;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup_x1"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DUP_X1 = 90;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup_x2"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DUP_X2 = 91;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup2"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DUP2 = 92;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup2_x1"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DUP2_X1 = 93;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dup2_x2"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DUP2_X2 = 94;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.swap"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short SWAP = 95;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iadd"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IADD = 96;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ladd"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LADD = 97;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fadd"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FADD = 98;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dadd"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DADD = 99;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.isub"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ISUB = 100;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lsub"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LSUB = 101;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fsub"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FSUB = 102;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dsub"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DSUB = 103;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.imul"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IMUL = 104;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lmul"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LMUL = 105;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fmul"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FMUL = 106;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dmul"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DMUL = 107;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.idiv"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IDIV = 108;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldiv"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LDIV = 109;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fdiv"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FDIV = 110;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ddiv"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DDIV = 111;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.irem"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IREM = 112;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lrem"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LREM = 113;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.frem"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FREM = 114;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.drem"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DREM = 115;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ineg"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short INEG = 116;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lneg"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LNEG = 117;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fneg"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FNEG = 118;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dneg"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DNEG = 119;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ishl"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ISHL = 120;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lshl"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LSHL = 121;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ishr"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ISHR = 122;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lshr"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LSHR = 123;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iushr"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IUSHR = 124;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lushr"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LUSHR = 125;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iand"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IAND = 126;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.land"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LAND = 127;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ior"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short IOR = 128;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lor"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short LOR = 129;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ixor"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IXOR = 130;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lxor"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LXOR = 131;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iinc"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IINC = 132;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2l"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short I2L = 133;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2f"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short I2F = 134;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2d"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short I2D = 135;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.l2i"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short L2I = 136;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.l2f"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short L2F = 137;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.l2d"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short L2D = 138;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.f2i"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short F2I = 139;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.f2l"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short F2L = 140;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.f2d"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short F2D = 141;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.d2i"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short D2I = 142;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.d2l"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short D2L = 143;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.d2f"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short D2F = 144;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2b"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short I2B = 145;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short INT2BYTE = 145; // Old notation
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2c"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short I2C = 146;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short INT2CHAR = 146; // Old notation
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.i2s"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short I2S = 147;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short INT2SHORT = 147; // Old notation
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lcmp"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LCMP = 148;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fcmpl"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FCMPL = 149;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fcmpg"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FCMPG = 150;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dcmpl"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DCMPL = 151;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dcmpg"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DCMPG = 152;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifeq"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IFEQ = 153;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifne"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IFNE = 154;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iflt"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IFLT = 155;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifge"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IFGE = 156;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifgt"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IFGT = 157;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifle"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IFLE = 158;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ICMPEQ = 159;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ICMPNE = 160;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ICMPLT = 161;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ICMPGE = 162;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ICMPGT = 163;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_icmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ICMPLE = 164;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_acmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ACMPEQ = 165;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.if_acmp_cond"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short IF_ACMPNE = 166;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.goto"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short GOTO = 167;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.jsr"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short JSR = 168;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ret"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short RET = 169;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.tableswitch"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short TABLESWITCH = 170;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lookupswitch"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short LOOKUPSWITCH = 171;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ireturn"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IRETURN = 172;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.lreturn"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short LRETURN = 173;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.freturn"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short FRETURN = 174;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.dreturn"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short DRETURN = 175;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.areturn"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ARETURN = 176;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.return"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short RETURN = 177;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.getstatic"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short GETSTATIC = 178;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.putstatic"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short PUTSTATIC = 179;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.getfield"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short GETFIELD = 180;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.putfield"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short PUTFIELD = 181;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokevirtual"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short INVOKEVIRTUAL = 182;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokespecial"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short INVOKESPECIAL = 183;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokestatic"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short INVOKESTATIC = 184;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokeinterface"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short INVOKEINTERFACE = 185;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokedynamic"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short INVOKEDYNAMIC = 186;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.new"> Opcode definitions in The
+     *      Java Virtual Machine Specification</a>
+     */
+    public static final short NEW = 187;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.newarray"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short NEWARRAY = 188;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.anewarray"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short ANEWARRAY = 189;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.arraylength"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short ARRAYLENGTH = 190;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.athrow"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short ATHROW = 191;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.checkcast"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short CHECKCAST = 192;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.instanceof"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short INSTANCEOF = 193;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.monitorenter"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short MONITORENTER = 194;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.monitorexit"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short MONITOREXIT = 195;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.wide"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short WIDE = 196;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.multianewarray"> Opcode
+     *      definitions in The Java Virtual Machine Specification</a>
+     */
+    public static final short MULTIANEWARRAY = 197;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifnull"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short IFNULL = 198;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ifnonnull"> Opcode definitions
+     *      in The Java Virtual Machine Specification</a>
+     */
+    public static final short IFNONNULL = 199;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.goto_w"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short GOTO_W = 200;
+
+    /**
+     * Java VM opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.jsr_w"> Opcode definitions in
+     *      The Java Virtual Machine Specification</a>
+     */
+    public static final short JSR_W = 201;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.2"> Reserved opcodes in the Java
+     *      Virtual Machine Specification</a>
+     */
+    public static final short BREAKPOINT = 202;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short LDC_QUICK = 203;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short LDC_W_QUICK = 204;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short LDC2_W_QUICK = 205;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short GETFIELD_QUICK = 206;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short PUTFIELD_QUICK = 207;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short GETFIELD2_QUICK = 208;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short PUTFIELD2_QUICK = 209;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short GETSTATIC_QUICK = 210;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short PUTSTATIC_QUICK = 211;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short GETSTATIC2_QUICK = 212;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short PUTSTATIC2_QUICK = 213;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INVOKEVIRTUAL_QUICK = 214;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INVOKENONVIRTUAL_QUICK = 215;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INVOKESUPER_QUICK = 216;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INVOKESTATIC_QUICK = 217;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INVOKEINTERFACE_QUICK = 218;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INVOKEVIRTUALOBJECT_QUICK = 219;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short NEW_QUICK = 221;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short ANEWARRAY_QUICK = 222;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short MULTIANEWARRAY_QUICK = 223;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short CHECKCAST_QUICK = 224;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INSTANCEOF_QUICK = 225;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short INVOKEVIRTUAL_QUICK_W = 226;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short GETFIELD_QUICK_W = 227;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href=
+     *      "https://web.archive.org/web/20120108031230/http://java.sun.com/docs/books/jvms/first_edition/html/Quick.doc.html">
+     *      Specification of _quick opcodes in the Java Virtual Machine Specification (version 1)</a>
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se5.0/html/ChangesAppendix.doc.html#448885"> Why the _quick
+     *      opcodes were removed from the second version of the Java Virtual Machine Specification.</a>
+     */
+    public static final short PUTFIELD_QUICK_W = 228;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.2"> Reserved opcodes in the Java
+     *      Virtual Machine Specification</a>
+     */
+    public static final short IMPDEP1 = 254;
+
+    /**
+     * JVM internal opcode.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.2"> Reserved opcodes in the Java
+     *      Virtual Machine Specification</a>
+     */
+    public static final short IMPDEP2 = 255;
+
+    /**
+     * BCEL virtual instruction for pushing an arbitrary data type onto the stack. Will be converted to the appropriate JVM
+     * opcode when the class is dumped.
+     */
+    public static final short PUSH = 4711;
+
+    /**
+     * BCEL virtual instruction for either LOOKUPSWITCH or TABLESWITCH. Will be converted to the appropriate JVM opcode when
+     * the class is dumped.
+     */
+    public static final short SWITCH = 4712;
+
+    /** Illegal opcode. */
+    public static final short UNDEFINED = -1;
+
+    /** Illegal opcode. */
+    public static final short UNPREDICTABLE = -2;
+
+    /** Illegal opcode. */
+    public static final short RESERVED = -3;
+
+    /** Mnemonic for an illegal opcode. */
+    public static final String ILLEGAL_OPCODE = "<illegal opcode>";
+
+    /** Mnemonic for an illegal type. */
+    public static final String ILLEGAL_TYPE = "<illegal type>";
+
+    /**
+     * Boolean data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_BOOLEAN = 4;
+
+    /**
+     * Char data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_CHAR = 5;
+
+    /**
+     * Float data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_FLOAT = 6;
+
+    /**
+     * Double data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_DOUBLE = 7;
+
+    /**
+     * Byte data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_BYTE = 8;
+
+    /**
+     * Short data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_SHORT = 9;
+
+    /**
+     * Int data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_INT = 10;
+
+    /**
+     * Long data type.
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.9.1-120-P"> Static Constraints in
+     *      the Java Virtual Machine Specification</a>
+     */
+    public static final byte T_LONG = 11;
+
+    /** Void data type (non-standard). */
+    public static final byte T_VOID = 12; // Non-standard
+
+    /** Array data type. */
+    public static final byte T_ARRAY = 13;
+
+    /** Object data type. */
+    public static final byte T_OBJECT = 14;
+
+    /** Reference data type (deprecated). */
+    public static final byte T_REFERENCE = 14; // Deprecated
+
+    /** Unknown data type. */
+    public static final byte T_UNKNOWN = 15;
+
+    /** Address data type. */
+    public static final byte T_ADDRESS = 16;
+
+    /** Empty arrays used to replace references to ArrayUtils */
+    public static final byte[] EMPTY_BYTE_ARRAY = {};
+    public static final int[] EMPTY_INT_ARRAY = {};
+    public static final String[] EMPTY_STRING_ARRAY = {};
+
+    /**
+     * The primitive type names corresponding to the T_XX constants, e.g., TYPE_NAMES[T_INT] = "int"
+     */
+    private static final String[] TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "boolean", "char", "float", "double", "byte", "short",
+        "int", "long", "void", "array", "object", "unknown", "address"};
+
+    /**
+     * The primitive class names corresponding to the T_XX constants, e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
+     */
+    private static final String[] CLASS_TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "java.lang.Boolean", "java.lang.Character",
+        "java.lang.Float", "java.lang.Double", "java.lang.Byte", "java.lang.Short", "java.lang.Integer", "java.lang.Long", "java.lang.Void", ILLEGAL_TYPE,
+        ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE};
+
+    /**
+     * The signature characters corresponding to primitive types, e.g., SHORT_TYPE_NAMES[T_INT] = "I"
+     */
+    private static final String[] SHORT_TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "Z", "C", "F", "D", "B", "S", "I", "J", "V",
+        ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE};
+
+    /**
+     * Number of byte code operands for each opcode, i.e., number of bytes after the tag byte itself. Indexed by opcode, so
+     * NO_OF_OPERANDS[BIPUSH] = the number of operands for a bipush instruction.
+     */
+    static final short[] NO_OF_OPERANDS = {0/* nop */, 0/* aconst_null */, 0/* iconst_m1 */, 0/* iconst_0 */, 0/* iconst_1 */, 0/* iconst_2 */,
+        0/* iconst_3 */, 0/* iconst_4 */, 0/* iconst_5 */, 0/* lconst_0 */, 0/* lconst_1 */, 0/* fconst_0 */, 0/* fconst_1 */, 0/* fconst_2 */, 0/* dconst_0 */,
+        0/* dconst_1 */, 1/* bipush */, 2/* sipush */, 1/* ldc */, 2/* ldc_w */, 2/* ldc2_w */, 1/* iload */, 1/* lload */, 1/* fload */, 1/* dload */,
+        1/* aload */, 0/* iload_0 */, 0/* iload_1 */, 0/* iload_2 */, 0/* iload_3 */, 0/* lload_0 */, 0/* lload_1 */, 0/* lload_2 */, 0/* lload_3 */,
+        0/* fload_0 */, 0/* fload_1 */, 0/* fload_2 */, 0/* fload_3 */, 0/* dload_0 */, 0/* dload_1 */, 0/* dload_2 */, 0/* dload_3 */, 0/* aload_0 */,
+        0/* aload_1 */, 0/* aload_2 */, 0/* aload_3 */, 0/* iaload */, 0/* laload */, 0/* faload */, 0/* daload */, 0/* aaload */, 0/* baload */, 0/* caload */,
+        0/* saload */, 1/* istore */, 1/* lstore */, 1/* fstore */, 1/* dstore */, 1/* astore */, 0/* istore_0 */, 0/* istore_1 */, 0/* istore_2 */,
+        0/* istore_3 */, 0/* lstore_0 */, 0/* lstore_1 */, 0/* lstore_2 */, 0/* lstore_3 */, 0/* fstore_0 */, 0/* fstore_1 */, 0/* fstore_2 */, 0/* fstore_3 */,
+        0/* dstore_0 */, 0/* dstore_1 */, 0/* dstore_2 */, 0/* dstore_3 */, 0/* astore_0 */, 0/* astore_1 */, 0/* astore_2 */, 0/* astore_3 */, 0/* iastore */,
+        0/* lastore */, 0/* fastore */, 0/* dastore */, 0/* aastore */, 0/* bastore */, 0/* castore */, 0/* sastore */, 0/* pop */, 0/* pop2 */, 0/* dup */,
+        0/* dup_x1 */, 0/* dup_x2 */, 0/* dup2 */, 0/* dup2_x1 */, 0/* dup2_x2 */, 0/* swap */, 0/* iadd */, 0/* ladd */, 0/* fadd */, 0/* dadd */, 0/* isub */,
+        0/* lsub */, 0/* fsub */, 0/* dsub */, 0/* imul */, 0/* lmul */, 0/* fmul */, 0/* dmul */, 0/* idiv */, 0/* ldiv */, 0/* fdiv */, 0/* ddiv */,
+        0/* irem */, 0/* lrem */, 0/* frem */, 0/* drem */, 0/* ineg */, 0/* lneg */, 0/* fneg */, 0/* dneg */, 0/* ishl */, 0/* lshl */, 0/* ishr */,
+        0/* lshr */, 0/* iushr */, 0/* lushr */, 0/* iand */, 0/* land */, 0/* ior */, 0/* lor */, 0/* ixor */, 0/* lxor */, 2/* iinc */, 0/* i2l */,
+        0/* i2f */, 0/* i2d */, 0/* l2i */, 0/* l2f */, 0/* l2d */, 0/* f2i */, 0/* f2l */, 0/* f2d */, 0/* d2i */, 0/* d2l */, 0/* d2f */, 0/* i2b */,
+        0/* i2c */, 0/* i2s */, 0/* lcmp */, 0/* fcmpl */, 0/* fcmpg */, 0/* dcmpl */, 0/* dcmpg */, 2/* ifeq */, 2/* ifne */, 2/* iflt */, 2/* ifge */,
+        2/* ifgt */, 2/* ifle */, 2/* if_icmpeq */, 2/* if_icmpne */, 2/* if_icmplt */, 2/* if_icmpge */, 2/* if_icmpgt */, 2/* if_icmple */, 2/* if_acmpeq */,
+        2/* if_acmpne */, 2/* goto */, 2/* jsr */, 1/* ret */, UNPREDICTABLE/* tableswitch */, UNPREDICTABLE/* lookupswitch */, 0/* ireturn */, 0/* lreturn */,
+        0/* freturn */, 0/* dreturn */, 0/* areturn */, 0/* return */, 2/* getstatic */, 2/* putstatic */, 2/* getfield */, 2/* putfield */,
+        2/* invokevirtual */, 2/* invokespecial */, 2/* invokestatic */, 4/* invokeinterface */, 4/* invokedynamic */, 2/* new */, 1/* newarray */,
+        2/* anewarray */, 0/* arraylength */, 0/* athrow */, 2/* checkcast */, 2/* instanceof */, 0/* monitorenter */, 0/* monitorexit */,
+        UNPREDICTABLE/* wide */, 3/* multianewarray */, 2/* ifnull */, 2/* ifnonnull */, 4/* goto_w */, 4/* jsr_w */, 0/* breakpoint */, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, RESERVED/* impdep1 */,
+        RESERVED/* impdep2 */
+    };
+
+    /**
+     * How the byte code operands are to be interpreted for each opcode. Indexed by opcode. TYPE_OF_OPERANDS[ILOAD] = an
+     * array of shorts describing the data types for the instruction.
+     */
+    static final short[][] TYPE_OF_OPERANDS = {{}/* nop */, {}/* aconst_null */, {}/* iconst_m1 */, {}/* iconst_0 */, {}/* iconst_1 */,
+        {}/* iconst_2 */, {}/* iconst_3 */, {}/* iconst_4 */, {}/* iconst_5 */, {}/* lconst_0 */, {}/* lconst_1 */, {}/* fconst_0 */, {}/* fconst_1 */,
+        {}/* fconst_2 */, {}/* dconst_0 */, {}/* dconst_1 */, {T_BYTE}/* bipush */, {T_SHORT}/* sipush */, {T_BYTE}/* ldc */, {T_SHORT}/* ldc_w */,
+        {T_SHORT}/* ldc2_w */, {T_BYTE}/* iload */, {T_BYTE}/* lload */, {T_BYTE}/* fload */, {T_BYTE}/* dload */, {T_BYTE}/* aload */, {}/* iload_0 */,
+        {}/* iload_1 */, {}/* iload_2 */, {}/* iload_3 */, {}/* lload_0 */, {}/* lload_1 */, {}/* lload_2 */, {}/* lload_3 */, {}/* fload_0 */, {}/* fload_1 */,
+        {}/* fload_2 */, {}/* fload_3 */, {}/* dload_0 */, {}/* dload_1 */, {}/* dload_2 */, {}/* dload_3 */, {}/* aload_0 */, {}/* aload_1 */, {}/* aload_2 */,
+        {}/* aload_3 */, {}/* iaload */, {}/* laload */, {}/* faload */, {}/* daload */, {}/* aaload */, {}/* baload */, {}/* caload */, {}/* saload */,
+        {T_BYTE}/* istore */, {T_BYTE}/* lstore */, {T_BYTE}/* fstore */, {T_BYTE}/* dstore */, {T_BYTE}/* astore */, {}/* istore_0 */, {}/* istore_1 */,
+        {}/* istore_2 */, {}/* istore_3 */, {}/* lstore_0 */, {}/* lstore_1 */, {}/* lstore_2 */, {}/* lstore_3 */, {}/* fstore_0 */, {}/* fstore_1 */,
+        {}/* fstore_2 */, {}/* fstore_3 */, {}/* dstore_0 */, {}/* dstore_1 */, {}/* dstore_2 */, {}/* dstore_3 */, {}/* astore_0 */, {}/* astore_1 */,
+        {}/* astore_2 */, {}/* astore_3 */, {}/* iastore */, {}/* lastore */, {}/* fastore */, {}/* dastore */, {}/* aastore */, {}/* bastore */,
+        {}/* castore */, {}/* sastore */, {}/* pop */, {}/* pop2 */, {}/* dup */, {}/* dup_x1 */, {}/* dup_x2 */, {}/* dup2 */, {}/* dup2_x1 */,
+        {}/* dup2_x2 */, {}/* swap */, {}/* iadd */, {}/* ladd */, {}/* fadd */, {}/* dadd */, {}/* isub */, {}/* lsub */, {}/* fsub */, {}/* dsub */,
+        {}/* imul */, {}/* lmul */, {}/* fmul */, {}/* dmul */, {}/* idiv */, {}/* ldiv */, {}/* fdiv */, {}/* ddiv */, {}/* irem */, {}/* lrem */,
+        {}/* frem */, {}/* drem */, {}/* ineg */, {}/* lneg */, {}/* fneg */, {}/* dneg */, {}/* ishl */, {}/* lshl */, {}/* ishr */, {}/* lshr */,
+        {}/* iushr */, {}/* lushr */, {}/* iand */, {}/* land */, {}/* ior */, {}/* lor */, {}/* ixor */, {}/* lxor */, {T_BYTE, T_BYTE}/* iinc */, {}/* i2l */,
+        {}/* i2f */, {}/* i2d */, {}/* l2i */, {}/* l2f */, {}/* l2d */, {}/* f2i */, {}/* f2l */, {}/* f2d */, {}/* d2i */, {}/* d2l */, {}/* d2f */,
+        {}/* i2b */, {}/* i2c */, {}/* i2s */, {}/* lcmp */, {}/* fcmpl */, {}/* fcmpg */, {}/* dcmpl */, {}/* dcmpg */, {T_SHORT}/* ifeq */,
+        {T_SHORT}/* ifne */, {T_SHORT}/* iflt */, {T_SHORT}/* ifge */, {T_SHORT}/* ifgt */, {T_SHORT}/* ifle */, {T_SHORT}/* if_icmpeq */,
+        {T_SHORT}/* if_icmpne */, {T_SHORT}/* if_icmplt */, {T_SHORT}/* if_icmpge */, {T_SHORT}/* if_icmpgt */, {T_SHORT}/* if_icmple */,
+        {T_SHORT}/* if_acmpeq */, {T_SHORT}/* if_acmpne */, {T_SHORT}/* goto */, {T_SHORT}/* jsr */, {T_BYTE}/* ret */, {}/* tableswitch */,
+        {}/* lookupswitch */, {}/* ireturn */, {}/* lreturn */, {}/* freturn */, {}/* dreturn */, {}/* areturn */, {}/* return */, {T_SHORT}/* getstatic */,
+        {T_SHORT}/* putstatic */, {T_SHORT}/* getfield */, {T_SHORT}/* putfield */, {T_SHORT}/* invokevirtual */, {T_SHORT}/* invokespecial */,
+        {T_SHORT}/* invokestatic */, {T_SHORT, T_BYTE, T_BYTE}/* invokeinterface */, {T_SHORT, T_BYTE, T_BYTE}/* invokedynamic */, {T_SHORT}/* new */,
+        {T_BYTE}/* newarray */, {T_SHORT}/* anewarray */, {}/* arraylength */, {}/* athrow */, {T_SHORT}/* checkcast */, {T_SHORT}/* instanceof */,
+        {}/* monitorenter */, {}/* monitorexit */, {T_BYTE}/* wide */, {T_SHORT, T_BYTE}/* multianewarray */, {T_SHORT}/* ifnull */, {T_SHORT}/* ifnonnull */,
+        {T_INT}/* goto_w */, {T_INT}/* jsr_w */, {}/* breakpoint */, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
+        {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}/* impdep1 */, {}/* impdep2 */
+    };
+
+    /**
+     * Names of opcodes. Indexed by opcode. OPCODE_NAMES[ALOAD] = "aload".
+     */
+    static final String[] OPCODE_NAMES = {"nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1", "iconst_2", "iconst_3", "iconst_4", "iconst_5",
+        "lconst_0", "lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0", "dconst_1", "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload", "lload",
+        "fload", "dload", "aload", "iload_0", "iload_1", "iload_2", "iload_3", "lload_0", "lload_1", "lload_2", "lload_3", "fload_0", "fload_1", "fload_2",
+        "fload_3", "dload_0", "dload_1", "dload_2", "dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload", "laload", "faload", "daload", "aaload",
+        "baload", "caload", "saload", "istore", "lstore", "fstore", "dstore", "astore", "istore_0", "istore_1", "istore_2", "istore_3", "lstore_0", "lstore_1",
+        "lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2", "fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3", "astore_0", "astore_1",
+        "astore_2", "astore_3", "iastore", "lastore", "fastore", "dastore", "aastore", "bastore", "castore", "sastore", "pop", "pop2", "dup", "dup_x1",
+        "dup_x2", "dup2", "dup2_x1", "dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub", "fsub", "dsub", "imul", "lmul", "fmul", "dmul", "idiv",
+        "ldiv", "fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg", "fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr", "iand",
+        "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f", "i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", "d2f", "i2b", "i2c", "i2s",
+        "lcmp", "fcmpl", "fcmpg", "dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle", "if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge",
+        "if_icmpgt", "if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret", "tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn", "dreturn",
+        "areturn", "return", "getstatic", "putstatic", "getfield", "putfield", "invokevirtual", "invokespecial", "invokestatic", "invokeinterface",
+        "invokedynamic", "new", "newarray", "anewarray", "arraylength", "athrow", "checkcast", "instanceof", "monitorenter", "monitorexit", "wide",
+        "multianewarray", "ifnull", "ifnonnull", "goto_w", "jsr_w", "breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+        ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+        ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+        ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+        ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+        ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
+        ILLEGAL_OPCODE, ILLEGAL_OPCODE, "impdep1", "impdep2"};
+
+    /**
+     * @since 6.0
+     */
+    public static final int OPCODE_NAMES_LENGTH = OPCODE_NAMES.length;
+
+    /**
+     * Number of words consumed on operand stack by instructions. Indexed by opcode. CONSUME_STACK[FALOAD] = number of words
+     * consumed from the stack by a faload instruction.
+     */
+    static final int[] CONSUME_STACK = {0/* nop */, 0/* aconst_null */, 0/* iconst_m1 */, 0/* iconst_0 */, 0/* iconst_1 */, 0/* iconst_2 */,
+        0/* iconst_3 */, 0/* iconst_4 */, 0/* iconst_5 */, 0/* lconst_0 */, 0/* lconst_1 */, 0/* fconst_0 */, 0/* fconst_1 */, 0/* fconst_2 */, 0/* dconst_0 */,
+        0/* dconst_1 */, 0/* bipush */, 0/* sipush */, 0/* ldc */, 0/* ldc_w */, 0/* ldc2_w */, 0/* iload */, 0/* lload */, 0/* fload */, 0/* dload */,
+        0/* aload */, 0/* iload_0 */, 0/* iload_1 */, 0/* iload_2 */, 0/* iload_3 */, 0/* lload_0 */, 0/* lload_1 */, 0/* lload_2 */, 0/* lload_3 */,
+        0/* fload_0 */, 0/* fload_1 */, 0/* fload_2 */, 0/* fload_3 */, 0/* dload_0 */, 0/* dload_1 */, 0/* dload_2 */, 0/* dload_3 */, 0/* aload_0 */,
+        0/* aload_1 */, 0/* aload_2 */, 0/* aload_3 */, 2/* iaload */, 2/* laload */, 2/* faload */, 2/* daload */, 2/* aaload */, 2/* baload */, 2/* caload */,
+        2/* saload */, 1/* istore */, 2/* lstore */, 1/* fstore */, 2/* dstore */, 1/* astore */, 1/* istore_0 */, 1/* istore_1 */, 1/* istore_2 */,
+        1/* istore_3 */, 2/* lstore_0 */, 2/* lstore_1 */, 2/* lstore_2 */, 2/* lstore_3 */, 1/* fstore_0 */, 1/* fstore_1 */, 1/* fstore_2 */, 1/* fstore_3 */,
+        2/* dstore_0 */, 2/* dstore_1 */, 2/* dstore_2 */, 2/* dstore_3 */, 1/* astore_0 */, 1/* astore_1 */, 1/* astore_2 */, 1/* astore_3 */, 3/* iastore */,
+        4/* lastore */, 3/* fastore */, 4/* dastore */, 3/* aastore */, 3/* bastore */, 3/* castore */, 3/* sastore */, 1/* pop */, 2/* pop2 */, 1/* dup */,
+        2/* dup_x1 */, 3/* dup_x2 */, 2/* dup2 */, 3/* dup2_x1 */, 4/* dup2_x2 */, 2/* swap */, 2/* iadd */, 4/* ladd */, 2/* fadd */, 4/* dadd */, 2/* isub */,
+        4/* lsub */, 2/* fsub */, 4/* dsub */, 2/* imul */, 4/* lmul */, 2/* fmul */, 4/* dmul */, 2/* idiv */, 4/* ldiv */, 2/* fdiv */, 4/* ddiv */,
+        2/* irem */, 4/* lrem */, 2/* frem */, 4/* drem */, 1/* ineg */, 2/* lneg */, 1/* fneg */, 2/* dneg */, 2/* ishl */, 3/* lshl */, 2/* ishr */,
+        3/* lshr */, 2/* iushr */, 3/* lushr */, 2/* iand */, 4/* land */, 2/* ior */, 4/* lor */, 2/* ixor */, 4/* lxor */, 0/* iinc */, 1/* i2l */,
+        1/* i2f */, 1/* i2d */, 2/* l2i */, 2/* l2f */, 2/* l2d */, 1/* f2i */, 1/* f2l */, 1/* f2d */, 2/* d2i */, 2/* d2l */, 2/* d2f */, 1/* i2b */,
+        1/* i2c */, 1/* i2s */, 4/* lcmp */, 2/* fcmpl */, 2/* fcmpg */, 4/* dcmpl */, 4/* dcmpg */, 1/* ifeq */, 1/* ifne */, 1/* iflt */, 1/* ifge */,
+        1/* ifgt */, 1/* ifle */, 2/* if_icmpeq */, 2/* if_icmpne */, 2/* if_icmplt */, 2 /* if_icmpge */, 2/* if_icmpgt */, 2/* if_icmple */, 2/* if_acmpeq */,
+        2/* if_acmpne */, 0/* goto */, 0/* jsr */, 0/* ret */, 1/* tableswitch */, 1/* lookupswitch */, 1/* ireturn */, 2/* lreturn */, 1/* freturn */,
+        2/* dreturn */, 1/* areturn */, 0/* return */, 0/* getstatic */, UNPREDICTABLE/* putstatic */, 1/* getfield */, UNPREDICTABLE/* putfield */,
+        UNPREDICTABLE/* invokevirtual */, UNPREDICTABLE/* invokespecial */, UNPREDICTABLE/* invokestatic */, UNPREDICTABLE/* invokeinterface */,
+        UNPREDICTABLE/* invokedynamic */, 0/* new */, 1/* newarray */, 1/* anewarray */, 1/* arraylength */, 1/* athrow */, 1/* checkcast */, 1/* instanceof */,
+        1/* monitorenter */, 1/* monitorexit */, 0/* wide */, UNPREDICTABLE/* multianewarray */, 1/* ifnull */, 1/* ifnonnull */, 0/* goto_w */, 0/* jsr_w */,
+        0/* breakpoint */, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNPREDICTABLE/* impdep1 */, UNPREDICTABLE/* impdep2 */
+    };
+
+    /**
+     * Number of words produced onto operand stack by instructions. Indexed by opcode. CONSUME_STACK[DALOAD] = number of
+     * words consumed from the stack by a daload instruction.
+     */
+    static final int[] PRODUCE_STACK = {0/* nop */, 1/* aconst_null */, 1/* iconst_m1 */, 1/* iconst_0 */, 1/* iconst_1 */, 1/* iconst_2 */,
+        1/* iconst_3 */, 1/* iconst_4 */, 1/* iconst_5 */, 2/* lconst_0 */, 2/* lconst_1 */, 1/* fconst_0 */, 1/* fconst_1 */, 1/* fconst_2 */, 2/* dconst_0 */,
+        2/* dconst_1 */, 1/* bipush */, 1/* sipush */, 1/* ldc */, 1/* ldc_w */, 2/* ldc2_w */, 1/* iload */, 2/* lload */, 1/* fload */, 2/* dload */,
+        1/* aload */, 1/* iload_0 */, 1/* iload_1 */, 1/* iload_2 */, 1/* iload_3 */, 2/* lload_0 */, 2/* lload_1 */, 2/* lload_2 */, 2/* lload_3 */,
+        1/* fload_0 */, 1/* fload_1 */, 1/* fload_2 */, 1/* fload_3 */, 2/* dload_0 */, 2/* dload_1 */, 2/* dload_2 */, 2/* dload_3 */, 1/* aload_0 */,
+        1/* aload_1 */, 1/* aload_2 */, 1/* aload_3 */, 1/* iaload */, 2/* laload */, 1/* faload */, 2/* daload */, 1/* aaload */, 1/* baload */, 1/* caload */,
+        1/* saload */, 0/* istore */, 0/* lstore */, 0/* fstore */, 0/* dstore */, 0/* astore */, 0/* istore_0 */, 0/* istore_1 */, 0/* istore_2 */,
+        0/* istore_3 */, 0/* lstore_0 */, 0/* lstore_1 */, 0/* lstore_2 */, 0/* lstore_3 */, 0/* fstore_0 */, 0/* fstore_1 */, 0/* fstore_2 */, 0/* fstore_3 */,
+        0/* dstore_0 */, 0/* dstore_1 */, 0/* dstore_2 */, 0/* dstore_3 */, 0/* astore_0 */, 0/* astore_1 */, 0/* astore_2 */, 0/* astore_3 */, 0/* iastore */,
+        0/* lastore */, 0/* fastore */, 0/* dastore */, 0/* aastore */, 0/* bastore */, 0/* castore */, 0/* sastore */, 0/* pop */, 0/* pop2 */, 2/* dup */,
+        3/* dup_x1 */, 4/* dup_x2 */, 4/* dup2 */, 5/* dup2_x1 */, 6/* dup2_x2 */, 2/* swap */, 1/* iadd */, 2/* ladd */, 1/* fadd */, 2/* dadd */, 1/* isub */,
+        2/* lsub */, 1/* fsub */, 2/* dsub */, 1/* imul */, 2/* lmul */, 1/* fmul */, 2/* dmul */, 1/* idiv */, 2/* ldiv */, 1/* fdiv */, 2/* ddiv */,
+        1/* irem */, 2/* lrem */, 1/* frem */, 2/* drem */, 1/* ineg */, 2/* lneg */, 1/* fneg */, 2/* dneg */, 1/* ishl */, 2/* lshl */, 1/* ishr */,
+        2/* lshr */, 1/* iushr */, 2/* lushr */, 1/* iand */, 2/* land */, 1/* ior */, 2/* lor */, 1/* ixor */, 2/* lxor */, 0/* iinc */, 2/* i2l */,
+        1/* i2f */, 2/* i2d */, 1/* l2i */, 1/* l2f */, 2/* l2d */, 1/* f2i */, 2/* f2l */, 2/* f2d */, 1/* d2i */, 2/* d2l */, 1/* d2f */, 1/* i2b */,
+        1/* i2c */, 1/* i2s */, 1/* lcmp */, 1/* fcmpl */, 1/* fcmpg */, 1/* dcmpl */, 1/* dcmpg */, 0/* ifeq */, 0/* ifne */, 0/* iflt */, 0/* ifge */,
+        0/* ifgt */, 0/* ifle */, 0/* if_icmpeq */, 0/* if_icmpne */, 0/* if_icmplt */, 0/* if_icmpge */, 0/* if_icmpgt */, 0/* if_icmple */, 0/* if_acmpeq */,
+        0/* if_acmpne */, 0/* goto */, 1/* jsr */, 0/* ret */, 0/* tableswitch */, 0/* lookupswitch */, 0/* ireturn */, 0/* lreturn */, 0/* freturn */,
+        0/* dreturn */, 0/* areturn */, 0/* return */, UNPREDICTABLE/* getstatic */, 0/* putstatic */, UNPREDICTABLE/* getfield */, 0/* putfield */,
+        UNPREDICTABLE/* invokevirtual */, UNPREDICTABLE/* invokespecial */, UNPREDICTABLE/* invokestatic */, UNPREDICTABLE/* invokeinterface */,
+        UNPREDICTABLE/* invokedynamic */, 1/* new */, 1/* newarray */, 1/* anewarray */, 1/* arraylength */, 1/* athrow */, 1/* checkcast */, 1/* instanceof */,
+        0/* monitorenter */, 0/* monitorexit */, 0/* wide */, 1/* multianewarray */, 0/* ifnull */, 0/* ifnonnull */, 0/* goto_w */, 1/* jsr_w */,
+        0/* breakpoint */, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
+        UNPREDICTABLE/* impdep1 */, UNPREDICTABLE/* impdep2 */
+    };
+
+    /**
+     * Attributes and their corresponding names.
+     */
+    public static final byte ATTR_UNKNOWN = -1;
+
+    public static final byte ATTR_SOURCE_FILE = 0;
+
+    public static final byte ATTR_CONSTANT_VALUE = 1;
+
+    public static final byte ATTR_CODE = 2;
+
+    public static final byte ATTR_EXCEPTIONS = 3;
+
+    public static final byte ATTR_LINE_NUMBER_TABLE = 4;
+
+    public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5;
+
+    public static final byte ATTR_INNER_CLASSES = 6;
+
+    public static final byte ATTR_SYNTHETIC = 7;
+
+    public static final byte ATTR_DEPRECATED = 8;
+
+    public static final byte ATTR_PMG = 9;
+
+    public static final byte ATTR_SIGNATURE = 10;
+
+    public static final byte ATTR_STACK_MAP = 11;
+    public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS = 12;
+    public static final byte ATTR_RUNTIME_INVISIBLE_ANNOTATIONS = 13;
+    public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = 14;
+    public static final byte ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = 15;
+    public static final byte ATTR_ANNOTATION_DEFAULT = 16;
+    public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE = 17;
+    public static final byte ATTR_ENCLOSING_METHOD = 18;
+    public static final byte ATTR_STACK_MAP_TABLE = 19;
+    public static final byte ATTR_BOOTSTRAP_METHODS = 20;
+    public static final byte ATTR_METHOD_PARAMETERS = 21;
+    public static final byte ATTR_MODULE = 22;
+    public static final byte ATTR_MODULE_PACKAGES = 23;
+    public static final byte ATTR_MODULE_MAIN_CLASS = 24;
+    public static final byte ATTR_NEST_HOST = 25;
+    public static final byte ATTR_NEST_MEMBERS = 26;
+    public static final short KNOWN_ATTRIBUTES = 27; // count of attributes
+    private static final String[] ATTRIBUTE_NAMES = {"SourceFile", "ConstantValue", "Code", "Exceptions", "LineNumberTable", "LocalVariableTable",
+        "InnerClasses", "Synthetic", "Deprecated", "PMGClass", "Signature", "StackMap", "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
+        "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations", "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod",
+        "StackMapTable", "BootstrapMethods", "MethodParameters", "Module", "ModulePackages", "ModuleMainClass", "NestHost", "NestMembers"};
+    /**
+     * Constants used in the StackMap attribute.
+     */
+    public static final byte ITEM_Bogus = 0;
+    public static final byte ITEM_Integer = 1;
+    public static final byte ITEM_Float = 2;
+    public static final byte ITEM_Double = 3;
+    public static final byte ITEM_Long = 4;
+    public static final byte ITEM_Null = 5;
+    public static final byte ITEM_InitObject = 6;
+    public static final byte ITEM_Object = 7;
+    public static final byte ITEM_NewObject = 8;
+    private static final String[] ITEM_NAMES = {"Bogus", "Integer", "Float", "Double", "Long", "Null", "InitObject", "Object", "NewObject"};
+
+    /**
+     * Constants used to identify StackMapEntry types.
+     *
+     * For those types which can specify a range, the constant names the lowest value.
+     */
+    public static final int SAME_FRAME = 0;
+
+    public static final int SAME_LOCALS_1_STACK_ITEM_FRAME = 64;
+
+    public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED = 247;
+
+    public static final int CHOP_FRAME = 248;
+    public static final int SAME_FRAME_EXTENDED = 251;
+    public static final int APPEND_FRAME = 252;
+    public static final int FULL_FRAME = 255;
+    /**
+     * Constants that define the maximum value of those constants which store ranges.
+     */
+
+    public static final int SAME_FRAME_MAX = 63;
+    public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_MAX = 127;
+    public static final int CHOP_FRAME_MAX = 250;
+    public static final int APPEND_FRAME_MAX = 254;
+    public static final byte REF_getField = 1;
+
+    public static final byte REF_getStatic = 2;
+
+    public static final byte REF_putField = 3;
+
+    public static final byte REF_putStatic = 4;
+    public static final byte REF_invokeVirtual = 5;
+    public static final byte REF_invokeStatic = 6;
+    public static final byte REF_invokeSpecial = 7;
+    public static final byte REF_newInvokeSpecial = 8;
+    public static final byte REF_invokeInterface = 9;
+    /**
+     * The names of the reference_kinds of a CONSTANT_MethodHandle_info.
+     */
+    private static final String[] METHODHANDLE_NAMES = {"", "getField", "getStatic", "putField", "putStatic", "invokeVirtual", "invokeStatic", "invokeSpecial",
+        "newInvokeSpecial", "invokeInterface"};
+
+    /**
+     * @param index
+     * @return the ACCESS_NAMES entry at the given index
+     * @since 6.0
+     */
+    public static String getAccessName(final int index) {
+        return ACCESS_NAMES[index];
+    }
+
+    /**
+     *
+     * @param index
+     * @return the attribute name
+     * @since 6.0
+     */
+    public static String getAttributeName(final int index) {
+        return ATTRIBUTE_NAMES[index];
+    }
+
+    /**
+     * The primitive class names corresponding to the T_XX constants, e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
+     *
+     * @param index
+     * @return the class name
+     * @since 6.0
+     */
+    public static String getClassTypeName(final int index) {
+        return CLASS_TYPE_NAMES[index];
+    }
+
+    /**
+     *
+     * @param index
+     * @return the CONSTANT_NAMES entry at the given index
+     * @since 6.0
+     */
+    public static String getConstantName(final int index) {
+        return CONSTANT_NAMES[index];
+    }
+
+    // Constants defining the behavior of the Method Handles (JVMS 5.4.3.5)
+
+    /**
+     *
+     * @param index
+     * @return Number of words consumed on operand stack
+     * @since 6.0
+     */
+    public static int getConsumeStack(final int index) {
+        return CONSUME_STACK[index];
+    }
+
+    /**
+     * @since 6.0
+     */
+    public static Iterable<String> getInterfacesImplementedByArrays() {
+        return Collections.unmodifiableList(Arrays.asList(INTERFACES_IMPLEMENTED_BY_ARRAYS));
+    }
+
+    /**
+     *
+     * @param index
+     * @return the item name
+     * @since 6.0
+     */
+    public static String getItemName(final int index) {
+        return ITEM_NAMES[index];
+    }
+
+    /**
+     *
+     * @param index
+     * @return the method handle name
+     * @since 6.0
+     */
+    public static String getMethodHandleName(final int index) {
+        return METHODHANDLE_NAMES[index];
+    }
+
+    /**
+     *
+     * @param index
+     * @return Number of byte code operands
+     * @since 6.0
+     */
+    public static short getNoOfOperands(final int index) {
+        return NO_OF_OPERANDS[index];
+    }
+
+    /**
+     * @since 6.0
+     */
+    public static String getOpcodeName(final int index) {
+        return OPCODE_NAMES[index];
+    }
+
+    /**
+     * @since 6.0
+     */
+    public static short getOperandType(final int opcode, final int index) {
+        return TYPE_OF_OPERANDS[opcode][index];
+    }
+
+    /**
+     * @since 6.0
+     */
+    public static long getOperandTypeCount(final int opcode) {
+        return TYPE_OF_OPERANDS[opcode].length;
+    }
+
+    /**
+     *
+     * @param index
+     * @return Number of words produced onto operand stack
+     * @since 6.0
+     */
+    public static int getProduceStack(final int index) {
+        return PRODUCE_STACK[index];
+    }
+
+    /**
+     *
+     * @param index
+     * @return the short type name
+     * @since 6.0
+     */
+    public static String getShortTypeName(final int index) {
+        return SHORT_TYPE_NAMES[index];
+    }
+
+    /**
+     * The primitive type names corresponding to the T_XX constants, e.g., TYPE_NAMES[T_INT] = "int"
+     *
+     * @param index
+     * @return the type name
+     * @since 6.0
+     */
+    public static String getTypeName(final int index) {
+        return TYPE_NAMES[index];
+    }
+
+    private Const() {
+    } // not instantiable
 
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java
index 2da7e1248dc..d45c5794b7b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/ExceptionConst.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,13 +20,24 @@
 
 package com.sun.org.apache.bcel.internal;
 
+import jdk.xml.internal.Utils;
+
 /**
  * Exception constants.
+ *
  * @since 6.0 (intended to replace the InstructionConstant interface)
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public final class ExceptionConst {
 
+    /**
+     * Enum corresponding to the various Exception Class arrays, used by
+     * {@link ExceptionConst#createExceptions(EXCS, Class...)}
+     */
+    public enum EXCS {
+        EXCS_CLASS_AND_INTERFACE_RESOLUTION, EXCS_FIELD_AND_METHOD_RESOLUTION, EXCS_INTERFACE_METHOD_RESOLUTION, EXCS_STRING_RESOLUTION, EXCS_ARRAY_EXCEPTION,
+    }
+
     /**
      * The mother of all exceptions
      */
@@ -64,61 +75,41 @@ public final class ExceptionConst {
      * Run-Time Exceptions
      */
     public static final Class<NullPointerException> NULL_POINTER_EXCEPTION = NullPointerException.class;
-    public static final Class<ArrayIndexOutOfBoundsException> ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION
-                                                            = ArrayIndexOutOfBoundsException.class;
+    public static final Class<ArrayIndexOutOfBoundsException> ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class;
     public static final Class<ArithmeticException> ARITHMETIC_EXCEPTION = ArithmeticException.class;
     public static final Class<NegativeArraySizeException> NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class;
     public static final Class<ClassCastException> CLASS_CAST_EXCEPTION = ClassCastException.class;
+
     public static final Class<IllegalMonitorStateException> ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class;
+    /**
+     * Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual Machine Specification
+     */
+    private static final Class<?>[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR,
+        EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR}; // Chapter 5.1
+
+    private static final Class<?>[] EXCS_FIELD_AND_METHOD_RESOLUTION = {NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR}; // Chapter 5.2
 
     /**
-     * Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual
-     * Machine Specification
+     * Empty array.
      */
-    private static final Class<?>[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {
-            NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR,
-            EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR
-    }; // Chapter 5.1
-    private static final Class<?>[] EXCS_FIELD_AND_METHOD_RESOLUTION = {
-            NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR
-    }; // Chapter 5.2
     private static final Class<?>[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class<?>[0]; // Chapter 5.3 (as below)
-    private static final Class<?>[] EXCS_STRING_RESOLUTION = new Class<?>[0];
-    // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.)
-    private static final Class<?>[] EXCS_ARRAY_EXCEPTION = {
-            NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION
-    };
 
     /**
-     * Enum corresponding to the various Exception Class arrays,
-     * used by {@link ExceptionConst#createExceptions(EXCS, Class...)}
+     * Empty array.
      */
-    public enum EXCS {
-        EXCS_CLASS_AND_INTERFACE_RESOLUTION,
-        EXCS_FIELD_AND_METHOD_RESOLUTION,
-        EXCS_INTERFACE_METHOD_RESOLUTION,
-        EXCS_STRING_RESOLUTION,
-        EXCS_ARRAY_EXCEPTION,
-    }
+    private static final Class<?>[] EXCS_STRING_RESOLUTION = new Class<?>[0];
 
-    // helper method to merge exception class arrays
-    private static Class<?>[] mergeExceptions(final Class<?>[] input, final Class<?> ... extraClasses) {
-        final int extraLen = extraClasses == null ? 0 : extraClasses.length;
-        final Class<?>[] excs = new Class<?>[input.length + extraLen];
-        System.arraycopy(input, 0, excs, 0, input.length);
-        if (extraLen > 0) {
-            System.arraycopy(extraClasses, 0, excs, input.length, extraLen);
-        }
-        return excs;
-    }
+    // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.)
+    private static final Class<?>[] EXCS_ARRAY_EXCEPTION = {NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION};
 
     /**
      * Creates a copy of the specified Exception Class array combined with any additional Exception classes.
+     *
      * @param type the basic array type
      * @param extraClasses additional classes, if any
      * @return the merged array
      */
-    public static Class<?>[] createExceptions(final EXCS type, final Class<?> ... extraClasses) {
+    public static Class<?>[] createExceptions(final EXCS type, final Class<?>... extraClasses) {
         switch (type) {
         case EXCS_CLASS_AND_INTERFACE_RESOLUTION:
             return mergeExceptions(EXCS_CLASS_AND_INTERFACE_RESOLUTION, extraClasses);
@@ -135,5 +126,8 @@ public static Class<?>[] createExceptions(final EXCS type, final Class<?> ... ex
         }
     }
 
-
+    // helper method to merge exception class arrays
+    private static Class<?>[] mergeExceptions(final Class<?>[] input, final Class<?>... extraClasses) {
+        return Utils.arraysAppend(input, extraClasses);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Repository.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Repository.java
index 4b419f399a6..d36260cc23a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Repository.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/Repository.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,227 +24,183 @@
 import com.sun.org.apache.bcel.internal.util.SyntheticRepository;
 
 /**
- * The repository maintains informations about class interdependencies, e.g.,
- * whether a class is a sub-class of another. Delegates actual class loading
- * to SyntheticRepository with current class path by default.
+ * The repository maintains informations about class interdependencies, e.g., whether a class is a sub-class of another.
+ * Delegates actual class loading to SyntheticRepository with current class path by default.
  *
  * @see com.sun.org.apache.bcel.internal.util.Repository
  * @see SyntheticRepository
  *
- * @LastModified: Jan 2020
+ * @LastModified: Feb 2023
  */
 public abstract class Repository {
 
-    private static com.sun.org.apache.bcel.internal.util.Repository repository
-            = SyntheticRepository.getInstance();
-
+    private static com.sun.org.apache.bcel.internal.util.Repository repository = SyntheticRepository.getInstance();
 
     /**
-     * @return currently used repository instance
+     * Adds clazz to repository if there isn't an equally named class already in there.
+     *
+     * @return old entry in repository
      */
-    public static com.sun.org.apache.bcel.internal.util.Repository getRepository() {
-        return repository;
+    public static JavaClass addClass(final JavaClass clazz) {
+        final JavaClass old = repository.findClass(clazz.getClassName());
+        repository.storeClass(clazz);
+        return old;
     }
 
-
     /**
-     * Sets repository instance to be used for class loading
+     * Clears the repository.
      */
-    public static void setRepository( final com.sun.org.apache.bcel.internal.util.Repository rep ) {
-        repository = rep;
+    public static void clearCache() {
+        repository.clear();
     }
 
-
     /**
-     * Lookups class somewhere found on your CLASSPATH, or whereever the
-     * repository instance looks for it.
-     *
-     * @return class object for given fully qualified class name
-     * @throws ClassNotFoundException if the class could not be found or
-     * parsed correctly
+     * @return all interfaces implemented by class and its super classes and the interfaces that those interfaces extend,
+     *         and so on. (Some people call this a transitive hull).
+     * @throws ClassNotFoundException if any of the class's superclasses or superinterfaces can't be found
      */
-    public static JavaClass lookupClass( final String class_name ) throws ClassNotFoundException {
-        return repository.loadClass(class_name);
+    public static JavaClass[] getInterfaces(final JavaClass clazz) throws ClassNotFoundException {
+        return clazz.getAllInterfaces();
     }
 
-
     /**
-     * Tries to find class source using the internal repository instance.
-     *
-     * @see Class
-     * @return JavaClass object for given runtime class
-     * @throws ClassNotFoundException if the class could not be found or
-     * parsed correctly
+     * @return all interfaces implemented by class and its super classes and the interfaces that extend those interfaces,
+     *         and so on
+     * @throws ClassNotFoundException if the named class can't be found, or if any of its superclasses or superinterfaces
+     *         can't be found
      */
-    public static JavaClass lookupClass( final Class<?> clazz ) throws ClassNotFoundException {
-        return repository.loadClass(clazz);
+    public static JavaClass[] getInterfaces(final String className) throws ClassNotFoundException {
+        return getInterfaces(lookupClass(className));
     }
 
-
     /**
-     * Clear the repository.
+     * @return currently used repository instance
      */
-    public static void clearCache() {
-        repository.clear();
+    public static com.sun.org.apache.bcel.internal.util.Repository getRepository() {
+        return repository;
     }
 
-
     /**
-     * Adds clazz to repository if there isn't an equally named class already in there.
-     *
-     * @return old entry in repository
+     * @return list of super classes of clazz in ascending order, i.e., Object is always the last element
+     * @throws ClassNotFoundException if any of the superclasses can't be found
      */
-    public static JavaClass addClass( final JavaClass clazz ) {
-        final JavaClass old = repository.findClass(clazz.getClassName());
-        repository.storeClass(clazz);
-        return old;
+    public static JavaClass[] getSuperClasses(final JavaClass clazz) throws ClassNotFoundException {
+        return clazz.getSuperClasses();
     }
 
-
     /**
-     * Removes class with given (fully qualified) name from repository.
+     * @return list of super classes of clazz in ascending order, i.e., Object is always the last element.
+     * @throws ClassNotFoundException if the named class or any of its superclasses can't be found
      */
-    public static void removeClass( final String clazz ) {
-        repository.removeClass(repository.findClass(clazz));
+    public static JavaClass[] getSuperClasses(final String className) throws ClassNotFoundException {
+        return getSuperClasses(lookupClass(className));
     }
 
-
     /**
-     * Removes given class from repository.
+     * @return true, if clazz is an implementation of interface inter
+     * @throws ClassNotFoundException if any superclasses or superinterfaces of clazz can't be found
      */
-    public static void removeClass( final JavaClass clazz ) {
-        repository.removeClass(clazz);
+    public static boolean implementationOf(final JavaClass clazz, final JavaClass inter) throws ClassNotFoundException {
+        return clazz.implementationOf(inter);
     }
 
-
     /**
-     * @return list of super classes of clazz in ascending order, i.e.,
-     * Object is always the last element
-     * @throws ClassNotFoundException if any of the superclasses can't be found
+     * @return true, if clazz is an implementation of interface inter
+     * @throws ClassNotFoundException if inter or any superclasses or superinterfaces of clazz can't be found
      */
-    public static JavaClass[] getSuperClasses( final JavaClass clazz ) throws ClassNotFoundException {
-        return clazz.getSuperClasses();
+    public static boolean implementationOf(final JavaClass clazz, final String inter) throws ClassNotFoundException {
+        return implementationOf(clazz, lookupClass(inter));
     }
 
-
     /**
-     * @return list of super classes of clazz in ascending order, i.e.,
-     * Object is always the last element.
-     * @throws ClassNotFoundException if the named class or any of its
-     *  superclasses can't be found
+     * @return true, if clazz is an implementation of interface inter
+     * @throws ClassNotFoundException if clazz or any superclasses or superinterfaces of clazz can't be found
      */
-    public static JavaClass[] getSuperClasses( final String class_name ) throws ClassNotFoundException {
-        final JavaClass jc = lookupClass(class_name);
-        return getSuperClasses(jc);
+    public static boolean implementationOf(final String clazz, final JavaClass inter) throws ClassNotFoundException {
+        return implementationOf(lookupClass(clazz), inter);
     }
 
-
     /**
-     * @return all interfaces implemented by class and its super
-     * classes and the interfaces that those interfaces extend, and so on.
-     * (Some people call this a transitive hull).
-     * @throws ClassNotFoundException if any of the class's
-     *  superclasses or superinterfaces can't be found
+     * @return true, if clazz is an implementation of interface inter
+     * @throws ClassNotFoundException if clazz, inter, or any superclasses or superinterfaces of clazz can't be found
      */
-    public static JavaClass[] getInterfaces( final JavaClass clazz ) throws ClassNotFoundException {
-        return clazz.getAllInterfaces();
+    public static boolean implementationOf(final String clazz, final String inter) throws ClassNotFoundException {
+        return implementationOf(lookupClass(clazz), lookupClass(inter));
     }
 
-
     /**
-     * @return all interfaces implemented by class and its super
-     * classes and the interfaces that extend those interfaces, and so on
-     * @throws ClassNotFoundException if the named class can't be found,
-     *   or if any of its superclasses or superinterfaces can't be found
+     * Equivalent to runtime "instanceof" operator.
+     *
+     * @return true, if clazz is an instance of superclass
+     * @throws ClassNotFoundException if any superclasses or superinterfaces of clazz can't be found
      */
-    public static JavaClass[] getInterfaces( final String class_name ) throws ClassNotFoundException {
-        return getInterfaces(lookupClass(class_name));
+    public static boolean instanceOf(final JavaClass clazz, final JavaClass superclass) throws ClassNotFoundException {
+        return clazz.instanceOf(superclass);
     }
 
-
     /**
-     * Equivalent to runtime "instanceof" operator.
-     * @return true, if clazz is an instance of super_class
-     * @throws ClassNotFoundException if any superclasses or superinterfaces
-     *   of clazz can't be found
+     * @return true, if clazz is an instance of superclass
+     * @throws ClassNotFoundException if superclass can't be found
      */
-    public static boolean instanceOf( final JavaClass clazz, final JavaClass super_class )
-            throws ClassNotFoundException {
-        return clazz.instanceOf(super_class);
+    public static boolean instanceOf(final JavaClass clazz, final String superclass) throws ClassNotFoundException {
+        return instanceOf(clazz, lookupClass(superclass));
     }
 
-
     /**
-     * @return true, if clazz is an instance of super_class
-     * @throws ClassNotFoundException if either clazz or super_class
-     *   can't be found
+     * @return true, if clazz is an instance of superclass
+     * @throws ClassNotFoundException if clazz can't be found
      */
-    public static boolean instanceOf( final String clazz, final String super_class )
-            throws ClassNotFoundException {
-        return instanceOf(lookupClass(clazz), lookupClass(super_class));
+    public static boolean instanceOf(final String clazz, final JavaClass superclass) throws ClassNotFoundException {
+        return instanceOf(lookupClass(clazz), superclass);
     }
 
-
     /**
-     * @return true, if clazz is an instance of super_class
-     * @throws ClassNotFoundException if super_class can't be found
+     * @return true, if clazz is an instance of superclass
+     * @throws ClassNotFoundException if either clazz or superclass can't be found
      */
-    public static boolean instanceOf( final JavaClass clazz, final String super_class )
-            throws ClassNotFoundException {
-        return instanceOf(clazz, lookupClass(super_class));
+    public static boolean instanceOf(final String clazz, final String superclass) throws ClassNotFoundException {
+        return instanceOf(lookupClass(clazz), lookupClass(superclass));
     }
 
-
     /**
-     * @return true, if clazz is an instance of super_class
-     * @throws ClassNotFoundException if clazz can't be found
+     * Tries to find class source using the internal repository instance.
+     *
+     * @see Class
+     * @return JavaClass object for given runtime class
+     * @throws ClassNotFoundException if the class could not be found or parsed correctly
      */
-    public static boolean instanceOf( final String clazz, final JavaClass super_class )
-            throws ClassNotFoundException {
-        return instanceOf(lookupClass(clazz), super_class);
+    public static JavaClass lookupClass(final Class<?> clazz) throws ClassNotFoundException {
+        return repository.loadClass(clazz);
     }
 
-
     /**
-     * @return true, if clazz is an implementation of interface inter
-     * @throws ClassNotFoundException if any superclasses or superinterfaces
-     *   of clazz can't be found
+     * Lookups class somewhere found on your CLASSPATH, or wherever the repository instance looks for it.
+     *
+     * @return class object for given fully qualified class name
+     * @throws ClassNotFoundException if the class could not be found or parsed correctly
      */
-    public static boolean implementationOf( final JavaClass clazz, final JavaClass inter )
-            throws ClassNotFoundException {
-        return clazz.implementationOf(inter);
+    public static JavaClass lookupClass(final String className) throws ClassNotFoundException {
+        return repository.loadClass(className);
     }
 
-
     /**
-     * @return true, if clazz is an implementation of interface inter
-     * @throws ClassNotFoundException if clazz, inter, or any superclasses
-     *   or superinterfaces of clazz can't be found
+     * Removes given class from repository.
      */
-    public static boolean implementationOf( final String clazz, final String inter )
-            throws ClassNotFoundException {
-        return implementationOf(lookupClass(clazz), lookupClass(inter));
+    public static void removeClass(final JavaClass clazz) {
+        repository.removeClass(clazz);
     }
 
-
     /**
-     * @return true, if clazz is an implementation of interface inter
-     * @throws ClassNotFoundException if inter or any superclasses
-     *   or superinterfaces of clazz can't be found
+     * Removes class with given (fully qualified) name from repository.
      */
-    public static boolean implementationOf( final JavaClass clazz, final String inter )
-            throws ClassNotFoundException {
-        return implementationOf(clazz, lookupClass(inter));
+    public static void removeClass(final String clazz) {
+        repository.removeClass(repository.findClass(clazz));
     }
 
-
     /**
-     * @return true, if clazz is an implementation of interface inter
-     * @throws ClassNotFoundException if clazz or any superclasses or
-     *   superinterfaces of clazz can't be found
+     * Sets repository instance to be used for class loading
      */
-    public static boolean implementationOf( final String clazz, final JavaClass inter )
-            throws ClassNotFoundException {
-        return implementationOf(lookupClass(clazz), inter);
+    public static void setRepository(final com.sun.org.apache.bcel.internal.util.Repository rep) {
+        repository = rep;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java
index a6e086a97a9..61ec9c4d690 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java
@@ -29,14 +29,17 @@
  */
 public abstract class AccessFlags {
 
-    private int access_flags;
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected int access_flags; // TODO not used externally at present
 
     public AccessFlags() {
     }
 
     /**
-     * @param a
-     *            inital access flags
+     * @param a initial access flags
      */
     public AccessFlags(final int a) {
         access_flags = a;
@@ -56,163 +59,159 @@ public final int getModifiers() {
         return access_flags;
     }
 
-    /**
-     * Set access flags aka "modifiers".
-     *
-     * @param access_flags
-     *            Access flags of the object.
-     */
-    public final void setAccessFlags(final int access_flags) {
-        this.access_flags = access_flags;
-    }
-
-    /**
-     * Set access flags aka "modifiers".
-     *
-     * @param access_flags
-     *            Access flags of the object.
-     */
-    public final void setModifiers(final int access_flags) {
-        setAccessFlags(access_flags);
-    }
-
-    private void setFlag(final int flag, final boolean set) {
-        if ((access_flags & flag) != 0) { // Flag is set already
-            if (!set) {
-                access_flags ^= flag;
-            }
-        } else { // Flag not set
-            if (set) {
-                access_flags |= flag;
-            }
-        }
-    }
-
-    public final void isPublic(final boolean flag) {
-        setFlag(Const.ACC_PUBLIC, flag);
-    }
-
-    public final boolean isPublic() {
-        return (access_flags & Const.ACC_PUBLIC) != 0;
+    public final boolean isAbstract() {
+        return (access_flags & Const.ACC_ABSTRACT) != 0;
     }
 
-    public final void isPrivate(final boolean flag) {
-        setFlag(Const.ACC_PRIVATE, flag);
+    public final void isAbstract(final boolean flag) {
+        setFlag(Const.ACC_ABSTRACT, flag);
     }
 
-    public final boolean isPrivate() {
-        return (access_flags & Const.ACC_PRIVATE) != 0;
+    public final boolean isAnnotation() {
+        return (access_flags & Const.ACC_ANNOTATION) != 0;
     }
 
-    public final void isProtected(final boolean flag) {
-        setFlag(Const.ACC_PROTECTED, flag);
+    public final void isAnnotation(final boolean flag) {
+        setFlag(Const.ACC_ANNOTATION, flag);
     }
 
-    public final boolean isProtected() {
-        return (access_flags & Const.ACC_PROTECTED) != 0;
+    public final boolean isEnum() {
+        return (access_flags & Const.ACC_ENUM) != 0;
     }
 
-    public final void isStatic(final boolean flag) {
-        setFlag(Const.ACC_STATIC, flag);
+    public final void isEnum(final boolean flag) {
+        setFlag(Const.ACC_ENUM, flag);
     }
 
-    public final boolean isStatic() {
-        return (access_flags & Const.ACC_STATIC) != 0;
+    public final boolean isFinal() {
+        return (access_flags & Const.ACC_FINAL) != 0;
     }
 
     public final void isFinal(final boolean flag) {
         setFlag(Const.ACC_FINAL, flag);
     }
 
-    public final boolean isFinal() {
-        return (access_flags & Const.ACC_FINAL) != 0;
+    public final boolean isInterface() {
+        return (access_flags & Const.ACC_INTERFACE) != 0;
     }
 
-    public final void isSynchronized(final boolean flag) {
-        setFlag(Const.ACC_SYNCHRONIZED, flag);
+    public final void isInterface(final boolean flag) {
+        setFlag(Const.ACC_INTERFACE, flag);
     }
 
-    public final boolean isSynchronized() {
-        return (access_flags & Const.ACC_SYNCHRONIZED) != 0;
+    public final boolean isNative() {
+        return (access_flags & Const.ACC_NATIVE) != 0;
     }
 
-    public final void isVolatile(final boolean flag) {
-        setFlag(Const.ACC_VOLATILE, flag);
+    public final void isNative(final boolean flag) {
+        setFlag(Const.ACC_NATIVE, flag);
     }
 
-    public final boolean isVolatile() {
-        return (access_flags & Const.ACC_VOLATILE) != 0;
+    public final boolean isPrivate() {
+        return (access_flags & Const.ACC_PRIVATE) != 0;
     }
 
-    public final void isTransient(final boolean flag) {
-        setFlag(Const.ACC_TRANSIENT, flag);
+    public final void isPrivate(final boolean flag) {
+        setFlag(Const.ACC_PRIVATE, flag);
     }
 
-    public final boolean isTransient() {
-        return (access_flags & Const.ACC_TRANSIENT) != 0;
+    public final boolean isProtected() {
+        return (access_flags & Const.ACC_PROTECTED) != 0;
     }
 
-    public final void isNative(final boolean flag) {
-        setFlag(Const.ACC_NATIVE, flag);
+    public final void isProtected(final boolean flag) {
+        setFlag(Const.ACC_PROTECTED, flag);
     }
 
-    public final boolean isNative() {
-        return (access_flags & Const.ACC_NATIVE) != 0;
+    public final boolean isPublic() {
+        return (access_flags & Const.ACC_PUBLIC) != 0;
     }
 
-    public final void isInterface(final boolean flag) {
-        setFlag(Const.ACC_INTERFACE, flag);
+    public final void isPublic(final boolean flag) {
+        setFlag(Const.ACC_PUBLIC, flag);
     }
 
-    public final boolean isInterface() {
-        return (access_flags & Const.ACC_INTERFACE) != 0;
+    public final boolean isStatic() {
+        return (access_flags & Const.ACC_STATIC) != 0;
     }
 
-    public final void isAbstract(final boolean flag) {
-        setFlag(Const.ACC_ABSTRACT, flag);
+    public final void isStatic(final boolean flag) {
+        setFlag(Const.ACC_STATIC, flag);
     }
 
-    public final boolean isAbstract() {
-        return (access_flags & Const.ACC_ABSTRACT) != 0;
+    public final boolean isStrictfp() {
+        return (access_flags & Const.ACC_STRICT) != 0;
     }
 
     public final void isStrictfp(final boolean flag) {
         setFlag(Const.ACC_STRICT, flag);
     }
 
-    public final boolean isStrictfp() {
-        return (access_flags & Const.ACC_STRICT) != 0;
+    public final boolean isSynchronized() {
+        return (access_flags & Const.ACC_SYNCHRONIZED) != 0;
     }
 
-    public final void isSynthetic(final boolean flag) {
-        setFlag(Const.ACC_SYNTHETIC, flag);
+    public final void isSynchronized(final boolean flag) {
+        setFlag(Const.ACC_SYNCHRONIZED, flag);
     }
 
     public final boolean isSynthetic() {
         return (access_flags & Const.ACC_SYNTHETIC) != 0;
     }
 
-    public final void isAnnotation(final boolean flag) {
-        setFlag(Const.ACC_ANNOTATION, flag);
+    public final void isSynthetic(final boolean flag) {
+        setFlag(Const.ACC_SYNTHETIC, flag);
     }
 
-    public final boolean isAnnotation() {
-        return (access_flags & Const.ACC_ANNOTATION) != 0;
+    public final boolean isTransient() {
+        return (access_flags & Const.ACC_TRANSIENT) != 0;
     }
 
-    public final void isEnum(final boolean flag) {
-        setFlag(Const.ACC_ENUM, flag);
+    public final void isTransient(final boolean flag) {
+        setFlag(Const.ACC_TRANSIENT, flag);
     }
 
-    public final boolean isEnum() {
-        return (access_flags & Const.ACC_ENUM) != 0;
+    public final boolean isVarArgs() {
+        return (access_flags & Const.ACC_VARARGS) != 0;
     }
 
     public final void isVarArgs(final boolean flag) {
         setFlag(Const.ACC_VARARGS, flag);
     }
 
-    public final boolean isVarArgs() {
-        return (access_flags & Const.ACC_VARARGS) != 0;
+    public final boolean isVolatile() {
+        return (access_flags & Const.ACC_VOLATILE) != 0;
+    }
+
+    public final void isVolatile(final boolean flag) {
+        setFlag(Const.ACC_VOLATILE, flag);
+    }
+
+    /**
+     * Set access flags aka "modifiers".
+     *
+     * @param accessFlags Access flags of the object.
+     */
+    public final void setAccessFlags(final int accessFlags) {
+        this.access_flags = accessFlags;
+    }
+
+    private void setFlag(final int flag, final boolean set) {
+        if ((access_flags & flag) != 0) { // Flag is set already
+            if (!set) {
+                access_flags ^= flag;
+            }
+        } else if (set) {
+            access_flags |= flag;
+        }
+    }
+
+    /**
+     * Set access flags aka "modifiers".
+     *
+     * @param accessFlags Access flags of the object.
+     */
+    public final void setModifiers(final int accessFlags) {
+        setAccessFlags(accessFlags);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java
index dc9c8ca47ba..40bbfb6eae0 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationDefault.java
@@ -28,7 +28,7 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * Represents the default value of a annotation for a method info
+ * Represents the default value of a annotation for a method info.
  *
  * @since 6.0
  */
@@ -37,31 +37,30 @@ public class AnnotationDefault extends Attribute {
     private ElementValue defaultValue;
 
     /**
-     * @param name_index    Index pointing to the name <em>Code</em>
-     * @param length        Content length in bytes
-     * @param input         Input stream
-     * @param constant_pool Array of constants
+     * @param nameIndex Index pointing to the name <em>Code</em>
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
      */
-    AnnotationDefault(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        this(name_index, length, (ElementValue) null, constant_pool);
-        defaultValue = ElementValue.readElementValue(input, constant_pool);
+    AnnotationDefault(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (ElementValue) null, constantPool);
+        defaultValue = ElementValue.readElementValue(input, constantPool);
     }
 
     /**
-     * @param name_index    Index pointing to the name <em>Code</em>
-     * @param length        Content length in bytes
-     * @param defaultValue  the annotation's default value
-     * @param constant_pool Array of constants
+     * @param nameIndex Index pointing to the name <em>Code</em>
+     * @param length Content length in bytes
+     * @param defaultValue the annotation's default value
+     * @param constantPool Array of constants
      */
-    public AnnotationDefault(final int name_index, final int length, final ElementValue defaultValue, final ConstantPool constant_pool) {
-        super(Const.ATTR_ANNOTATION_DEFAULT, name_index, length, constant_pool);
+    public AnnotationDefault(final int nameIndex, final int length, final ElementValue defaultValue, final ConstantPool constantPool) {
+        super(Const.ATTR_ANNOTATION_DEFAULT, nameIndex, length, constantPool);
         this.defaultValue = defaultValue;
     }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
@@ -70,11 +69,15 @@ public void accept(final Visitor v) {
         v.visitAnnotationDefault(this);
     }
 
-    /**
-     * @param defaultValue the default value of this methodinfo's annotation
-     */
-    public final void setDefaultValue(final ElementValue defaultValue) {
-        this.defaultValue = defaultValue;
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        return (Attribute) clone();
+    }
+
+    @Override
+    public final void dump(final DataOutputStream dos) throws IOException {
+        super.dump(dos);
+        defaultValue.dump(dos);
     }
 
     /**
@@ -84,14 +87,10 @@ public final ElementValue getDefaultValue() {
         return defaultValue;
     }
 
-    @Override
-    public Attribute copy(final ConstantPool _constant_pool) {
-        return (Attribute) clone();
-    }
-
-    @Override
-    public final void dump(final DataOutputStream dos) throws IOException {
-        super.dump(dos);
-        defaultValue.dump(dos);
+    /**
+     * @param defaultValue the default value of this methodinfo's annotation
+     */
+    public final void setDefaultValue(final ElementValue defaultValue) {
+        this.defaultValue = defaultValue;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java
index 79c7b25a266..8d618258d53 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.java
@@ -27,43 +27,35 @@
 /**
  * @since 6.0
  */
-public class AnnotationElementValue extends ElementValue
-{
-        // For annotation element values, this is the annotation
-        private final AnnotationEntry annotationEntry;
-
-        public AnnotationElementValue(final int type, final AnnotationEntry annotationEntry,
-                        final ConstantPool cpool)
-        {
-                super(type, cpool);
-                if (type != ANNOTATION) {
-                    throw new IllegalArgumentException(
-                                    "Only element values of type annotation can be built with this ctor - type specified: " + type);
-                }
-                this.annotationEntry = annotationEntry;
-        }
-
-        @Override
-        public void dump(final DataOutputStream dos) throws IOException
-        {
-                dos.writeByte(super.getType()); // u1 type of value (ANNOTATION == '@')
-                annotationEntry.dump(dos);
-        }
-
-        @Override
-        public String stringifyValue()
-        {
-                return annotationEntry.toString();
-        }
-
-        @Override
-        public String toString()
-        {
-                return stringifyValue();
-        }
-
-        public AnnotationEntry getAnnotationEntry()
-        {
-                return annotationEntry;
+public class AnnotationElementValue extends ElementValue {
+    // For annotation element values, this is the annotation
+    private final AnnotationEntry annotationEntry;
+
+    public AnnotationElementValue(final int type, final AnnotationEntry annotationEntry, final ConstantPool cpool) {
+        super(type, cpool);
+        if (type != ANNOTATION) {
+            throw new ClassFormatException("Only element values of type annotation can be built with this ctor - type specified: " + type);
         }
+        this.annotationEntry = annotationEntry;
+    }
+
+    @Override
+    public void dump(final DataOutputStream dos) throws IOException {
+        dos.writeByte(super.getType()); // u1 type of value (ANNOTATION == '@')
+        annotationEntry.dump(dos);
+    }
+
+    public AnnotationEntry getAnnotationEntry() {
+        return annotationEntry;
+    }
+
+    @Override
+    public String stringifyValue() {
+        return annotationEntry.toString();
+    }
+
+    @Override
+    public String toString() {
+        return stringifyValue();
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java
index 8344048ab93..466e9bf3404 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationEntry.java
@@ -25,66 +25,60 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
-
-import com.sun.org.apache.bcel.internal.Const;
+import java.util.stream.Stream;
 
 /**
- * represents one annotation in the annotation table
+ * Represents one annotation in the annotation table
  *
  * @since 6.0
  */
 public class AnnotationEntry implements Node {
 
-    private final int typeIndex;
-    private final ConstantPool constantPool;
-    private final boolean isRuntimeVisible;
+    public static final AnnotationEntry[] EMPTY_ARRAY = {};
 
-    private List<ElementValuePair> elementValuePairs;
+    public static AnnotationEntry[] createAnnotationEntries(final Attribute[] attrs) {
+        // Find attributes that contain annotation data
+        return Stream.of(attrs).filter(Annotations.class::isInstance).flatMap(e -> Stream.of(((Annotations) e).getAnnotationEntries()))
+            .toArray(AnnotationEntry[]::new);
+    }
 
-    /*
+    /**
      * Factory method to create an AnnotionEntry from a DataInput
      *
      * @param input
      * @param constantPool
      * @param isRuntimeVisible
      * @return the entry
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    public static AnnotationEntry read(final DataInput input, final ConstantPool constant_pool, final boolean isRuntimeVisible) throws IOException {
-
-        final AnnotationEntry annotationEntry = new AnnotationEntry(input.readUnsignedShort(), constant_pool, isRuntimeVisible);
-        final int num_element_value_pairs = input.readUnsignedShort();
+    public static AnnotationEntry read(final DataInput input, final ConstantPool constantPool, final boolean isRuntimeVisible) throws IOException {
+        final AnnotationEntry annotationEntry = new AnnotationEntry(input.readUnsignedShort(), constantPool, isRuntimeVisible);
+        final int numElementValuePairs = input.readUnsignedShort();
         annotationEntry.elementValuePairs = new ArrayList<>();
-        for (int i = 0; i < num_element_value_pairs; i++) {
-            annotationEntry.elementValuePairs.add(
-                    new ElementValuePair(input.readUnsignedShort(), ElementValue.readElementValue(input, constant_pool),
-                    constant_pool));
+        for (int i = 0; i < numElementValuePairs; i++) {
+            annotationEntry.elementValuePairs
+                .add(new ElementValuePair(input.readUnsignedShort(), ElementValue.readElementValue(input, constantPool), constantPool));
         }
         return annotationEntry;
     }
 
-    public AnnotationEntry(final int type_index, final ConstantPool constant_pool, final boolean isRuntimeVisible) {
-        this.typeIndex = type_index;
-        this.constantPool = constant_pool;
-        this.isRuntimeVisible = isRuntimeVisible;
-    }
+    private final int typeIndex;
 
-    public int getTypeIndex() {
-        return typeIndex;
-    }
+    private final ConstantPool constantPool;
 
-    public ConstantPool getConstantPool() {
-        return constantPool;
-    }
+    private final boolean isRuntimeVisible;
 
-    public boolean isRuntimeVisible() {
-        return isRuntimeVisible;
+    private List<ElementValuePair> elementValuePairs;
+
+    public AnnotationEntry(final int typeIndex, final ConstantPool constantPool, final boolean isRuntimeVisible) {
+        this.typeIndex = typeIndex;
+        this.constantPool = constantPool;
+        this.isRuntimeVisible = isRuntimeVisible;
     }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
      * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
@@ -94,12 +88,24 @@ public void accept(final Visitor v) {
         v.visitAnnotationEntry(this);
     }
 
+    public void addElementNameValuePair(final ElementValuePair elementNameValuePair) {
+        elementValuePairs.add(elementNameValuePair);
+    }
+
+    public void dump(final DataOutputStream dos) throws IOException {
+        dos.writeShort(typeIndex); // u2 index of type name in cpool
+        dos.writeShort(elementValuePairs.size()); // u2 element_value pair
+        // count
+        for (final ElementValuePair envp : elementValuePairs) {
+            envp.dump(dos);
+        }
+    }
+
     /**
      * @return the annotation type name
      */
     public String getAnnotationType() {
-        final ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant(typeIndex, Const.CONSTANT_Utf8);
-        return c.getBytes();
+        return constantPool.getConstantUtf8(typeIndex).getBytes();
     }
 
     /**
@@ -109,11 +115,8 @@ public int getAnnotationTypeIndex() {
         return typeIndex;
     }
 
-    /**
-     * @return the number of element value pairs in this annotation entry
-     */
-    public final int getNumElementValuePairs() {
-        return elementValuePairs.size();
+    public ConstantPool getConstantPool() {
+        return constantPool;
     }
 
     /**
@@ -121,20 +124,22 @@ public final int getNumElementValuePairs() {
      */
     public ElementValuePair[] getElementValuePairs() {
         // TODO return List
-        return elementValuePairs.toArray(new ElementValuePair[elementValuePairs.size()]);
+        return elementValuePairs.toArray(ElementValuePair.EMPTY_ARRAY);
     }
 
-    public void dump(final DataOutputStream dos) throws IOException {
-        dos.writeShort(typeIndex); // u2 index of type name in cpool
-        dos.writeShort(elementValuePairs.size()); // u2 element_value pair
-        // count
-        for (final ElementValuePair envp : elementValuePairs) {
-            envp.dump(dos);
-        }
+    /**
+     * @return the number of element value pairs in this annotation entry
+     */
+    public final int getNumElementValuePairs() {
+        return elementValuePairs.size();
     }
 
-    public void addElementNameValuePair(final ElementValuePair elementNameValuePair) {
-        elementValuePairs.add(elementNameValuePair);
+    public int getTypeIndex() {
+        return typeIndex;
+    }
+
+    public boolean isRuntimeVisible() {
+        return isRuntimeVisible;
     }
 
     public String toShortString() {
@@ -146,7 +151,10 @@ public String toShortString() {
             result.append("(");
             for (final ElementValuePair element : evPairs) {
                 result.append(element.toShortString());
+                result.append(", ");
             }
+            // remove last ", "
+            result.setLength(result.length() - 2);
             result.append(")");
         }
         return result.toString();
@@ -156,16 +164,4 @@ public String toShortString() {
     public String toString() {
         return toShortString();
     }
-
-    public static AnnotationEntry[] createAnnotationEntries(final Attribute[] attrs) {
-        // Find attributes that contain annotation data
-        final List<AnnotationEntry> accumulatedAnnotations = new ArrayList<>(attrs.length);
-        for (final Attribute attribute : attrs) {
-            if (attribute instanceof Annotations) {
-                final Annotations runtimeAnnotations = (Annotations) attribute;
-                Collections.addAll(accumulatedAnnotations, runtimeAnnotations.getAnnotationEntries());
-            }
-        }
-        return accumulatedAnnotations.toArray(new AnnotationEntry[accumulatedAnnotations.size()]);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java
index 5dc5f5cae77..52ac9d0dd98 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Annotations.java
@@ -24,40 +24,30 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Iterator;
+import java.util.stream.Stream;
+
+import com.sun.org.apache.bcel.internal.Const;
 
 /**
  * base class for annotations
  *
  * @since 6.0
  */
-public abstract class Annotations extends Attribute {
+public abstract class Annotations extends Attribute implements Iterable<AnnotationEntry> {
 
     private AnnotationEntry[] annotationTable;
     private final boolean isRuntimeVisible;
 
     /**
-     * @param annotation_type the subclass type of the annotation
-     * @param name_index Index pointing to the name <em>Code</em>
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     */
-    Annotations(final byte annotation_type, final int name_index, final int length, final DataInput input,
-            final ConstantPool constant_pool, final boolean isRuntimeVisible) throws IOException {
-        this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool, isRuntimeVisible);
-        final int annotation_table_length = input.readUnsignedShort();
-        annotationTable = new AnnotationEntry[annotation_table_length];
-        for (int i = 0; i < annotation_table_length; i++) {
-            annotationTable[i] = AnnotationEntry.read(input, constant_pool, isRuntimeVisible);
-        }
-    }
-
-    /**
-     * @param annotationType the subclass type of the annotation
-     * @param nameIndex Index pointing to the name <em>Code</em>
-     * @param length Content length in bytes
-     * @param annotationTable the actual annotations
-     * @param constantPool Array of constants
+     * Constructs an instance.
+     *
+     * @param annotationType   the subclass type of the annotation
+     * @param nameIndex        Index pointing to the name <em>Code</em>
+     * @param length           Content length in bytes
+     * @param annotationTable  the actual annotations
+     * @param constantPool     Array of constants
+     * @param isRuntimeVisible whether this Annotation visible at runtime
      */
     public Annotations(final byte annotationType, final int nameIndex, final int length, final AnnotationEntry[] annotationTable,
             final ConstantPool constantPool, final boolean isRuntimeVisible) {
@@ -67,8 +57,30 @@ public Annotations(final byte annotationType, final int nameIndex, final int len
     }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
-     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+     * Constructs an instance.
+     *
+     * @param annotationType   the subclass type of the annotation
+     * @param nameIndex        Index pointing to the name <em>Code</em>
+     * @param length           Content length in bytes
+     * @param input            Input stream
+     * @param constantPool     Array of constants
+     * @param isRuntimeVisible whether this Annotation visible at runtime
+     * @throws IOException if an I/O error occurs.
+     */
+    Annotations(final byte annotationType, final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool,
+            final boolean isRuntimeVisible) throws IOException {
+        this(annotationType, nameIndex, length, (AnnotationEntry[]) null, constantPool, isRuntimeVisible);
+        final int annotationTableLength = input.readUnsignedShort();
+        annotationTable = new AnnotationEntry[annotationTableLength];
+        for (int i = 0; i < annotationTableLength; i++) {
+            annotationTable[i] = AnnotationEntry.read(input, constantPool, isRuntimeVisible);
+        }
+    }
+
+    /**
+     * Called by objects that are traversing the nodes of the tree implicitly
+     * defined by the contents of a Java class. I.e., the hierarchy of methods,
+     * fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
@@ -77,21 +89,22 @@ public void accept(final Visitor v) {
         v.visitAnnotation(this);
     }
 
-    /**
-     * @param annotationTable the entries to set in this annotation
-     */
-    public final void setAnnotationTable(final AnnotationEntry[] annotationTable) {
-        this.annotationTable = annotationTable;
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        // TODO Auto-generated method stub
+        return null;
     }
 
     /**
-     * returns the array of annotation entries in this annotation
+     * Gets the array of annotation entries in this annotation
      */
     public AnnotationEntry[] getAnnotationEntries() {
         return annotationTable;
     }
 
     /**
+     * Gets the number of annotation entries in this annotation.
+     *
      * @return the number of annotation entries in this annotation
      */
     public final int getNumAnnotations() {
@@ -105,6 +118,38 @@ public boolean isRuntimeVisible() {
         return isRuntimeVisible;
     }
 
+    @Override
+    public Iterator<AnnotationEntry> iterator() {
+        return Stream.of(annotationTable).iterator();
+    }
+
+    /**
+     * Sets the entries to set in this annotation.
+     *
+     * @param annotationTable the entries to set in this annotation
+     */
+    public final void setAnnotationTable(final AnnotationEntry[] annotationTable) {
+        this.annotationTable = annotationTable;
+    }
+
+    /**
+     * Converts to a String representation.
+     *
+     * @return String representation
+     */
+    @Override
+    public final String toString() {
+        final StringBuilder buf = new StringBuilder(Const.getAttributeName(getTag()));
+        buf.append(":\n");
+        for (int i = 0; i < annotationTable.length; i++) {
+            buf.append("  ").append(annotationTable[i]);
+            if (i < annotationTable.length - 1) {
+                buf.append('\n');
+            }
+        }
+        return buf.toString();
+    }
+
     protected void writeAnnotations(final DataOutputStream dos) throws IOException {
         if (annotationTable == null) {
             return;
@@ -114,4 +159,5 @@ protected void writeAnnotations(final DataOutputStream dos) throws IOException {
             element.dump(dos);
         }
     }
+
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java
index 1e15d77049c..e8768886de5 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ArrayElementValue.java
@@ -27,40 +27,20 @@
 /**
  * @since 6.0
  */
-public class ArrayElementValue extends ElementValue
-{
+public class ArrayElementValue extends ElementValue {
     // For array types, this is the array
     private final ElementValue[] elementValues;
 
-    @Override
-    public String toString()
-    {
-        final StringBuilder sb = new StringBuilder();
-        sb.append("{");
-        for (int i = 0; i < elementValues.length; i++)
-        {
-            sb.append(elementValues[i]);
-            if ((i + 1) < elementValues.length) {
-                sb.append(",");
-            }
-        }
-        sb.append("}");
-        return sb.toString();
-    }
-
-    public ArrayElementValue(final int type, final ElementValue[] datums, final ConstantPool cpool)
-    {
+    public ArrayElementValue(final int type, final ElementValue[] datums, final ConstantPool cpool) {
         super(type, cpool);
         if (type != ARRAY) {
-            throw new IllegalArgumentException(
-                    "Only element values of type array can be built with this ctor - type specified: " + type);
+            throw new ClassFormatException("Only element values of type array can be built with this ctor - type specified: " + type);
         }
         this.elementValues = datums;
     }
 
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
+    public void dump(final DataOutputStream dos) throws IOException {
         dos.writeByte(super.getType()); // u1 type of value (ARRAY == '[')
         dos.writeShort(elementValues.length);
         for (final ElementValue evalue : elementValues) {
@@ -68,15 +48,21 @@ public void dump(final DataOutputStream dos) throws IOException
         }
     }
 
+    public ElementValue[] getElementValuesArray() {
+        return elementValues;
+    }
+
+    public int getElementValuesArraySize() {
+        return elementValues.length;
+    }
+
     @Override
-    public String stringifyValue()
-    {
+    public String stringifyValue() {
         final StringBuilder sb = new StringBuilder();
         sb.append("[");
-        for (int i = 0; i < elementValues.length; i++)
-        {
+        for (int i = 0; i < elementValues.length; i++) {
             sb.append(elementValues[i].stringifyValue());
-            if ((i + 1) < elementValues.length) {
+            if (i + 1 < elementValues.length) {
                 sb.append(",");
             }
         }
@@ -84,13 +70,17 @@ public String stringifyValue()
         return sb.toString();
     }
 
-    public ElementValue[] getElementValuesArray()
-    {
-        return elementValues;
-    }
-
-    public int getElementValuesArraySize()
-    {
-        return elementValues.length;
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("{");
+        for (int i = 0; i < elementValues.length; i++) {
+            sb.append(elementValues[i]);
+            if (i + 1 < elementValues.length) {
+                sb.append(",");
+            }
+        }
+        sb.append("}");
+        return sb.toString();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java
index 4b21e9cdcc2..bf72fee4e00 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,14 +27,20 @@
 import java.util.Map;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * Abstract super class for <em>Attribute</em> objects. Currently the
- * <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
- * <em>Exceptiontable</em>, <em>LineNumberTable</em>,
- * <em>LocalVariableTable</em>, <em>InnerClasses</em> and
- * <em>Synthetic</em> attributes are supported. The <em>Unknown</em>
- * attribute stands for non-standard-attributes.
+ * Abstract super class for <em>Attribute</em> objects. Currently the <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>, <em>Exceptiontable</em>,
+ * <em>LineNumberTable</em>, <em>LocalVariableTable</em>, <em>InnerClasses</em> and <em>Synthetic</em> attributes are supported. The <em>Unknown</em> attribute
+ * stands for non-standard-attributes.
+ *
+ * <pre>
+ * attribute_info {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u1 info[attribute_length];
+ * }
+ * </pre>
  *
  * @see ConstantValue
  * @see SourceFile
@@ -47,28 +53,29 @@
  * @see Synthetic
  * @see Deprecated
  * @see Signature
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public abstract class Attribute implements Cloneable, Node {
     private static final boolean debug = false;
-    private int name_index; // Points to attribute name in constant pool
-    private int length; // Content length of attribute field
-    private final byte tag; // Tag to distinguish subclasses
-    private ConstantPool constant_pool;
 
-    private static final Map<String, Object> readers = new HashMap<>();
+    private static final Map<String, Object> READERS = new HashMap<>();
+
+    /**
+     * Empty array.
+     *
+     * @since 6.6.0
+     */
+    public static final Attribute[] EMPTY_ARRAY = {};
 
     /**
-     * Add an Attribute reader capable of parsing (user-defined) attributes
-     * named "name". You should not add readers for the standard attributes such
-     * as "LineNumberTable", because those are handled internally.
+     * Add an Attribute reader capable of parsing (user-defined) attributes named "name". You should not add readers for the
+     * standard attributes such as "LineNumberTable", because those are handled internally.
      *
      * @param name the name of the attribute as stored in the class file
-     * @param r    the reader object
+     * @param unknownAttributeReader the reader object
      */
-    public static void addAttributeReader(final String name, final UnknownAttributeReader r)
-    {
-        readers.put(name, r);
+    public static void addAttributeReader(final String name, final UnknownAttributeReader unknownAttributeReader) {
+        READERS.put(name, unknownAttributeReader);
     }
 
     protected static void println(final String msg) {
@@ -78,135 +85,122 @@ protected static void println(final String msg) {
     }
 
     /**
-     * Class method reads one attribute from the input data stream. This method
-     * must not be accessible from the outside. It is called by the Field and
-     * Method constructor methods.
+     * Class method reads one attribute from the input data stream. This method must not be accessible from the outside. It
+     * is called by the Field and Method constructor methods.
      *
      * @see Field
      * @see Method
      *
-     * @param file Input stream
-     * @param constant_pool Array of constants
+     * @param dataInput Input stream
+     * @param constantPool Array of constants
      * @return Attribute
-     * @throws IOException
-     * @throws ClassFormatException
+     * @throws IOException if an I/O error occurs.
      * @since 6.0
      */
-    public static Attribute readAttribute(final DataInput file, final ConstantPool constant_pool)
-            throws IOException, ClassFormatException
-    {
+    public static Attribute readAttribute(final DataInput dataInput, final ConstantPool constantPool) throws IOException {
         byte tag = Const.ATTR_UNKNOWN; // Unknown attribute
-        // Get class name from constant pool via `name_index' indirection
-        final int name_index = file.readUnsignedShort();
-        final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8);
-        final String name = c.getBytes();
+        // Get class name from constant pool via 'name_index' indirection
+        final int nameIndex = dataInput.readUnsignedShort();
+        final String name = constantPool.getConstantUtf8(nameIndex).getBytes();
 
         // Length of data in bytes
-        final int length = file.readInt();
+        final int length = dataInput.readInt();
 
         // Compare strings to find known attribute
-        for (byte i = 0; i < Const.KNOWN_ATTRIBUTES; i++)
-        {
-            if (name.equals(Const.getAttributeName(i)))
-            {
+        for (byte i = 0; i < Const.KNOWN_ATTRIBUTES; i++) {
+            if (name.equals(Const.getAttributeName(i))) {
                 tag = i; // found!
                 break;
             }
         }
 
-        // Call proper constructor, depending on `tag'
-        switch (tag)
-        {
-            case Const.ATTR_UNKNOWN:
-                final Object r = readers.get(name);
-                if (r instanceof UnknownAttributeReader)
-                {
-                    return ((UnknownAttributeReader) r).createAttribute(name_index, length, file, constant_pool);
-                }
-                return new Unknown(name_index, length, file, constant_pool);
-            case Const.ATTR_CONSTANT_VALUE:
-                return new ConstantValue(name_index, length, file, constant_pool);
-            case Const.ATTR_SOURCE_FILE:
-                return new SourceFile(name_index, length, file, constant_pool);
-            case Const.ATTR_CODE:
-                return new Code(name_index, length, file, constant_pool);
-            case Const.ATTR_EXCEPTIONS:
-                return new ExceptionTable(name_index, length, file, constant_pool);
-            case Const.ATTR_LINE_NUMBER_TABLE:
-                return new LineNumberTable(name_index, length, file, constant_pool);
-            case Const.ATTR_LOCAL_VARIABLE_TABLE:
-                return new LocalVariableTable(name_index, length, file, constant_pool);
-            case Const.ATTR_INNER_CLASSES:
-                return new InnerClasses(name_index, length, file, constant_pool);
-            case Const.ATTR_SYNTHETIC:
-                return new Synthetic(name_index, length, file, constant_pool);
-            case Const.ATTR_DEPRECATED:
-                return new Deprecated(name_index, length, file, constant_pool);
-            case Const.ATTR_PMG:
-                return new PMGClass(name_index, length, file, constant_pool);
-            case Const.ATTR_SIGNATURE:
-                return new Signature(name_index, length, file, constant_pool);
-            case Const.ATTR_STACK_MAP:
-                // old style stack map: unneeded for JDK5 and below;
-                // illegal(?) for JDK6 and above.  So just delete with a warning.
-                println("Warning: Obsolete StackMap attribute ignored.");
-                return new Unknown(name_index, length, file, constant_pool);
-            case Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS:
-                return new RuntimeVisibleAnnotations(name_index, length, file, constant_pool);
-            case Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS:
-                return new RuntimeInvisibleAnnotations(name_index, length, file, constant_pool);
-            case Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
-                return new RuntimeVisibleParameterAnnotations(name_index, length, file, constant_pool);
-            case Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS:
-                return new RuntimeInvisibleParameterAnnotations(name_index, length, file, constant_pool);
-            case Const.ATTR_ANNOTATION_DEFAULT:
-                return new AnnotationDefault(name_index, length, file, constant_pool);
-            case Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
-                return new LocalVariableTypeTable(name_index, length, file, constant_pool);
-            case Const.ATTR_ENCLOSING_METHOD:
-                return new EnclosingMethod(name_index, length, file, constant_pool);
-            case Const.ATTR_STACK_MAP_TABLE:
-                // read new style stack map: StackMapTable.  The rest of the code
-                // calls this a StackMap for historical reasons.
-                return new StackMap(name_index, length, file, constant_pool);
-            case Const.ATTR_BOOTSTRAP_METHODS:
-                return new BootstrapMethods(name_index, length, file, constant_pool);
-            case Const.ATTR_METHOD_PARAMETERS:
-                return new MethodParameters(name_index, length, file, constant_pool);
-            case Const.ATTR_MODULE:
-                return new Module(name_index, length, file, constant_pool);
-            case Const.ATTR_MODULE_PACKAGES:
-                return new ModulePackages(name_index, length, file, constant_pool);
-            case Const.ATTR_MODULE_MAIN_CLASS:
-                return new ModuleMainClass(name_index, length, file, constant_pool);
-            case Const.ATTR_NEST_HOST:
-                return new NestHost(name_index, length, file, constant_pool);
-            case Const.ATTR_NEST_MEMBERS:
-                return new NestMembers(name_index, length, file, constant_pool);
-            default:
-                // Never reached
-                throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag);
+        // Call proper constructor, depending on 'tag'
+        switch (tag) {
+        case Const.ATTR_UNKNOWN:
+            final Object r = READERS.get(name);
+            if (r instanceof UnknownAttributeReader) {
+                return ((UnknownAttributeReader) r).createAttribute(nameIndex, length, dataInput, constantPool);
+            }
+            return new Unknown(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_CONSTANT_VALUE:
+            return new ConstantValue(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_SOURCE_FILE:
+            return new SourceFile(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_CODE:
+            return new Code(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_EXCEPTIONS:
+            return new ExceptionTable(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_LINE_NUMBER_TABLE:
+            return new LineNumberTable(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_LOCAL_VARIABLE_TABLE:
+            return new LocalVariableTable(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_INNER_CLASSES:
+            return new InnerClasses(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_SYNTHETIC:
+            return new Synthetic(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_DEPRECATED:
+            return new Deprecated(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_PMG:
+            return new PMGClass(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_SIGNATURE:
+            return new Signature(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_STACK_MAP:
+            // old style stack map: unneeded for JDK5 and below;
+            // illegal(?) for JDK6 and above. So just delete with a warning.
+            println("Warning: Obsolete StackMap attribute ignored.");
+            return new Unknown(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS:
+            return new RuntimeVisibleAnnotations(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS:
+            return new RuntimeInvisibleAnnotations(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
+            return new RuntimeVisibleParameterAnnotations(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS:
+            return new RuntimeInvisibleParameterAnnotations(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_ANNOTATION_DEFAULT:
+            return new AnnotationDefault(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
+            return new LocalVariableTypeTable(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_ENCLOSING_METHOD:
+            return new EnclosingMethod(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_STACK_MAP_TABLE:
+            // read new style stack map: StackMapTable. The rest of the code
+            // calls this a StackMap for historical reasons.
+            return new StackMap(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_BOOTSTRAP_METHODS:
+            return new BootstrapMethods(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_METHOD_PARAMETERS:
+            return new MethodParameters(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_MODULE:
+            return new Module(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_MODULE_PACKAGES:
+            return new ModulePackages(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_MODULE_MAIN_CLASS:
+            return new ModuleMainClass(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_NEST_HOST:
+            return new NestHost(nameIndex, length, dataInput, constantPool);
+        case Const.ATTR_NEST_MEMBERS:
+            return new NestMembers(nameIndex, length, dataInput, constantPool);
+        default:
+            // Never reached
+            throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag);
         }
     }
 
     /**
-     * Class method reads one attribute from the input data stream. This method
-     * must not be accessible from the outside. It is called by the Field and
-     * Method constructor methods.
+     * Class method reads one attribute from the input data stream. This method must not be accessible from the outside. It
+     * is called by the Field and Method constructor methods.
      *
      * @see Field
      * @see Method
      *
-     * @param file Input stream
-     * @param constant_pool Array of constants
+     * @param dataInputStream Input stream
+     * @param constantPool Array of constants
      * @return Attribute
-     * @throws IOException
-     * @throws ClassFormatException
+     * @throws IOException if an I/O error occurs.
      */
-    public static Attribute readAttribute(final DataInputStream file, final ConstantPool constant_pool)
-            throws IOException, ClassFormatException
-    {
-        return readAttribute((DataInput) file, constant_pool);
+    public static Attribute readAttribute(final DataInputStream dataInputStream, final ConstantPool constantPool) throws IOException {
+        return readAttribute((DataInput) dataInputStream, constantPool);
     }
 
     /**
@@ -214,65 +208,95 @@ public static Attribute readAttribute(final DataInputStream file, final Constant
      *
      * @param name the name of the attribute as stored in the class file
      */
-    public static void removeAttributeReader(final String name)
-    {
-        readers.remove(name);
+    public static void removeAttributeReader(final String name) {
+        READERS.remove(name);
     }
 
-    protected Attribute(final byte tag, final int name_index, final int length, final ConstantPool constant_pool)
-    {
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected int name_index; // Points to attribute name in constant pool TODO make private (has getter & setter)
+
+    /**
+     * @deprecated (since 6.0) (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected int length; // Content length of attribute field TODO make private (has getter & setter)
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected byte tag; // Tag to distinguish subclasses TODO make private & final; supposed to be immutable
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected ConstantPool constant_pool; // TODO make private (has getter & setter)
+
+    /**
+     * Constructs an instance.
+     *
+     * <pre>
+     * attribute_info {
+     *   u2 attribute_name_index;
+     *   u4 attribute_length;
+     *   u1 info[attribute_length];
+     * }
+     * </pre>
+     *
+     * @param tag tag.
+     * @param nameIndex u2 name index.
+     * @param length u4 length.
+     * @param constantPool constant pool.
+     */
+    protected Attribute(final byte tag, final int nameIndex, final int length, final ConstantPool constantPool) {
         this.tag = tag;
-        this.name_index = name_index;
-        this.length = length;
-        this.constant_pool = constant_pool;
+        this.name_index = Args.requireU2(nameIndex, 0, constantPool.getLength(), getClass().getSimpleName() + " name index");
+        this.length = Args.requireU4(length, getClass().getSimpleName() + " attribute length");
+        this.constant_pool = constantPool;
     }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
-     * @param v
-     *            Visitor object
+     * @param v Visitor object
      */
     @Override
     public abstract void accept(Visitor v);
 
     /**
-     * Use copy() if you want to have a deep copy(), i.e., with all references
-     * copied correctly.
+     * Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.
      *
      * @return shallow copy of this attribute
      */
     @Override
-    public Object clone()
-    {
+    public Object clone() {
         Attribute attr = null;
-        try
-        {
+        try {
             attr = (Attribute) super.clone();
-        }
-        catch (final CloneNotSupportedException e)
-        {
+        } catch (final CloneNotSupportedException e) {
             throw new Error("Clone Not Supported"); // never happens
         }
         return attr;
     }
 
     /**
-     * @return deep copy of this attribute
+     * @param constantPool constant pool to save.
+     * @return deep copy of this attribute.
      */
-    public abstract Attribute copy(ConstantPool _constant_pool);
+    public abstract Attribute copy(ConstantPool constantPool);
 
     /**
-     * Dump attribute to file stream in binary format.
+     * Dumps attribute to file stream in binary format.
      *
-     * @param file
-     *            Output file stream
-     * @throws IOException
+     * @param file Output file stream
+     * @throws IOException if an I/O error occurs.
      */
-    public void dump(final DataOutputStream file) throws IOException
-    {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(name_index);
         file.writeInt(length);
     }
@@ -281,16 +305,14 @@ public void dump(final DataOutputStream file) throws IOException
      * @return Constant pool used by this object.
      * @see ConstantPool
      */
-    public final ConstantPool getConstantPool()
-    {
+    public final ConstantPool getConstantPool() {
         return constant_pool;
     }
 
     /**
      * @return Length of attribute field in bytes.
      */
-    public final int getLength()
-    {
+    public final int getLength() {
         return length;
     }
 
@@ -298,59 +320,51 @@ public final int getLength()
      * @return Name of attribute
      * @since 6.0
      */
-    public String getName()
-    {
-        final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8);
-        return c.getBytes();
+    public String getName() {
+        return constant_pool.getConstantUtf8(name_index).getBytes();
     }
 
     /**
      * @return Name index in constant pool of attribute name.
      */
-    public final int getNameIndex()
-    {
+    public final int getNameIndex() {
         return name_index;
     }
 
     /**
      * @return Tag of attribute, i.e., its type. Value may not be altered, thus there is no setTag() method.
      */
-    public final byte getTag()
-    {
+    public final byte getTag() {
         return tag;
     }
 
     /**
-     * @param constant_pool Constant pool to be used for this object.
+     * @param constantPool Constant pool to be used for this object.
      * @see ConstantPool
      */
-    public final void setConstantPool(final ConstantPool constant_pool)
-    {
-        this.constant_pool = constant_pool;
+    public final void setConstantPool(final ConstantPool constantPool) {
+        this.constant_pool = constantPool;
     }
 
     /**
      * @param length length in bytes.
      */
-    public final void setLength(final int length)
-    {
+    public final void setLength(final int length) {
         this.length = length;
     }
 
     /**
-     * @param name_index of attribute.
+     * @param nameIndex of attribute.
      */
-    public final void setNameIndex(final int name_index)
-    {
-        this.name_index = name_index;
+    public final void setNameIndex(final int nameIndex) {
+        this.name_index = nameIndex;
     }
 
     /**
      * @return attribute name.
      */
     @Override
-    public String toString()
-    {
+    public String toString() {
         return Const.getAttributeName(tag);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java
index 33dcd33cec4..6d4891f953f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java
@@ -22,10 +22,9 @@
 package com.sun.org.apache.bcel.internal.classfile;
 
 /**
- * Unknown (non-standard) attributes may be read via user-defined factory
- * objects that can be registered with the Attribute.addAttributeReader
- * method. These factory objects should implement this interface.
-
+ * Unknown (non-standard) attributes may be read via user-defined factory objects that can be registered with the
+ * Attribute.addAttributeReader method. These factory objects should implement this interface.
+ *
  * @see Attribute
  *
  * @deprecated Use UnknownAttributeReader instead
@@ -34,30 +33,23 @@
 public interface AttributeReader {
 
     /**
-     When this attribute reader is added via the static method
-     Attribute.addAttributeReader, an attribute name is associated with it.
-     As the class file parser parses attributes, it will call various
-     AttributeReaders based on the name of the attributes it is
-     constructing.
-
-     @param name_index An index into the constant pool, indexing a
-     ConstantUtf8 that represents the name of the attribute.
-
-     @param length The length of the data contained in the attribute.  This
-     is written into the constant pool and should agree with what the
-     factory expects the length to be.
-
-     @param file This is the data input stream that the factory needs to read
-     its data from.
-
-     @param constant_pool This is the constant pool associated with the
-     Attribute that we are constructing.
-
-     @return The user-defined AttributeReader should take this data and use
-     it to construct an attribute.  In the case of errors, a null can be
-     returned which will cause the parsing of the class file to fail.
-
-     @see Attribute#addAttributeReader( String, AttributeReader )
+     * When this attribute reader is added via the static method Attribute.addAttributeReader, an attribute name is
+     * associated with it. As the class file parser parses attributes, it will call various AttributeReaders based on the
+     * name of the attributes it is constructing.
+     *
+     * @param nameIndex An index into the constant pool, indexing a ConstantUtf8 that represents the name of the attribute.
+     *
+     * @param length The length of the data contained in the attribute. This is written into the constant pool and should
+     *        agree with what the factory expects the length to be.
+     *
+     * @param file This is the data input stream that the factory needs to read its data from.
+     *
+     * @param constantPool This is the constant pool associated with the Attribute that we are constructing.
+     *
+     * @return The user-defined AttributeReader should take this data and use it to construct an attribute. In the case of
+     *         errors, a null can be returned which will cause the parsing of the class file to fail.
+     *
+     * @see Attribute#addAttributeReader( String, AttributeReader )
      */
-    Attribute createAttribute( int name_index, int length, java.io.DataInputStream file, ConstantPool constant_pool );
+    Attribute createAttribute(int nameIndex, int length, java.io.DataInputStream file, ConstantPool constantPool);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java
index 47e655e13c5..61b818ec4f0 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethod.java
@@ -29,12 +29,11 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents a bootstrap method attribute, i.e., the bootstrap
- * method ref, the number of bootstrap arguments and an array of the
- * bootstrap arguments.
+ * This class represents a bootstrap method attribute, i.e., the bootstrap method ref, the number of bootstrap arguments
+ * and an array of the bootstrap arguments.
  *
- * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.23">
- * The class File Format : The BootstrapMethods Attribute</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.23"> The class File Format :
+ *      The BootstrapMethods Attribute</a>
  * @since 6.0
  */
 public class BootstrapMethod implements Cloneable {
@@ -45,9 +44,10 @@ public class BootstrapMethod implements Cloneable {
     /** Array of references to the constant_pool table */
     private int[] bootstrapArguments;
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public BootstrapMethod(final BootstrapMethod c) {
         this(c.getBootstrapMethodRef(), c.getBootstrapArguments());
@@ -57,7 +57,7 @@ public BootstrapMethod(final BootstrapMethod c) {
      * Construct object from input stream.
      *
      * @param input Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     BootstrapMethod(final DataInput input) throws IOException {
         this(input.readUnsignedShort(), input.readUnsignedShort());
@@ -68,8 +68,8 @@ public BootstrapMethod(final BootstrapMethod c) {
     }
 
     // helper method
-    private BootstrapMethod(final int bootstrap_method_ref, final int num_bootstrap_arguments) {
-        this(bootstrap_method_ref, new int[num_bootstrap_arguments]);
+    private BootstrapMethod(final int bootstrapMethodRef, final int numBootstrapArguments) {
+        this(bootstrapMethodRef, new int[numBootstrapArguments]);
     }
 
     /**
@@ -82,17 +82,29 @@ public BootstrapMethod(final int bootstrapMethodRef, final int[] bootstrapArgume
     }
 
     /**
-     * @return index into constant_pool of bootstrap_method
+     * @return deep copy of this object
      */
-    public int getBootstrapMethodRef() {
-        return bootstrapMethodRef;
+    public BootstrapMethod copy() {
+        try {
+            return (BootstrapMethod) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
     }
 
     /**
-     * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle
+     * Dump object to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException if an I/O error occurs.
      */
-    public void setBootstrapMethodRef(final int bootstrapMethodRef) {
-        this.bootstrapMethodRef = bootstrapMethodRef;
+    public final void dump(final DataOutputStream file) throws IOException {
+        file.writeShort(bootstrapMethodRef);
+        file.writeShort(bootstrapArguments.length);
+        for (final int bootstrapArgument : bootstrapArguments) {
+            file.writeShort(bootstrapArgument);
+        }
     }
 
     /**
@@ -102,6 +114,13 @@ public int[] getBootstrapArguments() {
         return bootstrapArguments;
     }
 
+    /**
+     * @return index into constant_pool of bootstrap_method
+     */
+    public int getBootstrapMethodRef() {
+        return bootstrapMethodRef;
+    }
+
     /**
      * @return count of number of boostrap arguments
      */
@@ -116,58 +135,36 @@ public void setBootstrapArguments(final int[] bootstrapArguments) {
         this.bootstrapArguments = bootstrapArguments;
     }
 
+    /**
+     * @param bootstrapMethodRef int index into constant_pool of CONSTANT_MethodHandle
+     */
+    public void setBootstrapMethodRef(final int bootstrapMethodRef) {
+        this.bootstrapMethodRef = bootstrapMethodRef;
+    }
+
     /**
      * @return String representation.
      */
     @Override
     public final String toString() {
-        return "BootstrapMethod(" + bootstrapMethodRef + ", " + bootstrapArguments.length + ", "
-               + Arrays.toString(bootstrapArguments) + ")";
+        return "BootstrapMethod(" + bootstrapMethodRef + ", " + bootstrapArguments.length + ", " + Arrays.toString(bootstrapArguments) + ")";
     }
 
     /**
      * @return Resolved string representation
      */
-    public final String toString( final ConstantPool constantPool ) {
+    public final String toString(final ConstantPool constantPool) {
         final StringBuilder buf = new StringBuilder();
-        String bootstrap_method_name;
-        bootstrap_method_name = constantPool.constantToString(bootstrapMethodRef,
-                Const.CONSTANT_MethodHandle);
-        buf.append(Utility.compactClassName(bootstrap_method_name, false));
-        final int num_bootstrap_arguments = bootstrapArguments.length;
-        if (num_bootstrap_arguments > 0) {
+        final String bootstrapMethodName = constantPool.constantToString(bootstrapMethodRef, Const.CONSTANT_MethodHandle);
+        buf.append(Utility.compactClassName(bootstrapMethodName, false));
+        final int bootstrapArgumentsLen = bootstrapArguments.length;
+        if (bootstrapArgumentsLen > 0) {
             buf.append("\nMethod Arguments:");
-            for (int i = 0; i < num_bootstrap_arguments; i++) {
+            for (int i = 0; i < bootstrapArgumentsLen; i++) {
                 buf.append("\n  ").append(i).append(": ");
                 buf.append(constantPool.constantToString(constantPool.getConstant(bootstrapArguments[i])));
             }
         }
         return buf.toString();
     }
-
-    /**
-     * Dump object to file stream in binary format.
-     *
-     * @param file Output file stream
-     * @throws IOException
-     */
-    public final void dump(final DataOutputStream file) throws IOException {
-        file.writeShort(bootstrapMethodRef);
-        file.writeShort(bootstrapArguments.length);
-        for (final int bootstrap_argument : bootstrapArguments) {
-            file.writeShort(bootstrap_argument);
-        }
-    }
-
-    /**
-     * @return deep copy of this object
-     */
-    public BootstrapMethod copy() {
-        try {
-            return (BootstrapMethod) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java
index 1a55a725c9f..6f9930f1b16 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/BootstrapMethods.java
@@ -24,73 +24,62 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Iterator;
+import java.util.stream.Stream;
 
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
  * This class represents a BootstrapMethods attribute.
  *
- * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.23">
- * The class File Format : The BootstrapMethods Attribute</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.23"> The class File Format :
+ *      The BootstrapMethods Attribute</a>
  * @since 6.0
  */
-public class BootstrapMethods extends Attribute {
+public class BootstrapMethods extends Attribute implements Iterable<BootstrapMethod> {
 
-    private BootstrapMethod[] bootstrapMethods;  // TODO this could be made final (setter is not used)
+    private BootstrapMethod[] bootstrapMethods; // TODO this could be made final (setter is not used)
 
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
     public BootstrapMethods(final BootstrapMethods c) {
         this(c.getNameIndex(), c.getLength(), c.getBootstrapMethods(), c.getConstantPool());
     }
 
-
     /**
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param bootstrapMethods array of bootstrap methods
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public BootstrapMethods(final int name_index, final int length, final BootstrapMethod[] bootstrapMethods, final ConstantPool constant_pool) {
-        super(Const.ATTR_BOOTSTRAP_METHODS, name_index, length, constant_pool);
+    public BootstrapMethods(final int nameIndex, final int length, final BootstrapMethod[] bootstrapMethods, final ConstantPool constantPool) {
+        super(Const.ATTR_BOOTSTRAP_METHODS, nameIndex, length, constantPool);
         this.bootstrapMethods = bootstrapMethods;
     }
 
     /**
      * Construct object from Input stream.
      *
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    BootstrapMethods(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        this(name_index, length, (BootstrapMethod[]) null, constant_pool);
+    BootstrapMethods(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (BootstrapMethod[]) null, constantPool);
 
-        final int num_bootstrap_methods = input.readUnsignedShort();
-        bootstrapMethods = new BootstrapMethod[num_bootstrap_methods];
-        for (int i = 0; i < num_bootstrap_methods; i++) {
+        final int numBootstrapMethods = input.readUnsignedShort();
+        bootstrapMethods = new BootstrapMethod[numBootstrapMethods];
+        for (int i = 0; i < numBootstrapMethods; i++) {
             bootstrapMethods[i] = new BootstrapMethod(input);
         }
     }
 
-    /**
-     * @return array of bootstrap method "records"
-     */
-    public final BootstrapMethod[] getBootstrapMethods() {
-        return bootstrapMethods;
-    }
-
-    /**
-     * @param bootstrapMethods the array of bootstrap methods
-     */
-    public final void setBootstrapMethods(final BootstrapMethod[] bootstrapMethods) {
-        this.bootstrapMethods = bootstrapMethods;
-    }
-
     /**
      * @param v Visitor object
      */
@@ -103,14 +92,14 @@ public void accept(final Visitor v) {
      * @return deep copy of this attribute
      */
     @Override
-    public BootstrapMethods copy(final ConstantPool _constant_pool) {
+    public BootstrapMethods copy(final ConstantPool constantPool) {
         final BootstrapMethods c = (BootstrapMethods) clone();
         c.bootstrapMethods = new BootstrapMethod[bootstrapMethods.length];
 
         for (int i = 0; i < bootstrapMethods.length; i++) {
             c.bootstrapMethods[i] = bootstrapMethods[i].copy();
         }
-        c.setConstantPool(_constant_pool);
+        c.setConstantPool(constantPool);
         return c;
     }
 
@@ -118,18 +107,37 @@ public BootstrapMethods copy(final ConstantPool _constant_pool) {
      * Dump bootstrap methods attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
     public final void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
 
         file.writeShort(bootstrapMethods.length);
-        for (final BootstrapMethod bootstrap_method : bootstrapMethods) {
-            bootstrap_method.dump(file);
+        for (final BootstrapMethod bootstrapMethod : bootstrapMethods) {
+            bootstrapMethod.dump(file);
         }
     }
 
+    /**
+     * @return array of bootstrap method "records"
+     */
+    public final BootstrapMethod[] getBootstrapMethods() {
+        return bootstrapMethods;
+    }
+
+    @Override
+    public Iterator<BootstrapMethod> iterator() {
+        return Stream.of(bootstrapMethods).iterator();
+    }
+
+    /**
+     * @param bootstrapMethods the array of bootstrap methods
+     */
+    public final void setBootstrapMethods(final BootstrapMethod[] bootstrapMethods) {
+        this.bootstrapMethods = bootstrapMethods;
+    }
+
     /**
      * @return String representation.
      */
@@ -143,11 +151,11 @@ public final String toString() {
             buf.append("\n");
             final int start = buf.length();
             buf.append("  ").append(i).append(": ");
-            final int indent_count = buf.length() - start;
-            final String[] lines = (bootstrapMethods[i].toString(super.getConstantPool())).split("\\r?\\n");
+            final int indentCount = buf.length() - start;
+            final String[] lines = bootstrapMethods[i].toString(super.getConstantPool()).split("\\r?\\n");
             buf.append(lines[0]);
             for (int j = 1; j < lines.length; j++) {
-                buf.append("\n").append("          ".substring(0,indent_count)).append(lines[j]);
+                buf.append("\n").append("          ", 0, indentCount).append(lines[j]);
             }
         }
         return buf.toString();
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java
index 1a9939c656b..3df0eb98653 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassElementValue.java
@@ -24,48 +24,36 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-import com.sun.org.apache.bcel.internal.Const;
-
 /**
  * @since 6.0
  */
-public class ClassElementValue extends ElementValue
-{
+public class ClassElementValue extends ElementValue {
     // For primitive types and string type, this points to the value entry in
     // the cpool
     // For 'class' this points to the class entry in the cpool
     private final int idx;
 
-    public ClassElementValue(final int type, final int idx, final ConstantPool cpool)
-    {
+    public ClassElementValue(final int type, final int idx, final ConstantPool cpool) {
         super(type, cpool);
         this.idx = idx;
     }
 
-    public int getIndex()
-    {
-        return idx;
+    @Override
+    public void dump(final DataOutputStream dos) throws IOException {
+        dos.writeByte(super.getType()); // u1 kind of value
+        dos.writeShort(idx);
     }
 
-    public String getClassString()
-    {
-        final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(idx,
-                Const.CONSTANT_Utf8);
-        return c.getBytes();
+    public String getClassString() {
+        return super.getConstantPool().getConstantUtf8(idx).getBytes();
     }
 
-    @Override
-    public String stringifyValue()
-    {
-        final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(idx,
-                Const.CONSTANT_Utf8);
-        return cu8.getBytes();
+    public int getIndex() {
+        return idx;
     }
 
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
-        dos.writeByte(super.getType()); // u1 kind of value
-        dos.writeShort(idx);
+    public String stringifyValue() {
+        return super.getConstantPool().getConstantUtf8(idx).getBytes();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java
index 02f8142c58b..a61e1d75390 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java
@@ -22,28 +22,52 @@
 package com.sun.org.apache.bcel.internal.classfile;
 
 /**
- * Thrown when the BCEL attempts to read a class file and determines
- * that the file is malformed or otherwise cannot be interpreted as a
- * class file.
- *
+ * Thrown when the BCEL attempts to read a class file and determines that a class is malformed or otherwise cannot be interpreted as a class file.
  */
 public class ClassFormatException extends RuntimeException {
 
     private static final long serialVersionUID = -3569097343160139969L;
 
+    /**
+     * Constructs a new instance with {@code null} as its detail message. The cause is not initialized, and may subsequently be initialized by a call to
+     * {@link #initCause}.
+     */
     public ClassFormatException() {
-        super();
     }
 
-
-    public ClassFormatException(final String s) {
-        super(s);
+    /**
+     * Constructs a new instance with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to
+     * {@link #initCause}.
+     *
+     * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
+     */
+    public ClassFormatException(final String message) {
+        super(message);
     }
 
     /**
+     * Constructs a new instance with the specified detail message and cause.
+     * <p>
+     * Note that the detail message associated with {@code cause} is <i>not</i> automatically incorporated in this runtime exception's detail message.
+     *
+     * @param message the detail message (which is saved for later retrieval by the {@link #getMessage()} method).
+     * @param cause   the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that
+     *                the cause is nonexistent or unknown.)
      * @since 6.0
      */
     public ClassFormatException(final String message, final Throwable cause) {
         super(message, cause);
     }
+
+    /**
+     * Constructs a new instance with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the
+     * class and detail message of {@code cause}). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
+     *
+     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the
+     *              cause is nonexistent or unknown.)
+     * @since 6.7.0
+     */
+    public ClassFormatException(final Throwable cause) {
+        super(cause);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java
index 0ad2b781629..c9daaeabf9b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java
@@ -32,20 +32,17 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * Wrapper class that parses a given Java .class file. The method <A
- * href ="#parse">parse</A> returns a <A href ="JavaClass.html">
- * JavaClass</A> object on success. When an I/O error or an
- * inconsistency occurs an appropiate exception is propagated back to
- * the caller.
- *
- * The structure and the names comply, except for a few conveniences,
- * exactly with the <A href="http://docs.oracle.com/javase/specs/">
- * JVM specification 1.0</a>. See this paper for
- * further details about the structure of a bytecode file.
+ * Wrapper class that parses a given Java .class file. The method <a href ="#parse">parse</a> returns a
+ * <a href ="JavaClass.html"> JavaClass</a> object on success. When an I/O error or an inconsistency occurs an
+ * appropriate exception is propagated back to the caller.
  *
+ * The structure and the names comply, except for a few conveniences, exactly with the
+ * <a href="http://docs.oracle.com/javase/specs/"> JVM specification 1.0</a>. See this paper for further details about
+ * the structure of a bytecode file.
  */
 public final class ClassParser {
 
+    private static final int BUFSIZE = 8192;
     private DataInputStream dataInputStream;
     private final boolean fileOwned;
     private final String fileName;
@@ -61,8 +58,6 @@ public final class ClassParser {
     private Method[] methods; // methods defined in the class
     private Attribute[] attributes; // attributes defined in the class
     private final boolean isZip; // Loaded from zip file
-    private static final int BUFSIZE = 8192;
-
 
     /**
      * Parses class from the given stream.
@@ -72,9 +67,9 @@ public final class ClassParser {
      */
     public ClassParser(final InputStream inputStream, final String fileName) {
         this.fileName = fileName;
-        fileOwned = false;
+        this.fileOwned = false;
         final String clazz = inputStream.getClass().getName(); // Not a very clean solution ...
-        isZip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
+        this.isZip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
         if (inputStream instanceof DataInputStream) {
             this.dataInputStream = (DataInputStream) inputStream;
         } else {
@@ -82,41 +77,38 @@ public ClassParser(final InputStream inputStream, final String fileName) {
         }
     }
 
-
-    /** Parses class from given .class file.
+    /**
+     * Parses class from given .class file.
      *
      * @param fileName file name
      */
     public ClassParser(final String fileName) {
-        isZip = false;
+        this.isZip = false;
         this.fileName = fileName;
-        fileOwned = true;
+        this.fileOwned = true;
     }
 
-
-    /** Parses class from given .class file in a ZIP-archive
+    /**
+     * Parses class from given .class file in a ZIP-archive
      *
      * @param zipFile zip file name
      * @param fileName file name
      */
     public ClassParser(final String zipFile, final String fileName) {
-        isZip = true;
-        fileOwned = true;
+        this.isZip = true;
+        this.fileOwned = true;
         this.zipFile = zipFile;
         this.fileName = fileName;
     }
 
-
     /**
-     * Parses the given Java class file and return an object that represents
-     * the contained data, i.e., constants, methods, fields and commands.
-     * A <em>ClassFormatException</em> is raised, if the file is not a valid
-     * .class file. (This does not include verification of the byte code as it
-     * is performed by the java interpreter).
+     * Parses the given Java class file and return an object that represents the contained data, i.e., constants, methods,
+     * fields and commands. A <em>ClassFormatException</em> is raised, if the file is not a valid .class file. (This does
+     * not include verification of the byte code as it is performed by the java interpreter).
      *
      * @return Class object representing the parsed class file
-     * @throws  IOException
-     * @throws  ClassFormatException
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     public JavaClass parse() throws IOException, ClassFormatException {
         ZipFile zip = null;
@@ -130,11 +122,9 @@ public JavaClass parse() throws IOException, ClassFormatException {
                         throw new IOException("File " + fileName + " not found");
                     }
 
-                    dataInputStream = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
-                            BUFSIZE));
+                    dataInputStream = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), BUFSIZE));
                 } else {
-                    dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(
-                            fileName), BUFSIZE));
+                    dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(fileName), BUFSIZE));
                 }
             }
             /****************** Read headers ********************************/
@@ -157,19 +147,19 @@ public JavaClass parse() throws IOException, ClassFormatException {
             // Read class attributes
             readAttributes();
             // Check for unknown variables
-            //Unknown[] u = Unknown.getUnknownAttributes();
-            //for (int i=0; i < u.length; i++)
-            //  System.err.println("WARNING: " + u[i]);
+            // Unknown[] u = Unknown.getUnknownAttributes();
+            // for (int i=0; i < u.length; i++)
+            // System.err.println("WARNING: " + u[i]);
             // Everything should have been read now
-            //      if(file.available() > 0) {
-            //        int bytes = file.available();
-            //        byte[] buf = new byte[bytes];
-            //        file.read(buf);
-            //        if(!(isZip && (buf.length == 1))) {
-            //      System.err.println("WARNING: Trailing garbage at end of " + fileName);
-            //      System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
-            //        }
-            //      }
+            // if(file.available() > 0) {
+            // int bytes = file.available();
+            // byte[] buf = new byte[bytes];
+            // file.read(buf);
+            // if(!(isZip && (buf.length == 1))) {
+            // System.err.println("WARNING: Trailing garbage at end of " + fileName);
+            // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
+            // }
+            // }
         } finally {
             // Read everything of interest, so close the file
             if (fileOwned) {
@@ -177,92 +167,88 @@ public JavaClass parse() throws IOException, ClassFormatException {
                     if (dataInputStream != null) {
                         dataInputStream.close();
                     }
-                } catch (final IOException ioe) {
-                    //ignore close exceptions
+                } catch (final IOException ignored) {
+                    // ignore close exceptions
                 }
             }
             try {
                 if (zip != null) {
                     zip.close();
                 }
-            } catch (final IOException ioe) {
-                //ignore close exceptions
+            } catch (final IOException ignored) {
+                // ignore close exceptions
             }
         }
         // Return the information we have gathered in a new object
-        return new JavaClass(classNameIndex, superclassNameIndex, fileName, major, minor,
-                accessFlags, constantPool, interfaces, fields, methods, attributes, isZip
-                        ? JavaClass.ZIP
-                        : JavaClass.FILE);
+        return new JavaClass(classNameIndex, superclassNameIndex, fileName, major, minor, accessFlags, constantPool, interfaces, fields, methods, attributes,
+            isZip ? JavaClass.ZIP : JavaClass.FILE);
     }
 
-
     /**
      * Reads information about the attributes of the class.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     private void readAttributes() throws IOException, ClassFormatException {
-        final int attributes_count = dataInputStream.readUnsignedShort();
-        attributes = new Attribute[attributes_count];
-        for (int i = 0; i < attributes_count; i++) {
+        final int attributesCount = dataInputStream.readUnsignedShort();
+        attributes = new Attribute[attributesCount];
+        for (int i = 0; i < attributesCount; i++) {
             attributes[i] = Attribute.readAttribute(dataInputStream, constantPool);
         }
     }
 
-
     /**
      * Reads information about the class and its super class.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     private void readClassInfo() throws IOException, ClassFormatException {
         accessFlags = dataInputStream.readUnsignedShort();
-        /* Interfaces are implicitely abstract, the flag should be set
-         * according to the JVM specification.
+        /*
+         * Interfaces are implicitly abstract, the flag should be set according to the JVM specification.
          */
         if ((accessFlags & Const.ACC_INTERFACE) != 0) {
             accessFlags |= Const.ACC_ABSTRACT;
         }
-        if (((accessFlags & Const.ACC_ABSTRACT) != 0)
-                && ((accessFlags & Const.ACC_FINAL) != 0)) {
+        if ((accessFlags & Const.ACC_ABSTRACT) != 0 && (accessFlags & Const.ACC_FINAL) != 0) {
             throw new ClassFormatException("Class " + fileName + " can't be both final and abstract");
         }
         classNameIndex = dataInputStream.readUnsignedShort();
         superclassNameIndex = dataInputStream.readUnsignedShort();
     }
 
-
     /**
      * Reads constant pool entries.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     private void readConstantPool() throws IOException, ClassFormatException {
         constantPool = new ConstantPool(dataInputStream);
     }
 
-
     /**
      * Reads information about the fields of the class, i.e., its variables.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     private void readFields() throws IOException, ClassFormatException {
-        final int fields_count = dataInputStream.readUnsignedShort();
-        fields = new Field[fields_count];
-        for (int i = 0; i < fields_count; i++) {
+        final int fieldsCount = dataInputStream.readUnsignedShort();
+        fields = new Field[fieldsCount];
+        for (int i = 0; i < fieldsCount; i++) {
             fields[i] = new Field(dataInputStream, constantPool);
         }
     }
 
-
     /******************** Private utility methods **********************/
     /**
-     * Checks whether the header of the file is ok.
-     * Of course, this has to be the first action on successive file reads.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     * Checks whether the header of the file is ok. Of course, this has to be the first action on successive file reads.
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     private void readID() throws IOException, ClassFormatException {
         if (dataInputStream.readInt() != Const.JVM_CLASSFILE_MAGIC) {
@@ -270,39 +256,39 @@ private void readID() throws IOException, ClassFormatException {
         }
     }
 
-
     /**
      * Reads information about the interfaces implemented by this class.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     private void readInterfaces() throws IOException, ClassFormatException {
-        final int interfaces_count = dataInputStream.readUnsignedShort();
-        interfaces = new int[interfaces_count];
-        for (int i = 0; i < interfaces_count; i++) {
+        final int interfacesCount = dataInputStream.readUnsignedShort();
+        interfaces = new int[interfacesCount];
+        for (int i = 0; i < interfacesCount; i++) {
             interfaces[i] = dataInputStream.readUnsignedShort();
         }
     }
 
-
     /**
      * Reads information about the methods of the class.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
-    private void readMethods() throws IOException, ClassFormatException {
-        final int methods_count = dataInputStream.readUnsignedShort();
-        methods = new Method[methods_count];
-        for (int i = 0; i < methods_count; i++) {
+    private void readMethods() throws IOException {
+        final int methodsCount = dataInputStream.readUnsignedShort();
+        methods = new Method[methodsCount];
+        for (int i = 0; i < methodsCount; i++) {
             methods[i] = new Method(dataInputStream, constantPool);
         }
     }
 
-
     /**
      * Reads major and minor version of compiler which created the file.
-     * @throws  IOException
-     * @throws  ClassFormatException
+     *
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     private void readVersion() throws IOException, ClassFormatException {
         minor = dataInputStream.readUnsignedShort();
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java
index c486f2bb273..498a8c71b18 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,126 +23,173 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class represents a chunk of Java byte code contained in a
- * method. It is instantiated by the
- * <em>Attribute.readAttribute()</em> method. A <em>Code</em>
- * attribute contains informations about operand stack, local
- * variables, byte code and the exceptions handled within this
- * method.
+ * This class represents a chunk of Java byte code contained in a method. It is instantiated by the
+ * <em>Attribute.readAttribute()</em> method. A <em>Code</em> attribute contains informations about operand stack, local
+ * variables, byte code and the exceptions handled within this method.
  *
- * This attribute has attributes itself, namely <em>LineNumberTable</em> which
- * is used for debugging purposes and <em>LocalVariableTable</em> which
- * contains information about the local variables.
+ * This attribute has attributes itself, namely <em>LineNumberTable</em> which is used for debugging purposes and
+ * <em>LocalVariableTable</em> which contains information about the local variables.
  *
- * @see     Attribute
- * @see     CodeException
- * @see     LineNumberTable
+ * <pre>
+ * Code_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 max_stack;
+ *   u2 max_locals;
+ *   u4 code_length;
+ *   u1 code[code_length];
+ *   u2 exception_table_length;
+ *   {
+ *     u2 start_pc;
+ *     u2 end_pc;
+ *     u2 handler_pc;
+ *     u2 catch_type;
+ *   } exception_table[exception_table_length];
+ *   u2 attributes_count;
+ *   attribute_info attributes[attributes_count];
+ * }
+ * </pre>
+ * @see Attribute
+ * @see CodeException
+ * @see LineNumberTable
  * @see LocalVariableTable
+ * @LastModified: Feb 2023
  */
 public final class Code extends Attribute {
 
-    private int maxStack; // Maximum size of stack used by this method  // TODO this could be made final (setter is not used)
-    private int maxLocals; // Number of local variables  // TODO this could be made final (setter is not used)
+    private int maxStack; // Maximum size of stack used by this method // TODO this could be made final (setter is not used)
+    private int maxLocals; // Number of local variables // TODO this could be made final (setter is not used)
     private byte[] code; // Actual byte code
     private CodeException[] exceptionTable; // Table of handled exceptions
     private Attribute[] attributes; // or LocalVariable
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param code The source Code.
      */
-    public Code(final Code c) {
-        this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(), c.getCode(), c
-                .getExceptionTable(), c.getAttributes(), c.getConstantPool());
+    public Code(final Code code) {
+        this(code.getNameIndex(), code.getLength(), code.getMaxStack(), code.getMaxLocals(), code.getCode(), code.getExceptionTable(), code.getAttributes(),
+                code.getConstantPool());
     }
 
-
     /**
-     * @param name_index Index pointing to the name <em>Code</em>
+     * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param file Input stream
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    Code(final int name_index, final int length, final DataInput file, final ConstantPool constant_pool)
-            throws IOException {
+    Code(final int nameIndex, final int length, final DataInput file, final ConstantPool constantPool) throws IOException {
         // Initialize with some default values which will be overwritten later
-        this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null,
-                (CodeException[]) null, (Attribute[]) null, constant_pool);
-        final int code_length = file.readInt();
-        code = new byte[code_length]; // Read byte code
+        this(nameIndex, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null, (CodeException[]) null, (Attribute[]) null, constantPool);
+        final int codeLength = Args.requireU4(file.readInt(), 1, "Code length attribute");
+        code = new byte[codeLength]; // Read byte code
         file.readFully(code);
-        /* Read exception table that contains all regions where an exception
-         * handler is active, i.e., a try { ... } catch() block.
+        /*
+         * Read exception table that contains all regions where an exception handler is active, i.e., a try { ... } catch()
+         * block.
          */
-        final int exception_table_length = file.readUnsignedShort();
-        exceptionTable = new CodeException[exception_table_length];
-        for (int i = 0; i < exception_table_length; i++) {
+        final int exceptionTableLength = file.readUnsignedShort();
+        exceptionTable = new CodeException[exceptionTableLength];
+        for (int i = 0; i < exceptionTableLength; i++) {
             exceptionTable[i] = new CodeException(file);
         }
-        /* Read all attributes, currently `LineNumberTable' and
-         * `LocalVariableTable'
+        /*
+         * Read all attributes, currently 'LineNumberTable' and 'LocalVariableTable'
          */
-        final int attributes_count = file.readUnsignedShort();
-        attributes = new Attribute[attributes_count];
-        for (int i = 0; i < attributes_count; i++) {
-            attributes[i] = Attribute.readAttribute(file, constant_pool);
+        final int attributesCount = file.readUnsignedShort();
+        attributes = new Attribute[attributesCount];
+        for (int i = 0; i < attributesCount; i++) {
+            attributes[i] = Attribute.readAttribute(file, constantPool);
         }
-        /* Adjust length, because of setAttributes in this(), s.b.  length
-         * is incorrect, because it didn't take the internal attributes
-         * into account yet! Very subtle bug, fixed in 3.1.1.
+        /*
+         * Adjust length, because of setAttributes in this(), s.b. length is incorrect, because it didn't take the internal
+         * attributes into account yet! Very subtle bug, fixed in 3.1.1.
          */
         super.setLength(length);
     }
 
-
     /**
-     * @param name_index Index pointing to the name <em>Code</em>
+     * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param maxStack Maximum size of stack
      * @param maxLocals Number of local variables
      * @param code Actual byte code
      * @param exceptionTable of handled exceptions
      * @param attributes Attributes of code: LineNumber or LocalVariable
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public Code(final int name_index, final int length, final int maxStack, final int maxLocals, final byte[] code,
-            final CodeException[] exceptionTable, final Attribute[] attributes, final ConstantPool constant_pool) {
-        super(Const.ATTR_CODE, name_index, length, constant_pool);
-        this.maxStack = maxStack;
-        this.maxLocals = maxLocals;
-        this.code = code != null ? code : new byte[0];
-        this.exceptionTable = exceptionTable != null ? exceptionTable : new CodeException[0];
-        this.attributes = attributes != null ? attributes : new Attribute[0];
+    public Code(final int nameIndex, final int length, final int maxStack, final int maxLocals, final byte[] code, final CodeException[] exceptionTable,
+        final Attribute[] attributes, final ConstantPool constantPool) {
+        super(Const.ATTR_CODE, nameIndex, length, constantPool);
+        this.maxStack = Args.requireU2(maxStack, "maxStack");
+        this.maxLocals = Args.requireU2(maxLocals, "maxLocals");
+        this.code = code != null ? code : Const.EMPTY_BYTE_ARRAY;
+        this.exceptionTable = exceptionTable != null ? exceptionTable : CodeException.EMPTY_CODE_EXCEPTION_ARRAY;
+        Args.requireU2(this.exceptionTable.length, "exceptionTable.length");
+        this.attributes = attributes != null ? attributes : EMPTY_ARRAY;
         super.setLength(calculateLength()); // Adjust length
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitCode(this);
     }
 
+    /**
+     * @return the full size of this code attribute, minus its first 6 bytes, including the size of all its contained
+     *         attributes
+     */
+    private int calculateLength() {
+        int len = 0;
+        if (attributes != null) {
+            for (final Attribute attribute : attributes) {
+                len += attribute.getLength() + 6 /* attribute header size */;
+            }
+        }
+        return len + getInternalLength();
+    }
+
+    /**
+     * @return deep copy of this attribute
+     *
+     * @param constantPool the constant pool to duplicate
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final Code c = (Code) clone();
+        if (code != null) {
+            c.code = code.clone();
+        }
+        c.setConstantPool(constantPool);
+        c.exceptionTable = new CodeException[exceptionTable.length];
+        Arrays.setAll(c.exceptionTable, i -> exceptionTable[i].copy());
+        c.attributes = new Attribute[attributes.length];
+        Arrays.setAll(c.attributes, i -> attributes[i].copy(constantPool));
+        return c;
+    }
 
     /**
      * Dump code attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(maxStack);
         file.writeShort(maxLocals);
@@ -159,7 +205,6 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
     /**
      * @return Collection of code attributes.
      * @see Attribute
@@ -168,6 +213,31 @@ public Attribute[] getAttributes() {
         return attributes;
     }
 
+    /**
+     * @return Actual byte code of the method.
+     */
+    public byte[] getCode() {
+        return code;
+    }
+
+    /**
+     * @return Table of handled exceptions.
+     * @see CodeException
+     */
+    public CodeException[] getExceptionTable() {
+        return exceptionTable;
+    }
+
+    /**
+     * @return the internal length of this code attribute (minus the first 6 bytes) and excluding all its attributes
+     */
+    private int getInternalLength() {
+        return 2 /* maxStack */ + 2 /* maxLocals */ + 4 /* code length */
+            + code.length /* byte-code */
+            + 2 /* exception-table length */
+            + 8 * (exceptionTable == null ? 0 : exceptionTable.length) /* exception table */
+            + 2 /* attributes count */;
+    }
 
     /**
      * @return LineNumberTable of Code, if it has one
@@ -181,7 +251,6 @@ public LineNumberTable getLineNumberTable() {
         return null;
     }
 
-
     /**
      * @return LocalVariableTable of Code, if it has one
      */
@@ -194,24 +263,6 @@ public LocalVariableTable getLocalVariableTable() {
         return null;
     }
 
-
-    /**
-     * @return Actual byte code of the method.
-     */
-    public byte[] getCode() {
-        return code;
-    }
-
-
-    /**
-     * @return Table of handled exceptions.
-     * @see CodeException
-     */
-    public CodeException[] getExceptionTable() {
-        return exceptionTable;
-    }
-
-
     /**
      * @return Number of local variables.
      */
@@ -219,7 +270,6 @@ public int getMaxLocals() {
         return maxLocals;
     }
 
-
     /**
      * @return Maximum size of stack used by this method.
      */
@@ -227,86 +277,62 @@ public int getMaxStack() {
         return maxStack;
     }
 
-
-    /**
-     * @return the internal length of this code attribute (minus the first 6 bytes)
-     * and excluding all its attributes
-     */
-    private int getInternalLength() {
-        return 2 /*maxStack*/+ 2 /*maxLocals*/+ 4 /*code length*/
-                + code.length /*byte-code*/
-                + 2 /*exception-table length*/
-                + 8 * (exceptionTable == null ? 0 : exceptionTable.length) /* exception table */
-                + 2 /* attributes count */;
-    }
-
-
-    /**
-     * @return the full size of this code attribute, minus its first 6 bytes,
-     * including the size of all its contained attributes
-     */
-    private int calculateLength() {
-        int len = 0;
-        if (attributes != null) {
-            for (final Attribute attribute : attributes) {
-                len += attribute.getLength() + 6 /*attribute header size*/;
-            }
-        }
-        return len + getInternalLength();
-    }
-
-
     /**
      * @param attributes the attributes to set for this Code
      */
-    public void setAttributes( final Attribute[] attributes ) {
-        this.attributes = attributes != null ? attributes : new Attribute[0];
+    public void setAttributes(final Attribute[] attributes) {
+        this.attributes = attributes != null ? attributes : EMPTY_ARRAY;
         super.setLength(calculateLength()); // Adjust length
     }
 
-
     /**
      * @param code byte code
      */
-    public void setCode( final byte[] code ) {
-        this.code = code != null ? code : new byte[0];
+    public void setCode(final byte[] code) {
+        this.code = code != null ? code : Const.EMPTY_BYTE_ARRAY;
         super.setLength(calculateLength()); // Adjust length
     }
 
-
     /**
      * @param exceptionTable exception table
      */
-    public void setExceptionTable( final CodeException[] exceptionTable ) {
-        this.exceptionTable = exceptionTable != null ? exceptionTable : new CodeException[0];
+    public void setExceptionTable(final CodeException[] exceptionTable) {
+        this.exceptionTable = exceptionTable != null ? exceptionTable : CodeException.EMPTY_CODE_EXCEPTION_ARRAY;
         super.setLength(calculateLength()); // Adjust length
     }
 
-
     /**
      * @param maxLocals maximum number of local variables
      */
-    public void setMaxLocals( final int maxLocals ) {
+    public void setMaxLocals(final int maxLocals) {
         this.maxLocals = maxLocals;
     }
 
-
     /**
      * @param maxStack maximum stack size
      */
-    public void setMaxStack( final int maxStack ) {
+    public void setMaxStack(final int maxStack) {
         this.maxStack = maxStack;
     }
 
+    /**
+     * @return String representation of code chunk.
+     */
+    @Override
+    public String toString() {
+        return toString(true);
+    }
 
     /**
+     * Converts this object to a String.
+     *
+     * @param verbose Provides verbose output when true.
      * @return String representation of code chunk.
      */
-    public String toString( final boolean verbose ) {
+    public String toString(final boolean verbose) {
         final StringBuilder buf = new StringBuilder(100); // CHECKSTYLE IGNORE MagicNumber
-        buf.append("Code(maxStack = ").append(maxStack).append(", maxLocals = ").append(
-                maxLocals).append(", code_length = ").append(code.length).append(")\n").append(
-                Utility.codeToString(code, super.getConstantPool(), 0, -1, verbose));
+        buf.append("Code(maxStack = ").append(maxStack).append(", maxLocals = ").append(maxLocals).append(", code_length = ").append(code.length).append(")\n")
+            .append(Utility.codeToString(code, super.getConstantPool(), 0, -1, verbose));
         if (exceptionTable.length > 0) {
             buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n");
             for (final CodeException exception : exceptionTable) {
@@ -322,38 +348,4 @@ public String toString( final boolean verbose ) {
         }
         return buf.toString();
     }
-
-
-    /**
-     * @return String representation of code chunk.
-     */
-    @Override
-    public String toString() {
-        return toString(true);
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     *
-     * @param _constant_pool the constant pool to duplicate
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final Code c = (Code) clone();
-        if (code != null) {
-            c.code = new byte[code.length];
-            System.arraycopy(code, 0, c.code, 0, code.length);
-        }
-        c.setConstantPool(_constant_pool);
-        c.exceptionTable = new CodeException[exceptionTable.length];
-        for (int i = 0; i < exceptionTable.length; i++) {
-            c.exceptionTable[i] = exceptionTable[i].copy();
-        }
-        c.attributes = new Attribute[attributes.length];
-        for (int i = 0; i < attributes.length; i++) {
-            c.attributes[i] = attributes[i].copy(_constant_pool);
-        }
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java
index a1b8e46c825..ee224e6b348 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,101 +25,136 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class represents an entry in the exception table of the <em>Code</em>
- * attribute and is used only there. It contains a range in which a
- * particular exception handler is active.
+ * This class represents an entry in the exception table of the <em>Code</em> attribute and is used only there. It
+ * contains a range in which a particular exception handler is active.
  *
- * @see     Code
- * @LastModified: May 2021
+ * <pre>
+ * Code_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 max_stack;
+ *   u2 max_locals;
+ *   u4 code_length;
+ *   u1 code[code_length];
+ *   u2 exception_table_length;
+ *   {
+ *     u2 start_pc;
+ *     u2 end_pc;
+ *     u2 handler_pc;
+ *     u2 catch_type;
+ *   } exception_table[exception_table_length];
+ *   u2 attributes_count;
+ *   attribute_info attributes[attributes_count];
+ * }
+ * </pre>
+ *
+ * @see Code
+ * @LastModified: Feb 2023
  */
 public final class CodeException implements Cloneable, Node {
 
-    private int startPc; // Range in the code the exception handler is
-    private int endPc; // active. startPc is inclusive, endPc exclusive
-    private int handlerPc; /* Starting address of exception handler, i.e.,
-     * an offset from start of code.
+    /**
+     * Empty array.
      */
-    private int catchType; /* If this is zero the handler catches any
-     * exception, otherwise it points to the
-     * exception class which is to be caught.
+    static final CodeException[] EMPTY_CODE_EXCEPTION_ARRAY = {};
+
+    /** Range in the code the exception handler. */
+    private int startPc;
+
+    /** active. startPc is inclusive, endPc exclusive. */
+    private int endPc;
+
+    /**
+     * Starting address of exception handler, i.e., an offset from start of code.
      */
+    private int handlerPc;
 
+    /*
+     * If this is zero the handler catches any exception, otherwise it points to the exception class which is to be caught.
+     */
+    private int catchType;
 
     /**
-     * Initialize from another object.
+     * Constructs a new instance from another instance.
+     *
+     * @param c Source for copying.
      */
     public CodeException(final CodeException c) {
         this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
     }
 
-
     /**
-     * Construct object from file stream.
+     * Constructs a new instance from a DataInput.
+     *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     CodeException(final DataInput file) throws IOException {
-        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
-                .readUnsignedShort());
+        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort());
     }
 
-
     /**
-     * @param startPc Range in the code the exception handler is active,
-     * startPc is inclusive while
+     * Constructs a new instance.
+     *
+     * @param startPc Range in the code the exception handler is active, startPc is inclusive while
      * @param endPc is exclusive
-     * @param handlerPc Starting address of exception handler, i.e.,
-     * an offset from start of code.
-     * @param catchType If zero the handler catches any
-     * exception, otherwise it points to the exception class which is
-     * to be caught.
+     * @param handlerPc Starting address of exception handler, i.e., an offset from start of code.
+     * @param catchType If zero the handler catches any exception, otherwise it points to the exception class which is to be
+     *        caught.
      */
     public CodeException(final int startPc, final int endPc, final int handlerPc, final int catchType) {
-        this.startPc = startPc;
-        this.endPc = endPc;
-        this.handlerPc = handlerPc;
-        this.catchType = catchType;
+        this.startPc = Args.requireU2(startPc, "startPc");
+        this.endPc = Args.requireU2(endPc, "endPc");
+        this.handlerPc = Args.requireU2(handlerPc, "handlerPc");
+        this.catchType = Args.requireU2(catchType, "catchType");
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitCodeException(this);
     }
 
+    /**
+     * @return deep copy of this object
+     */
+    public CodeException copy() {
+        try {
+            return (CodeException) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
 
     /**
-     * Dump code exception to file stream in binary format.
+     * Dumps code exception to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(startPc);
         file.writeShort(endPc);
         file.writeShort(handlerPc);
         file.writeShort(catchType);
     }
 
-
     /**
-     * @return 0, if the handler catches any exception, otherwise it points to
-     * the exception class which is to be caught.
+     * @return 0, if the handler catches any exception, otherwise it points to the exception class which is to be caught.
      */
     public int getCatchType() {
         return catchType;
     }
 
-
     /**
      * @return Exclusive end index of the region where the handler is active.
      */
@@ -127,7 +162,6 @@ public int getEndPC() {
         return endPc;
     }
 
-
     /**
      * @return Starting address of exception handler, relative to the code.
      */
@@ -135,7 +169,6 @@ public int getHandlerPC() {
         return handlerPc;
     }
 
-
     /**
      * @return Inclusive start index of the region where the handler is active.
      */
@@ -143,78 +176,58 @@ public int getStartPC() {
         return startPc;
     }
 
-
     /**
      * @param catchType the type of exception that is caught
      */
-    public void setCatchType( final int catchType ) {
+    public void setCatchType(final int catchType) {
         this.catchType = catchType;
     }
 
-
     /**
      * @param endPc end of handled block
      */
-    public void setEndPC( final int endPc ) {
+    public void setEndPC(final int endPc) {
         this.endPc = endPc;
     }
 
-
     /**
      * @param handlerPc where the actual code is
      */
-    public void setHandlerPC( final int handlerPc ) { // TODO unused
+    public void setHandlerPC(final int handlerPc) { // TODO unused
         this.handlerPc = handlerPc;
     }
 
-
     /**
      * @param startPc start of handled block
      */
-    public void setStartPC( final int startPc ) { // TODO unused
+    public void setStartPC(final int startPc) { // TODO unused
         this.startPc = startPc;
     }
 
-
     /**
      * @return String representation.
      */
     @Override
     public String toString() {
-        return "CodeException(startPc = " + startPc + ", endPc = " + endPc + ", handlerPc = "
-                + handlerPc + ", catchType = " + catchType + ")";
+        return "CodeException(startPc = " + startPc + ", endPc = " + endPc + ", handlerPc = " + handlerPc + ", catchType = " + catchType + ")";
     }
 
+    public String toString(final ConstantPool cp) {
+        return toString(cp, true);
+    }
 
     /**
+     * @param cp constant pool source.
+     * @param verbose Output more if true.
      * @return String representation.
      */
-    public String toString( final ConstantPool cp, final boolean verbose ) {
+    public String toString(final ConstantPool cp, final boolean verbose) {
         String str;
         if (catchType == 0) {
             str = "<Any exception>(0)";
         } else {
-            str = Utility.compactClassName(cp.getConstantString(catchType, Const.CONSTANT_Class), false)
-                    + (verbose ? "(" + catchType + ")" : "");
+            str = Utility.compactClassName(cp.getConstantString(catchType, Const.CONSTANT_Class), false) + (verbose ? "(" + catchType + ")" : "");
         }
         return startPc + "\t" + endPc + "\t" + handlerPc + "\t" + str;
     }
-
-
-    public String toString( final ConstantPool cp ) {
-        return toString(cp, true);
-    }
-
-
-    /**
-     * @return deep copy of this object
-     */
-    public CodeException copy() {
-        try {
-            return (CodeException) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java
index 56ffb23cc83..885e1b599eb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java
@@ -39,81 +39,24 @@ public abstract class Constant implements Cloneable, Node {
     private static BCELComparator bcelComparator = new BCELComparator() {
 
         @Override
-        public boolean equals( final Object o1, final Object o2 ) {
+        public boolean equals(final Object o1, final Object o2) {
             final Constant THIS = (Constant) o1;
             final Constant THAT = (Constant) o2;
             return Objects.equals(THIS.toString(), THAT.toString());
         }
 
-
         @Override
-        public int hashCode( final Object o ) {
+        public int hashCode(final Object o) {
             final Constant THIS = (Constant) o;
             return THIS.toString().hashCode();
         }
     };
 
-    /* In fact this tag is redundant since we can distinguish different
-     * `Constant' objects by their type, i.e., via `instanceof'. In some
-     * places we will use the tag for switch()es anyway.
-     *
-     * First, we want match the specification as closely as possible. Second we
-     * need the tag as an index to select the corresponding class name from the
-     * `CONSTANT_NAMES' array.
-     */
-    private byte tag;
-
-    Constant(final byte tag) {
-        this.tag = tag;
-    }
-
-    /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public abstract void accept( Visitor v );
-
-    public abstract void dump( DataOutputStream file ) throws IOException;
-
-    /**
-     * @return Tag of constant, i.e., its type. No setTag() method to avoid
-     * confusion.
-     */
-    public final byte getTag() {
-        return tag;
-    }
-
-    /**
-     * @return String representation.
-     */
-    @Override
-    public String toString() {
-        return Const.getConstantName(tag) + "[" + tag + "]";
-    }
-
     /**
-     * @return deep copy of this constant
+     * @return Comparison strategy object
      */
-    public Constant copy() {
-        try {
-            return (Constant) super.clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
-    }
-
-    @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (final CloneNotSupportedException e) {
-            throw new Error("Clone Not Supported"); // never happens
-        }
+    public static BCELComparator getComparator() {
+        return bcelComparator;
     }
 
     /**
@@ -168,39 +111,95 @@ public static Constant readConstant(final DataInput dataInput) throws IOExceptio
     }
 
     /**
-     * @return Comparison strategy object
+     * @param comparator Comparison strategy object
      */
-    public static BCELComparator getComparator() {
-        return bcelComparator;
+    public static void setComparator(final BCELComparator comparator) {
+        bcelComparator = comparator;
     }
 
+    /*
+     * In fact this tag is redundant since we can distinguish different 'Constant' objects by their type, i.e., via
+     * 'instanceof'. In some places we will use the tag for switch()es anyway.
+     *
+     * First, we want match the specification as closely as possible. Second we need the tag as an index to select the
+     * corresponding class name from the 'CONSTANT_NAMES' array.
+     */
     /**
-     * @param comparator Comparison strategy object
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    public static void setComparator( final BCELComparator comparator ) {
-        bcelComparator = comparator;
+    @java.lang.Deprecated
+    protected byte tag; // TODO should be private & final
+
+    Constant(final byte tag) {
+        this.tag = tag;
+    }
+
+    /**
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public abstract void accept(Visitor v);
+
+    @Override
+    public Object clone() {
+        try {
+            return super.clone();
+        } catch (final CloneNotSupportedException e) {
+            throw new Error("Clone Not Supported"); // never happens
+        }
     }
 
     /**
-     * Returns value as defined by given BCELComparator strategy.
-     * By default two Constant objects are said to be equal when
+     * @return deep copy of this constant
+     */
+    public Constant copy() {
+        try {
+            return (Constant) super.clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
+
+    public abstract void dump(DataOutputStream file) throws IOException;
+
+    /**
+     * Returns value as defined by given BCELComparator strategy. By default two Constant objects are said to be equal when
      * the result of toString() is equal.
      *
-     * @see java.lang.Object#equals(java.lang.Object)
+     * @see Object#equals(Object)
      */
     @Override
-    public boolean equals( final Object obj ) {
+    public boolean equals(final Object obj) {
         return bcelComparator.equals(this, obj);
     }
 
     /**
-     * Returns value as defined by given BCELComparator strategy.
-     * By default return the hashcode of the result of toString().
+     * @return Tag of constant, i.e., its type. No setTag() method to avoid confusion.
+     */
+    public final byte getTag() {
+        return tag;
+    }
+
+    /**
+     * Returns value as defined by given BCELComparator strategy. By default return the hashcode of the result of
+     * toString().
      *
-     * @see java.lang.Object#hashCode()
+     * @see Object#hashCode()
      */
     @Override
     public int hashCode() {
         return bcelComparator.hashCode(this);
     }
+
+    /**
+     * @return String representation.
+     */
+    @Override
+    public String toString() {
+        return Const.getConstantName(tag) + "[" + tag + "]";
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java
index 1573bd2172f..71fd91b249a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java
@@ -26,8 +26,7 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * Abstract super class for Fieldref, Methodref, InterfaceMethodref and
- *                          InvokeDynamic constants.
+ * Abstract super class for Fieldref, Methodref, InterfaceMethodref and InvokeDynamic constants.
  *
  * @see     ConstantFieldref
  * @see     ConstantMethodref
@@ -42,71 +41,76 @@ public abstract class ConstantCP extends Constant {
      */
     // Note that this field is used to store the
     // bootstrap_method_attr_index of a ConstantInvokeDynamic.
-    private int class_index;
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected int class_index; // TODO make private (has getter & setter)
     // This field has the same meaning for all subclasses.
-    private int name_and_type_index;
 
     /**
-     * Initialize from another object.
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    public ConstantCP(final ConstantCP c) {
-        this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
-    }
-
+    @java.lang.Deprecated
+    protected int name_and_type_index; // TODO make private (has getter & setter)
 
     /**
      * Initialize instance from file data.
      *
-     * @param tag  Constant type tag
+     * @param tag Constant type tag
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantCP(final byte tag, final DataInput file) throws IOException {
         this(tag, file.readUnsignedShort(), file.readUnsignedShort());
     }
 
-
     /**
-     * @param class_index Reference to the class containing the field
-     * @param name_and_type_index and the field signature
+     * @param classIndex Reference to the class containing the field
+     * @param nameAndTypeIndex and the field signature
      */
-    protected ConstantCP(final byte tag, final int class_index, final int name_and_type_index) {
+    protected ConstantCP(final byte tag, final int classIndex, final int nameAndTypeIndex) {
         super(tag);
-        this.class_index = class_index;
-        this.name_and_type_index = name_and_type_index;
+        this.class_index = classIndex;
+        this.name_and_type_index = nameAndTypeIndex;
     }
 
+    /**
+     * Initialize from another object.
+     *
+     * @param c Source to copy.
+     */
+    public ConstantCP(final ConstantCP c) {
+        this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
+    }
 
     /**
      * Dump constant field reference to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public final void dump( final DataOutputStream file ) throws IOException {
+    public final void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeShort(class_index);
         file.writeShort(name_and_type_index);
     }
 
-
     /**
-     * @return Reference (index) to class this constant refers to.
+     * @return Class this field belongs to.
      */
-    public final int getClassIndex() {
-        return class_index;
+    public String getClass(final ConstantPool cp) {
+        return cp.constantToString(class_index, Const.CONSTANT_Class);
     }
 
-
     /**
-     * @param class_index points to Constant_class
+     * @return Reference (index) to class this constant refers to.
      */
-    public final void setClassIndex( final int class_index ) {
-        this.class_index = class_index;
+    public final int getClassIndex() {
+        return class_index;
     }
 
-
     /**
      * @return Reference (index) to signature of the field.
      */
@@ -114,31 +118,27 @@ public final int getNameAndTypeIndex() {
         return name_and_type_index;
     }
 
-
     /**
-     * @param name_and_type_index points to Constant_NameAndType
+     * @param classIndex points to Constant_class
      */
-    public final void setNameAndTypeIndex( final int name_and_type_index ) {
-        this.name_and_type_index = name_and_type_index;
+    public final void setClassIndex(final int classIndex) {
+        this.class_index = classIndex;
     }
 
-
     /**
-     * @return Class this field belongs to.
+     * @param nameAndTypeIndex points to Constant_NameAndType
      */
-    public String getClass( final ConstantPool cp ) {
-        return cp.constantToString(class_index, Const.CONSTANT_Class);
+    public final void setNameAndTypeIndex(final int nameAndTypeIndex) {
+        this.name_and_type_index = nameAndTypeIndex;
     }
 
-
     /**
      * @return String representation.
      *
-     * not final as ConstantInvokeDynamic needs to modify
+     *         not final as ConstantInvokeDynamic needs to modify
      */
     @Override
     public String toString() {
-        return super.toString() + "(class_index = " + class_index + ", name_and_type_index = "
-                + name_and_type_index + ")";
+        return super.toString() + "(class_index = " + class_index + ", name_and_type_index = " + name_and_type_index + ")";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java
index ed64179834a..9361a5d572f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java
@@ -28,24 +28,23 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a (external) class.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a (external) class.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantClass extends Constant implements ConstantObject {
 
     private int nameIndex; // Identical to ConstantString except for the name
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantClass(final ConstantClass c) {
         this(c.getNameIndex());
     }
 
-
     /**
      * Constructs an instance from file data.
      *
@@ -56,30 +55,25 @@ public ConstantClass(final ConstantClass c) {
         this(dataInput.readUnsignedShort());
     }
 
-
     /**
-     * @param nameIndex Name index in constant pool.  Should refer to a
-     * ConstantUtf8.
+     * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8.
      */
     public ConstantClass(final int nameIndex) {
         super(Const.CONSTANT_Class);
         this.nameIndex = nameIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantClass(this);
     }
 
-
     /**
      * Dumps constant class to file stream in binary format.
      *
@@ -87,44 +81,40 @@ public void accept( final Visitor v ) {
      * @throws IOException if an I/O error occurs writing to the DataOutputStream.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeShort(nameIndex);
     }
 
-
     /**
-     * @return Name index in constant pool of class name.
+     * @return dereferenced string
      */
-    public int getNameIndex() {
-        return nameIndex;
+    public String getBytes(final ConstantPool cp) {
+        return (String) getConstantValue(cp);
     }
 
-
     /**
-     * @param nameIndex the name index in the constant pool of this Constant Class
+     * @return String object
      */
-    public void setNameIndex( final int nameIndex ) {
-        this.nameIndex = nameIndex;
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return cp.getConstantUtf8(nameIndex).getBytes();
     }
 
-
-    /** @return String object
+    /**
+     * @return Name index in constant pool of class name.
      */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        final Constant c = cp.getConstant(nameIndex, Const.CONSTANT_Utf8);
-        return ((ConstantUtf8) c).getBytes();
+    public int getNameIndex() {
+        return nameIndex;
     }
 
-
-    /** @return dereferenced string
+    /**
+     * @param nameIndex the name index in the constant pool of this Constant Class
      */
-    public String getBytes( final ConstantPool cp ) {
-        return (String) getConstantValue(cp);
+    public void setNameIndex(final int nameIndex) {
+        this.nameIndex = nameIndex;
     }
 
-
     /**
      * @return String representation.
      */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java
index bdbabe63bbd..ebb3d0af46a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java
@@ -27,8 +27,7 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract  {@link Constant}
- * and represents a reference to a Double object.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a Double object.
  *
  * @see     Constant
  * @LastModified: Jun 2019
@@ -37,61 +36,56 @@ public final class ConstantDouble extends Constant implements ConstantObject {
 
     private double bytes;
 
-
-    /**
-     * @param bytes Data
-     */
-    public ConstantDouble(final double bytes) {
-        super(Const.CONSTANT_Double);
-        this.bytes = bytes;
-    }
-
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantDouble(final ConstantDouble c) {
         this(c.getBytes());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantDouble(final DataInput file) throws IOException {
         this(file.readDouble());
     }
 
+    /**
+     * @param bytes Data
+     */
+    public ConstantDouble(final double bytes) {
+        super(Const.CONSTANT_Double);
+        this.bytes = bytes;
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantDouble(this);
     }
 
-
     /**
      * Dump constant double to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeDouble(bytes);
     }
 
-
     /**
      * @return data, i.e., 8 bytes.
      */
@@ -99,15 +93,21 @@ public double getBytes() {
         return bytes;
     }
 
+    /**
+     * @return Double object
+     */
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return Double.valueOf(bytes);
+    }
 
     /**
      * @param bytes the raw bytes that represent the double value
      */
-    public void setBytes( final double bytes ) {
+    public void setBytes(final double bytes) {
         this.bytes = bytes;
     }
 
-
     /**
      * @return String representation.
      */
@@ -115,12 +115,4 @@ public void setBytes( final double bytes ) {
     public String toString() {
         return super.toString() + "(bytes = " + bytes + ")";
     }
-
-
-    /** @return Double object
-     */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        return bytes;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java
index 312f7d2efd3..d51d2707137 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDynamic.java
@@ -27,61 +27,58 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a dynamically computed constant.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a dynamically computed
+ * constant.
  *
- * @see     Constant
- * @see  <a href="https://bugs.openjdk.org/secure/attachment/74618/constant-dynamic.html">
- * Change request for JEP 309</a>
+ * @see Constant
+ * @see <a href="https://bugs.openjdk.java.net/secure/attachment/74618/constant-dynamic.html"> Change request for JEP
+ *      309</a>
  * @since 6.3
  */
 public final class ConstantDynamic extends ConstantCP {
 
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantDynamic(final ConstantDynamic c) {
         this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantDynamic(final DataInput file) throws IOException {
         this(file.readShort(), file.readShort());
     }
 
-
-    public ConstantDynamic(final int bootstrap_method_attr_index, final int name_and_type_index) {
-        super(Const.CONSTANT_Dynamic, bootstrap_method_attr_index, name_and_type_index);
+    public ConstantDynamic(final int bootstrapMethodAttrIndex, final int nameAndTypeIndex) {
+        super(Const.CONSTANT_Dynamic, bootstrapMethodAttrIndex, nameAndTypeIndex);
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitly
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e.,
+     * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantDynamic(this);
     }
 
     /**
      * @return Reference (index) to bootstrap method this constant refers to.
      *
-     * Note that this method is a functional duplicate of getClassIndex
-     * for use by ConstantInvokeDynamic.
+     *         Note that this method is a functional duplicate of getClassIndex for use by ConstantInvokeDynamic.
      * @since 6.0
      */
     public int getBootstrapMethodAttrIndex() {
-        return super.getClassIndex();  // AKA bootstrap_method_attr_index
+        return super.getClassIndex(); // AKA bootstrap_method_attr_index
     }
 
     /**
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java
index 23af999e469..32bd750bed4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java
@@ -28,47 +28,44 @@
 
 /**
  * This class represents a constant pool reference to a field.
- *
  */
 public final class ConstantFieldref extends ConstantCP {
 
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantFieldref(final ConstantFieldref c) {
         super(Const.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
     }
 
-
     /**
      * Initialize instance from input data.
      *
      * @param input input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantFieldref(final DataInput input) throws IOException {
         super(Const.CONSTANT_Fieldref, input);
     }
 
-
     /**
-     * @param class_index Reference to the class containing the Field
-     * @param name_and_type_index and the Field signature
+     * @param classIndex Reference to the class containing the Field
+     * @param nameAndTypeIndex and the Field signature
      */
-    public ConstantFieldref(final int class_index, final int name_and_type_index) {
-        super(Const.CONSTANT_Fieldref, class_index, name_and_type_index);
+    public ConstantFieldref(final int classIndex, final int nameAndTypeIndex) {
+        super(Const.CONSTANT_Fieldref, classIndex, nameAndTypeIndex);
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of Fields,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of Fields, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantFieldref(this);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java
index 24f0ac4db03..9c30c9e4fdb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java
@@ -27,8 +27,7 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a float object.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a float object.
  *
  * @see     Constant
  * @LastModified: Jun 2019
@@ -37,62 +36,57 @@ public final class ConstantFloat extends Constant implements ConstantObject {
 
     private float bytes;
 
-
-    /**
-     * @param bytes Data
-     */
-    public ConstantFloat(final float bytes) {
-        super(Const.CONSTANT_Float);
-        this.bytes = bytes;
-    }
-
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
     public ConstantFloat(final ConstantFloat c) {
         this(c.getBytes());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantFloat(final DataInput file) throws IOException {
         this(file.readFloat());
     }
 
+    /**
+     * @param bytes Data
+     */
+    public ConstantFloat(final float bytes) {
+        super(Const.CONSTANT_Float);
+        this.bytes = bytes;
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantFloat(this);
     }
 
-
     /**
      * Dump constant float to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeFloat(bytes);
     }
 
-
     /**
      * @return data, i.e., 4 bytes.
      */
@@ -100,15 +94,21 @@ public float getBytes() {
         return bytes;
     }
 
+    /**
+     * @return Float object
+     */
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return Float.valueOf(bytes);
+    }
 
     /**
      * @param bytes the raw bytes that represent this float
      */
-    public void setBytes( final float bytes ) {
+    public void setBytes(final float bytes) {
         this.bytes = bytes;
     }
 
-
     /**
      * @return String representation.
      */
@@ -116,12 +116,4 @@ public void setBytes( final float bytes ) {
     public String toString() {
         return super.toString() + "(bytes = " + bytes + ")";
     }
-
-
-    /** @return Float object
-     */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        return bytes;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java
index ceff5bdc41a..cabd2e15b03 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java
@@ -27,8 +27,7 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to an int object.
+ * This class is derived from the abstract {@link Constant} and represents a reference to an int object.
  *
  * @see     Constant
  * @LastModified: Jun 2019
@@ -37,61 +36,56 @@ public final class ConstantInteger extends Constant implements ConstantObject {
 
     private int bytes;
 
-
-    /**
-     * @param bytes Data
-     */
-    public ConstantInteger(final int bytes) {
-        super(Const.CONSTANT_Integer);
-        this.bytes = bytes;
-    }
-
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantInteger(final ConstantInteger c) {
         this(c.getBytes());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantInteger(final DataInput file) throws IOException {
         this(file.readInt());
     }
 
+    /**
+     * @param bytes Data
+     */
+    public ConstantInteger(final int bytes) {
+        super(Const.CONSTANT_Integer);
+        this.bytes = bytes;
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantInteger(this);
     }
 
-
     /**
      * Dump constant integer to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeInt(bytes);
     }
 
-
     /**
      * @return data, i.e., 4 bytes.
      */
@@ -99,15 +93,21 @@ public int getBytes() {
         return bytes;
     }
 
+    /**
+     * @return Integer object
+     */
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return Integer.valueOf(bytes);
+    }
 
     /**
      * @param bytes the raw bytes that represent this integer
      */
-    public void setBytes( final int bytes ) {
+    public void setBytes(final int bytes) {
         this.bytes = bytes;
     }
 
-
     /**
      * @return String representation.
      */
@@ -115,12 +115,4 @@ public void setBytes( final int bytes ) {
     public String toString() {
         return super.toString() + "(bytes = " + bytes + ")";
     }
-
-
-    /** @return Integer object
-     */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        return Integer.valueOf(bytes);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java
index 882ecaada10..14cac5b9000 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java
@@ -28,47 +28,44 @@
 
 /**
  * This class represents a constant pool reference to an interface method.
- *
  */
 public final class ConstantInterfaceMethodref extends ConstantCP {
 
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantInterfaceMethodref(final ConstantInterfaceMethodref c) {
         super(Const.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
     }
 
-
     /**
      * Initialize instance from input data.
      *
      * @param input input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantInterfaceMethodref(final DataInput input) throws IOException {
         super(Const.CONSTANT_InterfaceMethodref, input);
     }
 
-
     /**
-     * @param class_index Reference to the class containing the method
-     * @param name_and_type_index and the method signature
+     * @param classIndex Reference to the class containing the method
+     * @param nameAndTypeIndex and the method signature
      */
-    public ConstantInterfaceMethodref(final int class_index, final int name_and_type_index) {
-        super(Const.CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
+    public ConstantInterfaceMethodref(final int classIndex, final int nameAndTypeIndex) {
+        super(Const.CONSTANT_InterfaceMethodref, classIndex, nameAndTypeIndex);
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantInterfaceMethodref(this);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java
index 7191c7ea207..b4154edd5a4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInvokeDynamic.java
@@ -27,61 +27,57 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a invoke dynamic.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a invoke dynamic.
  *
- * @see     Constant
- * @see  <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.10">
- * The CONSTANT_InvokeDynamic_info Structure in The Java Virtual Machine Specification</a>
+ * @see Constant
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.10"> The
+ *      CONSTANT_InvokeDynamic_info Structure in The Java Virtual Machine Specification</a>
  * @since 6.0
  */
 public final class ConstantInvokeDynamic extends ConstantCP {
 
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantInvokeDynamic(final ConstantInvokeDynamic c) {
         this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantInvokeDynamic(final DataInput file) throws IOException {
-        this(file.readShort(), file.readShort());
+        this(file.readUnsignedShort(), file.readUnsignedShort());
     }
 
-
-    public ConstantInvokeDynamic(final int bootstrap_method_attr_index, final int name_and_type_index) {
-        super(Const.CONSTANT_InvokeDynamic, bootstrap_method_attr_index, name_and_type_index);
+    public ConstantInvokeDynamic(final int bootstrapMethodAttrIndex, final int nameAndTypeIndex) {
+        super(Const.CONSTANT_InvokeDynamic, bootstrapMethodAttrIndex, nameAndTypeIndex);
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitly
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e.,
+     * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantInvokeDynamic(this);
     }
 
     /**
      * @return Reference (index) to bootstrap method this constant refers to.
      *
-     * Note that this method is a functional duplicate of getClassIndex
-     * for use by ConstantInvokeDynamic.
+     *         Note that this method is a functional duplicate of getClassIndex for use by ConstantInvokeDynamic.
      * @since 6.0
      */
     public int getBootstrapMethodAttrIndex() {
-        return super.getClassIndex();  // AKA bootstrap_method_attr_index
+        return super.getClassIndex(); // AKA bootstrap_method_attr_index
     }
 
     /**
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java
index ff06eb8934d..c1e683abadb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java
@@ -27,8 +27,7 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a long object.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a long object.
  *
  * @see     Constant
  * @LastModified: Jan 2020
@@ -37,61 +36,56 @@ public final class ConstantLong extends Constant implements ConstantObject {
 
     private long bytes;
 
-
-    /**
-     * @param bytes Data
-     */
-    public ConstantLong(final long bytes) {
-        super(Const.CONSTANT_Long);
-        this.bytes = bytes;
-    }
-
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantLong(final ConstantLong c) {
         this(c.getBytes());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantLong(final DataInput file) throws IOException {
         this(file.readLong());
     }
 
+    /**
+     * @param bytes Data
+     */
+    public ConstantLong(final long bytes) {
+        super(Const.CONSTANT_Long);
+        this.bytes = bytes;
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantLong(this);
     }
 
-
     /**
      * Dump constant long to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeLong(bytes);
     }
 
-
     /**
      * @return data, i.e., 8 bytes.
      */
@@ -99,15 +93,21 @@ public long getBytes() {
         return bytes;
     }
 
+    /**
+     * @return Long object
+     */
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return Long.valueOf(bytes);
+    }
 
     /**
      * @param bytes the raw bytes that represent this long
      */
-    public void setBytes( final long bytes ) {
+    public void setBytes(final long bytes) {
         this.bytes = bytes;
     }
 
-
     /**
      * @return String representation.
      */
@@ -115,12 +115,4 @@ public void setBytes( final long bytes ) {
     public String toString() {
         return super.toString() + "(bytes = " + bytes + ")";
     }
-
-
-    /** @return Long object
-     */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        return bytes;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java
index d516f1a609f..40dfc8fe64a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodHandle.java
@@ -28,10 +28,9 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a method handle.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a method handle.
  *
- * @see     Constant
+ * @see Constant
  * @since 6.0
  */
 public final class ConstantMethodHandle extends Constant {
@@ -39,86 +38,76 @@ public final class ConstantMethodHandle extends Constant {
     private int referenceKind;
     private int referenceIndex;
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantMethodHandle(final ConstantMethodHandle c) {
         this(c.getReferenceKind(), c.getReferenceIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantMethodHandle(final DataInput file) throws IOException {
         this(file.readUnsignedByte(), file.readUnsignedShort());
     }
 
-
-    public ConstantMethodHandle(final int reference_kind, final int reference_index) {
+    public ConstantMethodHandle(final int referenceKind, final int referenceIndex) {
         super(Const.CONSTANT_MethodHandle);
-        this.referenceKind = reference_kind;
-        this.referenceIndex = reference_index;
+        this.referenceKind = referenceKind;
+        this.referenceIndex = referenceIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitly
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e.,
+     * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantMethodHandle(this);
     }
 
-
     /**
      * Dump method kind and index to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeByte(referenceKind);
         file.writeShort(referenceIndex);
     }
 
+    public int getReferenceIndex() {
+        return referenceIndex;
+    }
 
     public int getReferenceKind() {
         return referenceKind;
     }
 
-
-    public void setReferenceKind(final int reference_kind) {
-        this.referenceKind = reference_kind;
-    }
-
-
-    public int getReferenceIndex() {
-        return referenceIndex;
+    public void setReferenceIndex(final int referenceIndex) {
+        this.referenceIndex = referenceIndex;
     }
 
-
-    public void setReferenceIndex(final int reference_index) {
-        this.referenceIndex = reference_index;
+    public void setReferenceKind(final int referenceKind) {
+        this.referenceKind = referenceKind;
     }
 
-
     /**
      * @return String representation
      */
     @Override
     public String toString() {
-        return super.toString() + "(referenceKind = " + referenceKind +
-                ", referenceIndex = " + referenceIndex + ")";
+        return super.toString() + "(referenceKind = " + referenceKind + ", referenceIndex = " + referenceIndex + ")";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java
index 08f894f0d4e..654d801709c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodType.java
@@ -28,78 +28,70 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a method type.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a method type.
  *
- * @see     Constant
+ * @see Constant
  * @since 6.0
  */
 public final class ConstantMethodType extends Constant {
 
     private int descriptorIndex;
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantMethodType(final ConstantMethodType c) {
         this(c.getDescriptorIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantMethodType(final DataInput file) throws IOException {
         this(file.readUnsignedShort());
     }
 
-
-    public ConstantMethodType(final int descriptor_index) {
+    public ConstantMethodType(final int descriptorIndex) {
         super(Const.CONSTANT_MethodType);
-        this.descriptorIndex = descriptor_index;
+        this.descriptorIndex = descriptorIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitly
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e.,
+     * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantMethodType(this);
     }
 
-
     /**
      * Dump name and signature index to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeShort(descriptorIndex);
     }
 
-
     public int getDescriptorIndex() {
         return descriptorIndex;
     }
 
-
-    public void setDescriptorIndex(final int descriptor_index) {
-        this.descriptorIndex = descriptor_index;
+    public void setDescriptorIndex(final int descriptorIndex) {
+        this.descriptorIndex = descriptorIndex;
     }
 
-
     /**
      * @return String representation
      */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java
index d8bdd7fd789..cd914092c4f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java
@@ -28,47 +28,44 @@
 
 /**
  * This class represents a constant pool reference to a method.
- *
  */
 public final class ConstantMethodref extends ConstantCP {
 
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantMethodref(final ConstantMethodref c) {
         super(Const.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
     }
 
-
     /**
      * Initialize instance from input data.
      *
      * @param input input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantMethodref(final DataInput input) throws IOException {
         super(Const.CONSTANT_Methodref, input);
     }
 
-
     /**
-     * @param class_index Reference to the class containing the method
-     * @param name_and_type_index and the method signature
+     * @param classIndex Reference to the class containing the method
+     * @param nameAndTypeIndex and the method signature
      */
-    public ConstantMethodref(final int class_index, final int name_and_type_index) {
-        super(Const.CONSTANT_Methodref, class_index, name_and_type_index);
+    public ConstantMethodref(final int classIndex, final int nameAndTypeIndex) {
+        super(Const.CONSTANT_Methodref, classIndex, nameAndTypeIndex);
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantMethodref(this);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java
index 12c37069255..06754b9676e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantModule.java
@@ -28,106 +28,98 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a module.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a module.
  *
- * <p>Note: Early access Java 9 support- currently subject to change</p>
+ * <p>
+ * Note: Early access Java 9 support- currently subject to change
+ * </p>
  *
- * @see     Constant
+ * @see Constant
  * @since 6.1
  */
 public final class ConstantModule extends Constant implements ConstantObject {
 
     private int nameIndex;
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantModule(final ConstantModule c) {
         this(c.getNameIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantModule(final DataInput file) throws IOException {
         this(file.readUnsignedShort());
     }
 
-
     /**
-     * @param nameIndex Name index in constant pool.  Should refer to a
-     * ConstantUtf8.
+     * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8.
      */
     public ConstantModule(final int nameIndex) {
         super(Const.CONSTANT_Module);
         this.nameIndex = nameIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitly
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e.,
+     * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantModule(this);
     }
 
-
     /**
      * Dump constant module to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeShort(nameIndex);
     }
 
-
     /**
-     * @return Name index in constant pool of module name.
+     * @return dereferenced string
      */
-    public int getNameIndex() {
-        return nameIndex;
+    public String getBytes(final ConstantPool cp) {
+        return (String) getConstantValue(cp);
     }
 
-
     /**
-     * @param nameIndex the name index in the constant pool of this Constant Module
+     * @return String object
      */
-    public void setNameIndex( final int nameIndex ) {
-        this.nameIndex = nameIndex;
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return cp.getConstantUtf8(nameIndex).getBytes();
     }
 
-
-    /** @return String object
+    /**
+     * @return Name index in constant pool of module name.
      */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        final Constant c = cp.getConstant(nameIndex, Const.CONSTANT_Utf8);
-        return ((ConstantUtf8) c).getBytes();
+    public int getNameIndex() {
+        return nameIndex;
     }
 
-
-    /** @return dereferenced string
+    /**
+     * @param nameIndex the name index in the constant pool of this Constant Module
      */
-    public String getBytes( final ConstantPool cp ) {
-        return (String) getConstantValue(cp);
+    public void setNameIndex(final int nameIndex) {
+        this.nameIndex = nameIndex;
     }
 
-
     /**
      * @return String representation.
      */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java
index f1ce11948aa..fbf09c9794c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java
@@ -28,37 +28,35 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to the name and signature
- * of a field or method.
+ * This class is derived from the abstract {@link Constant} and represents a reference to the name and signature of a
+ * field or method.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantNameAndType extends Constant {
 
     private int nameIndex; // Name of field/method
     private int signatureIndex; // and its signature.
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantNameAndType(final ConstantNameAndType c) {
         this(c.getNameIndex(), c.getSignatureIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantNameAndType(final DataInput file) throws IOException {
         this(file.readUnsignedShort(), file.readUnsignedShort());
     }
 
-
     /**
      * @param nameIndex Name of field/method
      * @param signatureIndex and its signature
@@ -69,33 +67,36 @@ public ConstantNameAndType(final int nameIndex, final int signatureIndex) {
         this.signatureIndex = signatureIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantNameAndType(this);
     }
 
-
     /**
      * Dump name and signature index to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeShort(nameIndex);
         file.writeShort(signatureIndex);
     }
 
+    /**
+     * @return name
+     */
+    public String getName(final ConstantPool cp) {
+        return cp.constantToString(getNameIndex(), Const.CONSTANT_Utf8);
+    }
 
     /**
      * @return Name index in constant pool of field/method name.
@@ -104,14 +105,13 @@ public int getNameIndex() {
         return nameIndex;
     }
 
-
-    /** @return name
+    /**
+     * @return signature
      */
-    public String getName( final ConstantPool cp ) {
-        return cp.constantToString(getNameIndex(), Const.CONSTANT_Utf8);
+    public String getSignature(final ConstantPool cp) {
+        return cp.constantToString(getSignatureIndex(), Const.CONSTANT_Utf8);
     }
 
-
     /**
      * @return Index in constant pool of field/method signature.
      */
@@ -119,36 +119,25 @@ public int getSignatureIndex() {
         return signatureIndex;
     }
 
-
-    /** @return signature
-     */
-    public String getSignature( final ConstantPool cp ) {
-        return cp.constantToString(getSignatureIndex(), Const.CONSTANT_Utf8);
-    }
-
-
     /**
      * @param nameIndex the name index of this constant
      */
-    public void setNameIndex( final int nameIndex ) {
+    public void setNameIndex(final int nameIndex) {
         this.nameIndex = nameIndex;
     }
 
-
     /**
      * @param signatureIndex the signature index in the constant pool of this type
      */
-    public void setSignatureIndex( final int signatureIndex ) {
+    public void setSignatureIndex(final int signatureIndex) {
         this.signatureIndex = signatureIndex;
     }
 
-
     /**
      * @return String representation
      */
     @Override
     public String toString() {
-        return super.toString() + "(nameIndex = " + nameIndex + ", signatureIndex = "
-                + signatureIndex + ")";
+        return super.toString() + "(nameIndex = " + nameIndex + ", signatureIndex = " + signatureIndex + ")";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java
index 361593e3d66..cb28f7dacb8 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java
@@ -22,14 +22,14 @@
 package com.sun.org.apache.bcel.internal.classfile;
 
 /**
- * This interface denotes those constants that have a "natural" value,
- * such as ConstantLong, ConstantString, etc..
+ * This interface denotes those constants that have a "natural" value, such as ConstantLong, ConstantString, etc..
  *
- * @see     Constant
+ * @see Constant
  */
 public interface ConstantObject {
 
-    /** @return object representing the constant, e.g., Long for ConstantLong
+    /**
+     * @return object representing the constant, e.g., Long for ConstantLong
      */
-    Object getConstantValue( ConstantPool cp );
+    Object getConstantValue(ConstantPool cp);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java
index 2770f95b2a2..2e8c7215016 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPackage.java
@@ -28,106 +28,98 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a package.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a package.
  *
- * <p>Note: Early access Java 9 support- currently subject to change</p>
+ * <p>
+ * Note: Early access Java 9 support- currently subject to change
+ * </p>
  *
- * @see     Constant
+ * @see Constant
  * @since 6.1
  */
 public final class ConstantPackage extends Constant implements ConstantObject {
 
     private int nameIndex;
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantPackage(final ConstantPackage c) {
         this(c.getNameIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantPackage(final DataInput file) throws IOException {
         this(file.readUnsignedShort());
     }
 
-
     /**
-     * @param nameIndex Name index in constant pool.  Should refer to a
-     * ConstantUtf8.
+     * @param nameIndex Name index in constant pool. Should refer to a ConstantUtf8.
      */
     public ConstantPackage(final int nameIndex) {
         super(Const.CONSTANT_Package);
         this.nameIndex = nameIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitly
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e.,
+     * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantPackage(this);
     }
 
-
     /**
      * Dump constant package to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeShort(nameIndex);
     }
 
-
     /**
-     * @return Name index in constant pool of package name.
+     * @return dereferenced string
      */
-    public int getNameIndex() {
-        return nameIndex;
+    public String getBytes(final ConstantPool cp) {
+        return (String) getConstantValue(cp);
     }
 
-
     /**
-     * @param nameIndex the name index in the constant pool of this Constant Package
+     * @return String object
      */
-    public void setNameIndex( final int nameIndex ) {
-        this.nameIndex = nameIndex;
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return cp.getConstantUtf8(nameIndex).getBytes();
     }
 
-
-    /** @return String object
+    /**
+     * @return Name index in constant pool of package name.
      */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        final Constant c = cp.getConstant(nameIndex, Const.CONSTANT_Utf8);
-        return ((ConstantUtf8) c).getBytes();
+    public int getNameIndex() {
+        return nameIndex;
     }
 
-
-    /** @return dereferenced string
+    /**
+     * @param nameIndex the name index in the constant pool of this Constant Package
      */
-    public String getBytes( final ConstantPool cp ) {
-        return (String) getConstantValue(cp);
+    public void setNameIndex(final int nameIndex) {
+        this.nameIndex = nameIndex;
     }
 
-
     /**
      * @return String representation.
      */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java
index b10c6521a38..5fb4ef1b080 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,23 +23,49 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
 
 import com.sun.org.apache.bcel.internal.Const;
-import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 
 /**
- * This class represents the constant pool, i.e., a table of constants, of
- * a parsed classfile. It may contain null references, due to the JVM
- * specification that skips an entry after an 8-byte constant (double,
- * long) entry.  Those interested in generating constant pools
- * programatically should see <a href="../generic/ConstantPoolGen.html">
- * ConstantPoolGen</a>.
-
- * @see     Constant
- * @see     com.sun.org.apache.bcel.internal.generic.ConstantPoolGen
- * @LastModified: June 2022
+ * This class represents the constant pool, i.e., a table of constants, of a parsed classfile. It may contain null references, due to the JVM specification that
+ * skips an entry after an 8-byte constant (double, long) entry. Those interested in generating constant pools programmatically should see
+ * <a href="../generic/ConstantPoolGen.html"> ConstantPoolGen</a>.
+ *
+ * @see Constant
+ * @see com.sun.org.apache.bcel.internal.generic.ConstantPoolGen
+ * @LastModified: Feb 2023
  */
-public class ConstantPool implements Cloneable, Node {
+public class ConstantPool implements Cloneable, Node, Iterable<Constant> {
+
+    private static String escape(final String str) {
+        final int len = str.length();
+        final StringBuilder buf = new StringBuilder(len + 5);
+        final char[] ch = str.toCharArray();
+        for (int i = 0; i < len; i++) {
+            switch (ch[i]) {
+            case '\n':
+                buf.append("\\n");
+                break;
+            case '\r':
+                buf.append("\\r");
+                break;
+            case '\t':
+                buf.append("\\t");
+                break;
+            case '\b':
+                buf.append("\\b");
+                break;
+            case '"':
+                buf.append("\\\"");
+                break;
+            default:
+                buf.append(ch[i]);
+            }
+        }
+        return buf.toString();
+    }
 
     private Constant[] constantPool;
 
@@ -54,182 +80,166 @@ public ConstantPool(final Constant[] constantPool) {
      * Reads constants from given input stream.
      *
      * @param input Input stream
-     * @throws IOException
-     * @throws ClassFormatException
+     * @throws IOException if problem in readUnsignedShort or readConstant
      */
-    public ConstantPool(final DataInput input) throws IOException, ClassFormatException {
+    public ConstantPool(final DataInput input) throws IOException {
         byte tag;
-        final int constant_pool_count = input.readUnsignedShort();
-        constantPool = new Constant[constant_pool_count];
-        /* constantPool[0] is unused by the compiler and may be used freely
-         * by the implementation.
+        final int constantPoolCount = input.readUnsignedShort();
+        constantPool = new Constant[constantPoolCount];
+        /*
+         * constantPool[0] is unused by the compiler and may be used freely by the implementation.
          */
-        for (int i = 1; i < constant_pool_count; i++) {
+        for (int i = 1; i < constantPoolCount; i++) {
             constantPool[i] = Constant.readConstant(input);
-            /* Quote from the JVM specification:
-             * "All eight byte constants take up two spots in the constant pool.
-             * If this is the n'th byte in the constant pool, then the next item
-             * will be numbered n+2"
+            /*
+             * Quote from the JVM specification: "All eight byte constants take up two spots in the constant pool. If this is the n'th byte in the constant
+             * pool, then the next item will be numbered n+2"
              *
              * Thus we have to increment the index counter.
              */
             tag = constantPool[i].getTag();
-            if ((tag == Const.CONSTANT_Double) || (tag == Const.CONSTANT_Long)) {
+            if (tag == Const.CONSTANT_Double || tag == Const.CONSTANT_Long) {
                 i++;
             }
         }
     }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields,
+     * attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantPool(this);
     }
 
     /**
      * Resolves constant to a string representation.
      *
-     * @param  c Constant to be printed
+     * @param c Constant to be printed
      * @return String representation
+     * @throws IllegalArgumentException if c is unknown constant type
      */
-    public String constantToString( Constant c ) throws ClassFormatException {
+    public String constantToString(Constant c) throws IllegalArgumentException {
         String str;
         int i;
         final byte tag = c.getTag();
         switch (tag) {
-            case Const.CONSTANT_Class:
-                i = ((ConstantClass) c).getNameIndex();
-                c = getConstant(i, Const.CONSTANT_Utf8);
-                str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
-                break;
-            case Const.CONSTANT_String:
-                i = ((ConstantString) c).getStringIndex();
-                c = getConstant(i, Const.CONSTANT_Utf8);
-                str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\"";
-                break;
-            case Const.CONSTANT_Utf8:
-                str = ((ConstantUtf8) c).getBytes();
-                break;
-            case Const.CONSTANT_Double:
-                str = String.valueOf(((ConstantDouble) c).getBytes());
-                break;
-            case Const.CONSTANT_Float:
-                str = String.valueOf(((ConstantFloat) c).getBytes());
-                break;
-            case Const.CONSTANT_Long:
-                str = String.valueOf(((ConstantLong) c).getBytes());
-                break;
-            case Const.CONSTANT_Integer:
-                str = String.valueOf(((ConstantInteger) c).getBytes());
-                break;
-            case Const.CONSTANT_NameAndType:
-                str = constantToString(((ConstantNameAndType) c).getNameIndex(),
-                        Const.CONSTANT_Utf8)
-                        + " " + constantToString(((ConstantNameAndType) c).getSignatureIndex(),
-                        Const.CONSTANT_Utf8);
-                break;
-            case Const.CONSTANT_InterfaceMethodref:
-            case Const.CONSTANT_Methodref:
-            case Const.CONSTANT_Fieldref:
-                str = constantToString(((ConstantCP) c).getClassIndex(), Const.CONSTANT_Class)
-                        + "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(),
-                        Const.CONSTANT_NameAndType);
-                break;
-            case Const.CONSTANT_MethodHandle:
-                // Note that the ReferenceIndex may point to a Fieldref, Methodref or
-                // InterfaceMethodref - so we need to peek ahead to get the actual type.
-                final ConstantMethodHandle cmh = (ConstantMethodHandle) c;
-                str = Const.getMethodHandleName(cmh.getReferenceKind())
-                        + " " + constantToString(cmh.getReferenceIndex(),
-                        getConstant(cmh.getReferenceIndex()).getTag());
-                break;
-            case Const.CONSTANT_MethodType:
-                final ConstantMethodType cmt = (ConstantMethodType) c;
-                str = constantToString(cmt.getDescriptorIndex(), Const.CONSTANT_Utf8);
-                break;
-            case Const.CONSTANT_InvokeDynamic:
-                final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) c;
-                str = cid.getBootstrapMethodAttrIndex()
-                        + ":" + constantToString(cid.getNameAndTypeIndex(),
-                        Const.CONSTANT_NameAndType);
-                break;
-            case Const.CONSTANT_Module:
-                i = ((ConstantModule) c).getNameIndex();
-                c = getConstant(i, Const.CONSTANT_Utf8);
-                str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
-                break;
-            case Const.CONSTANT_Package:
-                i = ((ConstantPackage) c).getNameIndex();
-                c = getConstant(i, Const.CONSTANT_Utf8);
-                str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
-                break;
-            default: // Never reached
-                throw new IllegalArgumentException("Unknown constant type " + tag);
+        case Const.CONSTANT_Class:
+            i = ((ConstantClass) c).getNameIndex();
+            c = getConstantUtf8(i);
+            str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
+            break;
+        case Const.CONSTANT_String:
+            i = ((ConstantString) c).getStringIndex();
+            c = getConstantUtf8(i);
+            str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\"";
+            break;
+        case Const.CONSTANT_Utf8:
+            str = ((ConstantUtf8) c).getBytes();
+            break;
+        case Const.CONSTANT_Double:
+            str = String.valueOf(((ConstantDouble) c).getBytes());
+            break;
+        case Const.CONSTANT_Float:
+            str = String.valueOf(((ConstantFloat) c).getBytes());
+            break;
+        case Const.CONSTANT_Long:
+            str = String.valueOf(((ConstantLong) c).getBytes());
+            break;
+        case Const.CONSTANT_Integer:
+            str = String.valueOf(((ConstantInteger) c).getBytes());
+            break;
+        case Const.CONSTANT_NameAndType:
+            str = constantToString(((ConstantNameAndType) c).getNameIndex(), Const.CONSTANT_Utf8) + " "
+                    + constantToString(((ConstantNameAndType) c).getSignatureIndex(), Const.CONSTANT_Utf8);
+            break;
+        case Const.CONSTANT_InterfaceMethodref:
+        case Const.CONSTANT_Methodref:
+        case Const.CONSTANT_Fieldref:
+            str = constantToString(((ConstantCP) c).getClassIndex(), Const.CONSTANT_Class) + "."
+                    + constantToString(((ConstantCP) c).getNameAndTypeIndex(), Const.CONSTANT_NameAndType);
+            break;
+        case Const.CONSTANT_MethodHandle:
+            // Note that the ReferenceIndex may point to a Fieldref, Methodref or
+            // InterfaceMethodref - so we need to peek ahead to get the actual type.
+            final ConstantMethodHandle cmh = (ConstantMethodHandle) c;
+            str = Const.getMethodHandleName(cmh.getReferenceKind()) + " "
+                    + constantToString(cmh.getReferenceIndex(), getConstant(cmh.getReferenceIndex()).getTag());
+            break;
+        case Const.CONSTANT_MethodType:
+            final ConstantMethodType cmt = (ConstantMethodType) c;
+            str = constantToString(cmt.getDescriptorIndex(), Const.CONSTANT_Utf8);
+            break;
+        case Const.CONSTANT_InvokeDynamic:
+            final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) c;
+            str = cid.getBootstrapMethodAttrIndex() + ":" + constantToString(cid.getNameAndTypeIndex(), Const.CONSTANT_NameAndType);
+            break;
+        case Const.CONSTANT_Dynamic:
+            final ConstantDynamic cd = (ConstantDynamic) c;
+            str = cd.getBootstrapMethodAttrIndex() + ":" + constantToString(cd.getNameAndTypeIndex(), Const.CONSTANT_NameAndType);
+            break;
+        case Const.CONSTANT_Module:
+            i = ((ConstantModule) c).getNameIndex();
+            c = getConstantUtf8(i);
+            str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
+            break;
+        case Const.CONSTANT_Package:
+            i = ((ConstantPackage) c).getNameIndex();
+            c = getConstantUtf8(i);
+            str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
+            break;
+        default: // Never reached
+            throw new IllegalArgumentException("Unknown constant type " + tag);
         }
         return str;
     }
 
-    private static String escape( final String str ) {
-        final int len = str.length();
-        final StringBuilder buf = new StringBuilder(len + 5);
-        final char[] ch = str.toCharArray();
-        for (int i = 0; i < len; i++) {
-            switch (ch[i]) {
-                case '\n':
-                    buf.append("\\n");
-                    break;
-                case '\r':
-                    buf.append("\\r");
-                    break;
-                case '\t':
-                    buf.append("\\t");
-                    break;
-                case '\b':
-                    buf.append("\\b");
-                    break;
-                case '"':
-                    buf.append("\\\"");
-                    break;
-                default:
-                    buf.append(ch[i]);
-            }
-        }
-        return buf.toString();
-    }
-
     /**
-     * Retrieves constant at `index' from constant pool and resolve it to
-     * a string representation.
+     * Retrieves constant at 'index' from constant pool and resolve it to a string representation.
      *
-     * @param  index of constant in constant pool
-     * @param  tag expected type
+     * @param index of constant in constant pool
+     * @param tag   expected type
      * @return String representation
      */
-    public String constantToString( final int index, final byte tag ) throws ClassFormatException {
-        final Constant c = getConstant(index, tag);
-        return constantToString(c);
+    public String constantToString(final int index, final byte tag) {
+        return constantToString(getConstant(index, tag));
+    }
+
+    /**
+     * @return deep copy of this constant pool
+     */
+    public ConstantPool copy() {
+        ConstantPool c = null;
+        try {
+            c = (ConstantPool) clone();
+            c.constantPool = new Constant[constantPool.length];
+            for (int i = 1; i < constantPool.length; i++) {
+                if (constantPool[i] != null) {
+                    c.constantPool[i] = constantPool[i].copy();
+                }
+            }
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return c;
     }
 
     /**
      * Dump constant pool to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if problem in writeShort or dump
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         /*
          * Constants over the size of the constant pool shall not be written out.
          * This is a redundant measure as the ConstantPoolGen should have already
          * reported an error back in the situation.
-        */
-        int size = constantPool.length < ConstantPoolGen.CONSTANT_POOL_SIZE ?
-                constantPool.length : ConstantPoolGen.CONSTANT_POOL_SIZE;
+         */
+        final int size = Math.min(constantPool.length, Const.MAX_CP_ENTRIES);
 
         file.writeShort(size);
         for (int i = 1; i < size; i++) {
@@ -242,94 +252,151 @@ public void dump( final DataOutputStream file ) throws IOException {
     /**
      * Gets constant from constant pool.
      *
-     * @param  index Index in constant pool
+     * @param index Index in constant pool
      * @return Constant value
-     * @see    Constant
+     * @see Constant
+     * @throws ClassFormatException if index is invalid
      */
-    public Constant getConstant( final int index ) {
-        if (index >= constantPool.length || index < 0) {
-            throw new ClassFormatException("Invalid constant pool reference: " + index
-                    + ". Constant pool size is: " + constantPool.length);
+    @SuppressWarnings("unchecked")
+    public <T extends Constant> T getConstant(final int index) throws ClassFormatException {
+        return (T) getConstant(index, Constant.class);
+    }
+
+    /**
+     * Gets constant from constant pool and check whether it has the expected type.
+     *
+     * @param index Index in constant pool
+     * @param tag   Tag of expected constant, i.e., its type
+     * @return Constant value
+     * @see Constant
+     * @throws ClassFormatException if constant type does not match tag
+     */
+    @SuppressWarnings("unchecked")
+    public <T extends Constant> T getConstant(final int index, final byte tag) throws ClassFormatException {
+        return (T) getConstant(index, tag, Constant.class);
+    }
+
+    /**
+     * Gets constant from constant pool and check whether it has the expected type.
+     *
+     * @param index Index in constant pool
+     * @param tag   Tag of expected constant, i.e., its type
+     * @return Constant value
+     * @see Constant
+     * @throws ClassFormatException if constant type does not match tag
+     * @since 6.6.0
+     */
+    public <T extends Constant> T getConstant(final int index, final byte tag, final Class<T> castTo) throws ClassFormatException {
+        final T c = getConstant(index);
+        if (c.getTag() != tag) {
+            throw new ClassFormatException("Expected class '" + Const.getConstantName(tag) + "' at index " + index + " and got " + c);
         }
-        return constantPool[index];
+        return c;
     }
 
     /**
-     * Gets constant from constant pool and check whether it has the
-     * expected type.
+     * Gets constant from constant pool.
      *
-     * @param  index Index in constant pool
-     * @param  tag Tag of expected constant, i.e., its type
+     * @param <T> A {@link Constant} subclass
+     * @param index Index in constant pool
+     * @param castTo The {@link Constant} subclass to cast to.
      * @return Constant value
-     * @see    Constant
-     * @throws  ClassFormatException
+     * @see Constant
+     * @throws ClassFormatException if index is invalid
+     * @since 6.6.0
      */
-    public Constant getConstant( final int index, final byte tag ) throws ClassFormatException {
-        Constant c;
-        c = getConstant(index);
-        if (c == null) {
-            throw new ClassFormatException("Constant pool at index " + index + " is null.");
+    public <T extends Constant> T getConstant(final int index, final Class<T> castTo) throws ClassFormatException {
+        if (index >= constantPool.length || index < 0) {
+            throw new ClassFormatException("Invalid constant pool reference using index: " + index + ". Constant pool size is: " + constantPool.length);
         }
-        if (c.getTag() != tag) {
-            throw new ClassFormatException("Expected class `" + Const.getConstantName(tag)
-                    + "' at index " + index + " and got " + c);
+        if (constantPool[index] != null && !castTo.isAssignableFrom(constantPool[index].getClass())) {
+            throw new ClassFormatException("Invalid constant pool reference at index: " + index +
+                    ". Expected " + castTo + " but was " + constantPool[index].getClass());
+        }
+        // Previous check ensures this won't throw a ClassCastException
+        final T c = castTo.cast(constantPool[index]);
+        if (c == null
+            // the 0th element is always null
+            && index != 0) {
+            final Constant prev = constantPool[index - 1];
+            if (prev == null || prev.getTag() != Const.CONSTANT_Double && prev.getTag() != Const.CONSTANT_Long) {
+                throw new ClassFormatException("Constant pool at index " + index + " is null.");
+            }
         }
         return c;
     }
 
+    /**
+     * Gets constant from constant pool and check whether it has the expected type.
+     *
+     * @param index Index in constant pool
+     * @return ConstantInteger value
+     * @see ConstantInteger
+     * @throws ClassFormatException if constant type does not match tag
+     */
+    public ConstantInteger getConstantInteger(final int index) {
+        return getConstant(index, Const.CONSTANT_Integer, ConstantInteger.class);
+    }
+
     /**
      * @return Array of constants.
-     * @see    Constant
+     * @see Constant
      */
     public Constant[] getConstantPool() {
         return constantPool;
     }
 
     /**
-     * Gets string from constant pool and bypass the indirection of
-     * `ConstantClass' and `ConstantString' objects. I.e. these classes have
-     * an index field that points to another entry of the constant pool of
-     * type `ConstantUtf8' which contains the real data.
+     * Gets string from constant pool and bypass the indirection of 'ConstantClass' and 'ConstantString' objects. I.e. these classes have an index field that
+     * points to another entry of the constant pool of type 'ConstantUtf8' which contains the real data.
      *
-     * @param  index Index in constant pool
-     * @param  tag Tag of expected constant, either ConstantClass or ConstantString
+     * @param index Index in constant pool
+     * @param tag   Tag of expected constant, either ConstantClass or ConstantString
      * @return Contents of string reference
-     * @see    ConstantClass
-     * @see    ConstantString
-     * @throws  ClassFormatException
+     * @see ConstantClass
+     * @see ConstantString
+     * @throws IllegalArgumentException if tag is invalid
      */
-    public String getConstantString( final int index, final byte tag ) throws ClassFormatException {
-        Constant c;
+    public String getConstantString(final int index, final byte tag) throws IllegalArgumentException {
         int i;
-        c = getConstant(index, tag);
-        /* This switch() is not that elegant, since the four classes have the
-         * same contents, they just differ in the name of the index
-         * field variable.
-         * But we want to stick to the JVM naming conventions closely though
-         * we could have solved these more elegantly by using the same
-         * variable name or by subclassing.
+        /*
+         * This switch() is not that elegant, since the four classes have the same contents, they just differ in the name of the index field variable. But we
+         * want to stick to the JVM naming conventions closely though we could have solved these more elegantly by using the same variable name or by
+         * subclassing.
          */
         switch (tag) {
-            case Const.CONSTANT_Class:
-                i = ((ConstantClass) c).getNameIndex();
-                break;
-            case Const.CONSTANT_String:
-                i = ((ConstantString) c).getStringIndex();
-                break;
-            case Const.CONSTANT_Module:
-                i = ((ConstantModule) c).getNameIndex();
-                break;
-            case Const.CONSTANT_Package:
-                i = ((ConstantPackage) c).getNameIndex();
-                break;
-            default:
-                throw new IllegalArgumentException("getConstantString called with illegal tag " + tag);
+        case Const.CONSTANT_Class:
+            i = getConstant(index, ConstantClass.class).getNameIndex();
+            break;
+        case Const.CONSTANT_String:
+            i = getConstant(index, ConstantString.class).getStringIndex();
+            break;
+        case Const.CONSTANT_Module:
+            i = getConstant(index, ConstantModule.class).getNameIndex();
+            break;
+        case Const.CONSTANT_Package:
+            i = getConstant(index, ConstantPackage.class).getNameIndex();
+            break;
+        case Const.CONSTANT_Utf8:
+            return getConstantUtf8(index).getBytes();
+        default:
+            throw new IllegalArgumentException("getConstantString called with illegal tag " + tag);
         }
         // Finally get the string from the constant pool
-        c = getConstant(i, Const.CONSTANT_Utf8);
-        return ((ConstantUtf8) c).getBytes();
+        return getConstantUtf8(i).getBytes();
     }
 
+    /**
+     * Gets constant from constant pool and check whether it has the expected type.
+     *
+     * @param index Index in constant pool
+     * @return ConstantUtf8 value
+     * @see ConstantUtf8
+     * @throws ClassFormatException if constant type does not match tag
+     */
+    public ConstantUtf8 getConstantUtf8(final int index) throws ClassFormatException {
+        return getConstant(index, Const.CONSTANT_Utf8, ConstantUtf8.class);
+    }
 
     /**
      * @return Length of constant pool.
@@ -338,23 +405,25 @@ public int getLength() {
         return constantPool == null ? 0 : constantPool.length;
     }
 
+    @Override
+    public Iterator<Constant> iterator() {
+        return Arrays.stream(constantPool).iterator();
+    }
 
     /**
      * @param constant Constant to set
      */
-    public void setConstant( final int index, final Constant constant ) {
+    public void setConstant(final int index, final Constant constant) {
         constantPool[index] = constant;
     }
 
-
     /**
      * @param constantPool
      */
-    public void setConstantPool( final Constant[] constantPool ) {
+    public void setConstantPool(final Constant[] constantPool) {
         this.constantPool = constantPool;
     }
 
-
     /**
      * @return String representation.
      */
@@ -366,24 +435,4 @@ public String toString() {
         }
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this constant pool
-     */
-    public ConstantPool copy() {
-        ConstantPool c = null;
-        try {
-            c = (ConstantPool) clone();
-            c.constantPool = new Constant[constantPool.length];
-            for (int i = 1; i < constantPool.length; i++) {
-                if (constantPool[i] != null) {
-                    c.constantPool[i] = constantPool[i].copy();
-                }
-            }
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java
index cdc2c0c5f9f..287e092b9aa 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java
@@ -28,35 +28,33 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from the abstract {@link Constant}
- * and represents a reference to a String object.
+ * This class is derived from the abstract {@link Constant} and represents a reference to a String object.
  *
- * @see     Constant
+ * @see Constant
  */
 public final class ConstantString extends Constant implements ConstantObject {
 
     private int stringIndex; // Identical to ConstantClass except for this name
 
-
     /**
      * Initialize from another object.
+     *
+     * @param c Source to copy.
      */
     public ConstantString(final ConstantString c) {
         this(c.getStringIndex());
     }
 
-
     /**
      * Initialize instance from file data.
      *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantString(final DataInput file) throws IOException {
         this(file.readUnsignedShort());
     }
 
-
     /**
      * @param stringIndex Index of Constant_Utf8 in constant pool
      */
@@ -65,32 +63,43 @@ public ConstantString(final int stringIndex) {
         this.stringIndex = stringIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantString(this);
     }
 
-
     /**
      * Dump constant field reference to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(super.getTag());
         file.writeShort(stringIndex);
     }
 
+    /**
+     * @return dereferenced string
+     */
+    public String getBytes(final ConstantPool cp) {
+        return (String) getConstantValue(cp);
+    }
+
+    /**
+     * @return String object
+     */
+    @Override
+    public Object getConstantValue(final ConstantPool cp) {
+        return cp.getConstantUtf8(stringIndex).getBytes();
+    }
 
     /**
      * @return Index in constant pool of the string (ConstantUtf8).
@@ -99,15 +108,13 @@ public int getStringIndex() {
         return stringIndex;
     }
 
-
     /**
      * @param stringIndex the index into the constant of the string value
      */
-    public void setStringIndex( final int stringIndex ) {
+    public void setStringIndex(final int stringIndex) {
         this.stringIndex = stringIndex;
     }
 
-
     /**
      * @return String representation.
      */
@@ -115,20 +122,4 @@ public void setStringIndex( final int stringIndex ) {
     public String toString() {
         return super.toString() + "(stringIndex = " + stringIndex + ")";
     }
-
-
-    /** @return String object
-     */
-    @Override
-    public Object getConstantValue( final ConstantPool cp ) {
-        final Constant c = cp.getConstant(stringIndex, Const.CONSTANT_Utf8);
-        return ((ConstantUtf8) c).getBytes();
-    }
-
-
-    /** @return dereferenced string
-     */
-    public String getBytes( final ConstantPool cp ) {
-        return (String) getConstantValue(cp);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java
index dd701a72bfb..ec875554c1a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,19 +20,45 @@
 
 package com.sun.org.apache.bcel.internal.classfile;
 
-import com.sun.org.apache.bcel.internal.Const;
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Objects;
+
+import com.sun.org.apache.bcel.internal.Const;
 
 /**
  * Extends the abstract {@link Constant} to represent a reference to a UTF-8 encoded string.
+ * <p>
+ * The following system properties govern caching this class performs.
+ * </p>
+ * <ul>
+ * <li>{@value #SYS_PROP_CACHE_MAX_ENTRIES} (since 6.4): The size of the cache, by default 0, meaning caching is
+ * disabled.</li>
+ * <li>{@value #SYS_PROP_CACHE_MAX_ENTRY_SIZE} (since 6.0): The maximum size of the values to cache, by default 200, 0
+ * disables caching. Values larger than this are <em>not</em> cached.</li>
+ * <li>{@value #SYS_PROP_STATISTICS} (since 6.0): Prints statistics on the console when the JVM exits.</li>
+ * </ul>
+ * <p>
+ * Here is a sample Maven invocation with caching disabled:
+ * </p>
+ *
+ * <pre>
+ * mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=0 -Dbcel.maxcached=0
+ * </pre>
+ * <p>
+ * Here is a sample Maven invocation with caching enabled:
+ * </p>
+ *
+ * <pre>
+ * mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=100000 -Dbcel.maxcached=5000000
+ * </pre>
  *
  * @see Constant
- * @LastModified: Jan 2020
+ * @LastModified: Feb 2023
  */
 public final class ConstantUtf8 extends Constant {
 
@@ -42,8 +68,7 @@ private static class Cache {
         private static final int MAX_ENTRIES = 20000;
         private static final int INITIAL_CAPACITY = (int) (MAX_ENTRIES / 0.75);
 
-        private static final HashMap<String, ConstantUtf8> CACHE = new LinkedHashMap<String, ConstantUtf8>(
-            INITIAL_CAPACITY, 0.75f, true) {
+        private static final HashMap<String, ConstantUtf8> CACHE = new LinkedHashMap<String, ConstantUtf8>(INITIAL_CAPACITY, 0.75f, true) {
 
             private static final long serialVersionUID = -8506975356158971766L;
 
@@ -62,6 +87,22 @@ static boolean isEnabled() {
 
     }
 
+    // TODO these should perhaps be AtomicInt?
+    private static volatile int considered;
+    private static volatile int created;
+    private static volatile int hits;
+    private static volatile int skipped;
+
+    private static final String SYS_PROP_CACHE_MAX_ENTRIES = "bcel.maxcached";
+    private static final String SYS_PROP_CACHE_MAX_ENTRY_SIZE = "bcel.maxcached.size";
+    private static final String SYS_PROP_STATISTICS = "bcel.statistics";
+
+    static {
+        if (Cache.BCEL_STATISTICS) {
+            Runtime.getRuntime().addShutdownHook(new Thread(ConstantUtf8::printStats));
+        }
+    }
+
     /**
      * Clears the cache.
      *
@@ -71,6 +112,11 @@ public static synchronized void clearCache() {
         Cache.CACHE.clear();
     }
 
+    // for access by test code
+    static synchronized void clearStats() {
+        hits = considered = skipped = created = 0;
+    }
+
     /**
      * Gets a new or cached instance of the given value.
      * <p>
@@ -83,12 +129,14 @@ public static synchronized void clearCache() {
      */
     public static ConstantUtf8 getCachedInstance(final String value) {
         if (value.length() > Cache.MAX_ENTRY_SIZE) {
+            skipped++;
             return new ConstantUtf8(value);
         }
-
+        considered++;
         synchronized (ConstantUtf8.class) { // might be better with a specific lock object
             ConstantUtf8 result = Cache.CACHE.get(value);
             if (result != null) {
+                hits++;
                 return result;
             }
             result = new ConstantUtf8(value);
@@ -126,6 +174,15 @@ public static ConstantUtf8 getInstance(final String value) {
         return Cache.isEnabled() ? getCachedInstance(value) : new ConstantUtf8(value);
     }
 
+    // for access by test code
+    static void printStats() {
+        final String prefix = "[Apache Commons BCEL]";
+        System.err.printf("%s Cache hit %,d/%,d, %d skipped.%n", prefix, hits, considered, skipped);
+        System.err.printf("%s Total of %,d ConstantUtf8 objects created.%n", prefix, created);
+        System.err.printf("%s Configuration: %s=%,d, %s=%,d.%n", prefix, SYS_PROP_CACHE_MAX_ENTRIES, Cache.MAX_ENTRIES, SYS_PROP_CACHE_MAX_ENTRY_SIZE,
+            Cache.MAX_ENTRY_SIZE);
+    }
+
     private final String value;
 
     /**
@@ -141,11 +198,12 @@ public ConstantUtf8(final ConstantUtf8 constantUtf8) {
      * Initializes instance from file data.
      *
      * @param dataInput Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ConstantUtf8(final DataInput dataInput) throws IOException {
         super(Const.CONSTANT_Utf8);
         value = dataInput.readUTF();
+        created++;
     }
 
     /**
@@ -153,14 +211,12 @@ public ConstantUtf8(final ConstantUtf8 constantUtf8) {
      */
     public ConstantUtf8(final String value) {
         super(Const.CONSTANT_Utf8);
-        if (value == null) {
-            throw new IllegalArgumentException("Value must not be null.");
-        }
-        this.value = value;
+        this.value = Objects.requireNonNull(value, "value");
+        created++;
     }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
      * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
@@ -174,7 +230,7 @@ public void accept(final Visitor v) {
      * Dumps String in Utf8 format to file stream.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
     public void dump(final DataOutputStream file) throws IOException {
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java
index 4b58ae8d40e..311e9a33fa3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java
@@ -26,81 +26,92 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and represents a constant
- * value, i.e., a default value for initializing a class field.
- * This class is instantiated by the <em>Attribute.readAttribute()</em> method.
+ * This class is derived from <em>Attribute</em> and represents a constant value, i.e., a default value for initializing
+ * a class field. This class is instantiated by the <em>Attribute.readAttribute()</em> method.
  *
- * @see     Attribute
+ * <pre>
+ * ConstantValue_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 constantvalue_index;
+ * }
+ * </pre>
+ * @see Attribute
  */
 public final class ConstantValue extends Attribute {
 
     private int constantValueIndex;
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
     public ConstantValue(final ConstantValue c) {
         this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c.getConstantPool());
     }
 
-
     /**
      * Construct object from input stream.
-     * @param name_index Name index in constant pool
+     *
+     * @param nameIndex Name index in constant pool
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    ConstantValue(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, input.readUnsignedShort(), constant_pool);
+    ConstantValue(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, input.readUnsignedShort(), constantPool);
     }
 
-
     /**
-     * @param name_index Name index in constant pool
+     * @param nameIndex Name index in constant pool
      * @param length Content length in bytes
      * @param constantValueIndex Index in constant pool
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public ConstantValue(final int name_index, final int length, final int constantValueIndex,
-            final ConstantPool constant_pool) {
-        super(Const.ATTR_CONSTANT_VALUE, name_index, length, constant_pool);
+    public ConstantValue(final int nameIndex, final int length, final int constantValueIndex, final ConstantPool constantPool) {
+        super(Const.ATTR_CONSTANT_VALUE, nameIndex, Args.require(length, 2, "ConstantValue attribute length"), constantPool);
         this.constantValueIndex = constantValueIndex;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitConstantValue(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final ConstantValue c = (ConstantValue) clone();
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump constant value attribute to file stream on binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(constantValueIndex);
     }
 
-
     /**
      * @return Index in constant pool of constant value.
      */
@@ -108,15 +119,13 @@ public int getConstantValueIndex() {
         return constantValueIndex;
     }
 
-
     /**
      * @param constantValueIndex the index info the constant pool of this constant value
      */
-    public void setConstantValueIndex( final int constantValueIndex ) {
+    public void setConstantValueIndex(final int constantValueIndex) {
         this.constantValueIndex = constantValueIndex;
     }
 
-
     /**
      * @return String representation of constant value.
      */
@@ -127,37 +136,26 @@ public String toString() {
         int i;
         // Print constant to string depending on its type
         switch (c.getTag()) {
-            case Const.CONSTANT_Long:
-                buf = String.valueOf(((ConstantLong) c).getBytes());
-                break;
-            case Const.CONSTANT_Float:
-                buf = String.valueOf(((ConstantFloat) c).getBytes());
-                break;
-            case Const.CONSTANT_Double:
-                buf = String.valueOf(((ConstantDouble) c).getBytes());
-                break;
-            case Const.CONSTANT_Integer:
-                buf = String.valueOf(((ConstantInteger) c).getBytes());
-                break;
-            case Const.CONSTANT_String:
-                i = ((ConstantString) c).getStringIndex();
-                c = super.getConstantPool().getConstant(i, Const.CONSTANT_Utf8);
-                buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\"";
-                break;
-            default:
-                throw new IllegalStateException("Type of ConstValue invalid: " + c);
+        case Const.CONSTANT_Long:
+            buf = String.valueOf(((ConstantLong) c).getBytes());
+            break;
+        case Const.CONSTANT_Float:
+            buf = String.valueOf(((ConstantFloat) c).getBytes());
+            break;
+        case Const.CONSTANT_Double:
+            buf = String.valueOf(((ConstantDouble) c).getBytes());
+            break;
+        case Const.CONSTANT_Integer:
+            buf = String.valueOf(((ConstantInteger) c).getBytes());
+            break;
+        case Const.CONSTANT_String:
+            i = ((ConstantString) c).getStringIndex();
+            c = super.getConstantPool().getConstantUtf8(i);
+            buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\"";
+            break;
+        default:
+            throw new IllegalStateException("Type of ConstValue invalid: " + c);
         }
         return buf;
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final ConstantValue c = (ConstantValue) clone();
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java
index 5b530f59b1c..90841d96081 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java
@@ -25,52 +25,50 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and denotes that this is a
- * deprecated method.
- * It is instantiated from the <em>Attribute.readAttribute()</em> method.
+ * This class is derived from <em>Attribute</em> and denotes that this is a deprecated method. It is instantiated from
+ * the <em>Attribute.readAttribute()</em> method.
  *
- * @see     Attribute
+ * @see Attribute
  */
 public final class Deprecated extends Attribute {
 
     private byte[] bytes;
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
     public Deprecated(final Deprecated c) {
         this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
     }
 
-
     /**
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param bytes Attribute contents
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public Deprecated(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) {
-        super(Const.ATTR_DEPRECATED, name_index, length, constant_pool);
+    public Deprecated(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) {
+        super(Const.ATTR_DEPRECATED, nameIndex, Args.require0(length, "Deprecated attribute length"), constantPool);
         this.bytes = bytes;
     }
 
-
     /**
      * Construct object from input stream.
      *
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    Deprecated(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, (byte[]) null, constant_pool);
+    Deprecated(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (byte[]) null, constantPool);
         if (length > 0) {
             bytes = new byte[length];
             input.readFully(bytes);
@@ -78,35 +76,44 @@ public Deprecated(final int name_index, final int length, final byte[] bytes, fi
         }
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitDeprecated(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final Deprecated c = (Deprecated) clone();
+        if (bytes != null) {
+            c.bytes = bytes.clone();
+        }
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump source file attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         if (super.getLength() > 0) {
             file.write(bytes, 0, super.getLength());
         }
     }
 
-
     /**
      * @return data bytes.
      */
@@ -114,35 +121,18 @@ public byte[] getBytes() {
         return bytes;
     }
 
-
     /**
      * @param bytes the raw bytes that represents this byte array
      */
-    public void setBytes( final byte[] bytes ) {
+    public void setBytes(final byte[] bytes) {
         this.bytes = bytes;
     }
 
-
     /**
      * @return attribute name
      */
     @Override
     public String toString() {
-        return Const.getAttributeName(Const.ATTR_DEPRECATED);
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final Deprecated c = (Deprecated) clone();
-        if (bytes != null) {
-            c.bytes = new byte[bytes.length];
-            System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
+        return Const.getAttributeName(Const.ATTR_DEPRECATED) + ": true";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java
index e57eec78311..3c475891acd 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java
@@ -19,7 +19,9 @@
  */
 package com.sun.org.apache.bcel.internal.classfile;
 
+import java.util.Objects;
 import java.util.Stack;
+import java.util.stream.Stream;
 
 /**
  * Traverses a JavaClass with another Visitor object 'piggy-backed' that is
@@ -27,8 +29,7 @@
  * traversal strategy, other classes can make use of it.
  *
  */
-public class DescendingVisitor implements Visitor
-{
+public class DescendingVisitor implements Visitor {
     private final JavaClass clazz;
 
     private final Visitor visitor;
@@ -36,74 +37,59 @@ public class DescendingVisitor implements Visitor
     private final Stack<Object> stack = new Stack<>();
 
     /**
-     * @return container of current entitity, i.e., predecessor during traversal
+     * @param clazz Class to traverse
+     * @param visitor visitor object to apply to all components
      */
-    public Object predecessor()
-    {
-        return predecessor(0);
+    public DescendingVisitor(final JavaClass clazz, final Visitor visitor) {
+        this.clazz = clazz;
+        this.visitor = visitor;
     }
 
-    /**
-     * @param level
-     *            nesting level, i.e., 0 returns the direct predecessor
-     * @return container of current entitity, i.e., predecessor during traversal
-     */
-    public Object predecessor(final int level)
-    {
-        final int size = stack.size();
-        if ((size < 2) || (level < 0))
-        {
-            return null;
-        }
-        return stack.elementAt(size - (level + 2)); // size - 1 == current
+    private <E extends Node> void accept(final E[] node) {
+        Stream.of(node).forEach(e -> e.accept(this));
     }
 
     /**
      * @return current object
      */
-    public Object current()
-    {
+    public Object current() {
         return stack.peek();
     }
 
     /**
-     * @param clazz
-     *            Class to traverse
-     * @param visitor
-     *            visitor object to apply to all components
+     * @return container of current entitity, i.e., predecessor during traversal
      */
-    public DescendingVisitor(final JavaClass clazz, final Visitor visitor)
-    {
-        this.clazz = clazz;
-        this.visitor = visitor;
+    public Object predecessor() {
+        return predecessor(0);
+    }
+
+    /**
+     * @param level nesting level, i.e., 0 returns the direct predecessor
+     * @return container of current entitity, i.e., predecessor during traversal
+     */
+    public Object predecessor(final int level) {
+        final int size = stack.size();
+        if (size < 2 || level < 0) {
+            return null;
+        }
+        return stack.elementAt(size - (level + 2)); // size - 1 == current
     }
 
     /**
      * Start traversal.
      */
-    public void visit()
-    {
+    public void visit() {
         clazz.accept(this);
     }
 
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitJavaClass(final JavaClass _clazz)
-    {
-        stack.push(_clazz);
-        _clazz.accept(visitor);
-        final Field[] fields = _clazz.getFields();
-        for (final Field field : fields) {
-            field.accept(this);
-        }
-        final Method[] methods = _clazz.getMethods();
-        for (final Method method : methods) {
-            method.accept(this);
-        }
-        final Attribute[] attributes = _clazz.getAttributes();
-        for (final Attribute attribute : attributes) {
-            attribute.accept(this);
-        }
-        _clazz.getConstantPool().accept(this);
+    public void visitAnnotation(final Annotations annotation) {
+        stack.push(annotation);
+        annotation.accept(visitor);
+        accept(annotation.getAnnotationEntries());
         stack.pop();
     }
 
@@ -111,14 +97,9 @@ public void visitJavaClass(final JavaClass _clazz)
      * @since 6.0
      */
     @Override
-    public void visitAnnotation(final Annotations annotation)
-    {
-        stack.push(annotation);
-        annotation.accept(visitor);
-        final AnnotationEntry[] entries = annotation.getAnnotationEntries();
-        for (final AnnotationEntry entrie : entries) {
-            entrie.accept(this);
-        }
+    public void visitAnnotationDefault(final AnnotationDefault obj) {
+        stack.push(obj);
+        obj.accept(visitor);
         stack.pop();
     }
 
@@ -126,327 +107,270 @@ public void visitAnnotation(final Annotations annotation)
      * @since 6.0
      */
     @Override
-    public void visitAnnotationEntry(final AnnotationEntry annotationEntry)
-    {
+    public void visitAnnotationEntry(final AnnotationEntry annotationEntry) {
         stack.push(annotationEntry);
         annotationEntry.accept(visitor);
         stack.pop();
     }
 
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitField(final Field field)
-    {
-        stack.push(field);
-        field.accept(visitor);
-        final Attribute[] attributes = field.getAttributes();
-        for (final Attribute attribute : attributes) {
-            attribute.accept(this);
-        }
+    public void visitBootstrapMethods(final BootstrapMethods bm) {
+        stack.push(bm);
+        bm.accept(visitor);
+        // BootstrapMethod[] bms = bm.getBootstrapMethods();
+        // for (int i = 0; i < bms.length; i++)
+        // {
+        // bms[i].accept(this);
+        // }
         stack.pop();
     }
 
     @Override
-    public void visitConstantValue(final ConstantValue cv)
-    {
-        stack.push(cv);
-        cv.accept(visitor);
+    public void visitCode(final Code code) {
+        stack.push(code);
+        code.accept(visitor);
+        accept(code.getExceptionTable());
+        accept(code.getAttributes());
         stack.pop();
     }
 
     @Override
-    public void visitMethod(final Method method)
-    {
-        stack.push(method);
-        method.accept(visitor);
-        final Attribute[] attributes = method.getAttributes();
-        for (final Attribute attribute : attributes) {
-            attribute.accept(this);
-        }
+    public void visitCodeException(final CodeException ce) {
+        stack.push(ce);
+        ce.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitExceptionTable(final ExceptionTable table)
-    {
-        stack.push(table);
-        table.accept(visitor);
+    public void visitConstantClass(final ConstantClass constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitCode(final Code code)
-    {
-        stack.push(code);
-        code.accept(visitor);
-        final CodeException[] table = code.getExceptionTable();
-        for (final CodeException element : table) {
-            element.accept(this);
-        }
-        final Attribute[] attributes = code.getAttributes();
-        for (final Attribute attribute : attributes) {
-            attribute.accept(this);
-        }
+    public void visitConstantDouble(final ConstantDouble constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
+    /** @since 6.3 */
     @Override
-    public void visitCodeException(final CodeException ce)
-    {
-        stack.push(ce);
-        ce.accept(visitor);
+    public void visitConstantDynamic(final ConstantDynamic obj) {
+        stack.push(obj);
+        obj.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitLineNumberTable(final LineNumberTable table)
-    {
-        stack.push(table);
-        table.accept(visitor);
-        final LineNumber[] numbers = table.getLineNumberTable();
-        for (final LineNumber number : numbers) {
-            number.accept(this);
-        }
+    public void visitConstantFieldref(final ConstantFieldref constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitLineNumber(final LineNumber number)
-    {
-        stack.push(number);
-        number.accept(visitor);
+    public void visitConstantFloat(final ConstantFloat constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitLocalVariableTable(final LocalVariableTable table)
-    {
-        stack.push(table);
-        table.accept(visitor);
-        final LocalVariable[] vars = table.getLocalVariableTable();
-        for (final LocalVariable var : vars) {
-            var.accept(this);
-        }
+    public void visitConstantInteger(final ConstantInteger constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitStackMap(final StackMap table)
-    {
-        stack.push(table);
-        table.accept(visitor);
-        final StackMapEntry[] vars = table.getStackMap();
-        for (final StackMapEntry var : vars) {
-            var.accept(this);
-        }
+    public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitStackMapEntry(final StackMapEntry var)
-    {
-        stack.push(var);
-        var.accept(visitor);
+    public void visitConstantInvokeDynamic(final ConstantInvokeDynamic constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitLocalVariable(final LocalVariable var)
-    {
-        stack.push(var);
-        var.accept(visitor);
+    public void visitConstantLong(final ConstantLong constant) {
+        stack.push(constant);
+        constant.accept(visitor);
         stack.pop();
     }
 
+    /** @since 6.0 */
     @Override
-    public void visitConstantPool(final ConstantPool cp)
-    {
-        stack.push(cp);
-        cp.accept(visitor);
-        final Constant[] constants = cp.getConstantPool();
-        for (int i = 1; i < constants.length; i++)
-        {
-            if (constants[i] != null)
-            {
-                constants[i].accept(this);
-            }
-        }
+    public void visitConstantMethodHandle(final ConstantMethodHandle obj) {
+        stack.push(obj);
+        obj.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitConstantClass(final ConstantClass constant)
-    {
+    public void visitConstantMethodref(final ConstantMethodref constant) {
         stack.push(constant);
         constant.accept(visitor);
         stack.pop();
     }
 
+    /** @since 6.0 */
     @Override
-    public void visitConstantDouble(final ConstantDouble constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitConstantMethodType(final ConstantMethodType obj) {
+        stack.push(obj);
+        obj.accept(visitor);
         stack.pop();
     }
 
+    /** @since 6.1 */
     @Override
-    public void visitConstantFieldref(final ConstantFieldref constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitConstantModule(final ConstantModule obj) {
+        stack.push(obj);
+        obj.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitConstantFloat(final ConstantFloat constant)
-    {
+    public void visitConstantNameAndType(final ConstantNameAndType constant) {
         stack.push(constant);
         constant.accept(visitor);
         stack.pop();
     }
 
+    /** @since 6.1 */
     @Override
-    public void visitConstantInteger(final ConstantInteger constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitConstantPackage(final ConstantPackage obj) {
+        stack.push(obj);
+        obj.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitConstantInterfaceMethodref(
-            final ConstantInterfaceMethodref constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitConstantPool(final ConstantPool cp) {
+        stack.push(cp);
+        cp.accept(visitor);
+        Stream.of(cp.getConstantPool()).filter(Objects::nonNull).forEach(e -> e.accept(this));
         stack.pop();
     }
 
-    /**
-     * @since 6.0
-     */
     @Override
-    public void visitConstantInvokeDynamic(
-            final ConstantInvokeDynamic constant)
-    {
+    public void visitConstantString(final ConstantString constant) {
         stack.push(constant);
         constant.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitConstantLong(final ConstantLong constant)
-    {
+    public void visitConstantUtf8(final ConstantUtf8 constant) {
         stack.push(constant);
         constant.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitConstantMethodref(final ConstantMethodref constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitConstantValue(final ConstantValue cv) {
+        stack.push(cv);
+        cv.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitConstantNameAndType(final ConstantNameAndType constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitDeprecated(final Deprecated attribute) {
+        stack.push(attribute);
+        attribute.accept(visitor);
         stack.pop();
     }
 
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitConstantString(final ConstantString constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitEnclosingMethod(final EnclosingMethod obj) {
+        stack.push(obj);
+        obj.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitConstantUtf8(final ConstantUtf8 constant)
-    {
-        stack.push(constant);
-        constant.accept(visitor);
+    public void visitExceptionTable(final ExceptionTable table) {
+        stack.push(table);
+        table.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitInnerClasses(final InnerClasses ic)
-    {
-        stack.push(ic);
-        ic.accept(visitor);
-        final InnerClass[] ics = ic.getInnerClasses();
-        for (final InnerClass ic2 : ics) {
-            ic2.accept(this);
-        }
+    public void visitField(final Field field) {
+        stack.push(field);
+        field.accept(visitor);
+        accept(field.getAttributes());
         stack.pop();
     }
 
     @Override
-    public void visitInnerClass(final InnerClass inner)
-    {
+    public void visitInnerClass(final InnerClass inner) {
         stack.push(inner);
         inner.accept(visitor);
         stack.pop();
     }
 
-    /**
-     * @since 6.0
-     */
     @Override
-    public void visitBootstrapMethods(final BootstrapMethods bm)
-    {
-        stack.push(bm);
-        bm.accept(visitor);
-        // BootstrapMethod[] bms = bm.getBootstrapMethods();
-        // for (int i = 0; i < bms.length; i++)
-        // {
-        //     bms[i].accept(this);
-        // }
+    public void visitInnerClasses(final InnerClasses ic) {
+        stack.push(ic);
+        ic.accept(visitor);
+        accept(ic.getInnerClasses());
         stack.pop();
     }
 
     @Override
-    public void visitDeprecated(final Deprecated attribute)
-    {
-        stack.push(attribute);
-        attribute.accept(visitor);
+    public void visitJavaClass(final JavaClass clazz) {
+        stack.push(clazz);
+        clazz.accept(visitor);
+        accept(clazz.getFields());
+        accept(clazz.getMethods());
+        accept(clazz.getAttributes());
+        clazz.getConstantPool().accept(this);
         stack.pop();
     }
 
     @Override
-    public void visitSignature(final Signature attribute)
-    {
-        stack.push(attribute);
-        attribute.accept(visitor);
+    public void visitLineNumber(final LineNumber number) {
+        stack.push(number);
+        number.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitSourceFile(final SourceFile attribute)
-    {
-        stack.push(attribute);
-        attribute.accept(visitor);
+    public void visitLineNumberTable(final LineNumberTable table) {
+        stack.push(table);
+        table.accept(visitor);
+        accept(table.getLineNumberTable());
         stack.pop();
     }
 
     @Override
-    public void visitSynthetic(final Synthetic attribute)
-    {
-        stack.push(attribute);
-        attribute.accept(visitor);
+    public void visitLocalVariable(final LocalVariable var) {
+        stack.push(var);
+        var.accept(visitor);
         stack.pop();
     }
 
     @Override
-    public void visitUnknown(final Unknown attribute)
-    {
-        stack.push(attribute);
-        attribute.accept(visitor);
+    public void visitLocalVariableTable(final LocalVariableTable table) {
+        stack.push(table);
+        table.accept(visitor);
+        accept(table.getLocalVariableTable());
         stack.pop();
     }
 
@@ -454,30 +378,25 @@ public void visitUnknown(final Unknown attribute)
      * @since 6.0
      */
     @Override
-    public void visitAnnotationDefault(final AnnotationDefault obj)
-    {
+    public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /**
-     * @since 6.0
-     */
     @Override
-    public void visitEnclosingMethod(final EnclosingMethod obj)
-    {
-        stack.push(obj);
-        obj.accept(visitor);
+    public void visitMethod(final Method method) {
+        stack.push(method);
+        method.accept(visitor);
+        accept(method.getAttributes());
         stack.pop();
     }
 
     /**
-     * @since 6.0
+     * @since 6.4.0
      */
     @Override
-    public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj)
-    {
+    public void visitMethodParameter(final MethodParameter obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
@@ -487,82 +406,76 @@ public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj)
      * @since 6.0
      */
     @Override
-    public void visitParameterAnnotation(final ParameterAnnotations obj)
-    {
+    public void visitMethodParameters(final MethodParameters obj) {
         stack.push(obj);
         obj.accept(visitor);
+        Stream.of(obj.getParameters()).forEach(e -> e.accept(this));
         stack.pop();
     }
 
-    /**
-     * @since 6.0
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitMethodParameters(final MethodParameters obj)
-    {
+    public void visitModule(final Module obj) {
         stack.push(obj);
         obj.accept(visitor);
-        final MethodParameter[] table = obj.getParameters();
-        for (final MethodParameter element : table) {
-            element.accept(this);
-        }
+        accept(obj.getRequiresTable());
+        accept(obj.getExportsTable());
+        accept(obj.getOpensTable());
+        accept(obj.getProvidesTable());
         stack.pop();
     }
 
-    /**
-     * @since 6.4.0
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitMethodParameter(final MethodParameter obj)
-    {
+    public void visitModuleExports(final ModuleExports obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.0 */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantMethodType(final ConstantMethodType obj) {
+    public void visitModuleMainClass(final ModuleMainClass obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.0 */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantMethodHandle(final ConstantMethodHandle obj) {
+    public void visitModuleOpens(final ModuleOpens obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.0 */
+    /** @since 6.4.0 */
     @Override
-    public void visitParameterAnnotationEntry(final ParameterAnnotationEntry obj) {
+    public void visitModulePackages(final ModulePackages obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.1 */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantPackage(final ConstantPackage obj) {
+    public void visitModuleProvides(final ModuleProvides obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.1 */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantModule(final ConstantModule obj) {
+    public void visitModuleRequires(final ModuleRequires obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.3 */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantDynamic(final ConstantDynamic obj) {
+    public void visitNestHost(final NestHost obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
@@ -570,89 +483,70 @@ public void visitConstantDynamic(final ConstantDynamic obj) {
 
     /** @since 6.4.0 */
     @Override
-    public void visitModule(final Module obj) {
+    public void visitNestMembers(final NestMembers obj) {
         stack.push(obj);
         obj.accept(visitor);
-        final ModuleRequires[] rtable = obj.getRequiresTable();
-        for (final ModuleRequires element : rtable) {
-            element.accept(this);
-        }
-        final ModuleExports[] etable = obj.getExportsTable();
-        for (final ModuleExports element : etable) {
-            element.accept(this);
-        }
-        final ModuleOpens[] otable = obj.getOpensTable();
-        for (final ModuleOpens element : otable) {
-            element.accept(this);
-        }
-        final ModuleProvides[] ptable = obj.getProvidesTable();
-        for (final ModuleProvides element : ptable) {
-            element.accept(this);
-        }
         stack.pop();
     }
 
-    /** @since 6.4.0 */
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitModuleRequires(final ModuleRequires obj) {
+    public void visitParameterAnnotation(final ParameterAnnotations obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.4.0 */
+    /** @since 6.0 */
     @Override
-    public void visitModuleExports(final ModuleExports obj) {
+    public void visitParameterAnnotationEntry(final ParameterAnnotationEntry obj) {
         stack.push(obj);
         obj.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModuleOpens(final ModuleOpens obj) {
-        stack.push(obj);
-        obj.accept(visitor);
+    public void visitSignature(final Signature attribute) {
+        stack.push(attribute);
+        attribute.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModuleProvides(final ModuleProvides obj) {
-        stack.push(obj);
-        obj.accept(visitor);
+    public void visitSourceFile(final SourceFile attribute) {
+        stack.push(attribute);
+        attribute.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModulePackages(final ModulePackages obj) {
-        stack.push(obj);
-        obj.accept(visitor);
+    public void visitStackMap(final StackMap table) {
+        stack.push(table);
+        table.accept(visitor);
+        accept(table.getStackMap());
         stack.pop();
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModuleMainClass(final ModuleMainClass obj) {
-        stack.push(obj);
-        obj.accept(visitor);
+    public void visitStackMapEntry(final StackMapEntry var) {
+        stack.push(var);
+        var.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitNestHost(final NestHost obj) {
-        stack.push(obj);
-        obj.accept(visitor);
+    public void visitSynthetic(final Synthetic attribute) {
+        stack.push(attribute);
+        attribute.accept(visitor);
         stack.pop();
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitNestMembers(final NestMembers obj) {
-        stack.push(obj);
-        obj.accept(visitor);
+    public void visitUnknown(final Unknown attribute) {
+        stack.push(attribute);
+        attribute.accept(visitor);
         stack.pop();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java
index d5967ffd531..5c3d9b3172b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValue.java
@@ -24,103 +24,155 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import com.sun.org.apache.bcel.internal.Const;
+
 /**
+ * The element_value structure is documented at https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.16.1
+ *
+ * <pre>
+ * element_value {
+ *    u1 tag;
+ *    union {
+ *        u2 const_value_index;
+ *
+ *        {   u2 type_name_index;
+ *            u2 const_name_index;
+ *        } enum_const_value;
+ *
+ *        u2 class_info_index;
+ *
+ *        annotation annotation_value;
+ *
+ *        {   u2            num_values;
+ *            element_value values[num_values];
+ *        } array_value;
+ *    } value;
+ *}
+ *</pre>
  * @since 6.0
  * @LastModified: May 2021
  */
-public abstract class ElementValue
-{
-    private final int type;
+public abstract class ElementValue {
+
+    public static final byte STRING = 's';
+    public static final byte ENUM_CONSTANT = 'e';
+    public static final byte CLASS = 'c';
+    public static final byte ANNOTATION = '@';
+    public static final byte ARRAY = '[';
+    public static final byte PRIMITIVE_INT = 'I';
+    public static final byte PRIMITIVE_BYTE = 'B';
+    public static final byte PRIMITIVE_CHAR = 'C';
+    public static final byte PRIMITIVE_DOUBLE = 'D';
+    public static final byte PRIMITIVE_FLOAT = 'F';
+    public static final byte PRIMITIVE_LONG = 'J';
+    public static final byte PRIMITIVE_SHORT = 'S';
+    public static final byte PRIMITIVE_BOOLEAN = 'Z';
 
-    private final ConstantPool cpool;
+    /**
+     * Reads an {@code element_value} as an {@code ElementValue}.
+     *
+     * @param input Raw data input.
+     * @param cpool Constant pool.
+     * @return a new ElementValue.
+     * @throws IOException if an I/O error occurs.
+     */
+    public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool) throws IOException {
+        return readElementValue(input, cpool, 0);
+    }
 
-    @Override
-    public String toString()
-    {
-        return stringifyValue();
+    /**
+     * Reads an {@code element_value} as an {@code ElementValue}.
+     *
+     * @param input Raw data input.
+     * @param cpool Constant pool.
+     * @param arrayNesting level of current array nesting.
+     * @return a new ElementValue.
+     * @throws IOException if an I/O error occurs.
+     * @since 6.7.0
+     */
+    public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool, int arrayNesting)
+            throws IOException {
+        final byte tag = input.readByte();
+        switch (tag) {
+        case PRIMITIVE_BYTE:
+        case PRIMITIVE_CHAR:
+        case PRIMITIVE_DOUBLE:
+        case PRIMITIVE_FLOAT:
+        case PRIMITIVE_INT:
+        case PRIMITIVE_LONG:
+        case PRIMITIVE_SHORT:
+        case PRIMITIVE_BOOLEAN:
+        case STRING:
+            return new SimpleElementValue(tag, input.readUnsignedShort(), cpool);
+
+        case ENUM_CONSTANT:
+            return new EnumElementValue(ENUM_CONSTANT, input.readUnsignedShort(), input.readUnsignedShort(), cpool);
+
+        case CLASS:
+            return new ClassElementValue(CLASS, input.readUnsignedShort(), cpool);
+
+        case ANNOTATION:
+            // TODO isRuntimeVisible
+            return new AnnotationElementValue(ANNOTATION, AnnotationEntry.read(input, cpool, false), cpool);
+
+        case ARRAY:
+            arrayNesting++;
+            if (arrayNesting > Const.MAX_ARRAY_DIMENSIONS) {
+                // JVM spec 4.4.1
+                throw new ClassFormatException(String.format("Arrays are only valid if they represent %,d or fewer dimensions.", Const.MAX_ARRAY_DIMENSIONS));
+            }
+            final int numArrayVals = input.readUnsignedShort();
+            final ElementValue[] evalues = new ElementValue[numArrayVals];
+            for (int j = 0; j < numArrayVals; j++) {
+                evalues[j] = ElementValue.readElementValue(input, cpool, arrayNesting);
+            }
+            return new ArrayElementValue(ARRAY, evalues, cpool);
+
+        default:
+            throw new ClassFormatException("Unexpected element value tag in annotation: " + tag);
+        }
     }
 
-    protected ElementValue(final int type, final ConstantPool cpool)
-    {
+    /**
+     * @deprecated (since 6.0) will be made private and final; do not access directly, use getter
+     */
+    @java.lang.Deprecated
+    protected int type; // TODO should be final
+    /**
+     * @deprecated (since 6.0) will be made private and final; do not access directly, use getter
+     */
+    @java.lang.Deprecated
+    protected ConstantPool cpool; // TODO should be final
+
+    protected ElementValue(final int type, final ConstantPool cpool) {
         this.type = type;
         this.cpool = cpool;
     }
 
-    public int getElementValueType()
-    {
-        return type;
-    }
-
-    public abstract String stringifyValue();
-
     public abstract void dump(DataOutputStream dos) throws IOException;
 
-    public static final byte STRING            = 's';
-    public static final byte ENUM_CONSTANT     = 'e';
-    public static final byte CLASS             = 'c';
-    public static final byte ANNOTATION        = '@';
-    public static final byte ARRAY             = '[';
-    public static final byte PRIMITIVE_INT     = 'I';
-    public static final byte PRIMITIVE_BYTE    = 'B';
-    public static final byte PRIMITIVE_CHAR    = 'C';
-    public static final byte PRIMITIVE_DOUBLE  = 'D';
-    public static final byte PRIMITIVE_FLOAT   = 'F';
-    public static final byte PRIMITIVE_LONG    = 'J';
-    public static final byte PRIMITIVE_SHORT   = 'S';
-    public static final byte PRIMITIVE_BOOLEAN = 'Z';
-
-    public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool) throws IOException
-    {
-        final byte type = input.readByte();
-        switch (type)
-        {
-            case PRIMITIVE_BYTE:
-            case PRIMITIVE_CHAR:
-            case PRIMITIVE_DOUBLE:
-            case PRIMITIVE_FLOAT:
-            case PRIMITIVE_INT:
-            case PRIMITIVE_LONG:
-            case PRIMITIVE_SHORT:
-            case PRIMITIVE_BOOLEAN:
-            case STRING:
-                return new SimpleElementValue(type, input.readUnsignedShort(), cpool);
-
-            case ENUM_CONSTANT:
-                return new EnumElementValue(ENUM_CONSTANT, input.readUnsignedShort(), input.readUnsignedShort(), cpool);
-
-            case CLASS:
-                return new ClassElementValue(CLASS, input.readUnsignedShort(), cpool);
-
-            case ANNOTATION:
-                // TODO isRuntimeVisible
-                return new AnnotationElementValue(ANNOTATION, AnnotationEntry.read(input, cpool, false), cpool);
-
-            case ARRAY:
-                final int numArrayVals = input.readUnsignedShort();
-                final ElementValue[] evalues = new ElementValue[numArrayVals];
-                for (int j = 0; j < numArrayVals; j++)
-                {
-                    evalues[j] = ElementValue.readElementValue(input, cpool);
-                }
-                return new ArrayElementValue(ARRAY, evalues, cpool);
-
-            default:
-                throw new IllegalArgumentException("Unexpected element value kind in annotation: " + type);
-        }
-    }
-
     /** @since 6.0 */
     final ConstantPool getConstantPool() {
         return cpool;
     }
 
+    public int getElementValueType() {
+        return type;
+    }
+
     /** @since 6.0 */
     final int getType() {
         return type;
     }
 
-    public String toShortString()
-    {
+    public abstract String stringifyValue();
+
+    public String toShortString() {
+        return stringifyValue();
+    }
+
+    @Override
+    public String toString() {
         return stringifyValue();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java
index a1fa26593d6..8a2e6706034 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ElementValuePair.java
@@ -24,56 +24,47 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-import com.sun.org.apache.bcel.internal.Const;
-
 /**
- * an annotation's element value pair
+ * An annotation's element value pair.
  *
  * @since 6.0
  */
-public class ElementValuePair
-{
+public class ElementValuePair {
+
+    static final ElementValuePair[] EMPTY_ARRAY = {};
+
     private final ElementValue elementValue;
 
     private final ConstantPool constantPool;
 
     private final int elementNameIndex;
 
-    public ElementValuePair(final int elementNameIndex, final ElementValue elementValue,
-            final ConstantPool constantPool)
-    {
+    public ElementValuePair(final int elementNameIndex, final ElementValue elementValue, final ConstantPool constantPool) {
         this.elementValue = elementValue;
         this.elementNameIndex = elementNameIndex;
         this.constantPool = constantPool;
     }
 
-    public String getNameString()
-    {
-        final ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant(
-                elementNameIndex, Const.CONSTANT_Utf8);
-        return c.getBytes();
+    protected void dump(final DataOutputStream dos) throws IOException {
+        dos.writeShort(elementNameIndex); // u2 name of the element
+        elementValue.dump(dos);
     }
 
-    public final ElementValue getValue()
-    {
-        return elementValue;
+    public int getNameIndex() {
+        return elementNameIndex;
     }
 
-    public int getNameIndex()
-    {
-        return elementNameIndex;
+    public String getNameString() {
+        return constantPool.getConstantUtf8(elementNameIndex).getBytes();
     }
 
-    public String toShortString()
-    {
-        final StringBuilder result = new StringBuilder();
-        result.append(getNameString()).append("=").append(
-                getValue().toShortString());
-        return result.toString();
+    public final ElementValue getValue() {
+        return elementValue;
     }
 
-    protected void dump(final DataOutputStream dos) throws IOException {
-        dos.writeShort(elementNameIndex); // u2 name of the element
-        elementValue.dump(dos);
+    public String toShortString() {
+        final StringBuilder result = new StringBuilder();
+        result.append(getNameString()).append("=").append(getValue().toShortString());
+        return result.toString();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java
index 231e4e64c1a..826ba41af70 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java
@@ -22,355 +22,304 @@
 package com.sun.org.apache.bcel.internal.classfile;
 
 /**
- * Visitor with empty method bodies, can be extended and used in conjunction
- * with the DescendingVisitor class, e.g. By courtesy of David Spencer.
+ * Visitor with empty method bodies, can be extended and used in conjunction with the DescendingVisitor class, e.g. By
+ * courtesy of David Spencer.
  *
  * @see DescendingVisitor
  */
-public class EmptyVisitor implements Visitor
-{
-    protected EmptyVisitor()
-    {
+public class EmptyVisitor implements Visitor {
+    protected EmptyVisitor() {
     }
 
     /**
      * @since 6.0
      */
     @Override
-    public void visitAnnotation(final Annotations obj)
-    {
+    public void visitAnnotation(final Annotations obj) {
     }
 
     /**
      * @since 6.0
      */
     @Override
-    public void visitParameterAnnotation(final ParameterAnnotations obj)
-    {
+    public void visitAnnotationDefault(final AnnotationDefault obj) {
     }
 
     /**
      * @since 6.0
      */
     @Override
-    public void visitAnnotationEntry(final AnnotationEntry obj)
-    {
+    public void visitAnnotationEntry(final AnnotationEntry obj) {
     }
 
     /**
      * @since 6.0
      */
     @Override
-    public void visitAnnotationDefault(final AnnotationDefault obj)
-    {
+    public void visitBootstrapMethods(final BootstrapMethods obj) {
     }
 
     @Override
-    public void visitCode(final Code obj)
-    {
+    public void visitCode(final Code obj) {
     }
 
     @Override
-    public void visitCodeException(final CodeException obj)
-    {
+    public void visitCodeException(final CodeException obj) {
     }
 
     @Override
-    public void visitConstantClass(final ConstantClass obj)
-    {
+    public void visitConstantClass(final ConstantClass obj) {
     }
 
     @Override
-    public void visitConstantDouble(final ConstantDouble obj)
-    {
+    public void visitConstantDouble(final ConstantDouble obj) {
     }
 
+    /**
+     * @since 6.3
+     */
     @Override
-    public void visitConstantFieldref(final ConstantFieldref obj)
-    {
+    public void visitConstantDynamic(final ConstantDynamic obj) {
     }
 
     @Override
-    public void visitConstantFloat(final ConstantFloat obj)
-    {
+    public void visitConstantFieldref(final ConstantFieldref obj) {
     }
 
     @Override
-    public void visitConstantInteger(final ConstantInteger obj)
-    {
+    public void visitConstantFloat(final ConstantFloat obj) {
     }
 
     @Override
-    public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj)
-    {
+    public void visitConstantInteger(final ConstantInteger obj) {
     }
 
     @Override
-    public void visitConstantInvokeDynamic(final ConstantInvokeDynamic obj)
-    {
+    public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj) {
     }
 
     @Override
-    public void visitConstantLong(final ConstantLong obj)
-    {
+    public void visitConstantInvokeDynamic(final ConstantInvokeDynamic obj) {
     }
 
     @Override
-    public void visitConstantMethodref(final ConstantMethodref obj)
-    {
+    public void visitConstantLong(final ConstantLong obj) {
     }
 
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitConstantNameAndType(final ConstantNameAndType obj)
-    {
+    public void visitConstantMethodHandle(final ConstantMethodHandle constantMethodHandle) {
+    }
+
+    @Override
+    public void visitConstantMethodref(final ConstantMethodref obj) {
     }
 
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitConstantPool(final ConstantPool obj)
-    {
+    public void visitConstantMethodType(final ConstantMethodType obj) {
     }
 
+    /**
+     * @since 6.1
+     */
     @Override
-    public void visitConstantString(final ConstantString obj)
-    {
+    public void visitConstantModule(final ConstantModule constantModule) {
     }
 
     @Override
-    public void visitConstantUtf8(final ConstantUtf8 obj)
-    {
+    public void visitConstantNameAndType(final ConstantNameAndType obj) {
     }
 
+    /**
+     * @since 6.1
+     */
     @Override
-    public void visitConstantValue(final ConstantValue obj)
-    {
+    public void visitConstantPackage(final ConstantPackage constantPackage) {
     }
 
     @Override
-    public void visitDeprecated(final Deprecated obj)
-    {
+    public void visitConstantPool(final ConstantPool obj) {
     }
 
     @Override
-    public void visitExceptionTable(final ExceptionTable obj)
-    {
+    public void visitConstantString(final ConstantString obj) {
     }
 
     @Override
-    public void visitField(final Field obj)
-    {
+    public void visitConstantUtf8(final ConstantUtf8 obj) {
     }
 
     @Override
-    public void visitInnerClass(final InnerClass obj)
-    {
+    public void visitConstantValue(final ConstantValue obj) {
     }
 
     @Override
-    public void visitInnerClasses(final InnerClasses obj)
-    {
+    public void visitDeprecated(final Deprecated obj) {
     }
 
     /**
      * @since 6.0
      */
     @Override
-    public void visitBootstrapMethods(final BootstrapMethods obj)
-    {
-    }
-
-    @Override
-    public void visitJavaClass(final JavaClass obj)
-    {
+    public void visitEnclosingMethod(final EnclosingMethod obj) {
     }
 
     @Override
-    public void visitLineNumber(final LineNumber obj)
-    {
+    public void visitExceptionTable(final ExceptionTable obj) {
     }
 
     @Override
-    public void visitLineNumberTable(final LineNumberTable obj)
-    {
+    public void visitField(final Field obj) {
     }
 
     @Override
-    public void visitLocalVariable(final LocalVariable obj)
-    {
+    public void visitInnerClass(final InnerClass obj) {
     }
 
     @Override
-    public void visitLocalVariableTable(final LocalVariableTable obj)
-    {
+    public void visitInnerClasses(final InnerClasses obj) {
     }
 
     @Override
-    public void visitMethod(final Method obj)
-    {
+    public void visitJavaClass(final JavaClass obj) {
     }
 
     @Override
-    public void visitSignature(final Signature obj)
-    {
+    public void visitLineNumber(final LineNumber obj) {
     }
 
     @Override
-    public void visitSourceFile(final SourceFile obj)
-    {
+    public void visitLineNumberTable(final LineNumberTable obj) {
     }
 
     @Override
-    public void visitSynthetic(final Synthetic obj)
-    {
+    public void visitLocalVariable(final LocalVariable obj) {
     }
 
     @Override
-    public void visitUnknown(final Unknown obj)
-    {
+    public void visitLocalVariableTable(final LocalVariableTable obj) {
     }
 
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitStackMap(final StackMap obj)
-    {
+    public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj) {
     }
 
     @Override
-    public void visitStackMapEntry(final StackMapEntry obj)
-    {
+    public void visitMethod(final Method obj) {
     }
 
     /**
      * @since 6.0
-    @Override
-    public void visitStackMapTable(StackMapTable obj)
-    {
-    }
+     * @Override public void visitStackMapTable(StackMapTable obj) { }
      */
 
     /**
      * @since 6.0
-    @Override
-    public void visitStackMapTableEntry(StackMapTableEntry obj)
-    {
-    }
+     * @Override public void visitStackMapTableEntry(StackMapTableEntry obj) { }
      */
 
     /**
-     * @since 6.0
+     * @since 6.4.0
      */
     @Override
-    public void visitEnclosingMethod(final EnclosingMethod obj)
-    {
+    public void visitMethodParameter(final MethodParameter obj) {
     }
 
     /**
      * @since 6.0
      */
     @Override
-    public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj)
-    {
+    public void visitMethodParameters(final MethodParameters obj) {
     }
 
-    /**
-     * @since 6.0
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitMethodParameters(final MethodParameters obj)
-    {
+    public void visitModule(final Module obj) {
     }
 
-    /**
-     * @since 6.4.0
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitMethodParameter(final MethodParameter obj)
-    {
+    public void visitModuleExports(final ModuleExports obj) {
     }
 
-    /**
-     * @since 6.0
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantMethodType(final ConstantMethodType obj)
-    {
+    public void visitModuleMainClass(final ModuleMainClass obj) {
     }
 
-    /**
-     * @since 6.0
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantMethodHandle(final ConstantMethodHandle constantMethodHandle) {
+    public void visitModuleOpens(final ModuleOpens obj) {
     }
 
-    /**
-     * @since 6.0
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitParameterAnnotationEntry(final ParameterAnnotationEntry parameterAnnotationEntry) {
+    public void visitModulePackages(final ModulePackages obj) {
     }
 
-    /**
-     * @since 6.1
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantPackage(final ConstantPackage constantPackage) {
+    public void visitModuleProvides(final ModuleProvides obj) {
     }
 
-    /**
-     * @since 6.1
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantModule(final ConstantModule constantModule) {
+    public void visitModuleRequires(final ModuleRequires obj) {
     }
 
-    /**
-     * @since 6.3
-     */
+    /** @since 6.4.0 */
     @Override
-    public void visitConstantDynamic(final ConstantDynamic obj) {
+    public void visitNestHost(final NestHost obj) {
     }
 
     /** @since 6.4.0 */
     @Override
-    public void visitModule(final Module obj) {
+    public void visitNestMembers(final NestMembers obj) {
     }
 
-    /** @since 6.4.0 */
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitModuleRequires(final ModuleRequires obj) {
+    public void visitParameterAnnotation(final ParameterAnnotations obj) {
     }
 
-    /** @since 6.4.0 */
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitModuleExports(final ModuleExports obj) {
+    public void visitParameterAnnotationEntry(final ParameterAnnotationEntry parameterAnnotationEntry) {
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModuleOpens(final ModuleOpens obj) {
+    public void visitSignature(final Signature obj) {
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModuleProvides(final ModuleProvides obj) {
+    public void visitSourceFile(final SourceFile obj) {
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModulePackages(final ModulePackages obj) {
+    public void visitStackMap(final StackMap obj) {
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitModuleMainClass(final ModuleMainClass obj) {
+    public void visitStackMapEntry(final StackMapEntry obj) {
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitNestHost(final NestHost obj) {
+    public void visitSynthetic(final Synthetic obj) {
     }
 
-    /** @since 6.4.0 */
     @Override
-    public void visitNestMembers(final NestMembers obj) {
+    public void visitUnknown(final Unknown obj) {
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java
index 431cabd8771..326e77738b0 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnclosingMethod.java
@@ -26,10 +26,10 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This attribute exists for local or
- * anonymous classes and ... there can be only one.
+ * This attribute exists for local or anonymous classes and ... there can be only one.
  *
  * @since 6.0
  */
@@ -41,10 +41,10 @@ public class EnclosingMethod extends Attribute {
 
     // If the current class is not immediately enclosed by a method or
     // constructor, then the value of the method_index item must be zero.
-    // Otherwise, the value of the  method_index item must point to a
+    // Otherwise, the value of the method_index item must point to a
     // CONSTANT_NameAndType_info structure representing the name and the
     // type of a method in the class referenced by the class we point
-    // to in the class_index.  *It is the compiler responsibility* to
+    // to in the class_index. *It is the compiler responsibility* to
     // ensure that the method identified by this index is the closest
     // lexically enclosing method that includes the local/anonymous class.
     private int methodIndex;
@@ -54,27 +54,45 @@ public class EnclosingMethod extends Attribute {
         this(nameIndex, len, input.readUnsignedShort(), input.readUnsignedShort(), cpool);
     }
 
-    private EnclosingMethod(final int nameIndex, final int len, final int classIdx,final int methodIdx, final ConstantPool cpool) {
-        super(Const.ATTR_ENCLOSING_METHOD, nameIndex, len, cpool);
-        classIndex  = classIdx;
-        methodIndex = methodIdx;
+    private EnclosingMethod(final int nameIndex, final int len, final int classIndex, final int methodIndex, final ConstantPool cpool) {
+        super(Const.ATTR_ENCLOSING_METHOD, nameIndex, Args.require(len, 4, "EnclosingMethod attribute length"), cpool);
+        this.classIndex = Args.requireU2(classIndex, 0, cpool.getLength(), "EnclosingMethod class index");
+        this.methodIndex = Args.requireU2(methodIndex, "EnclosingMethod method index");
     }
 
     @Override
     public void accept(final Visitor v) {
-      v.visitEnclosingMethod(this);
+        v.visitEnclosingMethod(this);
     }
 
     @Override
-    public Attribute copy(final ConstantPool constant_pool) {
+    public Attribute copy(final ConstantPool constantPool) {
         return (Attribute) clone();
     }
 
+    @Override
+    public final void dump(final DataOutputStream file) throws IOException {
+        super.dump(file);
+        file.writeShort(classIndex);
+        file.writeShort(methodIndex);
+    }
+
+    public final ConstantClass getEnclosingClass() {
+        return super.getConstantPool().getConstant(classIndex, Const.CONSTANT_Class, ConstantClass.class);
+    }
+
     // Accessors
     public final int getEnclosingClassIndex() {
         return classIndex;
     }
 
+    public final ConstantNameAndType getEnclosingMethod() {
+        if (methodIndex == 0) {
+            return null;
+        }
+        return super.getConstantPool().getConstant(methodIndex, Const.CONSTANT_NameAndType, ConstantNameAndType.class);
+    }
+
     public final int getEnclosingMethodIndex() {
         return methodIndex;
     }
@@ -86,26 +104,4 @@ public final void setEnclosingClassIndex(final int idx) {
     public final void setEnclosingMethodIndex(final int idx) {
         methodIndex = idx;
     }
-
-    public final ConstantClass getEnclosingClass() {
-        final ConstantClass c =
-            (ConstantClass)super.getConstantPool().getConstant(classIndex,Const.CONSTANT_Class);
-        return c;
-    }
-
-    public final ConstantNameAndType getEnclosingMethod() {
-        if (methodIndex == 0) {
-            return null;
-        }
-        final ConstantNameAndType nat =
-            (ConstantNameAndType)super.getConstantPool().getConstant(methodIndex,Const.CONSTANT_NameAndType);
-        return nat;
-    }
-
-    @Override
-    public final void dump(final DataOutputStream file) throws IOException {
-        super.dump(file);
-        file.writeShort(classIndex);
-        file.writeShort(methodIndex);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java
index ac8632ee223..0a8163ededa 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/EnumElementValue.java
@@ -24,67 +24,49 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-import com.sun.org.apache.bcel.internal.Const;
-
 /**
  * @since 6.0
  */
-public class EnumElementValue extends ElementValue
-{
+public class EnumElementValue extends ElementValue {
     // For enum types, these two indices point to the type and value
     private final int typeIdx;
 
     private final int valueIdx;
 
-    public EnumElementValue(final int type, final int typeIdx, final int valueIdx,
-            final ConstantPool cpool)
-    {
+    public EnumElementValue(final int type, final int typeIdx, final int valueIdx, final ConstantPool cpool) {
         super(type, cpool);
         if (type != ENUM_CONSTANT) {
-            throw new IllegalArgumentException(
-                    "Only element values of type enum can be built with this ctor - type specified: " + type);
+            throw new ClassFormatException("Only element values of type enum can be built with this ctor - type specified: " + type);
         }
         this.typeIdx = typeIdx;
         this.valueIdx = valueIdx;
     }
 
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
+    public void dump(final DataOutputStream dos) throws IOException {
         dos.writeByte(super.getType()); // u1 type of value (ENUM_CONSTANT == 'e')
         dos.writeShort(typeIdx); // u2
         dos.writeShort(valueIdx); // u2
     }
 
-    @Override
-    public String stringifyValue()
-    {
-        final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(valueIdx,
-                Const.CONSTANT_Utf8);
-        return cu8.getBytes();
+    public String getEnumTypeString() {
+        return super.getConstantPool().getConstantUtf8(typeIdx).getBytes();
     }
 
-    public String getEnumTypeString()
-    {
-        final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(typeIdx,
-                Const.CONSTANT_Utf8);
-        return cu8.getBytes();// Utility.signatureToString(cu8.getBytes());
+    public String getEnumValueString() {
+        return super.getConstantPool().getConstantUtf8(valueIdx).getBytes();
     }
 
-    public String getEnumValueString()
-    {
-        final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(valueIdx,
-                Const.CONSTANT_Utf8);
-        return cu8.getBytes();
+    public int getTypeIndex() {
+        return typeIdx;
     }
 
-    public int getValueIndex()
-    {
+    public int getValueIndex() {
         return valueIdx;
     }
 
-    public int getTypeIndex()
-    {
-        return typeIdx;
+    @Override
+    public String stringifyValue() {
+        return super.getConstantPool().getConstantUtf8(valueIdx).getBytes();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java
index cddae111923..90eaa3eb062 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,85 +23,104 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class represents the table of exceptions that are thrown by a
- * method. This attribute may be used once per method.  The name of
- * this class is <em>ExceptionTable</em> for historical reasons; The
- * Java Virtual Machine Specification, Second Edition defines this
- * attribute using the name <em>Exceptions</em> (which is inconsistent
- * with the other classes).
+ * This class represents the table of exceptions that are thrown by a method. This attribute may be used once per
+ * method. The name of this class is <em>ExceptionTable</em> for historical reasons; The Java Virtual Machine
+ * Specification, Second Edition defines this attribute using the name <em>Exceptions</em> (which is inconsistent with
+ * the other classes).
  *
- * @see     Code
+ * <pre>
+ * Exceptions_attribute {
+ *   u2 attribute_name_index;
+ *   u4 attribute_length;
+ *   u2 number_of_exceptions;
+ *   u2 exception_index_table[number_of_exceptions];
+ * }
+ * </pre>
+ * @see Code
+ * @LastModified: Feb 2023
  */
 public final class ExceptionTable extends Attribute {
 
     private int[] exceptionIndexTable; // constant pool
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
     public ExceptionTable(final ExceptionTable c) {
         this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), c.getConstantPool());
     }
 
-
-    /**
-     * @param name_index Index in constant pool
-     * @param length Content length in bytes
-     * @param exceptionIndexTable Table of indices in constant pool
-     * @param constant_pool Array of constants
-     */
-    public ExceptionTable(final int name_index, final int length, final int[] exceptionIndexTable,
-            final ConstantPool constant_pool) {
-        super(Const.ATTR_EXCEPTIONS, name_index, length, constant_pool);
-        this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : new int[0];
-    }
-
-
     /**
      * Construct object from input stream.
+     *
      * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param input Input stream
      * @param constantPool Array of constants
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     ExceptionTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
         this(nameIndex, length, (int[]) null, constantPool);
-        final int number_of_exceptions = input.readUnsignedShort();
-        exceptionIndexTable = new int[number_of_exceptions];
-        for (int i = 0; i < number_of_exceptions; i++) {
+        final int exceptionCount = input.readUnsignedShort();
+        exceptionIndexTable = new int[exceptionCount];
+        for (int i = 0; i < exceptionCount; i++) {
             exceptionIndexTable[i] = input.readUnsignedShort();
         }
     }
 
+    /**
+     * @param nameIndex Index in constant pool
+     * @param length Content length in bytes
+     * @param exceptionIndexTable Table of indices in constant pool
+     * @param constantPool Array of constants
+     */
+    public ExceptionTable(final int nameIndex, final int length, final int[] exceptionIndexTable, final ConstantPool constantPool) {
+        super(Const.ATTR_EXCEPTIONS, nameIndex, length, constantPool);
+        this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : Const.EMPTY_INT_ARRAY;
+        Args.requireU2(this.exceptionIndexTable.length, "exceptionIndexTable.length");
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionTable(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final ExceptionTable c = (ExceptionTable) clone();
+        if (exceptionIndexTable != null) {
+            c.exceptionIndexTable = exceptionIndexTable.clone();
+        }
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump exceptions attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(exceptionIndexTable.length);
         for (final int index : exceptionIndexTable) {
@@ -110,7 +128,6 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
     /**
      * @return Array of indices into constant pool of thrown exceptions.
      */
@@ -118,36 +135,29 @@ public int[] getExceptionIndexTable() {
         return exceptionIndexTable;
     }
 
-
-    /**
-     * @return Length of exception table.
-     */
-    public int getNumberOfExceptions() {
-        return exceptionIndexTable == null ? 0 : exceptionIndexTable.length;
-    }
-
-
     /**
      * @return class names of thrown exceptions
      */
     public String[] getExceptionNames() {
         final String[] names = new String[exceptionIndexTable.length];
-        for (int i = 0; i < exceptionIndexTable.length; i++) {
-            names[i] = super.getConstantPool().getConstantString(exceptionIndexTable[i],
-                    Const.CONSTANT_Class).replace('/', '.');
-        }
+        Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(exceptionIndexTable[i], Const.CONSTANT_Class)));
         return names;
     }
 
-
     /**
-     * @param exceptionIndexTable the list of exception indexes
-     * Also redefines number_of_exceptions according to table length.
+     * @return Length of exception table.
      */
-    public void setExceptionIndexTable( final int[] exceptionIndexTable ) {
-        this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : new int[0];
+    public int getNumberOfExceptions() {
+        return exceptionIndexTable == null ? 0 : exceptionIndexTable.length;
     }
 
+    /**
+     * @param exceptionIndexTable the list of exception indexes Also redefines number_of_exceptions according to table
+     *        length.
+     */
+    public void setExceptionIndexTable(final int[] exceptionIndexTable) {
+        this.exceptionIndexTable = exceptionIndexTable != null ? exceptionIndexTable : Const.EMPTY_INT_ARRAY;
+    }
 
     /**
      * @return String representation, i.e., a list of thrown exceptions.
@@ -166,20 +176,4 @@ public String toString() {
         }
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final ExceptionTable c = (ExceptionTable) clone();
-        if (exceptionIndexTable != null) {
-            c.exceptionIndexTable = new int[exceptionIndexTable.length];
-            System.arraycopy(exceptionIndexTable, 0, c.exceptionIndexTable, 0,
-                    exceptionIndexTable.length);
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Field.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Field.java
index f3ad1c45f94..7e6ccb2ecb5 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Field.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Field.java
@@ -30,75 +30,111 @@
 import com.sun.org.apache.bcel.internal.util.BCELComparator;
 
 /**
- * This class represents the field info structure, i.e., the representation
- * for a variable in the class. See JVM specification for details.
- *
+ * This class represents the field info structure, i.e., the representation for a variable in the class. See JVM
+ * specification for details.
  */
 public final class Field extends FieldOrMethod {
 
+    /**
+     * Empty array constant.
+     *
+     * @since 6.6.0
+     */
+    public static final Field[] EMPTY_ARRAY = {};
+
     private static BCELComparator bcelComparator = new BCELComparator() {
 
         @Override
-        public boolean equals( final Object o1, final Object o2 ) {
+        public boolean equals(final Object o1, final Object o2) {
             final Field THIS = (Field) o1;
             final Field THAT = (Field) o2;
-            return Objects.equals(THIS.getName(), THAT.getName())
-                    && Objects.equals(THIS.getSignature(), THAT.getSignature());
+            return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
         }
 
-
         @Override
-        public int hashCode( final Object o ) {
+        public int hashCode(final Object o) {
             final Field THIS = (Field) o;
             return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
         }
     };
 
+    /**
+     * Empty array.
+     */
+    static final Field[] EMPTY_FIELD_ARRAY = {};
 
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * @return Comparison strategy object
      */
-    public Field(final Field c) {
-        super(c);
+    public static BCELComparator getComparator() {
+        return bcelComparator;
     }
 
+    /**
+     * @param comparator Comparison strategy object
+     */
+    public static void setComparator(final BCELComparator comparator) {
+        bcelComparator = comparator;
+    }
 
     /**
      * Construct object from file stream.
+     *
      * @param file Input stream
      */
-    Field(final DataInput file, final ConstantPool constant_pool) throws IOException,
-            ClassFormatException {
-        super(file, constant_pool);
+    Field(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException {
+        super(file, constantPool);
     }
 
+    /**
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
+     */
+    public Field(final Field c) {
+        super(c);
+    }
 
     /**
-     * @param access_flags Access rights of field
-     * @param name_index Points to field name in constant pool
-     * @param signature_index Points to encoded signature
+     * @param accessFlags Access rights of field
+     * @param nameIndex Points to field name in constant pool
+     * @param signatureIndex Points to encoded signature
      * @param attributes Collection of attributes
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public Field(final int access_flags, final int name_index, final int signature_index, final Attribute[] attributes,
-            final ConstantPool constant_pool) {
-        super(access_flags, name_index, signature_index, attributes, constant_pool);
+    public Field(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool) {
+        super(accessFlags, nameIndex, signatureIndex, attributes, constantPool);
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitField(this);
     }
 
+    /**
+     * @return deep copy of this field
+     */
+    public Field copy(final ConstantPool constantPool) {
+        return (Field) copy_(constantPool);
+    }
+
+    /**
+     * Return value as defined by given BCELComparator strategy. By default two Field objects are said to be equal when
+     * their names and signatures are equal.
+     *
+     * @see Object#equals(Object)
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        return bcelComparator.equals(this, obj);
+    }
 
     /**
      * @return constant value associated with this field (may be null)
@@ -112,10 +148,26 @@ public ConstantValue getConstantValue() {
         return null;
     }
 
+    /**
+     * @return type of field
+     */
+    public Type getType() {
+        return Type.getReturnType(getSignature());
+    }
 
     /**
-     * Return string representation close to declaration format,
-     * `public static final short MAX = 100', e.g..
+     * Return value as defined by given BCELComparator strategy. By default return the hashcode of the field's name XOR
+     * signature.
+     *
+     * @see Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return bcelComparator.hashCode(this);
+    }
+
+    /**
+     * Return string representation close to declaration format, 'public static final short MAX = 100', e.g..
      *
      * @return String representation of field, including the signature.
      */
@@ -127,7 +179,7 @@ public String toString() {
 
         // Get names from constant pool
         access = Utility.accessToString(super.getAccessFlags());
-        access = access.isEmpty() ? "" : (access + " ");
+        access = access.isEmpty() ? "" : access + " ";
         signature = Utility.signatureToString(getSignature());
         name = getName();
         final StringBuilder buf = new StringBuilder(64); // CHECKSTYLE IGNORE MagicNumber
@@ -143,61 +195,4 @@ public String toString() {
         }
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this field
-     */
-    public Field copy( final ConstantPool _constant_pool ) {
-        return (Field) copy_(_constant_pool);
-    }
-
-
-    /**
-     * @return type of field
-     */
-    public Type getType() {
-        return Type.getReturnType(getSignature());
-    }
-
-
-    /**
-     * @return Comparison strategy object
-     */
-    public static BCELComparator getComparator() {
-        return bcelComparator;
-    }
-
-
-    /**
-     * @param comparator Comparison strategy object
-     */
-    public static void setComparator( final BCELComparator comparator ) {
-        bcelComparator = comparator;
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default two Field objects are said to be equal when
-     * their names and signatures are equal.
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals( final Object obj ) {
-        return bcelComparator.equals(this, obj);
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default return the hashcode of the field's name XOR signature.
-     *
-     * @see java.lang.Object#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        return bcelComparator.hashCode(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java
index 40e3ad4675a..1daa6a62fd5 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java
@@ -23,8 +23,7 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-
-import com.sun.org.apache.bcel.internal.Const;
+import java.util.Arrays;
 
 /**
  * Abstract super class for fields and methods.
@@ -32,89 +31,121 @@
  * @LastModified: Jan 2020
  */
 public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node {
-    private int name_index; // Points to field name in constant pool
-    private int signature_index; // Points to encoded signature
-    private Attribute[] attributes; // Collection of attributes
-    private int attributes_count; // No. of attributes
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected int name_index; // Points to field name in constant pool
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected int signature_index; // Points to encoded signature
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected Attribute[] attributes; // Collection of attributes
+
+    /**
+     * @deprecated (since 6.0) will be removed (not needed)
+     */
+    @java.lang.Deprecated
+    protected int attributes_count; // No. of attributes
 
     // @since 6.0
     private AnnotationEntry[] annotationEntries; // annotations defined on the field or method
 
-    private ConstantPool constant_pool;
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @java.lang.Deprecated
+    protected ConstantPool constant_pool;
 
-    private String signatureAttributeString = null;
-    private boolean searchedForSignatureAttribute = false;
+    private String signatureAttributeString;
+    private boolean searchedForSignatureAttribute;
 
     FieldOrMethod() {
     }
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * Construct object from file stream.
+     *
+     * @param file Input stream
+     * @throws IOException if an I/O error occurs.
      */
-    protected FieldOrMethod(final FieldOrMethod c) {
-        this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(),
-                c.getAttributes(), c.getConstantPool());
+    protected FieldOrMethod(final DataInput file, final ConstantPool constantPool) throws IOException {
+        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null, constantPool);
+        final int attributesCount = file.readUnsignedShort();
+        attributes = new Attribute[attributesCount];
+        for (int i = 0; i < attributesCount; i++) {
+            attributes[i] = Attribute.readAttribute(file, constantPool);
+        }
+        this.attributes_count = attributesCount; // init deprecated field
     }
 
-
     /**
      * Construct object from file stream.
      *
      * @param file Input stream
-     * @throws IOException
-     * @throws ClassFormatException
+     * @throws IOException if an I/O error occurs.
      * @deprecated (6.0) Use {@link #FieldOrMethod(java.io.DataInput, ConstantPool)} instead.
      */
     @java.lang.Deprecated
-    protected FieldOrMethod(final DataInputStream file, final ConstantPool constant_pool)
-            throws IOException,
-            ClassFormatException {
-        this((DataInput) file, constant_pool);
+    protected FieldOrMethod(final DataInputStream file, final ConstantPool constantPool) throws IOException {
+        this((DataInput) file, constantPool);
     }
 
     /**
-     * Construct object from file stream.
-     * @param file Input stream
-     * @throws IOException
-     * @throws ClassFormatException
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
-    protected FieldOrMethod(final DataInput file, final ConstantPool constant_pool)
-            throws IOException, ClassFormatException {
-        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null,
-                constant_pool);
-        final int attributes_count = file.readUnsignedShort();
-        attributes = new Attribute[attributes_count];
-        for (int i = 0; i < attributes_count; i++) {
-            attributes[i] = Attribute.readAttribute(file, constant_pool);
-        }
-        this.attributes_count = attributes_count; // init deprecated field
+    protected FieldOrMethod(final FieldOrMethod c) {
+        this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), c.getAttributes(), c.getConstantPool());
     }
 
-
     /**
-     * @param access_flags Access rights of method
-     * @param name_index Points to field name in constant pool
-     * @param signature_index Points to encoded signature
+     * @param accessFlags Access rights of method
+     * @param nameIndex Points to field name in constant pool
+     * @param signatureIndex Points to encoded signature
      * @param attributes Collection of attributes
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    protected FieldOrMethod(final int access_flags, final int name_index, final int signature_index,
-            final Attribute[] attributes, final ConstantPool constant_pool) {
-        super(access_flags);
-        this.name_index = name_index;
-        this.signature_index = signature_index;
-        this.constant_pool = constant_pool;
+    protected FieldOrMethod(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes,
+        final ConstantPool constantPool) {
+        super(accessFlags);
+        this.name_index = nameIndex;
+        this.signature_index = signatureIndex;
+        this.constant_pool = constantPool;
         setAttributes(attributes);
     }
 
+    /**
+     * @return deep copy of this field
+     */
+    protected FieldOrMethod copy_(final ConstantPool constantPool) {
+        try {
+            final FieldOrMethod c = (FieldOrMethod) clone();
+            c.constant_pool = constantPool;
+            c.attributes = new Attribute[attributes.length];
+            c.attributes_count = attributes_count; // init deprecated field
+            Arrays.setAll(c.attributes, i -> attributes[i].copy(constantPool));
+            return c;
+        } catch (final CloneNotSupportedException e) {
+            throw new IllegalStateException(e);
+        }
+    }
 
     /**
      * Dump object to file stream on binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     public final void dump(final DataOutputStream file) throws IOException {
         file.writeShort(super.getAccessFlags());
@@ -128,24 +159,25 @@ public final void dump(final DataOutputStream file) throws IOException {
         }
     }
 
-
     /**
-     * @return Collection of object attributes.
+     * @return Annotations on the field or method
+     * @since 6.0
      */
-    public final Attribute[] getAttributes() {
-        return attributes;
-    }
+    public AnnotationEntry[] getAnnotationEntries() {
+        if (annotationEntries == null) {
+            annotationEntries = AnnotationEntry.createAnnotationEntries(getAttributes());
+        }
 
+        return annotationEntries;
+    }
 
     /**
-     * @param attributes Collection of object attributes.
+     * @return Collection of object attributes.
      */
-    public final void setAttributes( final Attribute[] attributes ) {
-        this.attributes = attributes;
-        this.attributes_count = attributes != null ? attributes.length : 0; // init deprecated field
+    public final Attribute[] getAttributes() {
+        return attributes;
     }
 
-
     /**
      * @return Constant pool used by this object.
      */
@@ -153,14 +185,33 @@ public final ConstantPool getConstantPool() {
         return constant_pool;
     }
 
-
     /**
-     * @param constant_pool Constant pool to be used for this object.
+     * Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature may be
+     * (Ljava/util/Vector;)V the signature attribute may in fact say 'Ljava/lang/Vector&lt;Ljava/lang/String&gt;;' Coded for
+     * performance - searches for the attribute only when requested - only searches for it once.
+     *
+     * @since 6.0
      */
-    public final void setConstantPool( final ConstantPool constant_pool ) {
-        this.constant_pool = constant_pool;
+    public final String getGenericSignature() {
+        if (!searchedForSignatureAttribute) {
+            boolean found = false;
+            for (int i = 0; !found && i < attributes.length; i++) {
+                if (attributes[i] instanceof Signature) {
+                    signatureAttributeString = ((Signature) attributes[i]).getSignature();
+                    found = true;
+                }
+            }
+            searchedForSignatureAttribute = true;
+        }
+        return signatureAttributeString;
     }
 
+    /**
+     * @return Name of object, i.e., method name or field name
+     */
+    public final String getName() {
+        return constant_pool.getConstantUtf8(name_index).getBytes();
+    }
 
     /**
      * @return Index in constant pool of object's name.
@@ -169,15 +220,13 @@ public final int getNameIndex() {
         return name_index;
     }
 
-
     /**
-     * @param name_index Index in constant pool of object's name.
+     * @return String representation of object's type signature (java style)
      */
-    public final void setNameIndex( final int name_index ) {
-        this.name_index = name_index;
+    public final String getSignature() {
+        return constant_pool.getConstantUtf8(signature_index).getBytes();
     }
 
-
     /**
      * @return Index in constant pool of field signature.
      */
@@ -185,96 +234,32 @@ public final int getSignatureIndex() {
         return signature_index;
     }
 
-
-    /**
-     * @param signature_index Index in constant pool of field signature.
-     */
-    public final void setSignatureIndex( final int signature_index ) {
-        this.signature_index = signature_index;
-    }
-
-
     /**
-     * @return Name of object, i.e., method name or field name
-     */
-    public final String getName() {
-        ConstantUtf8 c;
-        c = (ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8);
-        return c.getBytes();
-    }
-
-
-    /**
-     * @return String representation of object's type signature (java style)
+     * @param attributes Collection of object attributes.
      */
-    public final String getSignature() {
-        ConstantUtf8 c;
-        c = (ConstantUtf8) constant_pool.getConstant(signature_index, Const.CONSTANT_Utf8);
-        return c.getBytes();
+    public final void setAttributes(final Attribute[] attributes) {
+        this.attributes = attributes;
+        this.attributes_count = attributes != null ? attributes.length : 0; // init deprecated field
     }
 
-
     /**
-     * @return deep copy of this field
+     * @param constantPool Constant pool to be used for this object.
      */
-    protected FieldOrMethod copy_( final ConstantPool _constant_pool ) {
-        FieldOrMethod c = null;
-
-        try {
-          c = (FieldOrMethod)clone();
-        } catch(final CloneNotSupportedException e) {
-            // ignored, but will cause NPE ...
-        }
-
-        c.constant_pool    = constant_pool;
-        c.attributes       = new Attribute[attributes.length];
-        c.attributes_count = attributes_count; // init deprecated field
-
-        for (int i = 0; i < attributes.length; i++) {
-            c.attributes[i] = attributes[i].copy(constant_pool);
-        }
-
-        return c;
+    public final void setConstantPool(final ConstantPool constantPool) {
+        this.constant_pool = constantPool;
     }
 
     /**
-     * @return Annotations on the field or method
-     * @since 6.0
+     * @param nameIndex Index in constant pool of object's name.
      */
-    public AnnotationEntry[] getAnnotationEntries() {
-        if (annotationEntries == null) {
-            annotationEntries = AnnotationEntry.createAnnotationEntries(getAttributes());
-        }
-
-        return annotationEntries;
+    public final void setNameIndex(final int nameIndex) {
+        this.name_index = nameIndex;
     }
 
     /**
-     * Hunts for a signature attribute on the member and returns its contents.
-     * So where the 'regular' signature may be (Ljava/util/Vector;)V the
-     * signature attribute may in fact say
-     * 'Ljava/lang/Vector&lt;Ljava/lang/String&gt;;' Coded for performance -
-     * searches for the attribute only when requested - only searches for it
-     * once.
-     *
-     * @since 6.0
+     * @param signatureIndex Index in constant pool of field signature.
      */
-    public final String getGenericSignature()
-    {
-        if (!searchedForSignatureAttribute)
-        {
-            boolean found = false;
-            for (int i = 0; !found && i < attributes.length; i++)
-            {
-                if (attributes[i] instanceof Signature)
-                {
-                    signatureAttributeString = ((Signature) attributes[i])
-                            .getSignature();
-                    found = true;
-                }
-            }
-            searchedForSignatureAttribute = true;
-        }
-        return signatureAttributeString;
+    public final void setSignatureIndex(final int signatureIndex) {
+        this.signature_index = signatureIndex;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java
index e7fbbe02b0f..d77582815b7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java
@@ -28,9 +28,8 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents a inner class attribute, i.e., the class
- * indices of the inner and outer classes, the name and the attributes
- * of the inner class.
+ * This class represents a inner class attribute, i.e., the class indices of the inner and outer classes, the name and
+ * the attributes of the inner class.
  *
  * @see InnerClasses
  */
@@ -41,69 +40,74 @@ public final class InnerClass implements Cloneable, Node {
     private int innerNameIndex;
     private int innerAccessFlags;
 
-
-    /**
-     * Initialize from another object.
-     */
-    public InnerClass(final InnerClass c) {
-        this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c
-                .getInnerAccessFlags());
-    }
-
-
     /**
      * Construct object from file stream.
+     *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     InnerClass(final DataInput file) throws IOException {
-        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
-                .readUnsignedShort());
+        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort());
     }
 
+    /**
+     * Initialize from another object.
+     *
+     * @param c Source to copy.
+     */
+    public InnerClass(final InnerClass c) {
+        this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c.getInnerAccessFlags());
+    }
 
     /**
      * @param innerClassIndex Class index in constant pool of inner class
      * @param outerClassIndex Class index in constant pool of outer class
-     * @param innerNameIndex  Name index in constant pool of inner class
+     * @param innerNameIndex Name index in constant pool of inner class
      * @param innerAccessFlags Access flags of inner class
      */
-    public InnerClass(final int innerClassIndex, final int outerClassIndex, final int innerNameIndex,
-            final int innerAccessFlags) {
+    public InnerClass(final int innerClassIndex, final int outerClassIndex, final int innerNameIndex, final int innerAccessFlags) {
         this.innerClassIndex = innerClassIndex;
         this.outerClassIndex = outerClassIndex;
         this.innerNameIndex = innerNameIndex;
         this.innerAccessFlags = innerAccessFlags;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitInnerClass(this);
     }
 
+    /**
+     * @return deep copy of this object
+     */
+    public InnerClass copy() {
+        try {
+            return (InnerClass) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
 
     /**
      * Dump inner class attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(innerClassIndex);
         file.writeShort(outerClassIndex);
         file.writeShort(innerNameIndex);
         file.writeShort(innerAccessFlags);
     }
 
-
     /**
      * @return access flags of inner class.
      */
@@ -111,7 +115,6 @@ public int getInnerAccessFlags() {
         return innerAccessFlags;
     }
 
-
     /**
      * @return class index of inner class.
      */
@@ -119,7 +122,6 @@ public int getInnerClassIndex() {
         return innerClassIndex;
     }
 
-
     /**
      * @return name index of inner class.
      */
@@ -127,7 +129,6 @@ public int getInnerNameIndex() {
         return innerNameIndex;
     }
 
-
     /**
      * @return class index of outer class.
      */
@@ -135,86 +136,63 @@ public int getOuterClassIndex() {
         return outerClassIndex;
     }
 
-
     /**
      * @param innerAccessFlags access flags for this inner class
      */
-    public void setInnerAccessFlags( final int innerAccessFlags ) {
+    public void setInnerAccessFlags(final int innerAccessFlags) {
         this.innerAccessFlags = innerAccessFlags;
     }
 
-
     /**
      * @param innerClassIndex index into the constant pool for this class
      */
-    public void setInnerClassIndex( final int innerClassIndex ) {
+    public void setInnerClassIndex(final int innerClassIndex) {
         this.innerClassIndex = innerClassIndex;
     }
 
-
     /**
      * @param innerNameIndex index into the constant pool for this class's name
      */
-    public void setInnerNameIndex( final int innerNameIndex ) { // TODO unused
+    public void setInnerNameIndex(final int innerNameIndex) { // TODO unused
         this.innerNameIndex = innerNameIndex;
     }
 
-
     /**
      * @param outerClassIndex index into the constant pool for the owning class
      */
-    public void setOuterClassIndex( final int outerClassIndex ) { // TODO unused
+    public void setOuterClassIndex(final int outerClassIndex) { // TODO unused
         this.outerClassIndex = outerClassIndex;
     }
 
-
     /**
      * @return String representation.
      */
     @Override
     public String toString() {
-        return "InnerClass(" + innerClassIndex + ", " + outerClassIndex + ", "
-                + innerNameIndex + ", " + innerAccessFlags + ")";
+        return "InnerClass(" + innerClassIndex + ", " + outerClassIndex + ", " + innerNameIndex + ", " + innerAccessFlags + ")";
     }
 
-
     /**
      * @return Resolved string representation
      */
-    public String toString( final ConstantPool constantPool ) {
-        String outer_class_name;
-        String inner_name;
-        String inner_class_name = constantPool.getConstantString(innerClassIndex,
-                Const.CONSTANT_Class);
-        inner_class_name = Utility.compactClassName(inner_class_name, false);
+    public String toString(final ConstantPool constantPool) {
+        String outerClassName;
+        String innerName;
+        String innerClassName = constantPool.getConstantString(innerClassIndex, Const.CONSTANT_Class);
+        innerClassName = Utility.compactClassName(innerClassName, false);
         if (outerClassIndex != 0) {
-            outer_class_name = constantPool.getConstantString(outerClassIndex,
-                    Const.CONSTANT_Class);
-            outer_class_name = " of class " + Utility.compactClassName(outer_class_name, false);
+            outerClassName = constantPool.getConstantString(outerClassIndex, Const.CONSTANT_Class);
+            outerClassName = " of class " + Utility.compactClassName(outerClassName, false);
         } else {
-            outer_class_name = "";
+            outerClassName = "";
         }
         if (innerNameIndex != 0) {
-            inner_name = ((ConstantUtf8) constantPool.getConstant(innerNameIndex,
-                    Const.CONSTANT_Utf8)).getBytes();
+            innerName = constantPool.getConstantUtf8(innerNameIndex).getBytes();
         } else {
-            inner_name = "(anonymous)";
+            innerName = "(anonymous)";
         }
         String access = Utility.accessToString(innerAccessFlags, true);
-        access = access.isEmpty() ? "" : (access + " ");
-        return "  " + access + inner_name + "=class " + inner_class_name + outer_class_name;
-    }
-
-
-    /**
-     * @return deep copy of this object
-     */
-    public InnerClass copy() {
-        try {
-            return (InnerClass) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
+        access = access.isEmpty() ? "" : access + " ";
+        return "  " + access + innerName + "=class " + innerClassName + outerClassName;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java
index 567972f0242..2295ca5c625 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java
@@ -24,93 +24,107 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.stream.Stream;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and denotes that this class
- * is an Inner class of another.
- * to the source file of this class.
- * It is instantiated from the <em>Attribute.readAttribute()</em> method.
+ * This class is derived from <em>Attribute</em> and denotes that this class is an Inner class of another. to the source
+ * file of this class. It is instantiated from the <em>Attribute.readAttribute()</em> method.
  *
- * @see     Attribute
+ * @see Attribute
  */
-public final class InnerClasses extends Attribute {
-
-    private InnerClass[] innerClasses;
-
+public final class InnerClasses extends Attribute implements Iterable<InnerClass> {
 
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * Empty array.
      */
-    public InnerClasses(final InnerClasses c) {
-        this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c.getConstantPool());
-    }
+    private static final InnerClass[] EMPTY_INNER_CLASSE_ARRAY = {};
 
+    private InnerClass[] innerClasses;
 
     /**
-     * @param name_index Index in constant pool to CONSTANT_Utf8
-     * @param length Content length in bytes
-     * @param innerClasses array of inner classes attributes
-     * @param constant_pool Array of constants
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
-    public InnerClasses(final int name_index, final int length, final InnerClass[] innerClasses,
-            final ConstantPool constant_pool) {
-        super(Const.ATTR_INNER_CLASSES, name_index, length, constant_pool);
-        this.innerClasses = innerClasses != null ? innerClasses : new InnerClass[0];
+    public InnerClasses(final InnerClasses c) {
+        this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c.getConstantPool());
     }
 
-
     /**
      * Construct object from input stream.
      *
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    InnerClasses(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, (InnerClass[]) null, constant_pool);
-        final int number_of_classes = input.readUnsignedShort();
-        innerClasses = new InnerClass[number_of_classes];
-        for (int i = 0; i < number_of_classes; i++) {
+    InnerClasses(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (InnerClass[]) null, constantPool);
+        final int classCount = input.readUnsignedShort();
+        innerClasses = new InnerClass[classCount];
+        for (int i = 0; i < classCount; i++) {
             innerClasses[i] = new InnerClass(input);
         }
     }
 
+    /**
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
+     * @param length Content length in bytes
+     * @param innerClasses array of inner classes attributes
+     * @param constantPool Array of constants
+     */
+    public InnerClasses(final int nameIndex, final int length, final InnerClass[] innerClasses, final ConstantPool constantPool) {
+        super(Const.ATTR_INNER_CLASSES, nameIndex, length, constantPool);
+        this.innerClasses = innerClasses != null ? innerClasses : EMPTY_INNER_CLASSE_ARRAY;
+        Args.requireU2(this.innerClasses.length, "innerClasses.length");
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitInnerClasses(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        // TODO this could be recoded to use a lower level constructor after creating a copy of the inner classes
+        final InnerClasses c = (InnerClasses) clone();
+        c.innerClasses = new InnerClass[innerClasses.length];
+        Arrays.setAll(c.innerClasses, i -> innerClasses[i].copy());
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump source file attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(innerClasses.length);
-        for (final InnerClass inner_class : innerClasses) {
-            inner_class.dump(file);
+        for (final InnerClass innerClass : innerClasses) {
+            innerClass.dump(file);
         }
     }
 
-
     /**
      * @return array of inner class "records"
      */
@@ -118,15 +132,18 @@ public InnerClass[] getInnerClasses() {
         return innerClasses;
     }
 
+    @Override
+    public Iterator<InnerClass> iterator() {
+        return Stream.of(innerClasses).iterator();
+    }
 
     /**
      * @param innerClasses the array of inner classes
      */
-    public void setInnerClasses( final InnerClass[] innerClasses ) {
-        this.innerClasses = innerClasses != null ? innerClasses : new InnerClass[0];
+    public void setInnerClasses(final InnerClass[] innerClasses) {
+        this.innerClasses = innerClasses != null ? innerClasses : EMPTY_INNER_CLASSE_ARRAY;
     }
 
-
     /**
      * @return String representation.
      */
@@ -136,25 +153,9 @@ public String toString() {
         buf.append("InnerClasses(");
         buf.append(innerClasses.length);
         buf.append("):\n");
-        for (final InnerClass inner_class : innerClasses) {
-            buf.append(inner_class.toString(super.getConstantPool())).append("\n");
+        for (final InnerClass innerClass : innerClasses) {
+            buf.append(innerClass.toString(super.getConstantPool())).append("\n");
         }
-        return buf.substring(0, buf.length()-1); // remove the last newline
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        // TODO this could be recoded to use a lower level constructor after creating a copy of the inner classes
-        final InnerClasses c = (InnerClasses) clone();
-        c.innerClasses = new InnerClass[innerClasses.length];
-        for (int i = 0; i < innerClasses.length; i++) {
-            c.innerClasses[i] = innerClasses[i].copy();
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
+        return buf.substring(0, buf.length() - 1); // remove the last newline
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java
index 052059fba0b..d6c4cfa6a07 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,10 +26,11 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Objects;
-import java.util.StringTokenizer;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
+import java.util.StringTokenizer;
 import java.util.TreeSet;
 
 import com.sun.org.apache.bcel.internal.Const;
@@ -39,20 +40,74 @@
 import com.sun.org.apache.bcel.internal.util.SyntheticRepository;
 
 /**
- * Represents a Java class, i.e., the data structures, constant pool,
- * fields, methods and commands contained in a Java .class file.
- * See <a href="https://docs.oracle.com/javase/specs/">JVM specification</a> for details.
- * The intent of this class is to represent a parsed or otherwise existing
- * class file.  Those interested in programatically generating classes
- * should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
-
+ * Represents a Java class, i.e., the data structures, constant pool, fields, methods and commands contained in a Java
+ * .class file. See <a href="https://docs.oracle.com/javase/specs/">JVM specification</a> for details. The intent of
+ * this class is to represent a parsed or otherwise existing class file. Those interested in programmatically generating
+ * classes should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
+ *
  * @see com.sun.org.apache.bcel.internal.generic.ClassGen
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable<JavaClass> {
 
+    /**
+     * The standard class file extension.
+     *
+     * @since 6.7.0
+     */
+    public static final String EXTENSION = ".class";
+
+    /**
+     * Empty array.
+     *
+     * @since 6.6.0
+     */
+    public static final JavaClass[] EMPTY_ARRAY = {};
+
+    public static final byte HEAP = 1;
+    public static final byte FILE = 2;
+    public static final byte ZIP = 3;
+    private static BCELComparator bcelComparator = new BCELComparator() {
+
+        @Override
+        public boolean equals(final Object o1, final Object o2) {
+            final JavaClass THIS = (JavaClass) o1;
+            final JavaClass THAT = (JavaClass) o2;
+            return Objects.equals(THIS.getClassName(), THAT.getClassName());
+        }
+
+        @Override
+        public int hashCode(final Object o) {
+            final JavaClass THIS = (JavaClass) o;
+            return THIS.getClassName().hashCode();
+        }
+    };
+
+    /**
+     * @return Comparison strategy object
+     */
+    public static BCELComparator getComparator() {
+        return bcelComparator;
+    }
+
+    private static String indent(final Object obj) {
+        final StringTokenizer tokenizer = new StringTokenizer(obj.toString(), "\n");
+        final StringBuilder buf = new StringBuilder();
+        while (tokenizer.hasMoreTokens()) {
+            buf.append("\t").append(tokenizer.nextToken()).append("\n");
+        }
+        return buf.toString();
+    }
+
+    /**
+     * @param comparator Comparison strategy object
+     */
+    public static void setComparator(final BCELComparator comparator) {
+        bcelComparator = comparator;
+    }
+
     private String fileName;
-    private String packageName;
+    private final String packageName;
     private String sourceFileName = "<Unknown>";
     private int classNameIndex;
     private int superclassNameIndex;
@@ -66,52 +121,52 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
     private Field[] fields; // Fields, i.e., variables of class
     private Method[] methods; // methods defined in the class
     private Attribute[] attributes; // attributes defined in the class
-    private AnnotationEntry[] annotations;   // annotations defined on the class
+
+    private AnnotationEntry[] annotations; // annotations defined on the class
     private byte source = HEAP; // Generated in memory
-    private boolean isAnonymous = false;
-    private boolean isNested = false;
-    private boolean computedNestedTypeStatus = false;
-    public static final byte HEAP = 1;
-    public static final byte FILE = 2;
-    public static final byte ZIP = 3;
-    private static final boolean debug = false;
 
-    private static BCELComparator bcelComparator = new BCELComparator() {
+    private boolean isAnonymous;
 
-        @Override
-        public boolean equals( final Object o1, final Object o2 ) {
-            final JavaClass THIS = (JavaClass) o1;
-            final JavaClass THAT = (JavaClass) o2;
-            return Objects.equals(THIS.getClassName(), THAT.getClassName());
-        }
+    private boolean isNested;
 
+    private boolean computedNestedTypeStatus;
 
-        @Override
-        public int hashCode( final Object o ) {
-            final JavaClass THIS = (JavaClass) o;
-            return THIS.getClassName().hashCode();
-        }
-    };
     /**
-     * In cases where we go ahead and create something,
-     * use the default SyntheticRepository, because we
-     * don't know any better.
+     * In cases where we go ahead and create something, use the default SyntheticRepository, because we don't know any
+     * better.
      */
-    private transient com.sun.org.apache.bcel.internal.util.Repository repository
-            = SyntheticRepository.getInstance();
+    private transient com.sun.org.apache.bcel.internal.util.Repository repository = SyntheticRepository.getInstance();
 
+    /**
+     * Constructor gets all contents as arguments.
+     *
+     * @param classNameIndex Class name
+     * @param superclassNameIndex Superclass name
+     * @param fileName File name
+     * @param major Major compiler version
+     * @param minor Minor compiler version
+     * @param accessFlags Access rights defined by bit flags
+     * @param constantPool Array of constants
+     * @param interfaces Implemented interfaces
+     * @param fields Class fields
+     * @param methods Class methods
+     * @param attributes Class attributes
+     */
+    public JavaClass(final int classNameIndex, final int superclassNameIndex, final String fileName, final int major, final int minor, final int accessFlags,
+        final ConstantPool constantPool, final int[] interfaces, final Field[] fields, final Method[] methods, final Attribute[] attributes) {
+        this(classNameIndex, superclassNameIndex, fileName, major, minor, accessFlags, constantPool, interfaces, fields, methods, attributes, HEAP);
+    }
 
     /**
      * Constructor gets all contents as arguments.
      *
-     * @param classNameIndex Index into constant pool referencing a
-     * ConstantClass that represents this class.
-     * @param superclassNameIndex Index into constant pool referencing a
-     * ConstantClass that represents this class's superclass.
+     * @param classNameIndex Index into constant pool referencing a ConstantClass that represents this class.
+     * @param superclassNameIndex Index into constant pool referencing a ConstantClass that represents this class's
+     *        superclass.
      * @param fileName File name
      * @param major Major compiler version
      * @param minor Minor compiler version
-     * @param access_flags Access rights defined by bit flags
+     * @param accessFlags Access rights defined by bit flags
      * @param constantPool Array of constants
      * @param interfaces Implemented interfaces
      * @param fields Class fields
@@ -119,22 +174,20 @@ public int hashCode( final Object o ) {
      * @param attributes Class attributes
      * @param source Read from file or generated in memory?
      */
-    public JavaClass(final int classNameIndex, final int superclassNameIndex,
-            final String fileName, final int major, final int minor, final int access_flags,
-            final ConstantPool constantPool, int[] interfaces, Field[] fields,
-            Method[] methods, Attribute[] attributes, final byte source) {
-        super(access_flags);
+    public JavaClass(final int classNameIndex, final int superclassNameIndex, final String fileName, final int major, final int minor, final int accessFlags,
+        final ConstantPool constantPool, int[] interfaces, Field[] fields, Method[] methods, Attribute[] attributes, final byte source) {
+        super(accessFlags);
         if (interfaces == null) {
-            interfaces = new int[0];
+            interfaces = Const.EMPTY_INT_ARRAY;
         }
         if (attributes == null) {
-            attributes = new Attribute[0];
+            attributes = Attribute.EMPTY_ARRAY;
         }
         if (fields == null) {
-            fields = new Field[0];
+            fields = Field.EMPTY_FIELD_ARRAY;
         }
         if (methods == null) {
-            methods = new Method[0];
+            methods = Method.EMPTY_METHOD_ARRAY;
         }
         this.classNameIndex = classNameIndex;
         this.superclassNameIndex = superclassNameIndex;
@@ -154,9 +207,9 @@ public JavaClass(final int classNameIndex, final int superclassNameIndex,
                 break;
             }
         }
-        /* According to the specification the following entries must be of type
-         * `ConstantClass' but we check that anyway via the
-         * `ConstPool.getConstant' method.
+        /*
+         * According to the specification the following entries must be of type 'ConstantClass' but we check that anyway via the
+         * 'ConstPool.getConstant' method.
          */
         className = constantPool.getConstantString(classNameIndex, Const.CONSTANT_Class);
         className = Utility.compactClassName(className, false);
@@ -168,8 +221,7 @@ public JavaClass(final int classNameIndex, final int superclassNameIndex,
         }
         if (superclassNameIndex > 0) {
             // May be zero -> class is java.lang.Object
-            superclassName = constantPool.getConstantString(superclassNameIndex,
-                    Const.CONSTANT_Class);
+            superclassName = constantPool.getConstantString(superclassNameIndex, Const.CONSTANT_Class);
             superclassName = Utility.compactClassName(superclassName, false);
         } else {
             superclassName = "java.lang.Object";
@@ -181,125 +233,80 @@ public JavaClass(final int classNameIndex, final int superclassNameIndex,
         }
     }
 
-
     /**
-     * Constructor gets all contents as arguments.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
-     * @param classNameIndex Class name
-     * @param superclassNameIndex Superclass name
-     * @param fileName File name
-     * @param major Major compiler version
-     * @param minor Minor compiler version
-     * @param access_flags Access rights defined by bit flags
-     * @param constantPool Array of constants
-     * @param interfaces Implemented interfaces
-     * @param fields Class fields
-     * @param methods Class methods
-     * @param attributes Class attributes
+     * @param v Visitor object
      */
-    public JavaClass(final int classNameIndex, final int superclassNameIndex,
-            final String fileName, final int major, final int minor, final int access_flags,
-            final ConstantPool constantPool, final int[] interfaces, final Field[] fields,
-            final Method[] methods, final Attribute[] attributes) {
-        this(classNameIndex, superclassNameIndex, fileName, major, minor, access_flags,
-                constantPool, interfaces, fields, methods, attributes, HEAP);
+    @Override
+    public void accept(final Visitor v) {
+        v.visitJavaClass(this);
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Return the natural ordering of two JavaClasses. This ordering is based on the class name
      *
-     * @param v Visitor object
+     * @since 6.0
      */
     @Override
-    public void accept( final Visitor v ) {
-        v.visitJavaClass(this);
+    public int compareTo(final JavaClass obj) {
+        return getClassName().compareTo(obj.getClassName());
     }
 
-
-    /* Print debug information depending on `JavaClass.debug'
-     */
-    static void Debug( final String str ) {
-        if (debug) {
-            System.out.println(str);
+    private void computeNestedTypeStatus() {
+        if (computedNestedTypeStatus) {
+            return;
         }
-    }
-
-
-    /**
-     * Dump class to a file.
-     *
-     * @param file Output file
-     * @throws IOException
-     */
-    public void dump(final File file) throws IOException {
-        final String parent = file.getParent();
-        if (parent != null) {
-            final File dir = new File(parent);
-            if (!dir.mkdirs()) { // either was not created or already existed
-                if (!dir.isDirectory()) {
-                    throw new IOException("Could not create the directory " + dir);
-                }
+        for (final Attribute attribute : this.attributes) {
+            if (attribute instanceof InnerClasses) {
+                ((InnerClasses) attribute).forEach(innerClass ->  {
+                    boolean innerClassAttributeRefersToMe = false;
+                    String innerClassName = constantPool.getConstantString(innerClass.getInnerClassIndex(), Const.CONSTANT_Class);
+                    innerClassName = Utility.compactClassName(innerClassName, false);
+                    if (innerClassName.equals(getClassName())) {
+                        innerClassAttributeRefersToMe = true;
+                    }
+                    if (innerClassAttributeRefersToMe) {
+                        this.isNested = true;
+                        if (innerClass.getInnerNameIndex() == 0) {
+                            this.isAnonymous = true;
+                        }
+                    }
+                });
             }
         }
-        try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(file))) {
-            dump(dos);
-        }
-    }
-
-
-    /**
-     * Dump class to a file named fileName.
-     *
-     * @param _file_name Output file name
-     * @throws IOException
-     */
-    public void dump( final String _file_name ) throws IOException {
-        dump(new File(_file_name));
+        this.computedNestedTypeStatus = true;
     }
 
-
     /**
-     * @return class in binary format
+     * @return deep copy of this class
      */
-    public byte[] getBytes() {
-        final ByteArrayOutputStream s = new ByteArrayOutputStream();
-        final DataOutputStream ds = new DataOutputStream(s);
+    public JavaClass copy() {
         try {
-            dump(ds);
-        } catch (final IOException e) {
-            System.err.println("Error dumping class: " + e.getMessage());
-        } finally {
-            try {
-                ds.close();
-            } catch (final IOException e2) {
-                System.err.println("Error dumping class: " + e2.getMessage());
-            }
+            final JavaClass c = (JavaClass) clone();
+            c.constantPool = constantPool.copy();
+            c.interfaces = interfaces.clone();
+            c.interfaceNames = interfaceNames.clone();
+            c.fields = new Field[fields.length];
+            Arrays.setAll(c.fields, i -> fields[i].copy(c.constantPool));
+            c.methods = new Method[methods.length];
+            Arrays.setAll(c.methods, i -> methods[i].copy(c.constantPool));
+            c.attributes = new Attribute[attributes.length];
+            Arrays.setAll(c.attributes, i -> attributes[i].copy(c.constantPool));
+            return c;
+        } catch (final CloneNotSupportedException e) {
+            return null;
         }
-        return s.toByteArray();
     }
 
-
-    /**
-     * Dump Java class to output stream in binary format.
-     *
-     * @param file Output stream
-     * @throws IOException
-     */
-    public void dump( final OutputStream file ) throws IOException {
-        dump(new DataOutputStream(file));
-    }
-
-
     /**
      * Dump Java class to output stream in binary format.
      *
      * @param file Output stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeInt(Const.JVM_CLASSFILE_MAGIC);
         file.writeShort(minor);
         file.writeShort(major);
@@ -330,12 +337,79 @@ public void dump( final DataOutputStream file ) throws IOException {
         file.flush();
     }
 
+    /**
+     * Dump class to a file.
+     *
+     * @param file Output file
+     * @throws IOException if an I/O error occurs.
+     */
+    public void dump(final File file) throws IOException {
+        final String parent = file.getParent();
+        if (parent != null) {
+            final File dir = new File(parent);
+            if (!dir.mkdirs() && !dir.isDirectory()) {
+                throw new IOException("Could not create the directory " + dir);
+            }
+        }
+        try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(file))) {
+            dump(dos);
+        }
+    }
+
+    /**
+     * Dump Java class to output stream in binary format.
+     *
+     * @param file Output stream
+     * @throws IOException if an I/O error occurs.
+     */
+    public void dump(final OutputStream file) throws IOException {
+        dump(new DataOutputStream(file));
+    }
+
+    /**
+     * Dump class to a file named fileName.
+     *
+     * @param fileName Output file name
+     * @throws IOException if an I/O error occurs.
+     */
+    public void dump(final String fileName) throws IOException {
+        dump(new File(fileName));
+    }
 
     /**
-     * @return Attributes of the class.
+     * Return value as defined by given BCELComparator strategy. By default two JavaClass objects are said to be equal when
+     * their class names are equal.
+     *
+     * @see Object#equals(Object)
      */
-    public Attribute[] getAttributes() {
-        return attributes;
+    @Override
+    public boolean equals(final Object obj) {
+        return bcelComparator.equals(this, obj);
+    }
+
+    /**
+     * Get all interfaces implemented by this JavaClass (transitively).
+     *
+     * @throws ClassNotFoundException if any of the class's superclasses or interfaces can't be found.
+     */
+    public JavaClass[] getAllInterfaces() throws ClassNotFoundException {
+        final ClassQueue queue = new ClassQueue();
+        final Set<JavaClass> allInterfaces = new TreeSet<>();
+        queue.enqueue(this);
+        while (!queue.empty()) {
+            final JavaClass clazz = queue.dequeue();
+            final JavaClass souper = clazz.getSuperClass();
+            final JavaClass[] interfaces = clazz.getInterfaces();
+            if (clazz.isInterface()) {
+                allInterfaces.add(clazz);
+            } else if (souper != null) {
+                queue.enqueue(souper);
+            }
+            for (final JavaClass iface : interfaces) {
+                queue.enqueue(iface);
+            }
+        }
+        return allInterfaces.toArray(JavaClass.EMPTY_ARRAY);
     }
 
     /**
@@ -351,20 +425,31 @@ public AnnotationEntry[] getAnnotationEntries() {
     }
 
     /**
-     * @return Class name.
+     * @return Attributes of the class.
      */
-    public String getClassName() {
-        return className;
+    public Attribute[] getAttributes() {
+        return attributes;
     }
 
-
     /**
-     * @return Package name.
+     * @return class in binary format
      */
-    public String getPackageName() {
-        return packageName;
+    public byte[] getBytes() {
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try (DataOutputStream dos = new DataOutputStream(baos)) {
+            dump(dos);
+        } catch (final IOException e) {
+            e.printStackTrace();
+        }
+        return baos.toByteArray();
     }
 
+    /**
+     * @return Class name.
+     */
+    public String getClassName() {
+        return className;
+    }
 
     /**
      * @return Class name index.
@@ -373,7 +458,6 @@ public int getClassNameIndex() {
         return classNameIndex;
     }
 
-
     /**
      * @return Constant pool.
      */
@@ -381,17 +465,14 @@ public ConstantPool getConstantPool() {
         return constantPool;
     }
 
-
     /**
-     * @return Fields, i.e., variables of the class. Like the JVM spec
-     * mandates for the classfile format, these fields are those specific to
-     * this class, and not those of the superclass or superinterfaces.
+     * @return Fields, i.e., variables of the class. Like the JVM spec mandates for the classfile format, these fields are
+     *         those specific to this class, and not those of the superclass or superinterfaces.
      */
     public Field[] getFields() {
         return fields;
     }
 
-
     /**
      * @return File name of class, aka SourceFile attribute value
      */
@@ -399,6 +480,12 @@ public String getFileName() {
         return fileName;
     }
 
+    /**
+     * @return Indices in constant pool of implemented interfaces.
+     */
+    public int[] getInterfaceIndices() {
+        return interfaces;
+    }
 
     /**
      * @return Names of implemented interfaces.
@@ -407,15 +494,20 @@ public String[] getInterfaceNames() {
         return interfaceNames;
     }
 
-
     /**
-     * @return Indices in constant pool of implemented interfaces.
+     * Get interfaces directly implemented by this JavaClass.
+     *
+     * @throws ClassNotFoundException if any of the class's interfaces can't be found.
      */
-    public int[] getInterfaceIndices() {
-        return interfaces;
+    public JavaClass[] getInterfaces() throws ClassNotFoundException {
+        final String[] interfaces = getInterfaceNames();
+        final JavaClass[] classes = new JavaClass[interfaces.length];
+        for (int i = 0; i < interfaces.length; i++) {
+            classes[i] = repository.loadClass(interfaces[i]);
+        }
+        return classes;
     }
 
-
     /**
      * @return Major number of class file version.
      */
@@ -423,29 +515,24 @@ public int getMajor() {
         return major;
     }
 
-
     /**
-     * @return Methods of the class.
+     * @return A {@link Method} corresponding to java.lang.reflect.Method if any
      */
-    public Method[] getMethods() {
-        return methods;
-    }
-
-
-    /**
-     * @return A {@link Method} corresponding to
-     * java.lang.reflect.Method if any
-     */
-    public Method getMethod( final java.lang.reflect.Method m ) {
+    public Method getMethod(final java.lang.reflect.Method m) {
         for (final Method method : methods) {
-            if (m.getName().equals(method.getName()) && (m.getModifiers() == method.getModifiers())
-                    && Type.getSignature(m).equals(method.getSignature())) {
+            if (m.getName().equals(method.getName()) && m.getModifiers() == method.getModifiers() && Type.getSignature(m).equals(method.getSignature())) {
                 return method;
             }
         }
         return null;
     }
 
+    /**
+     * @return Methods of the class.
+     */
+    public Method[] getMethods() {
+        return methods;
+    }
 
     /**
      * @return Minor number of class file version.
@@ -454,19 +541,78 @@ public int getMinor() {
         return minor;
     }
 
+    /**
+     * @return Package name.
+     */
+    public String getPackageName() {
+        return packageName;
+    }
+
+    /**
+     * Gets the ClassRepository which holds its definition. By default this is the same as
+     * SyntheticRepository.getInstance();
+     */
+    public com.sun.org.apache.bcel.internal.util.Repository getRepository() {
+        return repository;
+    }
+
+    /**
+     * @return returns either HEAP (generated), FILE, or ZIP
+     */
+    public final byte getSource() {
+        return source;
+    }
 
     /**
-     * @return sbsolute path to file where this class was read from
+     * @return file name where this class was read from
      */
     public String getSourceFileName() {
         return sourceFileName;
     }
 
+    /**
+     * Gets the source file path including the package path.
+     *
+     * @return path to original source file of parsed class, relative to original source directory.
+     * @since 6.7.0
+     */
+    public String getSourceFilePath() {
+        final StringBuilder outFileName = new StringBuilder();
+        if (!packageName.isEmpty()) {
+            outFileName.append(Utility.packageToPath(packageName));
+            outFileName.append('/');
+        }
+        outFileName.append(sourceFileName);
+        return outFileName.toString();
+    }
 
     /**
-     * returns the super class name of this class. In the case that this class is
-     * java.lang.Object, it will return itself (java.lang.Object). This is probably incorrect
-     * but isn't fixed at this time to not break existing clients.
+     * @return the superclass for this JavaClass object, or null if this is java.lang.Object
+     * @throws ClassNotFoundException if the superclass can't be found
+     */
+    public JavaClass getSuperClass() throws ClassNotFoundException {
+        if ("java.lang.Object".equals(getClassName())) {
+            return null;
+        }
+        return repository.loadClass(getSuperclassName());
+    }
+
+    /**
+     * @return list of super classes of this class in ascending order, i.e., java.lang.Object is always the last element
+     * @throws ClassNotFoundException if any of the superclasses can't be found
+     */
+    public JavaClass[] getSuperClasses() throws ClassNotFoundException {
+        JavaClass clazz = this;
+        final List<JavaClass> allSuperClasses = new ArrayList<>();
+        for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) {
+            allSuperClasses.add(clazz);
+        }
+        return allSuperClasses.toArray(JavaClass.EMPTY_ARRAY);
+    }
+
+    /**
+     * returns the super class name of this class. In the case that this class is java.lang.Object, it will return itself
+     * (java.lang.Object). This is probably incorrect but isn't fixed at this time to not break existing clients.
      *
      * @return Superclass name.
      */
@@ -474,7 +620,6 @@ public String getSuperclassName() {
         return superclassName;
     }
 
-
     /**
      * @return Class name index.
      */
@@ -482,129 +627,196 @@ public int getSuperclassNameIndex() {
         return superclassNameIndex;
     }
 
+    /**
+     * Return value as defined by given BCELComparator strategy. By default return the hashcode of the class name.
+     *
+     * @see Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return bcelComparator.hashCode(this);
+    }
+
+    /**
+     * @return true, if this class is an implementation of interface inter
+     * @throws ClassNotFoundException if superclasses or superinterfaces of this class can't be found
+     */
+    public boolean implementationOf(final JavaClass inter) throws ClassNotFoundException {
+        if (!inter.isInterface()) {
+            throw new IllegalArgumentException(inter.getClassName() + " is no interface");
+        }
+        if (this.equals(inter)) {
+            return true;
+        }
+        final JavaClass[] superInterfaces = getAllInterfaces();
+        for (final JavaClass superInterface : superInterfaces) {
+            if (superInterface.equals(inter)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Equivalent to runtime "instanceof" operator.
+     *
+     * @return true if this JavaClass is derived from the super class
+     * @throws ClassNotFoundException if superclasses or superinterfaces of this object can't be found
+     */
+    public final boolean instanceOf(final JavaClass superclass) throws ClassNotFoundException {
+        if (this.equals(superclass)) {
+            return true;
+        }
+        for (final JavaClass clazz : getSuperClasses()) {
+            if (clazz.equals(superclass)) {
+                return true;
+            }
+        }
+        if (superclass.isInterface()) {
+            return implementationOf(superclass);
+        }
+        return false;
+    }
+
+    /**
+     * @since 6.0
+     */
+    public final boolean isAnonymous() {
+        computeNestedTypeStatus();
+        return this.isAnonymous;
+    }
+
+    public final boolean isClass() {
+        return (super.getAccessFlags() & Const.ACC_INTERFACE) == 0;
+    }
+
+    /**
+     * @since 6.0
+     */
+    public final boolean isNested() {
+        computeNestedTypeStatus();
+        return this.isNested;
+    }
+
+    public final boolean isSuper() {
+        return (super.getAccessFlags() & Const.ACC_SUPER) != 0;
+    }
+
     /**
      * @param attributes .
      */
-    public void setAttributes( final Attribute[] attributes ) {
+    public void setAttributes(final Attribute[] attributes) {
         this.attributes = attributes;
     }
 
-
     /**
      * @param className .
      */
-    public void setClassName( final String className ) {
+    public void setClassName(final String className) {
         this.className = className;
     }
 
-
     /**
      * @param classNameIndex .
      */
-    public void setClassNameIndex( final int classNameIndex ) {
+    public void setClassNameIndex(final int classNameIndex) {
         this.classNameIndex = classNameIndex;
     }
 
-
     /**
      * @param constantPool .
      */
-    public void setConstantPool( final ConstantPool constantPool ) {
+    public void setConstantPool(final ConstantPool constantPool) {
         this.constantPool = constantPool;
     }
 
-
     /**
      * @param fields .
      */
-    public void setFields( final Field[] fields ) {
+    public void setFields(final Field[] fields) {
         this.fields = fields;
     }
 
-
     /**
      * Set File name of class, aka SourceFile attribute value
      */
-    public void setFileName( final String fileName ) {
+    public void setFileName(final String fileName) {
         this.fileName = fileName;
     }
 
-
     /**
      * @param interfaceNames .
      */
-    public void setInterfaceNames( final String[] interfaceNames ) {
+    public void setInterfaceNames(final String[] interfaceNames) {
         this.interfaceNames = interfaceNames;
     }
 
-
     /**
      * @param interfaces .
      */
-    public void setInterfaces( final int[] interfaces ) {
+    public void setInterfaces(final int[] interfaces) {
         this.interfaces = interfaces;
     }
 
-
     /**
      * @param major .
      */
-    public void setMajor( final int major ) {
+    public void setMajor(final int major) {
         this.major = major;
     }
 
-
     /**
      * @param methods .
      */
-    public void setMethods( final Method[] methods ) {
+    public void setMethods(final Method[] methods) {
         this.methods = methods;
     }
 
-
     /**
      * @param minor .
      */
-    public void setMinor( final int minor ) {
+    public void setMinor(final int minor) {
         this.minor = minor;
     }
 
+    /**
+     * Sets the ClassRepository which loaded the JavaClass. Should be called immediately after parsing is done.
+     */
+    public void setRepository(final com.sun.org.apache.bcel.internal.util.Repository repository) { // TODO make protected?
+        this.repository = repository;
+    }
 
     /**
      * Set absolute path to file this class was read from.
      */
-    public void setSourceFileName( final String sourceFileName ) {
+    public void setSourceFileName(final String sourceFileName) {
         this.sourceFileName = sourceFileName;
     }
 
-
     /**
      * @param superclassName .
      */
-    public void setSuperclassName( final String superclassName ) {
+    public void setSuperclassName(final String superclassName) {
         this.superclassName = superclassName;
     }
 
-
     /**
      * @param superclassNameIndex .
      */
-    public void setSuperclassNameIndex( final int superclassNameIndex ) {
+    public void setSuperclassNameIndex(final int superclassNameIndex) {
         this.superclassNameIndex = superclassNameIndex;
     }
 
-
     /**
      * @return String representing class contents.
      */
     @Override
     public String toString() {
         String access = Utility.accessToString(super.getAccessFlags(), true);
-        access = access.isEmpty() ? "" : (access + " ");
+        access = access.isEmpty() ? "" : access + " ";
         final StringBuilder buf = new StringBuilder(128);
-        buf.append(access).append(Utility.classOrInterface(super.getAccessFlags())).append(" ").append(
-                className).append(" extends ").append(
-                Utility.compactClassName(superclassName, false)).append('\n');
+        buf.append(access).append(Utility.classOrInterface(super.getAccessFlags())).append(" ").append(className).append(" extends ")
+            .append(Utility.compactClassName(superclassName, false)).append('\n');
         final int size = interfaces.length;
         if (size > 0) {
             buf.append("implements\t\t");
@@ -629,7 +841,7 @@ public String toString() {
             }
         }
         final AnnotationEntry[] annotations = getAnnotationEntries();
-        if (annotations!=null && annotations.length>0) {
+        if (annotations != null && annotations.length > 0) {
             buf.append("\nAnnotation(s):\n");
             for (final AnnotationEntry annotation : annotations) {
                 buf.append(indent(annotation));
@@ -649,286 +861,4 @@ public String toString() {
         }
         return buf.toString();
     }
-
-
-    private static String indent( final Object obj ) {
-        final StringTokenizer tok = new StringTokenizer(obj.toString(), "\n");
-        final StringBuilder buf = new StringBuilder();
-        while (tok.hasMoreTokens()) {
-            buf.append("\t").append(tok.nextToken()).append("\n");
-        }
-        return buf.toString();
-    }
-
-
-    /**
-     * @return deep copy of this class
-     */
-    public JavaClass copy() {
-        JavaClass c = null;
-        try {
-            c = (JavaClass) clone();
-            c.constantPool = constantPool.copy();
-            c.interfaces = interfaces.clone();
-            c.interfaceNames = interfaceNames.clone();
-            c.fields = new Field[fields.length];
-            for (int i = 0; i < fields.length; i++) {
-                c.fields[i] = fields[i].copy(c.constantPool);
-            }
-            c.methods = new Method[methods.length];
-            for (int i = 0; i < methods.length; i++) {
-                c.methods[i] = methods[i].copy(c.constantPool);
-            }
-            c.attributes = new Attribute[attributes.length];
-            for (int i = 0; i < attributes.length; i++) {
-                c.attributes[i] = attributes[i].copy(c.constantPool);
-            }
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return c;
-    }
-
-
-    public final boolean isSuper() {
-        return (super.getAccessFlags() & Const.ACC_SUPER) != 0;
-    }
-
-
-    public final boolean isClass() {
-        return (super.getAccessFlags() & Const.ACC_INTERFACE) == 0;
-    }
-
-    /**
-     * @since 6.0
-     */
-    public final boolean isAnonymous() {
-        computeNestedTypeStatus();
-        return this.isAnonymous;
-    }
-
-    /**
-     * @since 6.0
-     */
-    public final boolean isNested() {
-        computeNestedTypeStatus();
-        return this.isNested;
-    }
-
-    private void computeNestedTypeStatus() {
-        if (computedNestedTypeStatus) {
-            return;
-        }
-        for (final Attribute attribute : this.attributes) {
-              if (attribute instanceof InnerClasses) {
-                  final InnerClass[] innerClasses = ((InnerClasses) attribute).getInnerClasses();
-                  for (final InnerClass innerClasse : innerClasses) {
-                      boolean innerClassAttributeRefersToMe = false;
-                      String inner_class_name = constantPool.getConstantString(innerClasse.getInnerClassIndex(),
-                                 Const.CONSTANT_Class);
-                      inner_class_name = Utility.compactClassName(inner_class_name, false);
-                      if (inner_class_name.equals(getClassName())) {
-                          innerClassAttributeRefersToMe = true;
-                      }
-                      if (innerClassAttributeRefersToMe) {
-                          this.isNested = true;
-                          if (innerClasse.getInnerNameIndex() == 0) {
-                              this.isAnonymous = true;
-                          }
-                      }
-                  }
-              }
-        }
-        this.computedNestedTypeStatus = true;
-    }
-
-
-    /** @return returns either HEAP (generated), FILE, or ZIP
-     */
-    public final byte getSource() {
-        return source;
-    }
-
-
-    /********************* New repository functionality *********************/
-    /**
-     * Gets the ClassRepository which holds its definition. By default
-     * this is the same as SyntheticRepository.getInstance();
-     */
-    public com.sun.org.apache.bcel.internal.util.Repository getRepository() {
-        return repository;
-    }
-
-
-    /**
-     * Sets the ClassRepository which loaded the JavaClass.
-     * Should be called immediately after parsing is done.
-     */
-    public void setRepository( final com.sun.org.apache.bcel.internal.util.Repository repository ) { // TODO make protected?
-        this.repository = repository;
-    }
-
-
-    /** Equivalent to runtime "instanceof" operator.
-     *
-     * @return true if this JavaClass is derived from the super class
-     * @throws ClassNotFoundException if superclasses or superinterfaces
-     *   of this object can't be found
-     */
-    public final boolean instanceOf( final JavaClass super_class ) throws ClassNotFoundException {
-        if (this.equals(super_class)) {
-            return true;
-        }
-        final JavaClass[] super_classes = getSuperClasses();
-        for (final JavaClass super_classe : super_classes) {
-            if (super_classe.equals(super_class)) {
-                return true;
-            }
-        }
-        if (super_class.isInterface()) {
-            return implementationOf(super_class);
-        }
-        return false;
-    }
-
-
-    /**
-     * @return true, if this class is an implementation of interface inter
-     * @throws ClassNotFoundException if superclasses or superinterfaces
-     *   of this class can't be found
-     */
-    public boolean implementationOf( final JavaClass inter ) throws ClassNotFoundException {
-        if (!inter.isInterface()) {
-            throw new IllegalArgumentException(inter.getClassName() + " is no interface");
-        }
-        if (this.equals(inter)) {
-            return true;
-        }
-        final JavaClass[] super_interfaces = getAllInterfaces();
-        for (final JavaClass super_interface : super_interfaces) {
-            if (super_interface.equals(inter)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-
-    /**
-     * @return the superclass for this JavaClass object, or null if this
-     * is java.lang.Object
-     * @throws ClassNotFoundException if the superclass can't be found
-     */
-    public JavaClass getSuperClass() throws ClassNotFoundException {
-        if ("java.lang.Object".equals(getClassName())) {
-            return null;
-        }
-        return repository.loadClass(getSuperclassName());
-    }
-
-
-    /**
-     * @return list of super classes of this class in ascending order, i.e.,
-     * java.lang.Object is always the last element
-     * @throws ClassNotFoundException if any of the superclasses can't be found
-     */
-    public JavaClass[] getSuperClasses() throws ClassNotFoundException {
-        JavaClass clazz = this;
-        final List<JavaClass> allSuperClasses = new ArrayList<>();
-        for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) {
-            allSuperClasses.add(clazz);
-        }
-        return allSuperClasses.toArray(new JavaClass[allSuperClasses.size()]);
-    }
-
-
-    /**
-     * Get interfaces directly implemented by this JavaClass.
-     */
-    public JavaClass[] getInterfaces() throws ClassNotFoundException {
-        final String[] _interfaces = getInterfaceNames();
-        final JavaClass[] classes = new JavaClass[_interfaces.length];
-        for (int i = 0; i < _interfaces.length; i++) {
-            classes[i] = repository.loadClass(_interfaces[i]);
-        }
-        return classes;
-    }
-
-
-    /**
-     * Get all interfaces implemented by this JavaClass (transitively).
-     */
-    public JavaClass[] getAllInterfaces() throws ClassNotFoundException {
-        final ClassQueue queue = new ClassQueue();
-        final Set<JavaClass> allInterfaces = new TreeSet<>();
-        queue.enqueue(this);
-        while (!queue.empty()) {
-            final JavaClass clazz = queue.dequeue();
-            final JavaClass souper = clazz.getSuperClass();
-            final JavaClass[] _interfaces = clazz.getInterfaces();
-            if (clazz.isInterface()) {
-                allInterfaces.add(clazz);
-            } else {
-                if (souper != null) {
-                    queue.enqueue(souper);
-                }
-            }
-            for (final JavaClass _interface : _interfaces) {
-                queue.enqueue(_interface);
-            }
-        }
-        return allInterfaces.toArray(new JavaClass[allInterfaces.size()]);
-    }
-
-
-    /**
-     * @return Comparison strategy object
-     */
-    public static BCELComparator getComparator() {
-        return bcelComparator;
-    }
-
-
-    /**
-     * @param comparator Comparison strategy object
-     */
-    public static void setComparator( final BCELComparator comparator ) {
-        bcelComparator = comparator;
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default two JavaClass objects are said to be equal when
-     * their class names are equal.
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals( final Object obj ) {
-        return bcelComparator.equals(this, obj);
-    }
-
-
-    /**
-     * Return the natural ordering of two JavaClasses.
-     * This ordering is based on the class name
-     * @since 6.0
-     */
-    @Override
-    public int compareTo( final JavaClass obj ) {
-        return getClassName().compareTo(obj.getClassName());
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default return the hashcode of the class name.
-     *
-     * @see java.lang.Object#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        return bcelComparator.hashCode(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java
index f90b88f1cce..4380d04bc06 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java
@@ -25,30 +25,23 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import com.sun.org.apache.bcel.internal.util.Args;
+
 /**
- * This class represents a (PC offset, line number) pair, i.e., a line number in
- * the source that corresponds to a relative address in the byte code. This
- * is used for debugging purposes.
+ * This class represents a (PC offset, line number) pair, i.e., a line number in the source that corresponds to a
+ * relative address in the byte code. This is used for debugging purposes.
  *
- * @see     LineNumberTable
+ * @see LineNumberTable
  */
 public final class LineNumber implements Cloneable, Node {
 
+    static final LineNumber[] EMPTY_ARRAY = {};
+
     /** Program Counter (PC) corresponds to line */
-    private short startPc;
+    private int startPc;
 
     /** number in source file */
-    private short lineNumber;
-
-    /**
-     * Initialize from another object.
-     *
-     * @param c the object to copy
-     */
-    public LineNumber(final LineNumber c) {
-        this(c.getStartPC(), c.getLineNumber());
-    }
-
+    private int lineNumber;
 
     /**
      * Construct object from file stream.
@@ -60,29 +53,46 @@ public LineNumber(final LineNumber c) {
         this(file.readUnsignedShort(), file.readUnsignedShort());
     }
 
-
     /**
      * @param startPc Program Counter (PC) corresponds to
      * @param lineNumber line number in source file
      */
     public LineNumber(final int startPc, final int lineNumber) {
-        this.startPc = (short) startPc;
-        this.lineNumber = (short)lineNumber;
+        this.startPc = Args.requireU2(startPc, "startPc");
+        this.lineNumber = Args.requireU2(lineNumber, "lineNumber");
     }
 
+    /**
+     * Initialize from another object.
+     *
+     * @param c the object to copy
+     */
+    public LineNumber(final LineNumber c) {
+        this(c.getStartPC(), c.getLineNumber());
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLineNumber(this);
     }
 
+    /**
+     * @return deep copy of this object
+     */
+    public LineNumber copy() {
+        try {
+            return (LineNumber) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
 
     /**
      * Dump line number/pc pair to file stream in binary format.
@@ -90,62 +100,44 @@ public void accept( final Visitor v ) {
      * @param file Output file stream
      * @throws IOException if an I/O Exception occurs in writeShort
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(startPc);
         file.writeShort(lineNumber);
     }
 
-
     /**
      * @return Corresponding source line
      */
     public int getLineNumber() {
-        return 0xffff & lineNumber;
+        return lineNumber & 0xffff;
     }
 
-
     /**
      * @return PC in code
      */
     public int getStartPC() {
-        return  0xffff & startPc;
+        return startPc & 0xffff;
     }
 
-
     /**
      * @param lineNumber the source line number
      */
-    public void setLineNumber( final int lineNumber ) {
+    public void setLineNumber(final int lineNumber) {
         this.lineNumber = (short) lineNumber;
     }
 
-
     /**
      * @param startPc the pc for this line number
      */
-    public void setStartPC( final int startPc ) {
+    public void setStartPC(final int startPc) {
         this.startPc = (short) startPc;
     }
 
-
     /**
      * @return String representation
      */
     @Override
     public String toString() {
-        return "LineNumber(" + startPc + ", " + lineNumber + ")";
-    }
-
-
-    /**
-     * @return deep copy of this object
-     */
-    public LineNumber copy() {
-        try {
-            return (LineNumber) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
+        return "LineNumber(" + getStartPC() + ", " + getLineNumber() + ")";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java
index 7bad272fff3..6251fc514cc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java
@@ -19,78 +19,96 @@
  */
 package com.sun.org.apache.bcel.internal.classfile;
 
-import com.sun.org.apache.bcel.internal.Const;
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.stream.Stream;
+
+import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 import jdk.xml.internal.SecuritySupport;
 
 /**
- * This class represents a table of line numbers for debugging
- * purposes. This attribute is used by the <em>Code</em> attribute. It
- * contains pairs of PCs and line numbers.
+ * This class represents a table of line numbers for debugging purposes. This attribute is used by the <em>Code</em>
+ * attribute. It contains pairs of PCs and line numbers.
  *
- * @see     Code
+ * @see Code
  * @see LineNumber
  * @LastModified: May 2021
  */
-public final class LineNumberTable extends Attribute {
+public final class LineNumberTable extends Attribute implements Iterable<LineNumber> {
 
     private static final int MAX_LINE_LENGTH = 72;
     private LineNumber[] lineNumberTable; // Table of line/numbers pairs
 
-
-    /*
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+    /**
+     * Construct object from input stream.
+     *
+     * @param nameIndex Index of name
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O Exception occurs in readUnsignedShort
      */
-    public LineNumberTable(final LineNumberTable c) {
-        this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool());
+    LineNumberTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (LineNumber[]) null, constantPool);
+        final int lineNumberTableLength = input.readUnsignedShort();
+        lineNumberTable = new LineNumber[lineNumberTableLength];
+        for (int i = 0; i < lineNumberTableLength; i++) {
+            lineNumberTable[i] = new LineNumber(input);
+        }
     }
 
-
     /*
-     * @param name_index Index of name
+     * @param nameIndex Index of name
+     *
      * @param length Content length in bytes
+     *
      * @param lineNumberTable Table of line/numbers pairs
-     * @param constant_pool Array of constants
+     *
+     * @param constantPool Array of constants
      */
-    public LineNumberTable(final int name_index, final int length, final LineNumber[] line_number_table,
-            final ConstantPool constant_pool) {
-        super(Const.ATTR_LINE_NUMBER_TABLE, name_index, length, constant_pool);
-        this.lineNumberTable = line_number_table;
+    public LineNumberTable(final int nameIndex, final int length, final LineNumber[] lineNumberTable, final ConstantPool constantPool) {
+        super(Const.ATTR_LINE_NUMBER_TABLE, nameIndex, length, constantPool);
+        this.lineNumberTable = lineNumberTable != null ? lineNumberTable : LineNumber.EMPTY_ARRAY;
+        Args.requireU2(this.lineNumberTable.length, "lineNumberTable.length");
     }
 
-    /**
-     * Construct object from input stream.
-     * @param name_index Index of name
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException if an I/O Exception occurs in readUnsignedShort
+    /*
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
      */
-    LineNumberTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, (LineNumber[]) null, constant_pool);
-        final int line_number_table_length = input.readUnsignedShort();
-        lineNumberTable = new LineNumber[line_number_table_length];
-        for (int i = 0; i < line_number_table_length; i++) {
-            lineNumberTable[i] = new LineNumber(input);
-        }
+    public LineNumberTable(final LineNumberTable c) {
+        this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool());
     }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLineNumberTable(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        // TODO could use the lower level constructor and thereby allow
+        // lineNumberTable to be made final
+        final LineNumberTable c = (LineNumberTable) clone();
+        c.lineNumberTable = new LineNumber[lineNumberTable.length];
+        Arrays.setAll(c.lineNumberTable, i -> lineNumberTable[i].copy());
+        c.setConstantPool(constantPool);
+        return c;
+    }
+
     /**
      * Dump line number table attribute to file stream in binary format.
      *
@@ -98,7 +116,7 @@ public void accept( final Visitor v ) {
      * @throws IOException if an I/O Exception occurs in writeShort
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(lineNumberTable.length);
         for (final LineNumber lineNumber : lineNumberTable) {
@@ -113,98 +131,87 @@ public LineNumber[] getLineNumberTable() {
         return lineNumberTable;
     }
 
-    /**
-     * @param lineNumberTable the line number entries for this table
-     */
-    public void setLineNumberTable( final LineNumber[] lineNumberTable ) {
-        this.lineNumberTable = lineNumberTable;
-    }
-
-    /**
-     * @return String representation.
-     */
-    @Override
-    public String toString() {
-        final StringBuilder buf = new StringBuilder();
-        final StringBuilder line = new StringBuilder();
-
-        for (int i = 0; i < lineNumberTable.length; i++) {
-            line.append(lineNumberTable[i].toString());
-            if (i < lineNumberTable.length - 1) {
-                line.append(", ");
-            }
-            if ((line.length() > MAX_LINE_LENGTH) && (i < lineNumberTable.length - 1)) {
-                line.append(SecuritySupport.NEWLINE);
-                buf.append(line);
-                line.setLength(0);
-            }
-        }
-        buf.append(line);
-        return buf.toString();
-    }
-
     /**
      * Map byte code positions to source code lines.
      *
      * @param pos byte code offset
      * @return corresponding line in source code
      */
-    public int getSourceLine( final int pos ) {
+    public int getSourceLine(final int pos) {
         int l = 0;
         int r = lineNumberTable.length - 1;
         if (r < 0) {
             return -1;
         }
-        int min_index = -1;
+        int minIndex = -1;
         int min = -1;
-        /* Do a binary search since the array is ordered.
+        /*
+         * Do a binary search since the array is ordered.
          */
         do {
-            final int i = (l + r) >>> 1;
+            final int i = l + r >>> 1;
             final int j = lineNumberTable[i].getStartPC();
             if (j == pos) {
                 return lineNumberTable[i].getLineNumber();
-            } else if (pos < j) {
+            }
+            if (pos < j) {
                 r = i - 1;
             } else {
                 l = i + 1;
             }
-            /* If exact match can't be found (which is the most common case)
-             * return the line number that corresponds to the greatest index less
-             * than pos.
+            /*
+             * If exact match can't be found (which is the most common case) return the line number that corresponds to the greatest
+             * index less than pos.
              */
             if (j < pos && j > min) {
                 min = j;
-                min_index = i;
+                minIndex = i;
             }
         } while (l <= r);
-        /* It's possible that we did not find any valid entry for the bytecode
-         * offset we were looking for.
+        /*
+         * It's possible that we did not find any valid entry for the bytecode offset we were looking for.
          */
-        if (min_index < 0) {
+        if (minIndex < 0) {
             return -1;
         }
-        return lineNumberTable[min_index].getLineNumber();
+        return lineNumberTable[minIndex].getLineNumber();
+    }
+
+    public int getTableLength() {
+        return lineNumberTable == null ? 0 : lineNumberTable.length;
+    }
+
+    @Override
+    public Iterator<LineNumber> iterator() {
+        return Stream.of(lineNumberTable).iterator();
     }
 
     /**
-     * @return deep copy of this attribute
+     * @param lineNumberTable the line number entries for this table
+     */
+    public void setLineNumberTable(final LineNumber[] lineNumberTable) {
+        this.lineNumberTable = lineNumberTable;
+    }
+
+    /**
+     * @return String representation.
      */
     @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        // TODO could use the lower level constructor and thereby allow
-        // lineNumberTable to be made final
-        final LineNumberTable c = (LineNumberTable) clone();
-        c.lineNumberTable = new LineNumber[lineNumberTable.length];
+    public String toString() {
+        final StringBuilder buf = new StringBuilder();
+        final StringBuilder line = new StringBuilder();
         for (int i = 0; i < lineNumberTable.length; i++) {
-            c.lineNumberTable[i] = lineNumberTable[i].copy();
+            line.append(lineNumberTable[i].toString());
+            if (i < lineNumberTable.length - 1) {
+                line.append(", ");
+            }
+            if (line.length() > MAX_LINE_LENGTH && i < lineNumberTable.length - 1) {
+                line.append(SecuritySupport.NEWLINE);
+                buf.append(line);
+                line.setLength(0);
+            }
         }
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
-
-
-    public int getTableLength() {
-        return lineNumberTable == null ? 0 : lineNumberTable.length;
+        buf.append(line);
+        return buf.toString();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java
index f0605cfebe6..91d99c18288 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,119 +24,129 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class represents a local variable within a method. It contains its
- * scope, name, signature and index on the method's frame.  It is used both
- * to represent an element of the LocalVariableTable as well as an element
- * of the LocalVariableTypeTable.  The nomenclature used here may be a bit confusing;
- * while the two items have the same layout in a class file, a LocalVariableTable
- * attribute contains a descriptor_index, not a signatureIndex.  The
+ * This class represents a local variable within a method. It contains its scope, name, signature and index on the
+ * method's frame. It is used both to represent an element of the LocalVariableTable as well as an element of the
+ * LocalVariableTypeTable. The nomenclature used here may be a bit confusing; while the two items have the same layout
+ * in a class file, a LocalVariableTable attribute contains a descriptor_index, not a signatureIndex. The
  * LocalVariableTypeTable attribute does have a signatureIndex.
+ *
  * @see com.sun.org.apache.bcel.internal.classfile.Utility for more details on the difference.
  *
- * @see     LocalVariableTable
- * @see     LocalVariableTypeTable
- * @LastModified: May 2021
+ * @see LocalVariableTable
+ * @see LocalVariableTypeTable
+ * @LastModified: Feb 2023
  */
 public final class LocalVariable implements Cloneable, Node {
 
-    private int startPc; // Range in which the variable is valid
+    static final LocalVariable[] EMPTY_ARRAY = {};
+
+    /** Range in which the variable is valid. */
+    private int startPc;
+
     private int length;
-    private int nameIndex; // Index in constant pool of variable name
-    // Technically, a decscriptor_index for a local variable table entry
-    // and a signatureIndex for a local variable type table entry.
-    private int signatureIndex; // Index of variable signature
-    private int index; /* Variable is index'th local variable on
-     * this method's frame.
-     */
-    private ConstantPool constantPool;
-    private int origIndex; // never changes; used to match up with LocalVariableTypeTable entries
 
+    /** Index in constant pool of variable name. */
+    private int nameIndex;
 
     /**
-     * Initializes from another LocalVariable. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
-     *
-     * @param localVariable Another LocalVariable.
+     * Technically, a decscriptor_index for a local variable table entry and a signatureIndex for a local variable type table entry. Index of variable signature
      */
-    public LocalVariable(final LocalVariable localVariable) {
-        this(localVariable.getStartPC(), localVariable.getLength(), localVariable.getNameIndex(),
-                localVariable.getSignatureIndex(), localVariable.getIndex(), localVariable.getConstantPool());
-        this.origIndex = localVariable.getOrigIndex();
-    }
+    private int signatureIndex;
+
+    /*
+     * Variable is index'th local variable on this method's frame.
+     */
+    private int index;
+
+    private ConstantPool constantPool;
+
+    /** Never changes; used to match up with LocalVariableTypeTable entries. */
+    private final int origIndex;
 
     /**
      * Constructs object from file stream.
+     *
      * @param file Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    LocalVariable(final DataInput file, final ConstantPool constant_pool) throws IOException {
-        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
-                .readUnsignedShort(), file.readUnsignedShort(), constant_pool);
+    LocalVariable(final DataInput file, final ConstantPool constantPool) throws IOException {
+        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), constantPool);
     }
 
-
     /**
      * @param startPc Range in which the variable
      * @param length ... is valid
      * @param nameIndex Index in constant pool of variable name
      * @param signatureIndex Index of variable's signature
-     * @param index Variable is `index'th local variable on the method's frame
+     * @param index Variable is 'index'th local variable on the method's frame
      * @param constantPool Array of constants
      */
-    public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index,
-            final ConstantPool constantPool) {
-        this.startPc = startPc;
-        this.length = length;
-        this.nameIndex = nameIndex;
-        this.signatureIndex = signatureIndex;
-        this.index = index;
-        this.constantPool = constantPool;
-        this.origIndex = index;
+    public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool) {
+        this(startPc, length, nameIndex, signatureIndex, index, constantPool, index);
     }
 
-
     /**
      * @param startPc Range in which the variable
      * @param length ... is valid
      * @param nameIndex Index in constant pool of variable name
      * @param signatureIndex Index of variable's signature
-     * @param index Variable is `index'th local variable on the method's frame
+     * @param index Variable is 'index'th local variable on the method's frame
      * @param constantPool Array of constants
-     * @param origIndex Variable is `index'th local variable on the method's frame prior to any changes
+     * @param origIndex Variable is 'index'th local variable on the method's frame prior to any changes
      */
-    public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index,
-            final ConstantPool constantPool, final int origIndex) {
-        this.startPc = startPc;
-        this.length = length;
-        this.nameIndex = nameIndex;
-        this.signatureIndex = signatureIndex;
-        this.index = index;
+    public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool,
+        final int origIndex) {
+        this.startPc = Args.requireU2(startPc, "startPc");
+        this.length = Args.requireU2(length, "length");
+        this.nameIndex = Args.requireU2(nameIndex, "nameIndex");
+        this.signatureIndex = Args.requireU2(signatureIndex, "signatureIndex");
+        this.index = Args.requireU2(index, "index");
+        this.origIndex = Args.requireU2(origIndex, "origIndex");
         this.constantPool = constantPool;
-        this.origIndex = origIndex;
     }
 
+    /**
+     * Initializes from another LocalVariable. Note that both objects use the same references (shallow copy). Use copy() for
+     * a physical copy.
+     *
+     * @param localVariable Another LocalVariable.
+     */
+    public LocalVariable(final LocalVariable localVariable) {
+        this(localVariable.getStartPC(), localVariable.getLength(), localVariable.getNameIndex(), localVariable.getSignatureIndex(), localVariable.getIndex(),
+            localVariable.getConstantPool());
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLocalVariable(this);
     }
 
+    /**
+     * @return deep copy of this object
+     */
+    public LocalVariable copy() {
+        try {
+            return (LocalVariable) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
 
     /**
      * Dumps local variable to file stream in binary format.
      *
      * @param dataOutputStream Output file stream
-     * @exception IOException if an I/O error occurs.
+     * @throws IOException if an I/O error occurs.
      * @see java.io.FilterOutputStream#out
      */
     public void dump(final DataOutputStream dataOutputStream) throws IOException {
@@ -154,6 +164,12 @@ public ConstantPool getConstantPool() {
         return constantPool;
     }
 
+    /**
+     * @return index of register where variable is stored
+     */
+    public int getIndex() {
+        return index;
+    }
 
     /**
      * @return Variable is valid within getStartPC() .. getStartPC()+getLength()
@@ -162,17 +178,13 @@ public int getLength() {
         return length;
     }
 
-
     /**
      * @return Variable name.
      */
     public String getName() {
-        ConstantUtf8 c;
-        c = (ConstantUtf8) constantPool.getConstant(nameIndex, Const.CONSTANT_Utf8);
-        return c.getBytes();
+        return constantPool.getConstantUtf8(nameIndex).getBytes();
     }
 
-
     /**
      * @return Index in constant pool of variable name.
      */
@@ -180,17 +192,20 @@ public int getNameIndex() {
         return nameIndex;
     }
 
+    /**
+     * @return index of register where variable was originally stored
+     */
+    public int getOrigIndex() {
+        return origIndex;
+    }
 
     /**
      * @return Signature.
      */
     public String getSignature() {
-        ConstantUtf8 c;
-        c = (ConstantUtf8) constantPool.getConstant(signatureIndex, Const.CONSTANT_Utf8);
-        return c.getBytes();
+        return constantPool.getConstantUtf8(signatureIndex).getBytes();
     }
 
-
     /**
      * @return Index in constant pool of variable signature.
      */
@@ -198,23 +213,6 @@ public int getSignatureIndex() {
         return signatureIndex;
     }
 
-
-    /**
-     * @return index of register where variable is stored
-     */
-    public int getIndex() {
-        return index;
-    }
-
-
-    /**
-     * @return index of register where variable was originally stored
-     */
-    public int getOrigIndex() {
-        return origIndex;
-    }
-
-
     /**
      * @return Start of range where the variable is valid
      */
@@ -222,67 +220,48 @@ public int getStartPC() {
         return startPc;
     }
 
-
-    /*
-     * Helper method shared with LocalVariableTypeTable
-     */
-    String toStringShared( final boolean typeTable ) {
-        final String name = getName();
-        final String signature = Utility.signatureToString(getSignature(), false);
-        final String label = "LocalVariable" + (typeTable ? "Types" : "" );
-        return label + "(startPc = " + startPc + ", length = " + length + ", index = "
-                + index + ":" + signature + " " + name + ")";
-    }
-
-
     /**
      * @param constantPool Constant pool to be used for this object.
      */
-    public void setConstantPool( final ConstantPool constantPool ) {
+    public void setConstantPool(final ConstantPool constantPool) {
         this.constantPool = constantPool;
     }
 
+    /**
+     * @param index the index in the local variable table of this variable
+     */
+    public void setIndex(final int index) { // TODO unused
+        this.index = index;
+    }
 
     /**
      * @param length the length of this local variable
      */
-    public void setLength( final int length ) {
+    public void setLength(final int length) {
         this.length = length;
     }
 
-
     /**
      * @param nameIndex the index into the constant pool for the name of this variable
      */
-    public void setNameIndex( final int nameIndex ) { // TODO unused
+    public void setNameIndex(final int nameIndex) { // TODO unused
         this.nameIndex = nameIndex;
     }
 
-
     /**
      * @param signatureIndex the index into the constant pool for the signature of this variable
      */
-    public void setSignatureIndex( final int signatureIndex ) { // TODO unused
+    public void setSignatureIndex(final int signatureIndex) { // TODO unused
         this.signatureIndex = signatureIndex;
     }
 
-
-    /**
-     * @param index the index in the local variable table of this variable
-     */
-    public void setIndex( final int index ) { // TODO unused
-        this.index = index;
-    }
-
-
     /**
      * @param startPc Specify range where the local variable is valid.
      */
-    public void setStartPC( final int startPc ) { // TODO unused
+    public void setStartPC(final int startPc) { // TODO unused
         this.startPc = startPc;
     }
 
-
     /**
      * @return string representation.
      */
@@ -291,16 +270,13 @@ public String toString() {
         return toStringShared(false);
     }
 
-
-    /**
-     * @return deep copy of this object
+    /*
+     * Helper method shared with LocalVariableTypeTable
      */
-    public LocalVariable copy() {
-        try {
-            return (LocalVariable) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
+    String toStringShared(final boolean typeTable) {
+        final String name = getName();
+        final String signature = Utility.signatureToString(getSignature(), false);
+        final String label = "LocalVariable" + (typeTable ? "Types" : "");
+        return label + "(startPc = " + startPc + ", length = " + length + ", index = " + index + ":" + signature + " " + name + ")";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java
index 12bf71d2467..fd56e14a539 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java
@@ -24,83 +24,95 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.stream.Stream;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class represents colection of local variables in a
- * method. This attribute is contained in the <em>Code</em> attribute.
+ * This class represents colection of local variables in a method. This attribute is contained in the <em>Code</em>
+ * attribute.
  *
- * @see     Code
+ * @see Code
  * @see LocalVariable
  */
-public class LocalVariableTable extends Attribute {
+public class LocalVariableTable extends Attribute implements Iterable<LocalVariable> {
 
     private LocalVariable[] localVariableTable; // variables
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+     * Construct object from input stream.
+     *
+     * @param nameIndex Index in constant pool
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    public LocalVariableTable(final LocalVariableTable c) {
-        this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool());
+    LocalVariableTable(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (LocalVariable[]) null, constantPool);
+        final int localVariableTableLength = input.readUnsignedShort();
+        localVariableTable = new LocalVariable[localVariableTableLength];
+        for (int i = 0; i < localVariableTableLength; i++) {
+            localVariableTable[i] = new LocalVariable(input, constantPool);
+        }
     }
 
-
     /**
-     * @param nameIndex Index in constant pool to `LocalVariableTable'
+     * @param nameIndex Index in constant pool to 'LocalVariableTable'
      * @param length Content length in bytes
      * @param localVariableTable Table of local variables
      * @param constantPool Array of constants
      */
-    public LocalVariableTable(final int nameIndex, final int length, final LocalVariable[] localVariableTable,
-            final ConstantPool constantPool) {
+    public LocalVariableTable(final int nameIndex, final int length, final LocalVariable[] localVariableTable, final ConstantPool constantPool) {
         super(Const.ATTR_LOCAL_VARIABLE_TABLE, nameIndex, length, constantPool);
-        this.localVariableTable = localVariableTable;
+        this.localVariableTable = localVariableTable != null ? localVariableTable : LocalVariable.EMPTY_ARRAY;
+        Args.requireU2(this.localVariableTable.length, "localVariableTable.length");
     }
 
-
     /**
-     * Construct object from input stream.
-     * @param name_index Index in constant pool
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
-    LocalVariableTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, (LocalVariable[]) null, constant_pool);
-        final int local_variable_table_length = input.readUnsignedShort();
-        localVariableTable = new LocalVariable[local_variable_table_length];
-        for (int i = 0; i < local_variable_table_length; i++) {
-            localVariableTable[i] = new LocalVariable(input, constant_pool);
-        }
+    public LocalVariableTable(final LocalVariableTable c) {
+        this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool());
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLocalVariableTable(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final LocalVariableTable c = (LocalVariableTable) clone();
+        c.localVariableTable = new LocalVariable[localVariableTable.length];
+        Arrays.setAll(c.localVariableTable, i -> localVariableTable[i].copy());
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump local variable table attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public final void dump( final DataOutputStream file ) throws IOException {
+    public final void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(localVariableTable.length);
         for (final LocalVariable variable : localVariableTable) {
@@ -108,26 +120,17 @@ public final void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
-    /**
-     * @return Array of local variables of method.
-     */
-    public final LocalVariable[] getLocalVariableTable() {
-        return localVariableTable;
-    }
-
-
     /**
      *
      * @param index the variable slot
      *
      * @return the first LocalVariable that matches the slot or null if not found
      *
-     * @deprecated since 5.2 because multiple variables can share the
-     *             same slot, use getLocalVariable(int index, int pc) instead.
+     * @deprecated since 5.2 because multiple variables can share the same slot, use getLocalVariable(int index, int pc)
+     *             instead.
      */
     @java.lang.Deprecated
-    public final LocalVariable getLocalVariable( final int index ) {
+    public final LocalVariable getLocalVariable(final int index) {
         for (final LocalVariable variable : localVariableTable) {
             if (variable.getIndex() == index) {
                 return variable;
@@ -136,7 +139,6 @@ public final LocalVariable getLocalVariable( final int index ) {
         return null;
     }
 
-
     /**
      *
      * @param index the variable slot
@@ -144,12 +146,12 @@ public final LocalVariable getLocalVariable( final int index ) {
      *
      * @return the LocalVariable that matches or null if not found
      */
-    public final LocalVariable getLocalVariable( final int index, final int pc ) {
+    public final LocalVariable getLocalVariable(final int index, final int pc) {
         for (final LocalVariable variable : localVariableTable) {
             if (variable.getIndex() == index) {
-                final int start_pc = variable.getStartPC();
-                final int end_pc = start_pc + variable.getLength();
-                if ((pc >= start_pc) && (pc <= end_pc)) {
+                final int startPc = variable.getStartPC();
+                final int endPc = startPc + variable.getLength();
+                if (pc >= startPc && pc <= endPc) {
                     return variable;
                 }
             }
@@ -157,11 +159,25 @@ public final LocalVariable getLocalVariable( final int index, final int pc ) {
         return null;
     }
 
+    /**
+     * @return Array of local variables of method.
+     */
+    public final LocalVariable[] getLocalVariableTable() {
+        return localVariableTable;
+    }
+
+    public final int getTableLength() {
+        return localVariableTable == null ? 0 : localVariableTable.length;
+    }
 
-    public final void setLocalVariableTable( final LocalVariable[] local_variable_table ) {
-        this.localVariableTable = local_variable_table;
+    @Override
+    public Iterator<LocalVariable> iterator() {
+        return Stream.of(localVariableTable).iterator();
     }
 
+    public final void setLocalVariableTable(final LocalVariable[] localVariableTable) {
+        this.localVariableTable = localVariableTable;
+    }
 
     /**
      * @return String representation.
@@ -177,24 +193,4 @@ public final String toString() {
         }
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final LocalVariableTable c = (LocalVariableTable) clone();
-        c.localVariableTable = new LocalVariable[localVariableTable.length];
-        for (int i = 0; i < localVariableTable.length; i++) {
-            c.localVariableTable[i] = localVariableTable[i].copy();
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
-
-
-    public final int getTableLength() {
-        return localVariableTable == null ? 0 : localVariableTable.length;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java
index bdd5d7a1bd1..08868a82de8 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTypeTable.java
@@ -23,8 +23,12 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.stream.Stream;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 // The new table is used when generic types are about...
 
@@ -57,35 +61,49 @@
 /**
  * @since 6.0
  */
-public class LocalVariableTypeTable extends Attribute {
+public class LocalVariableTypeTable extends Attribute implements Iterable<LocalVariable> {
 
-    private LocalVariable[] localVariableTypeTable;        // variables
-
-    public LocalVariableTypeTable(final LocalVariableTypeTable c) {
-        this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(), c.getConstantPool());
-    }
-
-    public LocalVariableTypeTable(final int name_index, final int length, final LocalVariable[] local_variable_table, final ConstantPool constant_pool) {
-        super(Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE, name_index, length, constant_pool);
-        this.localVariableTypeTable = local_variable_table;
-    }
+    private LocalVariable[] localVariableTypeTable; // variables
 
     LocalVariableTypeTable(final int nameIdx, final int len, final DataInput input, final ConstantPool cpool) throws IOException {
         this(nameIdx, len, (LocalVariable[]) null, cpool);
 
-        final int local_variable_type_table_length = input.readUnsignedShort();
-        localVariableTypeTable = new LocalVariable[local_variable_type_table_length];
+        final int localVariableTypeTableLength = input.readUnsignedShort();
+        localVariableTypeTable = new LocalVariable[localVariableTypeTableLength];
 
-        for (int i = 0; i < local_variable_type_table_length; i++) {
+        for (int i = 0; i < localVariableTypeTableLength; i++) {
             localVariableTypeTable[i] = new LocalVariable(input, cpool);
         }
     }
 
+    public LocalVariableTypeTable(final int nameIndex, final int length, final LocalVariable[] localVariableTypeTable, final ConstantPool constantPool) {
+        super(Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE, nameIndex, length, constantPool);
+        this.localVariableTypeTable = localVariableTypeTable != null ? localVariableTypeTable : LocalVariable.EMPTY_ARRAY;
+        Args.requireU2(this.localVariableTypeTable.length, "localVariableTypeTable.length");
+    }
+
+    public LocalVariableTypeTable(final LocalVariableTypeTable c) {
+        this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(), c.getConstantPool());
+    }
+
     @Override
     public void accept(final Visitor v) {
         v.visitLocalVariableTypeTable(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final LocalVariableTypeTable c = (LocalVariableTypeTable) clone();
+
+        c.localVariableTypeTable = new LocalVariable[localVariableTypeTable.length];
+        Arrays.setAll(c.localVariableTypeTable, i -> localVariableTypeTable[i].copy());
+        c.setConstantPool(constantPool);
+        return c;
+    }
+
     @Override
     public final void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
@@ -95,10 +113,6 @@ public final void dump(final DataOutputStream file) throws IOException {
         }
     }
 
-    public final LocalVariable[] getLocalVariableTypeTable() {
-        return localVariableTypeTable;
-    }
-
     public final LocalVariable getLocalVariable(final int index) {
         for (final LocalVariable variable : localVariableTypeTable) {
             if (variable.getIndex() == index) {
@@ -109,8 +123,21 @@ public final LocalVariable getLocalVariable(final int index) {
         return null;
     }
 
-    public final void setLocalVariableTable(final LocalVariable[] local_variable_table) {
-        this.localVariableTypeTable = local_variable_table;
+    public final LocalVariable[] getLocalVariableTypeTable() {
+        return localVariableTypeTable;
+    }
+
+    public final int getTableLength() {
+        return localVariableTypeTable == null ? 0 : localVariableTypeTable.length;
+    }
+
+    @Override
+    public Iterator<LocalVariable> iterator() {
+        return Stream.of(localVariableTypeTable).iterator();
+    }
+
+    public final void setLocalVariableTable(final LocalVariable[] localVariableTable) {
+        this.localVariableTypeTable = localVariableTable;
     }
 
     /**
@@ -130,24 +157,4 @@ public final String toString() {
 
         return buf.toString();
     }
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy(final ConstantPool constant_pool) {
-        final LocalVariableTypeTable c = (LocalVariableTypeTable) clone();
-
-        c.localVariableTypeTable = new LocalVariable[localVariableTypeTable.length];
-        for (int i = 0; i < localVariableTypeTable.length; i++) {
-            c.localVariableTypeTable[i] = localVariableTypeTable[i].copy();
-        }
-
-        c.setConstantPool(constant_pool);
-        return c;
-    }
-
-    public final int getTableLength() {
-        return localVariableTypeTable == null ? 0 : localVariableTypeTable.length;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Method.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Method.java
index e1b22937082..ba2623eec08 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Method.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Method.java
@@ -24,93 +24,133 @@
 import java.io.IOException;
 import java.util.Objects;
 
-import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.generic.Type;
 import com.sun.org.apache.bcel.internal.util.BCELComparator;
 
 /**
- * This class represents the method info structure, i.e., the representation
- * for a method in the class. See JVM specification for details.
- * A method has access flags, a name, a signature and a number of attributes.
- *
+ * This class represents the method info structure, i.e., the representation for a method in the class. See JVM
+ * specification for details. A method has access flags, a name, a signature and a number of attributes.
  */
 public final class Method extends FieldOrMethod {
 
+    /**
+     * Empty array constant.
+     *
+     * @since 6.6.0
+     */
+    public static final Method[] EMPTY_ARRAY = {};
+
     private static BCELComparator bcelComparator = new BCELComparator() {
 
         @Override
-        public boolean equals( final Object o1, final Object o2 ) {
+        public boolean equals(final Object o1, final Object o2) {
             final Method THIS = (Method) o1;
             final Method THAT = (Method) o2;
-            return Objects.equals(THIS.getName(), THAT.getName())
-                    && Objects.equals(THIS.getSignature(), THAT.getSignature());
+            return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
         }
 
-
         @Override
-        public int hashCode( final Object o ) {
+        public int hashCode(final Object o) {
             final Method THIS = (Method) o;
             return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
         }
     };
 
-    // annotations defined on the parameters of a method
-    private ParameterAnnotationEntry[] parameterAnnotationEntries;
+    /**
+     * Empty array.
+     */
+    static final Method[] EMPTY_METHOD_ARRAY = {};
 
     /**
-     * Empty constructor, all attributes have to be defined via `setXXX'
-     * methods. Use at your own risk.
+     * @return Comparison strategy object
      */
-    public Method() {
+    public static BCELComparator getComparator() {
+        return bcelComparator;
     }
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
+     * @param comparator Comparison strategy object
      */
-    public Method(final Method c) {
-        super(c);
+    public static void setComparator(final BCELComparator comparator) {
+        bcelComparator = comparator;
     }
 
+    // annotations defined on the parameters of a method
+    private ParameterAnnotationEntry[] parameterAnnotationEntries;
+
+    /**
+     * Empty constructor, all attributes have to be defined via 'setXXX' methods. Use at your own risk.
+     */
+    public Method() {
+    }
 
     /**
      * Construct object from file stream.
+     *
      * @param file Input stream
-     * @throws IOException
-     * @throws ClassFormatException
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
-    Method(final DataInput file, final ConstantPool constant_pool) throws IOException,
-            ClassFormatException {
-        super(file, constant_pool);
+    Method(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException {
+        super(file, constantPool);
     }
 
-
     /**
-     * @param access_flags Access rights of method
-     * @param name_index Points to field name in constant pool
-     * @param signature_index Points to encoded signature
+     * @param accessFlags Access rights of method
+     * @param nameIndex Points to field name in constant pool
+     * @param signatureIndex Points to encoded signature
      * @param attributes Collection of attributes
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public Method(final int access_flags, final int name_index, final int signature_index, final Attribute[] attributes,
-            final ConstantPool constant_pool) {
-        super(access_flags, name_index, signature_index, attributes, constant_pool);
+    public Method(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool) {
+        super(accessFlags, nameIndex, signatureIndex, attributes, constantPool);
     }
 
+    /**
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
+     */
+    public Method(final Method c) {
+        super(c);
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitMethod(this);
     }
 
+    /**
+     * @return deep copy of this method
+     */
+    public Method copy(final ConstantPool constantPool) {
+        return (Method) copy_(constantPool);
+    }
+
+    /**
+     * Return value as defined by given BCELComparator strategy. By default two method objects are said to be equal when
+     * their names and signatures are equal.
+     *
+     * @see Object#equals(Object)
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        return bcelComparator.equals(this, obj);
+    }
+
+    /**
+     * @return array of method argument types
+     */
+    public Type[] getArgumentTypes() {
+        return Type.getArgumentTypes(getSignature());
+    }
 
     /**
      * @return Code attribute of method, if any
@@ -124,10 +164,9 @@ public Code getCode() {
         return null;
     }
 
-
     /**
-     * @return ExceptionTable attribute of method, if any, i.e., list all
-     * exceptions the method may throw not exception handlers!
+     * @return ExceptionTable attribute of method, if any, i.e., list all exceptions the method may throw not exception
+     *         handlers!
      */
     public ExceptionTable getExceptionTable() {
         for (final Attribute attribute : super.getAttributes()) {
@@ -138,34 +177,60 @@ public ExceptionTable getExceptionTable() {
         return null;
     }
 
-
-    /** @return LocalVariableTable of code attribute if any, i.e. the call is forwarded
-     * to the Code atribute.
+    /**
+     * @return LineNumberTable of code attribute if any, i.e. the call is forwarded to the Code atribute.
      */
-    public LocalVariableTable getLocalVariableTable() {
+    public LineNumberTable getLineNumberTable() {
         final Code code = getCode();
         if (code == null) {
             return null;
         }
-        return code.getLocalVariableTable();
+        return code.getLineNumberTable();
     }
 
-
-    /** @return LineNumberTable of code attribute if any, i.e. the call is forwarded
-     * to the Code atribute.
+    /**
+     * @return LocalVariableTable of code attribute if any, i.e. the call is forwarded to the Code atribute.
      */
-    public LineNumberTable getLineNumberTable() {
+    public LocalVariableTable getLocalVariableTable() {
         final Code code = getCode();
         if (code == null) {
             return null;
         }
-        return code.getLineNumberTable();
+        return code.getLocalVariableTable();
     }
 
+    /**
+     * @return Annotations on the parameters of a method
+     * @since 6.0
+     */
+    public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
+        if (parameterAnnotationEntries == null) {
+            parameterAnnotationEntries = ParameterAnnotationEntry.createParameterAnnotationEntries(getAttributes());
+        }
+        return parameterAnnotationEntries;
+    }
 
     /**
-     * Return string representation close to declaration format,
-     * `public static void main(String[] args) throws IOException', e.g.
+     * @return return type of method
+     */
+    public Type getReturnType() {
+        return Type.getReturnType(getSignature());
+    }
+
+    /**
+     * Return value as defined by given BCELComparator strategy. By default return the hashcode of the method's name XOR
+     * signature.
+     *
+     * @see Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return bcelComparator.hashCode(this);
+    }
+
+    /**
+     * Return string representation close to declaration format, 'public static void main(String[] args) throws
+     * IOException', e.g.
      *
      * @return String representation of the method.
      */
@@ -173,15 +238,14 @@ public LineNumberTable getLineNumberTable() {
     public String toString() {
         final String access = Utility.accessToString(super.getAccessFlags());
         // Get name and signature from constant pool
-        ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(super.getSignatureIndex(), Const.CONSTANT_Utf8);
+        ConstantUtf8 c = super.getConstantPool().getConstantUtf8(super.getSignatureIndex());
         String signature = c.getBytes();
-        c = (ConstantUtf8) super.getConstantPool().getConstant(super.getNameIndex(), Const.CONSTANT_Utf8);
+        c = super.getConstantPool().getConstantUtf8(super.getNameIndex());
         final String name = c.getBytes();
-        signature = Utility.methodSignatureToString(signature, name, access, true,
-                getLocalVariableTable());
+        signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable());
         final StringBuilder buf = new StringBuilder(signature);
         for (final Attribute attribute : super.getAttributes()) {
-            if (!((attribute instanceof Code) || (attribute instanceof ExceptionTable))) {
+            if (!(attribute instanceof Code || attribute instanceof ExceptionTable)) {
                 buf.append(" [").append(attribute).append("]");
             }
         }
@@ -194,80 +258,4 @@ public String toString() {
         }
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this method
-     */
-    public Method copy( final ConstantPool _constant_pool ) {
-        return (Method) copy_(_constant_pool);
-    }
-
-
-    /**
-     * @return return type of method
-     */
-    public Type getReturnType() {
-        return Type.getReturnType(getSignature());
-    }
-
-
-    /**
-     * @return array of method argument types
-     */
-    public Type[] getArgumentTypes() {
-        return Type.getArgumentTypes(getSignature());
-    }
-
-
-    /**
-     * @return Comparison strategy object
-     */
-    public static BCELComparator getComparator() {
-        return bcelComparator;
-    }
-
-
-    /**
-     * @param comparator Comparison strategy object
-     */
-    public static void setComparator( final BCELComparator comparator ) {
-        bcelComparator = comparator;
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default two method objects are said to be equal when
-     * their names and signatures are equal.
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals( final Object obj ) {
-        return bcelComparator.equals(this, obj);
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default return the hashcode of the method's name XOR signature.
-     *
-     * @see java.lang.Object#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        return bcelComparator.hashCode(this);
-    }
-
-    /**
-     * @return Annotations on the parameters of a method
-     * @since 6.0
-     */
-    public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
-        if (parameterAnnotationEntries == null) {
-            parameterAnnotationEntries = ParameterAnnotationEntry.createParameterAnnotationEntries(getAttributes());
-        }
-        return parameterAnnotationEntries;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java
index 86155336302..ffc1a20f80a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameter.java
@@ -30,11 +30,11 @@
 /**
  * Entry of the parameters table.
  *
- * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.24">
- * The class File Format : The MethodParameters Attribute</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.24"> The class File Format :
+ *      The MethodParameters Attribute</a>
  * @since 6.0
  */
-public class MethodParameter implements Cloneable {
+public class MethodParameter implements Cloneable, Node {
 
     /** Index of the CONSTANT_Utf8_info structure in the constant_pool table representing the name of the parameter */
     private int nameIndex;
@@ -49,76 +49,77 @@ public MethodParameter() {
      * Construct object from input stream.
      *
      * @param input Input stream
-     * @throws java.io.IOException
-     * @throws ClassFormatException
+     * @throws IOException if an I/O error occurs.
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
     MethodParameter(final DataInput input) throws IOException {
         nameIndex = input.readUnsignedShort();
         accessFlags = input.readUnsignedShort();
     }
 
-    public int getNameIndex() {
-        return nameIndex;
+    @Override
+    public void accept(final Visitor v) {
+        v.visitMethodParameter(this);
     }
 
-    public void setNameIndex(final int name_index) {
-        this.nameIndex = name_index;
+    /**
+     * @return deep copy of this object
+     */
+    public MethodParameter copy() {
+        try {
+            return (MethodParameter) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
     }
 
     /**
-     * Returns the name of the parameter.
+     * Dump object to file stream on binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException if an I/O error occurs.
      */
-    public String getParameterName(final ConstantPool constant_pool) {
-        if (nameIndex == 0) {
-            return null;
-        }
-        return ((ConstantUtf8) constant_pool.getConstant(nameIndex, Const.CONSTANT_Utf8)).getBytes();
-       }
+    public final void dump(final DataOutputStream file) throws IOException {
+        file.writeShort(nameIndex);
+        file.writeShort(accessFlags);
+    }
 
     public int getAccessFlags() {
         return accessFlags;
     }
 
-    public void setAccessFlags(final int access_flags) {
-        this.accessFlags = access_flags;
+    public int getNameIndex() {
+        return nameIndex;
     }
 
-    public boolean isFinal() {
-        return (accessFlags & Const.ACC_FINAL) != 0;
+    /**
+     * Returns the name of the parameter.
+     */
+    public String getParameterName(final ConstantPool constantPool) {
+        if (nameIndex == 0) {
+            return null;
+        }
+        return constantPool.getConstantUtf8(nameIndex).getBytes();
     }
 
-    public boolean isSynthetic() {
-        return (accessFlags & Const.ACC_SYNTHETIC) != 0;
+    public boolean isFinal() {
+        return (accessFlags & Const.ACC_FINAL) != 0;
     }
 
     public boolean isMandated() {
         return (accessFlags & Const.ACC_MANDATED) != 0;
     }
 
-    public void accept(final Visitor v) {
-        v.visitMethodParameter(this);
+    public boolean isSynthetic() {
+        return (accessFlags & Const.ACC_SYNTHETIC) != 0;
     }
 
-    /**
-     * Dump object to file stream on binary format.
-     *
-     * @param file Output file stream
-     * @throws IOException
-     */
-    public final void dump(final DataOutputStream file) throws IOException {
-        file.writeShort(nameIndex);
-        file.writeShort(accessFlags);
+    public void setAccessFlags(final int accessFlags) {
+        this.accessFlags = accessFlags;
     }
 
-    /**
-     * @return deep copy of this object
-     */
-    public MethodParameter copy() {
-        try {
-            return (MethodParameter) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
+    public void setNameIndex(final int nameIndex) {
+        this.nameIndex = nameIndex;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java
index 0ee75fb6355..5b5d1d77f6f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/MethodParameters.java
@@ -24,52 +24,50 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.stream.Stream;
 
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
  * This class represents a MethodParameters attribute.
  *
- * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.24">
- * The class File Format : The MethodParameters Attribute</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.24"> The class File Format :
+ *      The MethodParameters Attribute</a>
  * @since 6.0
  */
-public class MethodParameters extends Attribute {
+public class MethodParameters extends Attribute implements Iterable<MethodParameter> {
 
-    private MethodParameter[] parameters = new MethodParameter[0];
+    /**
+     * Empty array.
+     */
+    private static final MethodParameter[] EMPTY_METHOD_PARAMETER_ARRAY = {};
+
+    private MethodParameter[] parameters = EMPTY_METHOD_PARAMETER_ARRAY;
 
-    MethodParameters(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        super(Const.ATTR_METHOD_PARAMETERS, name_index, length, constant_pool);
+    MethodParameters(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        super(Const.ATTR_METHOD_PARAMETERS, nameIndex, length, constantPool);
 
-        final int parameters_count = input.readUnsignedByte();
-        parameters = new MethodParameter[parameters_count];
-        for (int i = 0; i < parameters_count; i++) {
+        final int parameterCount = input.readUnsignedByte();
+        parameters = new MethodParameter[parameterCount];
+        for (int i = 0; i < parameterCount; i++) {
             parameters[i] = new MethodParameter(input);
         }
     }
 
-    public MethodParameter[] getParameters() {
-        return parameters;
-    }
-
-    public void setParameters(final MethodParameter[] parameters) {
-        this.parameters = parameters;
-    }
-
     @Override
     public void accept(final Visitor v) {
         v.visitMethodParameters(this);
     }
 
     @Override
-    public Attribute copy(final ConstantPool _constant_pool) {
+    public Attribute copy(final ConstantPool constantPool) {
         final MethodParameters c = (MethodParameters) clone();
         c.parameters = new MethodParameter[parameters.length];
 
-        for (int i = 0; i < parameters.length; i++) {
-            c.parameters[i] = parameters[i].copy();
-        }
-        c.setConstantPool(_constant_pool);
+        Arrays.setAll(c.parameters, i -> parameters[i].copy());
+        c.setConstantPool(constantPool);
         return c;
     }
 
@@ -77,14 +75,27 @@ public Attribute copy(final ConstantPool _constant_pool) {
      * Dump method parameters attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-       public void dump(final DataOutputStream file) throws IOException {
-           super.dump(file);
-           file.writeByte(parameters.length);
+    public void dump(final DataOutputStream file) throws IOException {
+        super.dump(file);
+        file.writeByte(parameters.length);
         for (final MethodParameter parameter : parameters) {
             parameter.dump(file);
         }
     }
+
+    public MethodParameter[] getParameters() {
+        return parameters;
+    }
+
+    @Override
+    public Iterator<MethodParameter> iterator() {
+        return Stream.of(parameters).iterator();
+    }
+
+    public void setParameters(final MethodParameter[] parameters) {
+        this.parameters = parameters;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java
index ffb87b1123b..00eebe18245 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Module.java
@@ -24,19 +24,26 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from <em>Attribute</em> and represents the list of
- * modules required, exported, opened or provided by a module.
- * There may be at most one Module attribute in a ClassFile structure.
+ * This class is derived from <em>Attribute</em> and represents the list of modules required, exported, opened or
+ * provided by a module. There may be at most one Module attribute in a ClassFile structure.
  *
- * @see   Attribute
+ * @see Attribute
  * @since 6.4.0
  */
 public final class Module extends Attribute {
 
+    /**
+     * The module file name extension.
+     *
+     * @since 6.7.0
+     */
+    public static final String EXTENSION = ".jmod";
+
     private final int moduleNameIndex;
     private final int moduleFlags;
     private final int moduleVersionIndex;
@@ -50,34 +57,35 @@ public final class Module extends Attribute {
 
     /**
      * Construct object from input stream.
-     * @param name_index Index in constant pool
+     *
+     * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    Module(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        super(Const.ATTR_MODULE, name_index, length, constant_pool);
+    Module(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        super(Const.ATTR_MODULE, nameIndex, length, constantPool);
 
         moduleNameIndex = input.readUnsignedShort();
         moduleFlags = input.readUnsignedShort();
         moduleVersionIndex = input.readUnsignedShort();
 
-        final int requires_count = input.readUnsignedShort();
-        requiresTable = new ModuleRequires[requires_count];
-        for (int i = 0; i < requires_count; i++) {
+        final int requiresCount = input.readUnsignedShort();
+        requiresTable = new ModuleRequires[requiresCount];
+        for (int i = 0; i < requiresCount; i++) {
             requiresTable[i] = new ModuleRequires(input);
         }
 
-        final int exports_count = input.readUnsignedShort();
-        exportsTable = new ModuleExports[exports_count];
-        for (int i = 0; i < exports_count; i++) {
+        final int exportsCount = input.readUnsignedShort();
+        exportsTable = new ModuleExports[exportsCount];
+        for (int i = 0; i < exportsCount; i++) {
             exportsTable[i] = new ModuleExports(input);
         }
 
-        final int opens_count = input.readUnsignedShort();
-        opensTable = new ModuleOpens[opens_count];
-        for (int i = 0; i < opens_count; i++) {
+        final int opensCount = input.readUnsignedShort();
+        opensTable = new ModuleOpens[opensCount];
+        for (int i = 0; i < opensCount; i++) {
             opensTable[i] = new ModuleOpens(input);
         }
 
@@ -87,72 +95,57 @@ public final class Module extends Attribute {
             usesIndex[i] = input.readUnsignedShort();
         }
 
-        final int provides_count = input.readUnsignedShort();
-        providesTable = new ModuleProvides[provides_count];
-        for (int i = 0; i < provides_count; i++) {
+        final int providesCount = input.readUnsignedShort();
+        providesTable = new ModuleProvides[providesCount];
+        for (int i = 0; i < providesCount; i++) {
             providesTable[i] = new ModuleProvides(input);
         }
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitModule(this);
     }
 
     // TODO add more getters and setters?
 
     /**
-     * @return table of required modules
-     * @see ModuleRequires
+     * @return deep copy of this attribute
      */
-    public ModuleRequires[] getRequiresTable() {
-        return requiresTable;
-    }
-
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final Module c = (Module) clone();
 
-    /**
-     * @return table of exported interfaces
-     * @see ModuleExports
-     */
-    public ModuleExports[] getExportsTable() {
-        return exportsTable;
-    }
+        c.requiresTable = new ModuleRequires[requiresTable.length];
+        Arrays.setAll(c.requiresTable, i -> requiresTable[i].copy());
 
+        c.exportsTable = new ModuleExports[exportsTable.length];
+        Arrays.setAll(c.exportsTable, i -> exportsTable[i].copy());
 
-    /**
-     * @return table of provided interfaces
-     * @see ModuleOpens
-     */
-    public ModuleOpens[] getOpensTable() {
-        return opensTable;
-    }
+        c.opensTable = new ModuleOpens[opensTable.length];
+        Arrays.setAll(c.opensTable, i -> opensTable[i].copy());
 
+        c.providesTable = new ModuleProvides[providesTable.length];
+        Arrays.setAll(c.providesTable, i -> providesTable[i].copy());
 
-    /**
-     * @return table of provided interfaces
-     * @see ModuleProvides
-     */
-    public ModuleProvides[] getProvidesTable() {
-        return providesTable;
+        c.setConstantPool(constantPool);
+        return c;
     }
 
-
     /**
      * Dump Module attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
 
         file.writeShort(moduleNameIndex);
@@ -185,6 +178,37 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
+    /**
+     * @return table of exported interfaces
+     * @see ModuleExports
+     */
+    public ModuleExports[] getExportsTable() {
+        return exportsTable;
+    }
+
+    /**
+     * @return table of provided interfaces
+     * @see ModuleOpens
+     */
+    public ModuleOpens[] getOpensTable() {
+        return opensTable;
+    }
+
+    /**
+     * @return table of provided interfaces
+     * @see ModuleProvides
+     */
+    public ModuleProvides[] getProvidesTable() {
+        return providesTable;
+    }
+
+    /**
+     * @return table of required modules
+     * @see ModuleRequires
+     */
+    public ModuleRequires[] getRequiresTable() {
+        return requiresTable;
+    }
 
     /**
      * @return String representation, i.e., a list of packages.
@@ -194,10 +218,10 @@ public String toString() {
         final ConstantPool cp = super.getConstantPool();
         final StringBuilder buf = new StringBuilder();
         buf.append("Module:\n");
-        buf.append("  name:    ") .append(cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module).replace('/', '.')).append("\n");
-        buf.append("  flags:   ") .append(String.format("%04x", moduleFlags)).append("\n");
+        buf.append("  name:    ").append(Utility.pathToPackage(cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module))).append("\n");
+        buf.append("  flags:   ").append(String.format("%04x", moduleFlags)).append("\n");
         final String version = moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8);
-        buf.append("  version: ") .append(version).append("\n");
+        buf.append("  version: ").append(version).append("\n");
 
         buf.append("  requires(").append(requiresTable.length).append("):\n");
         for (final ModuleRequires module : requiresTable) {
@@ -216,8 +240,8 @@ public String toString() {
 
         buf.append("  uses(").append(usesIndex.length).append("):\n");
         for (final int index : usesIndex) {
-            final String class_name = cp.getConstantString(index, Const.CONSTANT_Class);
-            buf.append("    ").append(Utility.compactClassName(class_name, false)).append("\n");
+            final String className = cp.getConstantString(index, Const.CONSTANT_Class);
+            buf.append("    ").append(Utility.compactClassName(className, false)).append("\n");
         }
 
         buf.append("  provides(").append(providesTable.length).append("):\n");
@@ -225,38 +249,6 @@ public String toString() {
             buf.append("    ").append(module.toString(cp)).append("\n");
         }
 
-        return buf.substring(0, buf.length()-1); // remove the last newline
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final Module c = (Module) clone();
-
-        c.requiresTable = new ModuleRequires[requiresTable.length];
-        for (int i = 0; i < requiresTable.length; i++) {
-            c.requiresTable[i] = requiresTable[i].copy();
-        }
-
-        c.exportsTable = new ModuleExports[exportsTable.length];
-        for (int i = 0; i < exportsTable.length; i++) {
-            c.exportsTable[i] = exportsTable[i].copy();
-        }
-
-        c.opensTable = new ModuleOpens[opensTable.length];
-        for (int i = 0; i < opensTable.length; i++) {
-            c.opensTable[i] = opensTable[i].copy();
-        }
-
-        c.providesTable = new ModuleProvides[providesTable.length];
-        for (int i = 0; i < providesTable.length; i++) {
-            c.providesTable[i] = providesTable[i].copy();
-        }
-
-        c.setConstantPool(_constant_pool);
-        return c;
+        return buf.substring(0, buf.length() - 1); // remove the last newline
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java
index ec581c8baf1..8a97f4b6d08 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleExports.java
@@ -28,19 +28,18 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents an entry in the exports table of the Module attribute.
- * Each entry describes a package which may open the parent module.
+ * This class represents an entry in the exports table of the Module attribute. Each entry describes a package which may
+ * open the parent module.
  *
- * @see   Module
+ * @see Module
  * @since 6.4.0
  */
 public final class ModuleExports implements Cloneable, Node {
 
-    private final int exportsIndex;  // points to CONSTANT_Package_info
+    private final int exportsIndex; // points to CONSTANT_Package_info
     private final int exportsFlags;
     private final int exportsToCount;
-    private final int[] exportsToIndex;  // points to CONSTANT_Module_info
-
+    private final int[] exportsToIndex; // points to CONSTANT_Module_info
 
     /**
      * Construct object from file stream.
@@ -58,28 +57,38 @@ public final class ModuleExports implements Cloneable, Node {
         }
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitModuleExports(this);
     }
 
     // TODO add more getters and setters?
 
+    /**
+     * @return deep copy of this object
+     */
+    public ModuleExports copy() {
+        try {
+            return (ModuleExports) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
+
     /**
      * Dump table entry to file stream in binary format.
      *
      * @param file Output file stream
      * @throws IOException if an I/O Exception occurs in writeShort
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(exportsIndex);
         file.writeShort(exportsFlags);
         file.writeShort(exportsToCount);
@@ -88,7 +97,6 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
     /**
      * @return String representation
      */
@@ -97,33 +105,19 @@ public String toString() {
         return "exports(" + exportsIndex + ", " + exportsFlags + ", " + exportsToCount + ", ...)";
     }
 
-
     /**
      * @return Resolved string representation
      */
-    public String toString( final ConstantPool constant_pool ) {
+    public String toString(final ConstantPool constantPool) {
         final StringBuilder buf = new StringBuilder();
-        final String package_name = constant_pool.constantToString(exportsIndex, Const.CONSTANT_Package);
-        buf.append(Utility.compactClassName(package_name, false));
+        final String packageName = constantPool.constantToString(exportsIndex, Const.CONSTANT_Package);
+        buf.append(Utility.compactClassName(packageName, false));
         buf.append(", ").append(String.format("%04x", exportsFlags));
         buf.append(", to(").append(exportsToCount).append("):\n");
         for (final int index : exportsToIndex) {
-            final String module_name = constant_pool.getConstantString(index, Const.CONSTANT_Module);
-            buf.append("      ").append(Utility.compactClassName(module_name, false)).append("\n");
-        }
-        return buf.substring(0, buf.length()-1); // remove the last newline
-    }
-
-
-    /**
-     * @return deep copy of this object
-     */
-    public ModuleExports copy() {
-        try {
-            return (ModuleExports) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
+            final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module);
+            buf.append("      ").append(Utility.compactClassName(moduleName, false)).append("\n");
         }
-        return null;
+        return buf.substring(0, buf.length() - 1); // remove the last newline
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java
index 7b6d89ed69a..a6ffd882862 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleMainClass.java
@@ -26,66 +26,73 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and indicates the main class of a module.
- * There may be at most one ModuleMainClass attribute in a ClassFile structure.
+ * This class is derived from <em>Attribute</em> and indicates the main class of a module. There may be at most one
+ * ModuleMainClass attribute in a ClassFile structure.
  *
- * @see     Attribute
+ * @see Attribute
  */
 public final class ModuleMainClass extends Attribute {
 
     private int mainClassIndex;
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+     * Construct object from input stream.
+     *
+     * @param nameIndex Index in constant pool
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    public ModuleMainClass(final ModuleMainClass c) {
-        this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool());
+    ModuleMainClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, 0, constantPool);
+        mainClassIndex = input.readUnsignedShort();
     }
 
-
     /**
-     * @param name_index Index in constant pool
+     * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param mainClassIndex Host class index
      * @param constantPool Array of constants
      */
-    public ModuleMainClass(final int name_index, final int length, final int mainClassIndex,
-            final ConstantPool constantPool) {
-        super(Const.ATTR_NEST_MEMBERS, name_index, length, constantPool);
-        this.mainClassIndex = mainClassIndex;
+    public ModuleMainClass(final int nameIndex, final int length, final int mainClassIndex, final ConstantPool constantPool) {
+        super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool);
+        this.mainClassIndex = Args.requireU2(mainClassIndex, "mainClassIndex");
     }
 
-
     /**
-     * Construct object from input stream.
-     * @param nameIndex Index in constant pool
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constantPool Array of constants
-     * @throws IOException
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
-    ModuleMainClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
-        this(nameIndex, length, 0, constantPool);
-        mainClassIndex = input.readUnsignedShort();
+    public ModuleMainClass(final ModuleMainClass c) {
+        this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool());
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitly
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e.,
+     * the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitModuleMainClass(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final ModuleMainClass c = (ModuleMainClass) clone();
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump ModuleMainClass attribute to file stream in binary format.
@@ -94,12 +101,11 @@ public void accept( final Visitor v ) {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(mainClassIndex);
     }
 
-
     /**
      * @return index into constant pool of host class name.
      */
@@ -107,15 +113,13 @@ public int getHostClassIndex() {
         return mainClassIndex;
     }
 
-
     /**
      * @param mainClassIndex the host class index
      */
-    public void setHostClassIndex( final int mainClassIndex ) {
+    public void setHostClassIndex(final int mainClassIndex) {
         this.mainClassIndex = mainClassIndex;
     }
 
-
     /**
      * @return String representation
      */
@@ -123,19 +127,8 @@ public void setHostClassIndex( final int mainClassIndex ) {
     public String toString() {
         final StringBuilder buf = new StringBuilder();
         buf.append("ModuleMainClass: ");
-        final String class_name = super.getConstantPool().getConstantString(mainClassIndex, Const.CONSTANT_Class);
-        buf.append(Utility.compactClassName(class_name, false));
+        final String className = super.getConstantPool().getConstantString(mainClassIndex, Const.CONSTANT_Class);
+        buf.append(Utility.compactClassName(className, false));
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final ModuleMainClass c = (ModuleMainClass) clone();
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java
index 341228ea3a3..06b404df72b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleOpens.java
@@ -28,19 +28,18 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents an entry in the opens table of the Module attribute.
- * Each entry describes a package which the parent module opens.
+ * This class represents an entry in the opens table of the Module attribute. Each entry describes a package which the
+ * parent module opens.
  *
- * @see   Module
+ * @see Module
  * @since 6.4.0
  */
 public final class ModuleOpens implements Cloneable, Node {
 
-    private final int opensIndex;  // points to CONSTANT_Package_info
+    private final int opensIndex; // points to CONSTANT_Package_info
     private final int opensFlags;
     private final int opensToCount;
-    private final int[] opensToIndex;  // points to CONSTANT_Module_info
-
+    private final int[] opensToIndex; // points to CONSTANT_Module_info
 
     /**
      * Construct object from file stream.
@@ -58,28 +57,38 @@ public final class ModuleOpens implements Cloneable, Node {
         }
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitModuleOpens(this);
     }
 
     // TODO add more getters and setters?
 
+    /**
+     * @return deep copy of this object
+     */
+    public ModuleOpens copy() {
+        try {
+            return (ModuleOpens) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
+
     /**
      * Dump table entry to file stream in binary format.
      *
      * @param file Output file stream
      * @throws IOException if an I/O Exception occurs in writeShort
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(opensIndex);
         file.writeShort(opensFlags);
         file.writeShort(opensToCount);
@@ -88,7 +97,6 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
     /**
      * @return String representation
      */
@@ -97,33 +105,19 @@ public String toString() {
         return "opens(" + opensIndex + ", " + opensFlags + ", " + opensToCount + ", ...)";
     }
 
-
     /**
      * @return Resolved string representation
      */
-    public String toString( final ConstantPool constant_pool ) {
+    public String toString(final ConstantPool constantPool) {
         final StringBuilder buf = new StringBuilder();
-        final String package_name = constant_pool.constantToString(opensIndex, Const.CONSTANT_Package);
-        buf.append(Utility.compactClassName(package_name, false));
+        final String packageName = constantPool.constantToString(opensIndex, Const.CONSTANT_Package);
+        buf.append(Utility.compactClassName(packageName, false));
         buf.append(", ").append(String.format("%04x", opensFlags));
         buf.append(", to(").append(opensToCount).append("):\n");
         for (final int index : opensToIndex) {
-            final String module_name = constant_pool.getConstantString(index, Const.CONSTANT_Module);
-            buf.append("      ").append(Utility.compactClassName(module_name, false)).append("\n");
-        }
-        return buf.substring(0, buf.length()-1); // remove the last newline
-    }
-
-
-    /**
-     * @return deep copy of this object
-     */
-    public ModuleOpens copy() {
-        try {
-            return (ModuleOpens) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
+            final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module);
+            buf.append("      ").append(Utility.compactClassName(moduleName, false)).append("\n");
         }
-        return null;
+        return buf.substring(0, buf.length() - 1); // remove the last newline
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java
index 1e1cb98731d..96367e02d2d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModulePackages.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,81 +23,94 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and represents the list of packages that are exported or opened by the Module attribute.
- * There may be at most one ModulePackages attribute in a ClassFile structure.
+ * This class is derived from <em>Attribute</em> and represents the list of packages that are exported or opened by the
+ * Module attribute. There may be at most one ModulePackages attribute in a ClassFile structure.
  *
- * @see     Attribute
+ * @see Attribute
+ * @LastModified: Feb 2023
  */
 public final class ModulePackages extends Attribute {
 
     private int[] packageIndexTable;
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+     * Construct object from input stream.
+     *
+     * @param nameIndex Index in constant pool
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    public ModulePackages(final ModulePackages c) {
-        this(c.getNameIndex(), c.getLength(), c.getPackageIndexTable(), c.getConstantPool());
+    ModulePackages(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (int[]) null, constantPool);
+        final int packageCount = input.readUnsignedShort();
+        packageIndexTable = new int[packageCount];
+        for (int i = 0; i < packageCount; i++) {
+            packageIndexTable[i] = input.readUnsignedShort();
+        }
     }
 
-
     /**
      * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param packageIndexTable Table of indices in constant pool
      * @param constantPool Array of constants
      */
-    public ModulePackages(final int nameIndex, final int length, final int[] packageIndexTable,
-            final ConstantPool constantPool) {
+    public ModulePackages(final int nameIndex, final int length, final int[] packageIndexTable, final ConstantPool constantPool) {
         super(Const.ATTR_MODULE_PACKAGES, nameIndex, length, constantPool);
-        this.packageIndexTable = packageIndexTable != null ? packageIndexTable : new int[0];
+        this.packageIndexTable = packageIndexTable != null ? packageIndexTable : Const.EMPTY_INT_ARRAY;
+        Args.requireU2(this.packageIndexTable.length, "packageIndexTable.length");
     }
 
-
     /**
-     * Construct object from input stream.
-     * @param name_index Index in constant pool
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
-    ModulePackages(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        this(name_index, length, (int[]) null, constant_pool);
-        final int number_of_packages = input.readUnsignedShort();
-        packageIndexTable = new int[number_of_packages];
-        for (int i = 0; i < number_of_packages; i++) {
-            packageIndexTable[i] = input.readUnsignedShort();
-        }
+    public ModulePackages(final ModulePackages c) {
+        this(c.getNameIndex(), c.getLength(), c.getPackageIndexTable(), c.getConstantPool());
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitModulePackages(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final ModulePackages c = (ModulePackages) clone();
+        if (packageIndexTable != null) {
+            c.packageIndexTable = packageIndexTable.clone();
+        }
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump ModulePackages attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(packageIndexTable.length);
         for (final int index : packageIndexTable) {
@@ -106,15 +118,6 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
-    /**
-     * @return array of indices into constant pool of package names.
-     */
-    public int[] getPackageIndexTable() {
-        return packageIndexTable;
-    }
-
-
     /**
      * @return Length of package table.
      */
@@ -122,29 +125,29 @@ public int getNumberOfPackages() {
         return packageIndexTable == null ? 0 : packageIndexTable.length;
     }
 
+    /**
+     * @return array of indices into constant pool of package names.
+     */
+    public int[] getPackageIndexTable() {
+        return packageIndexTable;
+    }
 
     /**
      * @return string array of package names
      */
     public String[] getPackageNames() {
         final String[] names = new String[packageIndexTable.length];
-        for (int i = 0; i < packageIndexTable.length; i++) {
-            names[i] = super.getConstantPool().getConstantString(packageIndexTable[i],
-                    Const.CONSTANT_Package).replace('/', '.');
-        }
+        Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(packageIndexTable[i], Const.CONSTANT_Package)));
         return names;
     }
 
-
     /**
-     * @param packageIndexTable the list of package indexes
-     * Also redefines number_of_packages according to table length.
+     * @param packageIndexTable the list of package indexes Also redefines number_of_packages according to table length.
      */
-    public void setPackageIndexTable( final int[] packageIndexTable ) {
-        this.packageIndexTable = packageIndexTable != null ? packageIndexTable : new int[0];
+    public void setPackageIndexTable(final int[] packageIndexTable) {
+        this.packageIndexTable = packageIndexTable != null ? packageIndexTable : Const.EMPTY_INT_ARRAY;
     }
 
-
     /**
      * @return String representation, i.e., a list of packages.
      */
@@ -155,25 +158,9 @@ public String toString() {
         buf.append(packageIndexTable.length);
         buf.append("):\n");
         for (final int index : packageIndexTable) {
-            final String package_name = super.getConstantPool().getConstantString(index, Const.CONSTANT_Package);
-            buf.append("  ").append(Utility.compactClassName(package_name, false)).append("\n");
+            final String packageName = super.getConstantPool().getConstantString(index, Const.CONSTANT_Package);
+            buf.append("  ").append(Utility.compactClassName(packageName, false)).append("\n");
         }
-        return buf.substring(0, buf.length()-1); // remove the last newline
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final ModulePackages c = (ModulePackages) clone();
-        if (packageIndexTable != null) {
-            c.packageIndexTable = new int[packageIndexTable.length];
-            System.arraycopy(packageIndexTable, 0, c.packageIndexTable, 0,
-                    packageIndexTable.length);
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
+        return buf.substring(0, buf.length() - 1); // remove the last newline
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java
index 8cbeecc3f26..f6c6058dfbb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleProvides.java
@@ -28,18 +28,17 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents an entry in the provides table of the Module attribute.
- * Each entry describes a service implementation that the parent module provides.
+ * This class represents an entry in the provides table of the Module attribute. Each entry describes a service
+ * implementation that the parent module provides.
  *
- * @see   Module
+ * @see Module
  * @since 6.4.0
  */
 public final class ModuleProvides implements Cloneable, Node {
 
-    private final int providesIndex;  // points to CONSTANT_Class_info
+    private final int providesIndex; // points to CONSTANT_Class_info
     private final int providesWithCount;
-    private final int[] providesWithIndex;  // points to CONSTANT_Class_info
-
+    private final int[] providesWithIndex; // points to CONSTANT_Class_info
 
     /**
      * Construct object from file stream.
@@ -56,28 +55,38 @@ public final class ModuleProvides implements Cloneable, Node {
         }
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitModuleProvides(this);
     }
 
     // TODO add more getters and setters?
 
+    /**
+     * @return deep copy of this object
+     */
+    public ModuleProvides copy() {
+        try {
+            return (ModuleProvides) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
+
     /**
      * Dump table entry to file stream in binary format.
      *
      * @param file Output file stream
      * @throws IOException if an I/O Exception occurs in writeShort
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(providesIndex);
         file.writeShort(providesWithCount);
         for (final int entry : providesWithIndex) {
@@ -85,7 +94,6 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
     /**
      * @return String representation
      */
@@ -94,32 +102,18 @@ public String toString() {
         return "provides(" + providesIndex + ", " + providesWithCount + ", ...)";
     }
 
-
     /**
      * @return Resolved string representation
      */
-    public String toString( final ConstantPool constant_pool ) {
+    public String toString(final ConstantPool constantPool) {
         final StringBuilder buf = new StringBuilder();
-        final String interface_name = constant_pool.constantToString(providesIndex, Const.CONSTANT_Class);
-        buf.append(Utility.compactClassName(interface_name, false));
+        final String interfaceName = constantPool.constantToString(providesIndex, Const.CONSTANT_Class);
+        buf.append(Utility.compactClassName(interfaceName, false));
         buf.append(", with(").append(providesWithCount).append("):\n");
         for (final int index : providesWithIndex) {
-            final String class_name = constant_pool.getConstantString(index, Const.CONSTANT_Class);
-            buf.append("      ").append(Utility.compactClassName(class_name, false)).append("\n");
-        }
-        return buf.substring(0, buf.length()-1); // remove the last newline
-    }
-
-
-    /**
-     * @return deep copy of this object
-     */
-    public ModuleProvides copy() {
-        try {
-            return (ModuleProvides) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
+            final String className = constantPool.getConstantString(index, Const.CONSTANT_Class);
+            buf.append("      ").append(Utility.compactClassName(className, false)).append("\n");
         }
-        return null;
+        return buf.substring(0, buf.length() - 1); // remove the last newline
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java
index a368197220d..c9c26c20649 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ModuleRequires.java
@@ -28,18 +28,17 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents an entry in the requires table of the Module attribute.
- * Each entry describes a module on which the parent module depends.
+ * This class represents an entry in the requires table of the Module attribute. Each entry describes a module on which
+ * the parent module depends.
  *
- * @see   Module
+ * @see Module
  * @since 6.4.0
  */
 public final class ModuleRequires implements Cloneable, Node {
 
-    private final int requiresIndex;  // points to CONSTANT_Module_info
+    private final int requiresIndex; // points to CONSTANT_Module_info
     private final int requiresFlags;
-    private final int requiresVersionIndex;  // either 0 or points to CONSTANT_Utf8_info
-
+    private final int requiresVersionIndex; // either 0 or points to CONSTANT_Utf8_info
 
     /**
      * Construct object from file stream.
@@ -53,34 +52,43 @@ public final class ModuleRequires implements Cloneable, Node {
         requiresVersionIndex = file.readUnsignedShort();
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitModuleRequires(this);
     }
 
     // TODO add more getters and setters?
 
+    /**
+     * @return deep copy of this object
+     */
+    public ModuleRequires copy() {
+        try {
+            return (ModuleRequires) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
+    }
+
     /**
      * Dump table entry to file stream in binary format.
      *
      * @param file Output file stream
      * @throws IOException if an I/O Exception occurs in writeShort
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeShort(requiresIndex);
         file.writeShort(requiresFlags);
         file.writeShort(requiresVersionIndex);
     }
 
-
     /**
      * @return String representation
      */
@@ -89,30 +97,16 @@ public String toString() {
         return "requires(" + requiresIndex + ", " + String.format("%04x", requiresFlags) + ", " + requiresVersionIndex + ")";
     }
 
-
     /**
      * @return Resolved string representation
      */
-    public String toString( final ConstantPool constant_pool ) {
+    public String toString(final ConstantPool constantPool) {
         final StringBuilder buf = new StringBuilder();
-        final String module_name = constant_pool.constantToString(requiresIndex, Const.CONSTANT_Module);
-        buf.append(Utility.compactClassName(module_name, false));
+        final String moduleName = constantPool.constantToString(requiresIndex, Const.CONSTANT_Module);
+        buf.append(Utility.compactClassName(moduleName, false));
         buf.append(", ").append(String.format("%04x", requiresFlags));
-        final String version = requiresVersionIndex == 0 ? "0" : constant_pool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8);
+        final String version = requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8);
         buf.append(", ").append(version);
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this object
-     */
-    public ModuleRequires copy() {
-        try {
-            return (ModuleRequires) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java
index b9a0a1d68a4..48ba454c930 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestHost.java
@@ -26,67 +26,73 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and records the nest host of the nest
- * to which the current class or interface claims to belong.
- * There may be at most one NestHost attribute in a ClassFile structure.
+ * This class is derived from <em>Attribute</em> and records the nest host of the nest to which the current class or
+ * interface claims to belong. There may be at most one NestHost attribute in a ClassFile structure.
  *
- * @see     Attribute
+ * @see Attribute
  */
 public final class NestHost extends Attribute {
 
     private int hostClassIndex;
 
-
     /**
-     * Initializes from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+     * Constructs object from input stream.
+     *
+     * @param nameIndex Index in constant pool
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    public NestHost(final NestHost c) {
-        this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool());
+    NestHost(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, 0, constantPool);
+        hostClassIndex = input.readUnsignedShort();
     }
 
-
     /**
      * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param hostClassIndex Host class index
      * @param constantPool Array of constants
      */
-    public NestHost(final int nameIndex, final int length, final int hostClassIndex,
-            final ConstantPool constantPool) {
+    public NestHost(final int nameIndex, final int length, final int hostClassIndex, final ConstantPool constantPool) {
         super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool);
-        this.hostClassIndex = hostClassIndex;
+        this.hostClassIndex = Args.requireU2(hostClassIndex, "hostClassIndex");
     }
 
-
     /**
-     * Constructs object from input stream.
-     * @param name_index Index in constant pool
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * Initializes from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
-    NestHost(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        this(name_index, length, 0, constant_pool);
-        hostClassIndex = input.readUnsignedShort();
+    public NestHost(final NestHost c) {
+        this(c.getNameIndex(), c.getLength(), c.getHostClassIndex(), c.getConstantPool());
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitNestHost(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final NestHost c = (NestHost) clone();
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dumps NestHost attribute to file stream in binary format.
@@ -95,12 +101,11 @@ public void accept( final Visitor v ) {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(hostClassIndex);
     }
 
-
     /**
      * @return index into constant pool of host class name.
      */
@@ -108,15 +113,13 @@ public int getHostClassIndex() {
         return hostClassIndex;
     }
 
-
     /**
      * @param hostClassIndex the host class index
      */
-    public void setHostClassIndex( final int hostClassIndex ) {
+    public void setHostClassIndex(final int hostClassIndex) {
         this.hostClassIndex = hostClassIndex;
     }
 
-
     /**
      * @return String representation
      */
@@ -124,19 +127,8 @@ public void setHostClassIndex( final int hostClassIndex ) {
     public String toString() {
         final StringBuilder buf = new StringBuilder();
         buf.append("NestHost: ");
-        final String class_name = super.getConstantPool().getConstantString(hostClassIndex, Const.CONSTANT_Class);
-        buf.append(Utility.compactClassName(class_name, false));
+        final String className = super.getConstantPool().getConstantString(hostClassIndex, Const.CONSTANT_Class);
+        buf.append(Utility.compactClassName(className, false));
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final NestHost c = (NestHost) clone();
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestMembers.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestMembers.java
index 73a853af6e6..05d982ca6e8 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestMembers.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/NestMembers.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,82 +23,95 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and records the classes and interfaces that
- * are authorized to claim membership in the nest hosted by the current class or interface.
- * There may be at most one NestMembers attribute in a ClassFile structure.
+ * This class is derived from <em>Attribute</em> and records the classes and interfaces that are authorized to claim
+ * membership in the nest hosted by the current class or interface. There may be at most one NestMembers attribute in a
+ * ClassFile structure.
  *
- * @see     Attribute
+ * @see Attribute
+ * @LastModified: Feb 2023
  */
 public final class NestMembers extends Attribute {
 
     private int[] classes;
 
-
     /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
+     * Construct object from input stream.
+     *
+     * @param nameIndex Index in constant pool
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    public NestMembers(final NestMembers c) {
-        this(c.getNameIndex(), c.getLength(), c.getClasses(), c.getConstantPool());
+    NestMembers(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (int[]) null, constantPool);
+        final int classCount = input.readUnsignedShort();
+        classes = new int[classCount];
+        for (int i = 0; i < classCount; i++) {
+            classes[i] = input.readUnsignedShort();
+        }
     }
 
-
     /**
-     * @param name_index Index in constant pool
+     * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param classes Table of indices in constant pool
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public NestMembers(final int name_index, final int length, final int[] classes,
-            final ConstantPool constant_pool) {
-        super(Const.ATTR_NEST_MEMBERS, name_index, length, constant_pool);
-        this.classes = classes != null ? classes : new int[0];
+    public NestMembers(final int nameIndex, final int length, final int[] classes, final ConstantPool constantPool) {
+        super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool);
+        this.classes = classes != null ? classes : Const.EMPTY_INT_ARRAY;
+        Args.requireU2(this.classes.length, "classes.length");
     }
 
-
     /**
-     * Construct object from input stream.
-     * @param name_index Index in constant pool
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
      */
-    NestMembers(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        this(name_index, length, (int[]) null, constant_pool);
-        final int number_of_classes = input.readUnsignedShort();
-        classes = new int[number_of_classes];
-        for (int i = 0; i < number_of_classes; i++) {
-            classes[i] = input.readUnsignedShort();
-        }
+    public NestMembers(final NestMembers c) {
+        this(c.getNameIndex(), c.getLength(), c.getClasses(), c.getConstantPool());
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitNestMembers(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final NestMembers c = (NestMembers) clone();
+        if (classes.length > 0) {
+            c.classes = classes.clone();
+        }
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump NestMembers attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(classes.length);
         for (final int index : classes) {
@@ -107,7 +119,6 @@ public void dump( final DataOutputStream file ) throws IOException {
         }
     }
 
-
     /**
      * @return array of indices into constant pool of class names.
      */
@@ -115,36 +126,28 @@ public int[] getClasses() {
         return classes;
     }
 
-
-    /**
-     * @return Length of classes table.
-     */
-    public int getNumberClasses() {
-        return classes == null ? 0 : classes.length;
-    }
-
-
     /**
      * @return string array of class names
      */
     public String[] getClassNames() {
         final String[] names = new String[classes.length];
-        for (int i = 0; i < classes.length; i++) {
-            names[i] = super.getConstantPool().getConstantString(classes[i],
-                    Const.CONSTANT_Class).replace('/', '.');
-        }
+        Arrays.setAll(names, i -> Utility.pathToPackage(super.getConstantPool().getConstantString(classes[i], Const.CONSTANT_Class)));
         return names;
     }
 
-
     /**
-     * @param classes the list of class indexes
-     * Also redefines number_of_classes according to table length.
+     * @return Length of classes table.
      */
-    public void setClasses( final int[] classes ) {
-        this.classes = classes != null ? classes : new int[0];
+    public int getNumberClasses() {
+        return classes.length;
     }
 
+    /**
+     * @param classes the list of class indexes Also redefines number_of_classes according to table length.
+     */
+    public void setClasses(final int[] classes) {
+        this.classes = classes != null ? classes : Const.EMPTY_INT_ARRAY;
+    }
 
     /**
      * @return String representation, i.e., a list of classes.
@@ -156,25 +159,9 @@ public String toString() {
         buf.append(classes.length);
         buf.append("):\n");
         for (final int index : classes) {
-            final String class_name = super.getConstantPool().getConstantString(index, Const.CONSTANT_Class);
-            buf.append("  ").append(Utility.compactClassName(class_name, false)).append("\n");
+            final String className = super.getConstantPool().getConstantString(index, Const.CONSTANT_Class);
+            buf.append("  ").append(Utility.compactClassName(className, false)).append("\n");
         }
-        return buf.substring(0, buf.length()-1); // remove the last newline
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final NestMembers c = (NestMembers) clone();
-        if (classes != null) {
-            c.classes = new int[classes.length];
-            System.arraycopy(classes, 0, c.classes, 0,
-                    classes.length);
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
+        return buf.substring(0, buf.length() - 1); // remove the last newline
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Node.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Node.java
index 45d48e2aa39..c0395732d79 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Node.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Node.java
@@ -23,9 +23,8 @@
 
 /**
  * Denote class to have an accept method();
- *
  */
 public interface Node {
 
-    void accept( Visitor obj );
+    void accept(Visitor obj);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java
index fed7464e779..9b1dd4c7b41 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java
@@ -28,83 +28,83 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class is derived from <em>Attribute</em> and represents a reference
- * to a PMG attribute.
+ * This class is derived from <em>Attribute</em> and represents a reference to a PMG attribute.
  *
- * @see     Attribute
+ * @see Attribute
  */
 public final class PMGClass extends Attribute {
 
     private int pmgClassIndex;
     private int pmgIndex;
 
-
-    /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
-     */
-    public PMGClass(final PMGClass pgmClass) {
-        this(pgmClass.getNameIndex(), pgmClass.getLength(), pgmClass.getPMGIndex(), pgmClass.getPMGClassIndex(),
-            pgmClass.getConstantPool());
-    }
-
-
     /**
      * Construct object from input stream.
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     *
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    PMGClass(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, input.readUnsignedShort(), input.readUnsignedShort(), constant_pool);
+    PMGClass(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, input.readUnsignedShort(), input.readUnsignedShort(), constantPool);
     }
 
-
     /**
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param pmgIndex index in constant pool for source file name
      * @param pmgClassIndex Index in constant pool to CONSTANT_Utf8
      * @param constantPool Array of constants
      */
-    public PMGClass(final int name_index, final int length, final int pmgIndex, final int pmgClassIndex,
-            final ConstantPool constantPool) {
-        super(Const.ATTR_PMG, name_index, length, constantPool);
+    public PMGClass(final int nameIndex, final int length, final int pmgIndex, final int pmgClassIndex, final ConstantPool constantPool) {
+        super(Const.ATTR_PMG, nameIndex, length, constantPool);
         this.pmgIndex = pmgIndex;
         this.pmgClassIndex = pmgClassIndex;
     }
 
+    /**
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param pgmClass Source to copy.
+     */
+    public PMGClass(final PMGClass pgmClass) {
+        this(pgmClass.getNameIndex(), pgmClass.getLength(), pgmClass.getPMGIndex(), pgmClass.getPMGClassIndex(), pgmClass.getConstantPool());
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         println("Visiting non-standard PMGClass object");
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        return (Attribute) clone();
+    }
 
     /**
      * Dump source file attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(pmgIndex);
         file.writeShort(pmgClassIndex);
     }
 
-
     /**
      * @return Index in constant pool of source file name.
      */
@@ -112,15 +112,13 @@ public int getPMGClassIndex() {
         return pmgClassIndex;
     }
 
-
     /**
-     * @param pmgClassIndex
+     * @return PMG class name.
      */
-    public void setPMGClassIndex( final int pmgClassIndex ) {
-        this.pmgClassIndex = pmgClassIndex;
+    public String getPMGClassName() {
+        return super.getConstantPool().getConstantUtf8(pmgClassIndex).getBytes();
     }
 
-
     /**
      * @return Index in constant pool of source file name.
      */
@@ -128,35 +126,27 @@ public int getPMGIndex() {
         return pmgIndex;
     }
 
-
     /**
-     * @param pmgIndex
+     * @return PMG name.
      */
-    public void setPMGIndex( final int pmgIndex ) {
-        this.pmgIndex = pmgIndex;
+    public String getPMGName() {
+        return super.getConstantPool().getConstantUtf8(pmgIndex).getBytes();
     }
 
-
     /**
-     * @return PMG name.
+     * @param pmgClassIndex
      */
-    public String getPMGName() {
-        final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmgIndex,
-                Const.CONSTANT_Utf8);
-        return c.getBytes();
+    public void setPMGClassIndex(final int pmgClassIndex) {
+        this.pmgClassIndex = pmgClassIndex;
     }
 
-
     /**
-     * @return PMG class name.
+     * @param pmgIndex
      */
-    public String getPMGClassName() {
-        final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(pmgClassIndex,
-                Const.CONSTANT_Utf8);
-        return c.getBytes();
+    public void setPMGIndex(final int pmgIndex) {
+        this.pmgIndex = pmgIndex;
     }
 
-
     /**
      * @return String representation
      */
@@ -164,13 +154,4 @@ public String getPMGClassName() {
     public String toString() {
         return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        return (Attribute) clone();
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java
index f652ad7ca11..a3070fa7e0c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotationEntry.java
@@ -35,44 +35,48 @@
  */
 public class ParameterAnnotationEntry implements Node {
 
-    private final AnnotationEntry[] annotationTable;
+    static final ParameterAnnotationEntry[] EMPTY_ARRAY = {};
 
+    public static ParameterAnnotationEntry[] createParameterAnnotationEntries(final Attribute[] attrs) {
+        // Find attributes that contain parameter annotation data
+        final List<ParameterAnnotationEntry> accumulatedAnnotations = new ArrayList<>(attrs.length);
+        for (final Attribute attribute : attrs) {
+            if (attribute instanceof ParameterAnnotations) {
+                final ParameterAnnotations runtimeAnnotations = (ParameterAnnotations) attribute;
+                Collections.addAll(accumulatedAnnotations, runtimeAnnotations.getParameterAnnotationEntries());
+            }
+        }
+        return accumulatedAnnotations.toArray(ParameterAnnotationEntry.EMPTY_ARRAY);
+    }
+
+    private final AnnotationEntry[] annotationTable;
 
     /**
      * Construct object from input stream.
      *
      * @param input Input stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    ParameterAnnotationEntry(final DataInput input, final ConstantPool constant_pool) throws IOException {
-        final int annotation_table_length = input.readUnsignedShort();
-        annotationTable = new AnnotationEntry[annotation_table_length];
-        for (int i = 0; i < annotation_table_length; i++) {
+    ParameterAnnotationEntry(final DataInput input, final ConstantPool constantPool) throws IOException {
+        final int annotationTableLength = input.readUnsignedShort();
+        annotationTable = new AnnotationEntry[annotationTableLength];
+        for (int i = 0; i < annotationTableLength; i++) {
             // TODO isRuntimeVisible
-            annotationTable[i] = AnnotationEntry.read(input, constant_pool, false);
+            annotationTable[i] = AnnotationEntry.read(input, constantPool, false);
         }
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitParameterAnnotationEntry(this);
     }
 
-    /**
-     * returns the array of annotation entries in this annotation
-     */
-    public AnnotationEntry[] getAnnotationEntries() {
-        return annotationTable;
-    }
-
     public void dump(final DataOutputStream dos) throws IOException {
         dos.writeShort(annotationTable.length);
         for (final AnnotationEntry entry : annotationTable) {
@@ -80,15 +84,10 @@ public void dump(final DataOutputStream dos) throws IOException {
         }
     }
 
-  public static ParameterAnnotationEntry[] createParameterAnnotationEntries(final Attribute[] attrs) {
-      // Find attributes that contain parameter annotation data
-      final List<ParameterAnnotationEntry> accumulatedAnnotations = new ArrayList<>(attrs.length);
-      for (final Attribute attribute : attrs) {
-          if (attribute instanceof ParameterAnnotations) {
-              final ParameterAnnotations runtimeAnnotations = (ParameterAnnotations)attribute;
-              Collections.addAll(accumulatedAnnotations, runtimeAnnotations.getParameterAnnotationEntries());
-          }
-      }
-      return accumulatedAnnotations.toArray(new ParameterAnnotationEntry[accumulatedAnnotations.size()]);
-  }
+    /**
+     * returns the array of annotation entries in this annotation
+     */
+    public AnnotationEntry[] getAnnotationEntries() {
+        return annotationTable;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java
index 2370ed76aff..4817793120f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java
@@ -24,36 +24,36 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Iterator;
+import java.util.stream.Stream;
 
 /**
  * base class for parameter annotations
  *
  * @since 6.0
  */
-public abstract class ParameterAnnotations extends Attribute {
+public abstract class ParameterAnnotations extends Attribute implements Iterable<ParameterAnnotationEntry> {
 
     /** Table of parameter annotations */
     private ParameterAnnotationEntry[] parameterAnnotationTable;
 
     /**
-     * @param parameter_annotation_type the subclass type of the parameter annotation
-     * @param name_index Index pointing to the name <em>Code</em>
+     * @param parameterAnnotationType the subclass type of the parameter annotation
+     * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    ParameterAnnotations(final byte parameter_annotation_type, final int name_index, final int length,
-            final DataInput input, final ConstantPool constant_pool) throws IOException {
-        this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null,
-                constant_pool);
-        final int num_parameters = input.readUnsignedByte();
-        parameterAnnotationTable = new ParameterAnnotationEntry[num_parameters];
-        for (int i = 0; i < num_parameters; i++) {
-            parameterAnnotationTable[i] = new ParameterAnnotationEntry(input, constant_pool);
+    ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool)
+        throws IOException {
+        this(parameterAnnotationType, nameIndex, length, (ParameterAnnotationEntry[]) null, constantPool);
+        final int numParameters = input.readUnsignedByte();
+        parameterAnnotationTable = new ParameterAnnotationEntry[numParameters];
+        for (int i = 0; i < numParameters; i++) {
+            parameterAnnotationTable[i] = new ParameterAnnotationEntry(input, constantPool);
         }
     }
 
-
     /**
      * @param parameterAnnotationType the subclass type of the parameter annotation
      * @param nameIndex Index pointing to the name <em>Code</em>
@@ -62,65 +62,64 @@ public abstract class ParameterAnnotations extends Attribute {
      * @param constantPool Array of constants
      */
     public ParameterAnnotations(final byte parameterAnnotationType, final int nameIndex, final int length,
-            final ParameterAnnotationEntry[] parameterAnnotationTable, final ConstantPool constantPool) {
+        final ParameterAnnotationEntry[] parameterAnnotationTable, final ConstantPool constantPool) {
         super(parameterAnnotationType, nameIndex, length, constantPool);
         this.parameterAnnotationTable = parameterAnnotationTable;
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitParameterAnnotation(this);
     }
 
-
     /**
-     * @param parameterAnnotationTable the entries to set in this parameter annotation
+     * @return deep copy of this attribute
      */
-    public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameterAnnotationTable ) {
-        this.parameterAnnotationTable = parameterAnnotationTable;
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        return (Attribute) clone();
     }
 
+    @Override
+    public void dump(final DataOutputStream dos) throws IOException {
+        super.dump(dos);
+        dos.writeByte(parameterAnnotationTable.length);
+
+        for (final ParameterAnnotationEntry element : parameterAnnotationTable) {
+            element.dump(dos);
+        }
+
+    }
 
     /**
-     * @return the parameter annotation entry table
+     * returns the array of parameter annotation entries in this parameter annotation
      */
-    public final ParameterAnnotationEntry[] getParameterAnnotationTable() {
+    public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
         return parameterAnnotationTable;
     }
 
-
     /**
-     * returns the array of parameter annotation entries in this parameter annotation
+     * @return the parameter annotation entry table
      */
-    public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
+    public final ParameterAnnotationEntry[] getParameterAnnotationTable() {
         return parameterAnnotationTable;
     }
 
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
-        super.dump(dos);
-        dos.writeByte(parameterAnnotationTable.length);
-
-        for (final ParameterAnnotationEntry element : parameterAnnotationTable) {
-            element.dump(dos);
-        }
-
+    public Iterator<ParameterAnnotationEntry> iterator() {
+        return Stream.of(parameterAnnotationTable).iterator();
     }
 
     /**
-     * @return deep copy of this attribute
+     * @param parameterAnnotationTable the entries to set in this parameter annotation
      */
-    @Override
-    public Attribute copy( final ConstantPool constant_pool ) {
-        return (Attribute) clone();
+    public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameterAnnotationTable) {
+        this.parameterAnnotationTable = parameterAnnotationTable;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java
index 7c65eb6de22..7afb8719559 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleAnnotations.java
@@ -28,41 +28,33 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * represents an annotation that is represented in the class file but is not
- * provided to the JVM.
+ * represents an annotation that is represented in the class file but is not provided to the JVM.
  *
  * @since 6.0
  */
-public class RuntimeInvisibleAnnotations extends Annotations
-{
+public class RuntimeInvisibleAnnotations extends Annotations {
+
     /**
-     * @param name_index
-     *            Index pointing to the name <em>Code</em>
-     * @param length
-     *            Content length in bytes
-     * @param input
-     *            Input stream
-     * @param constant_pool
-     *            Array of constants
+     * @param nameIndex Index pointing to the name <em>Code</em>
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException Thrown when an I/O exception of some sort has occurred.
      */
-    public RuntimeInvisibleAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException
-    {
-        super(Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, name_index, length, input, constant_pool, false);
+    public RuntimeInvisibleAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        super(Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, nameIndex, length, input, constantPool, false);
     }
 
     /**
      * @return deep copy of this attribute
      */
     @Override
-    public Attribute copy(final ConstantPool constant_pool)
-    {
+    public Attribute copy(final ConstantPool constantPool) {
         return (Attribute) clone();
     }
 
     @Override
-    public final void dump(final DataOutputStream dos) throws IOException
-    {
+    public final void dump(final DataOutputStream dos) throws IOException {
         super.dump(dos);
         writeAnnotations(dos);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java
index 1717f752972..e4c3276f968 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeInvisibleParameterAnnotations.java
@@ -27,21 +27,21 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * Represents a parameter annotation that is represented in the class file
- * but is not provided to the JVM.
+ * Represents a parameter annotation that is represented in the class file but is not provided to the JVM.
  *
  * @since 6.0
  */
 public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations {
 
     /**
-     * @param name_index Index pointing to the name <em>Code</em>
+     * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
+     * @throws IOException Thrown when an I/O exception of some sort has occurred.
      */
-    public RuntimeInvisibleParameterAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        super(Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, name_index, length, input, constant_pool);
+    public RuntimeInvisibleParameterAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool)
+        throws IOException {
+        super(Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, nameIndex, length, input, constantPool);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java
index a4b5745118a..c91c77387b9 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleAnnotations.java
@@ -28,40 +28,33 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * represents an annotation that is represented in the class file and is
- * provided to the JVM.
+ * represents an annotation that is represented in the class file and is provided to the JVM.
  *
  * @since 6.0
  */
-public class RuntimeVisibleAnnotations extends Annotations
-{
+public class RuntimeVisibleAnnotations extends Annotations {
+
     /**
-     * @param name_index
-     *            Index pointing to the name <em>Code</em>
-     * @param length
-     *            Content length in bytes
-     * @param input
-     *            Input stream
-     * @param constant_pool
-     *            Array of constants
+     * @param nameIndex Index pointing to the name <em>Code</em>
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException Thrown when an I/O exception of some sort has occurred.
      */
-    public RuntimeVisibleAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException
-    {
-        super(Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length, input, constant_pool, true);
+    public RuntimeVisibleAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        super(Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, nameIndex, length, input, constantPool, true);
     }
 
     /**
      * @return deep copy of this attribute
      */
     @Override
-    public Attribute copy(final ConstantPool constant_pool)
-    {
+    public Attribute copy(final ConstantPool constantPool) {
         return (Attribute) clone();
     }
 
     @Override
-    public final void dump(final DataOutputStream dos) throws IOException
-    {
+    public final void dump(final DataOutputStream dos) throws IOException {
         super.dump(dos);
         writeAnnotations(dos);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java
index a85f51827d3..7e5d7eaaca3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/RuntimeVisibleParameterAnnotations.java
@@ -27,21 +27,21 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * Represents a parameter annotation that is represented in the class file
- * and is provided to the JVM.
+ * Represents a parameter annotation that is represented in the class file and is provided to the JVM.
  *
  * @since 6.0
  */
 public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations {
 
     /**
-     * @param name_index Index pointing to the name <em>Code</em>
+     * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
+     * @throws IOException Thrown when an I/O exception of some sort has occurred.
      */
-    public RuntimeVisibleParameterAnnotations(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        super(Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, input, constant_pool);
+    public RuntimeVisibleParameterAnnotations(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool)
+        throws IOException {
+        super(Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, nameIndex, length, input, constantPool);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java
index 45c138c6ad0..4f5d3a341b3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java
@@ -25,122 +25,32 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and represents a reference
- * to a GJ attribute.
+ * This class is derived from <em>Attribute</em> and represents a reference to a GJ attribute.
  *
- * @see     Attribute
+ * @see Attribute
  */
 public final class Signature extends Attribute {
 
-    private int signatureIndex;
-
-
-    /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
-     */
-    public Signature(final Signature c) {
-        this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool());
-    }
-
-
-    /**
-     * Construct object from file stream.
-     * @param name_index Index in constant pool to CONSTANT_Utf8
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
-     */
-    Signature(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, input.readUnsignedShort(), constant_pool);
-    }
-
-
-    /**
-     * @param name_index Index in constant pool to CONSTANT_Utf8
-     * @param length Content length in bytes
-     * @param signatureIndex Index in constant pool to CONSTANT_Utf8
-     * @param constant_pool Array of constants
-     */
-    public Signature(final int name_index, final int length, final int signatureIndex, final ConstantPool constant_pool) {
-        super(Const.ATTR_SIGNATURE, name_index, length, constant_pool);
-        this.signatureIndex = signatureIndex;
-    }
-
-
-    /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        //System.err.println("Visiting non-standard Signature object");
-        v.visitSignature(this);
-    }
-
-
-    /**
-     * Dump source file attribute to file stream in binary format.
-     *
-     * @param file Output file stream
-     * @throws IOException
-     */
-    @Override
-    public void dump( final DataOutputStream file ) throws IOException {
-        super.dump(file);
-        file.writeShort(signatureIndex);
-    }
-
-
-    /**
-     * @return Index in constant pool of source file name.
-     */
-    public int getSignatureIndex() {
-        return signatureIndex;
-    }
-
-
-    /**
-     * @param signatureIndex the index info the constant pool of this signature
-     */
-    public void setSignatureIndex( final int signatureIndex ) {
-        this.signatureIndex = signatureIndex;
-    }
-
-
-    /**
-     * @return GJ signature.
-     */
-    public String getSignature() {
-        final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(signatureIndex,
-                Const.CONSTANT_Utf8);
-        return c.getBytes();
-    }
-
     /**
      * Extends ByteArrayInputStream to make 'unreading' chars possible.
      */
     private static final class MyByteArrayInputStream extends ByteArrayInputStream {
 
         MyByteArrayInputStream(final String data) {
-            super(data.getBytes());
+            super(data.getBytes(StandardCharsets.UTF_8));
         }
 
-
         String getData() {
-            return new String(buf);
+            return new String(buf, StandardCharsets.UTF_8);
         }
 
-
         void unread() {
             if (pos > 0) {
                 pos--;
@@ -148,19 +58,59 @@ void unread() {
         }
     }
 
-
-    private static boolean identStart( final int ch ) {
+    private static boolean identStart(final int ch) {
         return ch == 'T' || ch == 'L';
     }
 
+    // @since 6.0 is no longer final
+    public static boolean isActualParameterList(final String s) {
+        return s.startsWith("L") && s.endsWith(">;");
+    }
+
+    // @since 6.0 is no longer final
+    public static boolean isFormalParameterList(final String s) {
+        return s.startsWith("<") && s.indexOf(':') > 0;
+    }
+
+    private static void matchGJIdent(final MyByteArrayInputStream in, final StringBuilder buf) {
+        int ch;
+        matchIdent(in, buf);
+        ch = in.read();
+        if (ch == '<' || ch == '(') { // Parameterized or method
+            // System.out.println("Enter <");
+            buf.append((char) ch);
+            matchGJIdent(in, buf);
+            while ((ch = in.read()) != '>' && ch != ')') { // List of parameters
+                if (ch == -1) {
+                    throw new IllegalArgumentException("Illegal signature: " + in.getData() + " reaching EOF");
+                }
+                // System.out.println("Still no >");
+                buf.append(", ");
+                in.unread();
+                matchGJIdent(in, buf); // Recursive call
+            }
+            // System.out.println("Exit >");
+            buf.append((char) ch);
+        } else {
+            in.unread();
+        }
+        ch = in.read();
+        if (identStart(ch)) {
+            in.unread();
+            matchGJIdent(in, buf);
+        } else if (ch == ')') {
+            in.unread();
+        } else if (ch != ';') {
+            throw new IllegalArgumentException("Illegal signature: " + in.getData() + " read " + (char) ch);
+        }
+    }
 
-    private static void matchIdent( final MyByteArrayInputStream in, final StringBuilder buf ) {
+    private static void matchIdent(final MyByteArrayInputStream in, final StringBuilder buf) {
         int ch;
         if ((ch = in.read()) == -1) {
-            throw new IllegalArgumentException("Illegal signature: " + in.getData()
-                    + " no ident, reaching EOF");
+            throw new IllegalArgumentException("Illegal signature: " + in.getData() + " no ident, reaching EOF");
         }
-        //System.out.println("return from ident:" + (char)ch);
+        // System.out.println("return from ident:" + (char)ch);
         if (!identStart(ch)) {
             final StringBuilder buf2 = new StringBuilder();
             int count = 1;
@@ -170,11 +120,15 @@ private static void matchIdent( final MyByteArrayInputStream in, final StringBui
                 ch = in.read();
             }
             if (ch == ':') { // Ok, formal parameter
-                in.skip("Ljava/lang/Object".length());
+                final int skipExpected = "Ljava/lang/Object".length();
+                final long skipActual = in.skip(skipExpected);
+                if (skipActual != skipExpected) {
+                    throw new IllegalStateException(String.format("Unexpected skip: expected=%,d, actual=%,d", skipExpected, skipActual));
+                }
                 buf.append(buf2);
                 ch = in.read();
                 in.unread();
-                //System.out.println("so far:" + buf2 + ":next:" +(char)ch);
+                // System.out.println("so far:" + buf2 + ":next:" +(char)ch);
             } else {
                 for (int i = 0; i < count; i++) {
                     in.unread();
@@ -187,87 +141,118 @@ private static void matchIdent( final MyByteArrayInputStream in, final StringBui
         do {
             buf2.append((char) ch);
             ch = in.read();
-            //System.out.println("within ident:"+ (char)ch);
-        } while ((ch != -1) && (Character.isJavaIdentifierPart((char) ch) || (ch == '/')));
-        buf.append(buf2.toString().replace('/', '.'));
-        //System.out.println("regular return ident:"+ (char)ch + ":" + buf2);
+            // System.out.println("within ident:"+ (char)ch);
+        } while (ch != -1 && (Character.isJavaIdentifierPart((char) ch) || ch == '/'));
+        buf.append(Utility.pathToPackage(buf2.toString()));
+        // System.out.println("regular return ident:"+ (char)ch + ":" + buf2);
         if (ch != -1) {
             in.unread();
         }
     }
 
-
-    private static void matchGJIdent( final MyByteArrayInputStream in, final StringBuilder buf ) {
-        int ch;
-        matchIdent(in, buf);
-        ch = in.read();
-        if ((ch == '<') || ch == '(') { // Parameterized or method
-            //System.out.println("Enter <");
-            buf.append((char) ch);
-            matchGJIdent(in, buf);
-            while (((ch = in.read()) != '>') && (ch != ')')) { // List of parameters
-                if (ch == -1) {
-                    throw new IllegalArgumentException("Illegal signature: " + in.getData()
-                            + " reaching EOF");
-                }
-                //System.out.println("Still no >");
-                buf.append(", ");
-                in.unread();
-                matchGJIdent(in, buf); // Recursive call
-            }
-            //System.out.println("Exit >");
-            buf.append((char) ch);
-        } else {
-            in.unread();
-        }
-        ch = in.read();
-        if (identStart(ch)) {
-            in.unread();
-            matchGJIdent(in, buf);
-        } else if (ch == ')') {
-            in.unread();
-            return;
-        } else if (ch != ';') {
-            throw new IllegalArgumentException("Illegal signature: " + in.getData() + " read " + (char) ch);
-        }
-    }
-
-
-    public static String translate( final String s ) {
-        //System.out.println("Sig:" + s);
+    public static String translate(final String s) {
+        // System.out.println("Sig:" + s);
         final StringBuilder buf = new StringBuilder();
         matchGJIdent(new MyByteArrayInputStream(s), buf);
         return buf.toString();
     }
 
+    private int signatureIndex;
 
-    // @since 6.0 is no longer final
-    public static boolean isFormalParameterList( final String s ) {
-        return s.startsWith("<") && (s.indexOf(':') > 0);
+    /**
+     * Construct object from file stream.
+     *
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
+     * @param length Content length in bytes
+     * @param input Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
+     */
+    Signature(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, input.readUnsignedShort(), constantPool);
     }
 
-
-    // @since 6.0 is no longer final
-    public static boolean isActualParameterList( final String s ) {
-        return s.startsWith("L") && s.endsWith(">;");
+    /**
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
+     * @param length Content length in bytes
+     * @param signatureIndex Index in constant pool to CONSTANT_Utf8
+     * @param constantPool Array of constants
+     */
+    public Signature(final int nameIndex, final int length, final int signatureIndex, final ConstantPool constantPool) {
+        super(Const.ATTR_SIGNATURE, nameIndex, Args.require(length, 2, "Signature length attribute"), constantPool);
+        this.signatureIndex = signatureIndex;
+        // validate:
+        Objects.requireNonNull(constantPool.getConstantUtf8(signatureIndex), "constantPool.getConstantUtf8(signatureIndex)");
     }
 
+    /**
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
+     */
+    public Signature(final Signature c) {
+        this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool());
+    }
 
     /**
-     * @return String representation
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+     *
+     * @param v Visitor object
      */
     @Override
-    public String toString() {
-        final String s = getSignature();
-        return "Signature: " + s;
+    public void accept(final Visitor v) {
+        // System.err.println("Visiting non-standard Signature object");
+        v.visitSignature(this);
     }
 
-
     /**
      * @return deep copy of this attribute
      */
     @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
+    public Attribute copy(final ConstantPool constantPool) {
         return (Attribute) clone();
     }
+
+    /**
+     * Dump source file attribute to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException if an I/O error occurs.
+     */
+    @Override
+    public void dump(final DataOutputStream file) throws IOException {
+        super.dump(file);
+        file.writeShort(signatureIndex);
+    }
+
+    /**
+     * @return GJ signature.
+     */
+    public String getSignature() {
+        return super.getConstantPool().getConstantUtf8(signatureIndex).getBytes();
+    }
+
+    /**
+     * @return Index in constant pool of source file name.
+     */
+    public int getSignatureIndex() {
+        return signatureIndex;
+    }
+
+    /**
+     * @param signatureIndex the index info the constant pool of this signature
+     */
+    public void setSignatureIndex(final int signatureIndex) {
+        this.signatureIndex = signatureIndex;
+    }
+
+    /**
+     * @return String representation
+     */
+    @Override
+    public String toString() {
+        return "Signature: " + getSignature();
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java
index 7b3050ea427..5e4e98d94df 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SimpleElementValue.java
@@ -29,201 +29,155 @@
 /**
  * @since 6.0
  */
-public class SimpleElementValue extends ElementValue
-{
+public class SimpleElementValue extends ElementValue {
     private int index;
 
-    public SimpleElementValue(final int type, final int index, final ConstantPool cpool)
-    {
+    public SimpleElementValue(final int type, final int index, final ConstantPool cpool) {
         super(type, cpool);
         this.index = index;
     }
 
+    @Override
+    public void dump(final DataOutputStream dos) throws IOException {
+        final int type = super.getType();
+        dos.writeByte(type); // u1 kind of value
+        switch (type) {
+        case PRIMITIVE_INT:
+        case PRIMITIVE_BYTE:
+        case PRIMITIVE_CHAR:
+        case PRIMITIVE_FLOAT:
+        case PRIMITIVE_LONG:
+        case PRIMITIVE_BOOLEAN:
+        case PRIMITIVE_SHORT:
+        case PRIMITIVE_DOUBLE:
+        case STRING:
+            dos.writeShort(getIndex());
+            break;
+        default:
+            throw new ClassFormatException("SimpleElementValue doesnt know how to write out type " + type);
+        }
+    }
+
     /**
      * @return Value entry index in the cpool
      */
-    public int getIndex()
-    {
+    public int getIndex() {
         return index;
     }
 
-    public void setIndex(final int index)
-    {
-        this.index = index;
-    }
-
-    public String getValueString()
-    {
-        if (super.getType() != STRING) {
-            throw new IllegalStateException(
-                    "Dont call getValueString() on a non STRING ElementValue");
-        }
-        final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(getIndex(),
-                Const.CONSTANT_Utf8);
-        return c.getBytes();
-    }
-
-    public int getValueInt()
-    {
-        if (super.getType() != PRIMITIVE_INT) {
-            throw new IllegalStateException(
-                    "Dont call getValueString() on a non STRING ElementValue");
+    public boolean getValueBoolean() {
+        if (super.getType() != PRIMITIVE_BOOLEAN) {
+            throw new IllegalStateException("Dont call getValueBoolean() on a non BOOLEAN ElementValue");
         }
-        final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(),
-                Const.CONSTANT_Integer);
-        return c.getBytes();
+        final ConstantInteger bo = (ConstantInteger) super.getConstantPool().getConstant(getIndex());
+        return bo.getBytes() != 0;
     }
 
-    public byte getValueByte()
-    {
+    public byte getValueByte() {
         if (super.getType() != PRIMITIVE_BYTE) {
-            throw new IllegalStateException(
-                    "Dont call getValueByte() on a non BYTE ElementValue");
+            throw new IllegalStateException("Dont call getValueByte() on a non BYTE ElementValue");
         }
-        final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(),
-                Const.CONSTANT_Integer);
-        return (byte) c.getBytes();
+        return (byte) super.getConstantPool().getConstantInteger(getIndex()).getBytes();
     }
 
-    public char getValueChar()
-    {
+    public char getValueChar() {
         if (super.getType() != PRIMITIVE_CHAR) {
-            throw new IllegalStateException(
-                    "Dont call getValueChar() on a non CHAR ElementValue");
+            throw new IllegalStateException("Dont call getValueChar() on a non CHAR ElementValue");
         }
-        final ConstantInteger c = (ConstantInteger) super.getConstantPool().getConstant(getIndex(),
-                Const.CONSTANT_Integer);
-        return (char) c.getBytes();
+        return (char) super.getConstantPool().getConstantInteger(getIndex()).getBytes();
     }
 
-    public long getValueLong()
-    {
-        if (super.getType() != PRIMITIVE_LONG) {
-            throw new IllegalStateException(
-                    "Dont call getValueLong() on a non LONG ElementValue");
+    public double getValueDouble() {
+        if (super.getType() != PRIMITIVE_DOUBLE) {
+            throw new IllegalStateException("Dont call getValueDouble() on a non DOUBLE ElementValue");
         }
-        final ConstantLong j = (ConstantLong) super.getConstantPool().getConstant(getIndex());
-        return j.getBytes();
+        final ConstantDouble d = (ConstantDouble) super.getConstantPool().getConstant(getIndex());
+        return d.getBytes();
     }
 
-    public float getValueFloat()
-    {
+    public float getValueFloat() {
         if (super.getType() != PRIMITIVE_FLOAT) {
-            throw new IllegalStateException(
-                    "Dont call getValueFloat() on a non FLOAT ElementValue");
+            throw new IllegalStateException("Dont call getValueFloat() on a non FLOAT ElementValue");
         }
         final ConstantFloat f = (ConstantFloat) super.getConstantPool().getConstant(getIndex());
         return f.getBytes();
     }
 
-    public double getValueDouble()
-    {
-        if (super.getType() != PRIMITIVE_DOUBLE) {
-            throw new IllegalStateException(
-                    "Dont call getValueDouble() on a non DOUBLE ElementValue");
+    public int getValueInt() {
+        if (super.getType() != PRIMITIVE_INT) {
+            throw new IllegalStateException("Dont call getValueInt() on a non INT ElementValue");
         }
-        final ConstantDouble d = (ConstantDouble) super.getConstantPool().getConstant(getIndex());
-        return d.getBytes();
+        return super.getConstantPool().getConstantInteger(getIndex()).getBytes();
     }
 
-    public boolean getValueBoolean()
-    {
-        if (super.getType() != PRIMITIVE_BOOLEAN) {
-            throw new IllegalStateException(
-                    "Dont call getValueBoolean() on a non BOOLEAN ElementValue");
+    public long getValueLong() {
+        if (super.getType() != PRIMITIVE_LONG) {
+            throw new IllegalStateException("Dont call getValueLong() on a non LONG ElementValue");
         }
-        final ConstantInteger bo = (ConstantInteger) super.getConstantPool().getConstant(getIndex());
-        return bo.getBytes() != 0;
+        final ConstantLong j = (ConstantLong) super.getConstantPool().getConstant(getIndex());
+        return j.getBytes();
     }
 
-    public short getValueShort()
-    {
+    public short getValueShort() {
         if (super.getType() != PRIMITIVE_SHORT) {
-            throw new IllegalStateException(
-                    "Dont call getValueShort() on a non SHORT ElementValue");
+            throw new IllegalStateException("Dont call getValueShort() on a non SHORT ElementValue");
         }
         final ConstantInteger s = (ConstantInteger) super.getConstantPool().getConstant(getIndex());
         return (short) s.getBytes();
     }
 
-    @Override
-    public String toString()
-    {
-        return stringifyValue();
+    public String getValueString() {
+        if (super.getType() != STRING) {
+            throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue");
+        }
+        return super.getConstantPool().getConstantUtf8(getIndex()).getBytes();
+    }
+
+    public void setIndex(final int index) {
+        this.index = index;
     }
 
     // Whatever kind of value it is, return it as a string
     @Override
-    public String stringifyValue()
-    {
+    public String stringifyValue() {
         final ConstantPool cpool = super.getConstantPool();
-        final int _type = super.getType();
-        switch (_type)
-        {
+        final int type = super.getType();
+        switch (type) {
         case PRIMITIVE_INT:
-            final ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Integer);
-            return Integer.toString(c.getBytes());
+            return Integer.toString(cpool.getConstantInteger(getIndex()).getBytes());
         case PRIMITIVE_LONG:
-            final ConstantLong j = (ConstantLong) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Long);
+            final ConstantLong j = cpool.getConstant(getIndex(), Const.CONSTANT_Long, ConstantLong.class);
             return Long.toString(j.getBytes());
         case PRIMITIVE_DOUBLE:
-            final ConstantDouble d = (ConstantDouble) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Double);
+            final ConstantDouble d = cpool.getConstant(getIndex(), Const.CONSTANT_Double, ConstantDouble.class);
             return Double.toString(d.getBytes());
         case PRIMITIVE_FLOAT:
-            final ConstantFloat f = (ConstantFloat) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Float);
+            final ConstantFloat f = cpool.getConstant(getIndex(), Const.CONSTANT_Float, ConstantFloat.class);
             return Float.toString(f.getBytes());
         case PRIMITIVE_SHORT:
-            final ConstantInteger s = (ConstantInteger) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Integer);
+            final ConstantInteger s = cpool.getConstantInteger(getIndex());
             return Integer.toString(s.getBytes());
         case PRIMITIVE_BYTE:
-            final ConstantInteger b = (ConstantInteger) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Integer);
+            final ConstantInteger b = cpool.getConstantInteger(getIndex());
             return Integer.toString(b.getBytes());
         case PRIMITIVE_CHAR:
-            final ConstantInteger ch = (ConstantInteger) cpool.getConstant(
-                    getIndex(), Const.CONSTANT_Integer);
-            return String.valueOf((char)ch.getBytes());
+            final ConstantInteger ch = cpool.getConstantInteger(getIndex());
+            return String.valueOf((char) ch.getBytes());
         case PRIMITIVE_BOOLEAN:
-            final ConstantInteger bo = (ConstantInteger) cpool.getConstant(
-                    getIndex(), Const.CONSTANT_Integer);
+            final ConstantInteger bo = cpool.getConstantInteger(getIndex());
             if (bo.getBytes() == 0) {
                 return "false";
             }
             return "true";
         case STRING:
-            final ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(getIndex(),
-                    Const.CONSTANT_Utf8);
-            return cu8.getBytes();
+            return cpool.getConstantUtf8(getIndex()).getBytes();
         default:
-            throw new IllegalStateException("SimpleElementValue class does not know how to stringify type " + _type);
+            throw new IllegalStateException("SimpleElementValue class does not know how to stringify type " + type);
         }
     }
 
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
-        final int _type = super.getType();
-        dos.writeByte(_type); // u1 kind of value
-        switch (_type)
-        {
-        case PRIMITIVE_INT:
-        case PRIMITIVE_BYTE:
-        case PRIMITIVE_CHAR:
-        case PRIMITIVE_FLOAT:
-        case PRIMITIVE_LONG:
-        case PRIMITIVE_BOOLEAN:
-        case PRIMITIVE_SHORT:
-        case PRIMITIVE_DOUBLE:
-        case STRING:
-            dos.writeShort(getIndex());
-            break;
-        default:
-            throw new IllegalStateException("SimpleElementValue doesnt know how to write out type " + _type);
-        }
+    public String toString() {
+        return stringifyValue();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java
index dc030f5b226..e9ceed21957 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java
@@ -26,88 +26,87 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and represents a reference
- * to the source file of this class.  At most one SourceFile attribute
- * should appear per classfile.  The intention of this class is that it is
- * instantiated from the <em>Attribute.readAttribute()</em> method.
+ * This class is derived from <em>Attribute</em> and represents a reference to the source file of this class. At most
+ * one SourceFile attribute should appear per classfile. The intention of this class is that it is instantiated from the
+ * <em>Attribute.readAttribute()</em> method.
  *
- * @see     Attribute
+ * @see Attribute
  */
 public final class SourceFile extends Attribute {
 
     private int sourceFileIndex;
 
-
-    /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
-     */
-    public SourceFile(final SourceFile c) {
-        this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool());
-    }
-
-
     /**
      * Construct object from input stream.
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     *
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    SourceFile(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, input.readUnsignedShort(), constant_pool);
+    SourceFile(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, input.readUnsignedShort(), constantPool);
     }
 
-
     /**
-     * @param name_index Index in constant pool to CONSTANT_Utf8, which
-     * should represent the string "SourceFile".
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8, which should represent the string "SourceFile".
      * @param length Content length in bytes, the value should be 2.
-     * @param constantPool The constant pool that this attribute is
-     * associated with.
-     * @param sourceFileIndex Index in constant pool to CONSTANT_Utf8.  This
-     * string will be interpreted as the name of the file from which this
-     * class was compiled.  It will not be interpreted as indicating the name
-     * of the directory contqining the file or an absolute path; this
-     * information has to be supplied the consumer of this attribute - in
-     * many cases, the JVM.
+     * @param constantPool The constant pool that this attribute is associated with.
+     * @param sourceFileIndex Index in constant pool to CONSTANT_Utf8. This string will be interpreted as the name of the
+     *        file from which this class was compiled. It will not be interpreted as indicating the name of the directory
+     *        contqining the file or an absolute path; this information has to be supplied the consumer of this attribute -
+     *        in many cases, the JVM.
      */
-    public SourceFile(final int name_index, final int length, final int sourceFileIndex, final ConstantPool constantPool) {
-        super(Const.ATTR_SOURCE_FILE, name_index, length, constantPool);
-        this.sourceFileIndex = sourceFileIndex;
+    public SourceFile(final int nameIndex, final int length, final int sourceFileIndex, final ConstantPool constantPool) {
+        super(Const.ATTR_SOURCE_FILE, nameIndex, Args.require(length, 2, "SourceFile length attribute"), constantPool);
+        this.sourceFileIndex = Args.requireU2(sourceFileIndex, 0, constantPool.getLength(), "SourceFile source file index");
     }
 
+    /**
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
+     */
+    public SourceFile(final SourceFile c) {
+        this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool());
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitSourceFile(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        return (Attribute) clone();
+    }
 
     /**
      * Dump source file attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         file.writeShort(sourceFileIndex);
     }
 
-
     /**
      * @return Index in constant pool of source file name.
      */
@@ -115,25 +114,20 @@ public int getSourceFileIndex() {
         return sourceFileIndex;
     }
 
-
     /**
-     * @param sourceFileIndex
+     * @return Source file name.
      */
-    public void setSourceFileIndex( final int sourceFileIndex ) {
-        this.sourceFileIndex = sourceFileIndex;
+    public String getSourceFileName() {
+        return super.getConstantPool().getConstantUtf8(sourceFileIndex).getBytes();
     }
 
-
     /**
-     * @return Source file name.
+     * @param sourceFileIndex
      */
-    public String getSourceFileName() {
-        final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(sourceFileIndex,
-                Const.CONSTANT_Utf8);
-        return c.getBytes();
+    public void setSourceFileIndex(final int sourceFileIndex) {
+        this.sourceFileIndex = sourceFileIndex;
     }
 
-
     /**
      * @return String representation
      */
@@ -141,13 +135,4 @@ public String getSourceFileName() {
     public String toString() {
         return "SourceFile: " + getSourceFileName();
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        return (Attribute) clone();
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java
index e5f4b8c69b7..1f8ce5ea410 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java
@@ -23,142 +23,144 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class represents a stack map attribute used for
- * preverification of Java classes for the <a
- * href="https://www.oracle.com/java/technologies/javameoverview.html">Java Platform, Micro Edition</a>
- * (Java ME). This attribute is used by the <a
- * href="https://www.oracle.com/technetwork/java/embedded/javame/java-mobile/kvmwp-150240.pdf">KVM</a>
- * and contained within the Code attribute of a method. See CLDC specification
- * 5.3.1.2
+ * This class represents a stack map attribute used for preverification of Java classes for the
+ * <a href="http://java.sun.com/j2me/"> Java 2 Micro Edition</a> (J2ME). This attribute is used by the
+ * <a href="http://java.sun.com/products/cldc/">KVM</a> and contained within the Code attribute of a method. See CLDC
+ * specification 5.3.1.2
  *
- * @see     Code
- * @see     StackMapEntry
- * @see     StackMapType
+ * <pre>
+ * StackMapTable_attribute {
+ *   u2              attribute_name_index;
+ *   u4              attribute_length;
+ *   u2              number_of_entries;
+ *   stack_map_frame entries[number_of_entries];
+ * }
+ * </pre>
+ *
+ * @see Code
+ * @see StackMapEntry
+ * @see StackMapType
  * @LastModified: Oct 2020
  */
 public final class StackMap extends Attribute {
 
-    private StackMapEntry[] map; // Table of stack map entries
+    private StackMapEntry[] table; // Table of stack map entries
 
+    /**
+     * Construct object from input stream.
+     *
+     * @param nameIndex Index of name
+     * @param length Content length in bytes
+     * @param dataInput Input stream
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
+     */
+    StackMap(final int nameIndex, final int length, final DataInput dataInput, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (StackMapEntry[]) null, constantPool);
+        final int mapLength = dataInput.readUnsignedShort();
+        table = new StackMapEntry[mapLength];
+        for (int i = 0; i < mapLength; i++) {
+            table[i] = new StackMapEntry(dataInput, constantPool);
+        }
+    }
 
     /*
-     * @param name_index Index of name
+     * @param nameIndex Index of name
+     *
      * @param length Content length in bytes
+     *
      * @param map Table of stack map entries
-     * @param constant_pool Array of constants
+     *
+     * @param constantPool Array of constants
      */
-    public StackMap(final int name_index, final int length, final StackMapEntry[] map, final ConstantPool constant_pool) {
-        super(Const.ATTR_STACK_MAP, name_index, length, constant_pool);
-        this.map = map;
+    public StackMap(final int nameIndex, final int length, final StackMapEntry[] table, final ConstantPool constantPool) {
+        super(Const.ATTR_STACK_MAP, nameIndex, length, constantPool);
+        this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY;
+        Args.requireU2(this.table.length, "table.length");
     }
 
-
     /**
-     * Construct object from input stream.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
-     * @param name_index Index of name
-     * @param length Content length in bytes
-     * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param v Visitor object
      */
-    StackMap(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
-        this(name_index, length, (StackMapEntry[]) null, constant_pool);
-        final int map_length = input.readUnsignedShort();
-        map = new StackMapEntry[map_length];
-        for (int i = 0; i < map_length; i++) {
-            map[i] = new StackMapEntry(input, constant_pool);
-        }
+    @Override
+    public void accept(final Visitor v) {
+        v.visitStackMap(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final StackMap c = (StackMap) clone();
+        c.table = new StackMapEntry[table.length];
+        Arrays.setAll(c.table, i -> table[i].copy());
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump stack map table attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
-        file.writeShort(map.length);
-        for (final StackMapEntry entry : map) {
+        file.writeShort(table.length);
+        for (final StackMapEntry entry : table) {
             entry.dump(file);
         }
     }
 
+    public int getMapLength() {
+        return table.length;
+    }
 
     /**
      * @return Array of stack map entries
      */
     public StackMapEntry[] getStackMap() {
-        return map;
+        return table;
     }
 
-
     /**
-     * @param map Array of stack map entries
+     * @param table Array of stack map entries
      */
-    public void setStackMap( final StackMapEntry[] map ) {
-        this.map = map;
+    public void setStackMap(final StackMapEntry[] table) {
+        this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY;
         int len = 2; // Length of 'number_of_entries' field prior to the array of stack maps
-        for (final StackMapEntry element : map) {
+        for (final StackMapEntry element : this.table) {
             len += element.getMapEntrySize();
         }
         setLength(len);
     }
 
-
     /**
      * @return String representation.
      */
     @Override
     public String toString() {
         final StringBuilder buf = new StringBuilder("StackMap(");
-        for (int i = 0; i < map.length; i++) {
-            buf.append(map[i]);
-            if (i < map.length - 1) {
+        int runningOffset = -1; // no +1 on first entry
+        for (int i = 0; i < table.length; i++) {
+            runningOffset = table[i].getByteCodeOffset() + runningOffset + 1;
+            buf.append(String.format("%n@%03d %s", runningOffset, table[i]));
+            if (i < table.length - 1) {
                 buf.append(", ");
             }
         }
         buf.append(')');
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final StackMap c = (StackMap) clone();
-        c.map = new StackMapEntry[map.length];
-        for (int i = 0; i < map.length; i++) {
-            c.map[i] = map[i].copy();
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
-
-
-    /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitStackMap(this);
-    }
-
-
-    public int getMapLength() {
-        return map == null ? 0 : map.length;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java
index eaf233a079b..110e30392ab 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java
@@ -24,18 +24,33 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
+
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents a stack map entry recording the types of
- * local variables and the the of stack items at a given byte code offset.
- * See CLDC specification 5.3.1.2
+ * This class represents a stack map entry recording the types of local variables and the of stack items at a given
+ * byte code offset. See CLDC specification 5.3.1.2.
+ *
+ * See also https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.4
  *
- * @see     StackMap
- * @see     StackMapType
+ * <pre>
+ * union stack_map_frame {
+ *   same_frame;
+ *   same_locals_1_stack_item_frame;
+ *   same_locals_1_stack_item_frame_extended;
+ *   chop_frame;
+ *   same_frame_extended;
+ *   append_frame;
+ *   full_frame;
+ * }
+ * </pre>
+ * @see StackMap
+ * @see StackMapType
  */
-public final class StackMapEntry implements Node, Cloneable
-{
+public final class StackMapEntry implements Node, Cloneable {
+
+    static final StackMapEntry[] EMPTY_ARRAY = {};
 
     private int frameType;
     private int byteCodeOffset;
@@ -43,53 +58,49 @@ public final class StackMapEntry implements Node, Cloneable
     private StackMapType[] typesOfStackItems;
     private ConstantPool constantPool;
 
-
     /**
      * Construct object from input stream.
      *
-     * @param input Input stream
-     * @throws IOException
+     * @param dataInput Input stream
+     * @throws IOException if an I/O error occurs.
      */
-    StackMapEntry(final DataInput input, final ConstantPool constantPool) throws IOException {
-        this(input.readByte() & 0xFF, -1, null, null, constantPool);
+    StackMapEntry(final DataInput dataInput, final ConstantPool constantPool) throws IOException {
+        this(dataInput.readByte() & 0xFF, -1, null, null, constantPool);
 
         if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) {
             byteCodeOffset = frameType - Const.SAME_FRAME;
-        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME &&
-                   frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
             byteCodeOffset = frameType - Const.SAME_LOCALS_1_STACK_ITEM_FRAME;
-            typesOfStackItems = new StackMapType[1];
-            typesOfStackItems[0] = new StackMapType(input, constantPool);
+            typesOfStackItems = new StackMapType[] { new StackMapType(dataInput, constantPool) };
         } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
-            byteCodeOffset = input.readShort();
-            typesOfStackItems = new StackMapType[1];
-            typesOfStackItems[0] = new StackMapType(input, constantPool);
+            byteCodeOffset = dataInput.readUnsignedShort();
+            typesOfStackItems = new StackMapType[] { new StackMapType(dataInput, constantPool) };
         } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) {
-            byteCodeOffset = input.readShort();
+            byteCodeOffset = dataInput.readUnsignedShort();
         } else if (frameType == Const.SAME_FRAME_EXTENDED) {
-            byteCodeOffset = input.readShort();
+            byteCodeOffset = dataInput.readUnsignedShort();
         } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) {
-            byteCodeOffset = input.readShort();
-            final int number_of_locals = frameType - 251;
-            typesOfLocals = new StackMapType[number_of_locals];
-            for (int i = 0; i < number_of_locals; i++) {
-                typesOfLocals[i] = new StackMapType(input, constantPool);
+            byteCodeOffset = dataInput.readUnsignedShort();
+            final int numberOfLocals = frameType - 251;
+            typesOfLocals = new StackMapType[numberOfLocals];
+            for (int i = 0; i < numberOfLocals; i++) {
+                typesOfLocals[i] = new StackMapType(dataInput, constantPool);
             }
         } else if (frameType == Const.FULL_FRAME) {
-            byteCodeOffset = input.readShort();
-            final int number_of_locals = input.readShort();
-            typesOfLocals = new StackMapType[number_of_locals];
-            for (int i = 0; i < number_of_locals; i++) {
-                typesOfLocals[i] = new StackMapType(input, constantPool);
+            byteCodeOffset = dataInput.readUnsignedShort();
+            final int numberOfLocals = dataInput.readUnsignedShort();
+            typesOfLocals = new StackMapType[numberOfLocals];
+            for (int i = 0; i < numberOfLocals; i++) {
+                typesOfLocals[i] = new StackMapType(dataInput, constantPool);
             }
-            final int number_of_stack_items = input.readShort();
-            typesOfStackItems = new StackMapType[number_of_stack_items];
-            for (int i = 0; i < number_of_stack_items; i++) {
-                typesOfStackItems[i] = new StackMapType(input, constantPool);
+            final int numberOfStackItems = dataInput.readUnsignedShort();
+            typesOfStackItems = new StackMapType[numberOfStackItems];
+            for (int i = 0; i < numberOfStackItems; i++) {
+                typesOfStackItems[i] = new StackMapType(dataInput, constantPool);
             }
         } else {
             /* Can't happen */
-            throw new ClassFormatException ("Invalid frame type found while parsing stack map table: " + frameType);
+            throw new ClassFormatException("Invalid frame type found while parsing stack map table: " + frameType);
         }
     }
 
@@ -102,17 +113,21 @@ public final class StackMapEntry implements Node, Cloneable
      * @param numberOfStackItems NOT USED
      * @param typesOfStackItems array ot {@link StackMapType}s of stack items
      * @param constantPool the constant pool
-     * @deprecated Since 6.0, use {@link #StackMapEntry(int, int, StackMapType[], StackMapType[], ConstantPool)}
-     * instead
+     * @deprecated Since 6.0, use {@link #StackMapEntry(int, int, StackMapType[], StackMapType[], ConstantPool)} instead
      */
     @java.lang.Deprecated
-    public StackMapEntry(final int byteCodeOffset, final int numberOfLocals,
-            final StackMapType[] typesOfLocals, final int numberOfStackItems,
-            final StackMapType[] typesOfStackItems, final ConstantPool constantPool) {
+    public StackMapEntry(final int byteCodeOffset, final int numberOfLocals, final StackMapType[] typesOfLocals, final int numberOfStackItems,
+        final StackMapType[] typesOfStackItems, final ConstantPool constantPool) {
         this.byteCodeOffset = byteCodeOffset;
-        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : new StackMapType[0];
-        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0];
+        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY;
+        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY;
         this.constantPool = constantPool;
+        if (numberOfLocals < 0) {
+            throw new IllegalArgumentException("numberOfLocals < 0");
+        }
+        if (numberOfStackItems < 0) {
+            throw new IllegalArgumentException("numberOfStackItems < 0");
+        }
     }
 
     /**
@@ -124,29 +139,53 @@ public StackMapEntry(final int byteCodeOffset, final int numberOfLocals,
      * @param typesOfStackItems array ot {@link StackMapType}s of stack items
      * @param constantPool the constant pool
      */
-    public StackMapEntry(final int tag, final int byteCodeOffset,
-            final StackMapType[] typesOfLocals,
-            final StackMapType[] typesOfStackItems, final ConstantPool constantPool) {
+    public StackMapEntry(final int tag, final int byteCodeOffset, final StackMapType[] typesOfLocals, final StackMapType[] typesOfStackItems,
+        final ConstantPool constantPool) {
         this.frameType = tag;
         this.byteCodeOffset = byteCodeOffset;
-        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : new StackMapType[0];
-        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : new StackMapType[0];
+        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY;
+        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY;
         this.constantPool = constantPool;
     }
 
+    /**
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitStackMapEntry(this);
+    }
+
+    /**
+     * @return deep copy of this object
+     */
+    public StackMapEntry copy() {
+        StackMapEntry e;
+        try {
+            e = (StackMapEntry) clone();
+        } catch (final CloneNotSupportedException ex) {
+            throw new Error("Clone Not Supported");
+        }
+
+        e.typesOfLocals = new StackMapType[typesOfLocals.length];
+        Arrays.setAll(e.typesOfLocals, i -> typesOfLocals[i].copy());
+        e.typesOfStackItems = new StackMapType[typesOfStackItems.length];
+        Arrays.setAll(e.typesOfStackItems, i -> typesOfStackItems[i].copy());
+        return e;
+    }
 
     /**
      * Dump stack map entry
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.write(frameType);
-        if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) {
-            // nothing to be done
-        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME &&
-                   frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+        if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
             typesOfStackItems[0].dump(file);
         } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
             file.writeShort(byteCodeOffset);
@@ -170,63 +209,26 @@ public void dump( final DataOutputStream file ) throws IOException {
             for (final StackMapType type : typesOfStackItems) {
                 type.dump(file);
             }
-        } else {
+        } else if (!(frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX)) {
             /* Can't happen */
-            throw new ClassFormatException ("Invalid Stack map table tag: " + frameType);
+            throw new ClassFormatException("Invalid Stack map table tag: " + frameType);
         }
     }
 
+    public int getByteCodeOffset() {
+        return byteCodeOffset;
+    }
 
     /**
-     * @return String representation.
+     * @return Constant pool used by this object.
      */
-    @Override
-    public String toString() {
-        final StringBuilder buf = new StringBuilder(64);
-        buf.append("(");
-        if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) {
-            buf.append("SAME");
-        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME &&
-                  frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
-            buf.append("SAME_LOCALS_1_STACK");
-        } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
-            buf.append("SAME_LOCALS_1_STACK_EXTENDED");
-        } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) {
-            buf.append("CHOP ").append(String.valueOf(251-frameType));
-        } else if (frameType == Const.SAME_FRAME_EXTENDED) {
-            buf.append("SAME_EXTENDED");
-        } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) {
-            buf.append("APPEND ").append(String.valueOf(frameType-251));
-        } else if (frameType == Const.FULL_FRAME) {
-            buf.append("FULL");
-        } else {
-            buf.append("UNKNOWN (").append(frameType).append(")");
-        }
-        buf.append(", offset delta=").append(byteCodeOffset);
-        if (typesOfLocals.length > 0) {
-            buf.append(", locals={");
-            for (int i = 0; i < typesOfLocals.length; i++) {
-                buf.append(typesOfLocals[i]);
-                if (i < typesOfLocals.length - 1) {
-                    buf.append(", ");
-                }
-            }
-            buf.append("}");
-        }
-        if (typesOfStackItems.length > 0) {
-            buf.append(", stack items={");
-            for (int i = 0; i < typesOfStackItems.length; i++) {
-                buf.append(typesOfStackItems[i]);
-                if (i < typesOfStackItems.length - 1) {
-                    buf.append(", ");
-                }
-            }
-            buf.append("}");
-        }
-        buf.append(")");
-        return buf.toString();
+    public ConstantPool getConstantPool() {
+        return constantPool;
     }
 
+    public int getFrameType() {
+        return frameType;
+    }
 
     /**
      * Calculate stack map entry size
@@ -235,205 +237,183 @@ public String toString() {
     int getMapEntrySize() {
         if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) {
             return 1;
-        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME &&
-                   frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+        }
+        if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
             return 1 + (typesOfStackItems[0].hasIndex() ? 3 : 1);
-        } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
+        }
+        if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
             return 3 + (typesOfStackItems[0].hasIndex() ? 3 : 1);
-        } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) {
-            return 3;
-        } else if (frameType == Const.SAME_FRAME_EXTENDED) {
+        }
+        if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX || frameType == Const.SAME_FRAME_EXTENDED) {
             return 3;
-        } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) {
+        }
+        if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) {
             int len = 3;
-            for (final StackMapType types_of_local : typesOfLocals) {
-                len += types_of_local.hasIndex() ? 3 : 1;
-            }
-            return len;
-        } else if (frameType == Const.FULL_FRAME) {
-            int len = 7;
-            for (final StackMapType types_of_local : typesOfLocals) {
-                len += types_of_local.hasIndex() ? 3 : 1;
-            }
-            for (final StackMapType types_of_stack_item : typesOfStackItems) {
-                len += types_of_stack_item.hasIndex() ? 3 : 1;
+            for (final StackMapType typesOfLocal : typesOfLocals) {
+                len += typesOfLocal.hasIndex() ? 3 : 1;
             }
             return len;
-        } else {
+        }
+        if (frameType != Const.FULL_FRAME) {
             throw new IllegalStateException("Invalid StackMap frameType: " + frameType);
         }
+        int len = 7;
+        for (final StackMapType typesOfLocal : typesOfLocals) {
+            len += typesOfLocal.hasIndex() ? 3 : 1;
+        }
+        for (final StackMapType typesOfStackItem : typesOfStackItems) {
+            len += typesOfStackItem.hasIndex() ? 3 : 1;
+        }
+        return len;
     }
 
+    public int getNumberOfLocals() {
+        return typesOfLocals.length;
+    }
 
-    public void setFrameType( final int f ) {
-        if (f >= Const.SAME_FRAME && f <= Const.SAME_FRAME_MAX) {
-            byteCodeOffset = f - Const.SAME_FRAME;
-        } else if (f >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME &&
-                   f <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
-            byteCodeOffset = f - Const.SAME_LOCALS_1_STACK_ITEM_FRAME;
-        } else if (f == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (f >= Const.CHOP_FRAME && f <= Const.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (f == Const.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (f >= Const.APPEND_FRAME && f <= Const.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (f == Const.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock
-        } else {
-            throw new IllegalArgumentException("Invalid StackMap frameType");
-        }
-        frameType = f;
+    public int getNumberOfStackItems() {
+        return typesOfStackItems.length;
     }
 
+    public StackMapType[] getTypesOfLocals() {
+        return typesOfLocals;
+    }
 
-    public int getFrameType() {
-        return frameType;
+    public StackMapType[] getTypesOfStackItems() {
+        return typesOfStackItems;
     }
 
+    private boolean invalidFrameType(final int f) {
+        // @formatter:off
+        return f != Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED
+            && !(f >= Const.CHOP_FRAME && f <= Const.CHOP_FRAME_MAX)
+            && f != Const.SAME_FRAME_EXTENDED
+            && !(f >= Const.APPEND_FRAME && f <= Const.APPEND_FRAME_MAX)
+            && f != Const.FULL_FRAME;
+        // @formatter:on
+    }
 
-    public void setByteCodeOffset( final int new_offset ) {
-        if (new_offset < 0 || new_offset > 32767) {
-            throw new IllegalArgumentException("Invalid StackMap offset: " + new_offset);
+    public void setByteCodeOffset(final int newOffset) {
+        if (newOffset < 0 || newOffset > 32767) {
+            throw new IllegalArgumentException("Invalid StackMap offset: " + newOffset);
         }
 
-        if (frameType >= Const.SAME_FRAME &&
-            frameType <= Const.SAME_FRAME_MAX) {
-            if (new_offset > Const.SAME_FRAME_MAX) {
+        if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) {
+            if (newOffset > Const.SAME_FRAME_MAX) {
                 frameType = Const.SAME_FRAME_EXTENDED;
             } else {
-                frameType = new_offset;
+                frameType = newOffset;
             }
-        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME &&
-                   frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
-            if (new_offset > Const.SAME_FRAME_MAX) {
+        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+            if (newOffset > Const.SAME_FRAME_MAX) {
                 frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED;
             } else {
-                frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME + new_offset;
+                frameType = Const.SAME_LOCALS_1_STACK_ITEM_FRAME + newOffset;
             }
-        } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (frameType >= Const.CHOP_FRAME &&
-                   frameType <= Const.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (frameType == Const.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (frameType >= Const.APPEND_FRAME &&
-                   frameType <= Const.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
-        } else if (frameType == Const.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock
-        } else {
+        } else if (invalidFrameType(frameType)) {
             throw new IllegalStateException("Invalid StackMap frameType: " + frameType);
         }
-        byteCodeOffset = new_offset;
+        byteCodeOffset = newOffset;
     }
 
-
     /**
-     * Update the distance (as an offset delta) from this StackMap
-     * entry to the next.  Note that this might cause the the
-     * frame type to change.  Note also that delta may be negative.
-     *
-     * @param delta offset delta
+     * @param constantPool Constant pool to be used for this object.
      */
-    public void updateByteCodeOffset(final int delta) {
-        setByteCodeOffset(byteCodeOffset + delta);
+    public void setConstantPool(final ConstantPool constantPool) {
+        this.constantPool = constantPool;
     }
 
-
-    public int getByteCodeOffset() {
-        return byteCodeOffset;
+    public void setFrameType(final int ft) {
+        if (ft >= Const.SAME_FRAME && ft <= Const.SAME_FRAME_MAX) {
+            byteCodeOffset = ft - Const.SAME_FRAME;
+        } else if (ft >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && ft <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+            byteCodeOffset = ft - Const.SAME_LOCALS_1_STACK_ITEM_FRAME;
+        } else if (invalidFrameType(ft)) {
+            throw new IllegalArgumentException("Invalid StackMap frameType");
+        }
+        frameType = ft;
     }
 
-
     /**
      *
      * @deprecated since 6.0
      */
     @java.lang.Deprecated
-    public void setNumberOfLocals( final int n ) { // TODO unused
-    }
-
-
-    public int getNumberOfLocals() {
-        return typesOfLocals.length;
+    public void setNumberOfLocals(final int n) { // TODO unused
     }
 
-
-    public void setTypesOfLocals( final StackMapType[] types ) {
-        typesOfLocals = types != null ? types : new StackMapType[0];
-    }
-
-
-    public StackMapType[] getTypesOfLocals() {
-        return typesOfLocals;
-    }
-
-
     /**
      *
      * @deprecated since 6.0
      */
     @java.lang.Deprecated
-    public void setNumberOfStackItems( final int n ) { // TODO unused
-    }
-
-
-    public int getNumberOfStackItems() {
-        return typesOfStackItems.length;
+    public void setNumberOfStackItems(final int n) { // TODO unused
     }
 
-
-    public void setTypesOfStackItems( final StackMapType[] types ) {
-        typesOfStackItems = types != null ? types : new StackMapType[0];
+    public void setTypesOfLocals(final StackMapType[] types) {
+        typesOfLocals = types != null ? types : StackMapType.EMPTY_ARRAY;
     }
 
-
-    public StackMapType[] getTypesOfStackItems() {
-        return typesOfStackItems;
+    public void setTypesOfStackItems(final StackMapType[] types) {
+        typesOfStackItems = types != null ? types : StackMapType.EMPTY_ARRAY;
     }
 
-
     /**
-     * @return deep copy of this object
+     * @return String representation.
      */
-    public StackMapEntry copy() {
-        StackMapEntry e;
-        try {
-            e = (StackMapEntry) clone();
-        } catch (final CloneNotSupportedException ex) {
-            throw new Error("Clone Not Supported");
+    @Override
+    public String toString() {
+        final StringBuilder buf = new StringBuilder(64);
+        buf.append("(");
+        if (frameType >= Const.SAME_FRAME && frameType <= Const.SAME_FRAME_MAX) {
+            buf.append("SAME");
+        } else if (frameType >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME && frameType <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+            buf.append("SAME_LOCALS_1_STACK");
+        } else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
+            buf.append("SAME_LOCALS_1_STACK_EXTENDED");
+        } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) {
+            buf.append("CHOP ").append(String.valueOf(251 - frameType));
+        } else if (frameType == Const.SAME_FRAME_EXTENDED) {
+            buf.append("SAME_EXTENDED");
+        } else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) {
+            buf.append("APPEND ").append(String.valueOf(frameType - 251));
+        } else if (frameType == Const.FULL_FRAME) {
+            buf.append("FULL");
+        } else {
+            buf.append("UNKNOWN (").append(frameType).append(")");
         }
-
-        e.typesOfLocals = new StackMapType[typesOfLocals.length];
-        for (int i = 0; i < typesOfLocals.length; i++) {
-            e.typesOfLocals[i] = typesOfLocals[i].copy();
+        buf.append(", offset delta=").append(byteCodeOffset);
+        if (typesOfLocals.length > 0) {
+            buf.append(", locals={");
+            for (int i = 0; i < typesOfLocals.length; i++) {
+                buf.append(typesOfLocals[i]);
+                if (i < typesOfLocals.length - 1) {
+                    buf.append(", ");
+                }
+            }
+            buf.append("}");
         }
-        e.typesOfStackItems = new StackMapType[typesOfStackItems.length];
-        for (int i = 0; i < typesOfStackItems.length; i++) {
-            e.typesOfStackItems[i] = typesOfStackItems[i].copy();
+        if (typesOfStackItems.length > 0) {
+            buf.append(", stack items={");
+            for (int i = 0; i < typesOfStackItems.length; i++) {
+                buf.append(typesOfStackItems[i]);
+                if (i < typesOfStackItems.length - 1) {
+                    buf.append(", ");
+                }
+            }
+            buf.append("}");
         }
-        return e;
+        buf.append(")");
+        return buf.toString();
     }
 
-
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Update the distance (as an offset delta) from this StackMap entry to the next. Note that this might cause the
+     * frame type to change. Note also that delta may be negative.
      *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitStackMapEntry(this);
-    }
-
-
-    /**
-     * @return Constant pool used by this object.
-     */
-    public ConstantPool getConstantPool() {
-        return constantPool;
-    }
-
-
-    /**
-     * @param constantPool Constant pool to be used for this object.
+     * @param delta offset delta
      */
-    public void setConstantPool( final ConstantPool constantPool ) {
-        this.constantPool = constantPool;
+    public void updateByteCodeOffset(final int delta) {
+        setByteCodeOffset(byteCodeOffset + delta);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java
index 8d7c3871a09..4575b31dfce 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java
@@ -28,143 +28,135 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents the type of a local variable or item on stack
- * used in the StackMap entries.
+ * This class represents the type of a local variable or item on stack used in the StackMap entries.
  *
- * @see     StackMapEntry
- * @see     StackMap
- * @see     Const
+ * @see StackMapEntry
+ * @see StackMap
+ * @see Const
  */
 public final class StackMapType implements Cloneable {
 
+    public static final StackMapType[] EMPTY_ARRAY = {}; // must be public because BCELifier code generator writes calls to it
+
     private byte type;
     private int index = -1; // Index to CONSTANT_Class or offset
     private ConstantPool constantPool;
 
-
-    /**
-     * Construct object from file stream.
-     * @param file Input stream
-     * @throws IOException
-     */
-    StackMapType(final DataInput file, final ConstantPool constant_pool) throws IOException {
-        this(file.readByte(), -1, constant_pool);
-        if (hasIndex()) {
-            this.index = file.readShort();
-        }
-        this.constantPool = constant_pool;
-    }
-
-
     /**
      * @param type type tag as defined in the Constants interface
      * @param index index to constant pool, or byte code offset
      */
-    public StackMapType(final byte type, final int index, final ConstantPool constant_pool) {
-        if ((type < Const.ITEM_Bogus) || (type > Const.ITEM_NewObject)) {
-            throw new IllegalArgumentException("Illegal type for StackMapType: " + type);
-        }
-        this.type = type;
+    public StackMapType(final byte type, final int index, final ConstantPool constantPool) {
+        this.type = checkType(type);
         this.index = index;
-        this.constantPool = constant_pool;
+        this.constantPool = constantPool;
     }
 
-
-    public void setType( final byte t ) {
-        if ((t < Const.ITEM_Bogus) || (t > Const.ITEM_NewObject)) {
-            throw new IllegalArgumentException("Illegal type for StackMapType: " + t);
+    /**
+     * Construct object from file stream.
+     *
+     * @param file Input stream
+     * @throws IOException if an I/O error occurs.
+     */
+    StackMapType(final DataInput file, final ConstantPool constantPool) throws IOException {
+        this(file.readByte(), -1, constantPool);
+        if (hasIndex()) {
+            this.index = file.readUnsignedShort();
         }
-        type = t;
+        this.constantPool = constantPool;
     }
 
-
-    public byte getType() {
+    private byte checkType(final byte type) {
+        if (type < Const.ITEM_Bogus || type > Const.ITEM_NewObject) {
+            throw new ClassFormatException("Illegal type for StackMapType: " + type);
+        }
         return type;
     }
 
-
-    public void setIndex( final int t ) {
-        index = t;
-    }
-
-
-    /** @return index to constant pool if type == ITEM_Object, or offset
-     * in byte code, if type == ITEM_NewObject, and -1 otherwise
+    /**
+     * @return deep copy of this object
      */
-    public int getIndex() {
-        return index;
+    public StackMapType copy() {
+        try {
+            return (StackMapType) clone();
+        } catch (final CloneNotSupportedException e) {
+            // TODO should this throw?
+        }
+        return null;
     }
 
-
     /**
      * Dump type entries to file.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         file.writeByte(type);
         if (hasIndex()) {
             file.writeShort(getIndex());
         }
     }
 
+    /**
+     * @return Constant pool used by this object.
+     */
+    public ConstantPool getConstantPool() {
+        return constantPool;
+    }
 
-    /** @return true, if type is either ITEM_Object or ITEM_NewObject
+    /**
+     * @return index to constant pool if type == ITEM_Object, or offset in byte code, if type == ITEM_NewObject, and -1
+     *         otherwise
+     */
+    public int getIndex() {
+        return index;
+    }
+
+    public byte getType() {
+        return type;
+    }
+
+    /**
+     * @return true, if type is either ITEM_Object or ITEM_NewObject
      */
     public boolean hasIndex() {
         return type == Const.ITEM_Object || type == Const.ITEM_NewObject;
     }
 
-
     private String printIndex() {
         if (type == Const.ITEM_Object) {
             if (index < 0) {
                 return ", class=<unknown>";
             }
             return ", class=" + constantPool.constantToString(index, Const.CONSTANT_Class);
-        } else if (type == Const.ITEM_NewObject) {
+        }
+        if (type == Const.ITEM_NewObject) {
             return ", offset=" + index;
-        } else {
-            return "";
         }
+        return "";
     }
 
-
     /**
-     * @return String representation
+     * @param constantPool Constant pool to be used for this object.
      */
-    @Override
-    public String toString() {
-        return "(type=" + Const.getItemName(type) + printIndex() + ")";
+    public void setConstantPool(final ConstantPool constantPool) {
+        this.constantPool = constantPool;
     }
 
-
-    /**
-     * @return deep copy of this object
-     */
-    public StackMapType copy() {
-        try {
-            return (StackMapType) clone();
-        } catch (final CloneNotSupportedException e) {
-            // TODO should this throw?
-        }
-        return null;
+    public void setIndex(final int index) {
+        this.index = index;
     }
 
-
-    /**
-     * @return Constant pool used by this object.
-     */
-    public ConstantPool getConstantPool() {
-        return constantPool;
+    public void setType(final byte type) {
+        this.type = checkType(type);
     }
 
-
     /**
-     * @param constantPool Constant pool to be used for this object.
+     * @return String representation
      */
-    public void setConstantPool( final ConstantPool constantPool ) {
-        this.constantPool = constantPool;
+    @Override
+    public String toString() {
+        return "(type=" + Const.getItemName(type) + printIndex() + ")";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java
index 4cd5827f950..3683fd6437e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java
@@ -26,58 +26,42 @@
 import java.io.IOException;
 
 import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.util.Args;
 
 /**
- * This class is derived from <em>Attribute</em> and declares this class as
- * `synthetic', i.e., it needs special handling.  The JVM specification
- * states "A class member that does not appear in the source code must be
- * marked using a Synthetic attribute."  It may appear in the ClassFile
- * attribute table, a field_info table or a method_info table.  This class
- * is intended to be instantiated from the
- * <em>Attribute.readAttribute()</em> method.
+ * This class is derived from <em>Attribute</em> and declares this class as 'synthetic', i.e., it needs special
+ * handling. The JVM specification states "A class member that does not appear in the source code must be marked using a
+ * Synthetic attribute." It may appear in the ClassFile attribute table, a field_info table or a method_info table. This
+ * class is intended to be instantiated from the <em>Attribute.readAttribute()</em> method.
  *
- * @see     Attribute
+ * @see Attribute
  */
 public final class Synthetic extends Attribute {
 
     private byte[] bytes;
 
-
-    /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use copy() for a physical copy.
-     */
-    public Synthetic(final Synthetic c) {
-        this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
-    }
-
-
     /**
-     * @param name_index Index in constant pool to CONSTANT_Utf8, which
-     * should represent the string "Synthetic".
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8, which should represent the string "Synthetic".
      * @param length Content length in bytes - should be zero.
      * @param bytes Attribute contents
-     * @param constant_pool The constant pool this attribute is associated
-     * with.
+     * @param constantPool The constant pool this attribute is associated with.
      */
-    public Synthetic(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) {
-        super(Const.ATTR_SYNTHETIC, name_index, length, constant_pool);
+    public Synthetic(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) {
+        super(Const.ATTR_SYNTHETIC, nameIndex, Args.require0(length, "Synthetic attribute length"), constantPool);
         this.bytes = bytes;
     }
 
-
     /**
      * Construct object from input stream.
      *
-     * @param name_index Index in constant pool to CONSTANT_Utf8
+     * @param nameIndex Index in constant pool to CONSTANT_Utf8
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    Synthetic(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, (byte[]) null, constant_pool);
+    Synthetic(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (byte[]) null, constantPool);
         if (length > 0) {
             bytes = new byte[length];
             input.readFully(bytes);
@@ -85,35 +69,54 @@ public Synthetic(final int name_index, final int length, final byte[] bytes, fin
         }
     }
 
+    /**
+     * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a
+     * physical copy.
+     *
+     * @param c Source to copy.
+     */
+    public Synthetic(final Synthetic c) {
+        this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitSynthetic(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final Synthetic c = (Synthetic) clone();
+        if (bytes != null) {
+            c.bytes = bytes.clone();
+        }
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
      * Dump source file attribute to file stream in binary format.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         if (super.getLength() > 0) {
             file.write(bytes, 0, super.getLength());
         }
     }
 
-
     /**
      * @return data bytes.
      */
@@ -121,15 +124,13 @@ public byte[] getBytes() {
         return bytes;
     }
 
-
     /**
      * @param bytes
      */
-    public void setBytes( final byte[] bytes ) {
+    public void setBytes(final byte[] bytes) {
         this.bytes = bytes;
     }
 
-
     /**
      * @return String representation.
      */
@@ -141,19 +142,4 @@ public String toString() {
         }
         return buf.toString();
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final Synthetic c = (Synthetic) clone();
-        if (bytes != null) {
-            c.bytes = new byte[bytes.length];
-            System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java
index 9b93a91e0c9..3500e472c85 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java
@@ -24,19 +24,15 @@
 import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Arrays;
 
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This class represents a reference to an unknown (i.e.,
- * application-specific) attribute of a class.  It is instantiated from the
- * {@link Attribute#readAttribute(java.io.DataInput, ConstantPool)} method.
- * Applications that need to read in application-specific attributes should create an
- * {@link UnknownAttributeReader} implementation and attach it via
+ * This class represents a reference to an unknown (i.e., application-specific) attribute of a class. It is instantiated
+ * from the {@link Attribute#readAttribute(java.io.DataInput, ConstantPool)} method. Applications that need to read in
+ * application-specific attributes should create an {@link UnknownAttributeReader} implementation and attach it via
  * {@link Attribute#addAttributeReader(String, UnknownAttributeReader)}.
-
  *
  * @see Attribute
  * @see UnknownAttributeReader
@@ -44,93 +40,87 @@
 public final class Unknown extends Attribute {
 
     private byte[] bytes;
-    private final String name;
-    private static final Map<String, Unknown> unknownAttributes = new HashMap<>();
-
-
-    /** @return array of unknown attributes, but just one for each kind.
-     */
-    static Unknown[] getUnknownAttributes() {
-        final Unknown[] unknowns = new Unknown[unknownAttributes.size()];
-        unknownAttributes.values().toArray(unknowns);
-        unknownAttributes.clear();
-        return unknowns;
-    }
-
-
-    /**
-     * Initialize from another object. Note that both objects use the same
-     * references (shallow copy). Use clone() for a physical copy.
-     */
-    public Unknown(final Unknown c) {
-        this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
-    }
 
+    private final String name;
 
     /**
-     * Create a non-standard attribute.
+     * Constructs a new instance for a non-standard attribute.
      *
-     * @param name_index Index in constant pool
+     * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param bytes Attribute contents
-     * @param constant_pool Array of constants
+     * @param constantPool Array of constants
      */
-    public Unknown(final int name_index, final int length, final byte[] bytes, final ConstantPool constant_pool) {
-        super(Const.ATTR_UNKNOWN, name_index, length, constant_pool);
+    public Unknown(final int nameIndex, final int length, final byte[] bytes, final ConstantPool constantPool) {
+        super(Const.ATTR_UNKNOWN, nameIndex, length, constantPool);
         this.bytes = bytes;
-        name = ((ConstantUtf8) constant_pool.getConstant(name_index, Const.CONSTANT_Utf8))
-                .getBytes();
-        unknownAttributes.put(name, this);
+        this.name = constantPool.getConstantUtf8(nameIndex).getBytes();
     }
 
-
     /**
-     * Construct object from input stream.
+     * Constructs a new instance from an input stream.
      *
-     * @param name_index Index in constant pool
+     * @param nameIndex Index in constant pool
      * @param length Content length in bytes
      * @param input Input stream
-     * @param constant_pool Array of constants
-     * @throws IOException
+     * @param constantPool Array of constants
+     * @throws IOException if an I/O error occurs.
      */
-    Unknown(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
-            throws IOException {
-        this(name_index, length, (byte[]) null, constant_pool);
+    Unknown(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException {
+        this(nameIndex, length, (byte[]) null, constantPool);
         if (length > 0) {
             bytes = new byte[length];
             input.readFully(bytes);
         }
     }
 
+    /**
+     * Constructs a new instance from another instance. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.
+     *
+     * @param unknown Source.
+     */
+    public Unknown(final Unknown unknown) {
+        this(unknown.getNameIndex(), unknown.getLength(), unknown.getBytes(), unknown.getConstantPool());
+    }
 
     /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
+     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
+     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitUnknown(this);
     }
 
+    /**
+     * @return deep copy of this attribute
+     */
+    @Override
+    public Attribute copy(final ConstantPool constantPool) {
+        final Unknown c = (Unknown) clone();
+        if (bytes != null) {
+            c.bytes = bytes.clone();
+        }
+        c.setConstantPool(constantPool);
+        return c;
+    }
 
     /**
-     * Dump unknown bytes to file stream.
+     * Dumps unknown bytes to file stream.
      *
      * @param file Output file stream
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void dump( final DataOutputStream file ) throws IOException {
+    public void dump(final DataOutputStream file) throws IOException {
         super.dump(file);
         if (super.getLength() > 0) {
             file.write(bytes, 0, super.getLength());
         }
     }
 
-
     /**
      * @return data bytes.
      */
@@ -138,7 +128,6 @@ public byte[] getBytes() {
         return bytes;
     }
 
-
     /**
      * @return name of attribute.
      */
@@ -147,15 +136,13 @@ public String getName() {
         return name;
     }
 
-
     /**
      * @param bytes the bytes to set
      */
-    public void setBytes( final byte[] bytes ) {
+    public void setBytes(final byte[] bytes) {
         this.bytes = bytes;
     }
 
-
     /**
      * @return String representation.
      */
@@ -165,28 +152,13 @@ public String toString() {
             return "(Unknown attribute " + name + ")";
         }
         String hex;
-        if (super.getLength() > 10) {
-            final byte[] tmp = new byte[10];
-            System.arraycopy(bytes, 0, tmp, 0, 10);
+        final int limit = 10;
+        if (super.getLength() > limit) {
+            final byte[] tmp = Arrays.copyOf(bytes, limit);
             hex = Utility.toHexString(tmp) + "... (truncated)";
         } else {
             hex = Utility.toHexString(bytes);
         }
         return "(Unknown attribute " + name + ": " + hex + ")";
     }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    @Override
-    public Attribute copy( final ConstantPool _constant_pool ) {
-        final Unknown c = (Unknown) clone();
-        if (bytes != null) {
-            c.bytes = new byte[bytes.length];
-            System.arraycopy(bytes, 0, c.bytes, 0, bytes.length);
-        }
-        c.setConstantPool(_constant_pool);
-        return c;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java
index f08266e5ba2..2c1cae9ee3d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/UnknownAttributeReader.java
@@ -22,9 +22,8 @@
 package com.sun.org.apache.bcel.internal.classfile;
 
 /**
- * Unknown (non-standard) attributes may be read via user-defined factory
- * objects that can be registered with the Attribute.addAttributeReader
- * method. These factory objects should implement this interface.
+ * Unknown (non-standard) attributes may be read via user-defined factory objects that can be registered with the
+ * Attribute.addAttributeReader method. These factory objects should implement this interface.
  *
  * @see Attribute
  * @since 6.0
@@ -32,22 +31,20 @@
 public interface UnknownAttributeReader {
 
     /**
-     * When this attribute reader is added via the static method Attribute.addAttributeReader,
-     * an attribute name is associated with it. As the class file parser parses attributes,
-     * it will call various AttributeReaders based on the name of the attributes it is constructing.
+     * When this attribute reader is added via the static method Attribute.addAttributeReader, an attribute name is
+     * associated with it. As the class file parser parses attributes, it will call various AttributeReaders based on the
+     * name of the attributes it is constructing.
      *
-     * @param name_index    An index into the constant pool, indexing a ConstantUtf8
-     *                      that represents the name of the attribute.
-     * @param length        The length of the data contained in the attribute. This is written
-     *                      into the constant pool and should agree with what the factory expects the length to be.
-     * @param file          This is the data input that the factory needs to read its data from.
-     * @param constant_pool This is the constant pool associated with the Attribute that we are constructing.
+     * @param nameIndex An index into the constant pool, indexing a ConstantUtf8 that represents the name of the attribute.
+     * @param length The length of the data contained in the attribute. This is written into the constant pool and should
+     *        agree with what the factory expects the length to be.
+     * @param file This is the data input that the factory needs to read its data from.
+     * @param constantPool This is the constant pool associated with the Attribute that we are constructing.
      *
-     * @return The user-defined AttributeReader should take this data and use
-     * it to construct an attribute.  In the case of errors, a null can be
-     * returned which will cause the parsing of the class file to fail.
+     * @return The user-defined AttributeReader should take this data and use it to construct an attribute. In the case of
+     *         errors, a null can be returned which will cause the parsing of the class file to fail.
      *
      * @see Attribute#addAttributeReader(String, UnknownAttributeReader)
      */
-    Attribute createAttribute( int name_index, int length, java.io.DataInput file, ConstantPool constant_pool );
+    Attribute createAttribute(int nameIndex, int length, java.io.DataInput file, ConstantPool constantPool);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java
index f2ba13aeb54..12dbbe4828a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -31,6 +31,7 @@
 import java.io.Reader;
 import java.io.Writer;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Locale;
 import java.util.zip.GZIPInputStream;
@@ -42,78 +43,167 @@
 /**
  * Utility functions that do not really belong to any class in particular.
  *
- * @LastModified: June 2021
+ * @LastModified: Feb 2023
  */
 // @since 6.0 methods are no longer final
 public abstract class Utility {
 
-    private static int unwrap( final ThreadLocal<Integer> tl ) {
-        return tl.get();
-    }
+    /**
+     * Decode characters into bytes. Used by <a href="Utility.html#decode(java.lang.String, boolean)">decode()</a>
+     */
+    private static class JavaReader extends FilterReader {
 
-    private static void wrap( final ThreadLocal<Integer> tl, final int value ) {
-        tl.set(value);
+        public JavaReader(final Reader in) {
+            super(in);
+        }
+
+        @Override
+        public int read() throws IOException {
+            final int b = in.read();
+            if (b != ESCAPE_CHAR) {
+                return b;
+            }
+            final int i = in.read();
+            if (i < 0) {
+                return -1;
+            }
+            if (i >= '0' && i <= '9' || i >= 'a' && i <= 'f') { // Normal escape
+                final int j = in.read();
+                if (j < 0) {
+                    return -1;
+                }
+                final char[] tmp = {(char) i, (char) j};
+                return Integer.parseInt(new String(tmp), 16);
+            }
+            return MAP_CHAR[i];
+        }
+
+        @Override
+        public int read(final char[] cbuf, final int off, final int len) throws IOException {
+            for (int i = 0; i < len; i++) {
+                cbuf[off + i] = (char) read();
+            }
+            return len;
+        }
     }
 
-    /* How many chars have been consumed
-     * during parsing in typeSignatureToString().
-     * Read by methodSignatureToString().
-     * Set by side effect, but only internally.
+    /**
+     * Encode bytes into valid java identifier characters. Used by
+     * <a href="Utility.html#encode(byte[], boolean)">encode()</a>
      */
-    private static ThreadLocal<Integer> consumed_chars = new ThreadLocal<Integer>() {
+    private static class JavaWriter extends FilterWriter {
+
+        public JavaWriter(final Writer out) {
+            super(out);
+        }
+
+        @Override
+        public void write(final char[] cbuf, final int off, final int len) throws IOException {
+            for (int i = 0; i < len; i++) {
+                write(cbuf[off + i]);
+            }
+        }
+
+        @Override
+        public void write(final int b) throws IOException {
+            if (isJavaIdentifierPart((char) b) && b != ESCAPE_CHAR) {
+                out.write(b);
+            } else {
+                out.write(ESCAPE_CHAR); // Escape character
+                // Special escape
+                if (b >= 0 && b < FREE_CHARS) {
+                    out.write(CHAR_MAP[b]);
+                } else { // Normal escape
+                    final char[] tmp = Integer.toHexString(b).toCharArray();
+                    if (tmp.length == 1) {
+                        out.write('0');
+                        out.write(tmp[0]);
+                    } else {
+                        out.write(tmp[0]);
+                        out.write(tmp[1]);
+                    }
+                }
+            }
+        }
+
         @Override
-        protected Integer initialValue() {
-            return 0;
+        public void write(final String str, final int off, final int len) throws IOException {
+            write(str.toCharArray(), off, len);
         }
-    };
-
-    /* The `WIDE' instruction is used in the
-     * byte code to allow 16-bit wide indices
-     * for local variables. This opcode
-     * precedes an `ILOAD', e.g.. The opcode
-     * immediately following takes an extra
-     * byte which is combined with the
-     * following byte to form a
-     * 16-bit value.
+    }
+
+    /*
+     * How many chars have been consumed during parsing in typeSignatureToString(). Read by methodSignatureToString(). Set
+     * by side effect, but only internally.
+     */
+    private static final ThreadLocal<Integer> CONSUMER_CHARS = ThreadLocal.withInitial(() -> Integer.valueOf(0));
+
+    /*
+     * The 'WIDE' instruction is used in the byte code to allow 16-bit wide indices for local variables. This opcode
+     * precedes an 'ILOAD', e.g.. The opcode immediately following takes an extra byte which is combined with the following
+     * byte to form a 16-bit value.
      */
-    private static boolean wide = false;
+    private static boolean wide;
 
+    // A-Z, g-z, _, $
+    private static final int FREE_CHARS = 48;
+
+    private static final int[] CHAR_MAP = new int[FREE_CHARS];
+
+    private static final int[] MAP_CHAR = new int[256]; // Reverse map
+
+    private static final char ESCAPE_CHAR = '$';
+
+    static {
+        int j = 0;
+        for (int i = 'A'; i <= 'Z'; i++) {
+            CHAR_MAP[j] = i;
+            MAP_CHAR[i] = j;
+            j++;
+        }
+        for (int i = 'g'; i <= 'z'; i++) {
+            CHAR_MAP[j] = i;
+            MAP_CHAR[i] = j;
+            j++;
+        }
+        CHAR_MAP[j] = '$';
+        MAP_CHAR['$'] = j;
+        j++;
+        CHAR_MAP[j] = '_';
+        MAP_CHAR['_'] = j;
+    }
 
     /**
-     * Convert bit field of flags into string such as `static final'.
+     * Convert bit field of flags into string such as 'static final'.
      *
-     * @param  access_flags Access flags
+     * @param accessFlags Access flags
      * @return String representation of flags
      */
-    public static String accessToString( final int access_flags ) {
-        return accessToString(access_flags, false);
+    public static String accessToString(final int accessFlags) {
+        return accessToString(accessFlags, false);
     }
 
-
     /**
-     * Convert bit field of flags into string such as `static final'.
+     * Convert bit field of flags into string such as 'static final'.
      *
-     * Special case: Classes compiled with new compilers and with the
-     * `ACC_SUPER' flag would be said to be "synchronized". This is
-     * because SUN used the same value for the flags `ACC_SUPER' and
-     * `ACC_SYNCHRONIZED'.
+     * Special case: Classes compiled with new compilers and with the 'ACC_SUPER' flag would be said to be "synchronized".
+     * This is because SUN used the same value for the flags 'ACC_SUPER' and 'ACC_SYNCHRONIZED'.
      *
-     * @param  access_flags Access flags
-     * @param  for_class access flags are for class qualifiers ?
+     * @param accessFlags Access flags
+     * @param forClass access flags are for class qualifiers ?
      * @return String representation of flags
      */
-    public static String accessToString( final int access_flags, final boolean for_class ) {
+    public static String accessToString(final int accessFlags, final boolean forClass) {
         final StringBuilder buf = new StringBuilder();
         int p = 0;
         for (int i = 0; p < Const.MAX_ACC_FLAG_I; i++) { // Loop through known flags
             p = pow2(i);
-            if ((access_flags & p) != 0) {
-                /* Special case: Classes compiled with new compilers and with the
-                 * `ACC_SUPER' flag would be said to be "synchronized". This is
-                 * because SUN used the same value for the flags `ACC_SUPER' and
-                 * `ACC_SYNCHRONIZED'.
+            if ((accessFlags & p) != 0) {
+                /*
+                 * Special case: Classes compiled with new compilers and with the 'ACC_SUPER' flag would be said to be "synchronized".
+                 * This is because SUN used the same value for the flags 'ACC_SUPER' and 'ACC_SYNCHRONIZED'.
                  */
-                if (for_class && ((p == Const.ACC_SUPER) || (p == Const.ACC_INTERFACE))) {
+                if (forClass && (p == Const.ACC_SUPER || p == Const.ACC_INTERFACE)) {
                     continue;
                 }
                 buf.append(Const.getAccessName(i)).append(" ");
@@ -122,42 +212,55 @@ public static String accessToString( final int access_flags, final boolean for_c
         return buf.toString().trim();
     }
 
+    /**
+     * Convert (signed) byte to (unsigned) short value, i.e., all negative values become positive.
+     */
+    private static short byteToShort(final byte b) {
+        return b < 0 ? (short) (256 + b) : (short) b;
+    }
 
     /**
-     * @param access_flags the class flags
+     * @param accessFlags the class flags
      *
      * @return "class" or "interface", depending on the ACC_INTERFACE flag
      */
-    public static String classOrInterface( final int access_flags ) {
-        return ((access_flags & Const.ACC_INTERFACE) != 0) ? "interface" : "class";
+    public static String classOrInterface(final int accessFlags) {
+        return (accessFlags & Const.ACC_INTERFACE) != 0 ? "interface" : "class";
+    }
+
+    /**
+     * @return 'flag' with bit 'i' set to 0
+     */
+    public static int clearBit(final int flag, final int i) {
+        final int bit = pow2(i);
+        return (flag & bit) == 0 ? flag : flag ^ bit;
     }
 
+    public static String codeToString(final byte[] code, final ConstantPool constantPool, final int index, final int length) {
+        return codeToString(code, constantPool, index, length, true);
+    }
 
     /**
-     * Disassemble a byte array of JVM byte codes starting from code line
-     * `index' and return the disassembled string representation. Decode only
-     * `num' opcodes (including their operands), use -1 if you want to
-     * decompile everything.
+     * Disassemble a byte array of JVM byte codes starting from code line 'index' and return the disassembled string
+     * representation. Decode only 'num' opcodes (including their operands), use -1 if you want to decompile everything.
      *
-     * @param  code byte code array
-     * @param  constant_pool Array of constants
-     * @param  index offset in `code' array
-     * <EM>(number of opcodes, not bytes!)</EM>
-     * @param  length number of opcodes to decompile, -1 for all
-     * @param  verbose be verbose, e.g. print constant pool index
+     * @param code byte code array
+     * @param constantPool Array of constants
+     * @param index offset in 'code' array <EM>(number of opcodes, not bytes!)</EM>
+     * @param length number of opcodes to decompile, -1 for all
+     * @param verbose be verbose, e.g. print constant pool index
      * @return String representation of byte codes
      */
-    public static String codeToString( final byte[] code, final ConstantPool constant_pool, final int index,
-            final int length, final boolean verbose ) {
+    public static String codeToString(final byte[] code, final ConstantPool constantPool, final int index, final int length, final boolean verbose) {
         final StringBuilder buf = new StringBuilder(code.length * 20); // Should be sufficient // CHECKSTYLE IGNORE MagicNumber
         try (ByteSequence stream = new ByteSequence(code)) {
             for (int i = 0; i < index; i++) {
-                codeToString(stream, constant_pool, verbose);
+                codeToString(stream, constantPool, verbose);
             }
             for (int i = 0; stream.available() > 0; i++) {
-                if ((length < 0) || (i < length)) {
+                if (length < 0 || i < length) {
                     final String indices = fillup(stream.getIndex() + ":", 6, true, ' ');
-                    buf.append(indices).append(codeToString(stream, constant_pool, verbose)).append('\n');
+                    buf.append(indices).append(codeToString(stream, constantPool, verbose)).append('\n');
                 }
             }
         } catch (final IOException e) {
@@ -166,28 +269,25 @@ public static String codeToString( final byte[] code, final ConstantPool constan
         return buf.toString();
     }
 
-
-    public static String codeToString( final byte[] code, final ConstantPool constant_pool, final int index, final int length ) {
-        return codeToString(code, constant_pool, index, length, true);
+    public static String codeToString(final ByteSequence bytes, final ConstantPool constantPool) throws IOException {
+        return codeToString(bytes, constantPool, true);
     }
 
-
     /**
-     * Disassemble a stream of byte codes and return the
-     * string representation.
+     * Disassemble a stream of byte codes and return the string representation.
      *
-     * @param  bytes stream of bytes
-     * @param  constant_pool Array of constants
-     * @param  verbose be verbose, e.g. print constant pool index
+     * @param bytes stream of bytes
+     * @param constantPool Array of constants
+     * @param verbose be verbose, e.g. print constant pool index
      * @return String representation of byte code
      *
      * @throws IOException if a failure from reading from the bytes argument occurs
      */
     @SuppressWarnings("fallthrough") // by design for case Const.INSTANCEOF
-    public static String codeToString(final ByteSequence bytes, final ConstantPool constant_pool,
+    public static String codeToString(final ByteSequence bytes, final ConstantPool constantPool,
             final boolean verbose) throws IOException {
         final short opcode = (short) bytes.readUnsignedByte();
-        int default_offset = 0;
+        int defaultOffset = 0;
         int low;
         int high;
         int npairs;
@@ -195,441 +295,612 @@ public static String codeToString(final ByteSequence bytes, final ConstantPool c
         int vindex;
         int constant;
         int[] match;
-        int[] jump_table;
-        int no_pad_bytes = 0;
+        int[] jumpTable;
+        int noPadBytes = 0;
         int offset;
         final StringBuilder buf = new StringBuilder(Const.getOpcodeName(opcode));
-        /* Special case: Skip (0-3) padding bytes, i.e., the
-         * following bytes are 4-byte-aligned
+        /*
+         * Special case: Skip (0-3) padding bytes, i.e., the following bytes are 4-byte-aligned
          */
-        if ((opcode == Const.TABLESWITCH) || (opcode == Const.LOOKUPSWITCH)) {
+        if (opcode == Const.TABLESWITCH || opcode == Const.LOOKUPSWITCH) {
             final int remainder = bytes.getIndex() % 4;
-            no_pad_bytes = (remainder == 0) ? 0 : 4 - remainder;
-            for (int i = 0; i < no_pad_bytes; i++) {
+            noPadBytes = remainder == 0 ? 0 : 4 - remainder;
+            for (int i = 0; i < noPadBytes; i++) {
                 byte b;
                 if ((b = bytes.readByte()) != 0) {
-                    System.err.println("Warning: Padding byte != 0 in "
-                            + Const.getOpcodeName(opcode) + ":" + b);
+                    System.err.println("Warning: Padding byte != 0 in " + Const.getOpcodeName(opcode) + ":" + b);
                 }
             }
             // Both cases have a field default_offset in common
-            default_offset = bytes.readInt();
+            defaultOffset = bytes.readInt();
         }
         switch (opcode) {
-            /* Table switch has variable length arguments.
-             */
-            case Const.TABLESWITCH:
-                low = bytes.readInt();
-                high = bytes.readInt();
-                offset = bytes.getIndex() - 12 - no_pad_bytes - 1;
-                default_offset += offset;
-                buf.append("\tdefault = ").append(default_offset).append(", low = ").append(low)
-                        .append(", high = ").append(high).append("(");
-                jump_table = new int[high - low + 1];
-                for (int i = 0; i < jump_table.length; i++) {
-                    jump_table[i] = offset + bytes.readInt();
-                    buf.append(jump_table[i]);
-                    if (i < jump_table.length - 1) {
-                        buf.append(", ");
-                    }
-                }
-                buf.append(")");
-                break;
-            /* Lookup switch has variable length arguments.
-             */
-            case Const.LOOKUPSWITCH: {
-                npairs = bytes.readInt();
-                offset = bytes.getIndex() - 8 - no_pad_bytes - 1;
-                match = new int[npairs];
-                jump_table = new int[npairs];
-                default_offset += offset;
-                buf.append("\tdefault = ").append(default_offset).append(", npairs = ").append(
-                        npairs).append(" (");
-                for (int i = 0; i < npairs; i++) {
-                    match[i] = bytes.readInt();
-                    jump_table[i] = offset + bytes.readInt();
-                    buf.append("(").append(match[i]).append(", ").append(jump_table[i]).append(")");
-                    if (i < npairs - 1) {
-                        buf.append(", ");
-                    }
+        /*
+         * Table switch has variable length arguments.
+         */
+        case Const.TABLESWITCH:
+            low = bytes.readInt();
+            high = bytes.readInt();
+            offset = bytes.getIndex() - 12 - noPadBytes - 1;
+            defaultOffset += offset;
+            buf.append("\tdefault = ").append(defaultOffset).append(", low = ").append(low).append(", high = ").append(high).append("(");
+            jumpTable = new int[high - low + 1];
+            for (int i = 0; i < jumpTable.length; i++) {
+                jumpTable[i] = offset + bytes.readInt();
+                buf.append(jumpTable[i]);
+                if (i < jumpTable.length - 1) {
+                    buf.append(", ");
                 }
-                buf.append(")");
             }
-                break;
-            /* Two address bytes + offset from start of byte stream form the
-             * jump target
-             */
-            case Const.GOTO:
-            case Const.IFEQ:
-            case Const.IFGE:
-            case Const.IFGT:
-            case Const.IFLE:
-            case Const.IFLT:
-            case Const.JSR:
-            case Const.IFNE:
-            case Const.IFNONNULL:
-            case Const.IFNULL:
-            case Const.IF_ACMPEQ:
-            case Const.IF_ACMPNE:
-            case Const.IF_ICMPEQ:
-            case Const.IF_ICMPGE:
-            case Const.IF_ICMPGT:
-            case Const.IF_ICMPLE:
-            case Const.IF_ICMPLT:
-            case Const.IF_ICMPNE:
-                buf.append("\t\t#").append((bytes.getIndex() - 1) + bytes.readShort());
-                break;
-            /* 32-bit wide jumps
-             */
-            case Const.GOTO_W:
-            case Const.JSR_W:
-                buf.append("\t\t#").append((bytes.getIndex() - 1) + bytes.readInt());
-                break;
-            /* Index byte references local variable (register)
-             */
-            case Const.ALOAD:
-            case Const.ASTORE:
-            case Const.DLOAD:
-            case Const.DSTORE:
-            case Const.FLOAD:
-            case Const.FSTORE:
-            case Const.ILOAD:
-            case Const.ISTORE:
-            case Const.LLOAD:
-            case Const.LSTORE:
-            case Const.RET:
-                if (wide) {
-                    vindex = bytes.readUnsignedShort();
-                    wide = false; // Clear flag
-                } else {
-                    vindex = bytes.readUnsignedByte();
+            buf.append(")");
+            break;
+        /*
+         * Lookup switch has variable length arguments.
+         */
+        case Const.LOOKUPSWITCH: {
+            npairs = bytes.readInt();
+            offset = bytes.getIndex() - 8 - noPadBytes - 1;
+            match = new int[npairs];
+            jumpTable = new int[npairs];
+            defaultOffset += offset;
+            buf.append("\tdefault = ").append(defaultOffset).append(", npairs = ").append(npairs).append(" (");
+            for (int i = 0; i < npairs; i++) {
+                match[i] = bytes.readInt();
+                jumpTable[i] = offset + bytes.readInt();
+                buf.append("(").append(match[i]).append(", ").append(jumpTable[i]).append(")");
+                if (i < npairs - 1) {
+                    buf.append(", ");
                 }
-                buf.append("\t\t%").append(vindex);
-                break;
-            /*
-             * Remember wide byte which is used to form a 16-bit address in the
-             * following instruction. Relies on that the method is called again with
-             * the following opcode.
-             */
-            case Const.WIDE:
-                wide = true;
-                buf.append("\t(wide)");
-                break;
-            /* Array of basic type.
-             */
-            case Const.NEWARRAY:
-                buf.append("\t\t<").append(Const.getTypeName(bytes.readByte())).append(">");
-                break;
-            /* Access object/class fields.
-             */
-            case Const.GETFIELD:
-            case Const.GETSTATIC:
-            case Const.PUTFIELD:
-            case Const.PUTSTATIC:
-                index = bytes.readUnsignedShort();
-                buf.append("\t\t").append(
-                        constant_pool.constantToString(index, Const.CONSTANT_Fieldref)).append(
-                        verbose ? " (" + index + ")" : "");
-                break;
-            /* Operands are references to classes in constant pool
-             */
-            case Const.NEW:
-            case Const.CHECKCAST:
-                buf.append("\t");
-                //$FALL-THROUGH$
-            case Const.INSTANCEOF:
-                index = bytes.readUnsignedShort();
-                buf.append("\t<").append(
-                        constant_pool.constantToString(index, Const.CONSTANT_Class))
-                        .append(">").append(verbose ? " (" + index + ")" : "");
-                break;
-            /* Operands are references to methods in constant pool
-             */
-            case Const.INVOKESPECIAL:
-            case Const.INVOKESTATIC:
-                index = bytes.readUnsignedShort();
-                final Constant c = constant_pool.getConstant(index);
-                // With Java8 operand may be either a CONSTANT_Methodref
-                // or a CONSTANT_InterfaceMethodref.   (markro)
-                buf.append("\t").append(
-                        constant_pool.constantToString(index, c.getTag()))
-                        .append(verbose ? " (" + index + ")" : "");
-                break;
-            case Const.INVOKEVIRTUAL:
-                index = bytes.readUnsignedShort();
-                buf.append("\t").append(
-                        constant_pool.constantToString(index, Const.CONSTANT_Methodref))
-                        .append(verbose ? " (" + index + ")" : "");
-                break;
-            case Const.INVOKEINTERFACE:
-                index = bytes.readUnsignedShort();
-                final int nargs = bytes.readUnsignedByte(); // historical, redundant
-                buf.append("\t").append(
-                        constant_pool
-                                .constantToString(index, Const.CONSTANT_InterfaceMethodref))
-                        .append(verbose ? " (" + index + ")\t" : "").append(nargs).append("\t")
-                        .append(bytes.readUnsignedByte()); // Last byte is a reserved space
-                break;
-            case Const.INVOKEDYNAMIC:
-                index = bytes.readUnsignedShort();
-                buf.append("\t").append(
-                        constant_pool
-                                .constantToString(index, Const.CONSTANT_InvokeDynamic))
-                        .append(verbose ? " (" + index + ")\t" : "")
-                        .append(bytes.readUnsignedByte())  // Thrid byte is a reserved space
-                        .append(bytes.readUnsignedByte()); // Last byte is a reserved space
-                break;
-            /* Operands are references to items in constant pool
-             */
-            case Const.LDC_W:
-            case Const.LDC2_W:
-                index = bytes.readUnsignedShort();
-                buf.append("\t\t").append(
-                        constant_pool.constantToString(index, constant_pool.getConstant(index)
-                                .getTag())).append(verbose ? " (" + index + ")" : "");
-                break;
-            case Const.LDC:
-                index = bytes.readUnsignedByte();
-                buf.append("\t\t").append(
-                        constant_pool.constantToString(index, constant_pool.getConstant(index)
-                                .getTag())).append(verbose ? " (" + index + ")" : "");
-                break;
-            /* Array of references.
-             */
-            case Const.ANEWARRAY:
-                index = bytes.readUnsignedShort();
-                buf.append("\t\t<").append(
-                        compactClassName(constant_pool.getConstantString(index,
-                                Const.CONSTANT_Class), false)).append(">").append(
-                        verbose ? " (" + index + ")" : "");
-                break;
-            /* Multidimensional array of references.
-             */
-            case Const.MULTIANEWARRAY: {
-                index = bytes.readUnsignedShort();
-                final int dimensions = bytes.readUnsignedByte();
-                buf.append("\t<").append(
-                        compactClassName(constant_pool.getConstantString(index,
-                                Const.CONSTANT_Class), false)).append(">\t").append(dimensions)
-                        .append(verbose ? " (" + index + ")" : "");
             }
-                break;
-            /* Increment local variable.
-             */
-            case Const.IINC:
-                if (wide) {
-                    vindex = bytes.readUnsignedShort();
-                    constant = bytes.readShort();
-                    wide = false;
-                } else {
-                    vindex = bytes.readUnsignedByte();
-                    constant = bytes.readByte();
-                }
-                buf.append("\t\t%").append(vindex).append("\t").append(constant);
-                break;
-            default:
-                if (Const.getNoOfOperands(opcode) > 0) {
-                    for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) {
-                        buf.append("\t\t");
-                        switch (Const.getOperandType(opcode, i)) {
-                            case Const.T_BYTE:
-                                buf.append(bytes.readByte());
-                                break;
-                            case Const.T_SHORT:
-                                buf.append(bytes.readShort());
-                                break;
-                            case Const.T_INT:
-                                buf.append(bytes.readInt());
-                                break;
-                            default: // Never reached
-                                throw new IllegalStateException("Unreachable default case reached!");
-                        }
+            buf.append(")");
+        }
+            break;
+        /*
+         * Two address bytes + offset from start of byte stream form the jump target
+         */
+        case Const.GOTO:
+        case Const.IFEQ:
+        case Const.IFGE:
+        case Const.IFGT:
+        case Const.IFLE:
+        case Const.IFLT:
+        case Const.JSR:
+        case Const.IFNE:
+        case Const.IFNONNULL:
+        case Const.IFNULL:
+        case Const.IF_ACMPEQ:
+        case Const.IF_ACMPNE:
+        case Const.IF_ICMPEQ:
+        case Const.IF_ICMPGE:
+        case Const.IF_ICMPGT:
+        case Const.IF_ICMPLE:
+        case Const.IF_ICMPLT:
+        case Const.IF_ICMPNE:
+            buf.append("\t\t#").append(bytes.getIndex() - 1 + bytes.readShort());
+            break;
+        /*
+         * 32-bit wide jumps
+         */
+        case Const.GOTO_W:
+        case Const.JSR_W:
+            buf.append("\t\t#").append(bytes.getIndex() - 1 + bytes.readInt());
+            break;
+        /*
+         * Index byte references local variable (register)
+         */
+        case Const.ALOAD:
+        case Const.ASTORE:
+        case Const.DLOAD:
+        case Const.DSTORE:
+        case Const.FLOAD:
+        case Const.FSTORE:
+        case Const.ILOAD:
+        case Const.ISTORE:
+        case Const.LLOAD:
+        case Const.LSTORE:
+        case Const.RET:
+            if (wide) {
+                vindex = bytes.readUnsignedShort();
+                wide = false; // Clear flag
+            } else {
+                vindex = bytes.readUnsignedByte();
+            }
+            buf.append("\t\t%").append(vindex);
+            break;
+        /*
+         * Remember wide byte which is used to form a 16-bit address in the following instruction. Relies on that the method is
+         * called again with the following opcode.
+         */
+        case Const.WIDE:
+            wide = true;
+            buf.append("\t(wide)");
+            break;
+        /*
+         * Array of basic type.
+         */
+        case Const.NEWARRAY:
+            buf.append("\t\t<").append(Const.getTypeName(bytes.readByte())).append(">");
+            break;
+        /*
+         * Access object/class fields.
+         */
+        case Const.GETFIELD:
+        case Const.GETSTATIC:
+        case Const.PUTFIELD:
+        case Const.PUTSTATIC:
+            index = bytes.readUnsignedShort();
+            buf.append("\t\t").append(constantPool.constantToString(index, Const.CONSTANT_Fieldref)).append(verbose ? " (" + index + ")" : "");
+            break;
+        /*
+         * Operands are references to classes in constant pool
+         */
+        case Const.NEW:
+        case Const.CHECKCAST:
+            buf.append("\t");
+            //$FALL-THROUGH$
+        case Const.INSTANCEOF:
+            index = bytes.readUnsignedShort();
+            buf.append("\t<").append(constantPool.constantToString(index, Const.CONSTANT_Class)).append(">").append(verbose ? " (" + index + ")" : "");
+            break;
+        /*
+         * Operands are references to methods in constant pool
+         */
+        case Const.INVOKESPECIAL:
+        case Const.INVOKESTATIC:
+            index = bytes.readUnsignedShort();
+            final Constant c = constantPool.getConstant(index);
+            // With Java8 operand may be either a CONSTANT_Methodref
+            // or a CONSTANT_InterfaceMethodref. (markro)
+            buf.append("\t").append(constantPool.constantToString(index, c.getTag())).append(verbose ? " (" + index + ")" : "");
+            break;
+        case Const.INVOKEVIRTUAL:
+            index = bytes.readUnsignedShort();
+            buf.append("\t").append(constantPool.constantToString(index, Const.CONSTANT_Methodref)).append(verbose ? " (" + index + ")" : "");
+            break;
+        case Const.INVOKEINTERFACE:
+            index = bytes.readUnsignedShort();
+            final int nargs = bytes.readUnsignedByte(); // historical, redundant
+            buf.append("\t").append(constantPool.constantToString(index, Const.CONSTANT_InterfaceMethodref)).append(verbose ? " (" + index + ")\t" : "")
+                .append(nargs).append("\t").append(bytes.readUnsignedByte()); // Last byte is a reserved space
+            break;
+        case Const.INVOKEDYNAMIC:
+            index = bytes.readUnsignedShort();
+            buf.append("\t").append(constantPool.constantToString(index, Const.CONSTANT_InvokeDynamic)).append(verbose ? " (" + index + ")\t" : "")
+                .append(bytes.readUnsignedByte()) // Thrid byte is a reserved space
+                .append(bytes.readUnsignedByte()); // Last byte is a reserved space
+            break;
+        /*
+         * Operands are references to items in constant pool
+         */
+        case Const.LDC_W:
+        case Const.LDC2_W:
+            index = bytes.readUnsignedShort();
+            buf.append("\t\t").append(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))
+                .append(verbose ? " (" + index + ")" : "");
+            break;
+        case Const.LDC:
+            index = bytes.readUnsignedByte();
+            buf.append("\t\t").append(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))
+                .append(verbose ? " (" + index + ")" : "");
+            break;
+        /*
+         * Array of references.
+         */
+        case Const.ANEWARRAY:
+            index = bytes.readUnsignedShort();
+            buf.append("\t\t<").append(compactClassName(constantPool.getConstantString(index, Const.CONSTANT_Class), false)).append(">")
+                .append(verbose ? " (" + index + ")" : "");
+            break;
+        /*
+         * Multidimensional array of references.
+         */
+        case Const.MULTIANEWARRAY: {
+            index = bytes.readUnsignedShort();
+            final int dimensions = bytes.readUnsignedByte();
+            buf.append("\t<").append(compactClassName(constantPool.getConstantString(index, Const.CONSTANT_Class), false)).append(">\t").append(dimensions)
+                .append(verbose ? " (" + index + ")" : "");
+        }
+            break;
+        /*
+         * Increment local variable.
+         */
+        case Const.IINC:
+            if (wide) {
+                vindex = bytes.readUnsignedShort();
+                constant = bytes.readShort();
+                wide = false;
+            } else {
+                vindex = bytes.readUnsignedByte();
+                constant = bytes.readByte();
+            }
+            buf.append("\t\t%").append(vindex).append("\t").append(constant);
+            break;
+        default:
+            if (Const.getNoOfOperands(opcode) > 0) {
+                for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) {
+                    buf.append("\t\t");
+                    switch (Const.getOperandType(opcode, i)) {
+                    case Const.T_BYTE:
+                        buf.append(bytes.readByte());
+                        break;
+                    case Const.T_SHORT:
+                        buf.append(bytes.readShort());
+                        break;
+                    case Const.T_INT:
+                        buf.append(bytes.readInt());
+                        break;
+                    default: // Never reached
+                        throw new IllegalStateException("Unreachable default case reached!");
                     }
                 }
+            }
         }
         return buf.toString();
     }
 
-
-    public static String codeToString( final ByteSequence bytes, final ConstantPool constant_pool )
-            throws IOException {
-        return codeToString(bytes, constant_pool, true);
-    }
-
-
     /**
-     * Shorten long class names, <em>java/lang/String</em> becomes
-     * <em>String</em>.
+     * Shorten long class names, <em>java/lang/String</em> becomes <em>String</em>.
      *
      * @param str The long class name
      * @return Compacted class name
      */
-    public static String compactClassName( final String str ) {
+    public static String compactClassName(final String str) {
         return compactClassName(str, true);
     }
 
-
     /**
-     * Shorten long class names, <em>java/lang/String</em> becomes
-     * <em>java.lang.String</em>,
-     * e.g.. If <em>chopit</em> is <em>true</em> the prefix <em>java.lang</em>
-     * is also removed.
+     * Shorten long class names, <em>java/lang/String</em> becomes <em>java.lang.String</em>, e.g.. If <em>chopit</em> is
+     * <em>true</em> the prefix <em>java.lang</em> is also removed.
      *
      * @param str The long class name
      * @param chopit flag that determines whether chopping is executed or not
      * @return Compacted class name
      */
-    public static String compactClassName( final String str, final boolean chopit ) {
+    public static String compactClassName(final String str, final boolean chopit) {
         return compactClassName(str, "java.lang.", chopit);
     }
 
-
     /**
-     * Shorten long class name <em>str</em>, i.e., chop off the <em>prefix</em>,
-     * if the
-     * class name starts with this string and the flag <em>chopit</em> is true.
-     * Slashes <em>/</em> are converted to dots <em>.</em>.
+     * Shorten long class name <em>str</em>, i.e., chop off the <em>prefix</em>, if the class name starts with this string
+     * and the flag <em>chopit</em> is true. Slashes <em>/</em> are converted to dots <em>.</em>.
      *
      * @param str The long class name
      * @param prefix The prefix the get rid off
      * @param chopit flag that determines whether chopping is executed or not
      * @return Compacted class name
      */
-    public static String compactClassName( String str, final String prefix, final boolean chopit ) {
+    public static String compactClassName(String str, final String prefix, final boolean chopit) {
         final int len = prefix.length();
-        str = str.replace('/', '.'); // Is `/' on all systems, even DOS
-        if (chopit) {
-            // If string starts with `prefix' and contains no further dots
-            if (str.startsWith(prefix) && (str.substring(len).indexOf('.') == -1)) {
-                str = str.substring(len);
-            }
+        str = pathToPackage(str); // Is '/' on all systems, even DOS
+        // If string starts with 'prefix' and contains no further dots
+        if (chopit && str.startsWith(prefix) && str.substring(len).indexOf('.') == -1) {
+            str = str.substring(len);
         }
         return str;
     }
 
-
-    /**
-     * @return `flag' with bit `i' set to 1
-     */
-    public static int setBit( final int flag, final int i ) {
-        return flag | pow2(i);
-    }
-
-
     /**
-     * @return `flag' with bit `i' set to 0
+     * Escape all occurrences of newline chars '\n', quotes \", etc.
      */
-    public static int clearBit( final int flag, final int i ) {
-        final int bit = pow2(i);
-        return (flag & bit) == 0 ? flag : flag ^ bit;
+    public static String convertString(final String label) {
+        final char[] ch = label.toCharArray();
+        final StringBuilder buf = new StringBuilder();
+        for (final char element : ch) {
+            switch (element) {
+            case '\n':
+                buf.append("\\n");
+                break;
+            case '\r':
+                buf.append("\\r");
+                break;
+            case '\"':
+                buf.append("\\\"");
+                break;
+            case '\'':
+                buf.append("\\'");
+                break;
+            case '\\':
+                buf.append("\\\\");
+                break;
+            default:
+                buf.append(element);
+                break;
+            }
+        }
+        return buf.toString();
     }
 
-
-    /**
-     * @return true, if bit `i' in `flag' is set
-     */
-    public static boolean isSet( final int flag, final int i ) {
-        return (flag & pow2(i)) != 0;
+    private static int countBrackets(final String brackets) {
+        final char[] chars = brackets.toCharArray();
+        int count = 0;
+        boolean open = false;
+        for (final char c : chars) {
+            switch (c) {
+            case '[':
+                if (open) {
+                    throw new IllegalArgumentException("Illegally nested brackets:" + brackets);
+                }
+                open = true;
+                break;
+            case ']':
+                if (!open) {
+                    throw new IllegalArgumentException("Illegally nested brackets:" + brackets);
+                }
+                open = false;
+                count++;
+                break;
+            default:
+                // Don't care
+                break;
+            }
+        }
+        if (open) {
+            throw new IllegalArgumentException("Illegally nested brackets:" + brackets);
+        }
+        return count;
     }
 
-
     /**
-     * Converts string containing the method return and argument types
-     * to a byte code method signature.
+     * Decode a string back to a byte array.
      *
-     * @param  ret Return type of method
-     * @param  argv Types of method arguments
-     * @return Byte code representation of method signature
+     * @param s the string to convert
+     * @param uncompress use gzip to uncompress the stream of bytes
      *
-     * @throws ClassFormatException if the signature is for Void
+     * @throws IOException if there's a gzip exception
      */
-    public static String methodTypeToSignature( final String ret, final String[] argv )
-            throws ClassFormatException {
-        final StringBuilder buf = new StringBuilder("(");
-        String str;
-        if (argv != null) {
-            for (final String element : argv) {
-                str = getSignature(element);
-                if (str.endsWith("V")) {
-                    throw new ClassFormatException("Invalid type: " + element);
-                }
-                buf.append(str);
+    public static byte[] decode(final String s, final boolean uncompress) throws IOException {
+        byte[] bytes;
+        try (JavaReader jr = new JavaReader(new CharArrayReader(s.toCharArray())); ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
+            int ch;
+            while ((ch = jr.read()) >= 0) {
+                bos.write(ch);
             }
+            bytes = bos.toByteArray();
         }
-        str = getSignature(ret);
-        buf.append(")").append(str);
-        return buf.toString();
+        if (uncompress) {
+            final GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes));
+            final byte[] tmp = new byte[bytes.length * 3]; // Rough estimate
+            int count = 0;
+            int b;
+            while ((b = gis.read()) >= 0) {
+                tmp[count++] = (byte) b;
+            }
+            bytes = Arrays.copyOf(tmp, count);
+        }
+        return bytes;
     }
 
-
     /**
-     * Converts argument list portion of method signature to string with all class names compacted.
+     * Encode byte array it into Java identifier string, i.e., a string that only contains the following characters: (a, ...
+     * z, A, ... Z, 0, ... 9, _, $). The encoding algorithm itself is not too clever: if the current byte's ASCII value
+     * already is a valid Java identifier part, leave it as it is. Otherwise it writes the escape character($) followed by:
      *
-     * @param  signature    Method signature
-     * @return String Array of argument types
-     * @throws ClassFormatException
-     */
-    public static String[] methodSignatureArgumentTypes( final String signature )
-            throws ClassFormatException {
-        return methodSignatureArgumentTypes(signature, true);
-    }
-
-
-    /**
-     * Converts argument list portion of method signature to string.
+     * <ul>
+     * <li>the ASCII value as a hexadecimal string, if the value is not in the range 200..247</li>
+     * <li>a Java identifier char not used in a lowercase hexadecimal string, if the value is in the range 200..247</li>
+     * </ul>
      *
-     * @param  signature    Method signature
-     * @param  chopit flag that determines whether chopping is executed or not
-     * @return String Array of argument types
-     * @throws ClassFormatException
-     */
-    public static String[] methodSignatureArgumentTypes( final String signature, final boolean chopit )
-            throws ClassFormatException {
+     * <p>
+     * This operation inflates the original byte array by roughly 40-50%
+     * </p>
+     *
+     * @param bytes the byte array to convert
+     * @param compress use gzip to minimize string
+     *
+     * @throws IOException if there's a gzip exception
+     */
+    public static String encode(byte[] bytes, final boolean compress) throws IOException {
+        if (compress) {
+            try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(baos)) {
+                gos.write(bytes, 0, bytes.length);
+                gos.finish();
+                bytes = baos.toByteArray();
+            }
+        }
+        final CharArrayWriter caw = new CharArrayWriter();
+        try (JavaWriter jw = new JavaWriter(caw)) {
+            for (final byte b : bytes) {
+                final int in = b & 0x000000ff; // Normalize to unsigned
+                jw.write(in);
+            }
+        }
+        return caw.toString();
+    }
+
+    /**
+     * Fillup char with up to length characters with char 'fill' and justify it left or right.
+     *
+     * @param str string to format
+     * @param length length of desired string
+     * @param leftJustify format left or right
+     * @param fill fill character
+     * @return formatted string
+     */
+    public static String fillup(final String str, final int length, final boolean leftJustify, final char fill) {
+        final int len = length - str.length();
+        final char[] buf = new char[Math.max(len, 0)];
+        Arrays.fill(buf, fill);
+        if (leftJustify) {
+            return str + new String(buf);
+        }
+        return new String(buf) + str;
+    }
+
+    /**
+     * Return a string for an integer justified left or right and filled up with 'fill' characters if necessary.
+     *
+     * @param i integer to format
+     * @param length length of desired string
+     * @param leftJustify format left or right
+     * @param fill fill character
+     * @return formatted int
+     */
+    public static String format(final int i, final int length, final boolean leftJustify, final char fill) {
+        return fillup(Integer.toString(i), length, leftJustify, fill);
+    }
+
+    /**
+     * WARNING:
+     *
+     * There is some nomenclature confusion through much of the BCEL code base with respect to the terms Descriptor and
+     * Signature. For the offical definitions see:
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.3"> Descriptors in The Java
+     *      Virtual Machine Specification</a>
+     *
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.9.1"> Signatures in The Java
+     *      Virtual Machine Specification</a>
+     *
+     *      In brief, a descriptor is a string representing the type of a field or method. Signatures are similar, but more
+     *      complex. Signatures are used to encode declarations written in the Java programming language that use types
+     *      outside the type system of the Java Virtual Machine. They are used to describe the type of any class, interface,
+     *      constructor, method or field whose declaration uses type variables or parameterized types.
+     *
+     *      To parse a descriptor, call typeSignatureToString. To parse a signature, call signatureToString.
+     *
+     *      Note that if the signature string is a single, non-generic item, the call to signatureToString reduces to a call
+     *      to typeSignatureToString. Also note, that if you only wish to parse the first item in a longer signature string,
+     *      you should call typeSignatureToString directly.
+     */
+
+    /**
+     * Parse Java type such as "char", or "java.lang.String[]" and return the signature in byte code format, e.g. "C" or
+     * "[Ljava/lang/String;" respectively.
+     *
+     * @param type Java type
+     * @return byte code signature
+     */
+    public static String getSignature(String type) {
+        final StringBuilder buf = new StringBuilder();
+        final char[] chars = type.toCharArray();
+        boolean charFound = false;
+        boolean delim = false;
+        int index = -1;
+        loop: for (int i = 0; i < chars.length; i++) {
+            switch (chars[i]) {
+            case ' ':
+            case '\t':
+            case '\n':
+            case '\r':
+            case '\f':
+                if (charFound) {
+                    delim = true;
+                }
+                break;
+            case '[':
+                if (!charFound) {
+                    throw new IllegalArgumentException("Illegal type: " + type);
+                }
+                index = i;
+                break loop;
+            default:
+                charFound = true;
+                if (!delim) {
+                    buf.append(chars[i]);
+                }
+            }
+        }
+        int brackets = 0;
+        if (index > 0) {
+            brackets = countBrackets(type.substring(index));
+        }
+        type = buf.toString();
+        buf.setLength(0);
+        for (int i = 0; i < brackets; i++) {
+            buf.append('[');
+        }
+        boolean found = false;
+        for (int i = Const.T_BOOLEAN; i <= Const.T_VOID && !found; i++) {
+            if (Const.getTypeName(i).equals(type)) {
+                found = true;
+                buf.append(Const.getShortTypeName(i));
+            }
+        }
+        if (!found) {
+            buf.append('L').append(packageToPath(type)).append(';');
+        }
+        return buf.toString();
+    }
+
+    /**
+     * @param ch the character to test if it's part of an identifier
+     *
+     * @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _)
+     */
+    public static boolean isJavaIdentifierPart(final char ch) {
+        return ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9' || ch == '_';
+    }
+
+    /**
+     * @return true, if bit 'i' in 'flag' is set
+     */
+    public static boolean isSet(final int flag, final int i) {
+        return (flag & pow2(i)) != 0;
+    }
+
+    /**
+     * Converts argument list portion of method signature to string with all class names compacted.
+     *
+     * @param signature Method signature
+     * @return String Array of argument types
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
+     */
+    public static String[] methodSignatureArgumentTypes(final String signature) throws ClassFormatException {
+        return methodSignatureArgumentTypes(signature, true);
+    }
+
+    /**
+     * Converts argument list portion of method signature to string.
+     *
+     * @param signature Method signature
+     * @param chopit flag that determines whether chopping is executed or not
+     * @return String Array of argument types
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
+     */
+    public static String[] methodSignatureArgumentTypes(final String signature, final boolean chopit) throws ClassFormatException {
         final List<String> vec = new ArrayList<>();
         int index;
         try {
-            // Skip any type arguments to read argument declarations between `(' and `)'
+            // Skip any type arguments to read argument declarations between '(' and ')'
             index = signature.indexOf('(') + 1;
             if (index <= 0) {
                 throw new ClassFormatException("Invalid method signature: " + signature);
             }
             while (signature.charAt(index) != ')') {
                 vec.add(typeSignatureToString(signature.substring(index), chopit));
-                //corrected concurrent private static field acess
-                index += unwrap(consumed_chars); // update position
+                // corrected concurrent private static field acess
+                index += unwrap(CONSUMER_CHARS); // update position
             }
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
             throw new ClassFormatException("Invalid method signature: " + signature, e);
         }
-        return vec.toArray(new String[vec.size()]);
+        return vec.toArray(Const.EMPTY_STRING_ARRAY);
     }
 
-
     /**
      * Converts return type portion of method signature to string with all class names compacted.
      *
-     * @param  signature    Method signature
+     * @param signature Method signature
      * @return String representation of method return type
-     * @throws ClassFormatException
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
-    public static String methodSignatureReturnType( final String signature ) throws ClassFormatException {
+    public static String methodSignatureReturnType(final String signature) throws ClassFormatException {
         return methodSignatureReturnType(signature, true);
     }
 
-
     /**
      * Converts return type portion of method signature to string.
      *
-     * @param  signature    Method signature
-     * @param  chopit flag that determines whether chopping is executed or not
+     * @param signature Method signature
+     * @param chopit flag that determines whether chopping is executed or not
      * @return String representation of method return type
-     * @throws ClassFormatException
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
-    public static String methodSignatureReturnType( final String signature, final boolean chopit ) throws ClassFormatException {
+    public static String methodSignatureReturnType(final String signature, final boolean chopit) throws ClassFormatException {
         int index;
         String type;
         try {
-            // Read return type after `)'
+            // Read return type after ')'
             index = signature.lastIndexOf(')') + 1;
             if (index <= 0) {
                 throw new ClassFormatException("Invalid method signature: " + signature);
@@ -641,81 +912,77 @@ public static String methodSignatureReturnType( final String signature, final bo
         return type;
     }
 
-
     /**
      * Converts method signature to string with all class names compacted.
      *
-     * @param  signature to convert
-     * @param  name of method
-     * @param  access flags of method
+     * @param signature to convert
+     * @param name of method
+     * @param access flags of method
      * @return Human readable signature
      */
-    public static String methodSignatureToString( final String signature, final String name, final String access ) {
+    public static String methodSignatureToString(final String signature, final String name, final String access) {
         return methodSignatureToString(signature, name, access, true);
     }
 
-
     /**
      * Converts method signature to string.
      *
-     * @param  signature to convert
-     * @param  name of method
-     * @param  access flags of method
-     * @param  chopit flag that determines whether chopping is executed or not
+     * @param signature to convert
+     * @param name of method
+     * @param access flags of method
+     * @param chopit flag that determines whether chopping is executed or not
      * @return Human readable signature
      */
-    public static String methodSignatureToString( final String signature, final String name, final String access, final boolean chopit ) {
+    public static String methodSignatureToString(final String signature, final String name, final String access, final boolean chopit) {
         return methodSignatureToString(signature, name, access, chopit, null);
     }
 
-
     /**
-     * This method converts a method signature string into a Java type declaration like
-     * `void main(String[])' and throws a `ClassFormatException' when the parsed
-     * type is invalid.
+     * This method converts a method signature string into a Java type declaration like 'void main(String[])' and throws a
+     * 'ClassFormatException' when the parsed type is invalid.
      *
-     * @param  signature    Method signature
-     * @param  name         Method name
-     * @param  access       Method access rights
-     * @param  chopit flag that determines whether chopping is executed or not
-     * @param  vars the LocalVariableTable for the method
+     * @param signature Method signature
+     * @param name Method name
+     * @param access Method access rights
+     * @param chopit flag that determines whether chopping is executed or not
+     * @param vars the LocalVariableTable for the method
      * @return Java type declaration
-     * @throws ClassFormatException
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
      */
-    public static String methodSignatureToString( final String signature, final String name,
-            final String access, final boolean chopit, final LocalVariableTable vars ) throws ClassFormatException {
+    public static String methodSignatureToString(final String signature, final String name, final String access, final boolean chopit,
+        final LocalVariableTable vars) throws ClassFormatException {
         final StringBuilder buf = new StringBuilder("(");
         String type;
         int index;
-        int var_index = access.contains("static") ? 0 : 1;
+        int varIndex = access.contains("static") ? 0 : 1;
         try {
-            // Skip any type arguments to read argument declarations between `(' and `)'
+            // Skip any type arguments to read argument declarations between '(' and ')'
             index = signature.indexOf('(') + 1;
             if (index <= 0) {
                 throw new ClassFormatException("Invalid method signature: " + signature);
             }
             while (signature.charAt(index) != ')') {
-                final String param_type = typeSignatureToString(signature.substring(index), chopit);
-                buf.append(param_type);
+                final String paramType = typeSignatureToString(signature.substring(index), chopit);
+                buf.append(paramType);
                 if (vars != null) {
-                    final LocalVariable l = vars.getLocalVariable(var_index, 0);
+                    final LocalVariable l = vars.getLocalVariable(varIndex, 0);
                     if (l != null) {
                         buf.append(" ").append(l.getName());
                     }
                 } else {
-                    buf.append(" arg").append(var_index);
+                    buf.append(" arg").append(varIndex);
                 }
-                if ("double".equals(param_type) || "long".equals(param_type)) {
-                    var_index += 2;
+                if ("double".equals(paramType) || "long".equals(paramType)) {
+                    varIndex += 2;
                 } else {
-                    var_index++;
+                    varIndex++;
                 }
                 buf.append(", ");
-                //corrected concurrent private static field acess
-                index += unwrap(consumed_chars); // update position
+                // corrected concurrent private static field acess
+                index += unwrap(CONSUMER_CHARS); // update position
             }
             index++; // update position
-            // Read return type after `)'
+            // Read return type after ')'
             type = typeSignatureToString(signature.substring(index), chopit);
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
             throw new ClassFormatException("Invalid method signature: " + signature, e);
@@ -725,15 +992,101 @@ public static String methodSignatureToString( final String signature, final Stri
             buf.setLength(buf.length() - 2);
         }
         buf.append(")");
-        return access + ((access.length() > 0) ? " " : "") + // May be an empty string
-                type + " " + name + buf.toString();
+        return access + (!access.isEmpty() ? " " : "") + // May be an empty string
+            type + " " + name + buf.toString();
+    }
+
+    /**
+     * Converts string containing the method return and argument types to a byte code method signature.
+     *
+     * @param ret Return type of method
+     * @param argv Types of method arguments
+     * @return Byte code representation of method signature
+     *
+     * @throws ClassFormatException if the signature is for Void
+     */
+    public static String methodTypeToSignature(final String ret, final String[] argv) throws ClassFormatException {
+        final StringBuilder buf = new StringBuilder("(");
+        String str;
+        if (argv != null) {
+            for (final String element : argv) {
+                str = getSignature(element);
+                if (str.endsWith("V")) {
+                    throw new ClassFormatException("Invalid type: " + element);
+                }
+                buf.append(str);
+            }
+        }
+        str = getSignature(ret);
+        buf.append(")").append(str);
+        return buf.toString();
+    }
+
+    /**
+     * Converts '.'s to '/'s.
+     *
+     * @param name Source
+     * @return converted value
+     * @since 6.7.0
+     */
+    public static String packageToPath(final String name) {
+        return name.replace('.', '/');
     }
 
+    /**
+     * Converts a path to a package name.
+     *
+     * @param str the source path.
+     * @return a package name.
+     * @since 6.6.0
+     */
+    public static String pathToPackage(final String str) {
+        return str.replace('/', '.');
+    }
 
-    private static int pow2( final int n ) {
+    private static int pow2(final int n) {
         return 1 << n;
     }
 
+    public static String printArray(final Object[] obj) {
+        return printArray(obj, true);
+    }
+
+    public static String printArray(final Object[] obj, final boolean braces) {
+        return printArray(obj, braces, false);
+    }
+
+    public static String printArray(final Object[] obj, final boolean braces, final boolean quote) {
+        if (obj == null) {
+            return null;
+        }
+        final StringBuilder buf = new StringBuilder();
+        if (braces) {
+            buf.append('{');
+        }
+        for (int i = 0; i < obj.length; i++) {
+            if (obj[i] != null) {
+                buf.append(quote ? "\"" : "").append(obj[i]).append(quote ? "\"" : "");
+            } else {
+                buf.append("null");
+            }
+            if (i < obj.length - 1) {
+                buf.append(", ");
+            }
+        }
+        if (braces) {
+            buf.append('}');
+        }
+        return buf.toString();
+    }
+
+    public static void printArray(final PrintStream out, final Object[] obj) {
+        out.println(printArray(obj, true));
+    }
+
+    public static void printArray(final PrintWriter out, final Object[] obj) {
+        out.println(printArray(obj, true));
+    }
 
     /**
      * Replace all occurrences of <em>old</em> in <em>str</em> with <em>new</em>.
@@ -743,20 +1096,20 @@ private static int pow2( final int n ) {
      * @param new_ Replacement string
      * @return new String object
      */
-    public static String replace( String str, final String old, final String new_ ) {
+    public static String replace(String str, final String old, final String new_) {
         int index;
-        int old_index;
+        int oldIndex;
         try {
-            if (str.contains(old)) { // `old' found in str
+            if (str.contains(old)) { // 'old' found in str
                 final StringBuilder buf = new StringBuilder();
-                old_index = 0; // String start offset
+                oldIndex = 0; // String start offset
                 // While we have something to replace
-                while ((index = str.indexOf(old, old_index)) != -1) {
-                    buf.append(str.substring(old_index, index)); // append prefix
+                while ((index = str.indexOf(old, oldIndex)) != -1) {
+                    buf.append(str, oldIndex, index); // append prefix
                     buf.append(new_); // append replacement
-                    old_index = index + old.length(); // Skip `old'.length chars
+                    oldIndex = index + old.length(); // Skip 'old'.length chars
                 }
-                buf.append(str.substring(old_index)); // append rest of string
+                buf.append(str.substring(oldIndex)); // append rest of string
                 str = buf.toString();
             }
         } catch (final StringIndexOutOfBoundsException e) { // Should not occur
@@ -765,81 +1118,69 @@ public static String replace( String str, final String old, final String new_ )
         return str;
     }
 
-
     /**
-     * WARNING:
-     *
-     * There is some nomenclature confusion through much of the BCEL code base with
-     * respect to the terms Descriptor and Signature.  For the offical definitions see:
-     *
-     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.3">
-     * Descriptors in The Java Virtual Machine Specification</a>
-     *
-     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.9.1">
-     * Signatures in The Java Virtual Machine Specification</a>
-     *
-     * In brief, a descriptor is a string representing the type of a field or method.
-     * Signatures are similar, but more complex.  Signatures are used to encode declarations
-     * written in the Java programming language that use types outside the type system of the
-     * Java Virtual Machine.  They are used to describe the type of any class, interface,
-     * constructor, method or field whose declaration uses type variables or parameterized types.
-     *
-     * To parse a descriptor, call typeSignatureToString.
-     * To parse a signature, call signatureToString.
-     *
-     * Note that if the signature string is a single, non-generic item, the call to
-     * signatureToString reduces to a call to typeSignatureToString.
-     * Also note, that if you only wish to parse the first item in a longer signature
-     * string, you should call typeSignatureToString directly.
+     * Map opcode names to opcode numbers. E.g., return Constants.ALOAD for "aload"
      */
+    public static short searchOpcode(String name) {
+        name = name.toLowerCase(Locale.ENGLISH);
+        for (short i = 0; i < Const.OPCODE_NAMES_LENGTH; i++) {
+            if (Const.getOpcodeName(i).equals(name)) {
+                return i;
+            }
+        }
+        return -1;
+    }
 
+    /**
+     * @return 'flag' with bit 'i' set to 1
+     */
+    public static int setBit(final int flag, final int i) {
+        return flag | pow2(i);
+    }
 
     /**
-     * Converts a signature to a string with all class names compacted.
-     * Class, Method and Type signatures are supported.
+     * Converts a signature to a string with all class names compacted. Class, Method and Type signatures are supported.
      * Enum and Interface signatures are not supported.
      *
-     * @param  signature signature to convert
+     * @param signature signature to convert
      * @return String containg human readable signature
      */
-    public static String signatureToString( final String signature ) {
+    public static String signatureToString(final String signature) {
         return signatureToString(signature, true);
     }
 
-
     /**
-     * Converts a signature to a string.
-     * Class, Method and Type signatures are supported.
-     * Enum and Interface signatures are not supported.
+     * Converts a signature to a string. Class, Method and Type signatures are supported. Enum and Interface signatures are
+     * not supported.
      *
-     * @param  signature signature to convert
-     * @param  chopit flag that determines whether chopping is executed or not
+     * @param signature signature to convert
+     * @param chopit flag that determines whether chopping is executed or not
      * @return String containg human readable signature
      */
-    public static String signatureToString( final String signature, final boolean chopit ) {
+    public static String signatureToString(final String signature, final boolean chopit) {
         String type = "";
         String typeParams = "";
         int index = 0;
         if (signature.charAt(0) == '<') {
             // we have type paramters
             typeParams = typeParamTypesToString(signature, chopit);
-            index += unwrap(consumed_chars); // update position
+            index += unwrap(CONSUMER_CHARS); // update position
         }
         if (signature.charAt(index) == '(') {
             // We have a Method signature.
             // add types of arguments
             type = typeParams + typeSignaturesToString(signature.substring(index), chopit, ')');
-            index += unwrap(consumed_chars); // update position
+            index += unwrap(CONSUMER_CHARS); // update position
             // add return type
             type = type + typeSignatureToString(signature.substring(index), chopit);
-            index += unwrap(consumed_chars); // update position
+            index += unwrap(CONSUMER_CHARS); // update position
             // ignore any throws information in the signature
             return type;
         }
         // Could be Class or Type...
         type = typeSignatureToString(signature.substring(index), chopit);
-        index += unwrap(consumed_chars); // update position
-        if ((typeParams.length() == 0) && (index == signature.length())) {
+        index += unwrap(CONSUMER_CHARS); // update position
+        if (typeParams.isEmpty() && index == signature.length()) {
             // We have a Type signature.
             return type;
         }
@@ -850,379 +1191,49 @@ public static String signatureToString( final String signature, final boolean ch
         if (index < signature.length()) {
             typeClass.append(" implements ");
             typeClass.append(typeSignatureToString(signature.substring(index), chopit));
-            index += unwrap(consumed_chars); // update position
+            index += unwrap(CONSUMER_CHARS); // update position
         }
         while (index < signature.length()) {
             typeClass.append(", ");
             typeClass.append(typeSignatureToString(signature.substring(index), chopit));
-            index += unwrap(consumed_chars); // update position
+            index += unwrap(CONSUMER_CHARS); // update position
         }
         return typeClass.toString();
     }
 
-
     /**
-     * Converts a type parameter list signature to a string.
+     * Convert bytes into hexadecimal string
      *
-     * @param  signature signature to convert
-     * @param  chopit flag that determines whether chopping is executed or not
-     * @return String containg human readable signature
+     * @param bytes an array of bytes to convert to hexadecimal
+     *
+     * @return bytes as hexadecimal string, e.g. 00 fa 12 ...
      */
-    private static String typeParamTypesToString( final String signature, final boolean chopit ) {
-        // The first character is guranteed to be '<'
-        final StringBuilder typeParams = new StringBuilder("<");
-        int index = 1;  // skip the '<'
-        // get the first TypeParameter
-        typeParams.append(typeParamTypeToString(signature.substring(index), chopit));
-        index += unwrap(consumed_chars); // update position
-        // are there more TypeParameters?
-        while (signature.charAt(index) != '>') {
-            typeParams.append(", ");
-            typeParams.append(typeParamTypeToString(signature.substring(index), chopit));
-            index += unwrap(consumed_chars); // update position
+    public static String toHexString(final byte[] bytes) {
+        final StringBuilder buf = new StringBuilder();
+        for (int i = 0; i < bytes.length; i++) {
+            final short b = byteToShort(bytes[i]);
+            final String hex = Integer.toHexString(b);
+            if (b < 0x10) {
+                buf.append('0');
+            }
+            buf.append(hex);
+            if (i < bytes.length - 1) {
+                buf.append(' ');
+            }
         }
-        wrap(consumed_chars, index + 1); // account for the '>' char
-        return typeParams.append(">").toString();
+        return buf.toString();
     }
 
-
     /**
-     * Converts a type parameter signature to a string.
+     * Return type of method signature as a byte value as defined in <em>Constants</em>
      *
-     * @param  signature signature to convert
-     * @param  chopit flag that determines whether chopping is executed or not
-     * @return String containg human readable signature
+     * @param signature in format described above
+     * @return type of method signature
+     * @see Const
+     *
+     * @throws ClassFormatException if signature is not a method signature
      */
-    private static String typeParamTypeToString( final String signature, final boolean chopit ) {
-        int index = signature.indexOf(':');
-        if (index <= 0) {
-            throw new ClassFormatException("Invalid type parameter signature: " + signature);
-        }
-        // get the TypeParameter identifier
-        final StringBuilder typeParam = new StringBuilder(signature.substring(0, index));
-        index++;  // account for the ':'
-        if (signature.charAt(index) != ':') {
-            // we have a class bound
-            typeParam.append(" extends ");
-            typeParam.append(typeSignatureToString(signature.substring(index), chopit));
-            index += unwrap(consumed_chars); // update position
-        }
-        // look for interface bounds
-        while (signature.charAt(index) == ':') {
-            index++;  // skip over the ':'
-            typeParam.append(" & ");
-            typeParam.append(typeSignatureToString(signature.substring(index), chopit));
-            index += unwrap(consumed_chars); // update position
-        }
-        wrap(consumed_chars, index);
-        return typeParam.toString();
-    }
-
-
-    /**
-     * Converts a list of type signatures to a string.
-     *
-     * @param  signature signature to convert
-     * @param  chopit flag that determines whether chopping is executed or not
-     * @param  term character indicating the end of the list
-     * @return String containg human readable signature
-     */
-    private static String typeSignaturesToString( final String signature, final boolean chopit, final char term ) {
-        // The first character will be an 'open' that matches the 'close' contained in term.
-        final StringBuilder typeList = new StringBuilder(signature.substring(0, 1));
-        int index = 1;  // skip the 'open' character
-        // get the first Type in the list
-        if (signature.charAt(index) != term) {
-            typeList.append(typeSignatureToString(signature.substring(index), chopit));
-            index += unwrap(consumed_chars); // update position
-        }
-        // are there more types in the list?
-        while (signature.charAt(index) != term) {
-            typeList.append(", ");
-            typeList.append(typeSignatureToString(signature.substring(index), chopit));
-            index += unwrap(consumed_chars); // update position
-        }
-        wrap(consumed_chars, index + 1); // account for the term char
-        return typeList.append(term).toString();
-    }
-
-
-    /**
-     *
-     * This method converts a type signature string into a Java type declaration such as
-     * `String[]' and throws a `ClassFormatException' when the parsed type is invalid.
-     *
-     * @param  signature type signature
-     * @param  chopit flag that determines whether chopping is executed or not
-     * @return string containing human readable type signature
-     * @throws ClassFormatException
-     * @since 6.4.0
-     */
-    public static String typeSignatureToString( final String signature, final boolean chopit ) throws ClassFormatException {
-        //corrected concurrent private static field acess
-        wrap(consumed_chars, 1); // This is the default, read just one char like `B'
-        try {
-            switch (signature.charAt(0)) {
-                case 'B':
-                    return "byte";
-                case 'C':
-                    return "char";
-                case 'D':
-                    return "double";
-                case 'F':
-                    return "float";
-                case 'I':
-                    return "int";
-                case 'J':
-                    return "long";
-                case 'T': { // TypeVariableSignature
-                    final int index = signature.indexOf(';'); // Look for closing `;'
-                    if (index < 0) {
-                        throw new ClassFormatException("Invalid type variable signature: " + signature);
-                    }
-                    //corrected concurrent private static field acess
-                    wrap(consumed_chars, index + 1); // "Tblabla;" `T' and `;' are removed
-                    return compactClassName(signature.substring(1, index), chopit);
-                }
-                case 'L': { // Full class name
-                    // should this be a while loop? can there be more than
-                    // one generic clause?  (markro)
-                    int fromIndex = signature.indexOf('<'); // generic type?
-                    if (fromIndex < 0) {
-                        fromIndex = 0;
-                    } else {
-                        fromIndex = signature.indexOf('>', fromIndex);
-                        if (fromIndex < 0) {
-                            throw new ClassFormatException("Invalid signature: " + signature);
-                        }
-                    }
-                    final int index = signature.indexOf(';', fromIndex); // Look for closing `;'
-                    if (index < 0) {
-                        throw new ClassFormatException("Invalid signature: " + signature);
-                    }
-
-                    // check to see if there are any TypeArguments
-                    final int bracketIndex = signature.substring(0, index).indexOf('<');
-                    if (bracketIndex < 0) {
-                        // just a class identifier
-                        wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed
-                        return compactClassName(signature.substring(1, index), chopit);
-                    }
-                    // but make sure we are not looking past the end of the current item
-                    fromIndex = signature.indexOf(';');
-                    if (fromIndex < 0) {
-                        throw new ClassFormatException("Invalid signature: " + signature);
-                    }
-                    if (fromIndex < bracketIndex) {
-                        // just a class identifier
-                        wrap(consumed_chars, fromIndex + 1); // "Lblabla;" `L' and `;' are removed
-                        return compactClassName(signature.substring(1, fromIndex), chopit);
-                    }
-
-                    // we have TypeArguments; build up partial result
-                    // as we recurse for each TypeArgument
-                    final StringBuilder type = new StringBuilder(compactClassName(signature.substring(1, bracketIndex), chopit)).append("<");
-                    int consumed_chars = bracketIndex + 1; // Shadows global var
-
-                    // check for wildcards
-                    if (signature.charAt(consumed_chars) == '+') {
-                        type.append("? extends ");
-                        consumed_chars++;
-                    } else if (signature.charAt(consumed_chars) == '-') {
-                        type.append("? super ");
-                        consumed_chars++;
-                    }
-
-                    // get the first TypeArgument
-                    if (signature.charAt(consumed_chars) == '*') {
-                        type.append("?");
-                        consumed_chars++;
-                    } else {
-                        type.append(typeSignatureToString(signature.substring(consumed_chars), chopit));
-                        // update our consumed count by the number of characters the for type argument
-                        consumed_chars = unwrap(Utility.consumed_chars) + consumed_chars;
-                        wrap(Utility.consumed_chars, consumed_chars);
-                    }
-
-                    // are there more TypeArguments?
-                    while (signature.charAt(consumed_chars) != '>') {
-                        type.append(", ");
-                        // check for wildcards
-                        if (signature.charAt(consumed_chars) == '+') {
-                            type.append("? extends ");
-                            consumed_chars++;
-                        } else if (signature.charAt(consumed_chars) == '-') {
-                            type.append("? super ");
-                            consumed_chars++;
-                        }
-                        if (signature.charAt(consumed_chars) == '*') {
-                            type.append("?");
-                            consumed_chars++;
-                        } else {
-                            type.append(typeSignatureToString(signature.substring(consumed_chars), chopit));
-                            // update our consumed count by the number of characters the for type argument
-                            consumed_chars = unwrap(Utility.consumed_chars) + consumed_chars;
-                            wrap(Utility.consumed_chars, consumed_chars);
-                        }
-                    }
-
-                    // process the closing ">"
-                    consumed_chars++;
-                    type.append(">");
-
-                    if (signature.charAt(consumed_chars) == '.') {
-                        // we have a ClassTypeSignatureSuffix
-                        type.append(".");
-                        // convert SimpleClassTypeSignature to fake ClassTypeSignature
-                        // and then recurse to parse it
-                        type.append(typeSignatureToString("L" + signature.substring(consumed_chars+1), chopit));
-                        // update our consumed count by the number of characters the for type argument
-                        // note that this count includes the "L" we added, but that is ok
-                        // as it accounts for the "." we didn't consume
-                        consumed_chars = unwrap(Utility.consumed_chars) + consumed_chars;
-                        wrap(Utility.consumed_chars, consumed_chars);
-                        return type.toString();
-                    }
-                    if (signature.charAt(consumed_chars) != ';') {
-                        throw new ClassFormatException("Invalid signature: " + signature);
-                    }
-                    wrap(Utility.consumed_chars, consumed_chars + 1); // remove final ";"
-                    return type.toString();
-                }
-                case 'S':
-                    return "short";
-                case 'Z':
-                    return "boolean";
-                case '[': { // Array declaration
-                    int n;
-                    StringBuilder brackets;
-                    String type;
-                    int consumed_chars; // Shadows global var
-                    brackets = new StringBuilder(); // Accumulate []'s
-                    // Count opening brackets and look for optional size argument
-                    for (n = 0; signature.charAt(n) == '['; n++) {
-                        brackets.append("[]");
-                    }
-                    consumed_chars = n; // Remember value
-                    // The rest of the string denotes a `<field_type>'
-                    type = typeSignatureToString(signature.substring(n), chopit);
-                    //corrected concurrent private static field acess
-                    //Utility.consumed_chars += consumed_chars; is replaced by:
-                    final int _temp = unwrap(Utility.consumed_chars) + consumed_chars;
-                    wrap(Utility.consumed_chars, _temp);
-                    return type + brackets.toString();
-                }
-                case 'V':
-                    return "void";
-                default:
-                    throw new ClassFormatException("Invalid signature: `" + signature + "'");
-            }
-        } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid signature: " + signature, e);
-        }
-    }
-
-
-    /** Parse Java type such as "char", or "java.lang.String[]" and return the
-     * signature in byte code format, e.g. "C" or "[Ljava/lang/String;" respectively.
-     *
-     * @param  type Java type
-     * @return byte code signature
-     */
-    public static String getSignature( String type ) {
-        final StringBuilder buf = new StringBuilder();
-        final char[] chars = type.toCharArray();
-        boolean char_found = false;
-        boolean delim = false;
-        int index = -1;
-        loop: for (int i = 0; i < chars.length; i++) {
-            switch (chars[i]) {
-                case ' ':
-                case '\t':
-                case '\n':
-                case '\r':
-                case '\f':
-                    if (char_found) {
-                        delim = true;
-                    }
-                    break;
-                case '[':
-                    if (!char_found) {
-                        throw new IllegalArgumentException("Illegal type: " + type);
-                    }
-                    index = i;
-                    break loop;
-                default:
-                    char_found = true;
-                    if (!delim) {
-                        buf.append(chars[i]);
-                    }
-            }
-        }
-        int brackets = 0;
-        if (index > 0) {
-            brackets = countBrackets(type.substring(index));
-        }
-        type = buf.toString();
-        buf.setLength(0);
-        for (int i = 0; i < brackets; i++) {
-            buf.append('[');
-        }
-        boolean found = false;
-        for (int i = Const.T_BOOLEAN; (i <= Const.T_VOID) && !found; i++) {
-            if (Const.getTypeName(i).equals(type)) {
-                found = true;
-                buf.append(Const.getShortTypeName(i));
-            }
-        }
-        if (!found) {
-            buf.append('L').append(type.replace('.', '/')).append(';');
-        }
-        return buf.toString();
-    }
-
-
-    private static int countBrackets( final String brackets ) {
-        final char[] chars = brackets.toCharArray();
-        int count = 0;
-        boolean open = false;
-        for (final char c : chars) {
-            switch (c) {
-                case '[':
-                    if (open) {
-                        throw new IllegalArgumentException("Illegally nested brackets:" + brackets);
-                    }
-                    open = true;
-                    break;
-                case ']':
-                    if (!open) {
-                        throw new IllegalArgumentException("Illegally nested brackets:" + brackets);
-                    }
-                    open = false;
-                    count++;
-                    break;
-                default:
-                    // Don't care
-                    break;
-            }
-        }
-        if (open) {
-            throw new IllegalArgumentException("Illegally nested brackets:" + brackets);
-        }
-        return count;
-    }
-
-
-    /**
-     * Return type of method signature as a byte value as defined in <em>Constants</em>
-     *
-     * @param  signature in format described above
-     * @return type of method signature
-     * @see    Const
-     *
-     * @throws ClassFormatException if signature is not a method signature
-     */
-    public static byte typeOfMethodSignature( final String signature ) throws ClassFormatException {
+    public static byte typeOfMethodSignature(final String signature) throws ClassFormatException {
         int index;
         try {
             if (signature.charAt(0) != '(') {
@@ -1235,426 +1246,317 @@ public static byte typeOfMethodSignature( final String signature ) throws ClassF
         }
     }
 
-
     /**
      * Return type of signature as a byte value as defined in <em>Constants</em>
      *
-     * @param  signature in format described above
+     * @param signature in format described above
      * @return type of signature
-     * @see    Const
+     * @see Const
      *
      * @throws ClassFormatException if signature isn't a known type
      */
-    public static byte typeOfSignature( final String signature ) throws ClassFormatException {
+    public static byte typeOfSignature(final String signature) throws ClassFormatException {
         try {
             switch (signature.charAt(0)) {
-                case 'B':
-                    return Const.T_BYTE;
-                case 'C':
-                    return Const.T_CHAR;
-                case 'D':
-                    return Const.T_DOUBLE;
-                case 'F':
-                    return Const.T_FLOAT;
-                case 'I':
-                    return Const.T_INT;
-                case 'J':
-                    return Const.T_LONG;
-                case 'L':
-                case 'T':
-                    return Const.T_REFERENCE;
-                case '[':
-                    return Const.T_ARRAY;
-                case 'V':
-                    return Const.T_VOID;
-                case 'Z':
-                    return Const.T_BOOLEAN;
-                case 'S':
-                    return Const.T_SHORT;
-                case '!':
-                case '+':
-                case '*':
-                    return typeOfSignature(signature.substring(1));
-                default:
-                    throw new ClassFormatException("Invalid method signature: " + signature);
+            case 'B':
+                return Const.T_BYTE;
+            case 'C':
+                return Const.T_CHAR;
+            case 'D':
+                return Const.T_DOUBLE;
+            case 'F':
+                return Const.T_FLOAT;
+            case 'I':
+                return Const.T_INT;
+            case 'J':
+                return Const.T_LONG;
+            case 'L':
+            case 'T':
+                return Const.T_REFERENCE;
+            case '[':
+                return Const.T_ARRAY;
+            case 'V':
+                return Const.T_VOID;
+            case 'Z':
+                return Const.T_BOOLEAN;
+            case 'S':
+                return Const.T_SHORT;
+            case '!':
+            case '+':
+            case '*':
+                return typeOfSignature(signature.substring(1));
+            default:
+                throw new ClassFormatException("Invalid method signature: " + signature);
             }
         } catch (final StringIndexOutOfBoundsException e) {
             throw new ClassFormatException("Invalid method signature: " + signature, e);
         }
     }
 
-
-    /** Map opcode names to opcode numbers. E.g., return Constants.ALOAD for "aload"
-     */
-    public static short searchOpcode( String name ) {
-        name = name.toLowerCase(Locale.ENGLISH);
-        for (short i = 0; i < Const.OPCODE_NAMES_LENGTH; i++) {
-            if (Const.getOpcodeName(i).equals(name)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-
     /**
-     * Convert (signed) byte to (unsigned) short value, i.e., all negative
-     * values become positive.
-     */
-    private static short byteToShort( final byte b ) {
-        return (b < 0) ? (short) (256 + b) : (short) b;
-    }
-
-
-    /** Convert bytes into hexadecimal string
-     *
-     * @param bytes an array of bytes to convert to hexadecimal
+     * Converts a type parameter list signature to a string.
      *
-     * @return bytes as hexadecimal string, e.g. 00 fa 12 ...
+     * @param signature signature to convert
+     * @param chopit flag that determines whether chopping is executed or not
+     * @return String containg human readable signature
      */
-    public static String toHexString( final byte[] bytes ) {
-        final StringBuilder buf = new StringBuilder();
-        for (int i = 0; i < bytes.length; i++) {
-            final short b = byteToShort(bytes[i]);
-            final String hex = Integer.toHexString(b);
-            if (b < 0x10) {
-                buf.append('0');
-            }
-            buf.append(hex);
-            if (i < bytes.length - 1) {
-                buf.append(' ');
-            }
+    private static String typeParamTypesToString(final String signature, final boolean chopit) {
+        // The first character is guranteed to be '<'
+        final StringBuilder typeParams = new StringBuilder("<");
+        int index = 1; // skip the '<'
+        // get the first TypeParameter
+        typeParams.append(typeParamTypeToString(signature.substring(index), chopit));
+        index += unwrap(CONSUMER_CHARS); // update position
+        // are there more TypeParameters?
+        while (signature.charAt(index) != '>') {
+            typeParams.append(", ");
+            typeParams.append(typeParamTypeToString(signature.substring(index), chopit));
+            index += unwrap(CONSUMER_CHARS); // update position
         }
-        return buf.toString();
-    }
-
-
-    /**
-     * Return a string for an integer justified left or right and filled up with
-     * `fill' characters if necessary.
-     *
-     * @param i integer to format
-     * @param length length of desired string
-     * @param left_justify format left or right
-     * @param fill fill character
-     * @return formatted int
-     */
-    public static String format( final int i, final int length, final boolean left_justify, final char fill ) {
-        return fillup(Integer.toString(i), length, left_justify, fill);
+        wrap(CONSUMER_CHARS, index + 1); // account for the '>' char
+        return typeParams.append(">").toString();
     }
 
-
     /**
-     * Fillup char with up to length characters with char `fill' and justify it left or right.
+     * Converts a type parameter signature to a string.
      *
-     * @param str string to format
-     * @param length length of desired string
-     * @param left_justify format left or right
-     * @param fill fill character
-     * @return formatted string
+     * @param signature signature to convert
+     * @param chopit flag that determines whether chopping is executed or not
+     * @return String containg human readable signature
      */
-    public static String fillup( final String str, final int length, final boolean left_justify, final char fill ) {
-        final int len = length - str.length();
-        final char[] buf = new char[(len < 0) ? 0 : len];
-        for (int j = 0; j < buf.length; j++) {
-            buf[j] = fill;
-        }
-        if (left_justify) {
-            return str + new String(buf);
-        }
-        return new String(buf) + str;
-    }
-
-
-    static boolean equals( final byte[] a, final byte[] b ) {
-        int size;
-        if ((size = a.length) != b.length) {
-            return false;
-        }
-        for (int i = 0; i < size; i++) {
-            if (a[i] != b[i]) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-
-    public static void printArray( final PrintStream out, final Object[] obj ) {
-        out.println(printArray(obj, true));
-    }
-
-
-    public static void printArray( final PrintWriter out, final Object[] obj ) {
-        out.println(printArray(obj, true));
-    }
-
-
-    public static String printArray( final Object[] obj ) {
-        return printArray(obj, true);
-    }
-
-
-    public static String printArray( final Object[] obj, final boolean braces ) {
-        return printArray(obj, braces, false);
-    }
-
-
-    public static String printArray( final Object[] obj, final boolean braces, final boolean quote ) {
-        if (obj == null) {
-            return null;
-        }
-        final StringBuilder buf = new StringBuilder();
-        if (braces) {
-            buf.append('{');
+    private static String typeParamTypeToString(final String signature, final boolean chopit) {
+        int index = signature.indexOf(':');
+        if (index <= 0) {
+            throw new ClassFormatException("Invalid type parameter signature: " + signature);
         }
-        for (int i = 0; i < obj.length; i++) {
-            if (obj[i] != null) {
-                buf.append(quote ? "\"" : "").append(obj[i]).append(quote ? "\"" : "");
-            } else {
-                buf.append("null");
-            }
-            if (i < obj.length - 1) {
-                buf.append(", ");
-            }
+        // get the TypeParameter identifier
+        final StringBuilder typeParam = new StringBuilder(signature.substring(0, index));
+        index++; // account for the ':'
+        if (signature.charAt(index) != ':') {
+            // we have a class bound
+            typeParam.append(" extends ");
+            typeParam.append(typeSignatureToString(signature.substring(index), chopit));
+            index += unwrap(CONSUMER_CHARS); // update position
         }
-        if (braces) {
-            buf.append('}');
+        // look for interface bounds
+        while (signature.charAt(index) == ':') {
+            index++; // skip over the ':'
+            typeParam.append(" & ");
+            typeParam.append(typeSignatureToString(signature.substring(index), chopit));
+            index += unwrap(CONSUMER_CHARS); // update position
         }
-        return buf.toString();
-    }
-
-
-    /**
-     * @param ch the character to test if it's part of an identifier
-     *
-     * @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _)
-     */
-    public static boolean isJavaIdentifierPart( final char ch ) {
-        return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z'))
-                || ((ch >= '0') && (ch <= '9')) || (ch == '_');
+        wrap(CONSUMER_CHARS, index);
+        return typeParam.toString();
     }
 
-
     /**
-     * Encode byte array it into Java identifier string, i.e., a string
-     * that only contains the following characters: (a, ... z, A, ... Z,
-     * 0, ... 9, _, $).  The encoding algorithm itself is not too
-     * clever: if the current byte's ASCII value already is a valid Java
-     * identifier part, leave it as it is. Otherwise it writes the
-     * escape character($) followed by:
-     *
-     * <ul>
-     *   <li> the ASCII value as a hexadecimal string, if the value is not in the range 200..247</li>
-     *   <li>a Java identifier char not used in a lowercase hexadecimal string, if the value is in the range 200..247</li>
-     * </ul>
-     *
-     * <p>This operation inflates the original byte array by roughly 40-50%</p>
-     *
-     * @param bytes the byte array to convert
-     * @param compress use gzip to minimize string
+     * Converts a list of type signatures to a string.
      *
-     * @throws IOException if there's a gzip exception
+     * @param signature signature to convert
+     * @param chopit flag that determines whether chopping is executed or not
+     * @param term character indicating the end of the list
+     * @return String containg human readable signature
      */
-    public static String encode(byte[] bytes, final boolean compress) throws IOException {
-        if (compress) {
-            try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                    GZIPOutputStream gos = new GZIPOutputStream(baos)) {
-                gos.write(bytes, 0, bytes.length);
-                gos.finish();
-                bytes = baos.toByteArray();
-            }
+    private static String typeSignaturesToString(final String signature, final boolean chopit, final char term) {
+        // The first character will be an 'open' that matches the 'close' contained in term.
+        final StringBuilder typeList = new StringBuilder(signature.substring(0, 1));
+        int index = 1; // skip the 'open' character
+        // get the first Type in the list
+        if (signature.charAt(index) != term) {
+            typeList.append(typeSignatureToString(signature.substring(index), chopit));
+            index += unwrap(CONSUMER_CHARS); // update position
         }
-        final CharArrayWriter caw = new CharArrayWriter();
-        try (JavaWriter jw = new JavaWriter(caw)) {
-            for (final byte b : bytes) {
-                final int in = b & 0x000000ff; // Normalize to unsigned
-                jw.write(in);
-            }
+        // are there more types in the list?
+        while (signature.charAt(index) != term) {
+            typeList.append(", ");
+            typeList.append(typeSignatureToString(signature.substring(index), chopit));
+            index += unwrap(CONSUMER_CHARS); // update position
         }
-        return caw.toString();
+        wrap(CONSUMER_CHARS, index + 1); // account for the term char
+        return typeList.append(term).toString();
     }
 
-
     /**
-     * Decode a string back to a byte array.
      *
-     * @param s the string to convert
-     * @param uncompress use gzip to uncompress the stream of bytes
+     * This method converts a type signature string into a Java type declaration such as 'String[]' and throws a
+     * 'ClassFormatException' when the parsed type is invalid.
      *
-     * @throws IOException if there's a gzip exception
-     */
-    public static byte[] decode(final String s, final boolean uncompress) throws IOException {
-        byte[] bytes;
-        try (JavaReader jr = new JavaReader(new CharArrayReader(s.toCharArray()));
-                ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
-            int ch;
-            while ((ch = jr.read()) >= 0) {
-                bos.write(ch);
-            }
-            bytes = bos.toByteArray();
-        }
-        if (uncompress) {
-            final GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes));
-            final byte[] tmp = new byte[bytes.length * 3]; // Rough estimate
-            int count = 0;
-            int b;
-            while ((b = gis.read()) >= 0) {
-                tmp[count++] = (byte) b;
-            }
-            bytes = new byte[count];
-            System.arraycopy(tmp, 0, bytes, 0, count);
-        }
-        return bytes;
-    }
-
-    // A-Z, g-z, _, $
-    private static final int FREE_CHARS = 48;
-    private static int[] CHAR_MAP = new int[FREE_CHARS];
-    private static int[] MAP_CHAR = new int[256]; // Reverse map
-    private static final char ESCAPE_CHAR = '$';
-    static {
-        int j = 0;
-        for (int i = 'A'; i <= 'Z'; i++) {
-            CHAR_MAP[j] = i;
-            MAP_CHAR[i] = j;
-            j++;
-        }
-        for (int i = 'g'; i <= 'z'; i++) {
-            CHAR_MAP[j] = i;
-            MAP_CHAR[i] = j;
-            j++;
-        }
-        CHAR_MAP[j] = '$';
-        MAP_CHAR['$'] = j;
-        j++;
-        CHAR_MAP[j] = '_';
-        MAP_CHAR['_'] = j;
-    }
-
-    /**
-     * Decode characters into bytes.
-     * Used by <a href="Utility.html#decode(java.lang.String, boolean)">decode()</a>
+     * @param signature type signature
+     * @param chopit flag that determines whether chopping is executed or not
+     * @return string containing human readable type signature
+     * @throws ClassFormatException if a class is malformed or cannot be interpreted as a class file
+     * @since 6.4.0
      */
-    private static class JavaReader extends FilterReader {
-
-        public JavaReader(final Reader in) {
-            super(in);
-        }
-
-
-        @Override
-        public int read() throws IOException {
-            final int b = in.read();
-            if (b != ESCAPE_CHAR) {
-                return b;
-            }
-            final int i = in.read();
-            if (i < 0) {
-                return -1;
-            }
-            if (((i >= '0') && (i <= '9')) || ((i >= 'a') && (i <= 'f'))) { // Normal escape
-                final int j = in.read();
-                if (j < 0) {
-                    return -1;
+    public static String typeSignatureToString(final String signature, final boolean chopit) throws ClassFormatException {
+        // corrected concurrent private static field acess
+        wrap(CONSUMER_CHARS, 1); // This is the default, read just one char like 'B'
+        try {
+            switch (signature.charAt(0)) {
+            case 'B':
+                return "byte";
+            case 'C':
+                return "char";
+            case 'D':
+                return "double";
+            case 'F':
+                return "float";
+            case 'I':
+                return "int";
+            case 'J':
+                return "long";
+            case 'T': { // TypeVariableSignature
+                final int index = signature.indexOf(';'); // Look for closing ';'
+                if (index < 0) {
+                    throw new ClassFormatException("Invalid type variable signature: " + signature);
                 }
-                final char[] tmp = {
-                        (char) i, (char) j
-                };
-                final int s = Integer.parseInt(new String(tmp), 16);
-                return s;
+                // corrected concurrent private static field acess
+                wrap(CONSUMER_CHARS, index + 1); // "Tblabla;" 'T' and ';' are removed
+                return compactClassName(signature.substring(1, index), chopit);
             }
-            return MAP_CHAR[i];
-        }
-
-
-        @Override
-        public int read( final char[] cbuf, final int off, final int len ) throws IOException {
-            for (int i = 0; i < len; i++) {
-                cbuf[off + i] = (char) read();
-            }
-            return len;
-        }
-    }
+            case 'L': { // Full class name
+                // should this be a while loop? can there be more than
+                // one generic clause? (markro)
+                int fromIndex = signature.indexOf('<'); // generic type?
+                if (fromIndex < 0) {
+                    fromIndex = 0;
+                } else {
+                    fromIndex = signature.indexOf('>', fromIndex);
+                    if (fromIndex < 0) {
+                        throw new ClassFormatException("Invalid signature: " + signature);
+                    }
+                }
+                final int index = signature.indexOf(';', fromIndex); // Look for closing ';'
+                if (index < 0) {
+                    throw new ClassFormatException("Invalid signature: " + signature);
+                }
 
-    /**
-     * Encode bytes into valid java identifier characters.
-     * Used by <a href="Utility.html#encode(byte[], boolean)">encode()</a>
-     */
-    private static class JavaWriter extends FilterWriter {
+                // check to see if there are any TypeArguments
+                final int bracketIndex = signature.substring(0, index).indexOf('<');
+                if (bracketIndex < 0) {
+                    // just a class identifier
+                    wrap(CONSUMER_CHARS, index + 1); // "Lblabla;" 'L' and ';' are removed
+                    return compactClassName(signature.substring(1, index), chopit);
+                }
+                // but make sure we are not looking past the end of the current item
+                fromIndex = signature.indexOf(';');
+                if (fromIndex < 0) {
+                    throw new ClassFormatException("Invalid signature: " + signature);
+                }
+                if (fromIndex < bracketIndex) {
+                    // just a class identifier
+                    wrap(CONSUMER_CHARS, fromIndex + 1); // "Lblabla;" 'L' and ';' are removed
+                    return compactClassName(signature.substring(1, fromIndex), chopit);
+                }
 
-        public JavaWriter(final Writer out) {
-            super(out);
-        }
+                // we have TypeArguments; build up partial result
+                // as we recurse for each TypeArgument
+                final StringBuilder type = new StringBuilder(compactClassName(signature.substring(1, bracketIndex), chopit)).append("<");
+                int consumedChars = bracketIndex + 1; // Shadows global var
+
+                // check for wildcards
+                if (signature.charAt(consumedChars) == '+') {
+                    type.append("? extends ");
+                    consumedChars++;
+                } else if (signature.charAt(consumedChars) == '-') {
+                    type.append("? super ");
+                    consumedChars++;
+                }
 
+                // get the first TypeArgument
+                if (signature.charAt(consumedChars) == '*') {
+                    type.append("?");
+                    consumedChars++;
+                } else {
+                    type.append(typeSignatureToString(signature.substring(consumedChars), chopit));
+                    // update our consumed count by the number of characters the for type argument
+                    consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars;
+                    wrap(Utility.CONSUMER_CHARS, consumedChars);
+                }
 
-        @Override
-        public void write( final int b ) throws IOException {
-            if (isJavaIdentifierPart((char) b) && (b != ESCAPE_CHAR)) {
-                out.write(b);
-            } else {
-                out.write(ESCAPE_CHAR); // Escape character
-                // Special escape
-                if (b >= 0 && b < FREE_CHARS) {
-                    out.write(CHAR_MAP[b]);
-                } else { // Normal escape
-                    final char[] tmp = Integer.toHexString(b).toCharArray();
-                    if (tmp.length == 1) {
-                        out.write('0');
-                        out.write(tmp[0]);
+                // are there more TypeArguments?
+                while (signature.charAt(consumedChars) != '>') {
+                    type.append(", ");
+                    // check for wildcards
+                    if (signature.charAt(consumedChars) == '+') {
+                        type.append("? extends ");
+                        consumedChars++;
+                    } else if (signature.charAt(consumedChars) == '-') {
+                        type.append("? super ");
+                        consumedChars++;
+                    }
+                    if (signature.charAt(consumedChars) == '*') {
+                        type.append("?");
+                        consumedChars++;
                     } else {
-                        out.write(tmp[0]);
-                        out.write(tmp[1]);
+                        type.append(typeSignatureToString(signature.substring(consumedChars), chopit));
+                        // update our consumed count by the number of characters the for type argument
+                        consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars;
+                        wrap(Utility.CONSUMER_CHARS, consumedChars);
                     }
                 }
-            }
-        }
-
 
-        @Override
-        public void write( final char[] cbuf, final int off, final int len ) throws IOException {
-            for (int i = 0; i < len; i++) {
-                write(cbuf[off + i]);
+                // process the closing ">"
+                consumedChars++;
+                type.append(">");
+
+                if (signature.charAt(consumedChars) == '.') {
+                    // we have a ClassTypeSignatureSuffix
+                    type.append(".");
+                    // convert SimpleClassTypeSignature to fake ClassTypeSignature
+                    // and then recurse to parse it
+                    type.append(typeSignatureToString("L" + signature.substring(consumedChars + 1), chopit));
+                    // update our consumed count by the number of characters the for type argument
+                    // note that this count includes the "L" we added, but that is ok
+                    // as it accounts for the "." we didn't consume
+                    consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars;
+                    wrap(Utility.CONSUMER_CHARS, consumedChars);
+                    return type.toString();
+                }
+                if (signature.charAt(consumedChars) != ';') {
+                    throw new ClassFormatException("Invalid signature: " + signature);
+                }
+                wrap(Utility.CONSUMER_CHARS, consumedChars + 1); // remove final ";"
+                return type.toString();
             }
-        }
-
-
-        @Override
-        public void write( final String str, final int off, final int len ) throws IOException {
-            write(str.toCharArray(), off, len);
+            case 'S':
+                return "short";
+            case 'Z':
+                return "boolean";
+            case '[': { // Array declaration
+                int n;
+                StringBuilder brackets;
+                String type;
+                int consumedChars; // Shadows global var
+                brackets = new StringBuilder(); // Accumulate []'s
+                // Count opening brackets and look for optional size argument
+                for (n = 0; signature.charAt(n) == '['; n++) {
+                    brackets.append("[]");
+                }
+                consumedChars = n; // Remember value
+                // The rest of the string denotes a '<field_type>'
+                type = typeSignatureToString(signature.substring(n), chopit);
+                // corrected concurrent private static field acess
+                // Utility.consumed_chars += consumed_chars; is replaced by:
+                final int temp = unwrap(Utility.CONSUMER_CHARS) + consumedChars;
+                wrap(Utility.CONSUMER_CHARS, temp);
+                return type + brackets.toString();
+            }
+            case 'V':
+                return "void";
+            default:
+                throw new ClassFormatException("Invalid signature: '" + signature + "'");
+            }
+        } catch (final StringIndexOutOfBoundsException e) { // Should never occur
+            throw new ClassFormatException("Invalid signature: " + signature, e);
         }
     }
 
+    private static int unwrap(final ThreadLocal<Integer> tl) {
+        return tl.get();
+    }
 
-    /**
-     * Escape all occurences of newline chars '\n', quotes \", etc.
-     */
-    public static String convertString( final String label ) {
-        final char[] ch = label.toCharArray();
-        final StringBuilder buf = new StringBuilder();
-        for (final char element : ch) {
-            switch (element) {
-                case '\n':
-                    buf.append("\\n");
-                    break;
-                case '\r':
-                    buf.append("\\r");
-                    break;
-                case '\"':
-                    buf.append("\\\"");
-                    break;
-                case '\'':
-                    buf.append("\\'");
-                    break;
-                case '\\':
-                    buf.append("\\\\");
-                    break;
-                default:
-                    buf.append(element);
-                    break;
-            }
-        }
-        return buf.toString();
+    private static void wrap(final ThreadLocal<Integer> tl, final int value) {
+        tl.set(value);
     }
 
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Visitor.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Visitor.java
index 01fe6a79d4a..74cb8400d3e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Visitor.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Visitor.java
@@ -22,13 +22,30 @@
 package com.sun.org.apache.bcel.internal.classfile;
 
 /**
- * Interface to make use of the Visitor pattern programming style. I.e. a class
- * that implements this interface can traverse the contents of a Java class just
- * by calling the `accept' method which all classes have.
- *
+ * Interface to make use of the Visitor pattern programming style. I.e. a class that implements this interface can
+ * traverse the contents of a Java class just by calling the 'accept' method which all classes have.
  */
-public interface Visitor
-{
+public interface Visitor {
+    /**
+     * @since 6.0
+     */
+    void visitAnnotation(Annotations obj);
+
+    /**
+     * @since 6.0
+     */
+    void visitAnnotationDefault(AnnotationDefault obj);
+
+    /**
+     * @since 6.0
+     */
+    void visitAnnotationEntry(AnnotationEntry obj);
+
+    /**
+     * @since 6.0
+     */
+    void visitBootstrapMethods(BootstrapMethods obj);
+
     void visitCode(Code obj);
 
     void visitCodeException(CodeException obj);
@@ -37,6 +54,13 @@ public interface Visitor
 
     void visitConstantDouble(ConstantDouble obj);
 
+    /**
+     * @since 6.3
+     */
+    default void visitConstantDynamic(final ConstantDynamic constantDynamic) {
+        // empty
+    }
+
     void visitConstantFieldref(ConstantFieldref obj);
 
     void visitConstantFloat(ConstantFloat obj);
@@ -49,10 +73,30 @@ public interface Visitor
 
     void visitConstantLong(ConstantLong obj);
 
+    /**
+     * @since 6.0
+     */
+    void visitConstantMethodHandle(ConstantMethodHandle obj);
+
     void visitConstantMethodref(ConstantMethodref obj);
 
+    /**
+     * @since 6.0
+     */
+    void visitConstantMethodType(ConstantMethodType obj);
+
+    /**
+     * @since 6.1
+     */
+    void visitConstantModule(ConstantModule constantModule);
+
     void visitConstantNameAndType(ConstantNameAndType obj);
 
+    /**
+     * @since 6.1
+     */
+    void visitConstantPackage(ConstantPackage constantPackage);
+
     void visitConstantPool(ConstantPool obj);
 
     void visitConstantString(ConstantString obj);
@@ -63,6 +107,11 @@ public interface Visitor
 
     void visitDeprecated(Deprecated obj);
 
+    /**
+     * @since 6.0
+     */
+    void visitEnclosingMethod(EnclosingMethod obj);
+
     void visitExceptionTable(ExceptionTable obj);
 
     void visitField(Field obj);
@@ -81,59 +130,12 @@ public interface Visitor
 
     void visitLocalVariableTable(LocalVariableTable obj);
 
-    void visitMethod(Method obj);
-
-    void visitSignature(Signature obj);
-
-    void visitSourceFile(SourceFile obj);
-
-    void visitSynthetic(Synthetic obj);
-
-    void visitUnknown(Unknown obj);
-
-    void visitStackMap(StackMap obj);
-
-    void visitStackMapEntry(StackMapEntry obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitAnnotation(Annotations obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitParameterAnnotation(ParameterAnnotations obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitAnnotationEntry(AnnotationEntry obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitAnnotationDefault(AnnotationDefault obj);
-
     /**
      * @since 6.0
      */
     void visitLocalVariableTypeTable(LocalVariableTypeTable obj);
 
-    /**
-     * @since 6.0
-     */
-    void visitEnclosingMethod(EnclosingMethod obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitBootstrapMethods(BootstrapMethods obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitMethodParameters(MethodParameters obj);
+    void visitMethod(Method obj);
 
     /**
      * @since 6.4.0
@@ -145,34 +147,7 @@ default void visitMethodParameter(final MethodParameter obj) {
     /**
      * @since 6.0
      */
-    void visitConstantMethodType(ConstantMethodType obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitConstantMethodHandle(ConstantMethodHandle obj);
-
-    /**
-     * @since 6.0
-     */
-    void visitParameterAnnotationEntry(ParameterAnnotationEntry obj);
-
-    /**
-     * @since 6.1
-     */
-    void visitConstantPackage(ConstantPackage constantPackage);
-
-    /**
-     * @since 6.1
-     */
-    void visitConstantModule(ConstantModule constantModule);
-
-    /**
-     * @since 6.3
-     */
-    default void visitConstantDynamic(final ConstantDynamic constantDynamic) {
-        // empty
-    }
+    void visitMethodParameters(MethodParameters obj);
 
     /**
      * @since 6.4.0
@@ -184,14 +159,14 @@ default void visitModule(final Module constantModule) {
     /**
      * @since 6.4.0
      */
-    default void visitModuleRequires(final ModuleRequires constantModule) {
+    default void visitModuleExports(final ModuleExports constantModule) {
         // empty
     }
 
     /**
      * @since 6.4.0
      */
-    default void visitModuleExports(final ModuleExports constantModule) {
+    default void visitModuleMainClass(final ModuleMainClass obj) {
         // empty
     }
 
@@ -205,21 +180,21 @@ default void visitModuleOpens(final ModuleOpens constantModule) {
     /**
      * @since 6.4.0
      */
-    default void visitModuleProvides(final ModuleProvides constantModule) {
+    default void visitModulePackages(final ModulePackages constantModule) {
         // empty
     }
 
     /**
      * @since 6.4.0
      */
-    default void visitModulePackages(final ModulePackages constantModule) {
+    default void visitModuleProvides(final ModuleProvides constantModule) {
         // empty
     }
 
     /**
      * @since 6.4.0
      */
-    default void visitModuleMainClass(final ModuleMainClass obj) {
+    default void visitModuleRequires(final ModuleRequires constantModule) {
         // empty
     }
 
@@ -236,4 +211,26 @@ default void visitNestHost(final NestHost obj) {
     default void visitNestMembers(final NestMembers obj) {
         // empty
     }
+
+    /**
+     * @since 6.0
+     */
+    void visitParameterAnnotation(ParameterAnnotations obj);
+
+    /**
+     * @since 6.0
+     */
+    void visitParameterAnnotationEntry(ParameterAnnotationEntry obj);
+
+    void visitSignature(Signature obj);
+
+    void visitSourceFile(SourceFile obj);
+
+    void visitStackMap(StackMap obj);
+
+    void visitStackMapEntry(StackMapEntry obj);
+
+    void visitSynthetic(Synthetic obj);
+
+    void visitUnknown(Unknown obj);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AALOAD.java
index b03235eb9bc..19bd38d0a7d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AALOAD.java
@@ -23,28 +23,28 @@
 
 /**
  * AALOAD - Load reference from array
- * <PRE>Stack: ..., arrayref, index -&gt; value</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; value
+ * </PRE>
  */
 public class AALOAD extends ArrayInstruction implements StackProducer {
 
-    /** Load reference from array
+    /**
+     * Load reference from array
      */
     public AALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.AALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AASTORE.java
index 1dab21a2ff5..9561ab4c77b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AASTORE.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * AASTORE -  Store into reference array
- * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ * AASTORE - Store into reference array
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value -&gt; ...
+ * </PRE>
  */
 public class AASTORE extends ArrayInstruction implements StackConsumer {
 
-    /** Store into reference array
+    /**
+     * Store into reference array
      */
     public AASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.AASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java
index a15aa1af40d..95556b9d085 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ACONST_NULL.java
@@ -23,8 +23,10 @@
 
 /**
  * ACONST_NULL - Push null reference
- * <PRE>Stack: ... -&gt; ..., null</PRE>
  *
+ * <PRE>
+ * Stack: ... -&gt; ..., null
+ * </PRE>
  */
 public class ACONST_NULL extends Instruction implements PushInstruction, TypedInstruction {
 
@@ -35,28 +37,25 @@ public ACONST_NULL() {
         super(com.sun.org.apache.bcel.internal.Const.ACONST_NULL, (short) 1);
     }
 
-
-    /** @return Type.NULL
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.NULL;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitPushInstruction(this);
         v.visitTypedInstruction(this);
         v.visitACONST_NULL(this);
     }
+
+    /**
+     * @return Type.NULL
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.NULL;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ALOAD.java
index ec2bcb657b0..8db0f9fadeb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ALOAD.java
@@ -20,43 +20,40 @@
 
 package com.sun.org.apache.bcel.internal.generic;
 
-import com.sun.org.apache.bcel.internal.Const;
-
 /**
  * ALOAD - Load reference from local variable
- * <PRE>Stack: ... -&gt; ..., objectref</PRE>
  *
+ * <PRE>
+ * Stack: ... -&gt; ..., objectref
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class ALOAD extends LoadInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ALOAD() {
-        super(Const.ALOAD, Const.ALOAD_0);
+        super(com.sun.org.apache.bcel.internal.Const.ALOAD, com.sun.org.apache.bcel.internal.Const.ALOAD_0);
     }
 
-
-    /** Load reference from local variable
+    /**
+     * Load reference from local variable
+     *
      * @param n index of local variable
      */
     public ALOAD(final int n) {
-        super(Const.ALOAD, Const.ALOAD_0, n);
+        super(com.sun.org.apache.bcel.internal.Const.ALOAD, com.sun.org.apache.bcel.internal.Const.ALOAD_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitALOAD(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java
index f81d6213ae5..eabf15c38b4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ANEWARRAY.java
@@ -24,43 +24,32 @@
 import com.sun.org.apache.bcel.internal.ExceptionConst;
 
 /**
- * ANEWARRAY -  Create new array of references
- * <PRE>Stack: ..., count -&gt; ..., arrayref</PRE>
+ * ANEWARRAY - Create new array of references
  *
+ * <PRE>
+ * Stack: ..., count -&gt; ..., arrayref
+ * </PRE>
  */
-public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction,
-        ExceptionThrower, StackConsumer, StackProducer {
+public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower, StackConsumer, StackProducer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ANEWARRAY() {
     }
 
-
     public ANEWARRAY(final int index) {
         super(com.sun.org.apache.bcel.internal.Const.ANEWARRAY, index);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION,
-            ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLoadClass(this);
         v.visitAllocationInstruction(this);
         v.visitExceptionThrower(this);
@@ -70,13 +59,17 @@ public void accept( final Visitor v ) {
         v.visitANEWARRAY(this);
     }
 
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION);
+    }
 
     @Override
-    public ObjectType getLoadClassType( final ConstantPoolGen cpg ) {
+    public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
         Type t = getType(cpg);
         if (t instanceof ArrayType) {
             t = ((ArrayType) t).getBasicType();
         }
-        return (t instanceof ObjectType) ? (ObjectType) t : null;
+        return t instanceof ObjectType ? (ObjectType) t : null;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARETURN.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARETURN.java
index 7231236e28b..ff2428d457c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARETURN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARETURN.java
@@ -22,9 +22,11 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * ARETURN -  Return reference from method
- * <PRE>Stack: ..., objectref -&gt; &lt;empty&gt;</PRE>
+ * ARETURN - Return reference from method
  *
+ * <PRE>
+ * Stack: ..., objectref -&gt; &lt;empty&gt;
+ * </PRE>
  */
 public class ARETURN extends ReturnInstruction {
 
@@ -35,17 +37,14 @@ public ARETURN() {
         super(com.sun.org.apache.bcel.internal.Const.ARETURN);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java
index 287a86de707..2d7188e9174 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ARRAYLENGTH.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,43 +23,40 @@
 import com.sun.org.apache.bcel.internal.ExceptionConst;
 
 /**
- * ARRAYLENGTH -  Get length of array
- * <PRE>Stack: ..., arrayref -&gt; ..., length</PRE>
+ * ARRAYLENGTH - Get length of array
  *
- * @LastModified: Jun 2019
+ * <PRE>
+ * Stack: ..., arrayref -&gt; ..., length
+ * </PRE>
+ * @LastModified: Feb 2023
  */
-public class ARRAYLENGTH extends Instruction
-    implements ExceptionThrower, StackProducer, StackConsumer /* since 6.0 */ {
+public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer, StackConsumer /* since 6.0 */ {
 
-    /** Get length of array
+    /**
+     * Get length of array
      */
     public ARRAYLENGTH() {
         super(com.sun.org.apache.bcel.internal.Const.ARRAYLENGTH, (short) 1);
     }
 
-
-    /** @return exceptions this instruction may cause
-     */
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.NULL_POINTER_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitStackProducer(this);
         v.visitARRAYLENGTH(this);
     }
+
+    /**
+     * @return exceptions this instruction may cause
+     */
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.NULL_POINTER_EXCEPTION};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ASTORE.java
index e68b2935762..7852c66466f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ASTORE.java
@@ -19,43 +19,40 @@
  */
 package com.sun.org.apache.bcel.internal.generic;
 
-import com.sun.org.apache.bcel.internal.Const;
-
 /**
  * ASTORE - Store reference into local variable
- * <PRE>Stack ..., objectref -&gt; ... </PRE>
  *
+ * <PRE>
+ * Stack ..., objectref -&gt; ...
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class ASTORE extends StoreInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ASTORE() {
-        super(Const.ASTORE, Const.ASTORE_0);
+        super(com.sun.org.apache.bcel.internal.Const.ASTORE, com.sun.org.apache.bcel.internal.Const.ASTORE_0);
     }
 
-
-    /** Store reference into local variable
+    /**
+     * Store reference into local variable
+     *
      * @param n index of local variable
      */
     public ASTORE(final int n) {
-        super(Const.ASTORE, Const.ASTORE_0, n);
+        super(com.sun.org.apache.bcel.internal.Const.ASTORE, com.sun.org.apache.bcel.internal.Const.ASTORE_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitASTORE(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ATHROW.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ATHROW.java
index 50d38bc353c..bb2e953f850 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ATHROW.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ATHROW.java
@@ -23,43 +23,39 @@
 import com.sun.org.apache.bcel.internal.ExceptionConst;
 
 /**
- * ATHROW -  Throw exception
- * <PRE>Stack: ..., objectref -&gt; objectref</PRE>
+ * ATHROW - Throw exception
  *
- * @LastModified: Jan 2020
+ * <PRE>
+ * Stack: ..., objectref -&gt; objectref
+ * </PRE>
  */
 public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower {
 
     /**
-     *  Throw exception
+     * Throw exception
      */
     public ATHROW() {
         super(com.sun.org.apache.bcel.internal.Const.ATHROW, (short) 1);
     }
 
-
-    /** @return exceptions this instruction may cause
-     */
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.THROWABLE
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitUnconditionalBranch(this);
         v.visitExceptionThrower(this);
         v.visitATHROW(this);
     }
+
+    /**
+     * @return exceptions this instruction may cause
+     */
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.THROWABLE};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java
index bf88d81087c..8e8626d32d0 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AllocationInstruction.java
@@ -23,7 +23,6 @@
 
 /**
  * Denote family of instructions that allocates space in the heap.
- *
  */
 public interface AllocationInstruction {
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java
index e58f6006969..1ed232d7292 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationElementValueGen.java
@@ -30,61 +30,48 @@
 /**
  * @since 6.0
  */
-public class AnnotationElementValueGen extends ElementValueGen
-{
+public class AnnotationElementValueGen extends ElementValueGen {
     // For annotation element values, this is the annotation
     private final AnnotationEntryGen a;
 
-    public AnnotationElementValueGen(final AnnotationEntryGen a, final ConstantPoolGen cpool)
-    {
+    public AnnotationElementValueGen(final AnnotationElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
+        super(ANNOTATION, cpool);
+        a = new AnnotationEntryGen(value.getAnnotationEntry(), cpool, copyPoolEntries);
+    }
+
+    public AnnotationElementValueGen(final AnnotationEntryGen a, final ConstantPoolGen cpool) {
         super(ANNOTATION, cpool);
         this.a = a;
     }
 
-    public AnnotationElementValueGen(final int type, final AnnotationEntryGen annotation,
-            final ConstantPoolGen cpool)
-    {
+    public AnnotationElementValueGen(final int type, final AnnotationEntryGen annotation, final ConstantPoolGen cpool) {
         super(type, cpool);
         if (type != ANNOTATION) {
-            throw new IllegalArgumentException(
-                    "Only element values of type annotation can be built with this ctor - type specified: " + type);
+            throw new IllegalArgumentException("Only element values of type annotation can be built with this ctor - type specified: " + type);
         }
         this.a = annotation;
     }
 
-    public AnnotationElementValueGen(final AnnotationElementValue value,
-            final ConstantPoolGen cpool, final boolean copyPoolEntries)
-    {
-        super(ANNOTATION, cpool);
-        a = new AnnotationEntryGen(value.getAnnotationEntry(), cpool, copyPoolEntries);
-    }
-
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
+    public void dump(final DataOutputStream dos) throws IOException {
         dos.writeByte(super.getElementValueType()); // u1 type of value (ANNOTATION == '@')
         a.dump(dos);
     }
 
-    @Override
-    public String stringifyValue()
-    {
-        throw new UnsupportedOperationException("Not implemented yet");
+    public AnnotationEntryGen getAnnotation() {
+        return a;
     }
 
     /**
      * Return immutable variant of this AnnotationElementValueGen
      */
     @Override
-    public ElementValue getElementValue()
-    {
-        return new AnnotationElementValue(super.getElementValueType(),
-                a.getAnnotation(),
-                getConstantPool().getConstantPool());
+    public ElementValue getElementValue() {
+        return new AnnotationElementValue(super.getElementValueType(), a.getAnnotation(), getConstantPool().getConstantPool());
     }
 
-    public AnnotationEntryGen getAnnotation()
-    {
-        return a;
+    @Override
+    public String stringifyValue() {
+        throw new UnsupportedOperationException("Not implemented yet");
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java
index 0223ee1b598..ea01a837175 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/AnnotationEntryGen.java
@@ -43,173 +43,25 @@
  * @LastModified: Jan 2020
  */
 public class AnnotationEntryGen {
-    private int typeIndex;
-
-    private List<ElementValuePairGen> evs;
-
-    private final ConstantPoolGen cpool;
-
-    private boolean isRuntimeVisible = false;
-
-    /**
-     * Here we are taking a fixed annotation of type Annotation and building a
-     * modifiable AnnotationGen object. If the pool passed in is for a different
-     * class file, then copyPoolEntries should have been passed as true as that
-     * will force us to do a deep copy of the annotation and move the cpool
-     * entries across. We need to copy the type and the element name value pairs
-     * and the visibility.
-     */
-    public AnnotationEntryGen(final AnnotationEntry a, final ConstantPoolGen cpool,
-                              final boolean copyPoolEntries) {
-        this.cpool = cpool;
-        if (copyPoolEntries) {
-            typeIndex = cpool.addUtf8(a.getAnnotationType());
-        } else {
-            typeIndex = a.getAnnotationTypeIndex();
-        }
-        isRuntimeVisible = a.isRuntimeVisible();
-        evs = copyValues(a.getElementValuePairs(), cpool, copyPoolEntries);
-    }
-
-    private List<ElementValuePairGen> copyValues(final ElementValuePair[] in, final ConstantPoolGen cpool,
-                                                 final boolean copyPoolEntries) {
-        final List<ElementValuePairGen> out = new ArrayList<>();
-        for (final ElementValuePair nvp : in) {
-            out.add(new ElementValuePairGen(nvp, cpool, copyPoolEntries));
-        }
-        return out;
-    }
-
-    private AnnotationEntryGen(final ConstantPoolGen cpool) {
-        this.cpool = cpool;
-    }
-
-    /**
-     * Retrieve an immutable version of this AnnotationGen
-     */
-    public AnnotationEntry getAnnotation() {
-        final AnnotationEntry a = new AnnotationEntry(typeIndex, cpool.getConstantPool(),
-                isRuntimeVisible);
-        for (final ElementValuePairGen element : evs) {
-            a.addElementNameValuePair(element.getElementNameValuePair());
-        }
-        return a;
-    }
-
-    public AnnotationEntryGen(final ObjectType type,
-                              final List<ElementValuePairGen> elements, final boolean vis,
-                              final ConstantPoolGen cpool) {
-        this.cpool = cpool;
-        this.typeIndex = cpool.addUtf8(type.getSignature());
-        evs = elements;
-        isRuntimeVisible = vis;
-    }
-
-    public static AnnotationEntryGen read(final DataInput dis,
-                                          final ConstantPoolGen cpool, final boolean b) throws IOException {
-        final AnnotationEntryGen a = new AnnotationEntryGen(cpool);
-        a.typeIndex = dis.readUnsignedShort();
-        final int elemValuePairCount = dis.readUnsignedShort();
-        for (int i = 0; i < elemValuePairCount; i++) {
-            final int nidx = dis.readUnsignedShort();
-            a.addElementNameValuePair(new ElementValuePairGen(nidx,
-                    ElementValueGen.readElementValue(dis, cpool), cpool));
-        }
-        a.isRuntimeVisible(b);
-        return a;
-    }
-
-    public void dump(final DataOutputStream dos) throws IOException {
-        dos.writeShort(typeIndex); // u2 index of type name in cpool
-        dos.writeShort(evs.size()); // u2 element_value pair count
-        for (final ElementValuePairGen envp : evs) {
-            envp.dump(dos);
-        }
-    }
-
-    public void addElementNameValuePair(final ElementValuePairGen evp) {
-        if (evs == null) {
-            evs = new ArrayList<>();
-        }
-        evs.add(evp);
-    }
 
-    public int getTypeIndex() {
-        return typeIndex;
-    }
-
-    public final String getTypeSignature() {
-        // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex);
-        final ConstantUtf8 utf8 = (ConstantUtf8) cpool
-                .getConstant(typeIndex/* c.getNameIndex() */);
-        return utf8.getBytes();
-    }
-
-    public final String getTypeName() {
-        return getTypeSignature();// BCELBUG: Should I use this instead?
-        // Utility.signatureToString(getTypeSignature());
-    }
+    static final AnnotationEntryGen[] EMPTY_ARRAY = {};
 
     /**
-     * Returns list of ElementNameValuePair objects
-     */
-    public List<ElementValuePairGen> getValues() {
-        return evs;
-    }
-
-    @Override
-    public String toString() {
-        final StringBuilder s = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber
-        s.append("AnnotationGen:[").append(getTypeName()).append(" #").append(evs.size()).append(" {");
-        for (int i = 0; i < evs.size(); i++) {
-            s.append(evs.get(i));
-            if (i + 1 < evs.size()) {
-                s.append(",");
-            }
-        }
-        s.append("}]");
-        return s.toString();
-    }
-
-    public String toShortString() {
-        final StringBuilder s = new StringBuilder();
-        s.append("@").append(getTypeName()).append("(");
-        for (int i = 0; i < evs.size(); i++) {
-            s.append(evs.get(i));
-            if (i + 1 < evs.size()) {
-                s.append(",");
-            }
-        }
-        s.append(")");
-        return s.toString();
-    }
-
-    private void isRuntimeVisible(final boolean b) {
-        isRuntimeVisible = b;
-    }
-
-    public boolean isRuntimeVisible() {
-        return isRuntimeVisible;
-    }
-
-
-    /**
-     * Converts a list of AnnotationGen objects into a set of attributes
-     * that can be attached to the class file.
+     * Converts a list of AnnotationGen objects into a set of attributes that can be attached to the class file.
      *
-     * @param cp  The constant pool gen where we can create the necessary name refs
+     * @param cp The constant pool gen where we can create the necessary name refs
      * @param annotationEntryGens An array of AnnotationGen objects
      */
     static Attribute[] getAnnotationAttributes(final ConstantPoolGen cp, final AnnotationEntryGen[] annotationEntryGens) {
         if (annotationEntryGens.length == 0) {
-            return new Attribute[0];
+            return Attribute.EMPTY_ARRAY;
         }
 
         try {
             int countVisible = 0;
             int countInvisible = 0;
 
-            //  put the annotations in the right output stream
+            // put the annotations in the right output stream
             for (final AnnotationEntryGen a : annotationEntryGens) {
                 if (a.isRuntimeVisible()) {
                     countVisible++;
@@ -220,8 +72,7 @@ static Attribute[] getAnnotationAttributes(final ConstantPoolGen cp, final Annot
 
             final ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream();
             final ByteArrayOutputStream riaBytes = new ByteArrayOutputStream();
-            try (DataOutputStream rvaDos = new DataOutputStream(rvaBytes);
-                    DataOutputStream riaDos = new DataOutputStream(riaBytes)) {
+            try (DataOutputStream rvaDos = new DataOutputStream(rvaBytes); DataOutputStream riaDos = new DataOutputStream(riaBytes)) {
 
                 rvaDos.writeShort(countVisible);
                 riaDos.writeShort(countInvisible);
@@ -251,17 +102,15 @@ static Attribute[] getAnnotationAttributes(final ConstantPoolGen cp, final Annot
 
             final List<Attribute> newAttributes = new ArrayList<>();
             if (rvaData.length > 2) {
-                newAttributes.add(
-                        new RuntimeVisibleAnnotations(rvaIndex, rvaData.length,
-                            new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool()));
+                newAttributes
+                    .add(new RuntimeVisibleAnnotations(rvaIndex, rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)), cp.getConstantPool()));
             }
             if (riaData.length > 2) {
                 newAttributes.add(
-                        new RuntimeInvisibleAnnotations(riaIndex, riaData.length,
-                            new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool()));
+                    new RuntimeInvisibleAnnotations(riaIndex, riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)), cp.getConstantPool()));
             }
 
-            return newAttributes.toArray(new Attribute[newAttributes.size()]);
+            return newAttributes.toArray(Attribute.EMPTY_ARRAY);
         } catch (final IOException e) {
             System.err.println("IOException whilst processing annotations");
             e.printStackTrace();
@@ -269,15 +118,12 @@ static Attribute[] getAnnotationAttributes(final ConstantPoolGen cp, final Annot
         return null;
     }
 
-
     /**
-     * Annotations against a class are stored in one of four attribute kinds:
-     * - RuntimeVisibleParameterAnnotations
-     * - RuntimeInvisibleParameterAnnotations
+     * Annotations against a class are stored in one of four attribute kinds: - RuntimeVisibleParameterAnnotations -
+     * RuntimeInvisibleParameterAnnotations
      */
-    static Attribute[] getParameterAnnotationAttributes(
-            final ConstantPoolGen cp,
-            final List<AnnotationEntryGen>[] /*Array of lists, array size depends on #params */vec) {
+    static Attribute[] getParameterAnnotationAttributes(final ConstantPoolGen cp,
+        final List<AnnotationEntryGen>[] /* Array of lists, array size depends on #params */ vec) {
         final int[] visCount = new int[vec.length];
         int totalVisCount = 0;
         final int[] invisCount = new int[vec.length];
@@ -338,25 +184,158 @@ static Attribute[] getParameterAnnotationAttributes(
             }
             final List<Attribute> newAttributes = new ArrayList<>();
             if (totalVisCount > 0) {
-                newAttributes
-                        .add(new RuntimeVisibleParameterAnnotations(rvaIndex,
-                                rvaData.length,
-                                new DataInputStream(new ByteArrayInputStream(rvaData)),
-                                    cp.getConstantPool()));
+                newAttributes.add(new RuntimeVisibleParameterAnnotations(rvaIndex, rvaData.length, new DataInputStream(new ByteArrayInputStream(rvaData)),
+                    cp.getConstantPool()));
             }
             if (totalInvisCount > 0) {
-                newAttributes
-                        .add(new RuntimeInvisibleParameterAnnotations(riaIndex,
-                                riaData.length,
-                                new DataInputStream(new ByteArrayInputStream(riaData)),
-                                    cp.getConstantPool()));
+                newAttributes.add(new RuntimeInvisibleParameterAnnotations(riaIndex, riaData.length, new DataInputStream(new ByteArrayInputStream(riaData)),
+                    cp.getConstantPool()));
             }
-            return newAttributes.toArray(new Attribute[newAttributes.size()]);
+            return newAttributes.toArray(Attribute.EMPTY_ARRAY);
         } catch (final IOException e) {
-            System.err.println("IOException whilst processing parameter annotations." +
-                    e.getMessage());
+            System.err.println("IOException whilst processing parameter annotations");
+            e.printStackTrace();
         }
         return null;
     }
 
+    public static AnnotationEntryGen read(final DataInput dis, final ConstantPoolGen cpool, final boolean b) throws IOException {
+        final AnnotationEntryGen a = new AnnotationEntryGen(cpool);
+        a.typeIndex = dis.readUnsignedShort();
+        final int elemValuePairCount = dis.readUnsignedShort();
+        for (int i = 0; i < elemValuePairCount; i++) {
+            final int nidx = dis.readUnsignedShort();
+            a.addElementNameValuePair(new ElementValuePairGen(nidx, ElementValueGen.readElementValue(dis, cpool), cpool));
+        }
+        a.isRuntimeVisible(b);
+        return a;
+    }
+
+    private int typeIndex;
+
+    private List<ElementValuePairGen> evs;
+
+    private final ConstantPoolGen cpool;
+
+    private boolean isRuntimeVisible;
+
+    /**
+     * Here we are taking a fixed annotation of type Annotation and building a modifiable AnnotationGen object. If the pool
+     * passed in is for a different class file, then copyPoolEntries should have been passed as true as that will force us
+     * to do a deep copy of the annotation and move the cpool entries across. We need to copy the type and the element name
+     * value pairs and the visibility.
+     */
+    public AnnotationEntryGen(final AnnotationEntry a, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
+        this.cpool = cpool;
+        if (copyPoolEntries) {
+            typeIndex = cpool.addUtf8(a.getAnnotationType());
+        } else {
+            typeIndex = a.getAnnotationTypeIndex();
+        }
+        isRuntimeVisible = a.isRuntimeVisible();
+        evs = copyValues(a.getElementValuePairs(), cpool, copyPoolEntries);
+    }
+
+    private AnnotationEntryGen(final ConstantPoolGen cpool) {
+        this.cpool = cpool;
+    }
+
+    public AnnotationEntryGen(final ObjectType type, final List<ElementValuePairGen> elements, final boolean vis, final ConstantPoolGen cpool) {
+        this.cpool = cpool;
+        this.typeIndex = cpool.addUtf8(type.getSignature());
+        evs = elements;
+        isRuntimeVisible = vis;
+    }
+
+    public void addElementNameValuePair(final ElementValuePairGen evp) {
+        if (evs == null) {
+            evs = new ArrayList<>();
+        }
+        evs.add(evp);
+    }
+
+    private List<ElementValuePairGen> copyValues(final ElementValuePair[] in, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
+        final List<ElementValuePairGen> out = new ArrayList<>();
+        for (final ElementValuePair nvp : in) {
+            out.add(new ElementValuePairGen(nvp, cpool, copyPoolEntries));
+        }
+        return out;
+    }
+
+    public void dump(final DataOutputStream dos) throws IOException {
+        dos.writeShort(typeIndex); // u2 index of type name in cpool
+        dos.writeShort(evs.size()); // u2 element_value pair count
+        for (final ElementValuePairGen envp : evs) {
+            envp.dump(dos);
+        }
+    }
+
+    /**
+     * Retrieve an immutable version of this AnnotationGen
+     */
+    public AnnotationEntry getAnnotation() {
+        final AnnotationEntry a = new AnnotationEntry(typeIndex, cpool.getConstantPool(), isRuntimeVisible);
+        for (final ElementValuePairGen element : evs) {
+            a.addElementNameValuePair(element.getElementNameValuePair());
+        }
+        return a;
+    }
+
+    public int getTypeIndex() {
+        return typeIndex;
+    }
+
+    public final String getTypeName() {
+        return getTypeSignature();// BCELBUG: Should I use this instead?
+        // Utility.signatureToString(getTypeSignature());
+    }
+
+    public final String getTypeSignature() {
+        // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex);
+        final ConstantUtf8 utf8 = (ConstantUtf8) cpool.getConstant(typeIndex/* c.getNameIndex() */);
+        return utf8.getBytes();
+    }
+
+    /**
+     * Returns list of ElementNameValuePair objects
+     */
+    public List<ElementValuePairGen> getValues() {
+        return evs;
+    }
+
+    public boolean isRuntimeVisible() {
+        return isRuntimeVisible;
+    }
+
+    private void isRuntimeVisible(final boolean b) {
+        isRuntimeVisible = b;
+    }
+
+    public String toShortString() {
+        final StringBuilder s = new StringBuilder();
+        s.append("@").append(getTypeName()).append("(");
+        for (int i = 0; i < evs.size(); i++) {
+            s.append(evs.get(i));
+            if (i + 1 < evs.size()) {
+                s.append(",");
+            }
+        }
+        s.append(")");
+        return s.toString();
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder s = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber
+        s.append("AnnotationGen:[").append(getTypeName()).append(" #").append(evs.size()).append(" {");
+        for (int i = 0; i < evs.size(); i++) {
+            s.append(evs.get(i));
+            if (i + 1 < evs.size()) {
+                s.append(",");
+            }
+        }
+        s.append("}]");
+        return s.toString();
+    }
+
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java
index cea2317e395..752ab1155c7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArithmeticInstruction.java
@@ -25,19 +25,15 @@
 
 /**
  * Super class for the family of arithmetic instructions.
- *
  */
-public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction,
-        StackProducer, StackConsumer {
+public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ArithmeticInstruction() {
     }
 
-
     /**
      * @param opcode of instruction
      */
@@ -45,55 +41,55 @@ protected ArithmeticInstruction(final short opcode) {
         super(opcode, (short) 1);
     }
 
-
-    /** @return type associated with the instruction
+    /**
+     * @return type associated with the instruction
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        final short _opcode = super.getOpcode();
-        switch (_opcode) {
-            case Const.DADD:
-            case Const.DDIV:
-            case Const.DMUL:
-            case Const.DNEG:
-            case Const.DREM:
-            case Const.DSUB:
-                return Type.DOUBLE;
-            case Const.FADD:
-            case Const.FDIV:
-            case Const.FMUL:
-            case Const.FNEG:
-            case Const.FREM:
-            case Const.FSUB:
-                return Type.FLOAT;
-            case Const.IADD:
-            case Const.IAND:
-            case Const.IDIV:
-            case Const.IMUL:
-            case Const.INEG:
-            case Const.IOR:
-            case Const.IREM:
-            case Const.ISHL:
-            case Const.ISHR:
-            case Const.ISUB:
-            case Const.IUSHR:
-            case Const.IXOR:
-                return Type.INT;
-            case Const.LADD:
-            case Const.LAND:
-            case Const.LDIV:
-            case Const.LMUL:
-            case Const.LNEG:
-            case Const.LOR:
-            case Const.LREM:
-            case Const.LSHL:
-            case Const.LSHR:
-            case Const.LSUB:
-            case Const.LUSHR:
-            case Const.LXOR:
-                return Type.LONG;
-            default: // Never reached
-                throw new ClassGenException("Unknown type " + _opcode);
+    public Type getType(final ConstantPoolGen cp) {
+        final short opcode = super.getOpcode();
+        switch (opcode) {
+        case Const.DADD:
+        case Const.DDIV:
+        case Const.DMUL:
+        case Const.DNEG:
+        case Const.DREM:
+        case Const.DSUB:
+            return Type.DOUBLE;
+        case Const.FADD:
+        case Const.FDIV:
+        case Const.FMUL:
+        case Const.FNEG:
+        case Const.FREM:
+        case Const.FSUB:
+            return Type.FLOAT;
+        case Const.IADD:
+        case Const.IAND:
+        case Const.IDIV:
+        case Const.IMUL:
+        case Const.INEG:
+        case Const.IOR:
+        case Const.IREM:
+        case Const.ISHL:
+        case Const.ISHR:
+        case Const.ISUB:
+        case Const.IUSHR:
+        case Const.IXOR:
+            return Type.INT;
+        case Const.LADD:
+        case Const.LAND:
+        case Const.LDIV:
+        case Const.LMUL:
+        case Const.LNEG:
+        case Const.LOR:
+        case Const.LREM:
+        case Const.LSHL:
+        case Const.LSHR:
+        case Const.LSUB:
+        case Const.LUSHR:
+        case Const.LXOR:
+            return Type.LONG;
+        default: // Never reached
+            throw new ClassGenException("Unknown type " + opcode);
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java
index b20f6ba848b..71374877efe 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayElementValueGen.java
@@ -32,25 +32,33 @@
 /**
  * @since 6.0
  */
-public class ArrayElementValueGen extends ElementValueGen
-{
+public class ArrayElementValueGen extends ElementValueGen {
     // J5TODO: Should we make this an array or a list? A list would be easier to
     // modify ...
     private final List<ElementValueGen> evalues;
 
-    public ArrayElementValueGen(final ConstantPoolGen cp)
-    {
+    /**
+     * @param value
+     * @param cpool
+     */
+    public ArrayElementValueGen(final ArrayElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
+        super(ARRAY, cpool);
+        evalues = new ArrayList<>();
+        final ElementValue[] in = value.getElementValuesArray();
+        for (final ElementValue element : in) {
+            evalues.add(ElementValueGen.copy(element, cpool, copyPoolEntries));
+        }
+    }
+
+    public ArrayElementValueGen(final ConstantPoolGen cp) {
         super(ARRAY, cp);
         evalues = new ArrayList<>();
     }
 
-    public ArrayElementValueGen(final int type, final ElementValue[] datums,
-            final ConstantPoolGen cpool)
-    {
+    public ArrayElementValueGen(final int type, final ElementValue[] datums, final ConstantPoolGen cpool) {
         super(type, cpool);
         if (type != ARRAY) {
-            throw new IllegalArgumentException(
-                    "Only element values of type array can be built with this ctor - type specified: " + type);
+            throw new IllegalArgumentException("Only element values of type array can be built with this ctor - type specified: " + type);
         }
         this.evalues = new ArrayList<>();
         for (final ElementValue datum : datums) {
@@ -58,50 +66,42 @@ public ArrayElementValueGen(final int type, final ElementValue[] datums,
         }
     }
 
+    public void addElement(final ElementValueGen gen) {
+        evalues.add(gen);
+    }
+
+    @Override
+    public void dump(final DataOutputStream dos) throws IOException {
+        dos.writeByte(super.getElementValueType()); // u1 type of value (ARRAY == '[')
+        dos.writeShort(evalues.size());
+        for (final ElementValueGen element : evalues) {
+            element.dump(dos);
+        }
+    }
+
     /**
      * Return immutable variant of this ArrayElementValueGen
      */
     @Override
-    public ElementValue getElementValue()
-    {
+    public ElementValue getElementValue() {
         final ElementValue[] immutableData = new ElementValue[evalues.size()];
         int i = 0;
         for (final ElementValueGen element : evalues) {
             immutableData[i++] = element.getElementValue();
         }
-        return new ArrayElementValue(super.getElementValueType(),
-                immutableData,
-                getConstantPool().getConstantPool());
+        return new ArrayElementValue(super.getElementValueType(), immutableData, getConstantPool().getConstantPool());
     }
 
-    /**
-     * @param value
-     * @param cpool
-     */
-    public ArrayElementValueGen(final ArrayElementValue value, final ConstantPoolGen cpool,
-            final boolean copyPoolEntries)
-    {
-        super(ARRAY, cpool);
-        evalues = new ArrayList<>();
-        final ElementValue[] in = value.getElementValuesArray();
-        for (final ElementValue element : in) {
-            evalues.add(ElementValueGen.copy(element, cpool, copyPoolEntries));
-        }
+    public List<ElementValueGen> getElementValues() {
+        return evalues;
     }
 
-    @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
-        dos.writeByte(super.getElementValueType()); // u1 type of value (ARRAY == '[')
-        dos.writeShort(evalues.size());
-        for (final ElementValueGen element : evalues) {
-            element.dump(dos);
-        }
+    public int getElementValuesSize() {
+        return evalues.size();
     }
 
     @Override
-    public String stringifyValue()
-    {
+    public String stringifyValue() {
         final StringBuilder sb = new StringBuilder();
         sb.append("[");
         String comma = "";
@@ -113,19 +113,4 @@ public String stringifyValue()
         sb.append("]");
         return sb.toString();
     }
-
-    public List<ElementValueGen> getElementValues()
-    {
-        return evalues;
-    }
-
-    public int getElementValuesSize()
-    {
-        return evalues.size();
-    }
-
-    public void addElement(final ElementValueGen gen)
-    {
-        evalues.add(gen);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java
index 50b0dbff7ce..538c180712a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayInstruction.java
@@ -25,19 +25,15 @@
 
 /**
  * Super class for instructions dealing with array access such as IALOAD.
- *
  */
-public abstract class ArrayInstruction extends Instruction implements ExceptionThrower,
-        TypedInstruction {
+public abstract class ArrayInstruction extends Instruction implements ExceptionThrower, TypedInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ArrayInstruction() {
     }
 
-
     /**
      * @param opcode of instruction
      */
@@ -45,45 +41,44 @@ protected ArrayInstruction(final short opcode) {
         super(opcode, (short) 1);
     }
 
-
     @Override
     public Class<?>[] getExceptions() {
         return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_ARRAY_EXCEPTION);
     }
 
-
-    /** @return type associated with the instruction
+    /**
+     * @return type associated with the instruction
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        final short _opcode = super.getOpcode();
-        switch (_opcode) {
-            case com.sun.org.apache.bcel.internal.Const.IALOAD:
-            case com.sun.org.apache.bcel.internal.Const.IASTORE:
-                return Type.INT;
-            case com.sun.org.apache.bcel.internal.Const.CALOAD:
-            case com.sun.org.apache.bcel.internal.Const.CASTORE:
-                return Type.CHAR;
-            case com.sun.org.apache.bcel.internal.Const.BALOAD:
-            case com.sun.org.apache.bcel.internal.Const.BASTORE:
-                return Type.BYTE;
-            case com.sun.org.apache.bcel.internal.Const.SALOAD:
-            case com.sun.org.apache.bcel.internal.Const.SASTORE:
-                return Type.SHORT;
-            case com.sun.org.apache.bcel.internal.Const.LALOAD:
-            case com.sun.org.apache.bcel.internal.Const.LASTORE:
-                return Type.LONG;
-            case com.sun.org.apache.bcel.internal.Const.DALOAD:
-            case com.sun.org.apache.bcel.internal.Const.DASTORE:
-                return Type.DOUBLE;
-            case com.sun.org.apache.bcel.internal.Const.FALOAD:
-            case com.sun.org.apache.bcel.internal.Const.FASTORE:
-                return Type.FLOAT;
-            case com.sun.org.apache.bcel.internal.Const.AALOAD:
-            case com.sun.org.apache.bcel.internal.Const.AASTORE:
-                return Type.OBJECT;
-            default:
-                throw new ClassGenException("Unknown case in switch" + _opcode);
+    public Type getType(final ConstantPoolGen cp) {
+        final short opcode = super.getOpcode();
+        switch (opcode) {
+        case com.sun.org.apache.bcel.internal.Const.IALOAD:
+        case com.sun.org.apache.bcel.internal.Const.IASTORE:
+            return Type.INT;
+        case com.sun.org.apache.bcel.internal.Const.CALOAD:
+        case com.sun.org.apache.bcel.internal.Const.CASTORE:
+            return Type.CHAR;
+        case com.sun.org.apache.bcel.internal.Const.BALOAD:
+        case com.sun.org.apache.bcel.internal.Const.BASTORE:
+            return Type.BYTE;
+        case com.sun.org.apache.bcel.internal.Const.SALOAD:
+        case com.sun.org.apache.bcel.internal.Const.SASTORE:
+            return Type.SHORT;
+        case com.sun.org.apache.bcel.internal.Const.LALOAD:
+        case com.sun.org.apache.bcel.internal.Const.LASTORE:
+            return Type.LONG;
+        case com.sun.org.apache.bcel.internal.Const.DALOAD:
+        case com.sun.org.apache.bcel.internal.Const.DASTORE:
+            return Type.DOUBLE;
+        case com.sun.org.apache.bcel.internal.Const.FALOAD:
+        case com.sun.org.apache.bcel.internal.Const.FASTORE:
+            return Type.FLOAT;
+        case com.sun.org.apache.bcel.internal.Const.AALOAD:
+        case com.sun.org.apache.bcel.internal.Const.AASTORE:
+            return Type.OBJECT;
+        default:
+            throw new ClassGenException("Unknown case in switch" + opcode);
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java
index 3b20c7336e8..138999ebe90 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java
@@ -24,56 +24,55 @@
 
 /**
  * Denotes array type, such as int[][]
- *
  */
 public final class ArrayType extends ReferenceType {
 
-    private int dimensions;
-    private Type basicType;
-
+    private final int dimensions;
+    private final Type basicType;
 
     /**
      * Convenience constructor for array type, e.g. int[]
      *
      * @param type array type, e.g. T_INT
+     * @param dimensions array dimensions
      */
     public ArrayType(final byte type, final int dimensions) {
         this(BasicType.getType(type), dimensions);
     }
 
-
     /**
      * Convenience constructor for reference array type, e.g. Object[]
      *
-     * @param class_name complete name of class (java.lang.String, e.g.)
+     * @param className complete name of class (java.lang.String, e.g.)
+     * @param dimensions array dimensions
      */
-    public ArrayType(final String class_name, final int dimensions) {
-        this(ObjectType.getInstance(class_name), dimensions);
+    public ArrayType(final String className, final int dimensions) {
+        this(ObjectType.getInstance(className), dimensions);
     }
 
-
     /**
      * Constructor for array of given type
      *
      * @param type type of array (may be an array itself)
+     * @param dimensions array dimensions
      */
     public ArrayType(final Type type, final int dimensions) {
         super(Const.T_ARRAY, "<dummy>");
-        if ((dimensions < 1) || (dimensions > Const.MAX_BYTE)) {
+        if (dimensions < 1 || dimensions > Const.MAX_BYTE) {
             throw new ClassGenException("Invalid number of dimensions: " + dimensions);
         }
         switch (type.getType()) {
-            case Const.T_ARRAY:
-                final ArrayType array = (ArrayType) type;
-                this.dimensions = dimensions + array.dimensions;
-                basicType = array.basicType;
-                break;
-            case Const.T_VOID:
-                throw new ClassGenException("Invalid type: void[]");
-            default: // Basic type or reference
-                this.dimensions = dimensions;
-                basicType = type;
-                break;
+        case Const.T_ARRAY:
+            final ArrayType array = (ArrayType) type;
+            this.dimensions = dimensions + array.dimensions;
+            basicType = array.basicType;
+            break;
+        case Const.T_VOID:
+            throw new ClassGenException("Invalid type: void[]");
+        default: // Basic type or reference
+            this.dimensions = dimensions;
+            basicType = type;
+            break;
         }
         final StringBuilder buf = new StringBuilder();
         for (int i = 0; i < this.dimensions; i++) {
@@ -83,6 +82,17 @@ public ArrayType(final Type type, final int dimensions) {
         super.setSignature(buf.toString());
     }
 
+    /**
+     * @return true if both type objects refer to the same array type.
+     */
+    @Override
+    public boolean equals(final Object type) {
+        if (type instanceof ArrayType) {
+            final ArrayType array = (ArrayType) type;
+            return array.dimensions == dimensions && array.basicType.equals(basicType);
+        }
+        return false;
+    }
 
     /**
      * @return basic type of array, i.e., for int[][][] the basic type is int
@@ -91,6 +101,24 @@ public Type getBasicType() {
         return basicType;
     }
 
+    /**
+     * Gets the name of referenced class.
+     *
+     * @return name of referenced class.
+     * @since 6.7.0
+     */
+    @Override
+    @Deprecated
+    public String getClassName() {
+        return signature;
+    }
+
+    /**
+     * @return number of dimensions of array
+     */
+    public int getDimensions() {
+        return dimensions;
+    }
 
     /**
      * @return element type of array, i.e., for int[][][] the element type is int[][]
@@ -102,30 +130,11 @@ public Type getElementType() {
         return new ArrayType(basicType, dimensions - 1);
     }
 
-
-    /** @return number of dimensions of array
-     */
-    public int getDimensions() {
-        return dimensions;
-    }
-
-
-    /** @return a hash code value for the object.
+    /**
+     * @return a hash code value for the object.
      */
     @Override
     public int hashCode() {
         return basicType.hashCode() ^ dimensions;
     }
-
-
-    /** @return true if both type objects refer to the same array type.
-     */
-    @Override
-    public boolean equals( final Object _type ) {
-        if (_type instanceof ArrayType) {
-            final ArrayType array = (ArrayType) _type;
-            return (array.dimensions == dimensions) && array.basicType.equals(basicType);
-        }
-        return false;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BALOAD.java
index 27f11125889..dc14c3fcdb1 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BALOAD.java
@@ -22,28 +22,28 @@
 
 /**
  * BALOAD - Load byte or boolean from array
- * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; ..., value
+ * </PRE>
  */
 public class BALOAD extends ArrayInstruction implements StackProducer {
 
-    /** Load byte or boolean from array
+    /**
+     * Load byte or boolean from array
      */
     public BALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.BALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BASTORE.java
index 9a71e9f6e1b..da73a504beb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BASTORE.java
@@ -21,29 +21,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * BASTORE -  Store into byte or boolean array
- * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ * BASTORE - Store into byte or boolean array
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value -&gt; ...
+ * </PRE>
  */
 public class BASTORE extends ArrayInstruction implements StackConsumer {
 
-    /** Store byte or boolean into array
+    /**
+     * Store byte or boolean into array
      */
     public BASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.BASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BIPUSH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BIPUSH.java
index d5cd303508e..264fe1cb54d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BIPUSH.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BIPUSH.java
@@ -27,87 +27,79 @@
 /**
  * BIPUSH - Push byte on stack
  *
- * <PRE>Stack: ... -&gt; ..., value</PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ..., value
+ * </PRE>
  */
 public class BIPUSH extends Instruction implements ConstantPushInstruction {
 
     private byte b;
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     BIPUSH() {
     }
 
-
-    /** Push byte on stack
+    /**
+     * Push byte on stack
      */
     public BIPUSH(final byte b) {
         super(com.sun.org.apache.bcel.internal.Const.BIPUSH, (short) 2);
         this.b = b;
     }
 
-
     /**
-     * Dump instruction as byte code to stream out.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        super.dump(out);
-        out.writeByte(b);
+    public void accept(final Visitor v) {
+        v.visitPushInstruction(this);
+        v.visitStackProducer(this);
+        v.visitTypedInstruction(this);
+        v.visitConstantPushInstruction(this);
+        v.visitBIPUSH(this);
     }
 
-
     /**
-     * @return mnemonic for instruction
+     * Dump instruction as byte code to stream out.
      */
     @Override
-    public String toString( final boolean verbose ) {
-        return super.toString(verbose) + " " + b;
+    public void dump(final DataOutputStream out) throws IOException {
+        super.dump(out);
+        out.writeByte(b);
     }
 
-
     /**
-     * Read needed data (e.g. index) from file.
+     * @return Type.BYTE
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
-        super.setLength(2);
-        b = bytes.readByte();
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.BYTE;
     }
 
-
     @Override
     public Number getValue() {
         return Integer.valueOf(b);
     }
 
-
-    /** @return Type.BYTE
+    /**
+     * Read needed data (e.g. index) from file.
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.BYTE;
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+        super.setLength(2);
+        b = bytes.readByte();
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
+     * @return mnemonic for instruction
      */
     @Override
-    public void accept( final Visitor v ) {
-        v.visitPushInstruction(this);
-        v.visitStackProducer(this);
-        v.visitTypedInstruction(this);
-        v.visitConstantPushInstruction(this);
-        v.visitBIPUSH(this);
+    public String toString(final boolean verbose) {
+        return super.toString(verbose) + " " + b;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java
index 857f628df51..a4fc7be058f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BREAKPOINT.java
@@ -22,7 +22,6 @@
 
 /**
  * BREAKPOINT, JVM dependent, ignored by default
- *
  */
 public class BREAKPOINT extends Instruction {
 
@@ -30,17 +29,14 @@ public BREAKPOINT() {
         super(com.sun.org.apache.bcel.internal.Const.BREAKPOINT, (short) 1);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitBREAKPOINT(this);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BasicType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BasicType.java
index 8d201b861a3..71bc5491186 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BasicType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BasicType.java
@@ -24,63 +24,61 @@
 
 /**
  * Denotes basic type such as int.
- *
  */
 public final class BasicType extends Type {
 
+    // @since 6.0 no longer final
+    public static BasicType getType(final byte type) {
+        switch (type) {
+        case Const.T_VOID:
+            return VOID;
+        case Const.T_BOOLEAN:
+            return BOOLEAN;
+        case Const.T_BYTE:
+            return BYTE;
+        case Const.T_SHORT:
+            return SHORT;
+        case Const.T_CHAR:
+            return CHAR;
+        case Const.T_INT:
+            return INT;
+        case Const.T_LONG:
+            return LONG;
+        case Const.T_DOUBLE:
+            return DOUBLE;
+        case Const.T_FLOAT:
+            return FLOAT;
+        default:
+            throw new ClassGenException("Invalid type: " + type);
+        }
+    }
+
     /**
-     * Constructor for basic types such as int, long, `void'
+     * Constructor for basic types such as int, long, 'void'
      *
      * @param type one of T_INT, T_BOOLEAN, ..., T_VOID
      * @see Const
      */
     BasicType(final byte type) {
         super(type, Const.getShortTypeName(type));
-        if ((type < Const.T_BOOLEAN) || (type > Const.T_VOID)) {
+        if (type < Const.T_BOOLEAN || type > Const.T_VOID) {
             throw new ClassGenException("Invalid type: " + type);
         }
     }
 
-
-    // @since 6.0 no longer final
-    public static BasicType getType( final byte type ) {
-        switch (type) {
-            case Const.T_VOID:
-                return VOID;
-            case Const.T_BOOLEAN:
-                return BOOLEAN;
-            case Const.T_BYTE:
-                return BYTE;
-            case Const.T_SHORT:
-                return SHORT;
-            case Const.T_CHAR:
-                return CHAR;
-            case Const.T_INT:
-                return INT;
-            case Const.T_LONG:
-                return LONG;
-            case Const.T_DOUBLE:
-                return DOUBLE;
-            case Const.T_FLOAT:
-                return FLOAT;
-            default:
-                throw new ClassGenException("Invalid type: " + type);
-        }
-    }
-
-
-    /** @return a hash code value for the object.
+    /**
+     * @return true if both type objects refer to the same type
      */
     @Override
-    public int hashCode() {
-        return super.getType();
+    public boolean equals(final Object type) {
+        return type instanceof BasicType && ((BasicType) type).getType() == this.getType();
     }
 
-
-    /** @return true if both type objects refer to the same type
+    /**
+     * @return a hash code value for the object.
      */
     @Override
-    public boolean equals( final Object _type ) {
-        return (_type instanceof BasicType) ? ((BasicType) _type).getType() == this.getType() : false;
+    public int hashCode() {
+        return super.getType();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchHandle.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchHandle.java
index d35800d4d96..91ab9ac5463 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchHandle.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchHandle.java
@@ -21,10 +21,8 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * BranchHandle is returned by specialized InstructionList.append() whenever a
- * BranchInstruction is appended. This is useful when the target of this
- * instruction is not known at time of creation and must be set later
- * via setTarget().
+ * BranchHandle is returned by specialized InstructionList.append() whenever a BranchInstruction is appended. This is
+ * useful when the target of this instruction is not known at time of creation and must be set later via setTarget().
  *
  * @see InstructionHandle
  * @see Instruction
@@ -32,83 +30,75 @@
  */
 public final class BranchHandle extends InstructionHandle {
 
+    /**
+     * Factory method.
+     */
+    static BranchHandle getBranchHandle(final BranchInstruction i) {
+        return new BranchHandle(i);
+    }
+
     // This is also a cache in case the InstructionHandle#swapInstruction() method is used
     // See BCEL-273
     private BranchInstruction bi; // An alias in fact, but saves lots of casts
 
-
     private BranchHandle(final BranchInstruction i) {
         super(i);
         bi = i;
     }
 
-    /** Factory method.
-     */
-    static BranchHandle getBranchHandle( final BranchInstruction i ) {
-        return new BranchHandle(i);
-    }
-
-
-    /* Override InstructionHandle methods: delegate to branch instruction.
-     * Through this overriding all access to the private i_position field should
-     * be prevented.
+    /*
+     * Override InstructionHandle methods: delegate to branch instruction. Through this overriding all access to the private
+     * i_position field should be prevented.
      */
     @Override
     public int getPosition() {
         return bi.getPosition();
     }
 
+    /**
+     * @return target of instruction.
+     */
+    public InstructionHandle getTarget() {
+        return bi.getTarget();
+    }
+
+    /**
+     * Set new contents. Old instruction is disposed and may not be used anymore.
+     */
+    @Override // This is only done in order to apply the additional type check; could be merged with super impl.
+    public void setInstruction(final Instruction i) { // TODO could be package-protected?
+        super.setInstruction(i);
+        if (!(i instanceof BranchInstruction)) {
+            throw new ClassGenException("Assigning " + i + " to branch handle which is not a branch instruction");
+        }
+        bi = (BranchInstruction) i;
+    }
 
     @Override
-    void setPosition( final int pos ) {
+    void setPosition(final int pos) {
         // Original code: i_position = bi.position = pos;
         bi.setPosition(pos);
         super.setPosition(pos);
     }
 
-
-    @Override
-    protected int updatePosition( final int offset, final int max_offset ) {
-        final int x = bi.updatePosition(offset, max_offset);
-        super.setPosition(bi.getPosition());
-        return x;
-    }
-
-
     /**
      * Pass new target to instruction.
      */
-    public void setTarget( final InstructionHandle ih ) {
+    public void setTarget(final InstructionHandle ih) {
         bi.setTarget(ih);
     }
 
-
-    /**
-     * Update target of instruction.
-     */
-    public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) {
-        bi.updateTarget(old_ih, new_ih);
-    }
-
-
-    /**
-     * @return target of instruction.
-     */
-    public InstructionHandle getTarget() {
-        return bi.getTarget();
+    @Override
+    protected int updatePosition(final int offset, final int maxOffset) {
+        final int x = bi.updatePosition(offset, maxOffset);
+        super.setPosition(bi.getPosition());
+        return x;
     }
 
-
     /**
-     * Set new contents. Old instruction is disposed and may not be used anymore.
+     * Update target of instruction.
      */
-    @Override // This is only done in order to apply the additional type check; could be merged with super impl.
-    public void setInstruction( final Instruction i ) { // TODO could be package-protected?
-        super.setInstruction(i);
-        if (!(i instanceof BranchInstruction)) {
-            throw new ClassGenException("Assigning " + i
-                    + " to branch handle which is not a branch instruction");
-        }
-        bi = (BranchInstruction) i;
+    public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) {
+        bi.updateTarget(oldIh, newIh);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java
index e650bea8ec5..4aba9a97027 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/BranchInstruction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,149 +25,94 @@
 import com.sun.org.apache.bcel.internal.util.ByteSequence;
 
 /**
- * Abstract super class for branching instructions like GOTO, IFEQ, etc..
- * Branch instructions may have a variable length, namely GOTO, JSR,
- * LOOKUPSWITCH and TABLESWITCH.
+ * Abstract super class for branching instructions like GOTO, IFEQ, etc.. Branch instructions may have a variable
+ * length, namely GOTO, JSR, LOOKUPSWITCH and TABLESWITCH.
  *
  * @see InstructionList
- * @LastModified: July 2020
+ * @LastModified: Feb 2023
  */
 public abstract class BranchInstruction extends Instruction implements InstructionTargeter {
 
-    private int index; // Branch target relative to this instruction
-    private InstructionHandle target; // Target object in instruction list
-    private int position; // Byte code offset
-
     /**
-     * Empty constructor needed for the Class.newInstance() statement in
-     * Instruction.readInstruction(). Not to be used otherwise.
+     * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen, LineNumberGen
      */
-    BranchInstruction() {
+    static void notifyTarget(final InstructionHandle oldIh, final InstructionHandle newIh, final InstructionTargeter t) {
+        if (oldIh != null) {
+            oldIh.removeTargeter(t);
+        }
+        if (newIh != null) {
+            newIh.addTargeter(t);
+        }
     }
 
-
-    /** Common super constructor
-     * @param opcode Instruction opcode
-     * @param target instruction to branch to
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    protected BranchInstruction(final short opcode, final InstructionHandle target) {
-        super(opcode, (short) 3);
-        setTarget(target);
-    }
-
+    @Deprecated
+    protected int index; // Branch target relative to this instruction
 
     /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        out.writeByte(super.getOpcode());
-        index = getTargetOffset();
-        if (!isValidShort(index)) {
-            throw new ClassGenException("Branch target offset too large for short: " + index);
-        }
-        out.writeShort(index); // May be negative, i.e., point backwards
-    }
-
+    @Deprecated
+    protected InstructionHandle target; // Target object in instruction list
 
     /**
-     * @param _target branch target
-     * @return the offset to  `target' relative to this instruction
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    protected int getTargetOffset( final InstructionHandle _target ) {
-        if (_target == null) {
-            throw new ClassGenException("Target of " + super.toString(true)
-                    + " is invalid null handle");
-        }
-        final int t = _target.getPosition();
-        if (t < 0) {
-            throw new ClassGenException("Invalid branch target position offset for "
-                    + super.toString(true) + ":" + t + ":" + _target);
-        }
-        return t - position;
-    }
-
+    @Deprecated
+    protected int position; // Byte code offset
 
     /**
-     * @return the offset to this instruction's target
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
-    protected int getTargetOffset() {
-        return getTargetOffset(target);
+    BranchInstruction() {
     }
 
-
     /**
-     * Called by InstructionList.setPositions when setting the position for every
-     * instruction. In the presence of variable length instructions `setPositions'
-     * performs multiple passes over the instruction list to calculate the
-     * correct (byte) positions and offsets by calling this function.
+     * Common super constructor
      *
-     * @param offset additional offset caused by preceding (variable length) instructions
-     * @param max_offset the maximum offset that may be caused by these instructions
-     * @return additional offset caused by possible change of this instruction's length
+     * @param opcode Instruction opcode
+     * @param target instruction to branch to
      */
-    protected int updatePosition( final int offset, final int max_offset ) {
-        position += offset;
-        return 0;
+    protected BranchInstruction(final short opcode, final InstructionHandle target) {
+        super(opcode, (short) 3);
+        setTarget(target);
     }
 
-
     /**
-     * Long output format:
-     *
-     * &lt;position in byte code&gt;
-     * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
-     * "("&lt;length of instruction&gt;")"
-     * "&lt;"&lt;target instruction&gt;"&gt;" "@"&lt;branch target offset&gt;
-     *
-     * @param verbose long/short format switch
-     * @return mnemonic for instruction
+     * @return true, if ih is target of this instruction
      */
     @Override
-    public String toString( final boolean verbose ) {
-        final String s = super.toString(verbose);
-        String t = "null";
-        if (verbose) {
-            if (target != null) {
-                if (target.getInstruction() == this) {
-                    t = "<points to itself>";
-                } else if (target.getInstruction() == null) {
-                    t = "<null instruction!!!?>";
-                } else {
-                    // I'm more interested in the address of the target then
-                    // the instruction located there.
-                    //t = target.getInstruction().toString(false); // Avoid circles
-                    t = "" + target.getPosition();
-                }
-            }
-        } else {
-            if (target != null) {
-                index = target.getPosition();
-                // index = getTargetOffset();  crashes if positions haven't been set
-                // t = "" + (index + position);
-                t = "" + index;
-            }
-        }
-        return s + " -> " + t;
+    public boolean containsTarget(final InstructionHandle ih) {
+        return target == ih;
     }
 
+    /**
+     * Inform target that it's not targeted anymore.
+     */
+    @Override
+    void dispose() {
+        setTarget(null);
+        index = -1;
+        position = -1;
+    }
 
     /**
-     * Read needed data (e.g. index) from file. Conversion to a InstructionHandle
-     * is done in InstructionList(byte[]).
+     * Dump instruction as byte code to stream out.
      *
-     * @param bytes input stream
-     * @param wide wide prefix?
-     * @see InstructionList
+     * @param out Output stream
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
-        super.setLength(3);
-        index = bytes.readShort();
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(super.getOpcode());
+        index = getTargetOffset();
+        if (!isValidShort(index)) {
+            throw new ClassGenException("Branch target offset too large for short: " + index);
+        }
+        out.writeShort(index); // May be negative, i.e., point backwards
     }
 
-
     /**
      * @return target offset in byte code
      */
@@ -175,6 +120,13 @@ public final int getIndex() {
         return index;
     }
 
+    /**
+     * @return the position
+     * @since 6.0
+     */
+    protected int getPosition() {
+        return position;
+    }
 
     /**
      * @return target of branch instruction
@@ -183,51 +135,55 @@ public InstructionHandle getTarget() {
         return target;
     }
 
-
     /**
-     * Set branch target
-     * @param target branch target
+     * @return the offset to this instruction's target
      */
-    public void setTarget( final InstructionHandle target ) {
-        notifyTarget(this.target, target, this);
-        this.target = target;
+    protected int getTargetOffset() {
+        return getTargetOffset(target);
     }
 
-
     /**
-     * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen, LineNumberGen
+     * @param target branch target
+     * @return the offset to 'target' relative to this instruction
      */
-    static void notifyTarget( final InstructionHandle old_ih, final InstructionHandle new_ih,
-            final InstructionTargeter t ) {
-        if (old_ih != null) {
-            old_ih.removeTargeter(t);
+    protected int getTargetOffset(final InstructionHandle target) {
+        if (target == null) {
+            throw new ClassGenException("Target of " + super.toString(true) + " is invalid null handle");
         }
-        if (new_ih != null) {
-            new_ih.addTargeter(t);
+        final int t = target.getPosition();
+        if (t < 0) {
+            throw new ClassGenException("Invalid branch target position offset for " + super.toString(true) + ":" + t + ":" + target);
         }
+        return t - position;
     }
 
-
     /**
-     * @param old_ih old target
-     * @param new_ih new target
+     * Read needed data (e.g. index) from file. Conversion to a InstructionHandle is done in InstructionList(byte[]).
+     *
+     * @param bytes input stream
+     * @param wide wide prefix?
+     * @see InstructionList
      */
     @Override
-    public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) {
-        if (target == old_ih) {
-            setTarget(new_ih);
-        } else {
-            throw new ClassGenException("Not targeting " + old_ih + ", but " + target);
-        }
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+        super.setLength(3);
+        index = bytes.readShort();
     }
 
+    /**
+     * @param index the index to set
+     * @since 6.0
+     */
+    protected void setIndex(final int index) {
+        this.index = index;
+    }
 
     /**
-     * @return true, if ih is target of this instruction
+     * @param position the position to set
+     * @since 6.0
      */
-    @Override
-    public boolean containsTarget( final InstructionHandle ih ) {
-        return target == ih;
+    protected void setPosition(final int position) {
+        this.position = position;
     }
 
     /**
@@ -249,40 +205,74 @@ void setOpcode( final short opcode ) {
     }
 
     /**
-     * Inform target that it's not targeted anymore.
+     * Set branch target
+     *
+     * @param target branch target
      */
-    @Override
-    void dispose() {
-        setTarget(null);
-        index = -1;
-        position = -1;
+    public void setTarget(final InstructionHandle target) {
+        notifyTarget(this.target, target, this);
+        this.target = target;
     }
 
-
     /**
-     * @return the position
-     * @since 6.0
+     * Long output format:
+     *
+     * &lt;position in byte code&gt; &lt;name of opcode&gt; "["&lt;opcode number&gt;"]" "("&lt;length of instruction&gt;")"
+     * "&lt;"&lt;target instruction&gt;"&gt;" "@"&lt;branch target offset&gt;
+     *
+     * @param verbose long/short format switch
+     * @return mnemonic for instruction
      */
-    protected int getPosition() {
-        return position;
+    @Override
+    public String toString(final boolean verbose) {
+        final String s = super.toString(verbose);
+        String t = "null";
+        if (target != null) {
+            if (verbose) {
+                if (target.getInstruction() == this) {
+                    t = "<points to itself>";
+                } else if (target.getInstruction() == null) {
+                    t = "<null instruction!!!?>";
+                } else {
+                    // I'm more interested in the address of the target then
+                    // the instruction located there.
+                    // t = target.getInstruction().toString(false); // Avoid circles
+                    t = "" + target.getPosition();
+                }
+            } else {
+                index = target.getPosition();
+                // index = getTargetOffset(); crashes if positions haven't been set
+                // t = "" + (index + position);
+                t = "" + index;
+            }
+        }
+        return s + " -> " + t;
     }
 
-
     /**
-     * @param position the position to set
-     * @since 6.0
+     * Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable
+     * length instructions 'setPositions' performs multiple passes over the instruction list to calculate the correct (byte)
+     * positions and offsets by calling this function.
+     *
+     * @param offset additional offset caused by preceding (variable length) instructions
+     * @param maxOffset the maximum offset that may be caused by these instructions
+     * @return additional offset caused by possible change of this instruction's length
      */
-    protected void setPosition(final int position) {
-        this.position = position;
+    protected int updatePosition(final int offset, final int maxOffset) {
+        position += offset;
+        return 0;
     }
 
-
     /**
-     * @param index the index to set
-     * @since 6.0
+     * @param oldIh old target
+     * @param newIh new target
      */
-    protected void setIndex(final int index) {
-        this.index = index;
+    @Override
+    public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) {
+        if (target != oldIh) {
+            throw new ClassGenException("Not targeting " + oldIh + ", but " + target);
+        }
+        setTarget(newIh);
     }
 
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CALOAD.java
index 750a6948bbc..02cc46df660 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CALOAD.java
@@ -23,28 +23,28 @@
 
 /**
  * CALOAD - Load char from array
- * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; ..., value
+ * </PRE>
  */
 public class CALOAD extends ArrayInstruction implements StackProducer {
 
-    /** Load char from array
+    /**
+     * Load char from array
      */
     public CALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.CALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CASTORE.java
index 499de83b9dd..ca4a4e1fe41 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CASTORE.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * CASTORE -  Store into char array
- * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ * CASTORE - Store into char array
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value -&gt; ...
+ * </PRE>
  */
 public class CASTORE extends ArrayInstruction implements StackConsumer {
 
-    /** Store char into array
+    /**
+     * Store char into array
      */
     public CASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.CASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java
index a329f359f5f..6983350f646 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CHECKCAST.java
@@ -25,57 +25,36 @@
 
 /**
  * CHECKCAST - Check whether object is of given type
- * <PRE>Stack: ..., objectref -&gt; ..., objectref</PRE>
  *
+ * <PRE>
+ * Stack: ..., objectref -&gt; ..., objectref
+ * </PRE>
  */
-public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer,
-        StackConsumer {
+public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer, StackConsumer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     CHECKCAST() {
     }
 
-
-    /** Check whether object is of given type
+    /**
+     * Check whether object is of given type
+     *
      * @param index index to class in constant pool
      */
     public CHECKCAST(final int index) {
         super(com.sun.org.apache.bcel.internal.Const.CHECKCAST, index);
     }
 
-
-    /** @return exceptions this instruction may cause
-     */
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION,
-            ExceptionConst.CLASS_CAST_EXCEPTION);
-    }
-
-
-    @Override
-    public ObjectType getLoadClassType( final ConstantPoolGen cpg ) {
-        Type t = getType(cpg);
-        if (t instanceof ArrayType) {
-            t = ((ArrayType) t).getBasicType();
-        }
-        return (t instanceof ObjectType) ? (ObjectType) t : null;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLoadClass(this);
         v.visitExceptionThrower(this);
         v.visitStackProducer(this);
@@ -84,4 +63,21 @@ public void accept( final Visitor v ) {
         v.visitCPInstruction(this);
         v.visitCHECKCAST(this);
     }
+
+    /**
+     * @return exceptions this instruction may cause
+     */
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.CLASS_CAST_EXCEPTION);
+    }
+
+    @Override
+    public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
+        Type t = getType(cpg);
+        if (t instanceof ArrayType) {
+            t = ((ArrayType) t).getBasicType();
+        }
+        return t instanceof ObjectType ? (ObjectType) t : null;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CPInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CPInstruction.java
index 5f904459751..1dfd244141a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CPInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CPInstruction.java
@@ -25,11 +25,11 @@
 import com.sun.org.apache.bcel.internal.classfile.Constant;
 import com.sun.org.apache.bcel.internal.classfile.ConstantClass;
 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
+import com.sun.org.apache.bcel.internal.classfile.Utility;
 import com.sun.org.apache.bcel.internal.util.ByteSequence;
 
 /**
- * Abstract super class for instructions that use an index into the
- * constant pool such as LDC, INVOKEVIRTUAL, etc.
+ * Abstract super class for instructions that use an index into the constant pool such as LDC, INVOKEVIRTUAL, etc.
  *
  * @see ConstantPoolGen
  * @see LDC
@@ -37,20 +37,20 @@
  *
  * @LastModified: Jan 2020
  */
-public abstract class CPInstruction extends Instruction implements TypedInstruction,
-        IndexedInstruction {
-
-    private int index; // index to constant pool
+public abstract class CPInstruction extends Instruction implements TypedInstruction, IndexedInstruction {
 
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int index; // index to constant pool
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     CPInstruction() {
     }
 
-
     /**
      * @param index to constant pool
      */
@@ -59,90 +59,87 @@ protected CPInstruction(final short opcode, final int index) {
         setIndex(index);
     }
 
-
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         out.writeByte(super.getOpcode());
         out.writeShort(index);
     }
 
-
     /**
-     * Long output format:
-     *
-     * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
-     * "("&lt;length of instruction&gt;")" "&lt;"&lt; constant pool index&gt;"&gt;"
-     *
-     * @param verbose long/short format switch
-     * @return mnemonic for instruction
+     * @return index in constant pool referred by this instruction.
      */
     @Override
-    public String toString( final boolean verbose ) {
-        return super.toString(verbose) + " " + index;
+    public final int getIndex() {
+        return index;
     }
 
-
     /**
-     * @return mnemonic for instruction with symbolic references resolved
+     * @return type related with this instruction.
      */
     @Override
-    public String toString( final ConstantPool cp ) {
-        final Constant c = cp.getConstant(index);
-        String str = cp.constantToString(c);
-        if (c instanceof ConstantClass) {
-            str = str.replace('.', '/');
+    public Type getType(final ConstantPoolGen cpg) {
+        final ConstantPool cp = cpg.getConstantPool();
+        String name = cp.getConstantString(index, com.sun.org.apache.bcel.internal.Const.CONSTANT_Class);
+        if (!name.startsWith("[")) {
+            name = "L" + name + ";";
         }
-        return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + str;
+        return Type.getType(name);
     }
 
-
     /**
      * Read needed data (i.e., index) from file.
+     *
      * @param bytes input stream
      * @param wide wide prefix?
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         setIndex(bytes.readUnsignedShort());
         super.setLength(3);
     }
 
-
-    /**
-     * @return index in constant pool referred by this instruction.
-     */
-    @Override
-    public final int getIndex() {
-        return index;
-    }
-
-
     /**
      * Set the index to constant pool.
-     * @param index in  constant pool.
+     *
+     * @param index in constant pool.
      */
     @Override
-    public void setIndex( final int index ) { // TODO could be package-protected?
+    public void setIndex(final int index) { // TODO could be package-protected?
         if (index < 0) {
             throw new ClassGenException("Negative index value: " + index);
         }
         this.index = index;
     }
 
+    /**
+     * Long output format:
+     *
+     * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]" "("&lt;length of instruction&gt;")" "&lt;"&lt; constant pool
+     * index&gt;"&gt;"
+     *
+     * @param verbose long/short format switch
+     * @return mnemonic for instruction
+     */
+    @Override
+    public String toString(final boolean verbose) {
+        return super.toString(verbose) + " " + index;
+    }
 
-    /** @return type related with this instruction.
+    /**
+     * @return mnemonic for instruction with symbolic references resolved
      */
     @Override
-    public Type getType( final ConstantPoolGen cpg ) {
-        final ConstantPool cp = cpg.getConstantPool();
-        String name = cp.getConstantString(index, com.sun.org.apache.bcel.internal.Const.CONSTANT_Class);
-        if (!name.startsWith("[")) {
-            name = "L" + name + ";";
+    public String toString(final ConstantPool cp) {
+        final Constant c = cp.getConstant(index);
+        String str = cp.constantToString(c);
+        if (c instanceof ConstantClass) {
+            str = Utility.packageToPath(str);
         }
-        return Type.getType(name);
+        return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + str;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java
index 249618f6122..1c1c032dbd5 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassElementValueGen.java
@@ -31,59 +31,40 @@
 /**
  * @since 6.0
  */
-public class ClassElementValueGen extends ElementValueGen
-{
+public class ClassElementValueGen extends ElementValueGen {
     // For primitive types and string type, this points to the value entry in
     // the cpool
     // For 'class' this points to the class entry in the cpool
-    private int idx;
+    private final int idx;
 
-    protected ClassElementValueGen(final int typeIdx, final ConstantPoolGen cpool)
-    {
+    public ClassElementValueGen(final ClassElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
+        super(CLASS, cpool);
+        if (copyPoolEntries) {
+            // idx = cpool.addClass(value.getClassString());
+            idx = cpool.addUtf8(value.getClassString());
+        } else {
+            idx = value.getIndex();
+        }
+    }
+
+    protected ClassElementValueGen(final int typeIdx, final ConstantPoolGen cpool) {
         super(ElementValueGen.CLASS, cpool);
         this.idx = typeIdx;
     }
 
-    public ClassElementValueGen(final ObjectType t, final ConstantPoolGen cpool)
-    {
+    public ClassElementValueGen(final ObjectType t, final ConstantPoolGen cpool) {
         super(ElementValueGen.CLASS, cpool);
         // this.idx = cpool.addClass(t);
         idx = cpool.addUtf8(t.getSignature());
     }
 
-    /**
-     * Return immutable variant of this ClassElementValueGen
-     */
     @Override
-    public ElementValue getElementValue()
-    {
-        return new ClassElementValue(super.getElementValueType(),
-                idx,
-                getConstantPool().getConstantPool());
-    }
-
-    public ClassElementValueGen(final ClassElementValue value, final ConstantPoolGen cpool,
-            final boolean copyPoolEntries)
-    {
-        super(CLASS, cpool);
-        if (copyPoolEntries)
-        {
-            // idx = cpool.addClass(value.getClassString());
-            idx = cpool.addUtf8(value.getClassString());
-        }
-        else
-        {
-            idx = value.getIndex();
-        }
-    }
-
-    public int getIndex()
-    {
-        return idx;
+    public void dump(final DataOutputStream dos) throws IOException {
+        dos.writeByte(super.getElementValueType()); // u1 kind of value
+        dos.writeShort(idx);
     }
 
-    public String getClassString()
-    {
+    public String getClassString() {
         final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx);
         return cu8.getBytes();
         // ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx);
@@ -92,16 +73,20 @@ public String getClassString()
         // return utf8.getBytes();
     }
 
+    /**
+     * Return immutable variant of this ClassElementValueGen
+     */
     @Override
-    public String stringifyValue()
-    {
-        return getClassString();
+    public ElementValue getElementValue() {
+        return new ClassElementValue(super.getElementValueType(), idx, getConstantPool().getConstantPool());
+    }
+
+    public int getIndex() {
+        return idx;
     }
 
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
-        dos.writeByte(super.getElementValueType()); // u1 kind of value
-        dos.writeShort(idx);
+    public String stringifyValue() {
+        return getClassString();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java
index 04be4be622a..acaf4519567 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,12 +20,13 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.classfile.AccessFlags;
-import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry;
 import com.sun.org.apache.bcel.internal.classfile.Annotations;
 import com.sun.org.apache.bcel.internal.classfile.Attribute;
 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
@@ -35,106 +36,79 @@
 import com.sun.org.apache.bcel.internal.classfile.RuntimeInvisibleAnnotations;
 import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleAnnotations;
 import com.sun.org.apache.bcel.internal.classfile.SourceFile;
+import com.sun.org.apache.bcel.internal.classfile.Utility;
 import com.sun.org.apache.bcel.internal.util.BCELComparator;
 
 /**
- * Template class for building up a java class. May be initialized with an
- * existing java class (file).
+ * Template class for building up a java class. May be initialized with an existing java class (file).
  *
  * @see JavaClass
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public class ClassGen extends AccessFlags implements Cloneable {
 
-    /* Corresponds to the fields found in a JavaClass object.
-     */
-    private String className;
-    private String superClassName;
-    private final String fileName;
-    private int classNameIndex = -1;
-    private int superclass_name_index = -1;
-    private int major = Const.MAJOR_1_1;
-    private int minor = Const.MINOR_1_1;
-    private ConstantPoolGen cp; // Template for building up constant pool
-    // ArrayLists instead of arrays to gather fields, methods, etc.
-    private final List<Field> fieldList = new ArrayList<>();
-    private final List<Method> methodList = new ArrayList<>();
-    private final List<Attribute> attributeList = new ArrayList<>();
-    private final List<String> interfaceList = new ArrayList<>();
-    private final List<AnnotationEntryGen> annotationList = new ArrayList<>();
-
     private static BCELComparator bcelComparator = new BCELComparator() {
 
         @Override
-        public boolean equals( final Object o1, final Object o2 ) {
+        public boolean equals(final Object o1, final Object o2) {
             final ClassGen THIS = (ClassGen) o1;
             final ClassGen THAT = (ClassGen) o2;
             return Objects.equals(THIS.getClassName(), THAT.getClassName());
         }
 
-
         @Override
-        public int hashCode( final Object o ) {
+        public int hashCode(final Object o) {
             final ClassGen THIS = (ClassGen) o;
             return THIS.getClassName().hashCode();
         }
     };
 
-
-    /** Convenience constructor to set up some important values initially.
-     *
-     * @param className fully qualified class name
-     * @param superClassName fully qualified superclass name
-     * @param fileName source file name
-     * @param accessFlags access qualifiers
-     * @param interfaces implemented interfaces
-     * @param cp constant pool to use
+    /**
+     * @return Comparison strategy object
      */
-    public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags,
-            final String[] interfaces, final ConstantPoolGen cp) {
-        super(accessFlags);
-        this.className = className;
-        this.superClassName = superClassName;
-        this.fileName = fileName;
-        this.cp = cp;
-        // Put everything needed by default into the constant pool and the vectors
-        if (fileName != null) {
-            addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(fileName), cp
-                    .getConstantPool()));
-        }
-        classNameIndex = cp.addClass(className);
-        superclass_name_index = cp.addClass(superClassName);
-        if (interfaces != null) {
-            for (final String interface1 : interfaces) {
-                addInterface(interface1);
-            }
-        }
+    public static BCELComparator getComparator() {
+        return bcelComparator;
     }
 
-
-    /** Convenience constructor to set up some important values initially.
-     *
-     * @param className fully qualified class name
-     * @param superClassName fully qualified superclass name
-     * @param fileName source file name
-     * @param accessFlags access qualifiers
-     * @param interfaces implemented interfaces
+    /**
+     * @param comparator Comparison strategy object
      */
-    public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags,
-            final String[] interfaces) {
-        this(className, superClassName, fileName, accessFlags, interfaces,
-                new ConstantPoolGen());
+    public static void setComparator(final BCELComparator comparator) {
+        bcelComparator = comparator;
     }
 
+    /*
+     * Corresponds to the fields found in a JavaClass object.
+     */
+    private String className;
+    private String superClassName;
+    private final String fileName;
+    private int classNameIndex = -1;
+    private int superclassNameIndex = -1;
+    private int major = Const.MAJOR_1_1;
+    private int minor = Const.MINOR_1_1;
+    private ConstantPoolGen cp; // Template for building up constant pool
+    // ArrayLists instead of arrays to gather fields, methods, etc.
+    private final List<Field> fieldList = new ArrayList<>();
+    private final List<Method> methodList = new ArrayList<>();
+
+    private final List<Attribute> attributeList = new ArrayList<>();
+
+    private final List<String> interfaceList = new ArrayList<>();
+
+    private final List<AnnotationEntryGen> annotationList = new ArrayList<>();
+
+    private List<ClassObserver> observers;
 
     /**
      * Initialize with existing class.
+     *
      * @param clazz JavaClass object (e.g. read from file)
      */
     public ClassGen(final JavaClass clazz) {
         super(clazz.getAccessFlags());
         classNameIndex = clazz.getClassNameIndex();
-        superclass_name_index = clazz.getSuperclassNameIndex();
+        superclassNameIndex = clazz.getSuperclassNameIndex();
         className = clazz.getClassName();
         superClassName = clazz.getSuperclassName();
         fileName = clazz.getSourceFileName();
@@ -144,189 +118,142 @@ public ClassGen(final JavaClass clazz) {
         final Attribute[] attributes = clazz.getAttributes();
         // J5TODO: Could make unpacking lazy, done on first reference
         final AnnotationEntryGen[] annotations = unpackAnnotations(attributes);
-        final Method[] methods = clazz.getMethods();
-        final Field[] fields = clazz.getFields();
-        final String[] interfaces = clazz.getInterfaceNames();
-        for (final String interface1 : interfaces) {
-            addInterface(interface1);
-        }
+        Collections.addAll(interfaceList, clazz.getInterfaceNames());
         for (final Attribute attribute : attributes) {
             if (!(attribute instanceof Annotations)) {
                 addAttribute(attribute);
             }
         }
-        for (final AnnotationEntryGen annotation : annotations) {
-            addAnnotationEntry(annotation);
-        }
-        for (final Method method : methods) {
-            addMethod(method);
-        }
-        for (final Field field : fields) {
-            addField(field);
-        }
+        Collections.addAll(annotationList, annotations);
+        Collections.addAll(methodList, clazz.getMethods());
+        Collections.addAll(fieldList, clazz.getFields());
     }
 
     /**
-     * Look for attributes representing annotations and unpack them.
+     * Convenience constructor to set up some important values initially.
+     *
+     * @param className fully qualified class name
+     * @param superClassName fully qualified superclass name
+     * @param fileName source file name
+     * @param accessFlags access qualifiers
+     * @param interfaces implemented interfaces
      */
-    private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attrs)
-    {
-        final List<AnnotationEntryGen> annotationGenObjs = new ArrayList<>();
-        for (final Attribute attr : attrs) {
-            if (attr instanceof RuntimeVisibleAnnotations)
-            {
-                final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
-                final AnnotationEntry[] annos = rva.getAnnotationEntries();
-                for (final AnnotationEntry a : annos) {
-                    annotationGenObjs.add(new AnnotationEntryGen(a,
-                            getConstantPool(), false));
-                }
-            }
-            else
-                if (attr instanceof RuntimeInvisibleAnnotations)
-                {
-                    final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr;
-                    final AnnotationEntry[] annos = ria.getAnnotationEntries();
-                    for (final AnnotationEntry a : annos) {
-                        annotationGenObjs.add(new AnnotationEntryGen(a,
-                                getConstantPool(), false));
-                    }
-                }
-        }
-        return annotationGenObjs.toArray(new AnnotationEntryGen[annotationGenObjs.size()]);
+    public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces) {
+        this(className, superClassName, fileName, accessFlags, interfaces, new ConstantPoolGen());
     }
 
-
     /**
-     * @return the (finally) built up Java class object.
+     * Convenience constructor to set up some important values initially.
+     *
+     * @param className fully qualified class name
+     * @param superClassName fully qualified superclass name
+     * @param fileName source file name
+     * @param accessFlags access qualifiers
+     * @param interfaces implemented interfaces
+     * @param cp constant pool to use
      */
-    public JavaClass getJavaClass() {
-        final int[] interfaces = getInterfaces();
-        final Field[] fields = getFields();
-        final Method[] methods = getMethods();
-        Attribute[] attributes = null;
-        if (annotationList.isEmpty()) {
-            attributes = getAttributes();
-        } else {
-            // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations'
-            final Attribute[] annAttributes  = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries());
-            attributes = new Attribute[attributeList.size()+annAttributes.length];
-            attributeList.toArray(attributes);
-            System.arraycopy(annAttributes,0,attributes,attributeList.size(),annAttributes.length);
+    public ClassGen(final String className, final String superClassName, final String fileName, final int accessFlags, final String[] interfaces,
+        final ConstantPoolGen cp) {
+        super(accessFlags);
+        this.className = className;
+        this.superClassName = superClassName;
+        this.fileName = fileName;
+        this.cp = cp;
+        // Put everything needed by default into the constant pool and the vectors
+        if (fileName != null) {
+            addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(fileName), cp.getConstantPool()));
+        }
+        classNameIndex = cp.addClass(className);
+        superclassNameIndex = cp.addClass(superClassName);
+        if (interfaces != null) {
+            Collections.addAll(interfaceList, interfaces);
         }
-        // Must be last since the above calls may still add something to it
-        final ConstantPool _cp = this.cp.getFinalConstantPool();
-        return new JavaClass(classNameIndex, superclass_name_index, fileName, major, minor,
-                super.getAccessFlags(), _cp, interfaces, fields, methods, attributes);
     }
 
-
-    /**
-     * Add an interface to this class, i.e., this class has to implement it.
-     * @param name interface to implement (fully qualified class name)
-     */
-    public void addInterface( final String name ) {
-        interfaceList.add(name);
+    public void addAnnotationEntry(final AnnotationEntryGen a) {
+        annotationList.add(a);
     }
 
-
     /**
-     * Remove an interface from this class.
-     * @param name interface to remove (fully qualified name)
+     * Add an attribute to this class.
+     *
+     * @param a attribute to add
      */
-    public void removeInterface( final String name ) {
-        interfaceList.remove(name);
+    public void addAttribute(final Attribute a) {
+        attributeList.add(a);
     }
 
-
     /**
-     * @return major version number of class file
-     */
-    public int getMajor() {
-        return major;
-    }
-
-
-    /** Set major version number of class file, default value is 45 (JDK 1.1)
-     * @param major major version number
-     */
-    public void setMajor( final int major ) { // TODO could be package-protected - only called by test code
-        this.major = major;
-    }
-
-
-    /** Set minor version number of class file, default value is 3 (JDK 1.1)
-     * @param minor minor version number
+     * Convenience method.
+     *
+     * Add an empty constructor to this class that does nothing but calling super().
+     *
+     * @param accessFlags rights for constructor
      */
-    public void setMinor( final int minor ) {  // TODO could be package-protected - only called by test code
-        this.minor = minor;
+    public void addEmptyConstructor(final int accessFlags) {
+        final InstructionList il = new InstructionList();
+        il.append(InstructionConst.THIS); // Push 'this'
+        il.append(new INVOKESPECIAL(cp.addMethodref(superClassName, Const.CONSTRUCTOR_NAME, "()V")));
+        il.append(InstructionConst.RETURN);
+        final MethodGen mg = new MethodGen(accessFlags, Type.VOID, Type.NO_ARGS, null, Const.CONSTRUCTOR_NAME, className, il, cp);
+        mg.setMaxStack(1);
+        addMethod(mg.getMethod());
     }
 
     /**
-     * @return minor version number of class file
+     * Add a field to this class.
+     *
+     * @param f field to add
      */
-    public int getMinor() {
-        return minor;
+    public void addField(final Field f) {
+        fieldList.add(f);
     }
 
-
     /**
-     * Add an attribute to this class.
-     * @param a attribute to add
+     * Add an interface to this class, i.e., this class has to implement it.
+     *
+     * @param name interface to implement (fully qualified class name)
      */
-    public void addAttribute( final Attribute a ) {
-        attributeList.add(a);
-    }
-
-    public void addAnnotationEntry(final AnnotationEntryGen a) {
-        annotationList.add(a);
+    public void addInterface(final String name) {
+        interfaceList.add(name);
     }
 
-
     /**
      * Add a method to this class.
+     *
      * @param m method to add
      */
-    public void addMethod( final Method m ) {
+    public void addMethod(final Method m) {
         methodList.add(m);
     }
 
-
     /**
-     * Convenience method.
-     *
-     * Add an empty constructor to this class that does nothing but calling super().
-     * @param access_flags rights for constructor
+     * Add observer for this object.
      */
-    public void addEmptyConstructor( final int access_flags ) {
-        final InstructionList il = new InstructionList();
-        il.append(InstructionConst.THIS); // Push `this'
-        il.append(new INVOKESPECIAL(cp.addMethodref(superClassName, "<init>", "()V")));
-        il.append(InstructionConst.RETURN);
-        final MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "<init>",
-                className, il, cp);
-        mg.setMaxStack(1);
-        addMethod(mg.getMethod());
+    public void addObserver(final ClassObserver o) {
+        if (observers == null) {
+            observers = new ArrayList<>();
+        }
+        observers.add(o);
     }
 
-
-    /**
-     * Add a field to this class.
-     * @param f field to add
-     */
-    public void addField( final Field f ) {
-        fieldList.add(f);
+    @Override
+    public Object clone() {
+        try {
+            return super.clone();
+        } catch (final CloneNotSupportedException e) {
+            throw new Error("Clone Not Supported"); // never happens
+        }
     }
 
-
-    public boolean containsField( final Field f ) {
+    public boolean containsField(final Field f) {
         return fieldList.contains(f);
     }
 
-
-    /** @return field object with given name, or null
+    /**
+     * @return field object with given name, or null
      */
-    public Field containsField( final String name ) {
+    public Field containsField(final String name) {
         for (final Field f : fieldList) {
             if (f.getName().equals(name)) {
                 return f;
@@ -335,10 +262,10 @@ public Field containsField( final String name ) {
         return null;
     }
 
-
-    /** @return method object with given name and signature, or null
+    /**
+     * @return method object with given name and signature, or null
      */
-    public Method containsMethod( final String name, final String signature ) {
+    public Method containsMethod(final String name, final String signature) {
         for (final Method m : methodList) {
             if (m.getName().equals(name) && m.getSignature().equals(signature)) {
                 return m;
@@ -347,264 +274,272 @@ public Method containsMethod( final String name, final String signature ) {
         return null;
     }
 
-
     /**
-     * Remove an attribute from this class.
-     * @param a attribute to remove
-     */
-    public void removeAttribute( final Attribute a ) {
-        attributeList.remove(a);
-    }
-
-
-    /**
-     * Remove a method from this class.
-     * @param m method to remove
-     */
-    public void removeMethod( final Method m ) {
-        methodList.remove(m);
-    }
-
-
-    /** Replace given method with new one. If the old one does not exist
-     * add the new_ method to the class anyway.
+     * Return value as defined by given BCELComparator strategy. By default two ClassGen objects are said to be equal when
+     * their class names are equal.
+     *
+     * @see Object#equals(Object)
      */
-    public void replaceMethod( final Method old, final Method new_ ) {
-        if (new_ == null) {
-            throw new ClassGenException("Replacement method must not be null");
-        }
-        final int i = methodList.indexOf(old);
-        if (i < 0) {
-            methodList.add(new_);
-        } else {
-            methodList.set(i, new_);
-        }
+    @Override
+    public boolean equals(final Object obj) {
+        return bcelComparator.equals(this, obj);
     }
 
-
-    /** Replace given field with new one. If the old one does not exist
-     * add the new_ field to the class anyway.
-     */
-    public void replaceField( final Field old, final Field new_ ) {
-        if (new_ == null) {
-            throw new ClassGenException("Replacement method must not be null");
-        }
-        final int i = fieldList.indexOf(old);
-        if (i < 0) {
-            fieldList.add(new_);
-        } else {
-            fieldList.set(i, new_);
-        }
+    // J5TODO: Should we make calling unpackAnnotations() lazy and put it in here?
+    public AnnotationEntryGen[] getAnnotationEntries() {
+        return annotationList.toArray(AnnotationEntryGen.EMPTY_ARRAY);
     }
 
-
-    /**
-     * Remove a field to this class.
-     * @param f field to remove
-     */
-    public void removeField( final Field f ) {
-        fieldList.remove(f);
+    public Attribute[] getAttributes() {
+        return attributeList.toArray(Attribute.EMPTY_ARRAY);
     }
 
-
     public String getClassName() {
         return className;
     }
 
-
-    public String getSuperclassName() {
-        return superClassName;
-    }
-
-
-    public String getFileName() {
-        return fileName;
-    }
-
-
-    public void setClassName( final String name ) {
-        className = name.replace('/', '.');
-        classNameIndex = cp.addClass(name);
-    }
-
-
-    public void setSuperclassName( final String name ) {
-        superClassName = name.replace('/', '.');
-        superclass_name_index = cp.addClass(name);
-    }
-
-
-    public Method[] getMethods() {
-        return methodList.toArray(new Method[methodList.size()]);
+    public int getClassNameIndex() {
+        return classNameIndex;
     }
 
-
-    public void setMethods( final Method[] methods ) {
-        methodList.clear();
-        for (final Method method : methods) {
-            addMethod(method);
-        }
+    public ConstantPoolGen getConstantPool() {
+        return cp;
     }
 
-
-    public void setMethodAt( final Method method, final int pos ) {
-        methodList.set(pos, method);
+    public Field[] getFields() {
+        return fieldList.toArray(Field.EMPTY_ARRAY);
     }
 
-
-    public Method getMethodAt( final int pos ) {
-        return methodList.get(pos);
+    public String getFileName() {
+        return fileName;
     }
 
-
     public String[] getInterfaceNames() {
-        final int size = interfaceList.size();
-        final String[] interfaces = new String[size];
-        interfaceList.toArray(interfaces);
-        return interfaces;
+        return interfaceList.toArray(Const.EMPTY_STRING_ARRAY);
     }
 
-
     public int[] getInterfaces() {
         final int size = interfaceList.size();
         final int[] interfaces = new int[size];
-        for (int i = 0; i < size; i++) {
-            interfaces[i] = cp.addClass(interfaceList.get(i));
-        }
+        Arrays.setAll(interfaces, i -> cp.addClass(interfaceList.get(i)));
         return interfaces;
     }
 
-
-    public Field[] getFields() {
-        return fieldList.toArray(new Field[fieldList.size()]);
-    }
-
-
-    public Attribute[] getAttributes() {
-        return attributeList.toArray(new Attribute[attributeList.size()]);
+    /**
+     * @return the (finally) built up Java class object.
+     */
+    public JavaClass getJavaClass() {
+        final int[] interfaces = getInterfaces();
+        final Field[] fields = getFields();
+        final Method[] methods = getMethods();
+        Attribute[] attributes = null;
+        if (annotationList.isEmpty()) {
+            attributes = getAttributes();
+        } else {
+            // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations'
+            final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries());
+            attributes = new Attribute[attributeList.size() + annAttributes.length];
+            attributeList.toArray(attributes);
+            System.arraycopy(annAttributes, 0, attributes, attributeList.size(), annAttributes.length);
+        }
+        // Must be last since the above calls may still add something to it
+        final ConstantPool cp = this.cp.getFinalConstantPool();
+        return new JavaClass(classNameIndex, superclassNameIndex, fileName, major, minor, super.getAccessFlags(), cp, interfaces, fields, methods,
+            attributes);
     }
 
-    //  J5TODO: Should we make calling unpackAnnotations() lazy and put it in here?
-    public AnnotationEntryGen[] getAnnotationEntries() {
-        return annotationList.toArray(new AnnotationEntryGen[annotationList.size()]);
+    /**
+     * @return major version number of class file
+     */
+    public int getMajor() {
+        return major;
     }
 
-
-    public ConstantPoolGen getConstantPool() {
-        return cp;
+    public Method getMethodAt(final int pos) {
+        return methodList.get(pos);
     }
 
-
-    public void setConstantPool( final ConstantPoolGen constant_pool ) {
-        cp = constant_pool;
+    public Method[] getMethods() {
+        return methodList.toArray(Method.EMPTY_ARRAY);
     }
 
-
-    public void setClassNameIndex( final int class_name_index ) {
-        this.classNameIndex = class_name_index;
-        className = cp.getConstantPool().getConstantString(class_name_index,
-                Const.CONSTANT_Class).replace('/', '.');
+    /**
+     * @return minor version number of class file
+     */
+    public int getMinor() {
+        return minor;
     }
 
-
-    public void setSuperclassNameIndex( final int superclass_name_index ) {
-        this.superclass_name_index = superclass_name_index;
-        superClassName = cp.getConstantPool().getConstantString(superclass_name_index,
-                Const.CONSTANT_Class).replace('/', '.');
+    public String getSuperclassName() {
+        return superClassName;
     }
 
-
     public int getSuperclassNameIndex() {
-        return superclass_name_index;
+        return superclassNameIndex;
     }
 
-
-    public int getClassNameIndex() {
-        return classNameIndex;
+    /**
+     * Return value as defined by given BCELComparator strategy. By default return the hashcode of the class name.
+     *
+     * @see Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return bcelComparator.hashCode(this);
     }
 
-    private List<ClassObserver> observers;
+    /**
+     * Remove an attribute from this class.
+     *
+     * @param a attribute to remove
+     */
+    public void removeAttribute(final Attribute a) {
+        attributeList.remove(a);
+    }
 
+    /**
+     * Remove a field to this class.
+     *
+     * @param f field to remove
+     */
+    public void removeField(final Field f) {
+        fieldList.remove(f);
+    }
 
-    /** Add observer for this object.
+    /**
+     * Remove an interface from this class.
+     *
+     * @param name interface to remove (fully qualified name)
      */
-    public void addObserver( final ClassObserver o ) {
-        if (observers == null) {
-            observers = new ArrayList<>();
-        }
-        observers.add(o);
+    public void removeInterface(final String name) {
+        interfaceList.remove(name);
     }
 
+    /**
+     * Remove a method from this class.
+     *
+     * @param m method to remove
+     */
+    public void removeMethod(final Method m) {
+        methodList.remove(m);
+    }
 
-    /** Remove observer for this object.
+    /**
+     * Remove observer for this object.
      */
-    public void removeObserver( final ClassObserver o ) {
+    public void removeObserver(final ClassObserver o) {
         if (observers != null) {
             observers.remove(o);
         }
     }
 
+    /**
+     * Replace given field with new one. If the old one does not exist add the new_ field to the class anyway.
+     */
+    public void replaceField(final Field old, final Field newField) {
+        if (newField == null) {
+            throw new ClassGenException("Replacement method must not be null");
+        }
+        final int i = fieldList.indexOf(old);
+        if (i < 0) {
+            fieldList.add(newField);
+        } else {
+            fieldList.set(i, newField);
+        }
+    }
 
-    /** Call notify() method on all observers. This method is not called
-     * automatically whenever the state has changed, but has to be
-     * called by the user after he has finished editing the object.
+    /**
+     * Replace given method with new one. If the old one does not exist add the newMethod method to the class anyway.
      */
-    public void update() {
-        if (observers != null) {
-            for (final ClassObserver observer : observers) {
-                observer.notify(this);
-            }
+    public void replaceMethod(final Method old, final Method newMethod) {
+        if (newMethod == null) {
+            throw new ClassGenException("Replacement method must not be null");
+        }
+        final int i = methodList.indexOf(old);
+        if (i < 0) {
+            methodList.add(newMethod);
+        } else {
+            methodList.set(i, newMethod);
         }
     }
 
+    public void setClassName(final String name) {
+        className = Utility.pathToPackage(name);
+        classNameIndex = cp.addClass(name);
+    }
 
-    @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (final CloneNotSupportedException e) {
-            throw new Error("Clone Not Supported"); // never happens
-        }
+    public void setClassNameIndex(final int classNameIndex) {
+        this.classNameIndex = classNameIndex;
+        this.className = Utility.pathToPackage(cp.getConstantPool().getConstantString(classNameIndex, Const.CONSTANT_Class));
     }
 
+    public void setConstantPool(final ConstantPoolGen constantPool) {
+        cp = constantPool;
+    }
 
     /**
-     * @return Comparison strategy object
+     * Set major version number of class file, default value is 45 (JDK 1.1)
+     *
+     * @param major major version number
      */
-    public static BCELComparator getComparator() {
-        return bcelComparator;
+    public void setMajor(final int major) { // TODO could be package-protected - only called by test code
+        this.major = major;
     }
 
+    public void setMethodAt(final Method method, final int pos) {
+        methodList.set(pos, method);
+    }
+
+    public void setMethods(final Method[] methods) {
+        methodList.clear();
+        Collections.addAll(methodList, methods);
+    }
 
     /**
-     * @param comparator Comparison strategy object
+     * Set minor version number of class file, default value is 3 (JDK 1.1)
+     *
+     * @param minor minor version number
      */
-    public static void setComparator( final BCELComparator comparator ) {
-        bcelComparator = comparator;
+    public void setMinor(final int minor) { // TODO could be package-protected - only called by test code
+        this.minor = minor;
     }
 
+    public void setSuperclassName(final String name) {
+        superClassName = Utility.pathToPackage(name);
+        superclassNameIndex = cp.addClass(name);
+    }
+
+    public void setSuperclassNameIndex(final int superclassNameIndex) {
+        this.superclassNameIndex = superclassNameIndex;
+        superClassName = Utility.pathToPackage(cp.getConstantPool().getConstantString(superclassNameIndex, Const.CONSTANT_Class));
+    }
 
     /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default two ClassGen objects are said to be equal when
-     * their class names are equal.
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
+     * Look for attributes representing annotations and unpack them.
      */
-    @Override
-    public boolean equals( final Object obj ) {
-        return bcelComparator.equals(this, obj);
+    private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attrs) {
+        final List<AnnotationEntryGen> annotationGenObjs = new ArrayList<>();
+        for (final Attribute attr : attrs) {
+            if (attr instanceof RuntimeVisibleAnnotations) {
+                final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
+                rva.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)));
+            } else if (attr instanceof RuntimeInvisibleAnnotations) {
+                final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr;
+                ria.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)));
+            }
+        }
+        return annotationGenObjs.toArray(AnnotationEntryGen.EMPTY_ARRAY);
     }
 
-
     /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default return the hashcode of the class name.
-     *
-     * @see java.lang.Object#hashCode()
+     * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but
+     * has to be called by the user after they have finished editing the object.
      */
-    @Override
-    public int hashCode() {
-        return bcelComparator.hashCode(this);
+    public void update() {
+        if (observers != null) {
+            for (final ClassObserver observer : observers) {
+                observer.notify(this);
+            }
+        }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGenException.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGenException.java
index 8fd54651af8..8dfbde810de 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGenException.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGenException.java
@@ -22,19 +22,15 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Thrown on internal errors. Extends RuntimeException so it hasn't to be declared
- * in the throws clause every time.
- *
+ * Thrown on internal exceptions.
  */
 public class ClassGenException extends RuntimeException {
 
     private static final long serialVersionUID = 7247369755051242791L;
 
     public ClassGenException() {
-        super();
     }
 
-
     public ClassGenException(final String s) {
         super(s);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassObserver.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassObserver.java
index 62ec3139efe..64f2c44c41d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassObserver.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassObserver.java
@@ -22,11 +22,10 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Implement this interface if you're interested in changes to a ClassGen object
- * and register yourself with addObserver().
- *
+ * Implement this interface if you're interested in changes to a ClassGen object and register yourself with
+ * addObserver().
  */
 public interface ClassObserver {
 
-    void notify( ClassGen clazz );
+    void notify(ClassGen clazz);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java
index de1a31dd125..fa660954d15 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java
@@ -23,167 +23,158 @@
 import com.sun.org.apache.bcel.internal.classfile.CodeException;
 
 /**
- * This class represents an exception handler, i.e., specifies the  region where
- * a handler is active and an instruction where the actual handling is done.
- * pool as parameters. Opposed to the JVM specification the end of the handled
- * region is set to be inclusive, i.e. all instructions between start and end
- * are protected including the start and end instructions (handles) themselves.
- * The end of the region is automatically mapped to be exclusive when calling
+ * This class represents an exception handler, i.e., specifies the region where a handler is active and an instruction
+ * where the actual handling is done. pool as parameters. Opposed to the JVM specification the end of the handled region
+ * is set to be inclusive, i.e. all instructions between start and end are protected including the start and end
+ * instructions (handles) themselves. The end of the region is automatically mapped to be exclusive when calling
  * getCodeException(), i.e., there is no difference semantically.
  *
- * @see     MethodGen
- * @see     CodeException
- * @see     InstructionHandle
+ * @see MethodGen
+ * @see CodeException
+ * @see InstructionHandle
  */
 public final class CodeExceptionGen implements InstructionTargeter, Cloneable {
 
+    static final CodeExceptionGen[] EMPTY_ARRAY = {};
+
     private InstructionHandle startPc;
     private InstructionHandle endPc;
     private InstructionHandle handlerPc;
     private ObjectType catchType;
 
-
     /**
-     * Add an exception handler, i.e., specify region where a handler is active and an
-     * instruction where the actual handling is done.
+     * Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling
+     * is done.
      *
      * @param startPc Start of handled region (inclusive)
      * @param endPc End of handled region (inclusive)
      * @param handlerPc Where handling is done
      * @param catchType which exception is handled, null for ANY
      */
-    public CodeExceptionGen(final InstructionHandle startPc, final InstructionHandle endPc,
-            final InstructionHandle handlerPc, final ObjectType catchType) {
+    public CodeExceptionGen(final InstructionHandle startPc, final InstructionHandle endPc, final InstructionHandle handlerPc, final ObjectType catchType) {
         setStartPC(startPc);
         setEndPC(endPc);
         setHandlerPC(handlerPc);
         this.catchType = catchType;
     }
 
+    @Override
+    public Object clone() {
+        try {
+            return super.clone();
+        } catch (final CloneNotSupportedException e) {
+            throw new Error("Clone Not Supported"); // never happens
+        }
+    }
 
     /**
-     * Get CodeException object.<BR>
-     *
-     * This relies on that the instruction list has already been dumped
-     * to byte code or or that the `setPositions' methods has been
-     * called for the instruction list.
-     *
-     * @param cp constant pool
+     * @return true, if ih is target of this handler
      */
-    public CodeException getCodeException( final ConstantPoolGen cp ) {
-        return new CodeException(startPc.getPosition(), endPc.getPosition()
-                + endPc.getInstruction().getLength(), handlerPc.getPosition(),
-                (catchType == null) ? 0 : cp.addClass(catchType));
+    @Override
+    public boolean containsTarget(final InstructionHandle ih) {
+        return startPc == ih || endPc == ih || handlerPc == ih;
     }
 
-
-    /* Set start of handler
-     * @param startPc Start of handled region (inclusive)
-     */
-    public void setStartPC( final InstructionHandle start_pc ) { // TODO could be package-protected?
-        BranchInstruction.notifyTarget(this.startPc, start_pc, this);
-        this.startPc = start_pc;
+    /** Gets the type of the Exception to catch, 'null' for ANY. */
+    public ObjectType getCatchType() {
+        return catchType;
     }
 
-
-    /* Set end of handler
-     * @param endPc End of handled region (inclusive)
+    /**
+     * Get CodeException object.<BR>
+     *
+     * This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods
+     * has been called for the instruction list.
+     *
+     * @param cp constant pool
      */
-    public void setEndPC( final InstructionHandle end_pc ) { // TODO could be package-protected?
-        BranchInstruction.notifyTarget(this.endPc, end_pc, this);
-        this.endPc = end_pc;
+    public CodeException getCodeException(final ConstantPoolGen cp) {
+        return new CodeException(startPc.getPosition(), endPc.getPosition() + endPc.getInstruction().getLength(), handlerPc.getPosition(),
+            catchType == null ? 0 : cp.addClass(catchType));
     }
 
-
-    /* Set handler code
-     * @param handlerPc Start of handler
+    /**
+     * @return end of handled region (inclusive)
      */
-    public void setHandlerPC( final InstructionHandle handler_pc ) { // TODO could be package-protected?
-        BranchInstruction.notifyTarget(this.handlerPc, handler_pc, this);
-        this.handlerPc = handler_pc;
+    public InstructionHandle getEndPC() {
+        return endPc;
     }
 
-
     /**
-     * @param old_ih old target, either start or end
-     * @param new_ih new target
+     * @return start of handler
      */
-    @Override
-    public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) {
-        boolean targeted = false;
-        if (startPc == old_ih) {
-            targeted = true;
-            setStartPC(new_ih);
-        }
-        if (endPc == old_ih) {
-            targeted = true;
-            setEndPC(new_ih);
-        }
-        if (handlerPc == old_ih) {
-            targeted = true;
-            setHandlerPC(new_ih);
-        }
-        if (!targeted) {
-            throw new ClassGenException("Not targeting " + old_ih + ", but {" + startPc + ", "
-                    + endPc + ", " + handlerPc + "}");
-        }
+    public InstructionHandle getHandlerPC() {
+        return handlerPc;
     }
 
-
     /**
-     * @return true, if ih is target of this handler
+     * @return start of handled region (inclusive)
      */
-    @Override
-    public boolean containsTarget( final InstructionHandle ih ) {
-        return (startPc == ih) || (endPc == ih) || (handlerPc == ih);
+    public InstructionHandle getStartPC() {
+        return startPc;
     }
 
-
     /** Sets the type of the Exception to catch. Set 'null' for ANY. */
-    public void setCatchType( final ObjectType catchType ) {
+    public void setCatchType(final ObjectType catchType) {
         this.catchType = catchType;
     }
 
-
-    /** Gets the type of the Exception to catch, 'null' for ANY. */
-    public ObjectType getCatchType() {
-        return catchType;
-    }
-
-
-    /** @return start of handled region (inclusive)
+    /*
+     * Set end of handler
+     *
+     * @param endPc End of handled region (inclusive)
      */
-    public InstructionHandle getStartPC() {
-        return startPc;
+    public void setEndPC(final InstructionHandle endPc) { // TODO could be package-protected?
+        BranchInstruction.notifyTarget(this.endPc, endPc, this);
+        this.endPc = endPc;
     }
 
-
-    /** @return end of handled region (inclusive)
+    /*
+     * Set handler code
+     *
+     * @param handlerPc Start of handler
      */
-    public InstructionHandle getEndPC() {
-        return endPc;
+    public void setHandlerPC(final InstructionHandle handlerPc) { // TODO could be package-protected?
+        BranchInstruction.notifyTarget(this.handlerPc, handlerPc, this);
+        this.handlerPc = handlerPc;
     }
 
-
-    /** @return start of handler
+    /*
+     * Set start of handler
+     *
+     * @param startPc Start of handled region (inclusive)
      */
-    public InstructionHandle getHandlerPC() {
-        return handlerPc;
+    public void setStartPC(final InstructionHandle startPc) { // TODO could be package-protected?
+        BranchInstruction.notifyTarget(this.startPc, startPc, this);
+        this.startPc = startPc;
     }
 
-
     @Override
     public String toString() {
         return "CodeExceptionGen(" + startPc + ", " + endPc + ", " + handlerPc + ")";
     }
 
-
+    /**
+     * @param oldIh old target, either start or end
+     * @param newIh new target
+     */
     @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (final CloneNotSupportedException e) {
-            throw new Error("Clone Not Supported"); // never happens
+    public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) {
+        boolean targeted = false;
+        if (startPc == oldIh) {
+            targeted = true;
+            setStartPC(newIh);
+        }
+        if (endPc == oldIh) {
+            targeted = true;
+            setEndPC(newIh);
+        }
+        if (handlerPc == oldIh) {
+            targeted = true;
+            setHandlerPC(newIh);
+        }
+        if (!targeted) {
+            throw new ClassGenException("Not targeting " + oldIh + ", but {" + startPc + ", " + endPc + ", " + handlerPc + "}");
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java
index f487d51fcfd..40fc722d0d1 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/CompoundInstruction.java
@@ -22,15 +22,12 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Wrapper class for `compound' operations, virtual instructions that
- * don't exist as byte code, but give a useful meaning. For example,
- * the (virtual) PUSH instruction takes an arbitray argument and produces the
- * appropiate code at dump time (ICONST, LDC, BIPUSH, ...). Also you can use the
- * SWITCH instruction as a useful template for either LOOKUPSWITCH or
- * TABLESWITCH.
+ * Wrapper class for 'compound' operations, virtual instructions that don't exist as byte code, but give a useful
+ * meaning. For example, the (virtual) PUSH instruction takes an arbitrary argument and produces the appropriate code at
+ * dump time (ICONST, LDC, BIPUSH, ...). Also you can use the SWITCH instruction as a useful template for either
+ * LOOKUPSWITCH or TABLESWITCH.
  *
- * The interface provides the possibilty for the user to write
- * `templates' or `macros' for such reuseable code patterns.
+ * The interface provides the possibility for the user to write 'templates' or 'macros' for such reusable code patterns.
  *
  * @see PUSH
  * @see SWITCH
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java
index 622cdb1b7ac..b07fef8f901 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,6 +19,7 @@
  */
 package com.sun.org.apache.bcel.internal.generic;
 
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -27,6 +28,7 @@
 import com.sun.org.apache.bcel.internal.classfile.ConstantCP;
 import com.sun.org.apache.bcel.internal.classfile.ConstantClass;
 import com.sun.org.apache.bcel.internal.classfile.ConstantDouble;
+import com.sun.org.apache.bcel.internal.classfile.ConstantDynamic;
 import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref;
 import com.sun.org.apache.bcel.internal.classfile.ConstantFloat;
 import com.sun.org.apache.bcel.internal.classfile.ConstantInteger;
@@ -38,45 +40,68 @@
 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
 import com.sun.org.apache.bcel.internal.classfile.ConstantString;
 import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
+import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
- * This class is used to build up a constant pool. The user adds
- * constants via `addXXX' methods, `addString', `addClass',
- * etc.. These methods return an index into the constant
- * pool. Finally, `getFinalConstantPool()' returns the constant pool
- * built up. Intermediate versions of the constant pool can be
- * obtained with `getConstantPool()'. A constant pool has capacity for
- * Constants.MAX_SHORT entries. Note that the first (0) is used by the
- * JVM and that Double and Long constants need two slots.
+ * This class is used to build up a constant pool. The user adds constants via 'addXXX' methods, 'addString',
+ * 'addClass', etc.. These methods return an index into the constant pool. Finally, 'getFinalConstantPool()' returns the
+ * constant pool built up. Intermediate versions of the constant pool can be obtained with 'getConstantPool()'. A
+ * constant pool has capacity for Constants.MAX_SHORT entries. Note that the first (0) is used by the JVM and that
+ * Double and Long constants need two slots.
  *
  * @see Constant
- * @LastModified: June 2022
+ * @LastModified: Feb 2023
  */
 public class ConstantPoolGen {
-    public static final int CONSTANT_POOL_SIZE = 65535;
+
     private static final int DEFAULT_BUFFER_SIZE = 256;
-    private int size;
-    private Constant[] constants;
-    private int index = 1; // First entry (0) used by JVM
 
     private static final String METHODREF_DELIM = ":";
+
     private static final String IMETHODREF_DELIM = "#";
+
     private static final String FIELDREF_DELIM = "&";
+
     private static final String NAT_DELIM = "%"; // Name and Type
 
-    private static class Index {
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int size;
 
-        final int index;
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected Constant[] constants;
 
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getSize()
+     */
+    @Deprecated
+    protected int index = 1; // First entry (0) used by JVM
 
-        Index(final int i) {
-            index = i;
-        }
-    }
+    private final Map<String, Integer> stringTable = new HashMap<>();
+
+    private final Map<String, Integer> classTable = new HashMap<>();
+
+    private final Map<String, Integer> utf8Table = new HashMap<>();
+
+    private final Map<String, Integer> natTable = new HashMap<>();
 
+    private final Map<String, Integer> cpTable = new HashMap<>();
 
     /**
-     * Initialize with given array of constants.
+     * Constructs a new empty constant pool.
+     */
+    public ConstantPoolGen() {
+        size = DEFAULT_BUFFER_SIZE;
+        constants = new Constant[size];
+    }
+
+    /**
+     * Constructs a new instance with the given array of constants.
      *
      * @param cs array of given constants, new ones will be appended
      */
@@ -88,15 +113,15 @@ public ConstantPoolGen(final Constant[] cs) {
          * This is however, not used by XSLT (or the java.xml implementation),
          * and only happens when BCELifier is called (see BCELifier).
         */
-        if (cs.length > CONSTANT_POOL_SIZE) {
-            throw new RuntimeException("The number of constants " + cs.length
+        if (cs.length > Const.MAX_CP_ENTRIES) {
+            throw new IllegalStateException("The number of constants " + cs.length
                     + " is over the size limit of the constant pool: "
-                    + CONSTANT_POOL_SIZE);
+                    + Const.MAX_CP_ENTRIES);
         }
 
         final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE);
 
-        size = Math.min(Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64), CONSTANT_POOL_SIZE);
+        size = Math.min(Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64), Const.MAX_CP_ENTRIES);
         constants = new Constant[size];
 
         System.arraycopy(cs, 0, constants, 0, cs.length);
@@ -104,7 +129,6 @@ public ConstantPoolGen(final Constant[] cs) {
             index = cs.length;
         }
 
-
         for (int i = 1; i < index; i++) {
             final Constant c = constants[i];
             if (c instanceof ConstantString) {
@@ -112,56 +136,57 @@ public ConstantPoolGen(final Constant[] cs) {
                 final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()];
                 final String key = u8.getBytes();
                 if (!stringTable.containsKey(key)) {
-                    stringTable.put(key, new Index(i));
+                    stringTable.put(key, Integer.valueOf(i));
                 }
             } else if (c instanceof ConstantClass) {
                 final ConstantClass s = (ConstantClass) c;
                 final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()];
                 final String key = u8.getBytes();
                 if (!classTable.containsKey(key)) {
-                    classTable.put(key, new Index(i));
+                    classTable.put(key, Integer.valueOf(i));
                 }
             } else if (c instanceof ConstantNameAndType) {
                 final ConstantNameAndType n = (ConstantNameAndType) c;
-                final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()];
-                final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()];
+                final ConstantUtf8 u8NameIdx = (ConstantUtf8) constants[n.getNameIndex()];
+                final ConstantUtf8 u8SigIdx = (ConstantUtf8) constants[n.getSignatureIndex()];
 
-                sb.append(u8.getBytes());
+                sb.append(u8NameIdx.getBytes());
                 sb.append(NAT_DELIM);
-                sb.append(u8_2.getBytes());
+                sb.append(u8SigIdx.getBytes());
                 final String key = sb.toString();
                 sb.delete(0, sb.length());
 
                 if (!natTable.containsKey(key)) {
-                    natTable.put(key, new Index(i));
+                    natTable.put(key, Integer.valueOf(i));
                 }
             } else if (c instanceof ConstantUtf8) {
                 final ConstantUtf8 u = (ConstantUtf8) c;
                 final String key = u.getBytes();
                 if (!utf8Table.containsKey(key)) {
-                    utf8Table.put(key, new Index(i));
+                    utf8Table.put(key, Integer.valueOf(i));
                 }
             } else if (c instanceof ConstantCP) {
                 final ConstantCP m = (ConstantCP) c;
-                String class_name;
+                String className;
                 ConstantUtf8 u8;
 
                 if (c instanceof ConstantInvokeDynamic) {
-                    class_name = Integer.toString(((ConstantInvokeDynamic) m).getBootstrapMethodAttrIndex());
-                    // since name can't begin with digit, can  use
-                    // METHODREF_DELIM with out fear of duplicates.
+                    className = Integer.toString(((ConstantInvokeDynamic) m).getBootstrapMethodAttrIndex());
+                } else if (c instanceof ConstantDynamic) {
+                    className = Integer.toString(((ConstantDynamic) m).getBootstrapMethodAttrIndex());
                 } else {
-                final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
+                    final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
                     u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
-                    class_name = u8.getBytes().replace('/', '.');
+                    className = Utility.pathToPackage(u8.getBytes());
                 }
 
                 final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()];
                 u8 = (ConstantUtf8) constants[n.getNameIndex()];
-                final String method_name = u8.getBytes();
+                final String methodName = u8.getBytes();
                 u8 = (ConstantUtf8) constants[n.getSignatureIndex()];
                 final String signature = u8.getBytes();
 
+                // Since name cannot begin with digit, we can use METHODREF_DELIM without fear of duplicates
                 String delim = METHODREF_DELIM;
                 if (c instanceof ConstantInterfaceMethodref) {
                     delim = IMETHODREF_DELIM;
@@ -169,245 +194,205 @@ public ConstantPoolGen(final Constant[] cs) {
                     delim = FIELDREF_DELIM;
                 }
 
-                sb.append(class_name);
+                sb.append(className);
                 sb.append(delim);
-                sb.append(method_name);
+                sb.append(methodName);
                 sb.append(delim);
                 sb.append(signature);
                 final String key = sb.toString();
                 sb.delete(0, sb.length());
 
                 if (!cpTable.containsKey(key)) {
-                    cpTable.put(key, new Index(i));
+                    cpTable.put(key, Integer.valueOf(i));
                 }
-            } else if (c == null) { // entries may be null
-                // nothing to do
-            } else if (c instanceof ConstantInteger) {
-                // nothing to do
-            } else if (c instanceof ConstantLong) {
-                // nothing to do
-            } else if (c instanceof ConstantFloat) {
-                // nothing to do
-            } else if (c instanceof ConstantDouble) {
-                // nothing to do
-            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantMethodType) {
-                // TODO should this be handled somehow?
-            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantMethodHandle) {
-                // TODO should this be handled somehow?
-            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantModule) {
-                // TODO should this be handled somehow?
-            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantPackage) {
-                // TODO should this be handled somehow?
-            } else {
-                assert false : "Unexpected constant type: " + c.getClass().getName();
             }
+//            else if (c == null) { // entries may be null
+//                // nothing to do
+//            } else if (c instanceof ConstantInteger) {
+//                // nothing to do
+//            } else if (c instanceof ConstantLong) {
+//                // nothing to do
+//            } else if (c instanceof ConstantFloat) {
+//                // nothing to do
+//            } else if (c instanceof ConstantDouble) {
+//                // nothing to do
+//            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantMethodType) {
+//                // TODO should this be handled somehow?
+//            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantMethodHandle) {
+//                // TODO should this be handled somehow?
+//            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantModule) {
+//                // TODO should this be handled somehow?
+//            } else if (c instanceof com.sun.org.apache.bcel.internal.classfile.ConstantPackage) {
+//                // TODO should this be handled somehow?
+//            } else {
+//                // Not helpful, should throw an exception.
+//                assert false : "Unexpected constant type: " + c.getClass().getName();
+//            }
         }
     }
 
-
     /**
-     * Initialize with given constant pool.
+     * Constructs a new instance with the given constant pool.
+     *
+     * @param cp the constant pool.
      */
     public ConstantPoolGen(final ConstantPool cp) {
         this(cp.getConstantPool());
     }
 
-
     /**
-     * Create empty constant pool.
-     */
-    public ConstantPoolGen() {
-        size = DEFAULT_BUFFER_SIZE;
-        constants = new Constant[size];
-    }
-
-
-    /** Resize internal array of constants.
-     */
-    protected void adjustSize() {
-        // 3 extra spaces are needed as some entries may take 3 slots
-        if (index + 3 >= CONSTANT_POOL_SIZE) {
-            throw new RuntimeException("The number of constants " + (index + 3)
-                    + " is over the size limit of the constant pool: "
-                    + CONSTANT_POOL_SIZE);
-        }
-
-        if (index + 3 >= size) {
-            final Constant[] cs = constants;
-            size *= 2;
-            // the constant array shall not exceed the size of the constant pool
-            size = Math.min(size, CONSTANT_POOL_SIZE);
-            constants = new Constant[size];
-            System.arraycopy(cs, 0, constants, 0, index);
-        }
-    }
-
-    private final Map<String, Index> stringTable = new HashMap<>();
-
-
-    /**
-     * Look for ConstantString in ConstantPool containing String `str'.
+     * Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY instruction, e.g. to the
+     * ConstantPool.
      *
-     * @param str String to search for
-     * @return index on success, -1 otherwise
+     * @param type type of array class
+     * @return index of entry
      */
-    public int lookupString( final String str ) {
-        final Index index = stringTable.get(str);
-        return (index != null) ? index.index : -1;
+    public int addArrayClass(final ArrayType type) {
+        return addClass_(type.getSignature());
     }
 
-
     /**
-     * Add a new String constant to the ConstantPool, if it is not already in there.
+     * Add a new Class reference to the ConstantPool for a given type.
      *
-     * @param str String to add
+     * @param type Class to add
      * @return index of entry
      */
-    public int addString( final String str ) {
-        int ret;
-        if ((ret = lookupString(str)) != -1) {
-            return ret; // Already in CP
-        }
-        final int utf8 = addUtf8(str);
-        adjustSize();
-        final ConstantString s = new ConstantString(utf8);
-        ret = index;
-        constants[index++] = s;
-        if (!stringTable.containsKey(str)) {
-            stringTable.put(str, new Index(ret));
-        }
-        return ret;
+    public int addClass(final ObjectType type) {
+        return addClass(type.getClassName());
     }
 
-    private final Map<String, Index> classTable = new HashMap<>();
-
-
     /**
-     * Look for ConstantClass in ConstantPool named `str'.
+     * Add a new Class reference to the ConstantPool, if it is not already in there.
      *
-     * @param str String to search for
-     * @return index on success, -1 otherwise
+     * @param str Class to add
+     * @return index of entry
      */
-    public int lookupClass( final String str ) {
-        final Index index = classTable.get(str.replace('.', '/'));
-        return (index != null) ? index.index : -1;
+    public int addClass(final String str) {
+        return addClass_(Utility.packageToPath(str));
     }
 
-
-    private int addClass_( final String clazz ) {
-        int ret;
-        if ((ret = lookupClass(clazz)) != -1) {
-            return ret; // Already in CP
+    private int addClass_(final String clazz) {
+        final int cpRet;
+        if ((cpRet = lookupClass(clazz)) != -1) {
+            return cpRet; // Already in CP
         }
         adjustSize();
         final ConstantClass c = new ConstantClass(addUtf8(clazz));
-        ret = index;
+        final int ret = index;
         constants[index++] = c;
-        if (!classTable.containsKey(clazz)) {
-            classTable.put(clazz, new Index(ret));
-        }
-        return ret;
-    }
-
-
-    /**
-     * Add a new Class reference to the ConstantPool, if it is not already in there.
-     *
-     * @param str Class to add
-     * @return index of entry
-     */
-    public int addClass( final String str ) {
-        return addClass_(str.replace('.', '/'));
-    }
-
-
-    /**
-     * Add a new Class reference to the ConstantPool for a given type.
-     *
-     * @param type Class to add
-     * @return index of entry
-     */
-    public int addClass( final ObjectType type ) {
-        return addClass(type.getClassName());
+        return computeIfAbsent(classTable, clazz, ret);
     }
 
-
     /**
-     * Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY
-     * instruction, e.g. to the ConstantPool.
+     * Adds a constant from another ConstantPool and returns the new index.
      *
-     * @param type type of array class
+     * @param constant The constant to add.
+     * @param cpGen Source pool.
      * @return index of entry
      */
-    public int addArrayClass( final ArrayType type ) {
-        return addClass_(type.getSignature());
-    }
-
-
-    /**
-     * Look for ConstantInteger in ConstantPool.
-     *
-     * @param n integer number to look for
-     * @return index on success, -1 otherwise
-     */
-    public int lookupInteger( final int n ) {
-        for (int i = 1; i < index; i++) {
-            if (constants[i] instanceof ConstantInteger) {
-                final ConstantInteger c = (ConstantInteger) constants[i];
-                if (c.getBytes() == n) {
-                    return i;
-                }
+    public int addConstant(final Constant constant, final ConstantPoolGen cpGen) {
+        final Constant[] constants = cpGen.getConstantPool().getConstantPool();
+        switch (constant.getTag()) {
+        case Const.CONSTANT_String: {
+            final ConstantString s = (ConstantString) constant;
+            final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()];
+            return addString(u8.getBytes());
+        }
+        case Const.CONSTANT_Class: {
+            final ConstantClass s = (ConstantClass) constant;
+            final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()];
+            return addClass(u8.getBytes());
+        }
+        case Const.CONSTANT_NameAndType: {
+            final ConstantNameAndType n = (ConstantNameAndType) constant;
+            final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()];
+            final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()];
+            return addNameAndType(u8.getBytes(), u8_2.getBytes());
+        }
+        case Const.CONSTANT_Utf8:
+            return addUtf8(((ConstantUtf8) constant).getBytes());
+        case Const.CONSTANT_Double:
+            return addDouble(((ConstantDouble) constant).getBytes());
+        case Const.CONSTANT_Float:
+            return addFloat(((ConstantFloat) constant).getBytes());
+        case Const.CONSTANT_Long:
+            return addLong(((ConstantLong) constant).getBytes());
+        case Const.CONSTANT_Integer:
+            return addInteger(((ConstantInteger) constant).getBytes());
+        case Const.CONSTANT_InterfaceMethodref:
+        case Const.CONSTANT_Methodref:
+        case Const.CONSTANT_Fieldref: {
+            final ConstantCP m = (ConstantCP) constant;
+            final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
+            final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()];
+            ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
+            final String className = Utility.pathToPackage(u8.getBytes());
+            u8 = (ConstantUtf8) constants[n.getNameIndex()];
+            final String name = u8.getBytes();
+            u8 = (ConstantUtf8) constants[n.getSignatureIndex()];
+            final String signature = u8.getBytes();
+            switch (constant.getTag()) {
+            case Const.CONSTANT_InterfaceMethodref:
+                return addInterfaceMethodref(className, name, signature);
+            case Const.CONSTANT_Methodref:
+                return addMethodref(className, name, signature);
+            case Const.CONSTANT_Fieldref:
+                return addFieldref(className, name, signature);
+            default: // Never reached
+                throw new IllegalArgumentException("Unknown constant type " + constant);
             }
         }
-        return -1;
+        default: // Never reached
+            throw new IllegalArgumentException("Unknown constant type " + constant);
+        }
     }
 
-
     /**
-     * Add a new Integer constant to the ConstantPool, if it is not already in there.
+     * Add a new double constant to the ConstantPool, if it is not already in there.
      *
-     * @param n integer number to add
+     * @param n Double number to add
      * @return index of entry
      */
-    public int addInteger( final int n ) {
+    public int addDouble(final double n) {
         int ret;
-        if ((ret = lookupInteger(n)) != -1) {
+        if ((ret = lookupDouble(n)) != -1) {
             return ret; // Already in CP
         }
         adjustSize();
         ret = index;
-        constants[index++] = new ConstantInteger(n);
+        constants[index] = new ConstantDouble(n);
+        index += 2; // Wastes one entry according to spec
         return ret;
     }
 
-
     /**
-     * Look for ConstantFloat in ConstantPool.
+     * Add a new Fieldref constant to the ConstantPool, if it is not already in there.
      *
-     * @param n Float number to look for
-     * @return index on success, -1 otherwise
+     * @param className class name string to add
+     * @param fieldName field name string to add
+     * @param signature signature string to add
+     * @return index of entry
      */
-    public int lookupFloat( final float n ) {
-        final int bits = Float.floatToIntBits(n);
-        for (int i = 1; i < index; i++) {
-            if (constants[i] instanceof ConstantFloat) {
-                final ConstantFloat c = (ConstantFloat) constants[i];
-                if (Float.floatToIntBits(c.getBytes()) == bits) {
-                    return i;
-                }
-            }
+    public int addFieldref(final String className, final String fieldName, final String signature) {
+        final int cpRet;
+        if ((cpRet = lookupFieldref(className, fieldName, signature)) != -1) {
+            return cpRet; // Already in CP
         }
-        return -1;
+        adjustSize();
+        final int classIndex = addClass(className);
+        final int nameAndTypeIndex = addNameAndType(fieldName, signature);
+        final int ret = index;
+        constants[index++] = new ConstantFieldref(classIndex, nameAndTypeIndex);
+        return computeIfAbsent(cpTable, className + FIELDREF_DELIM + fieldName + FIELDREF_DELIM + signature, ret);
     }
 
-
     /**
      * Add a new Float constant to the ConstantPool, if it is not already in there.
      *
      * @param n Float number to add
      * @return index of entry
      */
-    public int addFloat( final float n ) {
+    public int addFloat(final float n) {
         int ret;
         if ((ret = lookupFloat(n)) != -1) {
             return ret; // Already in CP
@@ -418,68 +403,55 @@ public int addFloat( final float n ) {
         return ret;
     }
 
-    private final Map<String, Index> utf8Table = new HashMap<>();
-
-
-    /**
-     * Look for ConstantUtf8 in ConstantPool.
-     *
-     * @param n Utf8 string to look for
-     * @return index on success, -1 otherwise
-     */
-    public int lookupUtf8( final String n ) {
-        final Index index = utf8Table.get(n);
-        return (index != null) ? index.index : -1;
-    }
-
-
     /**
-     * Add a new Utf8 constant to the ConstantPool, if it is not already in there.
+     * Add a new Integer constant to the ConstantPool, if it is not already in there.
      *
-     * @param n Utf8 string to add
+     * @param n integer number to add
      * @return index of entry
      */
-    public int addUtf8( final String n ) {
+    public int addInteger(final int n) {
         int ret;
-        if ((ret = lookupUtf8(n)) != -1) {
+        if ((ret = lookupInteger(n)) != -1) {
             return ret; // Already in CP
         }
         adjustSize();
         ret = index;
-        constants[index++] = new ConstantUtf8(n);
-        if (!utf8Table.containsKey(n)) {
-            utf8Table.put(n, new Index(ret));
-        }
+        constants[index++] = new ConstantInteger(n);
         return ret;
     }
 
+    public int addInterfaceMethodref(final MethodGen method) {
+        return addInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature());
+    }
 
     /**
-     * Look for ConstantLong in ConstantPool.
+     * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already in there.
      *
-     * @param n Long number to look for
-     * @return index on success, -1 otherwise
+     * @param className class name string to add
+     * @param methodName method name string to add
+     * @param signature signature string to add
+     * @return index of entry
      */
-    public int lookupLong( final long n ) {
-        for (int i = 1; i < index; i++) {
-            if (constants[i] instanceof ConstantLong) {
-                final ConstantLong c = (ConstantLong) constants[i];
-                if (c.getBytes() == n) {
-                    return i;
-                }
-            }
+    public int addInterfaceMethodref(final String className, final String methodName, final String signature) {
+        final int cpRet;
+        if ((cpRet = lookupInterfaceMethodref(className, methodName, signature)) != -1) {
+            return cpRet; // Already in CP
         }
-        return -1;
+        adjustSize();
+        final int classIndex = addClass(className);
+        final int nameAndTypeIndex = addNameAndType(methodName, signature);
+        final int ret = index;
+        constants[index++] = new ConstantInterfaceMethodref(classIndex, nameAndTypeIndex);
+        return computeIfAbsent(cpTable, className + IMETHODREF_DELIM + methodName + IMETHODREF_DELIM + signature, ret);
     }
 
-
     /**
      * Add a new long constant to the ConstantPool, if it is not already in there.
      *
      * @param n Long number to add
      * @return index of entry
      */
-    public int addLong( final long n ) {
+    public int addLong(final long n) {
         int ret;
         if ((ret = lookupLong(n)) != -1) {
             return ret; // Already in CP
@@ -490,290 +462,317 @@ public int addLong( final long n ) {
         index += 2; // Wastes one entry according to spec
         return ret;
     }
-
+    public int addMethodref(final MethodGen method) {
+        return addMethodref(method.getClassName(), method.getName(), method.getSignature());
+    }
 
     /**
-     * Look for ConstantDouble in ConstantPool.
+     * Add a new Methodref constant to the ConstantPool, if it is not already in there.
      *
-     * @param n Double number to look for
-     * @return index on success, -1 otherwise
+     * @param className class name string to add
+     * @param methodName method name string to add
+     * @param signature method signature string to add
+     * @return index of entry
      */
-    public int lookupDouble( final double n ) {
-        final long bits = Double.doubleToLongBits(n);
-        for (int i = 1; i < index; i++) {
-            if (constants[i] instanceof ConstantDouble) {
-                final ConstantDouble c = (ConstantDouble) constants[i];
-                if (Double.doubleToLongBits(c.getBytes()) == bits) {
-                    return i;
-                }
-            }
+    public int addMethodref(final String className, final String methodName, final String signature) {
+        final int cpRet;
+        if ((cpRet = lookupMethodref(className, methodName, signature)) != -1) {
+            return cpRet; // Already in CP
         }
-        return -1;
+        adjustSize();
+        final int nameAndTypeIndex = addNameAndType(methodName, signature);
+        final int classIndex = addClass(className);
+        final int ret = index;
+        constants[index++] = new ConstantMethodref(classIndex, nameAndTypeIndex);
+        return computeIfAbsent(cpTable, className + METHODREF_DELIM + methodName + METHODREF_DELIM + signature, ret);
     }
 
-
     /**
-     * Add a new double constant to the ConstantPool, if it is not already in there.
+     * Add a new NameAndType constant to the ConstantPool if it is not already in there.
      *
-     * @param n Double number to add
+     * @param name Name string to add
+     * @param signature signature string to add
      * @return index of entry
      */
-    public int addDouble( final double n ) {
+    public int addNameAndType(final String name, final String signature) {
         int ret;
-        if ((ret = lookupDouble(n)) != -1) {
+        if ((ret = lookupNameAndType(name, signature)) != -1) {
             return ret; // Already in CP
         }
         adjustSize();
+        final int nameIndex = addUtf8(name);
+        final int signatureIndex = addUtf8(signature);
         ret = index;
-        constants[index] = new ConstantDouble(n);
-        index += 2; // Wastes one entry according to spec
-        return ret;
+        constants[index++] = new ConstantNameAndType(nameIndex, signatureIndex);
+        return computeIfAbsent(natTable, name + NAT_DELIM + signature, ret);
     }
 
-    private final Map<String, Index> natTable = new HashMap<>();
-
-
     /**
-     * Look for ConstantNameAndType in ConstantPool.
+     * Add a new String constant to the ConstantPool, if it is not already in there.
      *
-     * @param name of variable/method
-     * @param signature of variable/method
-     * @return index on success, -1 otherwise
+     * @param str String to add
+     * @return index of entry
      */
-    public int lookupNameAndType( final String name, final String signature ) {
-        final Index _index = natTable.get(name + NAT_DELIM + signature);
-        return (_index != null) ? _index.index : -1;
+    public int addString(final String str) {
+        int ret;
+        if ((ret = lookupString(str)) != -1) {
+            return ret; // Already in CP
+        }
+        final int utf8 = addUtf8(str);
+        adjustSize();
+        final ConstantString s = new ConstantString(utf8);
+        ret = index;
+        constants[index++] = s;
+        return computeIfAbsent(stringTable, str, ret);
     }
 
-
     /**
-     * Add a new NameAndType constant to the ConstantPool if it is not already
-     * in there.
+     * Add a new Utf8 constant to the ConstantPool, if it is not already in there.
      *
-     * @param name Name string to add
-     * @param signature signature string to add
+     * @param n Utf8 string to add
      * @return index of entry
      */
-    public int addNameAndType( final String name, final String signature ) {
+    public int addUtf8(final String n) {
         int ret;
-        int name_index;
-        int signature_index;
-        if ((ret = lookupNameAndType(name, signature)) != -1) {
+        if ((ret = lookupUtf8(n)) != -1) {
             return ret; // Already in CP
         }
         adjustSize();
-        name_index = addUtf8(name);
-        signature_index = addUtf8(signature);
         ret = index;
-        constants[index++] = new ConstantNameAndType(name_index, signature_index);
-        final String key = name + NAT_DELIM + signature;
-        if (!natTable.containsKey(key)) {
-            natTable.put(key, new Index(ret));
+        constants[index++] = new ConstantUtf8(n);
+        return computeIfAbsent(utf8Table, n, ret);
+    }
+
+    /**
+     * Resize internal array of constants.
+     */
+    protected void adjustSize() {
+        // 3 extra spaces are needed as some entries may take 3 slots
+        if (index + 3 >= Const.MAX_CP_ENTRIES) {
+            throw new IllegalStateException("The number of constants " + (index + 3)
+                    + " is over the size limit of the constant pool: "
+                    + Const.MAX_CP_ENTRIES);
+        }
+
+        if (index + 3 >= size) {
+            final Constant[] cs = constants;
+            size *= 2;
+            // the constant array shall not exceed the size of the constant pool
+            size = Math.min(size, Const.MAX_CP_ENTRIES);
+            constants = new Constant[size];
+            System.arraycopy(cs, 0, constants, 0, index);
         }
-        return ret;
     }
 
-    private final Map<String, Index> cpTable = new HashMap<>();
+    private int computeIfAbsent(final Map<String, Integer> map, final String key, final int value) {
+        return map.computeIfAbsent(key, k -> Integer.valueOf(value));
+    }
 
+    /**
+     * @param i index in constant pool
+     * @return constant pool entry at index i
+     */
+    public Constant getConstant(final int i) {
+        return constants[i];
+    }
 
     /**
-     * Look for ConstantMethodref in ConstantPool.
-     *
-     * @param class_name Where to find method
-     * @param method_name Guess what
-     * @param signature return and argument types
-     * @return index on success, -1 otherwise
+     * @return intermediate constant pool
      */
-    public int lookupMethodref( final String class_name, final String method_name, final String signature ) {
-        final Index index = cpTable.get(class_name + METHODREF_DELIM + method_name
-                + METHODREF_DELIM + signature);
-        return (index != null) ? index.index : -1;
+    public ConstantPool getConstantPool() {
+        return new ConstantPool(constants);
     }
 
+    /**
+     * @return constant pool with proper length
+     */
+    public ConstantPool getFinalConstantPool() {
+        return new ConstantPool(Arrays.copyOf(constants, index));
+    }
 
-    public int lookupMethodref( final MethodGen method ) {
-        return lookupMethodref(method.getClassName(), method.getName(), method.getSignature());
+    private int getIndex(final Map<String, Integer> map, final String key) {
+        return toIndex(map.get(key));
     }
 
+    /**
+     * @return current size of constant pool
+     */
+    public int getSize() {
+        return index;
+    }
 
     /**
-     * Add a new Methodref constant to the ConstantPool, if it is not already
-     * in there.
+     * Look for ConstantClass in ConstantPool named 'str'.
      *
-     * @param class_name class name string to add
-     * @param method_name method name string to add
-     * @param signature method signature string to add
-     * @return index of entry
+     * @param str String to search for
+     * @return index on success, -1 otherwise
      */
-    public int addMethodref( final String class_name, final String method_name, final String signature ) {
-        int ret;
-        int class_index;
-        int name_and_type_index;
-        if ((ret = lookupMethodref(class_name, method_name, signature)) != -1) {
-            return ret; // Already in CP
-        }
-        adjustSize();
-        name_and_type_index = addNameAndType(method_name, signature);
-        class_index = addClass(class_name);
-        ret = index;
-        constants[index++] = new ConstantMethodref(class_index, name_and_type_index);
-        final String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature;
-        if (!cpTable.containsKey(key)) {
-            cpTable.put(key, new Index(ret));
-        }
-        return ret;
+    public int lookupClass(final String str) {
+        return getIndex(classTable, Utility.packageToPath(str));
     }
 
-
-    public int addMethodref( final MethodGen method ) {
-        return addMethodref(method.getClassName(), method.getName(), method.getSignature());
+    /**
+     * Look for ConstantDouble in ConstantPool.
+     *
+     * @param n Double number to look for
+     * @return index on success, -1 otherwise
+     */
+    public int lookupDouble(final double n) {
+        final long bits = Double.doubleToLongBits(n);
+        for (int i = 1; i < index; i++) {
+            if (constants[i] instanceof ConstantDouble) {
+                final ConstantDouble c = (ConstantDouble) constants[i];
+                if (Double.doubleToLongBits(c.getBytes()) == bits) {
+                    return i;
+                }
+            }
+        }
+        return -1;
     }
 
-
     /**
-     * Look for ConstantInterfaceMethodref in ConstantPool.
+     * Look for ConstantFieldref in ConstantPool.
      *
-     * @param class_name Where to find method
-     * @param method_name Guess what
+     * @param className Where to find method
+     * @param fieldName Guess what
      * @param signature return and argument types
      * @return index on success, -1 otherwise
      */
-    public int lookupInterfaceMethodref( final String class_name, final String method_name, final String signature ) {
-        final Index index = cpTable.get(class_name + IMETHODREF_DELIM + method_name
-                + IMETHODREF_DELIM + signature);
-        return (index != null) ? index.index : -1;
+    public int lookupFieldref(final String className, final String fieldName, final String signature) {
+        return getIndex(cpTable, className + FIELDREF_DELIM + fieldName + FIELDREF_DELIM + signature);
     }
 
-
-    public int lookupInterfaceMethodref( final MethodGen method ) {
-        return lookupInterfaceMethodref(method.getClassName(), method.getName(), method
-                .getSignature());
+    /**
+     * Look for ConstantFloat in ConstantPool.
+     *
+     * @param n Float number to look for
+     * @return index on success, -1 otherwise
+     */
+    public int lookupFloat(final float n) {
+        final int bits = Float.floatToIntBits(n);
+        for (int i = 1; i < index; i++) {
+            if (constants[i] instanceof ConstantFloat) {
+                final ConstantFloat c = (ConstantFloat) constants[i];
+                if (Float.floatToIntBits(c.getBytes()) == bits) {
+                    return i;
+                }
+            }
+        }
+        return -1;
     }
 
-
     /**
-     * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already
-     * in there.
+     * Look for ConstantInteger in ConstantPool.
      *
-     * @param class_name class name string to add
-     * @param method_name method name string to add
-     * @param signature signature string to add
-     * @return index of entry
+     * @param n integer number to look for
+     * @return index on success, -1 otherwise
      */
-    public int addInterfaceMethodref( final String class_name, final String method_name, final String signature ) {
-        int ret;
-        int class_index;
-        int name_and_type_index;
-        if ((ret = lookupInterfaceMethodref(class_name, method_name, signature)) != -1) {
-            return ret; // Already in CP
-        }
-        adjustSize();
-        class_index = addClass(class_name);
-        name_and_type_index = addNameAndType(method_name, signature);
-        ret = index;
-        constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index);
-        final String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature;
-        if (!cpTable.containsKey(key)) {
-            cpTable.put(key, new Index(ret));
+    public int lookupInteger(final int n) {
+        for (int i = 1; i < index; i++) {
+            if (constants[i] instanceof ConstantInteger) {
+                final ConstantInteger c = (ConstantInteger) constants[i];
+                if (c.getBytes() == n) {
+                    return i;
+                }
+            }
         }
-        return ret;
+        return -1;
     }
 
-
-    public int addInterfaceMethodref( final MethodGen method ) {
-        return addInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature());
+    public int lookupInterfaceMethodref(final MethodGen method) {
+        return lookupInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature());
     }
 
-
     /**
-     * Look for ConstantFieldref in ConstantPool.
+     * Look for ConstantInterfaceMethodref in ConstantPool.
      *
-     * @param class_name Where to find method
-     * @param field_name Guess what
+     * @param className Where to find method
+     * @param methodName Guess what
      * @param signature return and argument types
      * @return index on success, -1 otherwise
      */
-    public int lookupFieldref( final String class_name, final String field_name, final String signature ) {
-        final Index index = cpTable.get(class_name + FIELDREF_DELIM + field_name
-                + FIELDREF_DELIM + signature);
-        return (index != null) ? index.index : -1;
+    public int lookupInterfaceMethodref(final String className, final String methodName, final String signature) {
+        return getIndex(cpTable, className + IMETHODREF_DELIM + methodName + IMETHODREF_DELIM + signature);
     }
 
-
     /**
-     * Add a new Fieldref constant to the ConstantPool, if it is not already
-     * in there.
+     * Look for ConstantLong in ConstantPool.
      *
-     * @param class_name class name string to add
-     * @param field_name field name string to add
-     * @param signature signature string to add
-     * @return index of entry
+     * @param n Long number to look for
+     * @return index on success, -1 otherwise
      */
-    public int addFieldref( final String class_name, final String field_name, final String signature ) {
-        int ret;
-        int class_index;
-        int name_and_type_index;
-        if ((ret = lookupFieldref(class_name, field_name, signature)) != -1) {
-            return ret; // Already in CP
-        }
-        adjustSize();
-        class_index = addClass(class_name);
-        name_and_type_index = addNameAndType(field_name, signature);
-        ret = index;
-        constants[index++] = new ConstantFieldref(class_index, name_and_type_index);
-        final String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature;
-        if (!cpTable.containsKey(key)) {
-            cpTable.put(key, new Index(ret));
+    public int lookupLong(final long n) {
+        for (int i = 1; i < index; i++) {
+            if (constants[i] instanceof ConstantLong) {
+                final ConstantLong c = (ConstantLong) constants[i];
+                if (c.getBytes() == n) {
+                    return i;
+                }
+            }
         }
-        return ret;
+        return -1;
     }
 
+    public int lookupMethodref(final MethodGen method) {
+        return lookupMethodref(method.getClassName(), method.getName(), method.getSignature());
+    }
 
     /**
-     * @param i index in constant pool
-     * @return constant pool entry at index i
+     * Look for ConstantMethodref in ConstantPool.
+     *
+     * @param className Where to find method
+     * @param methodName Guess what
+     * @param signature return and argument types
+     * @return index on success, -1 otherwise
      */
-    public Constant getConstant( final int i ) {
-        return constants[i];
+    public int lookupMethodref(final String className, final String methodName, final String signature) {
+        return getIndex(cpTable, className + METHODREF_DELIM + methodName + METHODREF_DELIM + signature);
     }
 
-
     /**
-     * Use with care!
+     * Look for ConstantNameAndType in ConstantPool.
      *
-     * @param i index in constant pool
-     * @param c new constant pool entry at index i
+     * @param name of variable/method
+     * @param signature of variable/method
+     * @return index on success, -1 otherwise
      */
-    public void setConstant( final int i, final Constant c ) {
-        constants[i] = c;
+    public int lookupNameAndType(final String name, final String signature) {
+        return getIndex(natTable, name + NAT_DELIM + signature);
     }
 
-
     /**
-     * @return intermediate constant pool
+     * Look for ConstantString in ConstantPool containing String 'str'.
+     *
+     * @param str String to search for
+     * @return index on success, -1 otherwise
      */
-    public ConstantPool getConstantPool() {
-        return new ConstantPool(constants);
+    public int lookupString(final String str) {
+        return getIndex(stringTable, str);
     }
 
-
     /**
-     * @return current size of constant pool
+     * Look for ConstantUtf8 in ConstantPool.
+     *
+     * @param n Utf8 string to look for
+     * @return index on success, -1 otherwise
      */
-    public int getSize() {
-        return index;
+    public int lookupUtf8(final String n) {
+        return getIndex(utf8Table, n);
     }
 
-
     /**
-     * @return constant pool with proper length
+     * Use with care!
+     *
+     * @param i index in constant pool
+     * @param c new constant pool entry at index i
      */
-    public ConstantPool getFinalConstantPool() {
-        final Constant[] cs = new Constant[index];
-        System.arraycopy(constants, 0, cs, 0, index);
-        return new ConstantPool(cs);
+    public void setConstant(final int i, final Constant c) {
+        constants[i] = c;
     }
 
+    private int toIndex(final Integer index) {
+        return index != null ? index.intValue() : -1;
+    }
 
     /**
      * @return String representation.
@@ -786,64 +785,4 @@ public String toString() {
         }
         return buf.toString();
     }
-
-
-    /** Import constant from another ConstantPool and return new index.
-     */
-    public int addConstant( final Constant c, final ConstantPoolGen cp ) {
-        final Constant[] constants = cp.getConstantPool().getConstantPool();
-        switch (c.getTag()) {
-            case Const.CONSTANT_String: {
-                final ConstantString s = (ConstantString) c;
-                final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()];
-                return addString(u8.getBytes());
-            }
-            case Const.CONSTANT_Class: {
-                final ConstantClass s = (ConstantClass) c;
-                final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()];
-                return addClass(u8.getBytes());
-            }
-            case Const.CONSTANT_NameAndType: {
-                final ConstantNameAndType n = (ConstantNameAndType) c;
-                final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()];
-                final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()];
-                return addNameAndType(u8.getBytes(), u8_2.getBytes());
-            }
-            case Const.CONSTANT_Utf8:
-                return addUtf8(((ConstantUtf8) c).getBytes());
-            case Const.CONSTANT_Double:
-                return addDouble(((ConstantDouble) c).getBytes());
-            case Const.CONSTANT_Float:
-                return addFloat(((ConstantFloat) c).getBytes());
-            case Const.CONSTANT_Long:
-                return addLong(((ConstantLong) c).getBytes());
-            case Const.CONSTANT_Integer:
-                return addInteger(((ConstantInteger) c).getBytes());
-            case Const.CONSTANT_InterfaceMethodref:
-            case Const.CONSTANT_Methodref:
-            case Const.CONSTANT_Fieldref: {
-                final ConstantCP m = (ConstantCP) c;
-                final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
-                final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()];
-                ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
-                final String class_name = u8.getBytes().replace('/', '.');
-                u8 = (ConstantUtf8) constants[n.getNameIndex()];
-                final String name = u8.getBytes();
-                u8 = (ConstantUtf8) constants[n.getSignatureIndex()];
-                final String signature = u8.getBytes();
-                switch (c.getTag()) {
-                    case Const.CONSTANT_InterfaceMethodref:
-                        return addInterfaceMethodref(class_name, name, signature);
-                    case Const.CONSTANT_Methodref:
-                        return addMethodref(class_name, name, signature);
-                    case Const.CONSTANT_Fieldref:
-                        return addFieldref(class_name, name, signature);
-                    default: // Never reached
-                        throw new IllegalArgumentException("Unknown constant type " + c);
-                }
-            }
-            default: // Never reached
-                throw new IllegalArgumentException("Unknown constant type " + c);
-        }
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java
index 3d752246a59..69114bf4628 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPushInstruction.java
@@ -22,10 +22,9 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denotes a push instruction that produces a literal on the stack
- * such as  SIPUSH, BIPUSH, ICONST, etc.
+ * Denotes a push instruction that produces a literal on the stack such as SIPUSH, BIPUSH, ICONST, etc.
+ *
  *
-
  * @see ICONST
  * @see SIPUSH
  */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java
index 20750fefb54..7937bbe46bc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConversionInstruction.java
@@ -25,19 +25,15 @@
 
 /**
  * Super class for the x2y family of instructions.
- *
  */
-public abstract class ConversionInstruction extends Instruction implements TypedInstruction,
-        StackProducer, StackConsumer {
+public abstract class ConversionInstruction extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ConversionInstruction() {
     }
 
-
     /**
      * @param opcode opcode of instruction
      */
@@ -45,37 +41,37 @@ protected ConversionInstruction(final short opcode) {
         super(opcode, (short) 1);
     }
 
-
-    /** @return type associated with the instruction
+    /**
+     * @return type associated with the instruction
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        final short _opcode = super.getOpcode();
-        switch (_opcode) {
-            case Const.D2I:
-            case Const.F2I:
-            case Const.L2I:
-                return Type.INT;
-            case Const.D2F:
-            case Const.I2F:
-            case Const.L2F:
-                return Type.FLOAT;
-            case Const.D2L:
-            case Const.F2L:
-            case Const.I2L:
-                return Type.LONG;
-            case Const.F2D:
-            case Const.I2D:
-            case Const.L2D:
-                return Type.DOUBLE;
-            case Const.I2B:
-                return Type.BYTE;
-            case Const.I2C:
-                return Type.CHAR;
-            case Const.I2S:
-                return Type.SHORT;
-            default: // Never reached
-                throw new ClassGenException("Unknown type " + _opcode);
+    public Type getType(final ConstantPoolGen cp) {
+        final short opcode = super.getOpcode();
+        switch (opcode) {
+        case Const.D2I:
+        case Const.F2I:
+        case Const.L2I:
+            return Type.INT;
+        case Const.D2F:
+        case Const.I2F:
+        case Const.L2F:
+            return Type.FLOAT;
+        case Const.D2L:
+        case Const.F2L:
+        case Const.I2L:
+            return Type.LONG;
+        case Const.F2D:
+        case Const.I2D:
+        case Const.L2D:
+            return Type.DOUBLE;
+        case Const.I2B:
+            return Type.BYTE;
+        case Const.I2C:
+            return Type.CHAR;
+        case Const.I2S:
+            return Type.SHORT;
+        default: // Never reached
+            throw new ClassGenException("Unknown type " + opcode);
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2F.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2F.java
index e857a41f5ee..45ee7158c3c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2F.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2F.java
@@ -23,28 +23,28 @@
 
 /**
  * D2F - Convert double to float
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result
+ * </PRE>
  */
 public class D2F extends ConversionInstruction {
 
-    /** Convert double to float
+    /**
+     * Convert double to float
      */
     public D2F() {
         super(com.sun.org.apache.bcel.internal.Const.D2F);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2I.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2I.java
index 97519bb5f8a..343076d7159 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2I.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2I.java
@@ -23,28 +23,28 @@
 
 /**
  * D2I - Convert double to int
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result
+ * </PRE>
  */
 public class D2I extends ConversionInstruction {
 
-    /** Convert double to int
+    /**
+     * Convert double to int
      */
     public D2I() {
         super(com.sun.org.apache.bcel.internal.Const.D2I);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2L.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2L.java
index 975eec6a39d..0a8b09c1d93 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2L.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/D2L.java
@@ -23,28 +23,28 @@
 
 /**
  * D2L - Convert double to long
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class D2L extends ConversionInstruction {
 
-    /** Convert double to long
+    /**
+     * Convert double to long
      */
     public D2L() {
         super(com.sun.org.apache.bcel.internal.Const.D2L);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DADD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DADD.java
index 8c787b60b66..55c6e05fe5a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DADD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DADD.java
@@ -23,29 +23,30 @@
 
 /**
  * DADD - Add doubles
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result1.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result1.word2
  */
 public class DADD extends ArithmeticInstruction {
 
-    /** Add doubles
+    /**
+     * Add doubles
      */
     public DADD() {
         super(com.sun.org.apache.bcel.internal.Const.DADD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DALOAD.java
index 3f901b335d3..e875b35171b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DALOAD.java
@@ -23,28 +23,28 @@
 
 /**
  * DALOAD - Load double from array
- * <PRE>Stack: ..., arrayref, index -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class DALOAD extends ArrayInstruction implements StackProducer {
 
-    /** Load double from array
+    /**
+     * Load double from array
      */
     public DALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.DALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DASTORE.java
index 53178fc3108..63a855900e1 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DASTORE.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * DASTORE -  Store into double array
- * <PRE>Stack: ..., arrayref, index, value.word1, value.word2 -&gt; ...</PRE>
+ * DASTORE - Store into double array
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value.word1, value.word2 -&gt; ...
+ * </PRE>
  */
 public class DASTORE extends ArrayInstruction implements StackConsumer {
 
-    /** Store double into array
+    /**
+     * Store double into array
      */
     public DASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.DASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPG.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPG.java
index 338c5906d6a..aa1353ef569 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPG.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPG.java
@@ -23,8 +23,10 @@
 
 /**
  * DCMPG - Compare doubles: value1 &gt; value2
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt; ..., result
+ * </PRE>
  */
 public class DCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
 
@@ -32,26 +34,25 @@ public DCMPG() {
         super(com.sun.org.apache.bcel.internal.Const.DCMPG, (short) 1);
     }
 
-    /** @return Type.DOUBLE
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.DOUBLE;
-    }
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
         v.visitDCMPG(this);
     }
+
+    /**
+     * @return Type.DOUBLE
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.DOUBLE;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPL.java
index e654310fe99..b43380bdbf8 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCMPL.java
@@ -23,8 +23,10 @@
 
 /**
  * DCMPL - Compare doubles: value1 &lt; value2
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt; ..., result
+ * </PRE>
  */
 public class DCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
 
@@ -32,26 +34,25 @@ public DCMPL() {
         super(com.sun.org.apache.bcel.internal.Const.DCMPL, (short) 1);
     }
 
-    /** @return Type.DOUBLE
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.DOUBLE;
-    }
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
         v.visitDCMPL(this);
     }
+
+    /**
+     * @return Type.DOUBLE
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.DOUBLE;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCONST.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCONST.java
index 39375bd5a89..313277185fe 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCONST.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCONST.java
@@ -23,23 +23,22 @@
 /**
  * DCONST - Push 0.0 or 1.0, other values cause an exception
  *
- * <PRE>Stack: ... -&gt; ..., </PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ...,
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class DCONST extends Instruction implements ConstantPushInstruction {
 
-    private double value;
-
+    private final double value;
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     DCONST() {
+        this(0);
     }
 
-
     public DCONST(final double f) {
         super(com.sun.org.apache.bcel.internal.Const.DCONST_0, (short) 1);
         if (f == 0.0) {
@@ -52,35 +51,31 @@ public DCONST(final double f) {
         value = f;
     }
 
-
-    @Override
-    public Number getValue() {
-        return value;
-    }
-
-
-    /** @return Type.DOUBLE
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.DOUBLE;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitPushInstruction(this);
         v.visitStackProducer(this);
         v.visitTypedInstruction(this);
         v.visitConstantPushInstruction(this);
         v.visitDCONST(this);
     }
+
+    /**
+     * @return Type.DOUBLE
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.DOUBLE;
+    }
+
+    @Override
+    public Number getValue() {
+        return Double.valueOf(value);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DDIV.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DDIV.java
index ae43ba11ace..29c008e7ccb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DDIV.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DDIV.java
@@ -22,30 +22,31 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * DDIV -  Divide doubles
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
+ * DDIV - Divide doubles
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class DDIV extends ArithmeticInstruction {
 
-    /** Divide doubles
+    /**
+     * Divide doubles
      */
     public DDIV() {
         super(com.sun.org.apache.bcel.internal.Const.DDIV);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DLOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DLOAD.java
index e13896bb009..9b61fd6697c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DLOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DLOAD.java
@@ -23,38 +23,37 @@
 
 /**
  * DLOAD - Load double from local variable
- * <PRE>Stack ... -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack ... -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class DLOAD extends LoadInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     DLOAD() {
         super(com.sun.org.apache.bcel.internal.Const.DLOAD, com.sun.org.apache.bcel.internal.Const.DLOAD_0);
     }
 
-
-    /** Load double from local variable
+    /**
+     * Load double from local variable
+     *
      * @param n index of local variable
      */
     public DLOAD(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.DLOAD, com.sun.org.apache.bcel.internal.Const.DLOAD_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitDLOAD(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DMUL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DMUL.java
index 98ee17fad47..6dc65ffa082 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DMUL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DMUL.java
@@ -23,29 +23,30 @@
 
 /**
  * DMUL - Multiply doubles
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class DMUL extends ArithmeticInstruction {
 
-    /** Multiply doubles
+    /**
+     * Multiply doubles
      */
     public DMUL() {
         super(com.sun.org.apache.bcel.internal.Const.DMUL);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DNEG.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DNEG.java
index 42043492537..8999f6fbaa3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DNEG.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DNEG.java
@@ -23,8 +23,10 @@
 
 /**
  * DNEG - Negate double
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class DNEG extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public DNEG() {
         super(com.sun.org.apache.bcel.internal.Const.DNEG);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DREM.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DREM.java
index 41ad3be2165..b478f6ca94a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DREM.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DREM.java
@@ -23,29 +23,30 @@
 
 /**
  * DREM - Remainder of doubles
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class DREM extends ArithmeticInstruction {
 
-    /** Remainder of doubles
+    /**
+     * Remainder of doubles
      */
     public DREM() {
         super(com.sun.org.apache.bcel.internal.Const.DREM);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DRETURN.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DRETURN.java
index 929ba33ef5f..749d92246dd 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DRETURN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DRETURN.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * DRETURN -  Return double from method
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; &lt;empty&gt;</PRE>
+ * DRETURN - Return double from method
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; &lt;empty&gt;
+ * </PRE>
  */
 public class DRETURN extends ReturnInstruction {
 
-    /** Return double from method
+    /**
+     * Return double from method
      */
     public DRETURN() {
         super(com.sun.org.apache.bcel.internal.Const.DRETURN);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSTORE.java
index aad12e19aeb..bd4e130c7e8 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSTORE.java
@@ -23,38 +23,37 @@
 
 /**
  * DSTORE - Store double into local variable
- * <pre>Stack: ..., value.word1, value.word2 -&gt; ... </PRE>
  *
+ * <pre>
+ * Stack: ..., value.word1, value.word2 -&gt; ...
+ * </PRE>
  */
 public class DSTORE extends StoreInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     DSTORE() {
         super(com.sun.org.apache.bcel.internal.Const.DSTORE, com.sun.org.apache.bcel.internal.Const.DSTORE_0);
     }
 
-
-    /** Store double into local variable
+    /**
+     * Store double into local variable
+     *
      * @param n index of local variable
      */
     public DSTORE(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.DSTORE, com.sun.org.apache.bcel.internal.Const.DSTORE_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitDSTORE(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSUB.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSUB.java
index efe66fb3b43..080a325d743 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSUB.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DSUB.java
@@ -23,29 +23,30 @@
 
 /**
  * DSUB - Substract doubles
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class DSUB extends ArithmeticInstruction {
 
-    /** Substract doubles
+    /**
+     * Substract doubles
      */
     public DSUB() {
         super(com.sun.org.apache.bcel.internal.Const.DSUB);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP.java
index 8f697a29d73..30cc6821c28 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP.java
@@ -23,8 +23,10 @@
 
 /**
  * DUP - Duplicate top operand stack word
- * <PRE>Stack: ..., word -&gt; ..., word, word</PRE>
  *
+ * <PRE>
+ * Stack: ..., word -&gt; ..., word, word
+ * </PRE>
  */
 public class DUP extends StackInstruction implements PushInstruction {
 
@@ -32,17 +34,14 @@ public DUP() {
         super(com.sun.org.apache.bcel.internal.Const.DUP);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitPushInstruction(this);
         v.visitStackInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2.java
index c3560979377..8b01a0606a0 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2.java
@@ -23,8 +23,10 @@
 
 /**
  * DUP2 - Duplicate two top operand stack words
- * <PRE>Stack: ..., word2, word1 -&gt; ..., word2, word1, word2, word1</PRE>
  *
+ * <PRE>
+ * Stack: ..., word2, word1 -&gt; ..., word2, word1, word2, word1
+ * </PRE>
  */
 public class DUP2 extends StackInstruction implements PushInstruction {
 
@@ -32,17 +34,14 @@ public DUP2() {
         super(com.sun.org.apache.bcel.internal.Const.DUP2);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitPushInstruction(this);
         v.visitStackInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java
index b2c90b428b1..69043ab87dc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X1.java
@@ -23,8 +23,10 @@
 
 /**
  * DUP2_X1 - Duplicate two top operand stack words and put three down
- * <PRE>Stack: ..., word3, word2, word1 -&gt; ..., word2, word1, word3, word2, word1</PRE>
  *
+ * <PRE>
+ * Stack: ..., word3, word2, word1 -&gt; ..., word2, word1, word3, word2, word1
+ * </PRE>
  */
 public class DUP2_X1 extends StackInstruction {
 
@@ -32,17 +34,14 @@ public DUP2_X1() {
         super(com.sun.org.apache.bcel.internal.Const.DUP2_X1);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackInstruction(this);
         v.visitDUP2_X1(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java
index 74ed06ef58b..e9b807ffc30 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP2_X2.java
@@ -23,8 +23,10 @@
 
 /**
  * DUP2_X2 - Duplicate two top operand stack words and put four down
- * <PRE>Stack: ..., word4, word3, word2, word1 -&gt; ..., word2, word1, word4, word3, word2, word1</PRE>
  *
+ * <PRE>
+ * Stack: ..., word4, word3, word2, word1 -&gt; ..., word2, word1, word4, word3, word2, word1
+ * </PRE>
  */
 public class DUP2_X2 extends StackInstruction {
 
@@ -32,17 +34,14 @@ public DUP2_X2() {
         super(com.sun.org.apache.bcel.internal.Const.DUP2_X2);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackInstruction(this);
         v.visitDUP2_X2(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X1.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X1.java
index 81b1e01f0db..ce2316baa88 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X1.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X1.java
@@ -23,8 +23,10 @@
 
 /**
  * DUP_X1 - Duplicate top operand stack word and put two down
- * <PRE>Stack: ..., word2, word1 -&gt; ..., word1, word2, word1</PRE>
  *
+ * <PRE>
+ * Stack: ..., word2, word1 -&gt; ..., word1, word2, word1
+ * </PRE>
  */
 public class DUP_X1 extends StackInstruction {
 
@@ -32,17 +34,14 @@ public DUP_X1() {
         super(com.sun.org.apache.bcel.internal.Const.DUP_X1);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackInstruction(this);
         v.visitDUP_X1(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X2.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X2.java
index 344f0068e2f..735437e1f80 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X2.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DUP_X2.java
@@ -23,8 +23,10 @@
 
 /**
  * DUP_X2 - Duplicate top operand stack word and put three down
- * <PRE>Stack: ..., word3, word2, word1 -&gt; ..., word1, word3, word2, word1</PRE>
  *
+ * <PRE>
+ * Stack: ..., word3, word2, word1 -&gt; ..., word1, word3, word2, word1
+ * </PRE>
  */
 public class DUP_X2 extends StackInstruction {
 
@@ -32,17 +34,14 @@ public DUP_X2() {
         super(com.sun.org.apache.bcel.internal.Const.DUP_X2);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackInstruction(this);
         v.visitDUP_X2(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java
index cebc7c45bd2..11b6b014a05 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValueGen.java
@@ -36,31 +36,7 @@
  * @since 6.0
  * @LastModified: May 2021
  */
-public abstract class ElementValueGen
-{
-    private final int type;
-    private final ConstantPoolGen cpGen;
-
-    protected ElementValueGen(final int type, final ConstantPoolGen cpGen)
-    {
-        this.type = type;
-        this.cpGen = cpGen;
-    }
-
-    /**
-     * Subtypes return an immutable variant of the ElementValueGen
-     */
-    public abstract ElementValue getElementValue();
-
-    public int getElementValueType()
-    {
-        return type;
-    }
-
-    public abstract String stringifyValue();
-
-    public abstract void dump(DataOutputStream dos) throws IOException;
-
+public abstract class ElementValueGen {
     public static final int STRING = 's';
 
     public static final int ENUM_CONSTANT = 'e';
@@ -87,57 +63,69 @@ public int getElementValueType()
 
     public static final int PRIMITIVE_BOOLEAN = 'Z';
 
-    public static ElementValueGen readElementValue(final DataInput dis,
-            final ConstantPoolGen cpGen) throws IOException
-    {
+    /**
+     * Creates an (modifiable) ElementValueGen copy of an (immutable) ElementValue - constant pool is assumed correct.
+     */
+    public static ElementValueGen copy(final ElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
+        switch (value.getElementValueType()) {
+        case 'B': // byte
+        case 'C': // char
+        case 'D': // double
+        case 'F': // float
+        case 'I': // int
+        case 'J': // long
+        case 'S': // short
+        case 'Z': // boolean
+        case 's': // String
+            return new SimpleElementValueGen((SimpleElementValue) value, cpool, copyPoolEntries);
+        case 'e': // Enum constant
+            return new EnumElementValueGen((EnumElementValue) value, cpool, copyPoolEntries);
+        case '@': // Annotation
+            return new AnnotationElementValueGen((AnnotationElementValue) value, cpool, copyPoolEntries);
+        case '[': // Array
+            return new ArrayElementValueGen((ArrayElementValue) value, cpool, copyPoolEntries);
+        case 'c': // Class
+            return new ClassElementValueGen((ClassElementValue) value, cpool, copyPoolEntries);
+        default:
+            throw new UnsupportedOperationException("Not implemented yet! (" + value.getElementValueType() + ")");
+        }
+    }
+
+    public static ElementValueGen readElementValue(final DataInput dis, final ConstantPoolGen cpGen) throws IOException {
         final int type = dis.readUnsignedByte();
-        switch (type)
-        {
+        switch (type) {
         case 'B': // byte
-            return new SimpleElementValueGen(PRIMITIVE_BYTE, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_BYTE, dis.readUnsignedShort(), cpGen);
         case 'C': // char
-            return new SimpleElementValueGen(PRIMITIVE_CHAR, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_CHAR, dis.readUnsignedShort(), cpGen);
         case 'D': // double
-            return new SimpleElementValueGen(PRIMITIVE_DOUBLE, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_DOUBLE, dis.readUnsignedShort(), cpGen);
         case 'F': // float
-            return new SimpleElementValueGen(PRIMITIVE_FLOAT, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_FLOAT, dis.readUnsignedShort(), cpGen);
         case 'I': // int
-            return new SimpleElementValueGen(PRIMITIVE_INT, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_INT, dis.readUnsignedShort(), cpGen);
         case 'J': // long
-            return new SimpleElementValueGen(PRIMITIVE_LONG, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_LONG, dis.readUnsignedShort(), cpGen);
         case 'S': // short
-            return new SimpleElementValueGen(PRIMITIVE_SHORT, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_SHORT, dis.readUnsignedShort(), cpGen);
         case 'Z': // boolean
-            return new SimpleElementValueGen(PRIMITIVE_BOOLEAN, dis
-                    .readUnsignedShort(), cpGen);
+            return new SimpleElementValueGen(PRIMITIVE_BOOLEAN, dis.readUnsignedShort(), cpGen);
         case 's': // String
-            return new SimpleElementValueGen(STRING, dis.readUnsignedShort(),
-                    cpGen);
+            return new SimpleElementValueGen(STRING, dis.readUnsignedShort(), cpGen);
         case 'e': // Enum constant
-            return new EnumElementValueGen(dis.readUnsignedShort(), dis
-                    .readUnsignedShort(), cpGen);
+            return new EnumElementValueGen(dis.readUnsignedShort(), dis.readUnsignedShort(), cpGen);
         case 'c': // Class
             return new ClassElementValueGen(dis.readUnsignedShort(), cpGen);
         case '@': // Annotation
             // TODO: isRuntimeVisible ??????????
             // FIXME
-            return new AnnotationElementValueGen(ANNOTATION,
-                    new AnnotationEntryGen(AnnotationEntry.read(dis, cpGen
-                            .getConstantPool(), true), cpGen, false), cpGen);
+            return new AnnotationElementValueGen(ANNOTATION, new AnnotationEntryGen(AnnotationEntry.read(dis, cpGen.getConstantPool(), true), cpGen, false),
+                cpGen);
         case '[': // Array
             final int numArrayVals = dis.readUnsignedShort();
             final ElementValue[] evalues = new ElementValue[numArrayVals];
-            for (int j = 0; j < numArrayVals; j++)
-            {
-                evalues[j] = ElementValue.readElementValue(dis, cpGen
-                        .getConstantPool());
+            for (int j = 0; j < numArrayVals; j++) {
+                evalues[j] = ElementValue.readElementValue(dis, cpGen.getConstantPool());
             }
             return new ArrayElementValueGen(ARRAY, evalues, cpGen);
         default:
@@ -145,45 +133,37 @@ public static ElementValueGen readElementValue(final DataInput dis,
         }
     }
 
-    protected ConstantPoolGen getConstantPool()
-    {
+    /**
+     * @deprecated (since 6.0) will be made private and final; do not access directly, use getter
+     */
+    @Deprecated
+    protected int type;
+
+    /**
+     * @deprecated (since 6.0) will be made private and final; do not access directly, use getter
+     */
+    @Deprecated
+    protected ConstantPoolGen cpGen;
+
+    protected ElementValueGen(final int type, final ConstantPoolGen cpGen) {
+        this.type = type;
+        this.cpGen = cpGen;
+    }
+
+    public abstract void dump(DataOutputStream dos) throws IOException;
+
+    protected ConstantPoolGen getConstantPool() {
         return cpGen;
     }
 
     /**
-     * Creates an (modifiable) ElementValueGen copy of an (immutable)
-     * ElementValue - constant pool is assumed correct.
+     * Subtypes return an immutable variant of the ElementValueGen
      */
-    public static ElementValueGen copy(final ElementValue value,
-            final ConstantPoolGen cpool, final boolean copyPoolEntries)
-    {
-        switch (value.getElementValueType())
-        {
-        case 'B': // byte
-        case 'C': // char
-        case 'D': // double
-        case 'F': // float
-        case 'I': // int
-        case 'J': // long
-        case 'S': // short
-        case 'Z': // boolean
-        case 's': // String
-            return new SimpleElementValueGen((SimpleElementValue) value, cpool,
-                    copyPoolEntries);
-        case 'e': // Enum constant
-            return new EnumElementValueGen((EnumElementValue) value, cpool,
-                    copyPoolEntries);
-        case '@': // Annotation
-            return new AnnotationElementValueGen(
-                    (AnnotationElementValue) value, cpool, copyPoolEntries);
-        case '[': // Array
-            return new ArrayElementValueGen((ArrayElementValue) value, cpool,
-                    copyPoolEntries);
-        case 'c': // Class
-            return new ClassElementValueGen((ClassElementValue) value, cpool,
-                    copyPoolEntries);
-        default:
-            throw new UnsupportedOperationException("Not implemented yet! (" + value.getElementValueType() + ")");
-        }
+    public abstract ElementValue getElementValue();
+
+    public int getElementValueType() {
+        return type;
     }
+
+    public abstract String stringifyValue();
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java
index 218ea89cae0..bdc9c517a86 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ElementValuePairGen.java
@@ -31,17 +31,14 @@
 /**
  * @since 6.0
  */
-public class ElementValuePairGen
-{
-    private int nameIdx;
+public class ElementValuePairGen {
+    private final int nameIdx;
 
     private final ElementValueGen value;
 
     private final ConstantPoolGen constantPoolGen;
 
-    public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpool,
-            final boolean copyPoolEntries)
-    {
+    public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
         this.constantPoolGen = cpool;
         // J5ASSERT:
         // Could assert nvp.getNameString() points to the same thing as
@@ -51,69 +48,54 @@ public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpo
         // {
         // throw new IllegalArgumentException("envp buggered");
         // }
-        if (copyPoolEntries)
-        {
+        if (copyPoolEntries) {
             nameIdx = cpool.addUtf8(nvp.getNameString());
-        }
-        else
-        {
+        } else {
             nameIdx = nvp.getNameIndex();
         }
         value = ElementValueGen.copy(nvp.getValue(), cpool, copyPoolEntries);
     }
 
-    /**
-     * Retrieve an immutable version of this ElementNameValuePairGen
-     */
-    public ElementValuePair getElementNameValuePair()
-    {
-        final ElementValue immutableValue = value.getElementValue();
-        return new ElementValuePair(nameIdx, immutableValue, constantPoolGen
-                .getConstantPool());
-    }
-
-    protected ElementValuePairGen(final int idx, final ElementValueGen value,
-            final ConstantPoolGen cpool)
-    {
+    protected ElementValuePairGen(final int idx, final ElementValueGen value, final ConstantPoolGen cpool) {
         this.nameIdx = idx;
         this.value = value;
         this.constantPoolGen = cpool;
     }
 
-    public ElementValuePairGen(final String name, final ElementValueGen value,
-            final ConstantPoolGen cpool)
-    {
+    public ElementValuePairGen(final String name, final ElementValueGen value, final ConstantPoolGen cpool) {
         this.nameIdx = cpool.addUtf8(name);
         this.value = value;
         this.constantPoolGen = cpool;
     }
 
-    protected void dump(final DataOutputStream dos) throws IOException
-    {
+    protected void dump(final DataOutputStream dos) throws IOException {
         dos.writeShort(nameIdx); // u2 name of the element
         value.dump(dos);
     }
 
-    public int getNameIndex()
-    {
+    /**
+     * Retrieve an immutable version of this ElementNameValuePairGen
+     */
+    public ElementValuePair getElementNameValuePair() {
+        final ElementValue immutableValue = value.getElementValue();
+        return new ElementValuePair(nameIdx, immutableValue, constantPoolGen.getConstantPool());
+    }
+
+    public int getNameIndex() {
         return nameIdx;
     }
 
-    public final String getNameString()
-    {
+    public final String getNameString() {
         // ConstantString cu8 = (ConstantString)constantPoolGen.getConstant(nameIdx);
         return ((ConstantUtf8) constantPoolGen.getConstant(nameIdx)).getBytes();
     }
 
-    public final ElementValueGen getValue()
-    {
+    public final ElementValueGen getValue() {
         return value;
     }
 
     @Override
-    public String toString()
-    {
-        return "ElementValuePair:[" + getNameString() + "="
-                + value.stringifyValue() + "]";
+    public String toString() {
+        return "ElementValuePair:[" + getNameString() + "=" + value.stringifyValue() + "]";
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java
index 5ae39f2d4ad..b76944416cb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EmptyVisitor.java
@@ -23,913 +23,733 @@
 
 /**
  * Supplies empty method bodies to be overridden by subclasses.
- *
  */
 public abstract class EmptyVisitor implements Visitor {
 
     @Override
-    public void visitStackInstruction( final StackInstruction obj ) {
+    public void visitAALOAD(final AALOAD obj) {
     }
 
-
     @Override
-    public void visitLocalVariableInstruction( final LocalVariableInstruction obj ) {
+    public void visitAASTORE(final AASTORE obj) {
     }
 
-
     @Override
-    public void visitBranchInstruction( final BranchInstruction obj ) {
+    public void visitACONST_NULL(final ACONST_NULL obj) {
     }
 
-
     @Override
-    public void visitLoadClass( final LoadClass obj ) {
+    public void visitAllocationInstruction(final AllocationInstruction obj) {
     }
 
-
     @Override
-    public void visitFieldInstruction( final FieldInstruction obj ) {
+    public void visitALOAD(final ALOAD obj) {
     }
 
-
     @Override
-    public void visitIfInstruction( final IfInstruction obj ) {
+    public void visitANEWARRAY(final ANEWARRAY obj) {
     }
 
-
     @Override
-    public void visitConversionInstruction( final ConversionInstruction obj ) {
+    public void visitARETURN(final ARETURN obj) {
     }
 
-
     @Override
-    public void visitPopInstruction( final PopInstruction obj ) {
+    public void visitArithmeticInstruction(final ArithmeticInstruction obj) {
     }
 
-
     @Override
-    public void visitJsrInstruction( final JsrInstruction obj ) {
+    public void visitArrayInstruction(final ArrayInstruction obj) {
     }
 
-
     @Override
-    public void visitGotoInstruction( final GotoInstruction obj ) {
+    public void visitARRAYLENGTH(final ARRAYLENGTH obj) {
     }
 
-
     @Override
-    public void visitStoreInstruction( final StoreInstruction obj ) {
+    public void visitASTORE(final ASTORE obj) {
     }
 
-
     @Override
-    public void visitTypedInstruction( final TypedInstruction obj ) {
+    public void visitATHROW(final ATHROW obj) {
     }
 
-
     @Override
-    public void visitSelect( final Select obj ) {
+    public void visitBALOAD(final BALOAD obj) {
     }
 
-
     @Override
-    public void visitUnconditionalBranch( final UnconditionalBranch obj ) {
+    public void visitBASTORE(final BASTORE obj) {
     }
 
-
     @Override
-    public void visitPushInstruction( final PushInstruction obj ) {
+    public void visitBIPUSH(final BIPUSH obj) {
     }
 
-
     @Override
-    public void visitArithmeticInstruction( final ArithmeticInstruction obj ) {
+    public void visitBranchInstruction(final BranchInstruction obj) {
     }
 
-
     @Override
-    public void visitCPInstruction( final CPInstruction obj ) {
+    public void visitBREAKPOINT(final BREAKPOINT obj) {
     }
 
-
     @Override
-    public void visitInvokeInstruction( final InvokeInstruction obj ) {
+    public void visitCALOAD(final CALOAD obj) {
     }
 
-
     @Override
-    public void visitArrayInstruction( final ArrayInstruction obj ) {
+    public void visitCASTORE(final CASTORE obj) {
     }
 
-
     @Override
-    public void visitAllocationInstruction( final AllocationInstruction obj ) {
+    public void visitCHECKCAST(final CHECKCAST obj) {
     }
 
-
     @Override
-    public void visitReturnInstruction( final ReturnInstruction obj ) {
+    public void visitConstantPushInstruction(final ConstantPushInstruction obj) {
     }
 
-
     @Override
-    public void visitFieldOrMethod( final FieldOrMethod obj ) {
+    public void visitConversionInstruction(final ConversionInstruction obj) {
     }
 
-
     @Override
-    public void visitConstantPushInstruction( final ConstantPushInstruction obj ) {
+    public void visitCPInstruction(final CPInstruction obj) {
     }
 
-
     @Override
-    public void visitExceptionThrower( final ExceptionThrower obj ) {
+    public void visitD2F(final D2F obj) {
     }
 
-
     @Override
-    public void visitLoadInstruction( final LoadInstruction obj ) {
+    public void visitD2I(final D2I obj) {
     }
 
-
     @Override
-    public void visitVariableLengthInstruction( final VariableLengthInstruction obj ) {
+    public void visitD2L(final D2L obj) {
     }
 
-
     @Override
-    public void visitStackProducer( final StackProducer obj ) {
+    public void visitDADD(final DADD obj) {
     }
 
-
     @Override
-    public void visitStackConsumer( final StackConsumer obj ) {
+    public void visitDALOAD(final DALOAD obj) {
     }
 
-
     @Override
-    public void visitACONST_NULL( final ACONST_NULL obj ) {
+    public void visitDASTORE(final DASTORE obj) {
     }
 
-
     @Override
-    public void visitGETSTATIC( final GETSTATIC obj ) {
+    public void visitDCMPG(final DCMPG obj) {
     }
 
-
     @Override
-    public void visitIF_ICMPLT( final IF_ICMPLT obj ) {
+    public void visitDCMPL(final DCMPL obj) {
     }
 
-
     @Override
-    public void visitMONITOREXIT( final MONITOREXIT obj ) {
+    public void visitDCONST(final DCONST obj) {
     }
 
-
     @Override
-    public void visitIFLT( final IFLT obj ) {
+    public void visitDDIV(final DDIV obj) {
     }
 
-
     @Override
-    public void visitLSTORE( final LSTORE obj ) {
+    public void visitDLOAD(final DLOAD obj) {
     }
 
-
     @Override
-    public void visitPOP2( final POP2 obj ) {
+    public void visitDMUL(final DMUL obj) {
     }
 
-
     @Override
-    public void visitBASTORE( final BASTORE obj ) {
+    public void visitDNEG(final DNEG obj) {
     }
 
-
     @Override
-    public void visitISTORE( final ISTORE obj ) {
+    public void visitDREM(final DREM obj) {
     }
 
-
     @Override
-    public void visitCHECKCAST( final CHECKCAST obj ) {
+    public void visitDRETURN(final DRETURN obj) {
     }
 
-
     @Override
-    public void visitFCMPG( final FCMPG obj ) {
+    public void visitDSTORE(final DSTORE obj) {
     }
 
-
     @Override
-    public void visitI2F( final I2F obj ) {
+    public void visitDSUB(final DSUB obj) {
     }
 
-
     @Override
-    public void visitATHROW( final ATHROW obj ) {
+    public void visitDUP(final DUP obj) {
     }
 
-
     @Override
-    public void visitDCMPL( final DCMPL obj ) {
+    public void visitDUP_X1(final DUP_X1 obj) {
     }
 
-
     @Override
-    public void visitARRAYLENGTH( final ARRAYLENGTH obj ) {
+    public void visitDUP_X2(final DUP_X2 obj) {
     }
 
-
     @Override
-    public void visitDUP( final DUP obj ) {
+    public void visitDUP2(final DUP2 obj) {
     }
 
-
     @Override
-    public void visitINVOKESTATIC( final INVOKESTATIC obj ) {
+    public void visitDUP2_X1(final DUP2_X1 obj) {
     }
 
-
     @Override
-    public void visitLCONST( final LCONST obj ) {
+    public void visitDUP2_X2(final DUP2_X2 obj) {
     }
 
-
     @Override
-    public void visitDREM( final DREM obj ) {
+    public void visitExceptionThrower(final ExceptionThrower obj) {
     }
 
-
     @Override
-    public void visitIFGE( final IFGE obj ) {
+    public void visitF2D(final F2D obj) {
     }
 
-
     @Override
-    public void visitCALOAD( final CALOAD obj ) {
+    public void visitF2I(final F2I obj) {
     }
 
-
     @Override
-    public void visitLASTORE( final LASTORE obj ) {
+    public void visitF2L(final F2L obj) {
     }
 
-
     @Override
-    public void visitI2D( final I2D obj ) {
+    public void visitFADD(final FADD obj) {
     }
 
-
     @Override
-    public void visitDADD( final DADD obj ) {
+    public void visitFALOAD(final FALOAD obj) {
     }
 
-
     @Override
-    public void visitINVOKESPECIAL( final INVOKESPECIAL obj ) {
+    public void visitFASTORE(final FASTORE obj) {
     }
 
-
     @Override
-    public void visitIAND( final IAND obj ) {
+    public void visitFCMPG(final FCMPG obj) {
     }
 
-
     @Override
-    public void visitPUTFIELD( final PUTFIELD obj ) {
+    public void visitFCMPL(final FCMPL obj) {
     }
 
-
     @Override
-    public void visitILOAD( final ILOAD obj ) {
+    public void visitFCONST(final FCONST obj) {
     }
 
-
     @Override
-    public void visitDLOAD( final DLOAD obj ) {
+    public void visitFDIV(final FDIV obj) {
     }
 
-
     @Override
-    public void visitDCONST( final DCONST obj ) {
+    public void visitFieldInstruction(final FieldInstruction obj) {
     }
 
-
     @Override
-    public void visitNEW( final NEW obj ) {
+    public void visitFieldOrMethod(final FieldOrMethod obj) {
     }
 
-
     @Override
-    public void visitIFNULL( final IFNULL obj ) {
+    public void visitFLOAD(final FLOAD obj) {
     }
 
-
     @Override
-    public void visitLSUB( final LSUB obj ) {
+    public void visitFMUL(final FMUL obj) {
     }
 
-
     @Override
-    public void visitL2I( final L2I obj ) {
+    public void visitFNEG(final FNEG obj) {
     }
 
-
     @Override
-    public void visitISHR( final ISHR obj ) {
+    public void visitFREM(final FREM obj) {
     }
 
-
     @Override
-    public void visitTABLESWITCH( final TABLESWITCH obj ) {
+    public void visitFRETURN(final FRETURN obj) {
     }
 
-
     @Override
-    public void visitIINC( final IINC obj ) {
+    public void visitFSTORE(final FSTORE obj) {
     }
 
-
     @Override
-    public void visitDRETURN( final DRETURN obj ) {
+    public void visitFSUB(final FSUB obj) {
     }
 
-
     @Override
-    public void visitFSTORE( final FSTORE obj ) {
+    public void visitGETFIELD(final GETFIELD obj) {
     }
 
-
     @Override
-    public void visitDASTORE( final DASTORE obj ) {
+    public void visitGETSTATIC(final GETSTATIC obj) {
     }
 
-
     @Override
-    public void visitIALOAD( final IALOAD obj ) {
+    public void visitGOTO(final GOTO obj) {
     }
 
-
     @Override
-    public void visitDDIV( final DDIV obj ) {
+    public void visitGOTO_W(final GOTO_W obj) {
     }
 
-
     @Override
-    public void visitIF_ICMPGE( final IF_ICMPGE obj ) {
+    public void visitGotoInstruction(final GotoInstruction obj) {
     }
 
-
     @Override
-    public void visitLAND( final LAND obj ) {
+    public void visitI2B(final I2B obj) {
     }
 
-
     @Override
-    public void visitIDIV( final IDIV obj ) {
+    public void visitI2C(final I2C obj) {
     }
 
-
     @Override
-    public void visitLOR( final LOR obj ) {
+    public void visitI2D(final I2D obj) {
     }
 
-
     @Override
-    public void visitCASTORE( final CASTORE obj ) {
+    public void visitI2F(final I2F obj) {
     }
 
-
     @Override
-    public void visitFREM( final FREM obj ) {
+    public void visitI2L(final I2L obj) {
     }
 
-
     @Override
-    public void visitLDC( final LDC obj ) {
+    public void visitI2S(final I2S obj) {
     }
 
-
     @Override
-    public void visitBIPUSH( final BIPUSH obj ) {
+    public void visitIADD(final IADD obj) {
     }
 
-
     @Override
-    public void visitDSTORE( final DSTORE obj ) {
+    public void visitIALOAD(final IALOAD obj) {
     }
 
-
     @Override
-    public void visitF2L( final F2L obj ) {
+    public void visitIAND(final IAND obj) {
     }
 
-
     @Override
-    public void visitFMUL( final FMUL obj ) {
+    public void visitIASTORE(final IASTORE obj) {
     }
 
-
     @Override
-    public void visitLLOAD( final LLOAD obj ) {
+    public void visitICONST(final ICONST obj) {
     }
 
-
     @Override
-    public void visitJSR( final JSR obj ) {
+    public void visitIDIV(final IDIV obj) {
     }
 
-
     @Override
-    public void visitFSUB( final FSUB obj ) {
+    public void visitIF_ACMPEQ(final IF_ACMPEQ obj) {
     }
 
-
     @Override
-    public void visitSASTORE( final SASTORE obj ) {
+    public void visitIF_ACMPNE(final IF_ACMPNE obj) {
     }
 
-
     @Override
-    public void visitALOAD( final ALOAD obj ) {
+    public void visitIF_ICMPEQ(final IF_ICMPEQ obj) {
     }
 
-
     @Override
-    public void visitDUP2_X2( final DUP2_X2 obj ) {
+    public void visitIF_ICMPGE(final IF_ICMPGE obj) {
     }
 
-
     @Override
-    public void visitRETURN( final RETURN obj ) {
+    public void visitIF_ICMPGT(final IF_ICMPGT obj) {
     }
 
-
     @Override
-    public void visitDALOAD( final DALOAD obj ) {
+    public void visitIF_ICMPLE(final IF_ICMPLE obj) {
     }
 
-
     @Override
-    public void visitSIPUSH( final SIPUSH obj ) {
+    public void visitIF_ICMPLT(final IF_ICMPLT obj) {
     }
 
-
     @Override
-    public void visitDSUB( final DSUB obj ) {
+    public void visitIF_ICMPNE(final IF_ICMPNE obj) {
     }
 
-
     @Override
-    public void visitL2F( final L2F obj ) {
+    public void visitIFEQ(final IFEQ obj) {
     }
 
-
     @Override
-    public void visitIF_ICMPGT( final IF_ICMPGT obj ) {
+    public void visitIFGE(final IFGE obj) {
     }
 
-
     @Override
-    public void visitF2D( final F2D obj ) {
+    public void visitIFGT(final IFGT obj) {
     }
 
-
     @Override
-    public void visitI2L( final I2L obj ) {
+    public void visitIfInstruction(final IfInstruction obj) {
     }
 
-
     @Override
-    public void visitIF_ACMPNE( final IF_ACMPNE obj ) {
+    public void visitIFLE(final IFLE obj) {
     }
 
-
     @Override
-    public void visitPOP( final POP obj ) {
+    public void visitIFLT(final IFLT obj) {
     }
 
-
     @Override
-    public void visitI2S( final I2S obj ) {
+    public void visitIFNE(final IFNE obj) {
     }
 
-
     @Override
-    public void visitIFEQ( final IFEQ obj ) {
+    public void visitIFNONNULL(final IFNONNULL obj) {
     }
 
-
     @Override
-    public void visitSWAP( final SWAP obj ) {
+    public void visitIFNULL(final IFNULL obj) {
     }
 
-
     @Override
-    public void visitIOR( final IOR obj ) {
+    public void visitIINC(final IINC obj) {
     }
 
-
     @Override
-    public void visitIREM( final IREM obj ) {
+    public void visitILOAD(final ILOAD obj) {
     }
 
-
     @Override
-    public void visitIASTORE( final IASTORE obj ) {
+    public void visitIMPDEP1(final IMPDEP1 obj) {
     }
 
-
     @Override
-    public void visitNEWARRAY( final NEWARRAY obj ) {
+    public void visitIMPDEP2(final IMPDEP2 obj) {
     }
 
-
     @Override
-    public void visitINVOKEINTERFACE( final INVOKEINTERFACE obj ) {
+    public void visitIMUL(final IMUL obj) {
     }
 
-
     @Override
-    public void visitINEG( final INEG obj ) {
+    public void visitINEG(final INEG obj) {
     }
 
-
     @Override
-    public void visitLCMP( final LCMP obj ) {
+    public void visitINSTANCEOF(final INSTANCEOF obj) {
     }
 
-
+    /**
+     * @since 6.0
+     */
     @Override
-    public void visitJSR_W( final JSR_W obj ) {
+    public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC obj) {
     }
 
-
     @Override
-    public void visitMULTIANEWARRAY( final MULTIANEWARRAY obj ) {
+    public void visitInvokeInstruction(final InvokeInstruction obj) {
     }
 
-
     @Override
-    public void visitDUP_X2( final DUP_X2 obj ) {
+    public void visitINVOKEINTERFACE(final INVOKEINTERFACE obj) {
     }
 
-
     @Override
-    public void visitSALOAD( final SALOAD obj ) {
+    public void visitINVOKESPECIAL(final INVOKESPECIAL obj) {
     }
 
-
     @Override
-    public void visitIFNONNULL( final IFNONNULL obj ) {
+    public void visitINVOKESTATIC(final INVOKESTATIC obj) {
     }
 
-
     @Override
-    public void visitDMUL( final DMUL obj ) {
+    public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL obj) {
     }
 
-
     @Override
-    public void visitIFNE( final IFNE obj ) {
+    public void visitIOR(final IOR obj) {
     }
 
-
     @Override
-    public void visitIF_ICMPLE( final IF_ICMPLE obj ) {
+    public void visitIREM(final IREM obj) {
     }
 
-
     @Override
-    public void visitLDC2_W( final LDC2_W obj ) {
+    public void visitIRETURN(final IRETURN obj) {
     }
 
-
     @Override
-    public void visitGETFIELD( final GETFIELD obj ) {
+    public void visitISHL(final ISHL obj) {
     }
 
-
     @Override
-    public void visitLADD( final LADD obj ) {
+    public void visitISHR(final ISHR obj) {
     }
 
-
     @Override
-    public void visitNOP( final NOP obj ) {
+    public void visitISTORE(final ISTORE obj) {
     }
 
-
     @Override
-    public void visitFALOAD( final FALOAD obj ) {
+    public void visitISUB(final ISUB obj) {
     }
 
-
     @Override
-    public void visitINSTANCEOF( final INSTANCEOF obj ) {
+    public void visitIUSHR(final IUSHR obj) {
     }
 
-
     @Override
-    public void visitIFLE( final IFLE obj ) {
+    public void visitIXOR(final IXOR obj) {
     }
 
-
     @Override
-    public void visitLXOR( final LXOR obj ) {
+    public void visitJSR(final JSR obj) {
     }
 
-
     @Override
-    public void visitLRETURN( final LRETURN obj ) {
+    public void visitJSR_W(final JSR_W obj) {
     }
 
-
     @Override
-    public void visitFCONST( final FCONST obj ) {
+    public void visitJsrInstruction(final JsrInstruction obj) {
     }
 
-
     @Override
-    public void visitIUSHR( final IUSHR obj ) {
+    public void visitL2D(final L2D obj) {
     }
 
-
     @Override
-    public void visitBALOAD( final BALOAD obj ) {
+    public void visitL2F(final L2F obj) {
     }
 
-
     @Override
-    public void visitDUP2( final DUP2 obj ) {
+    public void visitL2I(final L2I obj) {
     }
 
-
     @Override
-    public void visitIF_ACMPEQ( final IF_ACMPEQ obj ) {
+    public void visitLADD(final LADD obj) {
     }
 
-
     @Override
-    public void visitIMPDEP1( final IMPDEP1 obj ) {
+    public void visitLALOAD(final LALOAD obj) {
     }
 
-
     @Override
-    public void visitMONITORENTER( final MONITORENTER obj ) {
+    public void visitLAND(final LAND obj) {
     }
 
-
     @Override
-    public void visitLSHL( final LSHL obj ) {
+    public void visitLASTORE(final LASTORE obj) {
     }
 
-
     @Override
-    public void visitDCMPG( final DCMPG obj ) {
+    public void visitLCMP(final LCMP obj) {
     }
 
-
     @Override
-    public void visitD2L( final D2L obj ) {
+    public void visitLCONST(final LCONST obj) {
     }
 
-
     @Override
-    public void visitIMPDEP2( final IMPDEP2 obj ) {
+    public void visitLDC(final LDC obj) {
     }
 
-
     @Override
-    public void visitL2D( final L2D obj ) {
+    public void visitLDC2_W(final LDC2_W obj) {
     }
 
-
     @Override
-    public void visitRET( final RET obj ) {
+    public void visitLDIV(final LDIV obj) {
     }
 
-
     @Override
-    public void visitIFGT( final IFGT obj ) {
+    public void visitLLOAD(final LLOAD obj) {
     }
 
-
     @Override
-    public void visitIXOR( final IXOR obj ) {
+    public void visitLMUL(final LMUL obj) {
     }
 
-
     @Override
-    public void visitINVOKEVIRTUAL( final INVOKEVIRTUAL obj ) {
+    public void visitLNEG(final LNEG obj) {
     }
 
-
     @Override
-    public void visitFASTORE( final FASTORE obj ) {
+    public void visitLoadClass(final LoadClass obj) {
     }
 
-
     @Override
-    public void visitIRETURN( final IRETURN obj ) {
+    public void visitLoadInstruction(final LoadInstruction obj) {
     }
 
-
     @Override
-    public void visitIF_ICMPNE( final IF_ICMPNE obj ) {
+    public void visitLocalVariableInstruction(final LocalVariableInstruction obj) {
     }
 
-
     @Override
-    public void visitFLOAD( final FLOAD obj ) {
+    public void visitLOOKUPSWITCH(final LOOKUPSWITCH obj) {
     }
 
-
     @Override
-    public void visitLDIV( final LDIV obj ) {
+    public void visitLOR(final LOR obj) {
     }
 
-
     @Override
-    public void visitPUTSTATIC( final PUTSTATIC obj ) {
+    public void visitLREM(final LREM obj) {
     }
 
-
     @Override
-    public void visitAALOAD( final AALOAD obj ) {
+    public void visitLRETURN(final LRETURN obj) {
     }
 
-
     @Override
-    public void visitD2I( final D2I obj ) {
+    public void visitLSHL(final LSHL obj) {
     }
 
-
     @Override
-    public void visitIF_ICMPEQ( final IF_ICMPEQ obj ) {
+    public void visitLSHR(final LSHR obj) {
     }
 
-
     @Override
-    public void visitAASTORE( final AASTORE obj ) {
+    public void visitLSTORE(final LSTORE obj) {
     }
 
-
     @Override
-    public void visitARETURN( final ARETURN obj ) {
+    public void visitLSUB(final LSUB obj) {
     }
 
-
     @Override
-    public void visitDUP2_X1( final DUP2_X1 obj ) {
+    public void visitLUSHR(final LUSHR obj) {
     }
 
-
     @Override
-    public void visitFNEG( final FNEG obj ) {
+    public void visitLXOR(final LXOR obj) {
     }
 
-
     @Override
-    public void visitGOTO_W( final GOTO_W obj ) {
+    public void visitMONITORENTER(final MONITORENTER obj) {
     }
 
-
     @Override
-    public void visitD2F( final D2F obj ) {
+    public void visitMONITOREXIT(final MONITOREXIT obj) {
     }
 
-
     @Override
-    public void visitGOTO( final GOTO obj ) {
+    public void visitMULTIANEWARRAY(final MULTIANEWARRAY obj) {
     }
 
-
     @Override
-    public void visitISUB( final ISUB obj ) {
+    public void visitNEW(final NEW obj) {
     }
 
-
     @Override
-    public void visitF2I( final F2I obj ) {
+    public void visitNEWARRAY(final NEWARRAY obj) {
     }
 
-
     @Override
-    public void visitDNEG( final DNEG obj ) {
+    public void visitNOP(final NOP obj) {
     }
 
-
     @Override
-    public void visitICONST( final ICONST obj ) {
+    public void visitPOP(final POP obj) {
     }
 
-
     @Override
-    public void visitFDIV( final FDIV obj ) {
+    public void visitPOP2(final POP2 obj) {
     }
 
-
     @Override
-    public void visitI2B( final I2B obj ) {
+    public void visitPopInstruction(final PopInstruction obj) {
     }
 
-
     @Override
-    public void visitLNEG( final LNEG obj ) {
+    public void visitPushInstruction(final PushInstruction obj) {
     }
 
-
     @Override
-    public void visitLREM( final LREM obj ) {
+    public void visitPUTFIELD(final PUTFIELD obj) {
     }
 
-
     @Override
-    public void visitIMUL( final IMUL obj ) {
+    public void visitPUTSTATIC(final PUTSTATIC obj) {
     }
 
-
     @Override
-    public void visitIADD( final IADD obj ) {
+    public void visitRET(final RET obj) {
     }
 
-
     @Override
-    public void visitLSHR( final LSHR obj ) {
+    public void visitRETURN(final RETURN obj) {
     }
 
-
     @Override
-    public void visitLOOKUPSWITCH( final LOOKUPSWITCH obj ) {
+    public void visitReturnInstruction(final ReturnInstruction obj) {
     }
 
-
     @Override
-    public void visitDUP_X1( final DUP_X1 obj ) {
+    public void visitSALOAD(final SALOAD obj) {
     }
 
-
     @Override
-    public void visitFCMPL( final FCMPL obj ) {
+    public void visitSASTORE(final SASTORE obj) {
     }
 
-
     @Override
-    public void visitI2C( final I2C obj ) {
+    public void visitSelect(final Select obj) {
     }
 
-
     @Override
-    public void visitLMUL( final LMUL obj ) {
+    public void visitSIPUSH(final SIPUSH obj) {
     }
 
-
     @Override
-    public void visitLUSHR( final LUSHR obj ) {
+    public void visitStackConsumer(final StackConsumer obj) {
     }
 
-
     @Override
-    public void visitISHL( final ISHL obj ) {
+    public void visitStackInstruction(final StackInstruction obj) {
     }
 
-
     @Override
-    public void visitLALOAD( final LALOAD obj ) {
+    public void visitStackProducer(final StackProducer obj) {
     }
 
-
     @Override
-    public void visitASTORE( final ASTORE obj ) {
+    public void visitStoreInstruction(final StoreInstruction obj) {
     }
 
-
     @Override
-    public void visitANEWARRAY( final ANEWARRAY obj ) {
+    public void visitSWAP(final SWAP obj) {
     }
 
-
     @Override
-    public void visitFRETURN( final FRETURN obj ) {
+    public void visitTABLESWITCH(final TABLESWITCH obj) {
     }
 
-
     @Override
-    public void visitFADD( final FADD obj ) {
+    public void visitTypedInstruction(final TypedInstruction obj) {
     }
 
-
     @Override
-    public void visitBREAKPOINT( final BREAKPOINT obj ) {
+    public void visitUnconditionalBranch(final UnconditionalBranch obj) {
     }
 
-    /**
-     * @since 6.0
-     */
     @Override
-    public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC obj) {
+    public void visitVariableLengthInstruction(final VariableLengthInstruction obj) {
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java
index 13958521398..95ac794f2d7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/EnumElementValueGen.java
@@ -31,103 +31,73 @@
 /**
  * @since 6.0
  */
-public class EnumElementValueGen extends ElementValueGen
-{
+public class EnumElementValueGen extends ElementValueGen {
     // For enum types, these two indices point to the type and value
-    private int typeIdx;
+    private final int typeIdx;
 
-    private int valueIdx;
+    private final int valueIdx;
+
+    public EnumElementValueGen(final EnumElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
+        super(ENUM_CONSTANT, cpool);
+        if (copyPoolEntries) {
+            typeIdx = cpool.addUtf8(value.getEnumTypeString());// was
+                                                               // addClass(value.getEnumTypeString());
+            valueIdx = cpool.addUtf8(value.getEnumValueString()); // was
+                                                                  // addString(value.getEnumValueString());
+        } else {
+            typeIdx = value.getTypeIndex();
+            valueIdx = value.getValueIndex();
+        }
+    }
 
     /**
-     * This ctor assumes the constant pool already contains the right type and
-     * value - as indicated by typeIdx and valueIdx. This ctor is used for
-     * deserialization
+     * This ctor assumes the constant pool already contains the right type and value - as indicated by typeIdx and valueIdx.
+     * This ctor is used for deserialization
      */
-    protected EnumElementValueGen(final int typeIdx, final int valueIdx,
-            final ConstantPoolGen cpool)
-    {
+    protected EnumElementValueGen(final int typeIdx, final int valueIdx, final ConstantPoolGen cpool) {
         super(ElementValueGen.ENUM_CONSTANT, cpool);
         if (super.getElementValueType() != ENUM_CONSTANT) {
-            throw new IllegalArgumentException(
-                    "Only element values of type enum can be built with this ctor - type specified: "
-                            + super.getElementValueType());
+            throw new IllegalArgumentException("Only element values of type enum can be built with this ctor - type specified: " + super.getElementValueType());
         }
         this.typeIdx = typeIdx;
         this.valueIdx = valueIdx;
     }
 
-    /**
-     * Return immutable variant of this EnumElementValue
-     */
-    @Override
-    public ElementValue getElementValue()
-    {
-        System.err.println("Duplicating value: " + getEnumTypeString() + ":"
-                + getEnumValueString());
-        return new EnumElementValue(super.getElementValueType(), typeIdx, valueIdx,
-                getConstantPool().getConstantPool());
-    }
-
-    public EnumElementValueGen(final ObjectType t, final String value, final ConstantPoolGen cpool)
-    {
+    public EnumElementValueGen(final ObjectType t, final String value, final ConstantPoolGen cpool) {
         super(ElementValueGen.ENUM_CONSTANT, cpool);
         typeIdx = cpool.addUtf8(t.getSignature());// was addClass(t);
         valueIdx = cpool.addUtf8(value);// was addString(value);
     }
 
-    public EnumElementValueGen(final EnumElementValue value, final ConstantPoolGen cpool,
-            final boolean copyPoolEntries)
-    {
-        super(ENUM_CONSTANT, cpool);
-        if (copyPoolEntries)
-        {
-            typeIdx = cpool.addUtf8(value.getEnumTypeString());// was
-                                                                // addClass(value.getEnumTypeString());
-            valueIdx = cpool.addUtf8(value.getEnumValueString()); // was
-                                                                    // addString(value.getEnumValueString());
-        }
-        else
-        {
-            typeIdx = value.getTypeIndex();
-            valueIdx = value.getValueIndex();
-        }
-    }
-
     @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
+    public void dump(final DataOutputStream dos) throws IOException {
         dos.writeByte(super.getElementValueType()); // u1 type of value (ENUM_CONSTANT == 'e')
         dos.writeShort(typeIdx); // u2
         dos.writeShort(valueIdx); // u2
     }
 
+    /**
+     * Return immutable variant of this EnumElementValue
+     */
     @Override
-    public String stringifyValue()
-    {
-        final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx);
-        return cu8.getBytes();
-        // ConstantString cu8 =
-        // (ConstantString)getConstantPool().getConstant(valueIdx);
-        // return
-        // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes();
+    public ElementValue getElementValue() {
+        System.err.println("Duplicating value: " + getEnumTypeString() + ":" + getEnumValueString());
+        return new EnumElementValue(super.getElementValueType(), typeIdx, valueIdx, getConstantPool().getConstantPool());
     }
 
     // BCELBUG: Should we need to call utility.signatureToString() on the output
     // here?
-    public String getEnumTypeString()
-    {
+    public String getEnumTypeString() {
         // Constant cc = getConstantPool().getConstant(typeIdx);
         // ConstantClass cu8 =
         // (ConstantClass)getConstantPool().getConstant(typeIdx);
         // return
         // ((ConstantUtf8)getConstantPool().getConstant(cu8.getNameIndex())).getBytes();
-        return ((ConstantUtf8) getConstantPool().getConstant(typeIdx))
-                .getBytes();
+        return ((ConstantUtf8) getConstantPool().getConstant(typeIdx)).getBytes();
         // return Utility.signatureToString(cu8.getBytes());
     }
 
-    public String getEnumValueString()
-    {
+    public String getEnumValueString() {
         return ((ConstantUtf8) getConstantPool().getConstant(valueIdx)).getBytes();
         // ConstantString cu8 =
         // (ConstantString)getConstantPool().getConstant(valueIdx);
@@ -135,13 +105,21 @@ public String getEnumValueString()
         // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes();
     }
 
-    public int getValueIndex()
-    {
+    public int getTypeIndex() {
+        return typeIdx;
+    }
+
+    public int getValueIndex() {
         return valueIdx;
     }
 
-    public int getTypeIndex()
-    {
-        return typeIdx;
+    @Override
+    public String stringifyValue() {
+        final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx);
+        return cu8.getBytes();
+        // ConstantString cu8 =
+        // (ConstantString)getConstantPool().getConstant(valueIdx);
+        // return
+        // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java
index 9d6adb4e6c3..86a0cad256c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ExceptionThrower.java
@@ -22,24 +22,17 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denote an instruction that may throw a run-time or a linking
- * exception (or both) during execution.  This is not quite the truth
- * as such; because all instructions may throw an
- * java.lang.VirtualMachineError. These exceptions are omitted.
+ * Denote an instruction that may throw a run-time or a linking exception (or both) during execution. This is not quite
+ * the truth as such; because all instructions may throw an java.lang.VirtualMachineError. These exceptions are omitted.
  *
- * The Lava Language Specification specifies exactly which
- * <i>RUN-TIME</i> and which <i>LINKING</i> exceptions each
- * instruction may throw which is reflected by the implementers.  Due
- * to the structure of the JVM specification, it may be possible that
- * an Instruction implementing this interface returns a Class[] of
- * size 0.
- *
- * Please note that we speak of an "exception" here when we mean any
- * "Throwable" object; so this term is equally used for "Exception"
- * and "Error" objects.
+ * The Lava Language Specification specifies exactly which <i>RUN-TIME</i> and which <i>LINKING</i> exceptions each
+ * instruction may throw which is reflected by the implementers. Due to the structure of the JVM specification, it may
+ * be possible that an Instruction implementing this interface returns a Class[] of size 0.
  *
+ * Please note that we speak of an "exception" here when we mean any "Throwable" object; so this term is equally used
+ * for "Exception" and "Error" objects.
  */
 public interface ExceptionThrower {
 
-    java.lang.Class<?>[] getExceptions();
+    Class<?>[] getExceptions();
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2D.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2D.java
index a49d9bb7b18..3697ae379d5 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2D.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2D.java
@@ -23,28 +23,28 @@
 
 /**
  * F2D - Convert float to double
- * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class F2D extends ConversionInstruction {
 
-    /** Convert float to double
+    /**
+     * Convert float to double
      */
     public F2D() {
         super(com.sun.org.apache.bcel.internal.Const.F2D);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2I.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2I.java
index f3bd65485ef..552ab176a29 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2I.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2I.java
@@ -23,28 +23,28 @@
 
 /**
  * F2I - Convert float to int
- * <PRE>Stack: ..., value -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result
+ * </PRE>
  */
 public class F2I extends ConversionInstruction {
 
-    /** Convert float to int
+    /**
+     * Convert float to int
      */
     public F2I() {
         super(com.sun.org.apache.bcel.internal.Const.F2I);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2L.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2L.java
index 8d0ed680c1b..73b4edf7a2c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2L.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/F2L.java
@@ -23,28 +23,28 @@
 
 /**
  * F2L - Convert float to long
- * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class F2L extends ConversionInstruction {
 
-    /** Convert float to long
+    /**
+     * Convert float to long
      */
     public F2L() {
         super(com.sun.org.apache.bcel.internal.Const.F2L);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FADD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FADD.java
index e89d1a4f6e6..a1e4e466b15 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FADD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FADD.java
@@ -23,28 +23,28 @@
 
 /**
  * FADD - Add floats
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class FADD extends ArithmeticInstruction {
 
-    /** Add floats
+    /**
+     * Add floats
      */
     public FADD() {
         super(com.sun.org.apache.bcel.internal.Const.FADD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FALOAD.java
index be3b8f07ab7..7d00b4c5764 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FALOAD.java
@@ -23,28 +23,28 @@
 
 /**
  * FALOAD - Load float from array
- * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; ..., value
+ * </PRE>
  */
 public class FALOAD extends ArrayInstruction implements StackProducer {
 
-    /** Load float from array
+    /**
+     * Load float from array
      */
     public FALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.FALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FASTORE.java
index 9d0c0685c02..0215fd74bef 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FASTORE.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * FASTORE -  Store into float array
- * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ * FASTORE - Store into float array
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value -&gt; ...
+ * </PRE>
  */
 public class FASTORE extends ArrayInstruction implements StackConsumer {
 
-    /** Store float into array
+    /**
+     * Store float into array
      */
     public FASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.FASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPG.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPG.java
index 24b2655f05f..bbeb1e2ed23 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPG.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPG.java
@@ -23,8 +23,10 @@
 
 /**
  * FCMPG - Compare floats: value1 &gt; value2
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class FCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
 
@@ -32,28 +34,25 @@ public FCMPG() {
         super(com.sun.org.apache.bcel.internal.Const.FCMPG, (short) 1);
     }
 
-
-    /** @return Type.FLOAT
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.FLOAT;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
         v.visitFCMPG(this);
     }
+
+    /**
+     * @return Type.FLOAT
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.FLOAT;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPL.java
index 5d4cf811e83..0b7cec09388 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCMPL.java
@@ -23,8 +23,10 @@
 
 /**
  * FCMPL - Compare floats: value1 &lt; value2
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class FCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
 
@@ -32,28 +34,25 @@ public FCMPL() {
         super(com.sun.org.apache.bcel.internal.Const.FCMPL, (short) 1);
     }
 
-
-    /** @return Type.FLOAT
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.FLOAT;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
         v.visitFCMPL(this);
     }
+
+    /**
+     * @return Type.FLOAT
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.FLOAT;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCONST.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCONST.java
index 717ace5abfb..7c8116e8cbf 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCONST.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCONST.java
@@ -23,23 +23,22 @@
 /**
  * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception
  *
- * <PRE>Stack: ... -&gt; ..., </PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ...,
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class FCONST extends Instruction implements ConstantPushInstruction {
 
-    private float value;
-
+    private final float value;
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     FCONST() {
+        this(0);
     }
 
-
     public FCONST(final float f) {
         super(com.sun.org.apache.bcel.internal.Const.FCONST_0, (short) 1);
         if (f == 0.0) {
@@ -54,35 +53,31 @@ public FCONST(final float f) {
         value = f;
     }
 
-
-    @Override
-    public Number getValue() {
-        return value;
-    }
-
-
-    /** @return Type.FLOAT
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.FLOAT;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitPushInstruction(this);
         v.visitStackProducer(this);
         v.visitTypedInstruction(this);
         v.visitConstantPushInstruction(this);
         v.visitFCONST(this);
     }
+
+    /**
+     * @return Type.FLOAT
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.FLOAT;
+    }
+
+    @Override
+    public Number getValue() {
+        return Float.valueOf(value);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FDIV.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FDIV.java
index 720709b47a4..010c9d9960a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FDIV.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FDIV.java
@@ -23,28 +23,28 @@
 
 /**
  * FDIV - Divide floats
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class FDIV extends ArithmeticInstruction {
 
-    /** Divide floats
+    /**
+     * Divide floats
      */
     public FDIV() {
         super(com.sun.org.apache.bcel.internal.Const.FDIV);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FLOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FLOAD.java
index 8fecdd219ce..e8abc13d642 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FLOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FLOAD.java
@@ -23,38 +23,37 @@
 
 /**
  * FLOAD - Load float from local variable
- * <PRE>Stack ... -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack ... -&gt; ..., result
+ * </PRE>
  */
 public class FLOAD extends LoadInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     FLOAD() {
         super(com.sun.org.apache.bcel.internal.Const.FLOAD, com.sun.org.apache.bcel.internal.Const.FLOAD_0);
     }
 
-
-    /** Load float from local variable
+    /**
+     * Load float from local variable
+     *
      * @param n index of local variable
      */
     public FLOAD(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.FLOAD, com.sun.org.apache.bcel.internal.Const.FLOAD_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitFLOAD(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FMUL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FMUL.java
index e6c7cbcc9a4..a1d67147755 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FMUL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FMUL.java
@@ -23,28 +23,28 @@
 
 /**
  * FMUL - Multiply floats
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class FMUL extends ArithmeticInstruction {
 
-    /** Multiply floats
+    /**
+     * Multiply floats
      */
     public FMUL() {
         super(com.sun.org.apache.bcel.internal.Const.FMUL);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FNEG.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FNEG.java
index 55311300005..eb134d9940f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FNEG.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FNEG.java
@@ -23,8 +23,10 @@
 
 /**
  * FNEG - Negate float
- * <PRE>Stack: ..., value -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result
+ * </PRE>
  */
 public class FNEG extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public FNEG() {
         super(com.sun.org.apache.bcel.internal.Const.FNEG);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FREM.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FREM.java
index aa65abb8aef..39e0740cfbc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FREM.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FREM.java
@@ -23,28 +23,28 @@
 
 /**
  * FREM - Remainder of floats
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class FREM extends ArithmeticInstruction {
 
-    /** Remainder of floats
+    /**
+     * Remainder of floats
      */
     public FREM() {
         super(com.sun.org.apache.bcel.internal.Const.FREM);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FRETURN.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FRETURN.java
index d232625f7cb..3f7ba0c9a75 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FRETURN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FRETURN.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * FRETURN -  Return float from method
- * <PRE>Stack: ..., value -&gt; &lt;empty&gt;</PRE>
+ * FRETURN - Return float from method
  *
+ * <PRE>
+ * Stack: ..., value -&gt; &lt;empty&gt;
+ * </PRE>
  */
 public class FRETURN extends ReturnInstruction {
 
-    /** Return float from method
+    /**
+     * Return float from method
      */
     public FRETURN() {
         super(com.sun.org.apache.bcel.internal.Const.FRETURN);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSTORE.java
index eb366e3a203..868f9211f03 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSTORE.java
@@ -23,38 +23,37 @@
 
 /**
  * FSTORE - Store float into local variable
- * <PRE>Stack: ..., value -&gt; ... </PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class FSTORE extends StoreInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     FSTORE() {
         super(com.sun.org.apache.bcel.internal.Const.FSTORE, com.sun.org.apache.bcel.internal.Const.FSTORE_0);
     }
 
-
-    /** Store float into local variable
+    /**
+     * Store float into local variable
+     *
      * @param n index of local variable
      */
     public FSTORE(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.FSTORE, com.sun.org.apache.bcel.internal.Const.FSTORE_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitFSTORE(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSUB.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSUB.java
index ecb791b4398..9f2a3607a3d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSUB.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FSUB.java
@@ -23,28 +23,28 @@
 
 /**
  * FSUB - Substract floats
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class FSUB extends ArithmeticInstruction {
 
-    /** Substract floats
+    /**
+     * Substract floats
      */
     public FSUB() {
         super(com.sun.org.apache.bcel.internal.Const.FSUB);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java
index 78af8b698e0..9d1f4d41d93 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java
@@ -22,9 +22,9 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Stream;
 
 import com.sun.org.apache.bcel.internal.Const;
-import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry;
 import com.sun.org.apache.bcel.internal.classfile.Annotations;
 import com.sun.org.apache.bcel.internal.classfile.Attribute;
 import com.sun.org.apache.bcel.internal.classfile.Constant;
@@ -36,52 +36,47 @@
 import com.sun.org.apache.bcel.internal.util.BCELComparator;
 
 /**
- * Template class for building up a field.  The only extraordinary thing
- * one can do is to add a constant value attribute to a field (which must of
- * course be compatible with to the declared type).
+ * Template class for building up a field. The only extraordinary thing one can do is to add a constant value attribute
+ * to a field (which must of course be compatible with to the declared type).
  *
  * @see Field
  * @LastModified: May 2021
  */
 public class FieldGen extends FieldGenOrMethodGen {
 
-    private Object value = null;
     private static BCELComparator bcelComparator = new BCELComparator() {
 
         @Override
-        public boolean equals( final Object o1, final Object o2 ) {
+        public boolean equals(final Object o1, final Object o2) {
             final FieldGen THIS = (FieldGen) o1;
             final FieldGen THAT = (FieldGen) o2;
-            return Objects.equals(THIS.getName(), THAT.getName())
-                    && Objects.equals(THIS.getSignature(), THAT.getSignature());
+            return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
         }
 
-
         @Override
-        public int hashCode( final Object o ) {
+        public int hashCode(final Object o) {
             final FieldGen THIS = (FieldGen) o;
             return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
         }
     };
 
+    /**
+     * @return Comparison strategy object
+     */
+    public static BCELComparator getComparator() {
+        return bcelComparator;
+    }
 
     /**
-     * Declare a field. If it is static (isStatic() == true) and has a
-     * basic type like int or String it may have an initial value
-     * associated with it as defined by setInitValue().
-     *
-     * @param access_flags access qualifiers
-     * @param type  field type
-     * @param name field name
-     * @param cp constant pool
+     * @param comparator Comparison strategy object
      */
-    public FieldGen(final int access_flags, final Type type, final String name, final ConstantPoolGen cp) {
-        super(access_flags);
-        setType(type);
-        setName(name);
-        setConstantPool(cp);
+    public static void setComparator(final BCELComparator comparator) {
+        bcelComparator = comparator;
     }
 
+    private Object value;
+
+    private List<FieldObserver> observers;
 
     /**
      * Instantiate from existing field.
@@ -96,109 +91,73 @@ public FieldGen(final Field field, final ConstantPoolGen cp) {
             if (attr instanceof ConstantValue) {
                 setValue(((ConstantValue) attr).getConstantValueIndex());
             } else if (attr instanceof Annotations) {
-                final Annotations runtimeAnnotations = (Annotations)attr;
-                final AnnotationEntry[] annotationEntries = runtimeAnnotations.getAnnotationEntries();
-                for (final AnnotationEntry element : annotationEntries) {
-                    addAnnotationEntry(new AnnotationEntryGen(element,cp,false));
-                }
+                final Annotations runtimeAnnotations = (Annotations) attr;
+                runtimeAnnotations.forEach(element -> addAnnotationEntry(new AnnotationEntryGen(element, cp, false)));
             } else {
                 addAttribute(attr);
             }
         }
     }
 
-
-    private void setValue( final int index ) {
-        final ConstantPool cp = super.getConstantPool().getConstantPool();
-        final Constant c = cp.getConstant(index);
-        value = ((ConstantObject) c).getConstantValue(cp);
-    }
-
-
     /**
-     * Set (optional) initial value of field, otherwise it will be set to null/0/false
-     * by the JVM automatically.
+     * Declare a field. If it is static (isStatic() == true) and has a basic type like int or String it may have an initial
+     * value associated with it as defined by setInitValue().
+     *
+     * @param accessFlags access qualifiers
+     * @param type field type
+     * @param name field name
+     * @param cp constant pool
      */
-    public void setInitValue( final String str ) {
-        checkType(  ObjectType.getInstance("java.lang.String"));
-        if (str != null) {
-            value = str;
-        }
-    }
-
-
-    public void setInitValue( final long l ) {
-        checkType(Type.LONG);
-        if (l != 0L) {
-            value = Long.valueOf(l);
-        }
-    }
-
-
-    public void setInitValue( final int i ) {
-        checkType(Type.INT);
-        if (i != 0) {
-            value = Integer.valueOf(i);
-        }
-    }
-
-
-    public void setInitValue( final short s ) {
-        checkType(Type.SHORT);
-        if (s != 0) {
-            value = Integer.valueOf(s);
-        }
-    }
-
-
-    public void setInitValue( final char c ) {
-        checkType(Type.CHAR);
-        if (c != 0) {
-            value = Integer.valueOf(c);
-        }
-    }
-
-
-    public void setInitValue( final byte b ) {
-        checkType(Type.BYTE);
-        if (b != 0) {
-            value = Integer.valueOf(b);
-        }
+    public FieldGen(final int accessFlags, final Type type, final String name, final ConstantPoolGen cp) {
+        super(accessFlags);
+        setType(type);
+        setName(name);
+        setConstantPool(cp);
     }
 
-
-    public void setInitValue( final boolean b ) {
-        checkType(Type.BOOLEAN);
-        if (b) {
-            value = Integer.valueOf(1);
-        }
+    private void addAnnotationsAsAttribute(final ConstantPoolGen cp) {
+        Stream.of(AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries())).forEach(this::addAttribute);
     }
 
-
-    public void setInitValue( final float f ) {
-        checkType(Type.FLOAT);
-        if (f != 0.0) {
-            value = f;
+    private int addConstant() {
+        switch (super.getType().getType()) { // sic
+        case Const.T_INT:
+        case Const.T_CHAR:
+        case Const.T_BYTE:
+        case Const.T_BOOLEAN:
+        case Const.T_SHORT:
+            return super.getConstantPool().addInteger(((Integer) value).intValue());
+        case Const.T_FLOAT:
+            return super.getConstantPool().addFloat(((Float) value).floatValue());
+        case Const.T_DOUBLE:
+            return super.getConstantPool().addDouble(((Double) value).doubleValue());
+        case Const.T_LONG:
+            return super.getConstantPool().addLong(((Long) value).longValue());
+        case Const.T_REFERENCE:
+            return super.getConstantPool().addString((String) value);
+        default:
+            throw new IllegalStateException("Unhandled : " + super.getType().getType()); // sic
         }
     }
 
-
-    public void setInitValue( final double d ) {
-        checkType(Type.DOUBLE);
-        if (d != 0.0) {
-            value = d;
+    /**
+     * Add observer for this object.
+     */
+    public void addObserver(final FieldObserver o) {
+        if (observers == null) {
+            observers = new ArrayList<>();
         }
+        observers.add(o);
     }
 
-
-    /** Remove any initial value.
+    /**
+     * Remove any initial value.
      */
     public void cancelInitValue() {
         value = null;
     }
 
-
-    private void checkType( final Type atype ) {
+    private void checkType(final Type atype) {
         final Type superType = super.getType();
         if (superType == null) {
             throw new ClassGenException("You haven't defined the type of the field yet");
@@ -211,106 +170,148 @@ private void checkType( final Type atype ) {
         }
     }
 
+    /**
+     * @return deep copy of this field
+     */
+    public FieldGen copy(final ConstantPoolGen cp) {
+        final FieldGen fg = (FieldGen) clone();
+        fg.setConstantPool(cp);
+        return fg;
+    }
+
+    /**
+     * Return value as defined by given BCELComparator strategy. By default two FieldGen objects are said to be equal when
+     * their names and signatures are equal.
+     *
+     * @see Object#equals(Object)
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        return bcelComparator.equals(this, obj);
+    }
 
     /**
      * Get field object after having set up all necessary values.
      */
     public Field getField() {
         final String signature = getSignature();
-        final int name_index = super.getConstantPool().addUtf8(super.getName());
-        final int signature_index = super.getConstantPool().addUtf8(signature);
+        final int nameIndex = super.getConstantPool().addUtf8(super.getName());
+        final int signatureIndex = super.getConstantPool().addUtf8(signature);
         if (value != null) {
             checkType(super.getType());
             final int index = addConstant();
-            addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"), 2, index,
-                    super.getConstantPool().getConstantPool())); // sic
+            addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"), 2, index, super.getConstantPool().getConstantPool())); // sic
         }
         addAnnotationsAsAttribute(super.getConstantPool());
-        return new Field(super.getAccessFlags(), name_index, signature_index, getAttributes(),
-                super.getConstantPool().getConstantPool()); // sic
+        return new Field(super.getAccessFlags(), nameIndex, signatureIndex, getAttributes(), super.getConstantPool().getConstantPool()); // sic
     }
 
-    private void addAnnotationsAsAttribute(final ConstantPoolGen cp) {
-          final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
-        for (final Attribute attr : attrs) {
-            addAttribute(attr);
-        }
-      }
-
-
-    private int addConstant() {
-        switch (super.getType().getType()) { // sic
-            case Const.T_INT:
-            case Const.T_CHAR:
-            case Const.T_BYTE:
-            case Const.T_BOOLEAN:
-            case Const.T_SHORT:
-                return super.getConstantPool().addInteger(((Integer) value));
-            case Const.T_FLOAT:
-                return super.getConstantPool().addFloat(((Float) value));
-            case Const.T_DOUBLE:
-                return super.getConstantPool().addDouble(((Double) value));
-            case Const.T_LONG:
-                return super.getConstantPool().addLong(((Long) value));
-            case Const.T_REFERENCE:
-                return super.getConstantPool().addString((String) value);
-            default:
-                throw new IllegalStateException("Unhandled : " + super.getType().getType()); // sic
+    public String getInitValue() {
+        if (value != null) {
+            return value.toString();
         }
+        return null;
     }
 
-
     @Override
     public String getSignature() {
         return super.getType().getSignature();
     }
 
-    private List<FieldObserver> observers;
-
-
-    /** Add observer for this object.
+    /**
+     * Return value as defined by given BCELComparator strategy. By default return the hashcode of the field's name XOR
+     * signature.
+     *
+     * @see Object#hashCode()
      */
-    public void addObserver( final FieldObserver o ) {
-        if (observers == null) {
-            observers = new ArrayList<>();
-        }
-        observers.add(o);
+    @Override
+    public int hashCode() {
+        return bcelComparator.hashCode(this);
     }
 
-
-    /** Remove observer for this object.
+    /**
+     * Remove observer for this object.
      */
-    public void removeObserver( final FieldObserver o ) {
+    public void removeObserver(final FieldObserver o) {
         if (observers != null) {
             observers.remove(o);
         }
     }
 
+    public void setInitValue(final boolean b) {
+        checkType(Type.BOOLEAN);
+        if (b) {
+            value = Integer.valueOf(1);
+        }
+    }
 
-    /** Call notify() method on all observers. This method is not called
-     * automatically whenever the state has changed, but has to be
-     * called by the user after he has finished editing the object.
-     */
-    public void update() {
-        if (observers != null) {
-            for (final FieldObserver observer : observers ) {
-                observer.notify(this);
-            }
+    public void setInitValue(final byte b) {
+        checkType(Type.BYTE);
+        if (b != 0) {
+            value = Integer.valueOf(b);
         }
     }
 
+    public void setInitValue(final char c) {
+        checkType(Type.CHAR);
+        if (c != 0) {
+            value = Integer.valueOf(c);
+        }
+    }
 
-    public String getInitValue() {
-        if (value != null) {
-            return value.toString();
+    public void setInitValue(final double d) {
+        checkType(Type.DOUBLE);
+        if (d != 0.0) {
+            value = Double.valueOf(d);
+        }
+    }
+
+    public void setInitValue(final float f) {
+        checkType(Type.FLOAT);
+        if (f != 0.0) {
+            value = Float.valueOf(f);
+        }
+    }
+
+    public void setInitValue(final int i) {
+        checkType(Type.INT);
+        if (i != 0) {
+            value = Integer.valueOf(i);
+        }
+    }
+
+    public void setInitValue(final long l) {
+        checkType(Type.LONG);
+        if (l != 0L) {
+            value = Long.valueOf(l);
+        }
+    }
+
+    public void setInitValue(final short s) {
+        checkType(Type.SHORT);
+        if (s != 0) {
+            value = Integer.valueOf(s);
         }
-        return null;
     }
 
+    /**
+     * Set (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically.
+     */
+    public void setInitValue(final String str) {
+        checkType(ObjectType.getInstance("java.lang.String"));
+        if (str != null) {
+            value = str;
+        }
+    }
+
+    private void setValue(final int index) {
+        final ConstantPool cp = super.getConstantPool().getConstantPool();
+        final Constant c = cp.getConstant(index);
+        value = ((ConstantObject) c).getConstantValue(cp);
+    }
 
     /**
-     * Return string representation close to declaration format,
-     * `public static final short MAX = 100', e.g..
+     * Return string representation close to declaration format, 'public static final short MAX = 100', e.g..
      *
      * @return String representation of field
      */
@@ -320,7 +321,7 @@ public final String toString() {
         String signature;
         String access; // Short cuts to constant pool
         access = Utility.accessToString(super.getAccessFlags());
-        access = access.isEmpty() ? "" : (access + " ");
+        access = access.isEmpty() ? "" : access + " ";
         signature = super.getType().toString();
         name = getName();
         final StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber
@@ -332,53 +333,15 @@ public final String toString() {
         return buf.toString();
     }
 
-
-    /** @return deep copy of this field
-     */
-    public FieldGen copy( final ConstantPoolGen cp ) {
-        final FieldGen fg = (FieldGen) clone();
-        fg.setConstantPool(cp);
-        return fg;
-    }
-
-
     /**
-     * @return Comparison strategy object
+     * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but
+     * has to be called by the user after they have finished editing the object.
      */
-    public static BCELComparator getComparator() {
-        return bcelComparator;
-    }
-
-
-    /**
-     * @param comparator Comparison strategy object
-     */
-    public static void setComparator( final BCELComparator comparator ) {
-        bcelComparator = comparator;
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default two FieldGen objects are said to be equal when
-     * their names and signatures are equal.
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals( final Object obj ) {
-        return bcelComparator.equals(this, obj);
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default return the hashcode of the field's name XOR signature.
-     *
-     * @see java.lang.Object#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        return bcelComparator.hashCode(this);
+    public void update() {
+        if (observers != null) {
+            for (final FieldObserver observer : observers) {
+                observer.notify(this);
+            }
+        }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java
index 1c2e37f7d8b..6555392e9d4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGenOrMethodGen.java
@@ -20,6 +20,7 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import com.sun.org.apache.bcel.internal.Const;
@@ -27,109 +28,128 @@
 import com.sun.org.apache.bcel.internal.classfile.Attribute;
 
 /**
- * Super class for FieldGen and MethodGen objects, since they have
- * some methods in common!
+ * Super class for FieldGen and MethodGen objects, since they have some methods in common!
  *
  * @LastModified: May 2021
  */
 public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAndTyped, Cloneable {
 
-    private String name;
-    private Type type;
-    private ConstantPoolGen cp;
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected String name;
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected Type type;
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected ConstantPoolGen cp;
 
     private final List<Attribute> attributeList = new ArrayList<>();
 
     // @since 6.0
     private final List<AnnotationEntryGen> annotationList = new ArrayList<>();
 
-
     protected FieldGenOrMethodGen() {
     }
 
-
     /**
      * @since 6.0
      */
-    protected FieldGenOrMethodGen(final int access_flags) { // TODO could this be package protected?
-        super(access_flags);
+    protected FieldGenOrMethodGen(final int accessFlags) { // TODO could this be package protected?
+        super(accessFlags);
     }
 
-    @Override
-    public void setType( final Type type ) { // TODO could be package-protected?
-        if (type.getType() == Const.T_ADDRESS) {
-            throw new IllegalArgumentException("Type can not be " + type);
-        }
-        this.type = type;
+    protected void addAll(final Attribute[] attrs) {
+        Collections.addAll(attributeList, attrs);
     }
 
-
-    @Override
-    public Type getType() {
-        return type;
+    /**
+     * @since 6.0
+     */
+    public void addAnnotationEntry(final AnnotationEntryGen ag) {
+        annotationList.add(ag);
     }
 
-
-    /** @return name of method/field.
+    /**
+     * Add an attribute to this method. Currently, the JVM knows about the 'Code', 'ConstantValue', 'Synthetic' and
+     * 'Exceptions' attributes. Other attributes will be ignored by the JVM but do no harm.
+     *
+     * @param a attribute to be added
      */
-    @Override
-    public String getName() {
-        return name;
+    public void addAttribute(final Attribute a) {
+        attributeList.add(a);
     }
 
-
     @Override
-    public void setName( final String name ) { // TODO could be package-protected?
-        this.name = name;
+    public Object clone() {
+        try {
+            return super.clone();
+        } catch (final CloneNotSupportedException e) {
+            throw new Error("Clone Not Supported"); // never happens
+        }
     }
 
-
-    public ConstantPoolGen getConstantPool() {
-        return cp;
+    public AnnotationEntryGen[] getAnnotationEntries() {
+        return annotationList.toArray(AnnotationEntryGen.EMPTY_ARRAY);
     }
 
-
-    public void setConstantPool( final ConstantPoolGen cp ) { // TODO could be package-protected?
-        this.cp = cp;
+    /**
+     * @return all attributes of this method.
+     */
+    public Attribute[] getAttributes() {
+        return attributeList.toArray(Attribute.EMPTY_ARRAY);
     }
 
+    public ConstantPoolGen getConstantPool() {
+        return cp;
+    }
 
     /**
-     * Add an attribute to this method. Currently, the JVM knows about
-     * the `Code', `ConstantValue', `Synthetic' and `Exceptions'
-     * attributes. Other attributes will be ignored by the JVM but do no
-     * harm.
-     *
-     * @param a attribute to be added
+     * @return name of method/field.
      */
-    public void addAttribute( final Attribute a ) {
-        attributeList.add(a);
+    @Override
+    public String getName() {
+        return name;
     }
 
     /**
-     * @since 6.0
+     * @return signature of method/field.
      */
-    public void addAnnotationEntry(final AnnotationEntryGen ag)
-    {
-        annotationList.add(ag);
-    }
+    public abstract String getSignature();
 
+    @Override
+    public Type getType() {
+        return type;
+    }
 
     /**
-     * Remove an attribute.
+     * @since 6.0
      */
-    public void removeAttribute( final Attribute a ) {
-        attributeList.remove(a);
+    public void removeAnnotationEntries() {
+        annotationList.clear();
     }
 
     /**
      * @since 6.0
      */
-    public void removeAnnotationEntry(final AnnotationEntryGen ag)
-    {
+    public void removeAnnotationEntry(final AnnotationEntryGen ag) {
         annotationList.remove(ag);
     }
 
+    /**
+     * Remove an attribute.
+     */
+    public void removeAttribute(final Attribute a) {
+        attributeList.remove(a);
+    }
 
     /**
      * Remove all attributes.
@@ -138,38 +158,20 @@ public void removeAttributes() {
         attributeList.clear();
     }
 
-    /**
-     * @since 6.0
-     */
-    public void removeAnnotationEntries()
-    {
-        annotationList.clear();
+    public void setConstantPool(final ConstantPoolGen cp) { // TODO could be package-protected?
+        this.cp = cp;
     }
 
-
-    /**
-     * @return all attributes of this method.
-     */
-    public Attribute[] getAttributes() {
-        return attributeList.toArray(new Attribute[0]);
+    @Override
+    public void setName(final String name) { // TODO could be package-protected?
+        this.name = name;
     }
 
-    public AnnotationEntryGen[] getAnnotationEntries() {
-        return annotationList.toArray(new AnnotationEntryGen[0]);
-      }
-
-
-    /** @return signature of method/field.
-     */
-    public abstract String getSignature();
-
-
     @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (final CloneNotSupportedException e) {
-            throw new Error("Clone Not Supported"); // never happens
+    public void setType(final Type type) { // TODO could be package-protected?
+        if (type.getType() == Const.T_ADDRESS) {
+            throw new IllegalArgumentException("Type can not be " + type);
         }
+        this.type = type;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java
index 604a47ca330..368d07ec99f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldInstruction.java
@@ -25,18 +25,15 @@
 
 /**
  * Super class for the GET/PUTxxx family of instructions.
- *
  */
 public abstract class FieldInstruction extends FieldOrMethod {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     FieldInstruction() {
     }
 
-
     /**
      * @param index to constant pool
      */
@@ -44,42 +41,40 @@ protected FieldInstruction(final short opcode, final int index) {
         super(opcode, index);
     }
 
-
     /**
-     * @return mnemonic for instruction with symbolic references resolved
+     * @return name of referenced field.
      */
-    @Override
-    public String toString( final ConstantPool cp ) {
-        return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " "
-                + cp.constantToString(super.getIndex(), com.sun.org.apache.bcel.internal.Const.CONSTANT_Fieldref);
+    public String getFieldName(final ConstantPoolGen cpg) {
+        return getName(cpg);
     }
 
-
-    /** @return size of field (1 or 2)
+    /**
+     * @return size of field (1 or 2)
      */
-    protected int getFieldSize( final ConstantPoolGen cpg ) {
+    protected int getFieldSize(final ConstantPoolGen cpg) {
         return Type.size(Type.getTypeSize(getSignature(cpg)));
     }
 
-
-    /** @return return type of referenced field
+    /**
+     * @return type of field
      */
-    @Override
-    public Type getType( final ConstantPoolGen cpg ) {
-        return getFieldType(cpg);
+    public Type getFieldType(final ConstantPoolGen cpg) {
+        return Type.getType(getSignature(cpg));
     }
 
-
-    /** @return type of field
+    /**
+     * @return return type of referenced field
      */
-    public Type getFieldType( final ConstantPoolGen cpg ) {
-        return Type.getType(getSignature(cpg));
+    @Override
+    public Type getType(final ConstantPoolGen cpg) {
+        return getFieldType(cpg);
     }
 
-
-    /** @return name of referenced field.
+    /**
+     * @return mnemonic for instruction with symbolic references resolved
      */
-    public String getFieldName( final ConstantPoolGen cpg ) {
-        return getName(cpg);
+    @Override
+    public String toString(final ConstantPool cp) {
+        return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + cp.constantToString(super.getIndex(), com.sun.org.apache.bcel.internal.Const.CONSTANT_Fieldref);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldObserver.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldObserver.java
index 4bcbee8d922..a207a098522 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldObserver.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldObserver.java
@@ -22,11 +22,10 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Imnplement this interface if you're interested in changes to a FieldGen object
- * and register yourself with addObserver().
- *
+ * Imnplement this interface if you're interested in changes to a FieldGen object and register yourself with
+ * addObserver().
  */
 public interface FieldObserver {
 
-    void notify( FieldGen field );
+    void notify(FieldGen field);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java
index 182c3972601..1c646f48292 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java
@@ -26,23 +26,20 @@
 import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType;
 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
 import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
+import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
- * Super class for InvokeInstruction and FieldInstruction, since they have
- * some methods in common!
- *
+ * Super class for InvokeInstruction and FieldInstruction, since they have some methods in common!
  */
 public abstract class FieldOrMethod extends CPInstruction implements LoadClass {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     FieldOrMethod() {
         // no init
     }
 
-
     /**
      * @param index to constant pool
      */
@@ -50,36 +47,12 @@ protected FieldOrMethod(final short opcode, final int index) {
         super(opcode, index);
     }
 
-
-    /** @return signature of referenced method/field.
-     */
-    public String getSignature(final ConstantPoolGen cpg) {
-        final ConstantPool cp = cpg.getConstantPool();
-        final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
-        final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
-        return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
-    }
-
-
-    /** @return name of referenced method/field.
-     */
-    public String getName(final ConstantPoolGen cpg) {
-        final ConstantPool cp = cpg.getConstantPool();
-        final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
-        final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
-        return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
-    }
-
-
     /**
      * @return name of the referenced class/interface
-     * @deprecated If the instruction references an array class,
-     *    this method will return "java.lang.Object".
-     *    For code generated by Java 1.5, this answer is
-     *    sometimes wrong (e.g., if the "clone()" method is
-     *    called on an array).  A better idea is to use
-     *    the {@link #getReferenceType(ConstantPoolGen)} method, which correctly distinguishes
-     *    between class types and array types.
+     * @deprecated If the instruction references an array class, this method will return "java.lang.Object". For code
+     *             generated by Java 1.5, this answer is sometimes wrong (e.g., if the "clone()" method is called on an
+     *             array). A better idea is to use the {@link #getReferenceType(ConstantPoolGen)} method, which correctly
+     *             distinguishes between class types and array types.
      *
      */
     @Deprecated
@@ -91,28 +64,50 @@ public String getClassName(final ConstantPoolGen cpg) {
             // Turn array classes into java.lang.Object.
             return "java.lang.Object";
         }
-        return className.replace('/', '.');
+        return Utility.pathToPackage(className);
     }
 
-
-    /** @return type of the referenced class/interface
-     * @deprecated If the instruction references an array class,
-     *    the ObjectType returned will be invalid.  Use
-     *    getReferenceType() instead.
+    /**
+     * @return type of the referenced class/interface
+     * @deprecated If the instruction references an array class, the ObjectType returned will be invalid. Use
+     *             getReferenceType() instead.
      */
     @Deprecated
     public ObjectType getClassType(final ConstantPoolGen cpg) {
         return ObjectType.getInstance(getClassName(cpg));
     }
 
+    /**
+     * Gets the ObjectType of the method return or field.
+     *
+     * @return type of the referenced class/interface
+     * @throws ClassGenException when the field is (or method returns) an array,
+     */
+    @Override
+    public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
+        final ReferenceType rt = getReferenceType(cpg);
+        if (rt instanceof ObjectType) {
+            return (ObjectType) rt;
+        }
+        throw new ClassGenException(rt.getClass().getCanonicalName() + " " + rt.getSignature() + " does not represent an ObjectType");
+    }
+
+    /**
+     * @return name of referenced method/field.
+     */
+    public String getName(final ConstantPoolGen cpg) {
+        final ConstantPool cp = cpg.getConstantPool();
+        final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
+        final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
+        return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
+    }
 
     /**
-     * Gets the reference type representing the class, interface,
-     * or array class referenced by the instruction.
+     * Gets the reference type representing the class, interface, or array class referenced by the instruction.
+     *
      * @param cpg the ConstantPoolGen used to create the instruction
-     * @return an ObjectType (if the referenced class type is a class
-     *   or interface), or an ArrayType (if the referenced class
-     *   type is an array class)
+     * @return an ObjectType (if the referenced class type is a class or interface), or an ArrayType (if the referenced
+     *         class type is an array class)
      */
     public ReferenceType getReferenceType(final ConstantPoolGen cpg) {
         final ConstantPool cp = cpg.getConstantPool();
@@ -121,24 +116,17 @@ public ReferenceType getReferenceType(final ConstantPoolGen cpg) {
         if (className.startsWith("[")) {
             return (ArrayType) Type.getType(className);
         }
-        className = className.replace('/', '.');
+        className = Utility.pathToPackage(className);
         return ObjectType.getInstance(className);
     }
 
-
     /**
-     * Gets the ObjectType of the method return or field.
-     *
-     * @return type of the referenced class/interface
-     * @throws ClassGenException when the field is (or method returns) an array,
+     * @return signature of referenced method/field.
      */
-    @Override
-    public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
-        final ReferenceType rt = getReferenceType(cpg);
-        if (rt instanceof ObjectType) {
-            return (ObjectType) rt;
-        }
-        throw new ClassGenException(rt.getClass().getCanonicalName() + " " +
-                rt.getSignature() + " does not represent an ObjectType");
+    public String getSignature(final ConstantPoolGen cpg) {
+        final ConstantPool cp = cpg.getConstantPool();
+        final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
+        final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
+        return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETFIELD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETFIELD.java
index 1e1a652daec..bc4e5b11674 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETFIELD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETFIELD.java
@@ -25,51 +25,37 @@
 
 /**
  * GETFIELD - Fetch field from object
- * <PRE>Stack: ..., objectref -&gt; ..., value</PRE>
+ *
+ * <PRE>
+ * Stack: ..., objectref -&gt; ..., value
+ * </PRE>
+ *
  * OR
- * <PRE>Stack: ..., objectref -&gt; ..., value.word1, value.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., objectref -&gt; ..., value.word1, value.word2
+ * </PRE>
  */
-public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer,
-        StackProducer {
+public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer, StackProducer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     GETFIELD() {
     }
 
-
     public GETFIELD(final int index) {
         super(Const.GETFIELD, index);
     }
 
-
-    @Override
-    public int produceStack( final ConstantPoolGen cpg ) {
-        return getFieldSize(cpg);
-    }
-
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
-            ExceptionConst.NULL_POINTER_EXCEPTION,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitStackConsumer(this);
         v.visitStackProducer(this);
@@ -80,4 +66,15 @@ public void accept( final Visitor v ) {
         v.visitFieldInstruction(this);
         v.visitGETFIELD(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION,
+            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
+    }
+
+    @Override
+    public int produceStack(final ConstantPoolGen cpg) {
+        return getFieldSize(cpg);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java
index a8ff0989fbb..b8c4a4a3560 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETSTATIC.java
@@ -26,49 +26,37 @@
 
 /**
  * GETSTATIC - Fetch static field from class
- * <PRE>Stack: ..., -&gt; ..., value</PRE>
+ *
+ * <PRE>
+ * Stack: ..., -&gt; ..., value
+ * </PRE>
+ *
  * OR
- * <PRE>Stack: ..., -&gt; ..., value.word1, value.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., -&gt; ..., value.word1, value.word2
+ * </PRE>
  */
 public class GETSTATIC extends FieldInstruction implements PushInstruction, ExceptionThrower {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     GETSTATIC() {
     }
 
-
     public GETSTATIC(final int index) {
         super(Const.GETSTATIC, index);
     }
 
-
-    @Override
-    public int produceStack( final ConstantPoolGen cpg ) {
-        return getFieldSize(cpg);
-    }
-
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitPushInstruction(this);
         v.visitExceptionThrower(this);
@@ -79,4 +67,14 @@ public void accept( final Visitor v ) {
         v.visitFieldInstruction(this);
         v.visitGETSTATIC(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
+    }
+
+    @Override
+    public int produceStack(final ConstantPoolGen cpg) {
+        return getFieldSize(cpg);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO.java
index 64b7de98d62..cd76aae7981 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO.java
@@ -26,77 +26,70 @@
 
 /**
  * GOTO - Branch always (to relative offset, not absolute address)
- *
  */
 public class GOTO extends GotoInstruction implements VariableLengthInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     GOTO() {
     }
 
-
     public GOTO(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.GOTO, target);
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitVariableLengthInstruction(this);
+        v.visitUnconditionalBranch(this);
+        v.visitBranchInstruction(this);
+        v.visitGotoInstruction(this);
+        v.visitGOTO(this);
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         super.setIndex(getTargetOffset());
-        final short _opcode = getOpcode();
-        if (_opcode == com.sun.org.apache.bcel.internal.Const.GOTO) {
+        final short opcode = getOpcode();
+        if (opcode == com.sun.org.apache.bcel.internal.Const.GOTO) {
             super.dump(out);
         } else { // GOTO_W
             super.setIndex(getTargetOffset());
-            out.writeByte(_opcode);
+            out.writeByte(opcode);
             out.writeInt(super.getIndex());
         }
     }
 
-
     /**
-     * Called in pass 2 of InstructionList.setPositions() in order to update
-     * the branch target, that may shift due to variable length instructions.
+     * Called in pass 2 of InstructionList.setPositions() in order to update the branch target, that may shift due to
+     * variable length instructions.
      *
      * @param offset additional offset caused by preceding (variable length) instructions
-     * @param max_offset the maximum offset that may be caused by these instructions
+     * @param maxOffset the maximum offset that may be caused by these instructions
      * @return additional offset caused by possible change of this instruction's length
      */
     @Override
-    protected int updatePosition( final int offset, final int max_offset ) {
+    protected int updatePosition(final int offset, final int maxOffset) {
         final int i = getTargetOffset(); // Depending on old position value
         setPosition(getPosition() + offset); // Position may be shifted by preceding expansions
-        if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate)
+        if (Math.abs(i) >= Short.MAX_VALUE - maxOffset) { // to large for short (estimate)
             super.setOpcode(com.sun.org.apache.bcel.internal.Const.GOTO_W);
-            final short old_length = (short) super.getLength();
+            final short oldLength = (short) super.getLength();
             super.setLength(5);
-            return super.getLength() - old_length;
+            return super.getLength() - oldLength;
         }
         return 0;
     }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitVariableLengthInstruction(this);
-        v.visitUnconditionalBranch(this);
-        v.visitBranchInstruction(this);
-        v.visitGotoInstruction(this);
-        v.visitGOTO(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO_W.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO_W.java
index 5c97a0c9d55..df4c06be09a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO_W.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GOTO_W.java
@@ -28,59 +28,52 @@
 
 /**
  * GOTO_W - Branch always (to relative offset, not absolute address)
- *
  */
 public class GOTO_W extends GotoInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     GOTO_W() {
     }
 
-
     public GOTO_W(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.GOTO_W, target);
         super.setLength(5);
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitUnconditionalBranch(this);
+        v.visitBranchInstruction(this);
+        v.visitGotoInstruction(this);
+        v.visitGOTO_W(this);
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         super.setIndex(getTargetOffset());
         out.writeByte(super.getOpcode());
         out.writeInt(super.getIndex());
     }
 
-
     /**
      * Read needed data (e.g. index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         super.setIndex(bytes.readInt());
         super.setLength(5);
     }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitUnconditionalBranch(this);
-        v.visitBranchInstruction(this);
-        v.visitGotoInstruction(this);
-        v.visitGOTO_W(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java
index 766f68a95f1..b261ca584b6 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GotoInstruction.java
@@ -23,19 +23,16 @@
 
 /**
  * Super class for GOTO
- *
  */
 public abstract class GotoInstruction extends BranchInstruction implements UnconditionalBranch {
 
-    GotoInstruction(final short opcode, final InstructionHandle target) {
-        super(opcode, target);
-    }
-
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     GotoInstruction() {
     }
+
+    GotoInstruction(final short opcode, final InstructionHandle target) {
+        super(opcode, target);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2B.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2B.java
index 0daab14fccb..0b8c9dd529e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2B.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2B.java
@@ -23,28 +23,28 @@
 
 /**
  * I2B - Convert int to byte
- * <PRE>Stack: ..., value -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result
+ * </PRE>
  */
 public class I2B extends ConversionInstruction {
 
-    /** Convert int to byte
+    /**
+     * Convert int to byte
      */
     public I2B() {
         super(com.sun.org.apache.bcel.internal.Const.I2B);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2C.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2C.java
index 1222026e4ff..b5c6532a592 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2C.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2C.java
@@ -23,28 +23,28 @@
 
 /**
  * I2C - Convert int to char
- * <PRE>Stack: ..., value -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result
+ * </PRE>
  */
 public class I2C extends ConversionInstruction {
 
-    /** Convert int to char
+    /**
+     * Convert int to char
      */
     public I2C() {
         super(com.sun.org.apache.bcel.internal.Const.I2C);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2D.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2D.java
index 70c83845e69..e73270a5874 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2D.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2D.java
@@ -23,28 +23,28 @@
 
 /**
  * I2D - Convert int to double
- * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class I2D extends ConversionInstruction {
 
-    /** Convert int to double
+    /**
+     * Convert int to double
      */
     public I2D() {
         super(com.sun.org.apache.bcel.internal.Const.I2D);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2F.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2F.java
index f4b10e91d27..dc7df8c6d48 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2F.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2F.java
@@ -23,28 +23,28 @@
 
 /**
  * I2F - Convert int to float
- * <PRE>Stack: ..., value -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result
+ * </PRE>
  */
 public class I2F extends ConversionInstruction {
 
-    /** Convert int to float
+    /**
+     * Convert int to float
      */
     public I2F() {
         super(com.sun.org.apache.bcel.internal.Const.I2F);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2L.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2L.java
index 0ab03dd8413..e0a8e81e1cd 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2L.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2L.java
@@ -23,28 +23,28 @@
 
 /**
  * I2L - Convert int to long
- * <PRE>Stack: ..., value -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class I2L extends ConversionInstruction {
 
-    /** Convert int to long
+    /**
+     * Convert int to long
      */
     public I2L() {
         super(com.sun.org.apache.bcel.internal.Const.I2L);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2S.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2S.java
index 7fc76358385..04fa0e62a06 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2S.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/I2S.java
@@ -23,8 +23,10 @@
 
 /**
  * I2S - Convert int to short
- * <PRE>Stack: ..., value -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result
+ * </PRE>
  */
 public class I2S extends ConversionInstruction {
 
@@ -32,17 +34,14 @@ public I2S() {
         super(com.sun.org.apache.bcel.internal.Const.I2S);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IADD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IADD.java
index 2e454f30c6b..ad5e109af8c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IADD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IADD.java
@@ -23,28 +23,28 @@
 
 /**
  * IADD - Add ints
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class IADD extends ArithmeticInstruction {
 
-    /** Add ints
+    /**
+     * Add ints
      */
     public IADD() {
         super(com.sun.org.apache.bcel.internal.Const.IADD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IALOAD.java
index 79b6a66deb1..b9f39c13d51 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IALOAD.java
@@ -23,8 +23,10 @@
 
 /**
  * IALOAD - Load int from array
- * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; ..., value
+ * </PRE>
  */
 public class IALOAD extends ArrayInstruction implements StackProducer {
 
@@ -35,17 +37,14 @@ public IALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.IALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IAND.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IAND.java
index be4420e4f43..4fe036cc550 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IAND.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IAND.java
@@ -23,8 +23,10 @@
 
 /**
  * IAND - Bitwise AND int
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class IAND extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public IAND() {
         super(com.sun.org.apache.bcel.internal.Const.IAND);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IASTORE.java
index ff954de48ed..62cded23fe4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IASTORE.java
@@ -22,9 +22,11 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * IASTORE -  Store into int array
- * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
+ * IASTORE - Store into int array
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value -&gt; ...
+ * </PRE>
  */
 public class IASTORE extends ArrayInstruction implements StackConsumer {
 
@@ -35,17 +37,14 @@ public IASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.IASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ICONST.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ICONST.java
index 4c00097cb69..5effd7edcd9 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ICONST.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ICONST.java
@@ -22,61 +22,56 @@
 /**
  * ICONST - Push value between -1, ..., 5, other values cause an exception
  *
- * <PRE>Stack: ... -&gt; ..., </PRE>
+ * <PRE>
+ * Stack: ... -&gt; ...,
+ * </PRE>
  *
  */
 public class ICONST extends Instruction implements ConstantPushInstruction {
 
-    private int value;
-
+    private final int value;
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ICONST() {
+        this(0);
     }
 
-
     public ICONST(final int i) {
         super(com.sun.org.apache.bcel.internal.Const.ICONST_0, (short) 1);
-        if ((i >= -1) && (i <= 5)) {
-            super.setOpcode((short) (com.sun.org.apache.bcel.internal.Const.ICONST_0 + i)); // Even works for i == -1
-        } else {
+        if (i < -1 || i > 5) {
             throw new ClassGenException("ICONST can be used only for value between -1 and 5: " + i);
         }
+        super.setOpcode((short) (com.sun.org.apache.bcel.internal.Const.ICONST_0 + i)); // Even works for i == -1
         value = i;
     }
 
-
-    @Override
-    public Number getValue() {
-        return Integer.valueOf(value);
-    }
-
-
-    /** @return Type.INT
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.INT;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitPushInstruction(this);
         v.visitStackProducer(this);
         v.visitTypedInstruction(this);
         v.visitConstantPushInstruction(this);
         v.visitICONST(this);
     }
+
+    /**
+     * @return Type.INT
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.INT;
+    }
+
+    @Override
+    public Number getValue() {
+        return Integer.valueOf(value);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IDIV.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IDIV.java
index 078eefe1113..e23968c9ae3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IDIV.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IDIV.java
@@ -24,39 +24,29 @@
 
 /**
  * IDIV - Divide ints
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class IDIV extends ArithmeticInstruction implements ExceptionThrower {
 
-    /** Divide ints
+    /**
+     * Divide ints
      */
     public IDIV() {
         super(com.sun.org.apache.bcel.internal.Const.IDIV);
     }
 
-
-    /** @return exceptions this instruction may cause
-     */
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.ARITHMETIC_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
@@ -64,4 +54,12 @@ public void accept( final Visitor v ) {
         v.visitArithmeticInstruction(this);
         v.visitIDIV(this);
     }
+
+    /**
+     * @return exceptions this instruction may cause
+     */
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.ARITHMETIC_EXCEPTION};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFEQ.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFEQ.java
index 7518c24ee31..c44d0f57dfe 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFEQ.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFEQ.java
@@ -24,46 +24,41 @@
 /**
  * IFEQ - Branch if int comparison with zero succeeds
  *
- * <PRE>Stack: ..., value -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class IFEQ extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFEQ() {
     }
 
-
     public IFEQ(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFEQ, target);
     }
 
-
-    /**
-     * @return negation of instruction, e.g. IFEQ.negate() == IFNE
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFNE(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFEQ(this);
     }
+
+    /**
+     * @return negation of instruction, e.g. IFEQ.negate() == IFNE
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFNE(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGE.java
index ed5337de2ba..53e32a57ba3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGE.java
@@ -24,46 +24,41 @@
 /**
  * IFGE - Branch if int comparison with zero succeeds
  *
- * <PRE>Stack: ..., value -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class IFGE extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFGE() {
     }
 
-
     public IFGE(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFGE, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFLT(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFGE(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFLT(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGT.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGT.java
index 08a9788779b..23ab44754f6 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGT.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFGT.java
@@ -24,46 +24,41 @@
 /**
  * IFGT - Branch if int comparison with zero succeeds
  *
- * <PRE>Stack: ..., value -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class IFGT extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFGT() {
     }
 
-
     public IFGT(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFGT, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFLE(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFGT(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFLE(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLE.java
index 3eeced2aa4f..0bd68bd1be7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLE.java
@@ -24,46 +24,41 @@
 /**
  * IFLE - Branch if int comparison with zero succeeds
  *
- * <PRE>Stack: ..., value -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class IFLE extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFLE() {
     }
 
-
     public IFLE(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFLE, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFGT(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFLE(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFGT(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLT.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLT.java
index 36d086093fc..0c1589e95b8 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLT.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFLT.java
@@ -24,46 +24,41 @@
 /**
  * IFLT - Branch if int comparison with zero succeeds
  *
- * <PRE>Stack: ..., value -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class IFLT extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFLT() {
     }
 
-
     public IFLT(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFLT, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFGE(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFLT(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFGE(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNE.java
index 46a4ed659fa..91075bc66d8 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNE.java
@@ -24,46 +24,41 @@
 /**
  * IFNE - Branch if int comparison with zero succeeds
  *
- * <PRE>Stack: ..., value -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class IFNE extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFNE() {
     }
 
-
     public IFNE(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFNE, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFEQ(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFNE(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFEQ(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java
index 221ef55f1d1..342779a9b4f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNONNULL.java
@@ -24,46 +24,41 @@
 /**
  * IFNONNULL - Branch if reference is not null
  *
- * <PRE>Stack: ..., reference -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., reference -&gt; ...
+ * </PRE>
  */
 public class IFNONNULL extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFNONNULL() {
     }
 
-
     public IFNONNULL(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFNONNULL, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFNULL(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFNONNULL(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFNULL(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNULL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNULL.java
index c5d01005c19..b680033096d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNULL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IFNULL.java
@@ -24,46 +24,41 @@
 /**
  * IFNULL - Branch if reference is not null
  *
- * <PRE>Stack: ..., reference -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., reference -&gt; ...
+ * </PRE>
  */
 public class IFNULL extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IFNULL() {
     }
 
-
     public IFNULL(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IFNULL, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IFNONNULL(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIFNULL(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IFNONNULL(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java
index a01749f90d1..9f14fb58909 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPEQ.java
@@ -24,46 +24,41 @@
 /**
  * IF_ACMPEQ - Branch if reference comparison succeeds
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ACMPEQ extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ACMPEQ() {
     }
 
-
     public IF_ACMPEQ(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ACMPEQ, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ACMPNE(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ACMPEQ(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ACMPNE(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java
index 3115e4f70ee..536abe40d64 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ACMPNE.java
@@ -24,46 +24,41 @@
 /**
  * IF_ACMPNE - Branch if reference comparison doesn't succeed
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ACMPNE extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ACMPNE() {
     }
 
-
     public IF_ACMPNE(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ACMPNE, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ACMPEQ(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ACMPNE(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ACMPEQ(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java
index e9850f886c9..a3fa883dfb2 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPEQ.java
@@ -24,46 +24,41 @@
 /**
  * IF_ICMPEQ - Branch if int comparison succeeds
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ICMPEQ extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ICMPEQ() {
     }
 
-
     public IF_ICMPEQ(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ICMPEQ, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ICMPNE(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ICMPEQ(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ICMPNE(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java
index 59fb4e1c089..8848da01b49 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGE.java
@@ -24,46 +24,41 @@
 /**
  * IF_ICMPGE - Branch if int comparison succeeds
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ICMPGE extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ICMPGE() {
     }
 
-
     public IF_ICMPGE(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ICMPGE, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ICMPLT(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ICMPGE(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ICMPLT(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java
index b9e4b379e6f..b1145cc9491 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPGT.java
@@ -24,46 +24,41 @@
 /**
  * IF_ICMPGT - Branch if int comparison succeeds
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ICMPGT extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ICMPGT() {
     }
 
-
     public IF_ICMPGT(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ICMPGT, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ICMPLE(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ICMPGT(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ICMPLE(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java
index 8227630a88f..54eed61742d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLE.java
@@ -24,46 +24,41 @@
 /**
  * IF_ICMPLE - Branch if int comparison succeeds
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ICMPLE extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ICMPLE() {
     }
 
-
     public IF_ICMPLE(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ICMPLE, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ICMPGT(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ICMPLE(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ICMPGT(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java
index 92800955831..7c159f4b56a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPLT.java
@@ -24,46 +24,41 @@
 /**
  * IF_ICMPLT - Branch if int comparison succeeds
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ICMPLT extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ICMPLT() {
     }
 
-
     public IF_ICMPLT(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ICMPLT, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ICMPGE(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ICMPLT(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ICMPGE(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java
index e1de79ab77e..1c1f9800a47 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IF_ICMPNE.java
@@ -24,46 +24,41 @@
 /**
  * IF_ICMPNE - Branch if int comparison doesn't succeed
  *
- * <PRE>Stack: ..., value1, value2 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ...
+ * </PRE>
  */
 public class IF_ICMPNE extends IfInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IF_ICMPNE() {
     }
 
-
     public IF_ICMPNE(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.IF_ICMPNE, target);
     }
 
-
-    /**
-     * @return negation of instruction
-     */
-    @Override
-    public IfInstruction negate() {
-        return new IF_ICMPEQ(super.getTarget());
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitBranchInstruction(this);
         v.visitIfInstruction(this);
         v.visitIF_ICMPNE(this);
     }
+
+    /**
+     * @return negation of instruction
+     */
+    @Override
+    public IfInstruction negate() {
+        return new IF_ICMPEQ(super.getTarget());
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IINC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IINC.java
index 7b4e80c274c..aeaa2d8cdd2 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IINC.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IINC.java
@@ -24,47 +24,56 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.util.ByteSequence;
 
 /**
  * IINC - Increment local variable by constant
- *
  */
 public class IINC extends LocalVariableInstruction {
 
     private boolean wide;
     private int c;
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IINC() {
     }
 
-
     /**
      * @param n index of local variable
      * @param c increment factor
      */
     public IINC(final int n, final int c) {
-        super(); // Default behavior of LocalVariableInstruction causes error
-        super.setOpcode(com.sun.org.apache.bcel.internal.Const.IINC);
+        // Default behavior of LocalVariableInstruction causes error
+        super.setOpcode(Const.IINC);
         super.setLength((short) 3);
         setIndex(n); // May set wide as side effect
         setIncrement(c);
     }
 
+    /**
+     * Calls corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitLocalVariableInstruction(this);
+        v.visitIINC(this);
+    }
 
     /**
-     * Dump instruction as byte code to stream out.
+     * Dumps instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         if (wide) {
-            out.writeByte(com.sun.org.apache.bcel.internal.Const.WIDE);
+            out.writeByte(Const.WIDE);
         }
         out.writeByte(super.getOpcode());
         if (wide) {
@@ -76,27 +85,26 @@ public void dump( final DataOutputStream out ) throws IOException {
         }
     }
 
-
-    private void setWide() {
-        wide = super.getIndex() > com.sun.org.apache.bcel.internal.Const.MAX_BYTE;
-        if (c > 0) {
-            wide = wide || (c > Byte.MAX_VALUE);
-        } else {
-            wide = wide || (c < Byte.MIN_VALUE);
-        }
-        if (wide) {
-            super.setLength(6); // wide byte included
-        } else {
-            super.setLength(3);
-        }
+    /**
+     * @return increment factor
+     */
+    public final int getIncrement() {
+        return c;
     }
 
+    /**
+     * @return int type
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.INT;
+    }
 
     /**
-     * Read needed data (e.g. index) from file.
+     * Reads needed data (e.g. index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         this.wide = wide;
         if (wide) {
             super.setLength(6);
@@ -109,21 +117,19 @@ protected void initFromFile( final ByteSequence bytes, final boolean wide ) thro
         }
     }
 
-
     /**
-     * @return mnemonic for instruction
+     * Sets increment factor.
      */
-    @Override
-    public String toString( final boolean verbose ) {
-        return super.toString(verbose) + " " + c;
+    public final void setIncrement(final int c) {
+        this.c = c;
+        setWide();
     }
 
-
     /**
-     * Set index of local variable.
+     * Sets index of local variable.
      */
     @Override
-    public final void setIndex( final int n ) {
+    public final void setIndex(final int n) {
         if (n < 0) {
             throw new ClassGenException("Negative index value: " + n);
         }
@@ -131,43 +137,27 @@ public final void setIndex( final int n ) {
         setWide();
     }
 
-
-    /**
-     * @return increment factor
-     */
-    public final int getIncrement() {
-        return c;
-    }
-
-
-    /**
-     * Set increment factor.
-     */
-    public final void setIncrement( final int c ) {
-        this.c = c;
-        setWide();
-    }
-
-
-    /** @return int type
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.INT;
+    private void setWide() {
+        wide = super.getIndex() > Const.MAX_BYTE;
+        if (c > 0) {
+            wide = wide || c > Byte.MAX_VALUE;
+        } else {
+            wide = wide || c < Byte.MIN_VALUE;
+        }
+        if (wide) {
+            super.setLength(6); // wide byte included
+        } else {
+            super.setLength(3);
+        }
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Returns mnemonic for instruction.
      *
-     * @param v Visitor object
+     * @return mnemonic for instruction.
      */
     @Override
-    public void accept( final Visitor v ) {
-        v.visitLocalVariableInstruction(this);
-        v.visitIINC(this);
+    public String toString(final boolean verbose) {
+        return super.toString(verbose) + " " + c;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ILOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ILOAD.java
index 55f9c29fbbd..1ecc3aae4cc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ILOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ILOAD.java
@@ -23,38 +23,37 @@
 
 /**
  * ILOAD - Load int from local variable onto stack
- * <PRE>Stack: ... -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ... -&gt; ..., result
+ * </PRE>
  */
 public class ILOAD extends LoadInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ILOAD() {
         super(com.sun.org.apache.bcel.internal.Const.ILOAD, com.sun.org.apache.bcel.internal.Const.ILOAD_0);
     }
 
-
-    /** Load int from local variable
+    /**
+     * Load int from local variable
+     *
      * @param n index of local variable
      */
     public ILOAD(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.ILOAD, com.sun.org.apache.bcel.internal.Const.ILOAD_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitILOAD(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java
index a93c1808017..62fc89299a9 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP1.java
@@ -23,7 +23,6 @@
 
 /**
  * IMPDEP1 - Implementation dependent
- *
  */
 public class IMPDEP1 extends Instruction {
 
@@ -31,17 +30,14 @@ public IMPDEP1() {
         super(com.sun.org.apache.bcel.internal.Const.IMPDEP1, (short) 1);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitIMPDEP1(this);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java
index e77c250531c..cef4e08c794 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMPDEP2.java
@@ -23,7 +23,6 @@
 
 /**
  * IMPDEP2 - Implementation dependent
- *
  */
 public class IMPDEP2 extends Instruction {
 
@@ -31,17 +30,14 @@ public IMPDEP2() {
         super(com.sun.org.apache.bcel.internal.Const.IMPDEP2, (short) 1);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitIMPDEP2(this);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMUL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMUL.java
index f8fa6a18792..9f7ff3dbf6c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMUL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IMUL.java
@@ -23,28 +23,28 @@
 
 /**
  * IMUL - Multiply ints
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class IMUL extends ArithmeticInstruction {
 
-    /** Multiply ints
+    /**
+     * Multiply ints
      */
     public IMUL() {
         super(com.sun.org.apache.bcel.internal.Const.IMUL);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INEG.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INEG.java
index 1acc2886718..d881260b66e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INEG.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INEG.java
@@ -23,8 +23,10 @@
 
 /**
  * INEG - Negate int
- * <PRE>Stack: ..., value -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ..., result
+ * </PRE>
  */
 public class INEG extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public INEG() {
         super(com.sun.org.apache.bcel.internal.Const.INEG);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java
index 48500a4744b..10d5f2c0f65 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INSTANCEOF.java
@@ -25,51 +25,31 @@
 
 /**
  * INSTANCEOF - Determine if object is of given type
- * <PRE>Stack: ..., objectref -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., objectref -&gt; ..., result
+ * </PRE>
  */
-public class INSTANCEOF extends CPInstruction implements LoadClass, ExceptionThrower,
-        StackProducer, StackConsumer {
+public class INSTANCEOF extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer, StackConsumer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     INSTANCEOF() {
     }
 
-
     public INSTANCEOF(final int index) {
         super(com.sun.org.apache.bcel.internal.Const.INSTANCEOF, index);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION);
-    }
-
-
-    @Override
-    public ObjectType getLoadClassType( final ConstantPoolGen cpg ) {
-        Type t = getType(cpg);
-        if (t instanceof ArrayType) {
-            t = ((ArrayType) t).getBasicType();
-        }
-        return (t instanceof ObjectType) ? (ObjectType) t : null;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLoadClass(this);
         v.visitExceptionThrower(this);
         v.visitStackProducer(this);
@@ -78,4 +58,18 @@ public void accept( final Visitor v ) {
         v.visitCPInstruction(this);
         v.visitINSTANCEOF(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION);
+    }
+
+    @Override
+    public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
+        Type t = getType(cpg);
+        if (t instanceof ArrayType) {
+            t = ((ArrayType) t).getBasicType();
+        }
+        return t instanceof ObjectType ? (ObjectType) t : null;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java
index d6bac98f036..2865a158de2 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -31,85 +31,34 @@
 import com.sun.org.apache.bcel.internal.util.ByteSequence;
 
 /**
- * Class for INVOKEDYNAMIC. Not an instance of InvokeInstruction, since that class
- * expects to be able to get the class of the method. Ignores the bootstrap
- * mechanism entirely.
+ * Class for INVOKEDYNAMIC. Not an instance of InvokeInstruction, since that class expects to be able to get the class
+ * of the method. Ignores the bootstrap mechanism entirely.
  *
- * @see
- * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokedynamic">
- * The invokedynamic instruction in The Java Virtual Machine Specification</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokedynamic"> The
+ *      invokedynamic instruction in The Java Virtual Machine Specification</a>
  * @since 6.0
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public class INVOKEDYNAMIC extends InvokeInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     INVOKEDYNAMIC() {
     }
 
-
     public INVOKEDYNAMIC(final int index) {
         super(Const.INVOKEDYNAMIC, index);
     }
 
-
-    /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
-     */
-    @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        out.writeByte(super.getOpcode());
-        out.writeShort(super.getIndex());
-        out.writeByte(0);
-        out.writeByte(0);
-       }
-
-
-    /**
-     * Read needed data (i.e., index) from file.
-     */
-    @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
-        super.initFromFile(bytes, wide);
-        super.setLength(5);
-        bytes.readByte(); // Skip 0 byte
-        bytes.readByte(); // Skip 0 byte
-    }
-
-
-    /**
-     * @return mnemonic for instruction with symbolic references resolved
-     */
-    @Override
-    public String toString( final ConstantPool cp ) {
-        return super.toString(cp);
-    }
-
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION,
-            ExceptionConst.UNSATISFIED_LINK_ERROR,
-            ExceptionConst.ABSTRACT_METHOD_ERROR,
-            ExceptionConst.ILLEGAL_ACCESS_ERROR,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
@@ -122,28 +71,43 @@ public void accept( final Visitor v ) {
     }
 
     /**
-     * Override the parent method because our classname is held elsewhere.
+     * Dump instruction as byte code to stream out.
      *
-     * @param cpg the ConstantPool generator
-     * @deprecated in FieldOrMethod
+     * @param out Output stream
+     */
+    @Override
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(super.getOpcode());
+        out.writeShort(super.getIndex());
+        out.writeByte(0);
+        out.writeByte(0);
+    }
+
+    /**
+     * Override the parent method because our class name is held elsewhere.
      *
-     * @return name of the referenced class/interface
+     * Note: Contrary to this method's name it does not return the class name of the invoke target; rather it returns the
+     * name of the method that will be used to invoke the Lambda method generated by this invoke dynamic instruction.
      */
     @Override
     @Deprecated
     public String getClassName( final ConstantPoolGen cpg ) {
         final ConstantPool cp = cpg.getConstantPool();
-        final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic);
-        return ((ConstantNameAndType) cp.getConstant(cid.getNameAndTypeIndex())).getName(cp);
+        final ConstantInvokeDynamic cid = cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic, ConstantInvokeDynamic.class);
+        return cp.getConstant(cid.getNameAndTypeIndex(), ConstantNameAndType.class).getName(cp);
     }
 
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION, ExceptionConst.UNSATISFIED_LINK_ERROR,
+            ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.ILLEGAL_ACCESS_ERROR, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
+    }
 
     /**
-     * Since InvokeDynamic doesn't refer to a reference type, just return java.lang.Object,
-     * as that is the only type we can say for sure the reference will be.
+     * Since InvokeDynamic doesn't refer to a reference type, just return java.lang.Object, as that is the only type we can
+     * say for sure the reference will be.
      *
-     * @param cpg
-     *            the ConstantPoolGen used to create the instruction
+     * @param cpg the ConstantPoolGen used to create the instruction
      * @return an ObjectType for java.lang.Object
      * @since 6.1
      */
@@ -151,4 +115,16 @@ public String getClassName( final ConstantPoolGen cpg ) {
     public ReferenceType getReferenceType(final ConstantPoolGen cpg) {
         return new ObjectType(Object.class.getName());
     }
+
+    /**
+     * Read needed data (i.e., index) from file.
+     */
+    @Override
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+        super.initFromFile(bytes, wide);
+        super.setLength(5);
+        bytes.readByte(); // Skip 0 byte
+        bytes.readByte(); // Skip 0 byte
+    }
+
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java
index 4953abda34b..7f1858c5766 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEINTERFACE.java
@@ -31,25 +31,24 @@
 
 /**
  * INVOKEINTERFACE - Invoke interface method
- * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...</PRE>
  *
- * @see
- * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokeinterface">
- * The invokeinterface instruction in The Java Virtual Machine Specification</a>
+ * <PRE>
+ * Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...
+ * </PRE>
+ *
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokeinterface"> The
+ *      invokeinterface instruction in The Java Virtual Machine Specification</a>
  */
 public final class INVOKEINTERFACE extends InvokeInstruction {
 
     private int nargs; // Number of arguments on stack (number of stack slots), called "count" in vmspec2
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     INVOKEINTERFACE() {
     }
 
-
     public INVOKEINTERFACE(final int index, final int nargs) {
         super(Const.INVOKEINTERFACE, index);
         super.setLength(5);
@@ -59,84 +58,72 @@ public INVOKEINTERFACE(final int index, final int nargs) {
         this.nargs = nargs;
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitExceptionThrower(this);
+        v.visitTypedInstruction(this);
+        v.visitStackConsumer(this);
+        v.visitStackProducer(this);
+        v.visitLoadClass(this);
+        v.visitCPInstruction(this);
+        v.visitFieldOrMethod(this);
+        v.visitInvokeInstruction(this);
+        v.visitINVOKEINTERFACE(this);
+    }
+
+    @Override
+    public int consumeStack(final ConstantPoolGen cpg) { // nargs is given in byte-code
+        return nargs; // nargs includes this reference
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         out.writeByte(super.getOpcode());
         out.writeShort(super.getIndex());
         out.writeByte(nargs);
         out.writeByte(0);
     }
 
-
     /**
-     * The <B>count</B> argument according to the Java Language Specification,
-     * Second Edition.
+     * The <B>count</B> argument according to the Java Language Specification, Second Edition.
      */
     public int getCount() {
         return nargs;
     }
 
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION, ExceptionConst.UNSATISFIED_LINK_ERROR,
+            ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.ILLEGAL_ACCESS_ERROR, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
+    }
 
     /**
      * Read needed data (i.e., index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         super.initFromFile(bytes, wide);
         super.setLength(5);
         nargs = bytes.readUnsignedByte();
         bytes.readByte(); // Skip 0 byte
     }
 
-
     /**
      * @return mnemonic for instruction with symbolic references resolved
      */
     @Override
-    public String toString( final ConstantPool cp ) {
+    public String toString(final ConstantPool cp) {
         return super.toString(cp) + " " + nargs;
     }
-
-
-    @Override
-    public int consumeStack( final ConstantPoolGen cpg ) { // nargs is given in byte-code
-        return nargs; // nargs includes this reference
-    }
-
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION,
-            ExceptionConst.UNSATISFIED_LINK_ERROR,
-            ExceptionConst.ABSTRACT_METHOD_ERROR,
-            ExceptionConst.ILLEGAL_ACCESS_ERROR,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
-    }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitExceptionThrower(this);
-        v.visitTypedInstruction(this);
-        v.visitStackConsumer(this);
-        v.visitStackProducer(this);
-        v.visitLoadClass(this);
-        v.visitCPInstruction(this);
-        v.visitFieldOrMethod(this);
-        v.visitInvokeInstruction(this);
-        v.visitINVOKEINTERFACE(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java
index ce27d07fd20..4fdff394241 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESPECIAL.java
@@ -28,60 +28,36 @@
 import com.sun.org.apache.bcel.internal.ExceptionConst;
 
 /**
- * INVOKESPECIAL - Invoke instance method; special handling for superclass, private
- * and instance initialization method invocations
+ * INVOKESPECIAL - Invoke instance method; special handling for superclass, private and instance initialization method
+ * invocations
  *
- * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...</PRE>
+ * <PRE>
+ * Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...
+ * </PRE>
  *
- * @see
- * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokespecial">
- * The invokespecial instruction in The Java Virtual Machine Specification</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokespecial"> The
+ *      invokespecial instruction in The Java Virtual Machine Specification</a>
  */
 public class INVOKESPECIAL extends InvokeInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     INVOKESPECIAL() {
     }
 
-
     public INVOKESPECIAL(final int index) {
         super(Const.INVOKESPECIAL, index);
     }
 
-
-    /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
-     */
-    @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        out.writeByte(super.getOpcode());
-        out.writeShort(super.getIndex());
-    }
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
-            ExceptionConst.NULL_POINTER_EXCEPTION,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR,
-            ExceptionConst.ABSTRACT_METHOD_ERROR,
-            ExceptionConst.UNSATISFIED_LINK_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
@@ -92,4 +68,21 @@ public void accept( final Visitor v ) {
         v.visitInvokeInstruction(this);
         v.visitINVOKESPECIAL(this);
     }
+
+    /**
+     * Dump instruction as byte code to stream out.
+     *
+     * @param out Output stream
+     */
+    @Override
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(super.getOpcode());
+        out.writeShort(super.getIndex());
+    }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION,
+            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR, ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.UNSATISFIED_LINK_ERROR);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java
index a89702514a2..c9c7dcdab63 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKESTATIC.java
@@ -30,55 +30,33 @@
 /**
  * INVOKESTATIC - Invoke a class (static) method
  *
- * <PRE>Stack: ..., [arg1, [arg2 ...]] -&gt; ...</PRE>
+ * <PRE>
+ * Stack: ..., [arg1, [arg2 ...]] -&gt; ...
+ * </PRE>
  *
- * @see
- * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokestatic">
- * The invokestatic instruction in The Java Virtual Machine Specification</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokestatic"> The invokestatic
+ *      instruction in The Java Virtual Machine Specification</a>
  */
 public class INVOKESTATIC extends InvokeInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     INVOKESTATIC() {
     }
 
-
     public INVOKESTATIC(final int index) {
         super(Const.INVOKESTATIC, index);
     }
 
-
-    /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
-     */
-    @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-      out.writeByte(super.getOpcode());
-      out.writeShort(super.getIndex());
-    }
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
-            ExceptionConst.UNSATISFIED_LINK_ERROR,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
@@ -89,4 +67,21 @@ public void accept( final Visitor v ) {
         v.visitInvokeInstruction(this);
         v.visitINVOKESTATIC(this);
     }
+
+    /**
+     * Dump instruction as byte code to stream out.
+     *
+     * @param out Output stream
+     */
+    @Override
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(super.getOpcode());
+        out.writeShort(super.getIndex());
+    }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.UNSATISFIED_LINK_ERROR,
+            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java
index bd5a2b5fd07..09961236e2d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEVIRTUAL.java
@@ -30,57 +30,33 @@
 /**
  * INVOKEVIRTUAL - Invoke instance method; dispatch based on class
  *
- * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...</PRE>
+ * <PRE>
+ * Stack: ..., objectref, [arg1, [arg2 ...]] -&gt; ...
+ * </PRE>
  *
- * @see
- * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokevirtual">
- * The invokevirtual instruction in The Java Virtual Machine Specification</a>
+ * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokevirtual"> The
+ *      invokevirtual instruction in The Java Virtual Machine Specification</a>
  */
 public class INVOKEVIRTUAL extends InvokeInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     INVOKEVIRTUAL() {
     }
 
-
     public INVOKEVIRTUAL(final int index) {
         super(Const.INVOKEVIRTUAL, index);
     }
 
-
-    /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
-     */
-    @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        out.writeByte(super.getOpcode());
-        out.writeShort(super.getIndex());
-    }
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
-            ExceptionConst.NULL_POINTER_EXCEPTION,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR,
-            ExceptionConst.ABSTRACT_METHOD_ERROR,
-            ExceptionConst.UNSATISFIED_LINK_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
@@ -91,4 +67,21 @@ public void accept( final Visitor v ) {
         v.visitInvokeInstruction(this);
         v.visitINVOKEVIRTUAL(this);
     }
+
+    /**
+     * Dump instruction as byte code to stream out.
+     *
+     * @param out Output stream
+     */
+    @Override
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(super.getOpcode());
+        out.writeShort(super.getIndex());
+    }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION,
+            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR, ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.UNSATISFIED_LINK_ERROR);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IOR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IOR.java
index 0589c4b8297..9f9ee094e2d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IOR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IOR.java
@@ -23,8 +23,10 @@
 
 /**
  * IOR - Bitwise OR int
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class IOR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public IOR() {
         super(com.sun.org.apache.bcel.internal.Const.IOR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IREM.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IREM.java
index 984cf31fcf7..34b11f42d0e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IREM.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IREM.java
@@ -24,39 +24,29 @@
 
 /**
  * IREM - Remainder of int
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class IREM extends ArithmeticInstruction implements ExceptionThrower {
 
-    /** Remainder of ints
+    /**
+     * Remainder of ints
      */
     public IREM() {
         super(com.sun.org.apache.bcel.internal.Const.IREM);
     }
 
-
-    /** @return exceptions this instruction may cause
-     */
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.ARITHMETIC_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
@@ -64,4 +54,12 @@ public void accept( final Visitor v ) {
         v.visitArithmeticInstruction(this);
         v.visitIREM(this);
     }
+
+    /**
+     * @return exceptions this instruction may cause
+     */
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.ARITHMETIC_EXCEPTION};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IRETURN.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IRETURN.java
index 894738ffe4a..80c3bfba744 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IRETURN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IRETURN.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * IRETURN -  Return int from method
- * <PRE>Stack: ..., value -&gt; &lt;empty&gt;</PRE>
+ * IRETURN - Return int from method
  *
+ * <PRE>
+ * Stack: ..., value -&gt; &lt;empty&gt;
+ * </PRE>
  */
 public class IRETURN extends ReturnInstruction {
 
-    /** Return int from method
+    /**
+     * Return int from method
      */
     public IRETURN() {
         super(com.sun.org.apache.bcel.internal.Const.IRETURN);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHL.java
index 67482bf7633..2e762db8969 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHL.java
@@ -23,8 +23,10 @@
 
 /**
  * ISHL - Arithmetic shift left int
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class ISHL extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public ISHL() {
         super(com.sun.org.apache.bcel.internal.Const.ISHL);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHR.java
index 1729abb7ecd..c5e3906173a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISHR.java
@@ -23,8 +23,10 @@
 
 /**
  * ISHR - Arithmetic shift right int
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class ISHR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public ISHR() {
         super(com.sun.org.apache.bcel.internal.Const.ISHR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISTORE.java
index d27b087dc30..76d8f930f8d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISTORE.java
@@ -23,38 +23,37 @@
 
 /**
  * ISTORE - Store int from stack into local variable
- * <PRE>Stack: ..., value -&gt; ... </PRE>
  *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
  */
 public class ISTORE extends StoreInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ISTORE() {
         super(com.sun.org.apache.bcel.internal.Const.ISTORE, com.sun.org.apache.bcel.internal.Const.ISTORE_0);
     }
 
-
-    /** Store int into local variable
+    /**
+     * Store int into local variable
+     *
      * @param n index of local variable
      */
     public ISTORE(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.ISTORE, com.sun.org.apache.bcel.internal.Const.ISTORE_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitISTORE(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISUB.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISUB.java
index 60d67a47e25..571751ce33e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISUB.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ISUB.java
@@ -23,28 +23,28 @@
 
 /**
  * ISUB - Substract ints
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  */
 public class ISUB extends ArithmeticInstruction {
 
-    /** Substract ints
+    /**
+     * Substract ints
      */
     public ISUB() {
         super(com.sun.org.apache.bcel.internal.Const.ISUB);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IUSHR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IUSHR.java
index 0434d28889c..89236a0afa9 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IUSHR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IUSHR.java
@@ -23,8 +23,10 @@
 
 /**
  * IUSHR - Logical shift right int
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class IUSHR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public IUSHR() {
         super(com.sun.org.apache.bcel.internal.Const.IUSHR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IXOR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IXOR.java
index 5aae103fd61..1006f3d3841 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IXOR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IXOR.java
@@ -23,8 +23,10 @@
 
 /**
  * IXOR - Bitwise XOR int
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class IXOR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public IXOR() {
         super(com.sun.org.apache.bcel.internal.Const.IXOR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IfInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IfInstruction.java
index be02b847107..b4be83ebdc2 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IfInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IfInstruction.java
@@ -23,18 +23,15 @@
 
 /**
  * Super class for the IFxxx family of instructions.
- *
  */
 public abstract class IfInstruction extends BranchInstruction implements StackConsumer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     IfInstruction() {
     }
 
-
     /**
      * @param opcode opcode of instruction
      * @param target Target instruction to branch to
@@ -43,7 +40,6 @@ protected IfInstruction(final short opcode, final InstructionHandle target) {
         super(opcode, target);
     }
 
-
     /**
      * @return negation of instruction, e.g. IFEQ.negate() == IFNE
      */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java
index f84d2839d30..f9846297614 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/IndexedInstruction.java
@@ -22,14 +22,11 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denote entity that refers to an index, e.g. local variable instructions,
- * RET, CPInstruction, etc.
- *
+ * Denote entity that refers to an index, e.g. local variable instructions, RET, CPInstruction, etc.
  */
 public interface IndexedInstruction {
 
     int getIndex();
 
-
-    void setIndex( int index );
+    void setIndex(int index);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Instruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Instruction.java
index 20188a9f16a..16c8e2444b4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Instruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Instruction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -29,127 +29,59 @@
 /**
  * Abstract super class for all Java byte codes.
  *
- * @LastModified: July 2020
+ * @LastModified: Feb 2023
  */
 public abstract class Instruction implements Cloneable {
 
-    private short length = 1; // Length of instruction in bytes
-    private short opcode = -1; // Opcode number
+    static final Instruction[] EMPTY_ARRAY = {};
 
     private static InstructionComparator cmp = InstructionComparator.DEFAULT;
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
-     */
-    Instruction() {
-    }
-
-
-    public Instruction(final short opcode, final short length) {
-        this.length = length;
-        this.opcode = opcode;
-    }
-
-
-    /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
-     */
-    public void dump( final DataOutputStream out ) throws IOException {
-        out.writeByte(opcode); // Common for all instructions
-    }
-
-
-    /** @return name of instruction, i.e., opcode name
-     */
-    public String getName() {
-        return Const.getOpcodeName(opcode);
-    }
-
-
-    /**
-     * Long output format:
-     *
-     * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
-     * "("&lt;length of instruction&gt;")"
+     * Gets Comparator object used in the equals() method to determine equality of instructions.
      *
-     * @param verbose long/short format switch
-     * @return mnemonic for instruction
-     */
-    public String toString( final boolean verbose ) {
-        if (verbose) {
-            return getName() + "[" + opcode + "](" + length + ")";
-        }
-        return getName();
-    }
-
-
-    /**
-     * @return mnemonic for instruction in verbose format
-     */
-    @Override
-    public String toString() {
-        return toString(true);
-    }
-
-
-    /**
-     * @return mnemonic for instruction with sumbolic references resolved
+     * @return currently used comparator for equals()
+     * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods
      */
-    public String toString( final ConstantPool cp ) {
-        return toString(false);
+    @Deprecated
+    public static InstructionComparator getComparator() {
+        return cmp;
     }
 
-
     /**
-     * Use with caution, since `BranchInstruction's have a `target' reference which
-     * is not copied correctly (only basic types are). This also applies for
-     * `Select' instructions with their multiple branch targets.
+     * Tests if the value can fit in a byte (signed)
      *
-     * @see BranchInstruction
-     * @return (shallow) copy of an instruction
+     * @param value the value to check
+     * @return true if the value is in range
+     * @since 6.0
      */
-    public Instruction copy() {
-        Instruction i = null;
-        // "Constant" instruction, no need to duplicate
-        if (InstructionConst.getInstruction(this.getOpcode()) != null) {
-            i = this;
-        } else {
-            try {
-                i = (Instruction) clone();
-            } catch (final CloneNotSupportedException e) {
-                System.err.println(e);
-            }
-        }
-        return i;
+    public static boolean isValidByte(final int value) {
+        return value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE;
     }
 
-
     /**
-     * Read needed data (e.g. index) from file.
+     * Tests if the value can fit in a short (signed)
      *
-     * @param bytes byte sequence to read from
-     * @param wide "wide" instruction flag
-     * @throws IOException may be thrown if the implementation needs to read data from the file
+     * @param value the value to check
+     * @return true if the value is in range
+     * @since 6.0
      */
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    public static boolean isValidShort(final int value) {
+        return value >= Short.MIN_VALUE && value <= Short.MAX_VALUE;
     }
 
-
     /**
-     * Read an instruction from (byte code) input stream and return the
-     * appropiate object.
+     * Reads an instruction from (byte code) input stream and return the appropriate object.
      * <p>
-     * If the Instruction is defined in {@link InstructionConst}, then the
-     * singleton instance is returned.
+     * If the Instruction is defined in {@link InstructionConst}, then the singleton instance is returned.
+     * </p>
      * @param bytes input stream bytes
      * @return instruction object being read
+     * @throws IOException Thrown when an I/O exception of some sort has occurred.
      * @see InstructionConst#getInstruction(int)
      */
     // @since 6.0 no longer final
-    public static Instruction readInstruction( final ByteSequence bytes ) throws IOException {
+    public static Instruction readInstruction(final ByteSequence bytes) throws IOException {
         boolean wide = false;
         short opcode = (short) bytes.readUnsignedByte();
         Instruction obj = null;
@@ -163,304 +95,303 @@ public static Instruction readInstruction( final ByteSequence bytes ) throws IOE
         }
 
         switch (opcode) {
-            case Const.BIPUSH:
-                obj = new BIPUSH();
-                break;
-            case Const.SIPUSH:
-                obj = new SIPUSH();
-                break;
-            case Const.LDC:
-                obj = new LDC();
-                break;
-            case Const.LDC_W:
-                obj = new LDC_W();
-                break;
-            case Const.LDC2_W:
-                obj = new LDC2_W();
-                break;
-            case Const.ILOAD:
-                obj = new ILOAD();
-                break;
-            case Const.LLOAD:
-                obj = new LLOAD();
-                break;
-            case Const.FLOAD:
-                obj = new FLOAD();
-                break;
-            case Const.DLOAD:
-                obj = new DLOAD();
-                break;
-            case Const.ALOAD:
-                obj = new ALOAD();
-                break;
-            case Const.ILOAD_0:
-                obj = new ILOAD(0);
-                break;
-            case Const.ILOAD_1:
-                obj = new ILOAD(1);
-                break;
-            case Const.ILOAD_2:
-                obj = new ILOAD(2);
-                break;
-            case Const.ILOAD_3:
-                obj = new ILOAD(3);
-                break;
-            case Const.LLOAD_0:
-                obj = new LLOAD(0);
-                break;
-            case Const.LLOAD_1:
-                obj = new LLOAD(1);
-                break;
-            case Const.LLOAD_2:
-                obj = new LLOAD(2);
-                break;
-            case Const.LLOAD_3:
-                obj = new LLOAD(3);
-                break;
-            case Const.FLOAD_0:
-                obj = new FLOAD(0);
-                break;
-            case Const.FLOAD_1:
-                obj = new FLOAD(1);
-                break;
-            case Const.FLOAD_2:
-                obj = new FLOAD(2);
-                break;
-            case Const.FLOAD_3:
-                obj = new FLOAD(3);
-                break;
-            case Const.DLOAD_0:
-                obj = new DLOAD(0);
-                break;
-            case Const.DLOAD_1:
-                obj = new DLOAD(1);
-                break;
-            case Const.DLOAD_2:
-                obj = new DLOAD(2);
-                break;
-            case Const.DLOAD_3:
-                obj = new DLOAD(3);
-                break;
-            case Const.ALOAD_0:
-                obj = new ALOAD(0);
-                break;
-            case Const.ALOAD_1:
-                obj = new ALOAD(1);
-                break;
-            case Const.ALOAD_2:
-                obj = new ALOAD(2);
-                break;
-            case Const.ALOAD_3:
-                obj = new ALOAD(3);
-                break;
-            case Const.ISTORE:
-                obj = new ISTORE();
-                break;
-            case Const.LSTORE:
-                obj = new LSTORE();
-                break;
-            case Const.FSTORE:
-                obj = new FSTORE();
-                break;
-            case Const.DSTORE:
-                obj = new DSTORE();
-                break;
-            case Const.ASTORE:
-                obj = new ASTORE();
-                break;
-            case Const.ISTORE_0:
-                obj = new ISTORE(0);
-                break;
-            case Const.ISTORE_1:
-                obj = new ISTORE(1);
-                break;
-            case Const.ISTORE_2:
-                obj = new ISTORE(2);
-                break;
-            case Const.ISTORE_3:
-                obj = new ISTORE(3);
-                break;
-            case Const.LSTORE_0:
-                obj = new LSTORE(0);
-                break;
-            case Const.LSTORE_1:
-                obj = new LSTORE(1);
-                break;
-            case Const.LSTORE_2:
-                obj = new LSTORE(2);
-                break;
-            case Const.LSTORE_3:
-                obj = new LSTORE(3);
-                break;
-            case Const.FSTORE_0:
-                obj = new FSTORE(0);
-                break;
-            case Const.FSTORE_1:
-                obj = new FSTORE(1);
-                break;
-            case Const.FSTORE_2:
-                obj = new FSTORE(2);
-                break;
-            case Const.FSTORE_3:
-                obj = new FSTORE(3);
-                break;
-            case Const.DSTORE_0:
-                obj = new DSTORE(0);
-                break;
-            case Const.DSTORE_1:
-                obj = new DSTORE(1);
-                break;
-            case Const.DSTORE_2:
-                obj = new DSTORE(2);
-                break;
-            case Const.DSTORE_3:
-                obj = new DSTORE(3);
-                break;
-            case Const.ASTORE_0:
-                obj = new ASTORE(0);
-                break;
-            case Const.ASTORE_1:
-                obj = new ASTORE(1);
-                break;
-            case Const.ASTORE_2:
-                obj = new ASTORE(2);
-                break;
-            case Const.ASTORE_3:
-                obj = new ASTORE(3);
-                break;
-            case Const.IINC:
-                obj = new IINC();
-                break;
-            case Const.IFEQ:
-                obj = new IFEQ();
-                break;
-            case Const.IFNE:
-                obj = new IFNE();
-                break;
-            case Const.IFLT:
-                obj = new IFLT();
-                break;
-            case Const.IFGE:
-                obj = new IFGE();
-                break;
-            case Const.IFGT:
-                obj = new IFGT();
-                break;
-            case Const.IFLE:
-                obj = new IFLE();
-                break;
-            case Const.IF_ICMPEQ:
-                obj = new IF_ICMPEQ();
-                break;
-            case Const.IF_ICMPNE:
-                obj = new IF_ICMPNE();
-                break;
-            case Const.IF_ICMPLT:
-                obj = new IF_ICMPLT();
-                break;
-            case Const.IF_ICMPGE:
-                obj = new IF_ICMPGE();
-                break;
-            case Const.IF_ICMPGT:
-                obj = new IF_ICMPGT();
-                break;
-            case Const.IF_ICMPLE:
-                obj = new IF_ICMPLE();
-                break;
-            case Const.IF_ACMPEQ:
-                obj = new IF_ACMPEQ();
-                break;
-            case Const.IF_ACMPNE:
-                obj = new IF_ACMPNE();
-                break;
-            case Const.GOTO:
-                obj = new GOTO();
-                break;
-            case Const.JSR:
-                obj = new JSR();
-                break;
-            case Const.RET:
-                obj = new RET();
-                break;
-            case Const.TABLESWITCH:
-                obj = new TABLESWITCH();
-                break;
-            case Const.LOOKUPSWITCH:
-                obj = new LOOKUPSWITCH();
-                break;
-            case Const.GETSTATIC:
-                obj = new GETSTATIC();
-                break;
-            case Const.PUTSTATIC:
-                obj = new PUTSTATIC();
-                break;
-            case Const.GETFIELD:
-                obj = new GETFIELD();
-                break;
-            case Const.PUTFIELD:
-                obj = new PUTFIELD();
-                break;
-            case Const.INVOKEVIRTUAL:
-                obj = new INVOKEVIRTUAL();
-                break;
-            case Const.INVOKESPECIAL:
-                obj = new INVOKESPECIAL();
-                break;
-            case Const.INVOKESTATIC:
-                obj = new INVOKESTATIC();
-                break;
-            case Const.INVOKEINTERFACE:
-                obj = new INVOKEINTERFACE();
-                break;
-            case Const.INVOKEDYNAMIC:
-                obj = new INVOKEDYNAMIC();
-                break;
-            case Const.NEW:
-                obj = new NEW();
-                break;
-            case Const.NEWARRAY:
-                obj = new NEWARRAY();
-                break;
-            case Const.ANEWARRAY:
-                obj = new ANEWARRAY();
-                break;
-            case Const.CHECKCAST:
-                obj = new CHECKCAST();
-                break;
-            case Const.INSTANCEOF:
-                obj = new INSTANCEOF();
-                break;
-            case Const.MULTIANEWARRAY:
-                obj = new MULTIANEWARRAY();
-                break;
-            case Const.IFNULL:
-                obj = new IFNULL();
-                break;
-            case Const.IFNONNULL:
-                obj = new IFNONNULL();
-                break;
-            case Const.GOTO_W:
-                obj = new GOTO_W();
-                break;
-            case Const.JSR_W:
-                obj = new JSR_W();
-                break;
-            case Const.BREAKPOINT:
-                obj = new BREAKPOINT();
-                break;
-            case Const.IMPDEP1:
-                obj = new IMPDEP1();
-                break;
-            case Const.IMPDEP2:
-                obj = new IMPDEP2();
-                break;
-            default:
-                throw new ClassGenException("Illegal opcode detected: " + opcode);
+        case Const.BIPUSH:
+            obj = new BIPUSH();
+            break;
+        case Const.SIPUSH:
+            obj = new SIPUSH();
+            break;
+        case Const.LDC:
+            obj = new LDC();
+            break;
+        case Const.LDC_W:
+            obj = new LDC_W();
+            break;
+        case Const.LDC2_W:
+            obj = new LDC2_W();
+            break;
+        case Const.ILOAD:
+            obj = new ILOAD();
+            break;
+        case Const.LLOAD:
+            obj = new LLOAD();
+            break;
+        case Const.FLOAD:
+            obj = new FLOAD();
+            break;
+        case Const.DLOAD:
+            obj = new DLOAD();
+            break;
+        case Const.ALOAD:
+            obj = new ALOAD();
+            break;
+        case Const.ILOAD_0:
+            obj = new ILOAD(0);
+            break;
+        case Const.ILOAD_1:
+            obj = new ILOAD(1);
+            break;
+        case Const.ILOAD_2:
+            obj = new ILOAD(2);
+            break;
+        case Const.ILOAD_3:
+            obj = new ILOAD(3);
+            break;
+        case Const.LLOAD_0:
+            obj = new LLOAD(0);
+            break;
+        case Const.LLOAD_1:
+            obj = new LLOAD(1);
+            break;
+        case Const.LLOAD_2:
+            obj = new LLOAD(2);
+            break;
+        case Const.LLOAD_3:
+            obj = new LLOAD(3);
+            break;
+        case Const.FLOAD_0:
+            obj = new FLOAD(0);
+            break;
+        case Const.FLOAD_1:
+            obj = new FLOAD(1);
+            break;
+        case Const.FLOAD_2:
+            obj = new FLOAD(2);
+            break;
+        case Const.FLOAD_3:
+            obj = new FLOAD(3);
+            break;
+        case Const.DLOAD_0:
+            obj = new DLOAD(0);
+            break;
+        case Const.DLOAD_1:
+            obj = new DLOAD(1);
+            break;
+        case Const.DLOAD_2:
+            obj = new DLOAD(2);
+            break;
+        case Const.DLOAD_3:
+            obj = new DLOAD(3);
+            break;
+        case Const.ALOAD_0:
+            obj = new ALOAD(0);
+            break;
+        case Const.ALOAD_1:
+            obj = new ALOAD(1);
+            break;
+        case Const.ALOAD_2:
+            obj = new ALOAD(2);
+            break;
+        case Const.ALOAD_3:
+            obj = new ALOAD(3);
+            break;
+        case Const.ISTORE:
+            obj = new ISTORE();
+            break;
+        case Const.LSTORE:
+            obj = new LSTORE();
+            break;
+        case Const.FSTORE:
+            obj = new FSTORE();
+            break;
+        case Const.DSTORE:
+            obj = new DSTORE();
+            break;
+        case Const.ASTORE:
+            obj = new ASTORE();
+            break;
+        case Const.ISTORE_0:
+            obj = new ISTORE(0);
+            break;
+        case Const.ISTORE_1:
+            obj = new ISTORE(1);
+            break;
+        case Const.ISTORE_2:
+            obj = new ISTORE(2);
+            break;
+        case Const.ISTORE_3:
+            obj = new ISTORE(3);
+            break;
+        case Const.LSTORE_0:
+            obj = new LSTORE(0);
+            break;
+        case Const.LSTORE_1:
+            obj = new LSTORE(1);
+            break;
+        case Const.LSTORE_2:
+            obj = new LSTORE(2);
+            break;
+        case Const.LSTORE_3:
+            obj = new LSTORE(3);
+            break;
+        case Const.FSTORE_0:
+            obj = new FSTORE(0);
+            break;
+        case Const.FSTORE_1:
+            obj = new FSTORE(1);
+            break;
+        case Const.FSTORE_2:
+            obj = new FSTORE(2);
+            break;
+        case Const.FSTORE_3:
+            obj = new FSTORE(3);
+            break;
+        case Const.DSTORE_0:
+            obj = new DSTORE(0);
+            break;
+        case Const.DSTORE_1:
+            obj = new DSTORE(1);
+            break;
+        case Const.DSTORE_2:
+            obj = new DSTORE(2);
+            break;
+        case Const.DSTORE_3:
+            obj = new DSTORE(3);
+            break;
+        case Const.ASTORE_0:
+            obj = new ASTORE(0);
+            break;
+        case Const.ASTORE_1:
+            obj = new ASTORE(1);
+            break;
+        case Const.ASTORE_2:
+            obj = new ASTORE(2);
+            break;
+        case Const.ASTORE_3:
+            obj = new ASTORE(3);
+            break;
+        case Const.IINC:
+            obj = new IINC();
+            break;
+        case Const.IFEQ:
+            obj = new IFEQ();
+            break;
+        case Const.IFNE:
+            obj = new IFNE();
+            break;
+        case Const.IFLT:
+            obj = new IFLT();
+            break;
+        case Const.IFGE:
+            obj = new IFGE();
+            break;
+        case Const.IFGT:
+            obj = new IFGT();
+            break;
+        case Const.IFLE:
+            obj = new IFLE();
+            break;
+        case Const.IF_ICMPEQ:
+            obj = new IF_ICMPEQ();
+            break;
+        case Const.IF_ICMPNE:
+            obj = new IF_ICMPNE();
+            break;
+        case Const.IF_ICMPLT:
+            obj = new IF_ICMPLT();
+            break;
+        case Const.IF_ICMPGE:
+            obj = new IF_ICMPGE();
+            break;
+        case Const.IF_ICMPGT:
+            obj = new IF_ICMPGT();
+            break;
+        case Const.IF_ICMPLE:
+            obj = new IF_ICMPLE();
+            break;
+        case Const.IF_ACMPEQ:
+            obj = new IF_ACMPEQ();
+            break;
+        case Const.IF_ACMPNE:
+            obj = new IF_ACMPNE();
+            break;
+        case Const.GOTO:
+            obj = new GOTO();
+            break;
+        case Const.JSR:
+            obj = new JSR();
+            break;
+        case Const.RET:
+            obj = new RET();
+            break;
+        case Const.TABLESWITCH:
+            obj = new TABLESWITCH();
+            break;
+        case Const.LOOKUPSWITCH:
+            obj = new LOOKUPSWITCH();
+            break;
+        case Const.GETSTATIC:
+            obj = new GETSTATIC();
+            break;
+        case Const.PUTSTATIC:
+            obj = new PUTSTATIC();
+            break;
+        case Const.GETFIELD:
+            obj = new GETFIELD();
+            break;
+        case Const.PUTFIELD:
+            obj = new PUTFIELD();
+            break;
+        case Const.INVOKEVIRTUAL:
+            obj = new INVOKEVIRTUAL();
+            break;
+        case Const.INVOKESPECIAL:
+            obj = new INVOKESPECIAL();
+            break;
+        case Const.INVOKESTATIC:
+            obj = new INVOKESTATIC();
+            break;
+        case Const.INVOKEINTERFACE:
+            obj = new INVOKEINTERFACE();
+            break;
+        case Const.INVOKEDYNAMIC:
+            obj = new INVOKEDYNAMIC();
+            break;
+        case Const.NEW:
+            obj = new NEW();
+            break;
+        case Const.NEWARRAY:
+            obj = new NEWARRAY();
+            break;
+        case Const.ANEWARRAY:
+            obj = new ANEWARRAY();
+            break;
+        case Const.CHECKCAST:
+            obj = new CHECKCAST();
+            break;
+        case Const.INSTANCEOF:
+            obj = new INSTANCEOF();
+            break;
+        case Const.MULTIANEWARRAY:
+            obj = new MULTIANEWARRAY();
+            break;
+        case Const.IFNULL:
+            obj = new IFNULL();
+            break;
+        case Const.IFNONNULL:
+            obj = new IFNONNULL();
+            break;
+        case Const.GOTO_W:
+            obj = new GOTO_W();
+            break;
+        case Const.JSR_W:
+            obj = new JSR_W();
+            break;
+        case Const.BREAKPOINT:
+            obj = new BREAKPOINT();
+            break;
+        case Const.IMPDEP1:
+            obj = new IMPDEP1();
+            break;
+        case Const.IMPDEP2:
+            obj = new IMPDEP2();
+            break;
+        default:
+            throw new ClassGenException("Illegal opcode detected: " + opcode);
 
         }
 
-        if (wide
-                && !((obj instanceof LocalVariableInstruction) || (obj instanceof IINC) || (obj instanceof RET))) {
+        if (wide && !(obj instanceof LocalVariableInstruction || obj instanceof RET)) {
             throw new ClassGenException("Illegal opcode after wide: " + opcode);
         }
         obj.setOpcode(opcode);
@@ -469,109 +400,129 @@ public static Instruction readInstruction( final ByteSequence bytes ) throws IOE
     }
 
     /**
-     * This method also gives right results for instructions whose
-     * effect on the stack depends on the constant pool entry they
-     * reference.
-     *  @return Number of words consumed from stack by this instruction,
-     * or Constants.UNPREDICTABLE, if this can not be computed statically
+     * Sets comparator to be used for equals().
+     *
+     * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods
      */
-    public int consumeStack( final ConstantPoolGen cpg ) {
-        return Const.getConsumeStack(opcode);
+    @Deprecated
+    public static void setComparator(final InstructionComparator c) {
+        cmp = c;
     }
 
-
     /**
-     * This method also gives right results for instructions whose
-     * effect on the stack depends on the constant pool entry they
-     * reference.
-     * @return Number of words produced onto stack by this instruction,
-     * or Constants.UNPREDICTABLE, if this can not be computed statically
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    public int produceStack( final ConstantPoolGen cpg ) {
-        return Const.getProduceStack(opcode);
-    }
+    @Deprecated
+    protected short length = 1; // Length of instruction in bytes
 
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected short opcode = -1; // Opcode number
 
     /**
-     * @return this instructions opcode
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
-    public short getOpcode() {
-        return opcode;
+    Instruction() {
     }
 
+    public Instruction(final short opcode, final short length) {
+        this.length = length;
+        this.opcode = opcode;
+    }
 
     /**
-     * @return length (in bytes) of instruction
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
      */
-    public int getLength() {
-        return length;
-    }
-
+    public abstract void accept(Visitor v);
 
     /**
-     * Needed in readInstruction and subclasses in this package
+     * This method also gives right results for instructions whose effect on the stack depends on the constant pool entry
+     * they reference.
+     *
+     * @return Number of words consumed from stack by this instruction, or Constants.UNPREDICTABLE, if this can not be
+     *         computed statically
      */
-    void setOpcode( final short opcode ) {
-        this.opcode = opcode;
+    public int consumeStack(final ConstantPoolGen cpg) {
+        return Const.getConsumeStack(opcode);
     }
 
-
     /**
-     * Needed in readInstruction and subclasses in this package
-     * @since 6.0
+     * Use with caution, since 'BranchInstruction's have a 'target' reference which is not copied correctly (only basic
+     * types are). This also applies for 'Select' instructions with their multiple branch targets.
+     *
+     * @see BranchInstruction
+     * @return (shallow) copy of an instruction
      */
-    final void setLength( final int length ) {
-        this.length = (short) length; // TODO check range?
+    public Instruction copy() {
+        Instruction i = null;
+        // "Constant" instruction, no need to duplicate
+        if (InstructionConst.getInstruction(this.getOpcode()) != null) {
+            i = this;
+        } else {
+            try {
+                i = (Instruction) clone();
+            } catch (final CloneNotSupportedException e) {
+                System.err.println(e);
+            }
+        }
+        return i;
     }
 
-
-    /** Some instructions may be reused, so don't do anything by default.
+    /**
+     * Some instructions may be reused, so don't do anything by default.
      */
     void dispose() {
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Dumps instruction as byte code to stream out.
      *
-     * @param v Visitor object
+     * @param out Output stream
+     * @throws IOException Thrown when an I/O exception of some sort has occurred.
      */
-    public abstract void accept( Visitor v );
-
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(opcode); // Common for all instructions
+    }
 
-    /** Get Comparator object used in the equals() method to determine
-     * equality of instructions.
+    /**
+     * Tests for equality, delegated to comparator
      *
-     * @return currently used comparator for equals()
-     * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods
+     * @return true if that is an Instruction and has the same opcode
      */
-    @Deprecated
-    public static InstructionComparator getComparator() {
-        return cmp;
+    @Override
+    public boolean equals(final Object that) {
+        return that instanceof Instruction && cmp.equals(this, (Instruction) that);
     }
 
-
-    /** Set comparator to be used for equals().
-      * @deprecated (6.0) use the built in comparator, or wrap this class in another object that implements these methods
+    /**
+     * @return length (in bytes) of instruction
      */
-    @Deprecated
-    public static void setComparator( final InstructionComparator c ) {
-        cmp = c;
+    public int getLength() {
+        return length;
     }
 
+    /**
+     * @return name of instruction, i.e., opcode name
+     */
+    public String getName() {
+        return Const.getOpcodeName(opcode);
+    }
 
-    /** Check for equality, delegated to comparator
-     * @return true if that is an Instruction and has the same opcode
+    /**
+     * @return this instructions opcode
      */
-    @Override
-    public boolean equals( final Object that ) {
-        return (that instanceof Instruction) ? cmp.equals(this, (Instruction) that) : false;
+    public short getOpcode() {
+        return opcode;
     }
 
-    /** calculate the hashCode of this object
+    /**
+     * Gets the hashCode of this object.
+     *
      * @return the hashCode
      * @since 6.0
      */
@@ -581,22 +532,70 @@ public int hashCode() {
     }
 
     /**
-     * Check if the value can fit in a byte (signed)
-     * @param value the value to check
-     * @return true if the value is in range
-     * @since 6.0
+     * Reads needed data (e.g. index) from file.
+     *
+     * @param bytes byte sequence to read from
+     * @param wide "wide" instruction flag
+     * @throws IOException may be thrown if the implementation needs to read data from the file
      */
-    public static boolean isValidByte(final int value) {
-        return value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE;
+    @SuppressWarnings("unused") // thrown by subclasses
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
     }
 
     /**
-     * Check if the value can fit in a short (signed)
-     * @param value the value to check
-     * @return true if the value is in range
+     * This method also gives right results for instructions whose effect on the stack depends on the constant pool entry
+     * they reference.
+     *
+     * @return Number of words produced onto stack by this instruction, or Constants.UNPREDICTABLE, if this can not be
+     *         computed statically
+     */
+    public int produceStack(final ConstantPoolGen cpg) {
+        return Const.getProduceStack(opcode);
+    }
+
+    /**
+     * Needed in readInstruction and subclasses in this package
+     *
      * @since 6.0
      */
-    public static boolean isValidShort(final int value) {
-        return value >= Short.MIN_VALUE && value <= Short.MAX_VALUE;
+    final void setLength(final int length) {
+        this.length = (short) length; // TODO check range?
+    }
+
+    /**
+     * Needed in readInstruction and subclasses in this package
+     */
+    void setOpcode(final short opcode) {
+        this.opcode = opcode;
+    }
+
+    /**
+     * @return mnemonic for instruction in verbose format
+     */
+    @Override
+    public String toString() {
+        return toString(true);
+    }
+
+    /**
+     * Long output format:
+     *
+     * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]" "("&lt;length of instruction&gt;")"
+     *
+     * @param verbose long/short format switch
+     * @return mnemonic for instruction
+     */
+    public String toString(final boolean verbose) {
+        if (verbose) {
+            return getName() + "[" + opcode + "](" + length + ")";
+        }
+        return getName();
+    }
+
+    /**
+     * @return mnemonic for instruction with sumbolic references resolved
+     */
+    public String toString(final ConstantPool cp) {
+        return toString(false);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java
index a3f3c2d45e9..9f806a2d3d7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionComparator.java
@@ -22,15 +22,12 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Equality of instructions isn't clearly to be defined. You might
- * wish, for example, to compare whether instructions have the same
- * meaning. E.g., whether two INVOKEVIRTUALs describe the same
- * call.
+ * Equality of instructions isn't clearly to be defined. You might wish, for example, to compare whether instructions
+ * have the same meaning. E.g., whether two INVOKEVIRTUALs describe the same call.
  * <p>
- * The DEFAULT comparator however, considers two instructions
- * to be equal if they have same opcode and point to the same indexes
- * (if any) in the constant pool or the same local variable index. Branch
- * instructions must have the same target.
+ * The DEFAULT comparator however, considers two instructions to be equal if they have same opcode and point to the same
+ * indexes (if any) in the constant pool or the same local variable index. Branch instructions must have the same
+ * target.
  * </p>
  *
  * @see Instruction
@@ -40,25 +37,24 @@ public interface InstructionComparator {
     InstructionComparator DEFAULT = (i1, i2) -> {
         if (i1.getOpcode() == i2.getOpcode()) {
             if (i1 instanceof BranchInstruction) {
-             // BIs are never equal to make targeters work correctly (BCEL-195)
+                // BIs are never equal to make targeters work correctly (BCEL-195)
                 return false;
 //                } else if (i1 == i2) { TODO consider adding this shortcut
 //                    return true; // this must be AFTER the BI test
-            } else if (i1 instanceof ConstantPushInstruction) {
-                return ((ConstantPushInstruction) i1).getValue().equals(
-                        ((ConstantPushInstruction) i2).getValue());
-            } else if (i1 instanceof IndexedInstruction) {
-                return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2)
-                        .getIndex();
-            } else if (i1 instanceof NEWARRAY) {
+            }
+            if (i1 instanceof ConstantPushInstruction) {
+                return ((ConstantPushInstruction) i1).getValue().equals(((ConstantPushInstruction) i2).getValue());
+            }
+            if (i1 instanceof IndexedInstruction) {
+                return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2).getIndex();
+            }
+            if (i1 instanceof NEWARRAY) {
                 return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2).getTypecode();
-            } else {
-                return true;
             }
+            return true;
         }
         return false;
     };
 
-
-    boolean equals( Instruction i1, Instruction i2 );
+    boolean equals(Instruction i1, Instruction i2);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionConst.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionConst.java
index fece96b10ca..439268e35eb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionConst.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionConst.java
@@ -24,28 +24,24 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * This interface contains shareable instruction objects.
- *
- * In order to save memory you can use some instructions multiply,
- * since they have an immutable state and are directly derived from
- * Instruction.  I.e. they have no instance fields that could be
- * changed. Since some of these instructions like ICONST_0 occur
- * very frequently this can save a lot of time and space. This
- * feature is an adaptation of the FlyWeight design pattern, we
- * just use an array instead of a factory.
- *
- * The Instructions can also accessed directly under their names, so
- * it's possible to write il.append(Instruction.ICONST_0);
- *
+ * Contains shareable instruction objects.
+ * <p>
+ * In order to save memory you can use some instructions multiply, since they have an immutable state and are directly
+ * derived from Instruction. I.e. they have no instance fields that could be changed. Since some of these instructions
+ * like ICONST_0 occur very frequently this can save a lot of time and space. This feature is an adaptation of the
+ * FlyWeight design pattern, we just use an array instead of a factory.
+ * </p>
+ * <p>
+ * The Instructions can also accessed directly under their names, so it's possible to write
+ * il.append(Instruction.ICONST_0);
+ * </p>
  */
 public final class InstructionConst {
 
     /**
-     * Predefined instruction objects
-     */
-    /*
-     * NOTE these are not currently immutable, because Instruction
-     * has mutable protected fields opcode and length.
+     * Predefined instruction objects.
+     *
+     * NOTE these are not currently immutable, because Instruction has mutable protected fields opcode and length.
      */
     public static final Instruction NOP = new NOP();
     public static final Instruction ACONST_NULL = new ACONST_NULL();
@@ -155,8 +151,9 @@ public final class InstructionConst {
     public static final Instruction MONITORENTER = new MONITORENTER();
     public static final Instruction MONITOREXIT = new MONITOREXIT();
 
-    /** You can use these constants in multiple places safely, if you can guarantee
-     * that you will never alter their internal values, e.g. call setIndex().
+    /**
+     * You can use these constants in multiple places safely, if you can guarantee that you will never alter their internal
+     * values, e.g. call setIndex().
      */
     public static final LocalVariableInstruction THIS = new ALOAD(0);
     public static final LocalVariableInstruction ALOAD_0 = THIS;
@@ -172,10 +169,10 @@ public final class InstructionConst {
     public static final LocalVariableInstruction ISTORE_1 = new ISTORE(1);
     public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2);
 
-    /** Get object via its opcode, for immutable instructions like
-     * branch instructions entries are set to null.
+    /**
+     * Get object via its opcode, for immutable instructions like branch instructions entries are set to null.
      */
-    private static final Instruction[] INSTRUCTIONS = new Instruction[256];
+    static final Instruction[] INSTRUCTIONS = new Instruction[256];
 
     static {
         INSTRUCTIONS[Const.NOP] = NOP;
@@ -287,14 +284,16 @@ public final class InstructionConst {
         INSTRUCTIONS[Const.MONITOREXIT] = MONITOREXIT;
     }
 
-    private InstructionConst() { } // non-instantiable
-
     /**
      * Gets the Instruction.
+     *
      * @param index the index, e.g. {@link Const#RETURN}
      * @return the entry from the private INSTRUCTIONS table
      */
     public static Instruction getInstruction(final int index) {
         return INSTRUCTIONS[index];
     }
+
+    private InstructionConst() {
+    } // non-instantiable
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java
index d2ec08ed678..5e9220354c3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,672 +22,673 @@
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * Instances of this class may be used, e.g., to generate typed
- * versions of instructions. Its main purpose is to be used as the
- * byte code generating backend of a compiler. You can subclass it to
- * add your own create methods.
+ * Instances of this class may be used, e.g., to generate typed versions of instructions. Its main purpose is to be used
+ * as the byte code generating backend of a compiler. You can subclass it to add your own create methods.
  * <p>
- * Note: The static createXXX methods return singleton instances
- * from the {@link InstructionConst} class.
+ * Note: The static createXXX methods return singleton instances from the {@link InstructionConst} class.
+ * </p>
  *
  * @see Const
  * @see InstructionConst
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public class InstructionFactory {
 
-    // N.N. These must agree with the order of Constants.T_CHAR through T_LONG
-    private static final String[] short_names = {
-            "C", "F", "D", "B", "S", "I", "L"
-    };
-
-    private ClassGen cg;
-    private ConstantPoolGen cp;
-
-    public InstructionFactory(final ClassGen cg, final ConstantPoolGen cp) {
-        this.cg = cg;
-        this.cp = cp;
-    }
+    private static class MethodObject {
 
+        final Type[] argTypes;
+        final Type resultType;
+        final String className;
+        final String name;
 
-    /** Initialize with ClassGen object
-     */
-    public InstructionFactory(final ClassGen cg) {
-        this(cg, cg.getConstantPool());
+        MethodObject(final String c, final String n, final Type r, final Type[] a) {
+            this.className = c;
+            this.name = n;
+            this.resultType = r;
+            this.argTypes = a;
+        }
     }
 
+    private static final String APPEND = "append";
 
-    /** Initialize just with ConstantPoolGen object
-     */
-    public InstructionFactory(final ConstantPoolGen cp) {
-        this(null, cp);
-    }
-
+    private static final String FQCN_STRING_BUFFER = "java.lang.StringBuffer";
 
-    /** Create an invoke instruction. (Except for invokedynamic.)
-     *
-     * @param class_name name of the called class
-     * @param name name of the called method
-     * @param ret_type return type of method
-     * @param arg_types argument types of method
-     * @param kind how to invoke, i.e., INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL,
-     * or INVOKESPECIAL
-     * @see Const
-     */
-    public InvokeInstruction createInvoke( final String class_name, final String name,
-            final Type ret_type, final Type[] arg_types, final short kind ) {
-        return createInvoke(class_name, name, ret_type, arg_types, kind, kind == Const.INVOKEINTERFACE);
-    }
+    // N.N. These must agree with the order of Constants.T_CHAR through T_LONG
+    private static final String[] shortNames = {"C", "F", "D", "B", "S", "I", "L"};
+
+    private static final MethodObject[] appendMethodObjects = {
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.STRING }),
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.OBJECT }), null, null, // indices 2, 3
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.BOOLEAN }),
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.CHAR }),
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.FLOAT }),
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.DOUBLE }),
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.INT }),
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.INT }), // No append(byte)
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.INT }), // No append(short)
+            new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.LONG })};
 
     /**
-     * Creates an invoke instruction. (Except for invokedynamic.)
-     *
-     * @param class_name name of the called class
-     * @param name name of the called method
-     * @param ret_type return type of method
-     * @param arg_types argument types of method
-     * @param kind how to invoke: INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL
-     * @param use_interface force use of InterfaceMethodref
-     * @return A new InvokeInstruction.
-     * @since 6.5.0
+     * @param type type of elements of array, i.e., array.getElementType()
      */
-    public InvokeInstruction createInvoke( final String class_name, final String name, final Type ret_type,
-        final Type[] arg_types, final short kind, final boolean use_interface) {
-        if (kind != Const.INVOKESPECIAL && kind != Const.INVOKEVIRTUAL && kind != Const.INVOKESTATIC
-            && kind != Const.INVOKEINTERFACE && kind != Const.INVOKEDYNAMIC) {
-            throw new IllegalArgumentException("Unknown invoke kind: " + kind);
-        }
-        int index;
-        int nargs = 0;
-        final String signature = Type.getMethodSignature(ret_type, arg_types);
-        for (final Type arg_type : arg_types) {
-            nargs += arg_type.getSize();
-        }
-        if (use_interface) {
-            index = cp.addInterfaceMethodref(class_name, name, signature);
-        } else {
-            index = cp.addMethodref(class_name, name, signature);
-        }
-        switch (kind) {
-        case Const.INVOKESPECIAL:
-            return new INVOKESPECIAL(index);
-        case Const.INVOKEVIRTUAL:
-            return new INVOKEVIRTUAL(index);
-        case Const.INVOKESTATIC:
-            return new INVOKESTATIC(index);
-        case Const.INVOKEINTERFACE:
-            return new INVOKEINTERFACE(index, nargs + 1);
-        case Const.INVOKEDYNAMIC:
-            return new INVOKEDYNAMIC(index);
+    public static ArrayInstruction createArrayLoad(final Type type) {
+        switch (type.getType()) {
+        case Const.T_BOOLEAN:
+        case Const.T_BYTE:
+            return InstructionConst.BALOAD;
+        case Const.T_CHAR:
+            return InstructionConst.CALOAD;
+        case Const.T_SHORT:
+            return InstructionConst.SALOAD;
+        case Const.T_INT:
+            return InstructionConst.IALOAD;
+        case Const.T_FLOAT:
+            return InstructionConst.FALOAD;
+        case Const.T_DOUBLE:
+            return InstructionConst.DALOAD;
+        case Const.T_LONG:
+            return InstructionConst.LALOAD;
+        case Const.T_ARRAY:
+        case Const.T_OBJECT:
+            return InstructionConst.AALOAD;
         default:
-            // Can't happen
-            throw new IllegalStateException("Unknown invoke kind: " + kind);
+            throw new IllegalArgumentException("Invalid type " + type);
         }
     }
 
-    /** Create an invokedynamic instruction.
-     *
-     * @param bootstrap_index index into the bootstrap_methods array
-     * @param name name of the called method
-     * @param ret_type return type of method
-     * @param arg_types argument types of method
-     * @see Constants
+    /**
+     * @param type type of elements of array, i.e., array.getElementType()
      */
-/*
- * createInvokeDynamic only needed if instrumention code wants to generate
- * a new invokedynamic instruction.  I don't think we need.  (markro)
- *
-    public InvokeInstruction createInvokeDynamic( int bootstrap_index, String name, Type ret_type,
-            Type[] arg_types) {
-        int index;
-        int nargs = 0;
-        String signature = Type.getMethodSignature(ret_type, arg_types);
-        for (int i = 0; i < arg_types.length; i++) {
-            nargs += arg_types[i].getSize();
+    public static ArrayInstruction createArrayStore(final Type type) {
+        switch (type.getType()) {
+        case Const.T_BOOLEAN:
+        case Const.T_BYTE:
+            return InstructionConst.BASTORE;
+        case Const.T_CHAR:
+            return InstructionConst.CASTORE;
+        case Const.T_SHORT:
+            return InstructionConst.SASTORE;
+        case Const.T_INT:
+            return InstructionConst.IASTORE;
+        case Const.T_FLOAT:
+            return InstructionConst.FASTORE;
+        case Const.T_DOUBLE:
+            return InstructionConst.DASTORE;
+        case Const.T_LONG:
+            return InstructionConst.LASTORE;
+        case Const.T_ARRAY:
+        case Const.T_OBJECT:
+            return InstructionConst.AASTORE;
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
         }
-        // UNDONE - needs to be added to ConstantPoolGen
-        //index = cp.addInvokeDynamic(bootstrap_index, name, signature);
-        index = 0;
-        return new INVOKEDYNAMIC(index);
-    }
- */
-
-    /** Create a call to the most popular System.out.println() method.
-     *
-     * @param s the string to print
-     */
-    public InstructionList createPrintln( final String s ) {
-        final InstructionList il = new InstructionList();
-        final int out = cp.addFieldref("java.lang.System", "out", "Ljava/io/PrintStream;");
-        final int println = cp.addMethodref("java.io.PrintStream", "println", "(Ljava/lang/String;)V");
-        il.append(new GETSTATIC(out));
-        il.append(new PUSH(cp, s));
-        il.append(new INVOKEVIRTUAL(println));
-        return il;
     }
 
-
-    /** Uses PUSH to push a constant value onto the stack.
-     * @param value must be of type Number, Boolean, Character or String
-     */
-    public Instruction createConstant( final Object value ) {
-        PUSH push;
-        if (value instanceof Number) {
-            push = new PUSH(cp, (Number) value);
-        } else if (value instanceof String) {
-            push = new PUSH(cp, (String) value);
-        } else if (value instanceof Boolean) {
-            push = new PUSH(cp, (Boolean) value);
-        } else if (value instanceof Character) {
-            push = new PUSH(cp, (Character) value);
-        } else {
-            throw new ClassGenException("Illegal type: " + value.getClass());
+    private static ArithmeticInstruction createBinaryDoubleOp(final char op) {
+        switch (op) {
+        case '-':
+            return InstructionConst.DSUB;
+        case '+':
+            return InstructionConst.DADD;
+        case '*':
+            return InstructionConst.DMUL;
+        case '/':
+            return InstructionConst.DDIV;
+        case '%':
+            return InstructionConst.DREM;
+        default:
+            throw new IllegalArgumentException("Invalid operand " + op);
         }
-        return push.getInstruction();
     }
 
-    private static class MethodObject {
-
-        final Type[] arg_types;
-        final Type result_type;
-        final String class_name;
-        final String name;
-
-
-        MethodObject(final String c, final String n, final Type r, final Type[] a) {
-            class_name = c;
-            name = n;
-            result_type = r;
-            arg_types = a;
+    private static ArithmeticInstruction createBinaryFloatOp(final char op) {
+        switch (op) {
+        case '-':
+            return InstructionConst.FSUB;
+        case '+':
+            return InstructionConst.FADD;
+        case '*':
+            return InstructionConst.FMUL;
+        case '/':
+            return InstructionConst.FDIV;
+        case '%':
+            return InstructionConst.FREM;
+        default:
+            throw new IllegalArgumentException("Invalid operand " + op);
         }
     }
 
-
-    private InvokeInstruction createInvoke( final MethodObject m, final short kind ) {
-        return createInvoke(m.class_name, m.name, m.result_type, m.arg_types, kind);
-    }
-
-    private static final MethodObject[] append_mos = {
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.STRING
-            }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.OBJECT
-            }),
-            null,
-            null, // indices 2, 3
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.BOOLEAN
-            }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.CHAR
-            }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.FLOAT
-            }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.DOUBLE
-            }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.INT
-            }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(byte)
-                    new Type[] {
-                        Type.INT
-                    }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(short)
-                    new Type[] {
-                        Type.INT
-                    }),
-            new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] {
-                Type.LONG
-            })
-    };
-
-
-    private static boolean isString( final Type type ) {
-        return (type instanceof ObjectType) &&
-              ((ObjectType) type).getClassName().equals("java.lang.String");
-    }
-
-
-    public Instruction createAppend( final Type type ) {
-        final byte t = type.getType();
-        if (isString(type)) {
-            return createInvoke(append_mos[0], Const.INVOKEVIRTUAL);
-        }
-        switch (t) {
-            case Const.T_BOOLEAN:
-            case Const.T_CHAR:
-            case Const.T_FLOAT:
-            case Const.T_DOUBLE:
-            case Const.T_BYTE:
-            case Const.T_SHORT:
-            case Const.T_INT:
-            case Const.T_LONG:
-                return createInvoke(append_mos[t], Const.INVOKEVIRTUAL);
-            case Const.T_ARRAY:
-            case Const.T_OBJECT:
-                return createInvoke(append_mos[1], Const.INVOKEVIRTUAL);
-            default:
-                throw new IllegalArgumentException("No append for this type? " + type);
+    private static ArithmeticInstruction createBinaryIntOp(final char first, final String op) {
+        switch (first) {
+        case '-':
+            return InstructionConst.ISUB;
+        case '+':
+            return InstructionConst.IADD;
+        case '%':
+            return InstructionConst.IREM;
+        case '*':
+            return InstructionConst.IMUL;
+        case '/':
+            return InstructionConst.IDIV;
+        case '&':
+            return InstructionConst.IAND;
+        case '|':
+            return InstructionConst.IOR;
+        case '^':
+            return InstructionConst.IXOR;
+        case '<':
+            return InstructionConst.ISHL;
+        case '>':
+            return op.equals(">>>") ? InstructionConst.IUSHR : InstructionConst.ISHR;
+        default:
+            throw new IllegalArgumentException("Invalid operand " + op);
         }
     }
 
-
-    /** Create a field instruction.
+    /**
+     * Create an invokedynamic instruction.
      *
-     * @param class_name name of the accessed class
-     * @param name name of the referenced field
-     * @param type  type of field
-     * @param kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC
+     * @param bootstrap_index index into the bootstrap_methods array
+     * @param name name of the called method
+     * @param ret_type return type of method
+     * @param argTypes argument types of method
      * @see Const
      */
-    public FieldInstruction createFieldAccess( final String class_name,
-            final String name, final Type type, final short kind ) {
-        int index;
-        final String signature = type.getSignature();
-        index = cp.addFieldref(class_name, name, signature);
-        switch (kind) {
-            case Const.GETFIELD:
-                return new GETFIELD(index);
-            case Const.PUTFIELD:
-                return new PUTFIELD(index);
-            case Const.GETSTATIC:
-                return new GETSTATIC(index);
-            case Const.PUTSTATIC:
-                return new PUTSTATIC(index);
-            default:
-                throw new IllegalArgumentException("Unknown getfield kind:" + kind);
-        }
-    }
-
-
-    /** Create reference to `this'
-     */
-    public static Instruction createThis() {
-        return new ALOAD(0);
-    }
-
 
-    /** Create typed return
+    /*
+     * createInvokeDynamic only needed if instrumentation code wants to generate a new invokedynamic instruction. I don't
+     * think we need.
+     *
+     * public InvokeInstruction createInvokeDynamic( int bootstrap_index, String name, Type ret_type, Type[] argTypes) {
+     * int index; int nargs = 0; String signature = Type.getMethodSignature(ret_type, argTypes); for (int i = 0; i <
+     * argTypes.length; i++) { nargs += argTypes[i].getSize(); } // UNDONE - needs to be added to ConstantPoolGen //index
+     * = cp.addInvokeDynamic(bootstrap_index, name, signature); index = 0; return new INVOKEDYNAMIC(index); }
      */
-    public static ReturnInstruction createReturn( final Type type ) {
-        switch (type.getType()) {
-            case Const.T_ARRAY:
-            case Const.T_OBJECT:
-                return InstructionConst.ARETURN;
-            case Const.T_INT:
-            case Const.T_SHORT:
-            case Const.T_BOOLEAN:
-            case Const.T_CHAR:
-            case Const.T_BYTE:
-                return InstructionConst.IRETURN;
-            case Const.T_FLOAT:
-                return InstructionConst.FRETURN;
-            case Const.T_DOUBLE:
-                return InstructionConst.DRETURN;
-            case Const.T_LONG:
-                return InstructionConst.LRETURN;
-            case Const.T_VOID:
-                return InstructionConst.RETURN;
-            default:
-                throw new IllegalArgumentException("Invalid type: " + type);
-        }
-    }
-
 
-    private static ArithmeticInstruction createBinaryIntOp( final char first, final String op ) {
+    private static ArithmeticInstruction createBinaryLongOp(final char first, final String op) {
         switch (first) {
-            case '-':
-                return InstructionConst.ISUB;
-            case '+':
-                return InstructionConst.IADD;
-            case '%':
-                return InstructionConst.IREM;
-            case '*':
-                return InstructionConst.IMUL;
-            case '/':
-                return InstructionConst.IDIV;
-            case '&':
-                return InstructionConst.IAND;
-            case '|':
-                return InstructionConst.IOR;
-            case '^':
-                return InstructionConst.IXOR;
-            case '<':
-                return InstructionConst.ISHL;
-            case '>':
-                return op.equals(">>>") ? InstructionConst.IUSHR : InstructionConst.ISHR;
-            default:
-                throw new IllegalArgumentException("Invalid operand " + op);
-        }
-    }
-
-
-    private static ArithmeticInstruction createBinaryLongOp( final char first, final String op ) {
-        switch (first) {
-            case '-':
-                return InstructionConst.LSUB;
-            case '+':
-                return InstructionConst.LADD;
-            case '%':
-                return InstructionConst.LREM;
-            case '*':
-                return InstructionConst.LMUL;
-            case '/':
-                return InstructionConst.LDIV;
-            case '&':
-                return InstructionConst.LAND;
-            case '|':
-                return InstructionConst.LOR;
-            case '^':
-                return InstructionConst.LXOR;
-            case '<':
-                return InstructionConst.LSHL;
-            case '>':
-                return op.equals(">>>") ? InstructionConst.LUSHR : InstructionConst.LSHR;
-            default:
-                throw new IllegalArgumentException("Invalid operand " + op);
-        }
-    }
-
-
-    private static ArithmeticInstruction createBinaryFloatOp( final char op ) {
-        switch (op) {
-            case '-':
-                return InstructionConst.FSUB;
-            case '+':
-                return InstructionConst.FADD;
-            case '*':
-                return InstructionConst.FMUL;
-            case '/':
-                return InstructionConst.FDIV;
-            case '%':
-                return InstructionConst.FREM;
-            default:
-                throw new IllegalArgumentException("Invalid operand " + op);
-        }
-    }
-
-
-    private static ArithmeticInstruction createBinaryDoubleOp( final char op ) {
-        switch (op) {
-            case '-':
-                return InstructionConst.DSUB;
-            case '+':
-                return InstructionConst.DADD;
-            case '*':
-                return InstructionConst.DMUL;
-            case '/':
-                return InstructionConst.DDIV;
-            case '%':
-                return InstructionConst.DREM;
-            default:
-                throw new IllegalArgumentException("Invalid operand " + op);
+        case '-':
+            return InstructionConst.LSUB;
+        case '+':
+            return InstructionConst.LADD;
+        case '%':
+            return InstructionConst.LREM;
+        case '*':
+            return InstructionConst.LMUL;
+        case '/':
+            return InstructionConst.LDIV;
+        case '&':
+            return InstructionConst.LAND;
+        case '|':
+            return InstructionConst.LOR;
+        case '^':
+            return InstructionConst.LXOR;
+        case '<':
+            return InstructionConst.LSHL;
+        case '>':
+            return op.equals(">>>") ? InstructionConst.LUSHR : InstructionConst.LSHR;
+        default:
+            throw new IllegalArgumentException("Invalid operand " + op);
         }
     }
 
-
     /**
      * Create binary operation for simple basic types, such as int and float.
      *
      * @param op operation, such as "+", "*", "&lt;&lt;", etc.
      */
-    public static ArithmeticInstruction createBinaryOperation( final String op, final Type type ) {
+    public static ArithmeticInstruction createBinaryOperation(final String op, final Type type) {
         final char first = op.charAt(0);
         switch (type.getType()) {
-            case Const.T_BYTE:
-            case Const.T_SHORT:
-            case Const.T_INT:
-            case Const.T_CHAR:
-                return createBinaryIntOp(first, op);
-            case Const.T_LONG:
-                return createBinaryLongOp(first, op);
-            case Const.T_FLOAT:
-                return createBinaryFloatOp(first);
-            case Const.T_DOUBLE:
-                return createBinaryDoubleOp(first);
-            default:
-                throw new IllegalArgumentException("Invalid type " + type);
+        case Const.T_BYTE:
+        case Const.T_SHORT:
+        case Const.T_INT:
+        case Const.T_CHAR:
+            return createBinaryIntOp(first, op);
+        case Const.T_LONG:
+            return createBinaryLongOp(first, op);
+        case Const.T_FLOAT:
+            return createBinaryFloatOp(first);
+        case Const.T_DOUBLE:
+            return createBinaryDoubleOp(first);
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
         }
     }
 
+    /**
+     * Create branch instruction by given opcode, except LOOKUPSWITCH and TABLESWITCH. For those you should use the SWITCH
+     * compound instruction.
+     */
+    public static BranchInstruction createBranchInstruction(final short opcode, final InstructionHandle target) {
+        switch (opcode) {
+        case Const.IFEQ:
+            return new IFEQ(target);
+        case Const.IFNE:
+            return new IFNE(target);
+        case Const.IFLT:
+            return new IFLT(target);
+        case Const.IFGE:
+            return new IFGE(target);
+        case Const.IFGT:
+            return new IFGT(target);
+        case Const.IFLE:
+            return new IFLE(target);
+        case Const.IF_ICMPEQ:
+            return new IF_ICMPEQ(target);
+        case Const.IF_ICMPNE:
+            return new IF_ICMPNE(target);
+        case Const.IF_ICMPLT:
+            return new IF_ICMPLT(target);
+        case Const.IF_ICMPGE:
+            return new IF_ICMPGE(target);
+        case Const.IF_ICMPGT:
+            return new IF_ICMPGT(target);
+        case Const.IF_ICMPLE:
+            return new IF_ICMPLE(target);
+        case Const.IF_ACMPEQ:
+            return new IF_ACMPEQ(target);
+        case Const.IF_ACMPNE:
+            return new IF_ACMPNE(target);
+        case Const.GOTO:
+            return new GOTO(target);
+        case Const.JSR:
+            return new JSR(target);
+        case Const.IFNULL:
+            return new IFNULL(target);
+        case Const.IFNONNULL:
+            return new IFNONNULL(target);
+        case Const.GOTO_W:
+            return new GOTO_W(target);
+        case Const.JSR_W:
+            return new JSR_W(target);
+        default:
+            throw new IllegalArgumentException("Invalid opcode: " + opcode);
+        }
+    }
 
     /**
      * @param size size of operand, either 1 (int, e.g.) or 2 (double)
      */
-    public static StackInstruction createPop( final int size ) {
-        return (size == 2) ? InstructionConst.POP2 : InstructionConst.POP;
+    public static StackInstruction createDup(final int size) {
+        return size == 2 ? InstructionConst.DUP2 : InstructionConst.DUP;
     }
 
-
     /**
      * @param size size of operand, either 1 (int, e.g.) or 2 (double)
      */
-    public static StackInstruction createDup( final int size ) {
-        return (size == 2) ? InstructionConst.DUP2 : InstructionConst.DUP;
+    public static StackInstruction createDup_1(final int size) {
+        return size == 2 ? InstructionConst.DUP2_X1 : InstructionConst.DUP_X1;
     }
 
-
     /**
      * @param size size of operand, either 1 (int, e.g.) or 2 (double)
      */
-    public static StackInstruction createDup_2( final int size ) {
-        return (size == 2) ? InstructionConst.DUP2_X2 : InstructionConst.DUP_X2;
+    public static StackInstruction createDup_2(final int size) {
+        return size == 2 ? InstructionConst.DUP2_X2 : InstructionConst.DUP_X2;
     }
 
+    /**
+     * @param index index of local variable
+     */
+    public static LocalVariableInstruction createLoad(final Type type, final int index) {
+        switch (type.getType()) {
+        case Const.T_BOOLEAN:
+        case Const.T_CHAR:
+        case Const.T_BYTE:
+        case Const.T_SHORT:
+        case Const.T_INT:
+            return new ILOAD(index);
+        case Const.T_FLOAT:
+            return new FLOAD(index);
+        case Const.T_DOUBLE:
+            return new DLOAD(index);
+        case Const.T_LONG:
+            return new LLOAD(index);
+        case Const.T_ARRAY:
+        case Const.T_OBJECT:
+            return new ALOAD(index);
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
+        }
+    }
 
     /**
-     * @param size size of operand, either 1 (int, e.g.) or 2 (double)
+     * Create "null" value for reference types, 0 for basic types like int
      */
-    public static StackInstruction createDup_1( final int size ) {
-        return (size == 2) ? InstructionConst.DUP2_X1 : InstructionConst.DUP_X1;
+    public static Instruction createNull(final Type type) {
+        switch (type.getType()) {
+        case Const.T_ARRAY:
+        case Const.T_OBJECT:
+            return InstructionConst.ACONST_NULL;
+        case Const.T_INT:
+        case Const.T_SHORT:
+        case Const.T_BOOLEAN:
+        case Const.T_CHAR:
+        case Const.T_BYTE:
+            return InstructionConst.ICONST_0;
+        case Const.T_FLOAT:
+            return InstructionConst.FCONST_0;
+        case Const.T_DOUBLE:
+            return InstructionConst.DCONST_0;
+        case Const.T_LONG:
+            return InstructionConst.LCONST_0;
+        case Const.T_VOID:
+            return InstructionConst.NOP;
+        default:
+            throw new IllegalArgumentException("Invalid type: " + type);
+        }
     }
 
+    /**
+     * @param size size of operand, either 1 (int, e.g.) or 2 (double)
+     */
+    public static StackInstruction createPop(final int size) {
+        return size == 2 ? InstructionConst.POP2 : InstructionConst.POP;
+    }
 
     /**
-     * @param index index of local variable
+     * Create typed return
      */
-    public static LocalVariableInstruction createStore( final Type type, final int index ) {
+    public static ReturnInstruction createReturn(final Type type) {
         switch (type.getType()) {
-            case Const.T_BOOLEAN:
-            case Const.T_CHAR:
-            case Const.T_BYTE:
-            case Const.T_SHORT:
-            case Const.T_INT:
-                return new ISTORE(index);
-            case Const.T_FLOAT:
-                return new FSTORE(index);
-            case Const.T_DOUBLE:
-                return new DSTORE(index);
-            case Const.T_LONG:
-                return new LSTORE(index);
-            case Const.T_ARRAY:
-            case Const.T_OBJECT:
-                return new ASTORE(index);
-            default:
-                throw new IllegalArgumentException("Invalid type " + type);
+        case Const.T_ARRAY:
+        case Const.T_OBJECT:
+            return InstructionConst.ARETURN;
+        case Const.T_INT:
+        case Const.T_SHORT:
+        case Const.T_BOOLEAN:
+        case Const.T_CHAR:
+        case Const.T_BYTE:
+            return InstructionConst.IRETURN;
+        case Const.T_FLOAT:
+            return InstructionConst.FRETURN;
+        case Const.T_DOUBLE:
+            return InstructionConst.DRETURN;
+        case Const.T_LONG:
+            return InstructionConst.LRETURN;
+        case Const.T_VOID:
+            return InstructionConst.RETURN;
+        default:
+            throw new IllegalArgumentException("Invalid type: " + type);
         }
     }
 
-
     /**
      * @param index index of local variable
      */
-    public static LocalVariableInstruction createLoad( final Type type, final int index ) {
+    public static LocalVariableInstruction createStore(final Type type, final int index) {
         switch (type.getType()) {
-            case Const.T_BOOLEAN:
-            case Const.T_CHAR:
-            case Const.T_BYTE:
-            case Const.T_SHORT:
-            case Const.T_INT:
-                return new ILOAD(index);
-            case Const.T_FLOAT:
-                return new FLOAD(index);
-            case Const.T_DOUBLE:
-                return new DLOAD(index);
-            case Const.T_LONG:
-                return new LLOAD(index);
-            case Const.T_ARRAY:
-            case Const.T_OBJECT:
-                return new ALOAD(index);
-            default:
-                throw new IllegalArgumentException("Invalid type " + type);
+        case Const.T_BOOLEAN:
+        case Const.T_CHAR:
+        case Const.T_BYTE:
+        case Const.T_SHORT:
+        case Const.T_INT:
+            return new ISTORE(index);
+        case Const.T_FLOAT:
+            return new FSTORE(index);
+        case Const.T_DOUBLE:
+            return new DSTORE(index);
+        case Const.T_LONG:
+            return new LSTORE(index);
+        case Const.T_ARRAY:
+        case Const.T_OBJECT:
+            return new ASTORE(index);
+        default:
+            throw new IllegalArgumentException("Invalid type " + type);
         }
     }
 
+    /**
+     * Create reference to 'this'
+     */
+    public static Instruction createThis() {
+        return new ALOAD(0);
+    }
+
+    private static boolean isString(final Type type) {
+        return type instanceof ObjectType && ((ObjectType) type).getClassName().equals("java.lang.String");
+    }
 
     /**
-     * @param type type of elements of array, i.e., array.getElementType()
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    public static ArrayInstruction createArrayLoad( final Type type ) {
-        switch (type.getType()) {
-            case Const.T_BOOLEAN:
-            case Const.T_BYTE:
-                return InstructionConst.BALOAD;
-            case Const.T_CHAR:
-                return InstructionConst.CALOAD;
-            case Const.T_SHORT:
-                return InstructionConst.SALOAD;
-            case Const.T_INT:
-                return InstructionConst.IALOAD;
-            case Const.T_FLOAT:
-                return InstructionConst.FALOAD;
-            case Const.T_DOUBLE:
-                return InstructionConst.DALOAD;
-            case Const.T_LONG:
-                return InstructionConst.LALOAD;
-            case Const.T_ARRAY:
-            case Const.T_OBJECT:
-                return InstructionConst.AALOAD;
-            default:
-                throw new IllegalArgumentException("Invalid type " + type);
-        }
+    @Deprecated
+    protected ClassGen cg;
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected ConstantPoolGen cp;
+
+    /**
+     * Initialize with ClassGen object
+     */
+    public InstructionFactory(final ClassGen cg) {
+        this(cg, cg.getConstantPool());
     }
 
+    public InstructionFactory(final ClassGen cg, final ConstantPoolGen cp) {
+        this.cg = cg;
+        this.cp = cp;
+    }
 
     /**
-     * @param type type of elements of array, i.e., array.getElementType()
+     * Initialize just with ConstantPoolGen object
      */
-    public static ArrayInstruction createArrayStore( final Type type ) {
-        switch (type.getType()) {
-            case Const.T_BOOLEAN:
-            case Const.T_BYTE:
-                return InstructionConst.BASTORE;
-            case Const.T_CHAR:
-                return InstructionConst.CASTORE;
-            case Const.T_SHORT:
-                return InstructionConst.SASTORE;
-            case Const.T_INT:
-                return InstructionConst.IASTORE;
-            case Const.T_FLOAT:
-                return InstructionConst.FASTORE;
-            case Const.T_DOUBLE:
-                return InstructionConst.DASTORE;
-            case Const.T_LONG:
-                return InstructionConst.LASTORE;
-            case Const.T_ARRAY:
-            case Const.T_OBJECT:
-                return InstructionConst.AASTORE;
-            default:
-                throw new IllegalArgumentException("Invalid type " + type);
+    public InstructionFactory(final ConstantPoolGen cp) {
+        this(null, cp);
+    }
+
+    public Instruction createAppend(final Type type) {
+        final byte t = type.getType();
+        if (isString(type)) {
+            return createInvoke(appendMethodObjects[0], Const.INVOKEVIRTUAL);
+        }
+        switch (t) {
+        case Const.T_BOOLEAN:
+        case Const.T_CHAR:
+        case Const.T_FLOAT:
+        case Const.T_DOUBLE:
+        case Const.T_BYTE:
+        case Const.T_SHORT:
+        case Const.T_INT:
+        case Const.T_LONG:
+            return createInvoke(appendMethodObjects[t], Const.INVOKEVIRTUAL);
+        case Const.T_ARRAY:
+        case Const.T_OBJECT:
+            return createInvoke(appendMethodObjects[1], Const.INVOKEVIRTUAL);
+        default:
+            throw new IllegalArgumentException("No append for this type? " + type);
         }
     }
 
     /**
-     * Create conversion operation for two stack operands, this may be an I2C,
-     * instruction, e.g., if the operands are basic types and CHECKCAST if they
-     * are reference types.
+     * Create conversion operation for two stack operands, this may be an I2C, instruction, e.g., if the operands are basic
+     * types and CHECKCAST if they are reference types.
      */
-    public Instruction createCast( final Type src_type, final Type dest_type ) {
-        if ((src_type instanceof BasicType) && (dest_type instanceof BasicType)) {
-            final byte dest = dest_type.getType();
-            byte src = src_type.getType();
-            if (dest == Const.T_LONG
-                    && (src == Const.T_CHAR || src == Const.T_BYTE || src == Const.T_SHORT)) {
+    public Instruction createCast(final Type srcType, final Type destType) {
+        if (srcType instanceof BasicType && destType instanceof BasicType) {
+            final byte dest = destType.getType();
+            byte src = srcType.getType();
+            if (dest == Const.T_LONG && (src == Const.T_CHAR || src == Const.T_BYTE || src == Const.T_SHORT)) {
                 src = Const.T_INT;
             }
-            final String name = "com.sun.org.apache.bcel.internal.generic." + short_names[src - Const.T_CHAR] + "2"
-                    + short_names[dest - Const.T_CHAR];
+            final String name = "com.sun.org.apache.bcel.internal.generic." + shortNames[src - Const.T_CHAR] + "2" + shortNames[dest - Const.T_CHAR];
             Instruction i = null;
             try {
-                i = (Instruction) java.lang.Class.forName(name).getDeclaredConstructor().newInstance();
+                i = (Instruction) Class.forName(name).getDeclaredConstructor().newInstance();;
             } catch (final Exception e) {
                 throw new IllegalArgumentException("Could not find instruction: " + name, e);
             }
             return i;
-        } else if ((src_type instanceof ReferenceType) && (dest_type instanceof ReferenceType)) {
-            if (dest_type instanceof ArrayType) {
-                return new CHECKCAST(cp.addArrayClass((ArrayType) dest_type));
-            }
-            return new CHECKCAST(cp.addClass(((ObjectType) dest_type).getClassName()));
-        } else {
-            throw new IllegalArgumentException("Cannot cast " + src_type + " to " + dest_type);
         }
+        if (!(srcType instanceof ReferenceType) || !(destType instanceof ReferenceType)) {
+            throw new IllegalArgumentException("Cannot cast " + srcType + " to " + destType);
+        }
+        if (destType instanceof ArrayType) {
+            return new CHECKCAST(cp.addArrayClass((ArrayType) destType));
+        }
+        return new CHECKCAST(cp.addClass(((ObjectType) destType).getClassName()));
     }
 
-
-    public GETFIELD createGetField( final String class_name, final String name, final Type t ) {
-        return new GETFIELD(cp.addFieldref(class_name, name, t.getSignature()));
+    public CHECKCAST createCheckCast(final ReferenceType t) {
+        if (t instanceof ArrayType) {
+            return new CHECKCAST(cp.addArrayClass((ArrayType) t));
+        }
+        return new CHECKCAST(cp.addClass((ObjectType) t));
     }
 
-
-    public GETSTATIC createGetStatic( final String class_name, final String name, final Type t ) {
-        return new GETSTATIC(cp.addFieldref(class_name, name, t.getSignature()));
+    /**
+     * Uses PUSH to push a constant value onto the stack.
+     *
+     * @param value must be of type Number, Boolean, Character or String
+     */
+    public Instruction createConstant(final Object value) {
+        PUSH push;
+        if (value instanceof Number) {
+            push = new PUSH(cp, (Number) value);
+        } else if (value instanceof String) {
+            push = new PUSH(cp, (String) value);
+        } else if (value instanceof Boolean) {
+            push = new PUSH(cp, (Boolean) value);
+        } else if (value instanceof Character) {
+            push = new PUSH(cp, (Character) value);
+        } else {
+            throw new ClassGenException("Illegal type: " + value.getClass());
+        }
+        return push.getInstruction();
     }
 
-
-    public PUTFIELD createPutField( final String class_name, final String name, final Type t ) {
-        return new PUTFIELD(cp.addFieldref(class_name, name, t.getSignature()));
+    /**
+     * Create a field instruction.
+     *
+     * @param className name of the accessed class
+     * @param name name of the referenced field
+     * @param type type of field
+     * @param kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC
+     * @see Const
+     */
+    public FieldInstruction createFieldAccess(final String className, final String name, final Type type, final short kind) {
+        int index;
+        final String signature = type.getSignature();
+        index = cp.addFieldref(className, name, signature);
+        switch (kind) {
+        case Const.GETFIELD:
+            return new GETFIELD(index);
+        case Const.PUTFIELD:
+            return new PUTFIELD(index);
+        case Const.GETSTATIC:
+            return new GETSTATIC(index);
+        case Const.PUTSTATIC:
+            return new PUTSTATIC(index);
+        default:
+            throw new IllegalArgumentException("Unknown getfield kind:" + kind);
+        }
     }
 
-
-    public PUTSTATIC createPutStatic( final String class_name, final String name, final Type t ) {
-        return new PUTSTATIC(cp.addFieldref(class_name, name, t.getSignature()));
+    public GETFIELD createGetField(final String className, final String name, final Type t) {
+        return new GETFIELD(cp.addFieldref(className, name, t.getSignature()));
     }
 
-
-    public CHECKCAST createCheckCast( final ReferenceType t ) {
-        if (t instanceof ArrayType) {
-            return new CHECKCAST(cp.addArrayClass((ArrayType) t));
-        }
-        return new CHECKCAST(cp.addClass((ObjectType) t));
+    public GETSTATIC createGetStatic(final String className, final String name, final Type t) {
+        return new GETSTATIC(cp.addFieldref(className, name, t.getSignature()));
     }
 
-
-    public INSTANCEOF createInstanceOf( final ReferenceType t ) {
+    public INSTANCEOF createInstanceOf(final ReferenceType t) {
         if (t instanceof ArrayType) {
             return new INSTANCEOF(cp.addArrayClass((ArrayType) t));
         }
         return new INSTANCEOF(cp.addClass((ObjectType) t));
     }
 
+    private InvokeInstruction createInvoke(final MethodObject m, final short kind) {
+        return createInvoke(m.className, m.name, m.resultType, m.argTypes, kind);
+    }
 
-    public NEW createNew( final ObjectType t ) {
-        return new NEW(cp.addClass(t));
+    /**
+     * Create an invoke instruction. (Except for invokedynamic.)
+     *
+     * @param className name of the called class
+     * @param name name of the called method
+     * @param retType return type of method
+     * @param argTypes argument types of method
+     * @param kind how to invoke, i.e., INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL
+     * @see Const
+     */
+    public InvokeInstruction createInvoke(final String className, final String name, final Type retType, final Type[] argTypes, final short kind) {
+        return createInvoke(className, name, retType, argTypes, kind, kind == Const.INVOKEINTERFACE);
+    }
+
+    /**
+     * Create an invoke instruction. (Except for invokedynamic.)
+     *
+     * @param className name of the called class
+     * @param name name of the called method
+     * @param retType return type of method
+     * @param argTypes argument types of method
+     * @param kind how to invoke: INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL, or INVOKESPECIAL
+     * @param useInterface force use of InterfaceMethodref
+     * @return A new InvokeInstruction.
+     * @since 6.5.0
+     */
+    public InvokeInstruction createInvoke(final String className, final String name, final Type retType, final Type[] argTypes, final short kind,
+        final boolean useInterface) {
+        if (kind != Const.INVOKESPECIAL && kind != Const.INVOKEVIRTUAL && kind != Const.INVOKESTATIC && kind != Const.INVOKEINTERFACE
+            && kind != Const.INVOKEDYNAMIC) {
+            throw new IllegalArgumentException("Unknown invoke kind: " + kind);
+        }
+        int index;
+        int nargs = 0;
+        final String signature = Type.getMethodSignature(retType, argTypes);
+        for (final Type argType : argTypes) {
+            nargs += argType.getSize();
+        }
+        if (useInterface) {
+            index = cp.addInterfaceMethodref(className, name, signature);
+        } else {
+            index = cp.addMethodref(className, name, signature);
+        }
+        switch (kind) {
+        case Const.INVOKESPECIAL:
+            return new INVOKESPECIAL(index);
+        case Const.INVOKEVIRTUAL:
+            return new INVOKEVIRTUAL(index);
+        case Const.INVOKESTATIC:
+            return new INVOKESTATIC(index);
+        case Const.INVOKEINTERFACE:
+            return new INVOKEINTERFACE(index, nargs + 1);
+        case Const.INVOKEDYNAMIC:
+            return new INVOKEDYNAMIC(index);
+        default:
+            // Can't happen
+            throw new IllegalStateException("Unknown invoke kind: " + kind);
+        }
     }
 
+    public NEW createNew(final ObjectType t) {
+        return new NEW(cp.addClass(t));
+    }
 
-    public NEW createNew( final String s ) {
+    public NEW createNew(final String s) {
         return createNew(ObjectType.getInstance(s));
     }
 
     /**
      * Create new array of given size and type.
      *
-     * @return an instruction that creates the corresponding array at runtime,
-     * i.e. is an AllocationInstruction
+     * @return an instruction that creates the corresponding array at runtime, i.e. is an AllocationInstruction
      */
-    public Instruction createNewArray( final Type t, final short dim ) {
+    public Instruction createNewArray(final Type t, final short dim) {
         if (dim == 1) {
             if (t instanceof ObjectType) {
                 return new ANEWARRAY(cp.addClass((ObjectType) t));
-            } else if (t instanceof ArrayType) {
+            }
+            if (t instanceof ArrayType) {
                 return new ANEWARRAY(cp.addArrayClass((ArrayType) t));
-            } else {
-                return new NEWARRAY(t.getType());
             }
+            return new NEWARRAY(t.getType());
         }
         ArrayType at;
         if (t instanceof ArrayType) {
@@ -699,101 +700,40 @@ public Instruction createNewArray( final Type t, final short dim ) {
     }
 
     /**
-     * Create "null" value for reference types, 0 for basic types like int
+     * Create a call to the most popular System.out.println() method.
+     *
+     * @param s the string to print
      */
-    public static Instruction createNull( final Type type ) {
-        switch (type.getType()) {
-            case Const.T_ARRAY:
-            case Const.T_OBJECT:
-                return InstructionConst.ACONST_NULL;
-            case Const.T_INT:
-            case Const.T_SHORT:
-            case Const.T_BOOLEAN:
-            case Const.T_CHAR:
-            case Const.T_BYTE:
-                return InstructionConst.ICONST_0;
-            case Const.T_FLOAT:
-                return InstructionConst.FCONST_0;
-            case Const.T_DOUBLE:
-                return InstructionConst.DCONST_0;
-            case Const.T_LONG:
-                return InstructionConst.LCONST_0;
-            case Const.T_VOID:
-                return InstructionConst.NOP;
-            default:
-                throw new IllegalArgumentException("Invalid type: " + type);
-        }
+    public InstructionList createPrintln(final String s) {
+        final InstructionList il = new InstructionList();
+        il.append(createGetStatic("java.lang.System", "out", Type.getType("Ljava/io/PrintStream;")));
+        il.append(new PUSH(cp, s));
+        final MethodObject methodObject = new MethodObject("java.io.PrintStream", "println", Type.VOID, new Type[] { Type.getType("Ljava/lang/String;") });
+        il.append(createInvoke(methodObject, Const.INVOKEVIRTUAL));
+        return il;
     }
 
-    /**
-     * Create branch instruction by given opcode, except LOOKUPSWITCH and
-     * TABLESWITCH. For those you should use the SWITCH compound instruction.
-     */
-    public static BranchInstruction createBranchInstruction( final short opcode,
-            final InstructionHandle target ) {
-        switch (opcode) {
-            case Const.IFEQ:
-                return new IFEQ(target);
-            case Const.IFNE:
-                return new IFNE(target);
-            case Const.IFLT:
-                return new IFLT(target);
-            case Const.IFGE:
-                return new IFGE(target);
-            case Const.IFGT:
-                return new IFGT(target);
-            case Const.IFLE:
-                return new IFLE(target);
-            case Const.IF_ICMPEQ:
-                return new IF_ICMPEQ(target);
-            case Const.IF_ICMPNE:
-                return new IF_ICMPNE(target);
-            case Const.IF_ICMPLT:
-                return new IF_ICMPLT(target);
-            case Const.IF_ICMPGE:
-                return new IF_ICMPGE(target);
-            case Const.IF_ICMPGT:
-                return new IF_ICMPGT(target);
-            case Const.IF_ICMPLE:
-                return new IF_ICMPLE(target);
-            case Const.IF_ACMPEQ:
-                return new IF_ACMPEQ(target);
-            case Const.IF_ACMPNE:
-                return new IF_ACMPNE(target);
-            case Const.GOTO:
-                return new GOTO(target);
-            case Const.JSR:
-                return new JSR(target);
-            case Const.IFNULL:
-                return new IFNULL(target);
-            case Const.IFNONNULL:
-                return new IFNONNULL(target);
-            case Const.GOTO_W:
-                return new GOTO_W(target);
-            case Const.JSR_W:
-                return new JSR_W(target);
-            default:
-                throw new IllegalArgumentException("Invalid opcode: " + opcode);
-        }
+    public PUTFIELD createPutField(final String className, final String name, final Type t) {
+        return new PUTFIELD(cp.addFieldref(className, name, t.getSignature()));
     }
 
-
-    public void setClassGen( final ClassGen c ) {
-        cg = c;
+    public PUTSTATIC createPutStatic(final String className, final String name, final Type t) {
+        return new PUTSTATIC(cp.addFieldref(className, name, t.getSignature()));
     }
 
-
     public ClassGen getClassGen() {
         return cg;
     }
 
-
-    public void setConstantPool( final ConstantPoolGen c ) {
-        cp = c;
+    public ConstantPoolGen getConstantPool() {
+        return cp;
     }
 
+    public void setClassGen(final ClassGen c) {
+        cg = c;
+    }
 
-    public ConstantPoolGen getConstantPool() {
-        return cp;
+    public void setConstantPool(final ConstantPoolGen c) {
+        cp = c;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java
index bdf78029537..5e962354d16 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionHandle.java
@@ -28,16 +28,12 @@
 import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
- * Instances of this class give users a handle to the instructions contained in
- * an InstructionList. Instruction objects may be used more than once within a
- * list, this is useful because it saves memory and may be much faster.
+ * Instances of this class give users a handle to the instructions contained in an InstructionList. Instruction objects
+ * may be used more than once within a list, this is useful because it saves memory and may be much faster.
  *
- * Within an InstructionList an InstructionHandle object is wrapped
- * around all instructions, i.e., it implements a cell in a
- * doubly-linked list. From the outside only the next and the
- * previous instruction (handle) are accessible. One
- * can traverse the list via an Enumeration returned by
- * InstructionList.elements().
+ * Within an InstructionList an InstructionHandle object is wrapped around all instructions, i.e., it implements a cell
+ * in a doubly-linked list. From the outside only the next and the previous instruction (handle) are accessible. One can
+ * traverse the list via an Enumeration returned by InstructionList.elements().
  *
  * @see Instruction
  * @see BranchHandle
@@ -46,121 +42,86 @@
  */
 public class InstructionHandle {
 
-    private InstructionHandle next;
-    private InstructionHandle prev;
-    private Instruction instruction;
-
-    private int i_position = -1; // byte code offset of instruction
-
-    private Set<InstructionTargeter> targeters;
-    private Map<Object, Object> attributes;
-
-
     /**
-     * Does nothing.
+     * Empty array.
      *
-     * @deprecated Does nothing as of 6.3.1.
+     * @since 6.6.0
      */
-    @Deprecated
-    protected void addHandle() {
-        // noop
-    }
-
-    public final InstructionHandle getNext() {
-        return next;
-    }
-
-
-    public final InstructionHandle getPrev() {
-        return prev;
-    }
-
-
-    public final Instruction getInstruction() {
-        return instruction;
-    }
+    public static final InstructionHandle[] EMPTY_ARRAY = {};
 
+    /**
+     * Empty array.
+     */
+    static final InstructionTargeter[] EMPTY_INSTRUCTION_TARGETER_ARRAY = {};
 
     /**
-     * Replace current instruction contained in this handle.
-     * Old instruction is disposed using Instruction.dispose().
+     * Factory method.
      */
-    public void setInstruction( final Instruction i ) { // Overridden in BranchHandle TODO could be package-protected?
-        if (i == null) {
-            throw new ClassGenException("Assigning null to handle");
-        }
-        if ((this.getClass() != BranchHandle.class) && (i instanceof BranchInstruction)) {
-            throw new ClassGenException("Assigning branch instruction " + i + " to plain handle");
-        }
-        if (instruction != null) {
-            instruction.dispose();
-        }
-        instruction = i;
+    static InstructionHandle getInstructionHandle(final Instruction i) {
+        return new InstructionHandle(i);
     }
 
+    private InstructionHandle next;
+    private InstructionHandle prev;
+
+    private Instruction instruction;
 
     /**
-     * Temporarily swap the current instruction, without disturbing
-     * anything. Meant to be used by a debugger, implementing
-     * breakpoints. Current instruction is returned.
-     * <p>
-     * Warning: if this is used on a BranchHandle then some methods such as
-     * getPosition() will still refer to the original cached instruction, whereas
-     * other BH methods may affect the cache and the replacement instruction.
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
      */
-    // See BCEL-273
-    // TODO remove this method in any redesign of BCEL
-    public Instruction swapInstruction( final Instruction i ) {
-        final Instruction oldInstruction = instruction;
-        instruction = i;
-        return oldInstruction;
-    }
+    @Deprecated
+    protected int i_position = -1; // byte code offset of instruction
+    private Set<InstructionTargeter> targeters;
 
+    private Map<Object, Object> attributes;
 
-    /*private*/protected InstructionHandle(final Instruction i) {
+    protected InstructionHandle(final Instruction i) {
         setInstruction(i);
     }
 
-    /** Factory method.
+    /**
+     * Convenience method, simply calls accept() on the contained instruction.
+     *
+     * @param v Visitor object
      */
-    static InstructionHandle getInstructionHandle( final Instruction i ) {
-        return new InstructionHandle(i);
+    public void accept(final Visitor v) {
+        instruction.accept(v);
     }
 
-
     /**
-     * Called by InstructionList.setPositions when setting the position for every
-     * instruction. In the presence of variable length instructions `setPositions()'
-     * performs multiple passes over the instruction list to calculate the
-     * correct (byte) positions and offsets by calling this function.
+     * Add an attribute to an instruction handle.
      *
-     * @param offset additional offset caused by preceding (variable length) instructions
-     * @param max_offset the maximum offset that may be caused by these instructions
-     * @return additional offset caused by possible change of this instruction's length
+     * @param key the key object to store/retrieve the attribute
+     * @param attr the attribute to associate with this handle
      */
-    protected int updatePosition( final int offset, final int max_offset ) {
-        i_position += offset;
-        return 0;
+    public void addAttribute(final Object key, final Object attr) {
+        if (attributes == null) {
+            attributes = new HashMap<>(3);
+        }
+        attributes.put(key, attr);
     }
 
-
-    /** @return the position, i.e., the byte code offset of the contained
-     * instruction. This is accurate only after
-     * InstructionList.setPositions() has been called.
+    /**
+     * Does nothing.
+     *
+     * @deprecated Does nothing as of 6.3.1.
      */
-    public int getPosition() {
-        return i_position;
+    @Deprecated
+    protected void addHandle() {
+        // noop
     }
 
-
-    /** Set the position, i.e., the byte code offset of the contained
-     * instruction.
+    /**
+     * Denote this handle is being referenced by t.
      */
-    void setPosition( final int pos ) {
-        i_position = pos;
+    public void addTargeter(final InstructionTargeter t) {
+        if (targeters == null) {
+            targeters = new HashSet<>();
+        }
+        // if(!targeters.contains(t))
+        targeters.add(t);
     }
 
-
     /**
      * Delete contents, i.e., remove user access.
      */
@@ -173,126 +134,109 @@ void dispose() {
         removeAllTargeters();
     }
 
-
-    /** Remove all targeters, if any.
+    /**
+     * Get attribute of an instruction handle.
+     *
+     * @param key the key object to store/retrieve the attribute
      */
-    public void removeAllTargeters() {
-        if (targeters != null) {
-            targeters.clear();
+    public Object getAttribute(final Object key) {
+        if (attributes != null) {
+            return attributes.get(key);
         }
+        return null;
     }
 
-
     /**
-     * Denote this handle isn't referenced anymore by t.
+     * @return all attributes associated with this handle
      */
-    public void removeTargeter( final InstructionTargeter t ) {
-        if (targeters != null) {
-            targeters.remove(t);
+    public Collection<Object> getAttributes() {
+        if (attributes == null) {
+            attributes = new HashMap<>(3);
         }
+        return attributes.values();
+    }
+
+    public final Instruction getInstruction() {
+        return instruction;
     }
 
+    public final InstructionHandle getNext() {
+        return next;
+    }
 
     /**
-     * Denote this handle is being referenced by t.
+     * @return the position, i.e., the byte code offset of the contained instruction. This is accurate only after
+     *         InstructionList.setPositions() has been called.
      */
-    public void addTargeter( final InstructionTargeter t ) {
-        if (targeters == null) {
-            targeters = new HashSet<>();
-        }
-        //if(!targeters.contains(t))
-        targeters.add(t);
+    public int getPosition() {
+        return i_position;
     }
 
-
-    public boolean hasTargeters() {
-        return (targeters != null) && (targeters.size() > 0);
+    public final InstructionHandle getPrev() {
+        return prev;
     }
 
-
     /**
      * @return null, if there are no targeters
      */
     public InstructionTargeter[] getTargeters() {
         if (!hasTargeters()) {
-            return new InstructionTargeter[0];
+            return EMPTY_INSTRUCTION_TARGETER_ARRAY;
         }
         final InstructionTargeter[] t = new InstructionTargeter[targeters.size()];
         targeters.toArray(t);
         return t;
     }
 
-
-    /** @return a (verbose) string representation of the contained instruction.
-     */
-    public String toString( final boolean verbose ) {
-        return Utility.format(i_position, 4, false, ' ') + ": " + instruction.toString(verbose);
-    }
-
-
-    /** @return a string representation of the contained instruction.
-     */
-    @Override
-    public String toString() {
-        return toString(true);
+    public boolean hasTargeters() {
+        return targeters != null && !targeters.isEmpty();
     }
 
-
-    /** Add an attribute to an instruction handle.
-     *
-     * @param key the key object to store/retrieve the attribute
-     * @param attr the attribute to associate with this handle
+    /**
+     * Remove all targeters, if any.
      */
-    public void addAttribute( final Object key, final Object attr ) {
-        if (attributes == null) {
-            attributes = new HashMap<>(3);
+    public void removeAllTargeters() {
+        if (targeters != null) {
+            targeters.clear();
         }
-        attributes.put(key, attr);
     }
 
-
-    /** Delete an attribute of an instruction handle.
+    /**
+     * Delete an attribute of an instruction handle.
      *
      * @param key the key object to retrieve the attribute
      */
-    public void removeAttribute( final Object key ) {
+    public void removeAttribute(final Object key) {
         if (attributes != null) {
             attributes.remove(key);
         }
     }
 
-
-    /** Get attribute of an instruction handle.
-     *
-     * @param key the key object to store/retrieve the attribute
+    /**
+     * Denote this handle isn't referenced anymore by t.
      */
-    public Object getAttribute( final Object key ) {
-        if (attributes != null) {
-            return attributes.get(key);
+    public void removeTargeter(final InstructionTargeter t) {
+        if (targeters != null) {
+            targeters.remove(t);
         }
-        return null;
     }
 
-
-    /** @return all attributes associated with this handle
+    /**
+     * Replace current instruction contained in this handle. Old instruction is disposed using Instruction.dispose().
      */
-    public Collection<Object> getAttributes() {
-        if (attributes == null) {
-            attributes = new HashMap<>(3);
+    public void setInstruction(final Instruction i) { // Overridden in BranchHandle TODO could be package-protected?
+        if (i == null) {
+            throw new ClassGenException("Assigning null to handle");
         }
-        return attributes.values();
-    }
-
-
-    /** Convenience method, simply calls accept() on the contained instruction.
-     *
-     * @param v Visitor object
-     */
-    public void accept( final Visitor v ) {
-        instruction.accept(v);
+        if (this.getClass() != BranchHandle.class && i instanceof BranchInstruction) {
+            throw new ClassGenException("Assigning branch instruction " + i + " to plain handle");
+        }
+        if (instruction != null) {
+            instruction.dispose();
+        }
+        instruction = i;
     }
 
-
     /**
      * @param next the next to set
      * @since 6.0
@@ -302,6 +246,12 @@ final InstructionHandle setNext(final InstructionHandle next) {
         return next;
     }
 
+    /**
+     * Set the position, i.e., the byte code offset of the contained instruction.
+     */
+    void setPosition(final int pos) {
+        i_position = pos;
+    }
 
     /**
      * @param prev the prev to set
@@ -311,4 +261,48 @@ final InstructionHandle setPrev(final InstructionHandle prev) {
         this.prev = prev;
         return prev;
     }
+
+    /**
+     * Temporarily swap the current instruction, without disturbing anything. Meant to be used by a debugger, implementing
+     * breakpoints. Current instruction is returned.
+     * <p>
+     * Warning: if this is used on a BranchHandle then some methods such as getPosition() will still refer to the original
+     * cached instruction, whereas other BH methods may affect the cache and the replacement instruction.
+     */
+    // See BCEL-273
+    // TODO remove this method in any redesign of BCEL
+    public Instruction swapInstruction(final Instruction i) {
+        final Instruction oldInstruction = instruction;
+        instruction = i;
+        return oldInstruction;
+    }
+
+    /**
+     * @return a string representation of the contained instruction.
+     */
+    @Override
+    public String toString() {
+        return toString(true);
+    }
+
+    /**
+     * @return a (verbose) string representation of the contained instruction.
+     */
+    public String toString(final boolean verbose) {
+        return Utility.format(i_position, 4, false, ' ') + ": " + instruction.toString(verbose);
+    }
+
+    /**
+     * Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable
+     * length instructions 'setPositions()' performs multiple passes over the instruction list to calculate the correct
+     * (byte) positions and offsets by calling this function.
+     *
+     * @param offset additional offset caused by preceding (variable length) instructions
+     * @param maxOffset the maximum offset that may be caused by these instructions
+     * @return additional offset caused by possible change of this instruction's length
+     */
+    protected int updatePosition(final int offset, final int maxOffset) {
+        i_position += offset;
+        return 0;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java
index 28c53220444..7ffc3a8228e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
  /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,114 +19,59 @@
  */
 package com.sun.org.apache.bcel.internal.generic;
 
-import com.sun.org.apache.bcel.internal.Const;
-import com.sun.org.apache.bcel.internal.classfile.Constant;
-import com.sun.org.apache.bcel.internal.util.ByteSequence;
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
 
+import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.classfile.Constant;
+import com.sun.org.apache.bcel.internal.util.ByteSequence;
+
 /**
- * This class is a container for a list of <a
- * href="Instruction.html">Instruction</a> objects. Instructions can be
+ * This class is a container for a list of <a href="Instruction.html">Instruction</a> objects. Instructions can be
  * appended, inserted, moved, deleted, etc.. Instructions are being wrapped into
- * <a href="InstructionHandle.html">InstructionHandles</a> objects that are
- * returned upon append/insert operations. They give the user (read only) access
- * to the list structure, such that it can be traversed and manipulated in a
- * controlled way.
+ * <a href="InstructionHandle.html">InstructionHandles</a> objects that are returned upon append/insert operations. They
+ * give the user (read only) access to the list structure, such that it can be traversed and manipulated in a controlled
+ * way.
  *
- * A list is finally dumped to a byte code array with <a
- * href="#getByteCode()">getByteCode</a>.
+ * A list is finally dumped to a byte code array with <a href="#getByteCode()">getByteCode</a>.
  *
  * @see Instruction
  * @see InstructionHandle
  * @see BranchHandle
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public class InstructionList implements Iterable<InstructionHandle> {
 
-    private InstructionHandle start = null;
-    private InstructionHandle end = null;
-    private int length = 0; // number of elements in list
-    private int[] bytePositions; // byte code offsets corresponding to instructions
-
-    /**
-     * Create (empty) instruction list.
-     */
-    public InstructionList() {
-    }
-
-    /**
-     * Create instruction list containing one instruction.
-     *
-     * @param i
-     *            initial instruction
-     */
-    public InstructionList(final Instruction i) {
-        append(i);
-    }
-
-    /**
-     * Create instruction list containing one instruction.
-     *
-     * @param i
-     *            initial instruction
-     */
-    public InstructionList(final BranchInstruction i) {
-        append(i);
-    }
-
-    /**
-     * Initialize list with (nonnull) compound instruction. Consumes argument
-     * list, i.e., it becomes empty.
-     *
-     * @param c
-     *            compound instruction (list)
-     */
-    public InstructionList(final CompoundInstruction c) {
-        append(c.getInstructionList());
-    }
-
-    /**
-     * Test for empty list.
-     */
-    public boolean isEmpty() {
-        return start == null;
-    } // && end == null
-
     /**
-     * Find the target instruction (handle) that corresponds to the given target
-     * position (byte code offset).
+     * Find the target instruction (handle) that corresponds to the given target position (byte code offset).
      *
-     * @param ihs
-     *            array of instruction handles, i.e. il.getInstructionHandles()
-     * @param pos
-     *            array of positions corresponding to ihs, i.e. il.getInstructionPositions()
-     * @param count
-     *            length of arrays
-     * @param target
-     *            target position to search for
+     * @param ihs array of instruction handles, i.e. il.getInstructionHandles()
+     * @param pos array of positions corresponding to ihs, i.e. il.getInstructionPositions()
+     * @param count length of arrays
+     * @param target target position to search for
      * @return target position's instruction handle if available
      */
-    public static InstructionHandle findHandle(final InstructionHandle[] ihs,
-            final int[] pos, final int count, final int target) {
+    public static InstructionHandle findHandle(final InstructionHandle[] ihs, final int[] pos, final int count, final int target) {
         int l = 0;
         int r = count - 1;
         /*
          * Do a binary search since the pos array is orderd.
          */
         do {
-            final int i = (l + r) >>> 1;
+            final int i = l + r >>> 1;
             final int j = pos[i];
             if (j == target) {
                 return ihs[i];
-            } else if (target < j) {
+            }
+            if (target < j) {
                 r = i - 1;
             } else {
                 l = i + 1;
@@ -135,32 +80,33 @@ public static InstructionHandle findHandle(final InstructionHandle[] ihs,
         return null;
     }
 
+    private InstructionHandle start;
+    private InstructionHandle end;
+    private int length; // number of elements in list
+
+    private int[] bytePositions; // byte code offsets corresponding to instructions
+
+    private List<InstructionListObserver> observers;
+
+    /**
+     * Create (empty) instruction list.
+     */
+    public InstructionList() {
+    }
+
     /**
-     * Get instruction handle for instruction at byte code position pos. This
-     * only works properly, if the list is freshly initialized from a byte array
-     * or setPositions() has been called before this method.
+     * Create instruction list containing one instruction.
      *
-     * @param pos
-     *            byte code position to search for
-     * @return target position's instruction handle if available
+     * @param i initial instruction
      */
-    public InstructionHandle findHandle(final int pos) {
-        final int[] positions = bytePositions;
-        InstructionHandle ih = start;
-        for (int i = 0; i < length; i++) {
-            if (positions[i] == pos) {
-                return ih;
-            }
-            ih = ih.getNext();
-        }
-        return null;
+    public InstructionList(final BranchInstruction i) {
+        append(i);
     }
 
     /**
      * Initialize instruction list from byte array.
      *
-     * @param code
-     *            byte array containing the instructions
+     * @param code byte array containing the instructions
      */
     public InstructionList(final byte[] code) {
         int count = 0; // Contains actual length
@@ -193,18 +139,16 @@ public InstructionList(final byte[] code) {
         } catch (final IOException e) {
             throw new ClassGenException(e.toString(), e);
         }
-        bytePositions = new int[count]; // Trim to proper size
-        System.arraycopy(pos, 0, bytePositions, 0, count);
+        bytePositions = Arrays.copyOf(pos, count); // Trim to proper size
         /*
          * Pass 2: Look for BranchInstruction and update their targets, i.e., convert offsets to instruction handles.
          */
         for (int i = 0; i < count; i++) {
             if (ihs[i] instanceof BranchHandle) {
                 final BranchInstruction bi = (BranchInstruction) ihs[i].getInstruction();
-                int target = bi.getPosition() + bi.getIndex();
-                /*
-                 * Byte code position: relative -> absolute.
-                 */
+                int target = bi.getPosition() + bi.getIndex(); /*
+                                                                * Byte code position: relative -> absolute.
+                                                                */
                 // Search for target position
                 InstructionHandle ih = findHandle(ihs, pos, count, target);
                 if (ih == null) {
@@ -229,104 +173,59 @@ public InstructionList(final byte[] code) {
     }
 
     /**
-     * Append another list after instruction (handle) ih contained in this list.
-     * Consumes argument list, i.e., it becomes empty.
+     * Initialize list with (nonnull) compound instruction. Consumes argument list, i.e., it becomes empty.
      *
-     * @param ih
-     *            where to append the instruction list
-     * @param il
-     *            Instruction list to append to this one
-     * @return instruction handle pointing to the <B>first</B> appended instruction
+     * @param c compound instruction (list)
      */
-    public InstructionHandle append(final InstructionHandle ih, final InstructionList il) {
-        if (il == null) {
-            throw new ClassGenException("Appending null InstructionList");
-        }
-        if (il.isEmpty()) {
-            return ih;
-        }
-        final InstructionHandle next = ih.getNext();
-        final InstructionHandle ret = il.start;
-        ih.setNext(il.start);
-        il.start.setPrev(ih);
-        il.end.setNext(next);
-        if (next != null) {
-            next.setPrev(il.end);
-        } else {
-            end = il.end; // Update end ...
-        }
-        length += il.length; // Update length
-        il.clear();
-        return ret;
+    public InstructionList(final CompoundInstruction c) {
+        append(c.getInstructionList());
     }
 
     /**
-     * Append another list after instruction i contained in this list. Consumes
-     * argument list, i.e., it becomes empty.
+     * Create instruction list containing one instruction.
      *
-     * @param i
-     *            where to append the instruction list
-     * @param il
-     *            Instruction list to append to this one
-     * @return instruction handle pointing to the <B>first</B> appended instruction
+     * @param i initial instruction
      */
-    public InstructionHandle append(final Instruction i, final InstructionList il) {
-        InstructionHandle ih;
-        if ((ih = findInstruction2(i)) == null) {
-            throw new ClassGenException("Instruction " + i + " is not contained in this list.");
+    public InstructionList(final Instruction i) {
+        append(i);
+    }
+
+    /**
+     * Add observer for this object.
+     */
+    public void addObserver(final InstructionListObserver o) {
+        if (observers == null) {
+            observers = new ArrayList<>();
         }
-        return append(ih, il);
+        observers.add(o);
     }
 
     /**
-     * Append another list to this one. Consumes argument list, i.e., it becomes
-     * empty.
+     * Append a branch instruction to the end of this list.
      *
-     * @param il
-     *            list to append to end of this list
-     * @return instruction handle of the <B>first</B> appended instruction
+     * @param i branch instruction to append
+     * @return branch instruction handle of the appended instruction
      */
-    public InstructionHandle append(final InstructionList il) {
-        if (il == null) {
-            throw new ClassGenException("Appending null InstructionList");
-        }
-        if (il.isEmpty()) {
-            return null;
-        }
-        if (isEmpty()) {
-            start = il.start;
-            end = il.end;
-            length = il.length;
-            il.clear();
-            return start;
-        }
-        return append(end, il); // was end.instruction
+    public BranchHandle append(final BranchInstruction i) {
+        final BranchHandle ih = BranchHandle.getBranchHandle(i);
+        append(ih);
+        return ih;
     }
 
     /**
-     * Append an instruction to the end of this list.
+     * Append a compound instruction.
      *
-     * @param ih
-     *            instruction to append
+     * @param c The composite instruction (containing an InstructionList)
+     * @return instruction handle of the first appended instruction
      */
-    private void append(final InstructionHandle ih) {
-        if (isEmpty()) {
-            start = end = ih;
-            ih.setNext(ih.setPrev(null));
-        } else {
-            end.setNext(ih);
-            ih.setPrev(end);
-            ih.setNext(null);
-            end = ih;
-        }
-        length++; // Update length
+    public InstructionHandle append(final CompoundInstruction c) {
+        return append(c.getInstructionList());
     }
 
     /**
      * Append an instruction to the end of this list.
      *
-     * @param i
-     *            instruction to append
+     * @param i instruction to append
      * @return instruction handle of the appended instruction
      */
     public InstructionHandle append(final Instruction i) {
@@ -336,26 +235,21 @@ public InstructionHandle append(final Instruction i) {
     }
 
     /**
-     * Append a branch instruction to the end of this list.
+     * Append a compound instruction, after instruction i.
      *
-     * @param i
-     *            branch instruction to append
-     * @return branch instruction handle of the appended instruction
+     * @param i Instruction in list
+     * @param c The composite instruction (containing an InstructionList)
+     * @return instruction handle of the first appended instruction
      */
-    public BranchHandle append(final BranchInstruction i) {
-        final BranchHandle ih = BranchHandle.getBranchHandle(i);
-        append(ih);
-        return ih;
+    public InstructionHandle append(final Instruction i, final CompoundInstruction c) {
+        return append(i, c.getInstructionList());
     }
 
     /**
-     * Append a single instruction j after another instruction i, which must be
-     * in this list of course!
+     * Append a single instruction j after another instruction i, which must be in this list of course!
      *
-     * @param i
-     *            Instruction in list
-     * @param j
-     *            Instruction to append after i in list
+     * @param i Instruction in list
+     * @param j Instruction to append after i in list
      * @return instruction handle of the first appended instruction
      */
     public InstructionHandle append(final Instruction i, final Instruction j) {
@@ -363,36 +257,58 @@ public InstructionHandle append(final Instruction i, final Instruction j) {
     }
 
     /**
-     * Append a compound instruction, after instruction i.
+     * Append another list after instruction i contained in this list. Consumes argument list, i.e., it becomes empty.
      *
-     * @param i
-     *            Instruction in list
-     * @param c
-     *            The composite instruction (containing an InstructionList)
-     * @return instruction handle of the first appended instruction
+     * @param i where to append the instruction list
+     * @param il Instruction list to append to this one
+     * @return instruction handle pointing to the <B>first</B> appended instruction
      */
-    public InstructionHandle append(final Instruction i, final CompoundInstruction c) {
-        return append(i, c.getInstructionList());
+    public InstructionHandle append(final Instruction i, final InstructionList il) {
+        InstructionHandle ih;
+        if ((ih = findInstruction2(i)) == null) {
+            throw new ClassGenException("Instruction " + i + " is not contained in this list.");
+        }
+        return append(ih, il);
     }
 
     /**
-     * Append a compound instruction.
+     * Append an instruction to the end of this list.
      *
-     * @param c
-     *            The composite instruction (containing an InstructionList)
-     * @return instruction handle of the first appended instruction
+     * @param ih instruction to append
      */
-    public InstructionHandle append(final CompoundInstruction c) {
-        return append(c.getInstructionList());
+    private void append(final InstructionHandle ih) {
+        if (isEmpty()) {
+            start = end = ih;
+            ih.setNext(ih.setPrev(null));
+        } else {
+            end.setNext(ih);
+            ih.setPrev(end);
+            ih.setNext(null);
+            end = ih;
+        }
+        length++; // Update length
+    }
+
+    /**
+     * Append an instruction after instruction (handle) ih contained in this list.
+     *
+     * @param ih where to append the instruction list
+     * @param i Instruction to append
+     * @return instruction handle pointing to the <B>first</B> appended instruction
+     */
+    public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) {
+        final BranchHandle bh = BranchHandle.getBranchHandle(i);
+        final InstructionList il = new InstructionList();
+        il.append(bh);
+        append(ih, il);
+        return bh;
     }
 
     /**
      * Append a compound instruction.
      *
-     * @param ih
-     *            where to append the instruction list
-     * @param c
-     *            The composite instruction (containing an InstructionList)
+     * @param ih where to append the instruction list
+     * @param c The composite instruction (containing an InstructionList)
      * @return instruction handle of the first appended instruction
      */
     public InstructionHandle append(final InstructionHandle ih, final CompoundInstruction c) {
@@ -402,10 +318,8 @@ public InstructionHandle append(final InstructionHandle ih, final CompoundInstru
     /**
      * Append an instruction after instruction (handle) ih contained in this list.
      *
-     * @param ih
-     *            where to append the instruction list
-     * @param i
-     *            Instruction to append
+     * @param ih where to append the instruction list
+     * @param i Instruction to append
      * @return instruction handle pointing to the <B>first</B> appended instruction
      */
     public InstructionHandle append(final InstructionHandle ih, final Instruction i) {
@@ -413,48 +327,29 @@ public InstructionHandle append(final InstructionHandle ih, final Instruction i)
     }
 
     /**
-     * Append an instruction after instruction (handle) ih contained in this list.
+     * Append another list after instruction (handle) ih contained in this list. Consumes argument list, i.e., it becomes
+     * empty.
      *
-     * @param ih
-     *            where to append the instruction list
-     * @param i
-     *            Instruction to append
+     * @param ih where to append the instruction list
+     * @param il Instruction list to append to this one
      * @return instruction handle pointing to the <B>first</B> appended instruction
      */
-    public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) {
-        final BranchHandle bh = BranchHandle.getBranchHandle(i);
-        final InstructionList il = new InstructionList();
-        il.append(bh);
-        append(ih, il);
-        return bh;
-    }
-
-    /**
-     * Insert another list before Instruction handle ih contained in this list.
-     * Consumes argument list, i.e., it becomes empty.
-     *
-     * @param ih
-     *            where to append the instruction list
-     * @param il
-     *            Instruction list to insert
-     * @return instruction handle of the first inserted instruction
-     */
-    public InstructionHandle insert(final InstructionHandle ih, final InstructionList il) {
+    public InstructionHandle append(final InstructionHandle ih, final InstructionList il) {
         if (il == null) {
-            throw new ClassGenException("Inserting null InstructionList");
+            throw new ClassGenException("Appending null InstructionList");
         }
         if (il.isEmpty()) {
             return ih;
         }
-        final InstructionHandle prev = ih.getPrev();
+        final InstructionHandle next = ih.getNext();
         final InstructionHandle ret = il.start;
-        ih.setPrev(il.end);
-        il.end.setNext(ih);
-        il.start.setPrev(prev);
-        if (prev != null) {
-            prev.setNext(il.start);
+        ih.setNext(il.start);
+        il.start.setPrev(ih);
+        il.end.setNext(next);
+        if (next != null) {
+            next.setPrev(il.end);
         } else {
-            start = il.start; // Update start ...
+            end = il.end; // Update end ...
         }
         length += il.length; // Update length
         il.clear();
@@ -462,75 +357,296 @@ public InstructionHandle insert(final InstructionHandle ih, final InstructionLis
     }
 
     /**
-     * Insert another list.
+     * Append another list to this one. Consumes argument list, i.e., it becomes empty.
      *
-     * @param il
-     *            list to insert before start of this list
-     * @return instruction handle of the first inserted instruction
+     * @param il list to append to end of this list
+     * @return instruction handle of the <B>first</B> appended instruction
      */
-    public InstructionHandle insert(final InstructionList il) {
+    public InstructionHandle append(final InstructionList il) {
+        if (il == null) {
+            throw new ClassGenException("Appending null InstructionList");
+        }
+        if (il.isEmpty()) {
+            return null;
+        }
         if (isEmpty()) {
-            append(il); // Code is identical for this case
+            start = il.start;
+            end = il.end;
+            length = il.length;
+            il.clear();
             return start;
         }
-        return insert(start, il);
+        return append(end, il); // was end.instruction
     }
 
-    /**
-     * Insert an instruction at start of this list.
-     *
-     * @param ih
-     *            instruction to insert
+    private void clear() {
+        start = end = null;
+        length = 0;
+    }
+
+    public boolean contains(final Instruction i) {
+        return findInstruction1(i) != null;
+    }
+
+    public boolean contains(final InstructionHandle i) {
+        if (i == null) {
+            return false;
+        }
+        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
+            if (ih == i) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * @return complete, i.e., deep copy of this list
      */
-    private void insert(final InstructionHandle ih) {
-        if (isEmpty()) {
-            start = end = ih;
-            ih.setNext(ih.setPrev(null));
-        } else {
-            start.setPrev(ih);
-            ih.setNext(start);
-            ih.setPrev(null);
-            start = ih;
+    public InstructionList copy() {
+        final Map<InstructionHandle, InstructionHandle> map = new HashMap<>();
+        final InstructionList il = new InstructionList();
+        /*
+         * Pass 1: Make copies of all instructions, append them to the new list and associate old instruction references with
+         * the new ones, i.e., a 1:1 mapping.
+         */
+        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
+            final Instruction i = ih.getInstruction();
+            final Instruction c = i.copy(); // Use clone for shallow copy
+            if (c instanceof BranchInstruction) {
+                map.put(ih, il.append((BranchInstruction) c));
+            } else {
+                map.put(ih, il.append(c));
+            }
         }
-        length++;
+        /*
+         * Pass 2: Update branch targets.
+         */
+        InstructionHandle ih = start;
+        InstructionHandle ch = il.start;
+        while (ih != null) {
+            final Instruction i = ih.getInstruction();
+            final Instruction c = ch.getInstruction();
+            if (i instanceof BranchInstruction) {
+                final BranchInstruction bi = (BranchInstruction) i;
+                final BranchInstruction bc = (BranchInstruction) c;
+                final InstructionHandle itarget = bi.getTarget(); // old target
+                // New target is in hash map
+                bc.setTarget(map.get(itarget));
+                if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
+                    final InstructionHandle[] itargets = ((Select) bi).getTargets();
+                    final InstructionHandle[] ctargets = ((Select) bc).getTargets();
+                    for (int j = 0; j < itargets.length; j++) { // Update all targets
+                        ctargets[j] = map.get(itargets[j]);
+                    }
+                }
+            }
+            ih = ih.getNext();
+            ch = ch.getNext();
+        }
+        return il;
     }
 
     /**
-     * Insert another list before Instruction i contained in this list. Consumes
-     * argument list, i.e., it becomes empty.
+     * Remove instruction from this list. The corresponding Instruction handles must not be reused!
      *
-     * @param i
-     *            where to append the instruction list
-     * @param il
-     *            Instruction list to insert
-     * @return instruction handle pointing to the first inserted instruction, i.e., il.getStart()
+     * @param i instruction to remove
      */
-    public InstructionHandle insert(final Instruction i, final InstructionList il) {
+    public void delete(final Instruction i) throws TargetLostException {
         InstructionHandle ih;
         if ((ih = findInstruction1(i)) == null) {
             throw new ClassGenException("Instruction " + i + " is not contained in this list.");
         }
-        return insert(ih, il);
+        delete(ih);
     }
 
     /**
-     * Insert an instruction at start of this list.
+     * Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that
+     * 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused!
      *
-     * @param i
-     *            instruction to insert
-     * @return instruction handle of the inserted instruction
+     * @param from where to start deleting (inclusive)
+     * @param to where to end deleting (inclusive)
      */
-    public InstructionHandle insert(final Instruction i) {
-        final InstructionHandle ih = InstructionHandle.getInstructionHandle(i);
-        insert(ih);
-        return ih;
+    public void delete(final Instruction from, final Instruction to) throws TargetLostException {
+        InstructionHandle fromIh;
+        InstructionHandle toIh;
+        if ((fromIh = findInstruction1(from)) == null) {
+            throw new ClassGenException("Instruction " + from + " is not contained in this list.");
+        }
+        if ((toIh = findInstruction2(to)) == null) {
+            throw new ClassGenException("Instruction " + to + " is not contained in this list.");
+        }
+        delete(fromIh, toIh);
+    }
+
+    /**
+     * Remove instruction from this list. The corresponding Instruction handles must not be reused!
+     *
+     * @param ih instruction (handle) to remove
+     */
+    public void delete(final InstructionHandle ih) throws TargetLostException {
+        remove(ih.getPrev(), ih.getNext());
+    }
+
+    /**
+     * Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that
+     * 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused!
+     *
+     * @param from where to start deleting (inclusive)
+     * @param to where to end deleting (inclusive)
+     */
+    public void delete(final InstructionHandle from, final InstructionHandle to) throws TargetLostException {
+        remove(from.getPrev(), to.getNext());
+    }
+
+    /**
+     * Delete contents of list. Provides better memory utilization, because the system then may reuse the instruction
+     * handles. This method is typically called right after {@link MethodGen#getMethod()}.
+     */
+    public void dispose() {
+        // Traverse in reverse order, because ih.next is overwritten
+        for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) {
+            // Causes BranchInstructions to release target and targeters, because it calls dispose() on the contained instruction.
+            ih.dispose();
+        }
+        clear();
+    }
+
+    /**
+     * Get instruction handle for instruction at byte code position pos. This only works properly, if the list is freshly
+     * initialized from a byte array or setPositions() has been called before this method.
+     *
+     * @param pos byte code position to search for
+     * @return target position's instruction handle if available
+     */
+    public InstructionHandle findHandle(final int pos) {
+        final int[] positions = bytePositions;
+        InstructionHandle ih = start;
+        for (int i = 0; i < length; i++) {
+            if (positions[i] == pos) {
+                return ih;
+            }
+            ih = ih.getNext();
+        }
+        return null;
+    }
+
+    /**
+     * Search for given Instruction reference, start at beginning of list.
+     *
+     * @param i instruction to search for
+     * @return instruction found on success, null otherwise
+     */
+    private InstructionHandle findInstruction1(final Instruction i) {
+        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
+            if (ih.getInstruction() == i) {
+                return ih;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Search for given Instruction reference, start at end of list
+     *
+     * @param i instruction to search for
+     * @return instruction found on success, null otherwise
+     */
+    private InstructionHandle findInstruction2(final Instruction i) {
+        for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) {
+            if (ih.getInstruction() == i) {
+                return ih;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * When everything is finished, use this method to convert the instruction list into an array of bytes.
+     *
+     * @return the byte code ready to be dumped
+     */
+    public byte[] getByteCode() {
+        // Update position indices of instructions
+        setPositions();
+        final ByteArrayOutputStream b = new ByteArrayOutputStream();
+        final DataOutputStream out = new DataOutputStream(b);
+        try {
+            for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
+                final Instruction i = ih.getInstruction();
+                i.dump(out); // Traverse list
+            }
+            out.flush();
+        } catch (final IOException e) {
+            System.err.println(e);
+            return Const.EMPTY_BYTE_ARRAY;
+        }
+        return b.toByteArray();
+    }
+
+    /**
+     * @return end of list
+     */
+    public InstructionHandle getEnd() {
+        return end;
+    }
+
+    /**
+     * @return array containing all instructions (handles)
+     */
+    public InstructionHandle[] getInstructionHandles() {
+        final InstructionHandle[] ihs = new InstructionHandle[length];
+        InstructionHandle ih = start;
+        for (int i = 0; i < length; i++) {
+            ihs[i] = ih;
+            ih = ih.getNext();
+        }
+        return ihs;
+    }
+
+    /**
+     * Get positions (offsets) of all instructions in the list. This relies on that the list has been freshly created from
+     * an byte code array, or that setPositions() has been called. Otherwise this may be inaccurate.
+     *
+     * @return array containing all instruction's offset in byte code
+     */
+    public int[] getInstructionPositions() {
+        return bytePositions;
+    }
+
+    /**
+     * @return an array of instructions without target information for branch instructions.
+     */
+    public Instruction[] getInstructions() {
+        final List<Instruction> instructions = new ArrayList<>();
+        try (ByteSequence bytes = new ByteSequence(getByteCode())) {
+            while (bytes.available() > 0) {
+                instructions.add(Instruction.readInstruction(bytes));
+            }
+        } catch (final IOException e) {
+            throw new ClassGenException(e.toString(), e);
+        }
+        return instructions.toArray(Instruction.EMPTY_ARRAY);
+    }
+
+    /**
+     * @return length of list (Number of instructions, not bytes)
+     */
+    public int getLength() {
+        return length;
+    }
+
+    /**
+     * @return start of list
+     */
+    public InstructionHandle getStart() {
+        return start;
     }
 
     /**
      * Insert a branch instruction at start of this list.
      *
-     * @param i
-     *            branch instruction to insert
+     * @param i branch instruction to insert
      * @return branch instruction handle of the appended instruction
      */
     public BranchHandle insert(final BranchInstruction i) {
@@ -540,26 +656,32 @@ public BranchHandle insert(final BranchInstruction i) {
     }
 
     /**
-     * Insert a single instruction j before another instruction i, which must be
-     * in this list of course!
+     * Insert a compound instruction.
      *
-     * @param i
-     *            Instruction in list
-     * @param j
-     *            Instruction to insert before i in list
+     * @param c The composite instruction (containing an InstructionList)
      * @return instruction handle of the first inserted instruction
      */
-    public InstructionHandle insert(final Instruction i, final Instruction j) {
-        return insert(i, new InstructionList(j));
+    public InstructionHandle insert(final CompoundInstruction c) {
+        return insert(c.getInstructionList());
+    }
+
+    /**
+     * Insert an instruction at start of this list.
+     *
+     * @param i instruction to insert
+     * @return instruction handle of the inserted instruction
+     */
+    public InstructionHandle insert(final Instruction i) {
+        final InstructionHandle ih = InstructionHandle.getInstructionHandle(i);
+        insert(ih);
+        return ih;
     }
 
     /**
      * Insert a compound instruction before instruction i.
      *
-     * @param i
-     *            Instruction in list
-     * @param c
-     *            The composite instruction (containing an InstructionList)
+     * @param i Instruction in list
+     * @param c The composite instruction (containing an InstructionList)
      * @return instruction handle of the first inserted instruction
      */
     public InstructionHandle insert(final Instruction i, final CompoundInstruction c) {
@@ -567,49 +689,54 @@ public InstructionHandle insert(final Instruction i, final CompoundInstruction c
     }
 
     /**
-     * Insert a compound instruction.
+     * Insert a single instruction j before another instruction i, which must be in this list of course!
      *
-     * @param c
-     *            The composite instruction (containing an InstructionList)
+     * @param i Instruction in list
+     * @param j Instruction to insert before i in list
      * @return instruction handle of the first inserted instruction
      */
-    public InstructionHandle insert(final CompoundInstruction c) {
-        return insert(c.getInstructionList());
+    public InstructionHandle insert(final Instruction i, final Instruction j) {
+        return insert(i, new InstructionList(j));
     }
 
     /**
-     * Insert an instruction before instruction (handle) ih contained in this list.
+     * Insert another list before Instruction i contained in this list. Consumes argument list, i.e., it becomes empty.
      *
-     * @param ih
-     *            where to insert to the instruction list
-     * @param i
-     *            Instruction to insert
-     * @return instruction handle of the first inserted instruction
+     * @param i where to append the instruction list
+     * @param il Instruction list to insert
+     * @return instruction handle pointing to the first inserted instruction, i.e., il.getStart()
      */
-    public InstructionHandle insert(final InstructionHandle ih, final Instruction i) {
-        return insert(ih, new InstructionList(i));
+    public InstructionHandle insert(final Instruction i, final InstructionList il) {
+        InstructionHandle ih;
+        if ((ih = findInstruction1(i)) == null) {
+            throw new ClassGenException("Instruction " + i + " is not contained in this list.");
+        }
+        return insert(ih, il);
     }
 
     /**
-     * Insert a compound instruction.
+     * Insert an instruction at start of this list.
      *
-     * @param ih
-     *            where to insert the instruction list
-     * @param c
-     *            The composite instruction (containing an InstructionList)
-     * @return instruction handle of the first inserted instruction
+     * @param ih instruction to insert
      */
-    public InstructionHandle insert(final InstructionHandle ih, final CompoundInstruction c) {
-        return insert(ih, c.getInstructionList());
+    private void insert(final InstructionHandle ih) {
+        if (isEmpty()) {
+            start = end = ih;
+            ih.setNext(ih.setPrev(null));
+        } else {
+            start.setPrev(ih);
+            ih.setNext(start);
+            ih.setPrev(null);
+            start = ih;
+        }
+        length++;
     }
 
     /**
      * Insert an instruction before instruction (handle) ih contained in this list.
      *
-     * @param ih
-     *            where to insert to the instruction list
-     * @param i
-     *            Instruction to insert
+     * @param ih where to insert to the instruction list
+     * @param i Instruction to insert
      * @return instruction handle of the first inserted instruction
      */
     public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i) {
@@ -621,33 +748,144 @@ public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i
     }
 
     /**
-     * Take all instructions (handles) from "start" to "end" and append them
-     * after the new location "target". Of course, "end" must be after "start"
-     * and target must not be located within this range. If you want to move
-     * something to the start of the list use null as value for target.
+     * Insert a compound instruction.
+     *
+     * @param ih where to insert the instruction list
+     * @param c The composite instruction (containing an InstructionList)
+     * @return instruction handle of the first inserted instruction
+     */
+    public InstructionHandle insert(final InstructionHandle ih, final CompoundInstruction c) {
+        return insert(ih, c.getInstructionList());
+    }
+
+    /**
+     * Insert an instruction before instruction (handle) ih contained in this list.
+     *
+     * @param ih where to insert to the instruction list
+     * @param i Instruction to insert
+     * @return instruction handle of the first inserted instruction
+     */
+    public InstructionHandle insert(final InstructionHandle ih, final Instruction i) {
+        return insert(ih, new InstructionList(i));
+    }
+
+    /**
+     * Insert another list before Instruction handle ih contained in this list. Consumes argument list, i.e., it becomes
+     * empty.
+     *
+     * @param ih where to append the instruction list
+     * @param il Instruction list to insert
+     * @return instruction handle of the first inserted instruction
+     */
+    public InstructionHandle insert(final InstructionHandle ih, final InstructionList il) {
+        if (il == null) {
+            throw new ClassGenException("Inserting null InstructionList");
+        }
+        if (il.isEmpty()) {
+            return ih;
+        }
+        final InstructionHandle prev = ih.getPrev();
+        final InstructionHandle ret = il.start;
+        ih.setPrev(il.end);
+        il.end.setNext(ih);
+        il.start.setPrev(prev);
+        if (prev != null) {
+            prev.setNext(il.start);
+        } else {
+            start = il.start; // Update start ...
+        }
+        length += il.length; // Update length
+        il.clear();
+        return ret;
+    }
+
+    /**
+     * Insert another list.
+     *
+     * @param il list to insert before start of this list
+     * @return instruction handle of the first inserted instruction
+     */
+    public InstructionHandle insert(final InstructionList il) {
+        if (isEmpty()) {
+            append(il); // Code is identical for this case
+            return start;
+        }
+        return insert(start, il);
+    }
+
+    /**
+     * Test for empty list.
+     */
+    public boolean isEmpty() {
+        return start == null;
+    } // && end == null
+
+    /**
+     * @return iterator that lists all instructions (handles)
+     */
+    @Override
+    public Iterator<InstructionHandle> iterator() {
+        return new Iterator<InstructionHandle>() {
+
+            private InstructionHandle ih = start;
+
+            @Override
+            public boolean hasNext() {
+                return ih != null;
+            }
+
+            @Override
+            public InstructionHandle next() throws NoSuchElementException {
+                if (ih == null) {
+                    throw new NoSuchElementException();
+                }
+                final InstructionHandle i = ih;
+                ih = ih.getNext();
+                return i;
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+
+    /**
+     * Move a single instruction (handle) to a new location.
+     *
+     * @param ih moved instruction
+     * @param target new location of moved instruction
+     */
+    public void move(final InstructionHandle ih, final InstructionHandle target) {
+        move(ih, ih, target);
+    }
+
+    /**
+     * Take all instructions (handles) from "start" to "end" and append them after the new location "target". Of course,
+     * "end" must be after "start" and target must not be located withing this range. If you want to move something to the
+     * start of the list use null as value for target.
      * <p>
-     * Any instruction targeters pointing to handles within the block, keep
-     * their targets.
+     * Any instruction targeters pointing to handles within the block, keep their targets.
+     * </p>
      *
-     * @param start
-     *            of moved block
-     * @param end
-     *            of moved block
-     * @param target
-     *            of moved block
+     * @param start of moved block
+     * @param end of moved block
+     * @param target of moved block
      */
     public void move(final InstructionHandle start, final InstructionHandle end, final InstructionHandle target) {
         // Step 1: Check constraints
-        if ((start == null) || (end == null)) {
+        if (start == null || end == null) {
             throw new ClassGenException("Invalid null handle: From " + start + " to " + end);
         }
-        if ((target == start) || (target == end)) {
+        if (target == start || target == end) {
             throw new ClassGenException("Invalid range: From " + start + " to " + end + " contains target " + target);
         }
         for (InstructionHandle ih = start; ih != end.getNext(); ih = ih.getNext()) {
             if (ih == null) {
                 throw new ClassGenException("Invalid range: From " + start + " to " + end);
-            } else if (ih == target) {
+            }
+            if (ih == target) {
                 throw new ClassGenException("Invalid range: From " + start + " to " + end + " contains target " + target);
             }
         }
@@ -686,31 +924,86 @@ public void move(final InstructionHandle start, final InstructionHandle end, fin
     }
 
     /**
-     * Move a single instruction (handle) to a new location.
+     * Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions.
      *
-     * @param ih
-     *            moved instruction
-     * @param target
-     *            new location of moved instruction
+     * @param oldTarget the old target instruction handle
+     * @param newTarget the new target instruction handle
      */
-    public void move(final InstructionHandle ih, final InstructionHandle target) {
-        move(ih, ih, target);
+    public void redirectBranches(final InstructionHandle oldTarget, final InstructionHandle newTarget) {
+        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
+            final Instruction i = ih.getInstruction();
+            if (i instanceof BranchInstruction) {
+                final BranchInstruction b = (BranchInstruction) i;
+                final InstructionHandle target = b.getTarget();
+                if (target == oldTarget) {
+                    b.setTarget(newTarget);
+                }
+                if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
+                    final InstructionHandle[] targets = ((Select) b).getTargets();
+                    for (int j = 0; j < targets.length; j++) {
+                        if (targets[j] == oldTarget) {
+                            ((Select) b).setTarget(j, newTarget);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Redirect all references of exception handlers from oldTarget to newTarget.
+     *
+     * @param exceptions array of exception handlers
+     * @param oldTarget the old target instruction handle
+     * @param newTarget the new target instruction handle
+     * @see MethodGen
+     */
+    public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle oldTarget, final InstructionHandle newTarget) {
+        for (final CodeExceptionGen exception : exceptions) {
+            if (exception.getStartPC() == oldTarget) {
+                exception.setStartPC(newTarget);
+            }
+            if (exception.getEndPC() == oldTarget) {
+                exception.setEndPC(newTarget);
+            }
+            if (exception.getHandlerPC() == oldTarget) {
+                exception.setHandlerPC(newTarget);
+            }
+        }
     }
 
     /**
-     * Remove from instruction `prev' to instruction `next' both contained in
-     * this list. Throws TargetLostException when one of the removed instruction
-     * handles is still being targeted.
+     * Redirect all references of local variables from oldTarget to newTarget.
      *
-     * @param prev
-     *            where to start deleting (predecessor, exclusive)
-     * @param next
-     *            where to end deleting (successor, exclusive)
+     * @param lg array of local variables
+     * @param oldTarget the old target instruction handle
+     * @param newTarget the new target instruction handle
+     * @see MethodGen
+     */
+    public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle oldTarget, final InstructionHandle newTarget) {
+        for (final LocalVariableGen element : lg) {
+            final InstructionHandle start = element.getStart();
+            final InstructionHandle end = element.getEnd();
+            if (start == oldTarget) {
+                element.setStart(newTarget);
+            }
+            if (end == oldTarget) {
+                element.setEnd(newTarget);
+            }
+        }
+    }
+
+    /**
+     * Remove from instruction 'prev' to instruction 'next' both contained in this list. Throws TargetLostException when one
+     * of the removed instruction handles is still being targeted.
+     *
+     * @param prev where to start deleting (predecessor, exclusive)
+     * @param next where to end deleting (successor, exclusive)
      */
     private void remove(final InstructionHandle prev, InstructionHandle next) throws TargetLostException {
         InstructionHandle first;
         InstructionHandle last; // First and last deleted instruction
-        if ((prev == null) && (next == null)) {
+        if (prev == null && next == null) {
             first = start;
             last = end;
             start = end = null;
@@ -732,7 +1025,7 @@ private void remove(final InstructionHandle prev, InstructionHandle next) throws
         }
         first.setPrev(null); // Completely separated from rest of list
         last.setNext(null);
-        final List<InstructionHandle> target_vec = new ArrayList<>();
+        final List<InstructionHandle> targetList = new ArrayList<>();
         for (InstructionHandle ih = first; ih != null; ih = ih.getNext()) {
             ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets
         }
@@ -741,7 +1034,7 @@ private void remove(final InstructionHandle prev, InstructionHandle next) throws
             next = ih.getNext();
             length--;
             if (ih.hasTargeters()) { // Still got targeters?
-                target_vec.add(ih);
+                targetList.add(ih);
                 buf.append(ih.toString(true)).append(" ");
                 ih.setNext(ih.setPrev(null));
             } else {
@@ -749,120 +1042,32 @@ private void remove(final InstructionHandle prev, InstructionHandle next) throws
             }
         }
         buf.append("}");
-        if (!target_vec.isEmpty()) {
-            final InstructionHandle[] targeted = new InstructionHandle[target_vec.size()];
-            target_vec.toArray(targeted);
-            throw new TargetLostException(targeted, buf.toString());
-        }
-    }
-
-    /**
-     * Remove instruction from this list. The corresponding Instruction handles
-     * must not be reused!
-     *
-     * @param ih
-     *            instruction (handle) to remove
-     */
-    public void delete(final InstructionHandle ih) throws TargetLostException {
-        remove(ih.getPrev(), ih.getNext());
-    }
-
-    /**
-     * Remove instruction from this list. The corresponding Instruction handles must not be reused!
-     *
-     * @param i
-     *            instruction to remove
-     */
-    public void delete(final Instruction i) throws TargetLostException {
-        InstructionHandle ih;
-        if ((ih = findInstruction1(i)) == null) {
-            throw new ClassGenException("Instruction " + i + " is not contained in this list.");
+        if (!targetList.isEmpty()) {
+            throw new TargetLostException(targetList.toArray(InstructionHandle.EMPTY_ARRAY), buf.toString());
         }
-        delete(ih);
     }
 
     /**
-     * Remove instructions from instruction `from' to instruction `to' contained
-     * in this list. The user must ensure that `from' is an instruction before
-     * `to', or risk havoc. The corresponding Instruction handles must not be
-     * reused!
-     *
-     * @param from
-     *            where to start deleting (inclusive)
-     * @param to
-     *            where to end deleting (inclusive)
-     */
-    public void delete(final InstructionHandle from, final InstructionHandle to) throws TargetLostException {
-        remove(from.getPrev(), to.getNext());
-    }
-
-    /**
-     * Remove instructions from instruction `from' to instruction `to' contained in this list. The user must ensure that `from' is an instruction before `to',
-     * or risk havoc. The corresponding Instruction handles must not be reused!
-     *
-     * @param from
-     *            where to start deleting (inclusive)
-     * @param to
-     *            where to end deleting (inclusive)
-     */
-    public void delete(final Instruction from, final Instruction to) throws TargetLostException {
-        InstructionHandle from_ih;
-        InstructionHandle to_ih;
-        if ((from_ih = findInstruction1(from)) == null) {
-            throw new ClassGenException("Instruction " + from + " is not contained in this list.");
-        }
-        if ((to_ih = findInstruction2(to)) == null) {
-            throw new ClassGenException("Instruction " + to + " is not contained in this list.");
-        }
-        delete(from_ih, to_ih);
-    }
-
-    /**
-     * Search for given Instruction reference, start at beginning of list.
-     *
-     * @param i
-     *            instruction to search for
-     * @return instruction found on success, null otherwise
+     * Remove observer for this object.
      */
-    private InstructionHandle findInstruction1(final Instruction i) {
-        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
-            if (ih.getInstruction() == i) {
-                return ih;
-            }
+    public void removeObserver(final InstructionListObserver o) {
+        if (observers != null) {
+            observers.remove(o);
         }
-        return null;
     }
 
     /**
-     * Search for given Instruction reference, start at end of list
-     *
-     * @param i
-     *            instruction to search for
-     * @return instruction found on success, null otherwise
+     * Replace all references to the old constant pool with references to the new constant pool
      */
-    private InstructionHandle findInstruction2(final Instruction i) {
-        for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) {
-            if (ih.getInstruction() == i) {
-                return ih;
-            }
-        }
-        return null;
-    }
-
-    public boolean contains(final InstructionHandle i) {
-        if (i == null) {
-            return false;
-        }
+    public void replaceConstantPool(final ConstantPoolGen oldCp, final ConstantPoolGen newCp) {
         for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
-            if (ih == i) {
-                return true;
+            final Instruction i = ih.getInstruction();
+            if (i instanceof CPInstruction) {
+                final CPInstruction ci = (CPInstruction) i;
+                final Constant c = oldCp.getConstant(ci.getIndex());
+                ci.setIndex(newCp.addConstant(c, oldCp));
             }
         }
-        return false;
-    }
-
-    public boolean contains(final Instruction i) {
-        return findInstruction1(i) != null;
     }
 
     public void setPositions() { // TODO could be package-protected? (some test code would need to be repackaged)
@@ -870,15 +1075,13 @@ public void setPositions() { // TODO could be package-protected? (some test code
     }
 
     /**
-     * Give all instructions their position number (offset in byte stream),
-     * i.e., make the list ready to be dumped.
+     * Give all instructions their position number (offset in byte stream), i.e., make the list ready to be dumped.
      *
-     * @param check
-     *            Perform sanity checks, e.g. if all targeted instructions really belong to this list
+     * @param check Perform sanity checks, e.g. if all targeted instructions really belong to this list
      */
     public void setPositions(final boolean check) { // called by code in other packages
-        int max_additional_bytes = 0;
-        int additional_bytes = 0;
+        int maxAdditionalBytes = 0;
+        int additionalBytes = 0;
         int index = 0;
         int count = 0;
         final int[] pos = new int[length];
@@ -891,26 +1094,20 @@ public void setPositions(final boolean check) { // called by code in other packa
                 if (i instanceof BranchInstruction) { // target instruction within list?
                     Instruction inst = ((BranchInstruction) i).getTarget().getInstruction();
                     if (!contains(inst)) {
-                        throw new ClassGenException("Branch target of "
-                                + Const.getOpcodeName(i.getOpcode()) + ":"
-                                + inst + " not in instruction list");
+                        throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list");
                     }
                     if (i instanceof Select) {
                         final InstructionHandle[] targets = ((Select) i).getTargets();
                         for (final InstructionHandle target : targets) {
                             inst = target.getInstruction();
                             if (!contains(inst)) {
-                                throw new ClassGenException("Branch target of "
-                                        + Const.getOpcodeName(i.getOpcode()) + ":"
-                                        + inst + " not in instruction list");
+                                throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list");
                             }
                         }
                     }
                     if (!(ih instanceof BranchHandle)) {
                         throw new ClassGenException(
-                                "Branch instruction "
-                                + Const.getOpcodeName(i.getOpcode()) + ":"
-                                + inst + " not contained in BranchHandle.");
+                            "Branch instruction " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not contained in BranchHandle.");
                     }
                 }
             }
@@ -923,33 +1120,30 @@ public void setPositions(final boolean check) { // called by code in other packa
             ih.setPosition(index);
             pos[count++] = index;
             /*
-             * Get an estimate about how many additional bytes may be added,
-             * because BranchInstructions may have variable length depending on the target offset
-             * (short vs. int) or alignment issues (TABLESWITCH and LOOKUPSWITCH).
+             * Get an estimate about how many additional bytes may be added, because BranchInstructions may have variable length
+             * depending on the target offset (short vs. int) or alignment issues (TABLESWITCH and LOOKUPSWITCH).
              */
             switch (i.getOpcode()) {
-                case Const.JSR:
-                case Const.GOTO:
-                    max_additional_bytes += 2;
+            case Const.JSR:
+            case Const.GOTO:
+                maxAdditionalBytes += 2;
                 break;
-                case Const.TABLESWITCH:
-                case Const.LOOKUPSWITCH:
-                    max_additional_bytes += 3;
+            case Const.TABLESWITCH:
+            case Const.LOOKUPSWITCH:
+                maxAdditionalBytes += 3;
                 break;
             }
             index += i.getLength();
         }
-
-        /* Pass 2: Expand the variable-length (Branch)Instructions depending on
-         * the target offset (short or int) and ensure that branch targets are
-         * within this list.
+        /*
+         * Pass 2: Expand the variable-length (Branch)Instructions depending on the target offset (short or int) and ensure that
+         * branch targets are within this list.
          */
         for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
-            additional_bytes += ih.updatePosition(additional_bytes, max_additional_bytes);
+            additionalBytes += ih.updatePosition(additionalBytes, maxAdditionalBytes);
         }
         /*
-         * Pass 3: Update position numbers (which may have changed due to the
-         * preceding expansions), like pass 1.
+         * Pass 3: Update position numbers (which may have changed due to the preceding expansions), like pass 1.
          */
         index = count = 0;
         for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
@@ -963,43 +1157,10 @@ public void setPositions(final boolean check) { // called by code in other packa
     }
 
     /**
-     * When everything is finished, use this method to convert the instruction
-     * list into an array of bytes.
-     *
-     * @return the byte code ready to be dumped
-     */
-    public byte[] getByteCode() {
-        // Update position indices of instructions
-        setPositions();
-        final ByteArrayOutputStream b = new ByteArrayOutputStream();
-        final DataOutputStream out = new DataOutputStream(b);
-        try {
-            for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
-                final Instruction i = ih.getInstruction();
-                i.dump(out); // Traverse list
-            }
-            out.flush();
-        } catch (final IOException e) {
-            System.err.println(e);
-            return new byte[0];
-        }
-        return b.toByteArray();
-    }
-
-    /**
-     * @return an array of instructions without target information for branch
-     * instructions.
+     * @return length of list (Number of instructions, not bytes)
      */
-    public Instruction[] getInstructions() {
-        final List<Instruction> instructions = new ArrayList<>();
-        try (ByteSequence bytes = new ByteSequence(getByteCode())) {
-            while (bytes.available() > 0) {
-                instructions.add(Instruction.readInstruction(bytes));
-            }
-        } catch (final IOException e) {
-            throw new ClassGenException(e.toString(), e);
-        }
-        return instructions.toArray(new Instruction[instructions.size()]);
+    public int size() {
+        return length;
     }
 
     @Override
@@ -1008,8 +1169,7 @@ public String toString() {
     }
 
     /**
-     * @param verbose
-     *            toggle output format
+     * @param verbose toggle output format
      * @return String containing all instructions in this list.
      */
     public String toString(final boolean verbose) {
@@ -1021,277 +1181,8 @@ public String toString(final boolean verbose) {
     }
 
     /**
-     * @return iterator that lists all instructions (handles)
-     */
-    @Override
-    public Iterator<InstructionHandle> iterator() {
-        return new Iterator<InstructionHandle>() {
-
-            private InstructionHandle ih = start;
-
-            @Override
-            public InstructionHandle next() throws NoSuchElementException {
-                if (ih == null) {
-                    throw new NoSuchElementException();
-                }
-                final InstructionHandle i = ih;
-                ih = ih.getNext();
-                return i;
-            }
-
-            @Override
-            public void remove() {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override
-            public boolean hasNext() {
-                return ih != null;
-            }
-        };
-    }
-
-    /**
-     * @return array containing all instructions (handles)
-     */
-    public InstructionHandle[] getInstructionHandles() {
-        final InstructionHandle[] ihs = new InstructionHandle[length];
-        InstructionHandle ih = start;
-        for (int i = 0; i < length; i++) {
-            ihs[i] = ih;
-            ih = ih.getNext();
-        }
-        return ihs;
-    }
-
-    /**
-     * Get positions (offsets) of all instructions in the list. This relies on
-     * that the list has been freshly created from an byte code array, or that
-     * setPositions() has been called. Otherwise this may be inaccurate.
-     *
-     * @return array containing all instruction's offset in byte code
-     */
-    public int[] getInstructionPositions() {
-        return bytePositions;
-    }
-
-    /**
-     * @return complete, i.e., deep copy of this list
-     */
-    public InstructionList copy() {
-        final Map<InstructionHandle, InstructionHandle> map = new HashMap<>();
-        final InstructionList il = new InstructionList();
-        /*
-         * Pass 1: Make copies of all instructions, append them to the new list
-         * and associate old instruction references with the new ones, i.e., a 1:1 mapping.
-         */
-        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
-            final Instruction i = ih.getInstruction();
-            final Instruction c = i.copy(); // Use clone for shallow copy
-            if (c instanceof BranchInstruction) {
-                map.put(ih, il.append((BranchInstruction) c));
-            } else {
-                map.put(ih, il.append(c));
-            }
-        }
-        /*
-         * Pass 2: Update branch targets.
-         */
-        InstructionHandle ih = start;
-        InstructionHandle ch = il.start;
-        while (ih != null) {
-            final Instruction i = ih.getInstruction();
-            final Instruction c = ch.getInstruction();
-            if (i instanceof BranchInstruction) {
-                final BranchInstruction bi = (BranchInstruction) i;
-                final BranchInstruction bc = (BranchInstruction) c;
-                final InstructionHandle itarget = bi.getTarget(); // old target
-                // New target is in hash map
-                bc.setTarget(map.get(itarget));
-                if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
-                    final InstructionHandle[] itargets = ((Select) bi).getTargets();
-                    final InstructionHandle[] ctargets = ((Select) bc).getTargets();
-                    for (int j = 0; j < itargets.length; j++) { // Update all targets
-                        ctargets[j] = map.get(itargets[j]);
-                    }
-                }
-            }
-            ih = ih.getNext();
-            ch = ch.getNext();
-        }
-        return il;
-    }
-
-    /**
-     * Replace all references to the old constant pool with references to the
-     * new constant pool
-     */
-    public void replaceConstantPool(final ConstantPoolGen old_cp, final ConstantPoolGen new_cp) {
-        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
-            final Instruction i = ih.getInstruction();
-            if (i instanceof CPInstruction) {
-                final CPInstruction ci = (CPInstruction) i;
-                final Constant c = old_cp.getConstant(ci.getIndex());
-                ci.setIndex(new_cp.addConstant(c, old_cp));
-            }
-        }
-    }
-
-    private void clear() {
-        start = end = null;
-        length = 0;
-    }
-
-    /**
-     * Delete contents of list. Provides better memory utilization, because the
-     * system then may reuse the instruction handles. This method is typically
-     * called right after {@link MethodGen#getMethod()}.
-     */
-    public void dispose() {
-        // Traverse in reverse order, because ih.next is overwritten
-        for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) {
-            /*
-             * Causes BranchInstructions to release target and targeters,
-             * because it calls dispose() on the contained instruction.
-             */
-            ih.dispose();
-        }
-        clear();
-    }
-
-    /**
-     * @return start of list
-     */
-    public InstructionHandle getStart() {
-        return start;
-    }
-
-    /**
-     * @return end of list
-     */
-    public InstructionHandle getEnd() {
-        return end;
-    }
-
-    /**
-     * @return length of list (Number of instructions, not bytes)
-     */
-    public int getLength() {
-        return length;
-    }
-
-    /**
-     * @return length of list (Number of instructions, not bytes)
-     */
-    public int size() {
-        return length;
-    }
-
-    /**
-     * Redirect all references from old_target to new_target, i.e., update
-     * targets of branch instructions.
-     *
-     * @param old_target
-     *            the old target instruction handle
-     * @param new_target
-     *            the new target instruction handle
-     */
-    public void redirectBranches(final InstructionHandle old_target, final InstructionHandle new_target) {
-        for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
-            final Instruction i = ih.getInstruction();
-            if (i instanceof BranchInstruction) {
-                final BranchInstruction b = (BranchInstruction) i;
-                final InstructionHandle target = b.getTarget();
-                if (target == old_target) {
-                    b.setTarget(new_target);
-                }
-                if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
-                    final InstructionHandle[] targets = ((Select) b).getTargets();
-                    for (int j = 0; j < targets.length; j++) {
-                        if (targets[j] == old_target) {
-                            ((Select) b).setTarget(j, new_target);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Redirect all references of local variables from old_target to new_target.
-     *
-     * @param lg
-     *            array of local variables
-     * @param old_target
-     *            the old target instruction handle
-     * @param new_target
-     *            the new target instruction handle
-     * @see MethodGen
-     */
-    public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle old_target, final InstructionHandle new_target) {
-        for (final LocalVariableGen element : lg) {
-            final InstructionHandle start = element.getStart();
-            final InstructionHandle end = element.getEnd();
-            if (start == old_target) {
-                element.setStart(new_target);
-            }
-            if (end == old_target) {
-                element.setEnd(new_target);
-            }
-        }
-    }
-
-    /**
-     * Redirect all references of exception handlers from old_target to new_target.
-     *
-     * @param exceptions
-     *            array of exception handlers
-     * @param old_target
-     *            the old target instruction handle
-     * @param new_target
-     *            the new target instruction handle
-     * @see MethodGen
-     */
-    public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions,
-            final InstructionHandle old_target, final InstructionHandle new_target) {
-        for (final CodeExceptionGen exception : exceptions) {
-            if (exception.getStartPC() == old_target) {
-                exception.setStartPC(new_target);
-            }
-            if (exception.getEndPC() == old_target) {
-                exception.setEndPC(new_target);
-            }
-            if (exception.getHandlerPC() == old_target) {
-                exception.setHandlerPC(new_target);
-            }
-        }
-    }
-
-    private List<InstructionListObserver> observers;
-
-    /**
-     * Add observer for this object.
-     */
-    public void addObserver(final InstructionListObserver o) {
-        if (observers == null) {
-            observers = new ArrayList<>();
-        }
-        observers.add(o);
-    }
-
-    /**
-     * Remove observer for this object.
-     */
-    public void removeObserver(final InstructionListObserver o) {
-        if (observers != null) {
-            observers.remove(o);
-        }
-    }
-
-    /**
-     * Call notify() method on all observers. This method is not called
-     * automatically whenever the state has changed, but has to be called by the
-     * user after he has finished editing the object.
+     * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but
+     * has to be called by the user after he has finished editing the object.
      */
     public void update() {
         if (observers != null) {
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java
index 116273a44d7..758c455d659 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionListObserver.java
@@ -22,11 +22,10 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Implement this interface if you're interested in changes to an InstructionList object
- * and register yourself with addObserver().
- *
+ * Implement this interface if you're interested in changes to an InstructionList object and register yourself with
+ * addObserver().
  */
 public interface InstructionListObserver {
 
-    void notify( InstructionList list );
+    void notify(InstructionList list);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java
index 8cd436b38ce..5146408ef49 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionTargeter.java
@@ -22,8 +22,7 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denote that a class targets InstructionHandles within an InstructionList. Namely
- * the following implementers:
+ * Denote that a class targets InstructionHandles within an InstructionList. Namely the following implementers:
  *
  * @see BranchHandle
  * @see LocalVariableGen
@@ -31,6 +30,8 @@
  */
 public interface InstructionTargeter {
 
+    // static final InstructionTargeter[] EMPTY_ARRAY = new InstructionTargeter[0];
+
     /**
      * Checks whether this targeter targets the specified instruction handle.
      */
@@ -39,9 +40,9 @@ public interface InstructionTargeter {
     /**
      * Replaces the target of this targeter from this old handle to the new handle.
      *
-     * @param old_ih the old handle
-     * @param new_ih the new handle
-     * @throws ClassGenException if old_ih is not targeted by this object
+     * @param oldIh the old handle
+     * @param newIh the new handle
+     * @throws ClassGenException if oldIh is not targeted by this object
      */
-    void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) throws ClassGenException;
+    void updateTarget(InstructionHandle oldIh, InstructionHandle newIh) throws ClassGenException;
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java
index 73948914077..0daa3abfc13 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InvokeInstruction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,23 +26,21 @@
 import com.sun.org.apache.bcel.internal.classfile.Constant;
 import com.sun.org.apache.bcel.internal.classfile.ConstantCP;
 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
+import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
  * Super class for the INVOKExxx family of instructions.
  *
- * @LastModified: Jan 2020
+ * @LastModified: Feb 2023
  */
-public abstract class InvokeInstruction extends FieldOrMethod implements ExceptionThrower,
-        StackConsumer, StackProducer {
+public abstract class InvokeInstruction extends FieldOrMethod implements ExceptionThrower, StackConsumer, StackProducer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     InvokeInstruction() {
     }
 
-
     /**
      * @param index to constant pool
      */
@@ -50,39 +48,15 @@ protected InvokeInstruction(final short opcode, final int index) {
         super(opcode, index);
     }
 
-
     /**
-     * @return mnemonic for instruction with symbolic references resolved
-     */
-    @Override
-    public String toString( final ConstantPool cp ) {
-        final Constant c = cp.getConstant(super.getIndex());
-        final StringTokenizer tok = new StringTokenizer(cp.constantToString(c));
-
-        final String opcodeName = Const.getOpcodeName(super.getOpcode());
-
-        final StringBuilder sb = new StringBuilder(opcodeName);
-        if (tok.hasMoreTokens()) {
-            sb.append(" ");
-            sb.append(tok.nextToken().replace('.', '/'));
-            if (tok.hasMoreTokens()) {
-                sb.append(tok.nextToken());
-            }
-        }
-
-        return sb.toString();
-    }
-
-
-    /**
-     * Also works for instructions whose stack effect depends on the
-     * constant pool entry they reference.
+     * Also works for instructions whose stack effect depends on the constant pool entry they reference.
+     *
      * @return Number of words consumed from stack by this instruction
      */
     @Override
-    public int consumeStack( final ConstantPoolGen cpg ) {
+    public int consumeStack(final ConstantPoolGen cpg) {
         int sum;
-        if ((super.getOpcode() == Const.INVOKESTATIC) || (super.getOpcode() == Const.INVOKEDYNAMIC)) {
+        if (super.getOpcode() == Const.INVOKESTATIC || super.getOpcode() == Const.INVOKEDYNAMIC) {
             sum = 0;
         } else {
             sum = 1; // this reference
@@ -93,23 +67,15 @@ public int consumeStack( final ConstantPoolGen cpg ) {
         return sum;
     }
 
-
     /**
-     * Also works for instructions whose stack effect depends on the
-     * constant pool entry they reference.
-     * @return Number of words produced onto stack by this instruction
+     * @return argument types of referenced method.
      */
-    @Override
-    public int produceStack( final ConstantPoolGen cpg ) {
-        final String signature = getSignature(cpg);
-        return Type.getReturnTypeSize(signature);
+    public Type[] getArgumentTypes(final ConstantPoolGen cpg) {
+        return Type.getArgumentTypes(getSignature(cpg));
     }
 
     /**
-     * This overrides the deprecated version as we know here that the referenced class
-     * may legally be an array.
-     *
-     * @deprecated in FieldOrMethod
+     * This overrides the deprecated version as we know here that the referenced class may legally be an array.
      *
      * @return name of the referenced class/interface
      * @throws IllegalArgumentException if the referenced class is an array (this should not happen)
@@ -120,35 +86,62 @@ public String getClassName( final ConstantPoolGen cpg ) {
         final ConstantPool cp = cpg.getConstantPool();
         final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
         final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class);
-        return className.replace('/', '.');
+        return Utility.pathToPackage(className);
     }
 
-    /** @return return type of referenced method.
+    /**
+     * @return name of referenced method.
      */
-    @Override
-    public Type getType( final ConstantPoolGen cpg ) {
-        return getReturnType(cpg);
+    public String getMethodName(final ConstantPoolGen cpg) {
+        return getName(cpg);
     }
 
-
-    /** @return name of referenced method.
+    /**
+     * @return return type of referenced method.
      */
-    public String getMethodName( final ConstantPoolGen cpg ) {
-        return getName(cpg);
+    public Type getReturnType(final ConstantPoolGen cpg) {
+        return Type.getReturnType(getSignature(cpg));
     }
 
-
-    /** @return return type of referenced method.
+    /**
+     * @return return type of referenced method.
      */
-    public Type getReturnType( final ConstantPoolGen cpg ) {
-        return Type.getReturnType(getSignature(cpg));
+    @Override
+    public Type getType(final ConstantPoolGen cpg) {
+        return getReturnType(cpg);
     }
 
+    /**
+     * Also works for instructions whose stack effect depends on the constant pool entry they reference.
+     *
+     * @return Number of words produced onto stack by this instruction
+     */
+    @Override
+    public int produceStack(final ConstantPoolGen cpg) {
+        final String signature = getSignature(cpg);
+        return Type.getReturnTypeSize(signature);
+    }
 
-    /** @return argument types of referenced method.
+    /**
+     * @return mnemonic for instruction with symbolic references resolved
      */
-    public Type[] getArgumentTypes( final ConstantPoolGen cpg ) {
-        return Type.getArgumentTypes(getSignature(cpg));
+    @Override
+    public String toString(final ConstantPool cp) {
+        final Constant c = cp.getConstant(super.getIndex());
+        final StringTokenizer tok = new StringTokenizer(cp.constantToString(c));
+
+        final String opcodeName = Const.getOpcodeName(super.getOpcode());
+
+        final StringBuilder sb = new StringBuilder(opcodeName);
+        if (tok.hasMoreTokens()) {
+            sb.append(" ");
+            sb.append(Utility.packageToPath(tok.nextToken()));
+            if (tok.hasMoreTokens()) {
+                sb.append(tok.nextToken());
+            }
+        }
+
+        return sb.toString();
     }
 
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR.java
index edcc569ec03..548b321d0bc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR.java
@@ -26,29 +26,41 @@
 
 /**
  * JSR - Jump to subroutine
- *
  */
 public class JSR extends JsrInstruction implements VariableLengthInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     JSR() {
     }
 
-
     public JSR(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.JSR, target);
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitStackProducer(this);
+        v.visitVariableLengthInstruction(this);
+        v.visitBranchInstruction(this);
+        v.visitJsrInstruction(this);
+        v.visitJSR(this);
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         super.setIndex(getTargetOffset());
         if (super.getOpcode() == com.sun.org.apache.bcel.internal.Const.JSR) {
             super.dump(out);
@@ -59,35 +71,16 @@ public void dump( final DataOutputStream out ) throws IOException {
         }
     }
 
-
     @Override
-    protected int updatePosition( final int offset, final int max_offset ) {
+    protected int updatePosition(final int offset, final int maxOffset) {
         final int i = getTargetOffset(); // Depending on old position value
         setPosition(getPosition() + offset); // Position may be shifted by preceding expansions
-        if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate)
+        if (Math.abs(i) >= Short.MAX_VALUE - maxOffset) { // to large for short (estimate)
             super.setOpcode(com.sun.org.apache.bcel.internal.Const.JSR_W);
-            final short old_length = (short) super.getLength();
+            final short oldLength = (short) super.getLength();
             super.setLength(5);
-            return super.getLength() - old_length;
+            return super.getLength() - oldLength;
         }
         return 0;
     }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitStackProducer(this);
-        v.visitVariableLengthInstruction(this);
-        v.visitBranchInstruction(this);
-        v.visitJsrInstruction(this);
-        v.visitJSR(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR_W.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR_W.java
index 7cf3c9289ec..b51d05c6799 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR_W.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR_W.java
@@ -28,59 +28,52 @@
 
 /**
  * JSR_W - Jump to subroutine
- *
  */
 public class JSR_W extends JsrInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     JSR_W() {
     }
 
-
     public JSR_W(final InstructionHandle target) {
         super(com.sun.org.apache.bcel.internal.Const.JSR_W, target);
         super.setLength(5);
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitStackProducer(this);
+        v.visitBranchInstruction(this);
+        v.visitJsrInstruction(this);
+        v.visitJSR_W(this);
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         super.setIndex(getTargetOffset());
         out.writeByte(super.getOpcode());
         out.writeInt(super.getIndex());
     }
 
-
     /**
      * Read needed data (e.g. index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         super.setIndex(bytes.readInt());
         super.setLength(5);
     }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitStackProducer(this);
-        v.visitBranchInstruction(this);
-        v.visitJsrInstruction(this);
-        v.visitJSR_W(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java
index f999d5ce76b..1ecd736d355 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JsrInstruction.java
@@ -23,42 +23,33 @@
 
 /**
  * Super class for JSR - Jump to subroutine
- *
  */
-public abstract class JsrInstruction extends BranchInstruction implements UnconditionalBranch,
-        TypedInstruction, StackProducer {
-
-    JsrInstruction(final short opcode, final InstructionHandle target) {
-        super(opcode, target);
-    }
-
+public abstract class JsrInstruction extends BranchInstruction implements UnconditionalBranch, TypedInstruction, StackProducer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     JsrInstruction() {
     }
 
+    JsrInstruction(final short opcode, final InstructionHandle target) {
+        super(opcode, target);
+    }
 
-    /** @return return address type
+    /**
+     * @return return address type
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
+    public Type getType(final ConstantPoolGen cp) {
         return new ReturnaddressType(physicalSuccessor());
     }
 
-
     /**
-     * Returns an InstructionHandle to the physical successor
-     * of this JsrInstruction. <B>For this method to work,
-     * this JsrInstruction object must not be shared between
-     * multiple InstructionHandle objects!</B>
-     * Formally, there must not be InstructionHandle objects
-     * i, j where i != j and i.getInstruction() == this ==
-     * j.getInstruction().
-     * @return an InstructionHandle to the "next" instruction that
-     * will be executed when RETurned from a subroutine.
+     * Returns an InstructionHandle to the physical successor of this JsrInstruction. <B>For this method to work, this
+     * JsrInstruction object must not be shared between multiple InstructionHandle objects!</B> Formally, there must not be
+     * InstructionHandle objects i, j where i != j and i.getInstruction() == this == j.getInstruction().
+     *
+     * @return an InstructionHandle to the "next" instruction that will be executed when RETurned from a subroutine.
      */
     public InstructionHandle physicalSuccessor() {
         InstructionHandle ih = super.getTarget();
@@ -73,7 +64,7 @@ public InstructionHandle physicalSuccessor() {
         final InstructionHandle toThis = ih;
         while (ih != null) {
             ih = ih.getNext();
-            if ((ih != null) && (ih.getInstruction() == this)) {
+            if (ih != null && ih.getInstruction() == this) {
                 throw new IllegalStateException("physicalSuccessor() called on a shared JsrInstruction.");
             }
         }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2D.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2D.java
index 9bfed38607f..b82861f1759 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2D.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2D.java
@@ -23,8 +23,10 @@
 
 /**
  * L2D - Convert long to double
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class L2D extends ConversionInstruction {
 
@@ -32,17 +34,14 @@ public L2D() {
         super(com.sun.org.apache.bcel.internal.Const.L2D);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2F.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2F.java
index 460ea64d0f6..a264f8c3bc6 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2F.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2F.java
@@ -23,8 +23,10 @@
 
 /**
  * L2F - Convert long to float
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result
+ * </PRE>
  */
 public class L2F extends ConversionInstruction {
 
@@ -32,17 +34,14 @@ public L2F() {
         super(com.sun.org.apache.bcel.internal.Const.L2F);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2I.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2I.java
index efcb614abdc..a6fb121586a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2I.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/L2I.java
@@ -23,8 +23,10 @@
 
 /**
  * L2I - Convert long to int
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result
+ * </PRE>
  */
 public class L2I extends ConversionInstruction {
 
@@ -32,17 +34,14 @@ public L2I() {
         super(com.sun.org.apache.bcel.internal.Const.L2I);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LADD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LADD.java
index 2bbd2681ae5..0f8163f6f13 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LADD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LADD.java
@@ -23,9 +23,12 @@
 
 /**
  * LADD - Add longs
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class LADD extends ArithmeticInstruction {
 
@@ -33,17 +36,14 @@ public LADD() {
         super(com.sun.org.apache.bcel.internal.Const.LADD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LALOAD.java
index 0d19b09c867..70fd5255a11 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LALOAD.java
@@ -23,28 +23,28 @@
 
 /**
  * LALOAD - Load long from array
- * <PRE>Stack: ..., arrayref, index -&gt; ..., value1, value2</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; ..., value1, value2
+ * </PRE>
  */
 public class LALOAD extends ArrayInstruction implements StackProducer {
 
-    /** Load long from array
+    /**
+     * Load long from array
      */
     public LALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.LALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LAND.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LAND.java
index 03f67c86640..75c18f9c40d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LAND.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LAND.java
@@ -23,9 +23,12 @@
 
 /**
  * LAND - Bitwise AND longs
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class LAND extends ArithmeticInstruction {
 
@@ -33,17 +36,14 @@ public LAND() {
         super(com.sun.org.apache.bcel.internal.Const.LAND);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LASTORE.java
index b59856fc0fc..96f3a951170 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LASTORE.java
@@ -22,29 +22,29 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * LASTORE -  Store into long array
- * <PRE>Stack: ..., arrayref, index, value.word1, value.word2 -&gt; ...</PRE>
+ * LASTORE - Store into long array
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value.word1, value.word2 -&gt; ...
+ * </PRE>
  */
 public class LASTORE extends ArrayInstruction implements StackConsumer {
 
-    /** Store long into array
+    /**
+     * Store long into array
      */
     public LASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.LASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCMP.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCMP.java
index 9cf73c1ca03..c517b492f0a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCMP.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCMP.java
@@ -23,8 +23,10 @@
 
 /**
  * LCMP - Compare longs:
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt; ..., result &lt;= -1, 0, 1&gt;</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt; ..., result &lt;= -1, 0, 1&gt;
+ * </PRE>
  *
  */
 public class LCMP extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
@@ -33,28 +35,25 @@ public LCMP() {
         super(com.sun.org.apache.bcel.internal.Const.LCMP, (short) 1);
     }
 
-
-    /** @return Type.LONG
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.LONG;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
         v.visitLCMP(this);
     }
+
+    /**
+     * @return Type.LONG
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.LONG;
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCONST.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCONST.java
index af1ced8e90a..76ff4a26e25 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCONST.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LCONST.java
@@ -23,22 +23,21 @@
 /**
  * LCONST - Push 0 or 1, other values cause an exception
  *
- * <PRE>Stack: ... -&gt; ..., </PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ...,
+ * </PRE>
  */
 public class LCONST extends Instruction implements ConstantPushInstruction {
 
-    private long value;
-
+    private final long value;
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LCONST() {
+        this(0);
     }
 
-
     public LCONST(final long l) {
         super(com.sun.org.apache.bcel.internal.Const.LCONST_0, (short) 1);
         if (l == 0) {
@@ -51,35 +50,31 @@ public LCONST(final long l) {
         value = l;
     }
 
-
-    @Override
-    public Number getValue() {
-        return Long.valueOf(value);
-    }
-
-
-    /** @return Type.LONG
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.LONG;
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitPushInstruction(this);
         v.visitStackProducer(this);
         v.visitTypedInstruction(this);
         v.visitConstantPushInstruction(this);
         v.visitLCONST(this);
     }
+
+    /**
+     * @return Type.LONG
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.LONG;
+    }
+
+    @Override
+    public Number getValue() {
+        return Long.valueOf(value);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java
index 92c490a43b4..d95bade23bd 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java
@@ -29,44 +29,47 @@
 /**
  * LDC - Push item from constant pool.
  *
- * <PRE>Stack: ... -&gt; ..., item</PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ..., item
+ * </PRE>
  * @LastModified: May 2021
  */
 public class LDC extends CPInstruction implements PushInstruction, ExceptionThrower {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LDC() {
     }
 
-
     public LDC(final int index) {
         super(com.sun.org.apache.bcel.internal.Const.LDC_W, index);
         setSize();
     }
 
-
-    // Adjust to proper size
-    protected final void setSize() {
-        if (super.getIndex() <= com.sun.org.apache.bcel.internal.Const.MAX_BYTE) { // Fits in one byte?
-            super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC);
-            super.setLength(2);
-        } else {
-            super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC_W);
-            super.setLength(3);
-        }
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitStackProducer(this);
+        v.visitPushInstruction(this);
+        v.visitExceptionThrower(this);
+        v.visitTypedInstruction(this);
+        v.visitCPInstruction(this);
+        v.visitLDC(this);
     }
 
-
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         out.writeByte(super.getOpcode());
         if (super.getLength() == 2) { // TODO useless check?
             out.writeByte(super.getIndex());
@@ -75,86 +78,73 @@ public void dump( final DataOutputStream out ) throws IOException {
         }
     }
 
-
-    /**
-     * Set the index to constant pool and adjust size.
-     */
     @Override
-    public final void setIndex( final int index ) {
-        super.setIndex(index);
-        setSize();
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_STRING_RESOLUTION);
     }
 
-
-    /**
-     * Read needed data (e.g. index) from file.
-     */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
-        super.setLength(2);
-        super.setIndex(bytes.readUnsignedByte());
+    public Type getType(final ConstantPoolGen cpg) {
+        switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) {
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_String:
+            return Type.STRING;
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float:
+            return Type.FLOAT;
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer:
+            return Type.INT;
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class:
+            return Type.CLASS;
+        default: // Never reached
+            throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
+        }
     }
 
-
-    public Object getValue( final ConstantPoolGen cpg ) {
+    public Object getValue(final ConstantPoolGen cpg) {
         com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex());
         switch (c.getTag()) {
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_String:
-                final int i = ((com.sun.org.apache.bcel.internal.classfile.ConstantString) c).getStringIndex();
-                c = cpg.getConstantPool().getConstant(i);
-                return ((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes();
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float:
-                return ((com.sun.org.apache.bcel.internal.classfile.ConstantFloat) c).getBytes();
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer:
-                return ((com.sun.org.apache.bcel.internal.classfile.ConstantInteger) c).getBytes();
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class:
-                final int nameIndex = ((com.sun.org.apache.bcel.internal.classfile.ConstantClass) c).getNameIndex();
-                c = cpg.getConstantPool().getConstant(nameIndex);
-                return new ObjectType(((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes());
-            default: // Never reached
-                throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
-        }
-    }
-
-
-    @Override
-    public Type getType( final ConstantPoolGen cpg ) {
-        switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) {
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_String:
-                return Type.STRING;
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float:
-                return Type.FLOAT;
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer:
-                return Type.INT;
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class:
-                return Type.CLASS;
-            default: // Never reached
-                throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_String:
+            final int i = ((com.sun.org.apache.bcel.internal.classfile.ConstantString) c).getStringIndex();
+            c = cpg.getConstantPool().getConstant(i);
+            return ((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes();
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float:
+            return Float.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantFloat) c).getBytes());
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer:
+            return Integer.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantInteger) c).getBytes());
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class:
+            final int nameIndex = ((com.sun.org.apache.bcel.internal.classfile.ConstantClass) c).getNameIndex();
+            c = cpg.getConstantPool().getConstant(nameIndex);
+            return Type.getType(((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes());
+        default: // Never reached
+            throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
         }
     }
 
-
+    /**
+     * Read needed data (e.g. index) from file.
+     */
     @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_STRING_RESOLUTION);
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+        super.setLength(2);
+        super.setIndex(bytes.readUnsignedByte());
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
+     * Set the index to constant pool and adjust size.
      */
     @Override
-    public void accept( final Visitor v ) {
-        v.visitStackProducer(this);
-        v.visitPushInstruction(this);
-        v.visitExceptionThrower(this);
-        v.visitTypedInstruction(this);
-        v.visitCPInstruction(this);
-        v.visitLDC(this);
+    public final void setIndex(final int index) {
+        super.setIndex(index);
+        setSize();
+    }
+
+    // Adjust to proper size
+    protected final void setSize() {
+        if (super.getIndex() <= com.sun.org.apache.bcel.internal.Const.MAX_BYTE) { // Fits in one byte?
+            super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC);
+            super.setLength(2);
+        } else {
+            super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC_W);
+            super.setLength(3);
+        }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java
index ade9b29cd84..dc2ef43bea7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java
@@ -23,65 +23,59 @@
 /**
  * LDC2_W - Push long or double from constant pool
  *
- * <PRE>Stack: ... -&gt; ..., item.word1, item.word2</PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ..., item.word1, item.word2
+ * </PRE>
  * @LastModified: May 2021
  */
 public class LDC2_W extends CPInstruction implements PushInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LDC2_W() {
     }
 
-
     public LDC2_W(final int index) {
         super(com.sun.org.apache.bcel.internal.Const.LDC2_W, index);
     }
 
-
-    @Override
-    public Type getType( final ConstantPoolGen cpg ) {
-        switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) {
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
-                return Type.LONG;
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
-                return Type.DOUBLE;
-            default: // Never reached
-                throw new IllegalArgumentException("Unknown constant type " + super.getOpcode());
-        }
-    }
-
-
-    public Number getValue( final ConstantPoolGen cpg ) {
-        final com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex());
-        switch (c.getTag()) {
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
-                return ((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes();
-            case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
-                return ((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes();
-            default: // Never reached
-                throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
-        }
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitPushInstruction(this);
         v.visitTypedInstruction(this);
         v.visitCPInstruction(this);
         v.visitLDC2_W(this);
     }
+
+    @Override
+    public Type getType(final ConstantPoolGen cpg) {
+        switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) {
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
+            return Type.LONG;
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
+            return Type.DOUBLE;
+        default: // Never reached
+            throw new IllegalArgumentException("Unknown constant type " + super.getOpcode());
+        }
+    }
+
+    public Number getValue(final ConstantPoolGen cpg) {
+        final com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex());
+        switch (c.getTag()) {
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
+            return Long.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes());
+        case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
+            return Double.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes());
+        default: // Never reached
+            throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
+        }
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC_W.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC_W.java
index c0c0ff7c9ac..07ea06e377c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC_W.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC_W.java
@@ -28,29 +28,27 @@
 /**
  * LDC_W - Push item from constant pool (wide index)
  *
- * <PRE>Stack: ... -&gt; ..., item.word1, item.word2</PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ..., item.word1, item.word2
+ * </PRE>
  */
 public class LDC_W extends LDC {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LDC_W() {
     }
 
-
     public LDC_W(final int index) {
         super(index);
     }
 
-
     /**
      * Read needed data (i.e., index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         setIndex(bytes.readUnsignedShort());
         // Override just in case it has been changed
         super.setOpcode(com.sun.org.apache.bcel.internal.Const.LDC_W);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDIV.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDIV.java
index 3d08e15a0b5..819e98dc1e7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDIV.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDIV.java
@@ -24,9 +24,12 @@
 
 /**
  * LDIV - Divide longs
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  * @LastModified: Jan 2020
  */
 public class LDIV extends ArithmeticInstruction implements ExceptionThrower {
@@ -35,25 +38,14 @@ public LDIV() {
         super(com.sun.org.apache.bcel.internal.Const.LDIV);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.ARITHMETIC_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
@@ -61,4 +53,9 @@ public void accept( final Visitor v ) {
         v.visitArithmeticInstruction(this);
         v.visitLDIV(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.ARITHMETIC_EXCEPTION};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LLOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LLOAD.java
index 75a3c753dba..7ae6dc5509d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LLOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LLOAD.java
@@ -23,35 +23,32 @@
 
 /**
  * LLOAD - Load long from local variable
- *<PRE>Stack ... -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack ... -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class LLOAD extends LoadInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LLOAD() {
         super(com.sun.org.apache.bcel.internal.Const.LLOAD, com.sun.org.apache.bcel.internal.Const.LLOAD_0);
     }
 
-
     public LLOAD(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.LLOAD, com.sun.org.apache.bcel.internal.Const.LLOAD_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitLLOAD(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LMUL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LMUL.java
index 9ea55ffbf2b..86972264fdd 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LMUL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LMUL.java
@@ -23,9 +23,12 @@
 
 /**
  * LMUL - Multiply longs
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class LMUL extends ArithmeticInstruction {
 
@@ -33,17 +36,14 @@ public LMUL() {
         super(com.sun.org.apache.bcel.internal.Const.LMUL);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LNEG.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LNEG.java
index 39c1c636663..69c0d3572dc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LNEG.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LNEG.java
@@ -23,8 +23,10 @@
 
 /**
  * LNEG - Negate long
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class LNEG extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public LNEG() {
         super(com.sun.org.apache.bcel.internal.Const.LNEG);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java
index 1803e565f36..b8e153ca276 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOOKUPSWITCH.java
@@ -34,75 +34,68 @@
 public class LOOKUPSWITCH extends Select {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LOOKUPSWITCH() {
     }
 
-
-    public LOOKUPSWITCH(final int[] match, final InstructionHandle[] targets,
-            final InstructionHandle defaultTarget) {
+    public LOOKUPSWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) {
         super(com.sun.org.apache.bcel.internal.Const.LOOKUPSWITCH, match, targets, defaultTarget);
         /* alignment remainder assumed 0 here, until dump time. */
-        final short _length = (short) (9 + getMatch_length() * 8);
-        super.setLength(_length);
-        setFixed_length(_length);
+        final short length = (short) (9 + getMatchLength() * 8);
+        super.setLength(length);
+        setFixedLength(length);
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitVariableLengthInstruction(this);
+        v.visitStackConsumer(this);
+        v.visitBranchInstruction(this);
+        v.visitSelect(this);
+        v.visitLOOKUPSWITCH(this);
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         super.dump(out);
-        final int _match_length = getMatch_length();
-        out.writeInt(_match_length); // npairs
-        for (int i = 0; i < _match_length; i++) {
+        final int matchLength = getMatchLength();
+        out.writeInt(matchLength); // npairs
+        for (int i = 0; i < matchLength; i++) {
             out.writeInt(super.getMatch(i)); // match-offset pairs
             out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i))));
         }
     }
 
-
     /**
      * Read needed data (e.g. index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         super.initFromFile(bytes, wide); // reads padding
-        final int _match_length = bytes.readInt();
-        setMatch_length(_match_length);
-        final short _fixed_length = (short) (9 + _match_length * 8);
-        setFixed_length(_fixed_length);
-        final short _length = (short) (_match_length + super.getPadding());
-        super.setLength(_length);
-        super.setMatches(new int[_match_length]);
-        super.setIndices(new int[_match_length]);
-        super.setTargets(new InstructionHandle[_match_length]);
-        for (int i = 0; i < _match_length; i++) {
+        final int matchLength = bytes.readInt();
+        setMatchLength(matchLength);
+        final short fixedLength = (short) (9 + matchLength * 8);
+        setFixedLength(fixedLength);
+        final short length = (short) (matchLength + super.getPadding());
+        super.setLength(length);
+        super.setMatches(new int[matchLength]);
+        super.setIndices(new int[matchLength]);
+        super.setTargets(new InstructionHandle[matchLength]);
+        for (int i = 0; i < matchLength; i++) {
             super.setMatch(i, bytes.readInt());
             super.setIndices(i, bytes.readInt());
         }
     }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitVariableLengthInstruction(this);
-        v.visitStackConsumer(this);
-        v.visitBranchInstruction(this);
-        v.visitSelect(this);
-        v.visitLOOKUPSWITCH(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOR.java
index ec1cef11bdc..53d4e9bc191 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LOR.java
@@ -23,8 +23,10 @@
 
 /**
  * LOR - Bitwise OR long
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class LOR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public LOR() {
         super(com.sun.org.apache.bcel.internal.Const.LOR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LREM.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LREM.java
index 786cb80ca96..17a535df2d3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LREM.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LREM.java
@@ -24,8 +24,10 @@
 
 /**
  * LREM - Remainder of long
- * <PRE>Stack: ..., value1, value2 -&gt; result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; result
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class LREM extends ArithmeticInstruction implements ExceptionThrower {
@@ -34,25 +36,14 @@ public LREM() {
         super(com.sun.org.apache.bcel.internal.Const.LREM);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.ARITHMETIC_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
@@ -60,4 +51,9 @@ public void accept( final Visitor v ) {
         v.visitArithmeticInstruction(this);
         v.visitLREM(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.ARITHMETIC_EXCEPTION};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LRETURN.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LRETURN.java
index 4523f77e2a9..9d40c14f863 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LRETURN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LRETURN.java
@@ -22,9 +22,11 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * LRETURN -  Return long from method
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; &lt;empty&gt;</PRE>
+ * LRETURN - Return long from method
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; &lt;empty&gt;
+ * </PRE>
  */
 public class LRETURN extends ReturnInstruction {
 
@@ -32,17 +34,14 @@ public LRETURN() {
         super(com.sun.org.apache.bcel.internal.Const.LRETURN);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHL.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHL.java
index 491f035e813..72c2aeed22d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHL.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHL.java
@@ -23,8 +23,10 @@
 
 /**
  * LSHL - Arithmetic shift left long
- * <PRE>Stack: ..., value1.word1, value1.word2, value2 -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2 -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class LSHL extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public LSHL() {
         super(com.sun.org.apache.bcel.internal.Const.LSHL);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHR.java
index c3e238d25f7..d7a51d3cffb 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSHR.java
@@ -23,8 +23,10 @@
 
 /**
  * LSHR - Arithmetic shift right long
- * <PRE>Stack: ..., value1.word1, value1.word2, value2 -&gt; ..., result.word1, result.word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2 -&gt; ..., result.word1, result.word2
+ * </PRE>
  */
 public class LSHR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public LSHR() {
         super(com.sun.org.apache.bcel.internal.Const.LSHR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSTORE.java
index 1bbdc2c52e2..0b49912dba3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSTORE.java
@@ -23,35 +23,32 @@
 
 /**
  * LSTORE - Store long into local variable
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ... </PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ...
+ * </PRE>
  */
 public class LSTORE extends StoreInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LSTORE() {
         super(com.sun.org.apache.bcel.internal.Const.LSTORE, com.sun.org.apache.bcel.internal.Const.LSTORE_0);
     }
 
-
     public LSTORE(final int n) {
         super(com.sun.org.apache.bcel.internal.Const.LSTORE, com.sun.org.apache.bcel.internal.Const.LSTORE_0, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         super.accept(v);
         v.visitLSTORE(this);
     }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSUB.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSUB.java
index b33771a6d10..8ffdf4fc5a3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSUB.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LSUB.java
@@ -23,9 +23,12 @@
 
 /**
  * LSUB - Substract longs
- * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;</PRE>
- *        ..., result.word1, result.word2
  *
+ * <PRE>
+ * Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -&gt;
+ * </PRE>
+ *
+ * ..., result.word1, result.word2
  */
 public class LSUB extends ArithmeticInstruction {
 
@@ -33,17 +36,14 @@ public LSUB() {
         super(com.sun.org.apache.bcel.internal.Const.LSUB);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LUSHR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LUSHR.java
index c7b7e472c1c..0d9d2eab53c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LUSHR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LUSHR.java
@@ -23,8 +23,10 @@
 
 /**
  * LUSHR - Logical shift right long
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class LUSHR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public LUSHR() {
         super(com.sun.org.apache.bcel.internal.Const.LUSHR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LXOR.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LXOR.java
index fc8dafcaaab..cf6ac48074a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LXOR.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LXOR.java
@@ -23,8 +23,10 @@
 
 /**
  * LXOR - Bitwise XOR long
- * <PRE>Stack: ..., value1, value2 -&gt; ..., result</PRE>
  *
+ * <PRE>
+ * Stack: ..., value1, value2 -&gt; ..., result
+ * </PRE>
  */
 public class LXOR extends ArithmeticInstruction {
 
@@ -32,17 +34,14 @@ public LXOR() {
         super(com.sun.org.apache.bcel.internal.Const.LXOR);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitTypedInstruction(this);
         v.visitStackProducer(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java
index b5ac6cda812..3773c21e7b3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LineNumberGen.java
@@ -26,14 +26,16 @@
 import com.sun.org.apache.bcel.internal.classfile.LineNumber;
 
 /**
- * This class represents a line number within a method, i.e., give an instruction
- * a line number corresponding to the source code line.
+ * This class represents a line number within a method, i.e., give an instruction a line number corresponding to the
+ * source code line.
  *
- * @see     LineNumber
- * @see     MethodGen
+ * @see LineNumber
+ * @see MethodGen
  */
 public class LineNumberGen implements InstructionTargeter, Cloneable {
 
+    static final LineNumberGen[] EMPTY_ARRAY = {};
+
     private InstructionHandle ih;
     private int srcLine;
 
@@ -42,73 +44,65 @@ public class LineNumberGen implements InstructionTargeter, Cloneable {
      *
      * @param ih instruction handle to reference
      */
-    public LineNumberGen(final InstructionHandle ih, final int src_line) {
+    public LineNumberGen(final InstructionHandle ih, final int srcLine) {
         setInstruction(ih);
-        setSourceLine(src_line);
+        setSourceLine(srcLine);
     }
 
+    @Override
+    public Object clone() {
+        try {
+            return super.clone();
+        } catch (final CloneNotSupportedException e) {
+            throw new Error("Clone Not Supported"); // never happens
+        }
+    }
 
     /**
      * @return true, if ih is target of this line number
      */
     @Override
-    public boolean containsTarget( final InstructionHandle ih ) {
+    public boolean containsTarget(final InstructionHandle ih) {
         return this.ih == ih;
     }
 
-
-    /**
-     * @param old_ih old target
-     * @param new_ih new target
-     */
-    @Override
-    public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) {
-        if (old_ih != ih) {
-            throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}");
-        }
-        setInstruction(new_ih);
+    public InstructionHandle getInstruction() {
+        return ih;
     }
 
-
     /**
-     * Get LineNumber attribute .
+     * Get LineNumber attribute.
      *
-     * This relies on that the instruction list has already been dumped to byte code or
-     * or that the `setPositions' methods has been called for the instruction list.
+     * This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods
+     * has been called for the instruction list.
      */
     public LineNumber getLineNumber() {
         return new LineNumber(ih.getPosition(), srcLine);
     }
 
+    public int getSourceLine() {
+        return srcLine;
+    }
 
-    public void setInstruction( final InstructionHandle instructionHandle ) { // TODO could be package-protected?
+    public void setInstruction(final InstructionHandle instructionHandle) { // TODO could be package-protected?
         Objects.requireNonNull(instructionHandle, "instructionHandle");
         BranchInstruction.notifyTarget(this.ih, instructionHandle, this);
         this.ih = instructionHandle;
     }
 
+    public void setSourceLine(final int srcLine) { // TODO could be package-protected?
+        this.srcLine = srcLine;
+    }
 
+    /**
+     * @param oldIh old target
+     * @param newIh new target
+     */
     @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (final CloneNotSupportedException e) {
-            throw new Error("Clone Not Supported"); // never happens
+    public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) {
+        if (oldIh != ih) {
+            throw new ClassGenException("Not targeting " + oldIh + ", but " + ih + "}");
         }
-    }
-
-
-    public InstructionHandle getInstruction() {
-        return ih;
-    }
-
-
-    public void setSourceLine( final int src_line ) { // TODO could be package-protected?
-        this.srcLine = src_line;
-    }
-
-
-    public int getSourceLine() {
-        return srcLine;
+        setInstruction(newIh);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadClass.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadClass.java
index cc697fe99cb..9fad1d1595d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadClass.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadClass.java
@@ -22,32 +22,27 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denotes that an instruction may start the process of loading and resolving
- * the referenced class in the Virtual Machine.
- *
+ * Denotes that an instruction may start the process of loading and resolving the referenced class in the Virtual Machine.
  */
 public interface LoadClass {
 
     /**
-     * Returns the ObjectType of the referenced class or interface
-     * that may be loaded and resolved.
-     * @return object type that may be loaded or null if a primitive is
-     * referenced
+     * Returns the {@link ObjectType} of the referenced class or interface that may be loaded and resolved.
+     *
+     * @param cpg A ConstantPoolGen
+     * @return object type that may be loaded or null if a primitive is referenced
      */
-    ObjectType getLoadClassType( ConstantPoolGen cpg );
-
+    ObjectType getLoadClassType(ConstantPoolGen cpg);
 
     /**
-     * Returns the type associated with this instruction.
-     * LoadClass instances are always typed, but this type
-     * does not always refer to the type of the class or interface
-     * that it possibly forces to load. For example, GETFIELD would
-     * return the type of the field and not the type of the class
-     * where the field is defined.
-     * If no class is forced to be loaded, <B>null</B> is returned.
-     * An example for this is an ANEWARRAY instruction that creates
-     * an int[][].
+     * Returns the type associated with this instruction. LoadClass instances are always typed, but this type does not always refer to the type of the class or
+     * interface that it possibly forces to load. For example, {@link GETFIELD} would return the type of the field and not the type of the class where the field
+     * is defined. If no class is forced to be loaded, {@code null} is returned. An example for this is an {@link NEWARRAY} instruction that creates an
+     * {@code int[][]}.
+     *
+     * @param cpg A ConstantPoolGen
+     * @return the type associated with this instruction.
      * @see #getLoadClassType(ConstantPoolGen)
      */
-    Type getType( ConstantPoolGen cpg );
+    Type getType(ConstantPoolGen cpg);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java
index 245fd08cc54..faaf9fad552 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LoadInstruction.java
@@ -22,42 +22,35 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denotes an unparameterized instruction to load a value from a local
- * variable, e.g. ILOAD.
- *
+ * Denotes an unparameterized instruction to load a value from a local variable, e.g. ILOAD.
  */
 public abstract class LoadInstruction extends LocalVariableInstruction implements PushInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
-     * tag and length are defined in readInstruction and initFromFile, respectively.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in
+     * readInstruction and initFromFile, respectively.
      */
-    LoadInstruction(final short canon_tag, final short c_tag) {
-        super(canon_tag, c_tag);
+    LoadInstruction(final short canonTag, final short cTag) {
+        super(canonTag, cTag);
     }
 
-
     /**
      * @param opcode Instruction opcode
-     * @param c_tag Instruction number for compact version, ALOAD_0, e.g.
+     * @param cTag Instruction number for compact version, ALOAD_0, e.g.
      * @param n local variable index (unsigned short)
      */
-    protected LoadInstruction(final short opcode, final short c_tag, final int n) {
-        super(opcode, c_tag, n);
+    protected LoadInstruction(final short opcode, final short cTag, final int n) {
+        super(opcode, cTag, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitPushInstruction(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java
index 4693af780e7..830564d42c9 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java
@@ -24,13 +24,11 @@
 import com.sun.org.apache.bcel.internal.classfile.LocalVariable;
 
 /**
- * Represents a local variable within a method. It contains its
- * scope, name and type. The generated LocalVariable object can be obtained
- * with getLocalVariable which needs the instruction list and the constant
- * pool as parameters.
+ * Represents a local variable within a method. It contains its scope, name and type. The generated LocalVariable object
+ * can be obtained with getLocalVariable which needs the instruction list and the constant pool as parameters.
  *
- * @see     LocalVariable
- * @see     MethodGen
+ * @see LocalVariable
+ * @see MethodGen
  */
 public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Cloneable {
 
@@ -42,10 +40,9 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo
     private int origIndex; // never changes; used to match up with LocalVariableTypeTable entries
     private boolean liveToEnd;
 
-
     /**
-     * Generate a local variable that with index `index'. Note that double and long
-     * variables need two indexs. Index indices have to be provided by the user.
+     * Generate a local variable that with index 'index'. Note that double and long variables need two indexs. Index indices
+     * have to be provided by the user.
      *
      * @param index index of local variable
      * @param name its name
@@ -53,10 +50,9 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo
      * @param start from where the instruction is valid (null means from the start)
      * @param end until where the instruction is valid (null means to the end)
      */
-    public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start,
-            final InstructionHandle end) {
-        if ((index < 0) || (index > Const.MAX_SHORT)) {
-            throw new ClassGenException("Invalid index index: " + index);
+    public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, final InstructionHandle end) {
+        if (index < 0 || index > Const.MAX_SHORT) {
+            throw new ClassGenException("Invalid index: " + index);
         }
         this.name = name;
         this.type = type;
@@ -67,10 +63,9 @@ public LocalVariableGen(final int index, final String name, final Type type, fin
         this.liveToEnd = end == null;
     }
 
-
     /**
-     * Generates a local variable that with index `index'. Note that double and long
-     * variables need two indexs. Index indices have to be provided by the user.
+     * Generates a local variable that with index 'index'. Note that double and long variables need two indexs. Index
+     * indices have to be provided by the user.
      *
      * @param index index of local variable
      * @param name its name
@@ -79,187 +74,163 @@ public LocalVariableGen(final int index, final String name, final Type type, fin
      * @param end until where the instruction is valid (null means to the end)
      * @param origIndex index of local variable prior to any changes to index
      */
-    public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start,
-            final InstructionHandle end, final int origIndex) {
+    public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, final InstructionHandle end,
+        final int origIndex) {
         this(index, name, type, start, end);
         this.origIndex = origIndex;
     }
 
+    @Override
+    public Object clone() {
+        try {
+            return super.clone();
+        } catch (final CloneNotSupportedException e) {
+            throw new Error("Clone Not Supported"); // never happens
+        }
+    }
 
     /**
-     * Gets LocalVariable object.
-     *
-     * This relies on that the instruction list has already been dumped to byte code or
-     * or that the `setPositions' methods has been called for the instruction list.
-     *
-     * Note that due to the conversion from byte code offset to InstructionHandle,
-     * it is impossible to tell the difference between a live range that ends BEFORE
-     * the last insturction of the method or a live range that ends AFTER the last
-     * instruction of the method.  Hence the liveToEnd flag to differentiate
-     * between these two cases.
-     *
-     * @param cp constant pool
+     * @return true, if ih is target of this variable
      */
-    public LocalVariable getLocalVariable( final ConstantPoolGen cp ) {
-        int start_pc = 0;
-        int length = 0;
-        if ((start != null) && (end != null)) {
-            start_pc = start.getPosition();
-            length = end.getPosition() - start_pc;
-            if ((end.getNext() == null) && liveToEnd) {
-                length += end.getInstruction().getLength();
-            }
-        }
-        final int name_index = cp.addUtf8(name);
-        final int signature_index = cp.addUtf8(type.getSignature());
-        return new LocalVariable(start_pc, length, name_index, signature_index, index, cp
-                .getConstantPool(), origIndex);
+    @Override
+    public boolean containsTarget(final InstructionHandle ih) {
+        return start == ih || end == ih;
     }
 
-
-    public void setIndex( final int index ) {
-        this.index = index;
+    /**
+     * Clear the references from and to this variable when it's removed.
+     */
+    void dispose() {
+        setStart(null);
+        setEnd(null);
     }
 
-
-    public int getIndex() {
-        return index;
+    /**
+     * We consider to local variables to be equal, if the use the same index and are valid in the same range.
+     */
+    @Override
+    public boolean equals(final Object o) {
+        if (!(o instanceof LocalVariableGen)) {
+            return false;
+        }
+        final LocalVariableGen l = (LocalVariableGen) o;
+        return l.index == index && l.start == start && l.end == end;
     }
 
-
-    public int getOrigIndex() {
-        return origIndex;
+    public InstructionHandle getEnd() {
+        return end;
     }
 
-
-    public void setLiveToEnd( final boolean live_to_end) {
-        this.liveToEnd = live_to_end;
+    public int getIndex() {
+        return index;
     }
 
-
     public boolean getLiveToEnd() {
         return liveToEnd;
     }
 
-
-    @Override
-    public void setName( final String name ) {
-        this.name = name;
+    /**
+     * Gets LocalVariable object.
+     *
+     * This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods
+     * has been called for the instruction list.
+     *
+     * Note that due to the conversion from byte code offset to InstructionHandle, it is impossible to tell the difference
+     * between a live range that ends BEFORE the last insturction of the method or a live range that ends AFTER the last
+     * instruction of the method. Hence the liveToEnd flag to differentiate between these two cases.
+     *
+     * @param cp constant pool
+     */
+    public LocalVariable getLocalVariable(final ConstantPoolGen cp) {
+        int startPc = 0;
+        int length = 0;
+        if (start != null && end != null) {
+            startPc = start.getPosition();
+            length = end.getPosition() - startPc;
+            if (end.getNext() == null && liveToEnd) {
+                length += end.getInstruction().getLength();
+            }
+        }
+        final int nameIndex = cp.addUtf8(name);
+        final int signatureIndex = cp.addUtf8(type.getSignature());
+        return new LocalVariable(startPc, length, nameIndex, signatureIndex, index, cp.getConstantPool(), origIndex);
     }
 
-
     @Override
     public String getName() {
         return name;
     }
 
-
-    @Override
-    public void setType( final Type type ) {
-        this.type = type;
-    }
-
-
-    @Override
-    public Type getType() {
-        return type;
+    public int getOrigIndex() {
+        return origIndex;
     }
 
-
     public InstructionHandle getStart() {
         return start;
     }
 
-
-    public InstructionHandle getEnd() {
-        return end;
+    @Override
+    public Type getType() {
+        return type;
     }
 
-
-    public void setStart( final InstructionHandle start ) { // TODO could be package-protected?
-        BranchInstruction.notifyTarget(this.start, start, this);
-        this.start = start;
+    @Override
+    public int hashCode() {
+        // If the user changes the name or type, problems with the targeter hashmap will occur.
+        // Note: index cannot be part of hash as it may be changed by the user.
+        return name.hashCode() ^ type.hashCode();
     }
 
-
-    public void setEnd( final InstructionHandle end ) { // TODO could be package-protected?
+    public void setEnd(final InstructionHandle end) { // TODO could be package-protected?
         BranchInstruction.notifyTarget(this.end, end, this);
         this.end = end;
     }
 
-
-    /**
-     * @param old_ih old target, either start or end
-     * @param new_ih new target
-     */
-    @Override
-    public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) {
-        boolean targeted = false;
-        if (start == old_ih) {
-            targeted = true;
-            setStart(new_ih);
-        }
-        if (end == old_ih) {
-            targeted = true;
-            setEnd(new_ih);
-        }
-        if (!targeted) {
-            throw new ClassGenException("Not targeting " + old_ih + ", but {" + start + ", " + end
-                    + "}");
-        }
+    public void setIndex(final int index) {
+        this.index = index;
     }
 
-    /**
-     * Clear the references from and to this variable when it's removed.
-     */
-    void dispose() {
-        setStart(null);
-        setEnd(null);
+    public void setLiveToEnd(final boolean liveToEnd) {
+        this.liveToEnd = liveToEnd;
     }
 
-    /**
-     * @return true, if ih is target of this variable
-     */
     @Override
-    public boolean containsTarget( final InstructionHandle ih ) {
-        return (start == ih) || (end == ih);
+    public void setName(final String name) {
+        this.name = name;
     }
 
-
-    @Override
-    public int hashCode() {
-        // If the user changes the name or type, problems with the targeter hashmap will occur.
-        // Note: index cannot be part of hash as it may be changed by the user.
-        return name.hashCode() ^ type.hashCode();
+    public void setStart(final InstructionHandle start) { // TODO could be package-protected?
+        BranchInstruction.notifyTarget(this.start, start, this);
+        this.start = start;
     }
 
-
-    /**
-     * We consider to local variables to be equal, if the use the same index and
-     * are valid in the same range.
-     */
     @Override
-    public boolean equals( final Object o ) {
-        if (!(o instanceof LocalVariableGen)) {
-            return false;
-        }
-        final LocalVariableGen l = (LocalVariableGen) o;
-        return (l.index == index) && (l.start == start) && (l.end == end);
+    public void setType(final Type type) {
+        this.type = type;
     }
 
-
     @Override
     public String toString() {
         return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")";
     }
 
-
+    /**
+     * @param oldIh old target, either start or end
+     * @param newIh new target
+     */
     @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (final CloneNotSupportedException e) {
-            throw new Error("Clone Not Supported"); // never happens
+    public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) {
+        boolean targeted = false;
+        if (start == oldIh) {
+            targeted = true;
+            setStart(newIh);
+        }
+        if (end == oldIh) {
+            targeted = true;
+            setEnd(newIh);
+        }
+        if (!targeted) {
+            throw new ClassGenException("Not targeting " + oldIh + ", but {" + start + ", " + end + "}");
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java
index fb4d7545478..67184c0b9f1 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LocalVariableInstruction.java
@@ -30,39 +30,32 @@
  *
  * @LastModified: May 2021
  */
-public abstract class LocalVariableInstruction extends Instruction implements TypedInstruction,
-        IndexedInstruction {
+public abstract class LocalVariableInstruction extends Instruction implements TypedInstruction, IndexedInstruction {
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int n = -1; // index of referenced variable
 
-    private int n = -1; // index of referenced variable
     private short cTag = -1; // compact version, such as ILOAD_0
     private short canonTag = -1; // canonical tag such as ILOAD
 
-
-    private boolean wide() {
-        return n > Const.MAX_BYTE;
-    }
-
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
-     * tag and length are defined in readInstruction and initFromFile, respectively.
+     * Empty constructor needed for Instruction.readInstruction. Also used by IINC()!
      */
-    LocalVariableInstruction(final short canon_tag, final short c_tag) {
-        super();
-        this.canonTag = canon_tag;
-        this.cTag = c_tag;
+    LocalVariableInstruction() {
     }
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Also used by IINC()!
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in
+     * readInstruction and initFromFile, respectively.
      */
-    LocalVariableInstruction() {
+    LocalVariableInstruction(final short canonTag, final short cTag) {
+        this.canonTag = canonTag;
+        this.cTag = cTag;
     }
 
-
     /**
      * @param opcode Instruction opcode
      * @param cTag Instruction number for compact version, ALOAD_0, e.g.
@@ -75,13 +68,13 @@ protected LocalVariableInstruction(final short opcode, final short cTag, final i
         setIndex(n);
     }
 
-
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         if (wide()) {
             out.writeByte(Const.WIDE);
         }
@@ -95,73 +88,87 @@ public void dump( final DataOutputStream out ) throws IOException {
         }
     }
 
+    /**
+     * @return canonical tag for instruction, e.g., ALOAD for ALOAD_0
+     */
+    public short getCanonicalTag() {
+        return canonTag;
+    }
 
     /**
-     * Long output format:
-     *
-     * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]"
-     * "("&lt;length of instruction&gt;")" "&lt;"&lt; local variable index&gt;"&gt;"
+     * @return local variable index (n) referred by this instruction.
+     */
+    @Override
+    public final int getIndex() {
+        return n;
+    }
+
+    /**
+     * Returns the type associated with the instruction - in case of ALOAD or ASTORE Type.OBJECT is returned. This is just a
+     * bit incorrect, because ALOAD and ASTORE may work on every ReferenceType (including Type.NULL) and ASTORE may even
+     * work on a ReturnaddressType .
      *
-     * @param verbose long/short format switch
-     * @return mnemonic for instruction
+     * @return type associated with the instruction
      */
     @Override
-    public String toString( final boolean verbose ) {
-        final short _opcode = super.getOpcode();
-        if (((_opcode >= Const.ILOAD_0) && (_opcode <= Const.ALOAD_3))
-         || ((_opcode >= Const.ISTORE_0) && (_opcode <= Const.ASTORE_3))) {
-            return super.toString(verbose);
+    public Type getType(final ConstantPoolGen cp) {
+        switch (canonTag) {
+        case Const.ILOAD:
+        case Const.ISTORE:
+            return Type.INT;
+        case Const.LLOAD:
+        case Const.LSTORE:
+            return Type.LONG;
+        case Const.DLOAD:
+        case Const.DSTORE:
+            return Type.DOUBLE;
+        case Const.FLOAD:
+        case Const.FSTORE:
+            return Type.FLOAT;
+        case Const.ALOAD:
+        case Const.ASTORE:
+            return Type.OBJECT;
+        default:
+            throw new ClassGenException("Unknown case in switch" + canonTag);
         }
-        return super.toString(verbose) + " " + n;
     }
 
-
     /**
      * Read needed data (e.g. index) from file.
+     *
      * <pre>
      * (ILOAD &lt;= tag &lt;= ALOAD_3) || (ISTORE &lt;= tag &lt;= ASTORE_3)
      * </pre>
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         if (wide) {
             n = bytes.readUnsignedShort();
             super.setLength(4);
         } else {
-            final short _opcode = super.getOpcode();
-            if (((_opcode >= Const.ILOAD) && (_opcode <= Const.ALOAD))
-             || ((_opcode >= Const.ISTORE) && (_opcode <= Const.ASTORE))) {
+            final short opcode = super.getOpcode();
+            if (opcode >= Const.ILOAD && opcode <= Const.ALOAD || opcode >= Const.ISTORE && opcode <= Const.ASTORE) {
                 n = bytes.readUnsignedByte();
                 super.setLength(2);
-            } else if (_opcode <= Const.ALOAD_3) { // compact load instruction such as ILOAD_2
-                n = (_opcode - Const.ILOAD_0) % 4;
-                super.setLength(1);
-            } else { // Assert ISTORE_0 <= tag <= ASTORE_3
-                n = (_opcode - Const.ISTORE_0) % 4;
+            } else {
+                if (opcode <= Const.ALOAD_3) { // compact load instruction such as ILOAD_2
+                    n = (opcode - Const.ILOAD_0) % 4;
+                } else { // Assert ISTORE_0 <= tag <= ASTORE_3
+                    n = (opcode - Const.ISTORE_0) % 4;
+                }
                 super.setLength(1);
             }
         }
     }
 
-
-    /**
-     * @return local variable index (n) referred by this instruction.
-     */
-    @Override
-    public final int getIndex() {
-        return n;
-    }
-
-
     /**
-     * Set the local variable index.
-     * also updates opcode and length
-     * TODO Why?
+     * Set the local variable index. also updates opcode and length TODO Why?
+     *
      * @see #setIndexOnly(int)
      */
     @Override
-    public void setIndex( final int n ) { // TODO could be package-protected?
-        if ((n < 0) || (n > Const.MAX_SHORT)) {
+    public void setIndex(final int n) { // TODO could be package-protected?
+        if (n < 0 || n > Const.MAX_SHORT) {
             throw new ClassGenException("Illegal value: " + n);
         }
         this.n = n;
@@ -179,51 +186,35 @@ public void setIndex( final int n ) { // TODO could be package-protected?
         }
     }
 
-
-    /** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0
+    /**
+     * Sets the index of the referenced variable (n) only
+     *
+     * @since 6.0
+     * @see #setIndex(int)
      */
-    public short getCanonicalTag() {
-        return canonTag;
+    final void setIndexOnly(final int n) {
+        this.n = n;
     }
 
-
     /**
-     * Returns the type associated with the instruction -
-     * in case of ALOAD or ASTORE Type.OBJECT is returned.
-     * This is just a bit incorrect, because ALOAD and ASTORE
-     * may work on every ReferenceType (including Type.NULL) and
-     * ASTORE may even work on a ReturnaddressType .
-     * @return type associated with the instruction
+     * Long output format:
+     *
+     * &lt;name of opcode&gt; "["&lt;opcode number&gt;"]" "("&lt;length of instruction&gt;")" "&lt;"&lt; local variable
+     * index&gt;"&gt;"
+     *
+     * @param verbose long/short format switch
+     * @return mnemonic for instruction
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        switch (canonTag) {
-            case Const.ILOAD:
-            case Const.ISTORE:
-                return Type.INT;
-            case Const.LLOAD:
-            case Const.LSTORE:
-                return Type.LONG;
-            case Const.DLOAD:
-            case Const.DSTORE:
-                return Type.DOUBLE;
-            case Const.FLOAD:
-            case Const.FSTORE:
-                return Type.FLOAT;
-            case Const.ALOAD:
-            case Const.ASTORE:
-                return Type.OBJECT;
-            default:
-                throw new ClassGenException("Unknown case in switch" + canonTag);
+    public String toString(final boolean verbose) {
+        final short opcode = super.getOpcode();
+        if (opcode >= Const.ILOAD_0 && opcode <= Const.ALOAD_3 || opcode >= Const.ISTORE_0 && opcode <= Const.ASTORE_3) {
+            return super.toString(verbose);
         }
+        return super.toString(verbose) + " " + n;
     }
 
-    /**
-     * Sets the index of the referenced variable (n) only
-     * @since 6.0
-     * @see #setIndex(int)
-     */
-    final void setIndexOnly(final int n) {
-        this.n = n;
+    private boolean wide() {
+        return n > Const.MAX_BYTE;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java
index a8cb953051f..6ea4f918589 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITORENTER.java
@@ -24,8 +24,10 @@
 
 /**
  * MONITORENTER - Enter monitor for object
- * <PRE>Stack: ..., objectref -&gt; ...</PRE>
  *
+ * <PRE>
+ * Stack: ..., objectref -&gt; ...
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class MONITORENTER extends Instruction implements ExceptionThrower, StackConsumer {
@@ -34,27 +36,21 @@ public MONITORENTER() {
         super(com.sun.org.apache.bcel.internal.Const.MONITORENTER, (short) 1);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.NULL_POINTER_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitStackConsumer(this);
         v.visitMONITORENTER(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.NULL_POINTER_EXCEPTION};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java
index 9c83d55577b..40daeb13ba6 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MONITOREXIT.java
@@ -24,8 +24,10 @@
 
 /**
  * MONITOREXIT - Exit monitor for object
- * <PRE>Stack: ..., objectref -&gt; ...</PRE>
  *
+ * <PRE>
+ * Stack: ..., objectref -&gt; ...
+ * </PRE>
  * @LastModified: Jan 2020
  */
 public class MONITOREXIT extends Instruction implements ExceptionThrower, StackConsumer {
@@ -34,27 +36,21 @@ public MONITOREXIT() {
         super(com.sun.org.apache.bcel.internal.Const.MONITOREXIT, (short) 1);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.NULL_POINTER_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitStackConsumer(this);
         v.visitMONITOREXIT(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.NULL_POINTER_EXCEPTION};
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java
index 208410b3c98..9f83842d2ad 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MULTIANEWARRAY.java
@@ -30,23 +30,21 @@
 
 /**
  * MULTIANEWARRAY - Create new mutidimensional array of references
- * <PRE>Stack: ..., count1, [count2, ...] -&gt; ..., arrayref</PRE>
  *
+ * <PRE>
+ * Stack: ..., count1, [count2, ...] -&gt; ..., arrayref
+ * </PRE>
  */
-public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction,
-        ExceptionThrower {
+public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower {
 
     private short dimensions;
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     MULTIANEWARRAY() {
     }
 
-
     public MULTIANEWARRAY(final int index, final short dimensions) {
         super(com.sun.org.apache.bcel.internal.Const.MULTIANEWARRAY, index);
         if (dimensions < 1) {
@@ -56,100 +54,89 @@ public MULTIANEWARRAY(final int index, final short dimensions) {
         super.setLength(4);
     }
 
-
     /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        out.writeByte(super.getOpcode());
-        out.writeShort(super.getIndex());
-        out.writeByte(dimensions);
+    public void accept(final Visitor v) {
+        v.visitLoadClass(this);
+        v.visitAllocationInstruction(this);
+        v.visitExceptionThrower(this);
+        v.visitTypedInstruction(this);
+        v.visitCPInstruction(this);
+        v.visitMULTIANEWARRAY(this);
     }
 
-
     /**
-     * Read needed data (i.e., no. dimension) from file.
+     * Also works for instructions whose stack effect depends on the constant pool entry they reference.
+     *
+     * @return Number of words consumed from stack by this instruction
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
-        super.initFromFile(bytes, wide);
-        dimensions = bytes.readByte();
-        super.setLength(4);
-    }
-
-
-    /**
-     * @return number of dimensions to be created
-     */
-    public final short getDimensions() {
+    public int consumeStack(final ConstantPoolGen cpg) {
         return dimensions;
     }
 
-
-    /**
-     * @return mnemonic for instruction
-     */
-    @Override
-    public String toString( final boolean verbose ) {
-        return super.toString(verbose) + " " + super.getIndex() + " " + dimensions;
-    }
-
-
     /**
-     * @return mnemonic for instruction with symbolic references resolved
+     * Dump instruction as byte code to stream out.
+     *
+     * @param out Output stream
      */
     @Override
-    public String toString( final ConstantPool cp ) {
-        return super.toString(cp) + " " + dimensions;
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(super.getOpcode());
+        out.writeShort(super.getIndex());
+        out.writeByte(dimensions);
     }
 
-
     /**
-     * Also works for instructions whose stack effect depends on the
-     * constant pool entry they reference.
-     * @return Number of words consumed from stack by this instruction
+     * @return number of dimensions to be created
      */
-    @Override
-    public int consumeStack( final ConstantPoolGen cpg ) {
+    public final short getDimensions() {
         return dimensions;
     }
 
-
     @Override
     public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION,
-            ExceptionConst.ILLEGAL_ACCESS_ERROR,
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.ILLEGAL_ACCESS_ERROR,
             ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION);
     }
 
-
     @Override
-    public ObjectType getLoadClassType( final ConstantPoolGen cpg ) {
+    public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
         Type t = getType(cpg);
         if (t instanceof ArrayType) {
             t = ((ArrayType) t).getBasicType();
         }
-        return (t instanceof ObjectType) ? (ObjectType) t : null;
+        return t instanceof ObjectType ? (ObjectType) t : null;
     }
 
+    /**
+     * Read needed data (i.e., no. dimension) from file.
+     */
+    @Override
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+        super.initFromFile(bytes, wide);
+        dimensions = bytes.readByte();
+        super.setLength(4);
+    }
 
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
+     * @return mnemonic for instruction
      */
     @Override
-    public void accept( final Visitor v ) {
-        v.visitLoadClass(this);
-        v.visitAllocationInstruction(this);
-        v.visitExceptionThrower(this);
-        v.visitTypedInstruction(this);
-        v.visitCPInstruction(this);
-        v.visitMULTIANEWARRAY(this);
+    public String toString(final boolean verbose) {
+        return super.toString(verbose) + " " + super.getIndex() + " " + dimensions;
+    }
+
+    /**
+     * @return mnemonic for instruction with symbolic references resolved
+     */
+    @Override
+    public String toString(final ConstantPool cp) {
+        return super.toString(cp) + " " + dimensions;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java
index f787b44b08d..f6e8333be79 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,6 +19,15 @@
  */
 package com.sun.org.apache.bcel.internal.generic;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Objects;
+import java.util.Stack;
+
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.classfile.AnnotationEntry;
 import com.sun.org.apache.bcel.internal.classfile.Annotations;
@@ -37,96 +46,223 @@
 import com.sun.org.apache.bcel.internal.classfile.RuntimeVisibleParameterAnnotations;
 import com.sun.org.apache.bcel.internal.classfile.Utility;
 import com.sun.org.apache.bcel.internal.util.BCELComparator;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Stack;
 
 /**
- * Template class for building up a method. This is done by defining exception
- * handlers, adding thrown exceptions, local variables and attributes, whereas
- * the `LocalVariableTable' and `LineNumberTable' attributes will be set
- * automatically for the code. Use stripAttributes() if you don't like this.
+ * Template class for building up a method. This is done by defining exception handlers, adding thrown exceptions, local
+ * variables and attributes, whereas the 'LocalVariableTable' and 'LineNumberTable' attributes will be set automatically
+ * for the code. Use stripAttributes() if you don't like this.
  *
- * While generating code it may be necessary to insert NOP operations. You can
- * use the `removeNOPs' method to get rid off them.
- * The resulting method object can be obtained via the `getMethod()' method.
+ * While generating code it may be necessary to insert NOP operations. You can use the 'removeNOPs' method to get rid
+ * off them. The resulting method object can be obtained via the 'getMethod()' method.
  *
- * @see     InstructionList
- * @see     Method
- * @LastModified: May 2021
+ * @see InstructionList
+ * @see Method
+ * @LastModified: Feb 2023
  */
 public class MethodGen extends FieldGenOrMethodGen {
 
+    static final class BranchStack {
+
+        private final Stack<BranchTarget> branchTargets = new Stack<>();
+        private final HashMap<InstructionHandle, BranchTarget> visitedTargets = new HashMap<>();
+
+        public BranchTarget pop() {
+            if (!branchTargets.empty()) {
+                return branchTargets.pop();
+            }
+            return null;
+        }
+
+        public void push(final InstructionHandle target, final int stackDepth) {
+            if (visited(target)) {
+                return;
+            }
+            branchTargets.push(visit(target, stackDepth));
+        }
+
+        private BranchTarget visit(final InstructionHandle target, final int stackDepth) {
+            final BranchTarget bt = new BranchTarget(target, stackDepth);
+            visitedTargets.put(target, bt);
+            return bt;
+        }
+
+        private boolean visited(final InstructionHandle target) {
+            return visitedTargets.get(target) != null;
+        }
+    }
+
+    static final class BranchTarget {
+
+        final InstructionHandle target;
+        final int stackDepth;
+
+        BranchTarget(final InstructionHandle target, final int stackDepth) {
+            this.target = target;
+            this.stackDepth = stackDepth;
+        }
+    }
+
+    private static BCELComparator bcelComparator = new BCELComparator() {
+
+        @Override
+        public boolean equals(final Object o1, final Object o2) {
+            final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o1;
+            final FieldGenOrMethodGen THAT = (FieldGenOrMethodGen) o2;
+            return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
+        }
+
+        @Override
+        public int hashCode(final Object o) {
+            final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o;
+            return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
+        }
+    };
+
+    private static byte[] getByteCodes(final Method method) {
+        final Code code = method.getCode();
+        if (code == null) {
+            throw new IllegalStateException(String.format("The method '%s' has no code.", method));
+        }
+        return code.getCode();
+    }
+
+    /**
+     * @return Comparison strategy object
+     */
+    public static BCELComparator getComparator() {
+        return bcelComparator;
+    }
+
+    /**
+     * Computes stack usage of an instruction list by performing control flow analysis.
+     *
+     * @return maximum stack depth used by method
+     */
+    public static int getMaxStack(final ConstantPoolGen cp, final InstructionList il, final CodeExceptionGen[] et) {
+        final BranchStack branchTargets = new BranchStack();
+        /*
+         * Initially, populate the branch stack with the exception handlers, because these aren't (necessarily) branched to
+         * explicitly. in each case, the stack will have depth 1, containing the exception object.
+         */
+        for (final CodeExceptionGen element : et) {
+            final InstructionHandle handlerPc = element.getHandlerPC();
+            if (handlerPc != null) {
+                branchTargets.push(handlerPc, 1);
+            }
+        }
+        int stackDepth = 0;
+        int maxStackDepth = 0;
+        InstructionHandle ih = il.getStart();
+        while (ih != null) {
+            final Instruction instruction = ih.getInstruction();
+            final short opcode = instruction.getOpcode();
+            final int delta = instruction.produceStack(cp) - instruction.consumeStack(cp);
+            stackDepth += delta;
+            if (stackDepth > maxStackDepth) {
+                maxStackDepth = stackDepth;
+            }
+            // choose the next instruction based on whether current is a branch.
+            if (instruction instanceof BranchInstruction) {
+                final BranchInstruction branch = (BranchInstruction) instruction;
+                if (instruction instanceof Select) {
+                    // explore all of the select's targets. the default target is handled below.
+                    final Select select = (Select) branch;
+                    final InstructionHandle[] targets = select.getTargets();
+                    for (final InstructionHandle target : targets) {
+                        branchTargets.push(target, stackDepth);
+                    }
+                    // nothing to fall through to.
+                    ih = null;
+                } else if (!(branch instanceof IfInstruction)) {
+                    // if an instruction that comes back to following PC,
+                    // push next instruction, with stack depth reduced by 1.
+                    if (opcode == Const.JSR || opcode == Const.JSR_W) {
+                        branchTargets.push(ih.getNext(), stackDepth - 1);
+                    }
+                    ih = null;
+                }
+                // for all branches, the target of the branch is pushed on the branch stack.
+                // conditional branches have a fall through case, selects don't, and
+                // jsr/jsr_w return to the next instruction.
+                branchTargets.push(branch.getTarget(), stackDepth);
+            } else // check for instructions that terminate the method.
+            if (opcode == Const.ATHROW || opcode == Const.RET || opcode >= Const.IRETURN && opcode <= Const.RETURN) {
+                ih = null;
+            }
+            // normal case, go to the next instruction.
+            if (ih != null) {
+                ih = ih.getNext();
+            }
+            // if we have no more instructions, see if there are any deferred branches to explore.
+            if (ih == null) {
+                final BranchTarget bt = branchTargets.pop();
+                if (bt != null) {
+                    ih = bt.target;
+                    stackDepth = bt.stackDepth;
+                }
+            }
+        }
+        return maxStackDepth;
+    }
+
+    /**
+     * @param comparator Comparison strategy object
+     */
+    public static void setComparator(final BCELComparator comparator) {
+        bcelComparator = comparator;
+    }
+
     private String className;
     private Type[] argTypes;
     private String[] argNames;
     private int maxLocals;
     private int maxStack;
     private InstructionList il;
+
     private boolean stripAttributes;
-    private LocalVariableTypeTable localVariableTypeTable = null;
+    private LocalVariableTypeTable localVariableTypeTable;
     private final List<LocalVariableGen> variableList = new ArrayList<>();
+
     private final List<LineNumberGen> lineNumberList = new ArrayList<>();
+
     private final List<CodeExceptionGen> exceptionList = new ArrayList<>();
+
     private final List<String> throwsList = new ArrayList<>();
+
     private final List<Attribute> codeAttrsList = new ArrayList<>();
 
     private List<AnnotationEntryGen>[] paramAnnotations; // Array of lists containing AnnotationGen objects
-    private boolean hasParameterAnnotations = false;
-    private boolean haveUnpackedParameterAnnotations = false;
-
-    private static BCELComparator bcelComparator = new BCELComparator() {
-
-        @Override
-        public boolean equals( final Object o1, final Object o2 ) {
-            final MethodGen THIS = (MethodGen) o1;
-            final MethodGen THAT = (MethodGen) o2;
-            return Objects.equals(THIS.getName(), THAT.getName())
-                    && Objects.equals(THIS.getSignature(), THAT.getSignature());
-        }
 
+    private boolean hasParameterAnnotations;
 
-        @Override
-        public int hashCode( final Object o ) {
-            final MethodGen THIS = (MethodGen) o;
-            return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
-        }
-    };
+    private boolean haveUnpackedParameterAnnotations;
 
+    private List<MethodObserver> observers;
 
     /**
-     * Declare method. If the method is non-static the constructor
-     * automatically declares a local variable `$this' in slot 0. The
-     * actual code is contained in the `il' parameter, which may further
-     * manipulated by the user. But he must take care not to remove any
-     * instruction (handles) that are still referenced from this object.
+     * Declare method. If the method is non-static the constructor automatically declares a local variable '$this' in slot
+     * 0. The actual code is contained in the 'il' parameter, which may further manipulated by the user. But they must take
+     * care not to remove any instruction (handles) that are still referenced from this object.
      *
-     * For example one may not add a local variable and later remove the
-     * instructions it refers to without causing havoc. It is safe
-     * however if you remove that local variable, too.
+     * For example one may not add a local variable and later remove the instructions it refers to without causing havoc. It
+     * is safe however if you remove that local variable, too.
      *
-     * @param access_flags access qualifiers
-     * @param return_type  method type
+     * @param accessFlags access qualifiers
+     * @param returnType method type
      * @param argTypes argument types
-     * @param argNames argument names (if this is null, default names will be provided
-     * for them)
-     * @param method_name name of method
+     * @param argNames argument names (if this is null, default names will be provided for them)
+     * @param methodName name of method
      * @param className class name containing this method (may be null, if you don't care)
-     * @param il instruction list associated with this method, may be null only for
-     * abstract or native methods
+     * @param il instruction list associated with this method, may be null only for abstract or native methods
      * @param cp constant pool
      */
-    public MethodGen(final int access_flags, final Type return_type, final Type[] argTypes, String[] argNames,
-            final String method_name, final String className, final InstructionList il, final ConstantPoolGen cp) {
-        super(access_flags);
-        setType(return_type);
+    public MethodGen(final int accessFlags, final Type returnType, final Type[] argTypes, String[] argNames, final String methodName, final String className,
+        final InstructionList il, final ConstantPoolGen cp) {
+        super(accessFlags);
+        setType(returnType);
         setArgumentTypes(argTypes);
         setArgumentNames(argNames);
-        setName(method_name);
+        setName(methodName);
         setClassName(className);
         setInstructionList(il);
         setConstantPool(cp);
@@ -136,23 +272,23 @@ public MethodGen(final int access_flags, final Type return_type, final Type[] ar
         if (!abstract_) {
             start = il.getStart();
             // end == null => live to end of method
-            /* Add local variables, namely the implicit `this' and the arguments
+            /*
+             * Add local variables, namely the implicit 'this' and the arguments
              */
-            if (!isStatic() && (className != null)) { // Instance method -> `this' is local var 0
-                addLocalVariable("this",  ObjectType.getInstance(className), start, end);
+            if (!isStatic() && className != null) { // Instance method -> 'this' is local var 0
+                addLocalVariable("this", ObjectType.getInstance(className), start, end);
             }
         }
         if (argTypes != null) {
             final int size = argTypes.length;
-            for (final Type arg_type : argTypes) {
-                if (Type.VOID == arg_type) {
+            for (final Type argType : argTypes) {
+                if (Type.VOID == argType) {
                     throw new ClassGenException("'void' is an illegal argument type for a method");
                 }
             }
             if (argNames != null) { // Names for variables provided?
                 if (size != argNames.length) {
-                    throw new ClassGenException("Mismatch in argument array lengths: " + size
-                            + " vs. " + argNames.length);
+                    throw new ClassGenException("Mismatch in argument array lengths: " + size + " vs. " + argNames.length);
                 }
             } else { // Give them dummy names
                 argNames = new String[size];
@@ -169,7 +305,6 @@ public MethodGen(final int access_flags, final Type return_type, final Type[] ar
         }
     }
 
-
     /**
      * Instantiate from existing method.
      *
@@ -178,13 +313,10 @@ public MethodGen(final int access_flags, final Type return_type, final Type[] ar
      * @param cp constant pool
      */
     public MethodGen(final Method method, final String className, final ConstantPoolGen cp) {
-        this(method.getAccessFlags(), Type.getReturnType(method.getSignature()),
-            Type.getArgumentTypes(method.getSignature()), null /* may be overridden anyway */
+        this(method.getAccessFlags(), Type.getReturnType(method.getSignature()), Type.getArgumentTypes(method.getSignature()),
+            null /* may be overridden anyway */
             , method.getName(), className,
-            ((method.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0)
-                ? new InstructionList(getByteCodes(method))
-                : null,
-            cp);
+            (method.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0 ? new InstructionList(getByteCodes(method)) : null, cp);
         final Attribute[] attributes = method.getAttributes();
         for (final Attribute attribute : attributes) {
             Attribute a = attribute;
@@ -196,36 +328,33 @@ public MethodGen(final Method method, final String className, final ConstantPool
                 if (ces != null) {
                     for (final CodeException ce : ces) {
                         final int type = ce.getCatchType();
-                        ObjectType c_type = null;
+                        ObjectType cType = null;
                         if (type > 0) {
-                            final String cen = method.getConstantPool().getConstantString(type,
-                                    Const.CONSTANT_Class);
-                            c_type =  ObjectType.getInstance(cen);
+                            final String cen = method.getConstantPool().getConstantString(type, Const.CONSTANT_Class);
+                            cType = ObjectType.getInstance(cen);
                         }
-                        final int end_pc = ce.getEndPC();
+                        final int endPc = ce.getEndPC();
                         final int length = getByteCodes(method).length;
                         InstructionHandle end;
-                        if (length == end_pc) { // May happen, because end_pc is exclusive
+                        if (length == endPc) { // May happen, because end_pc is exclusive
                             end = il.getEnd();
                         } else {
-                            end = il.findHandle(end_pc);
+                            end = il.findHandle(endPc);
                             end = end.getPrev(); // Make it inclusive
                         }
-                        addExceptionHandler(il.findHandle(ce.getStartPC()), end,
-                                il.findHandle(ce.getHandlerPC()), c_type);
+                        addExceptionHandler(il.findHandle(ce.getStartPC()), end, il.findHandle(ce.getHandlerPC()), cType);
                     }
                 }
-                final Attribute[] c_attributes = c.getAttributes();
-                for (final Attribute c_attribute : c_attributes) {
-                    a = c_attribute;
+                final Attribute[] cAttributes = c.getAttributes();
+                for (final Attribute cAttribute : cAttributes) {
+                    a = cAttribute;
                     if (a instanceof LineNumberTable) {
-                        final LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable();
-                        for (final LineNumber l : ln) {
+                        ((LineNumberTable) a).forEach(l -> {
                             final InstructionHandle ih = il.findHandle(l.getStartPC());
                             if (ih != null) {
                                 addLineNumber(ih, l.getLineNumber());
                             }
-                        }
+                        });
                     } else if (a instanceof LocalVariableTable) {
                         updateLocalVariableTable((LocalVariableTable) a);
                     } else if (a instanceof LocalVariableTypeTable) {
@@ -235,474 +364,478 @@ public MethodGen(final Method method, final String className, final ConstantPool
                     }
                 }
             } else if (a instanceof ExceptionTable) {
-                final String[] names = ((ExceptionTable) a).getExceptionNames();
-                for (final String name2 : names) {
-                    addException(name2);
-                }
+                Collections.addAll(throwsList, ((ExceptionTable) a).getExceptionNames());
             } else if (a instanceof Annotations) {
                 final Annotations runtimeAnnotations = (Annotations) a;
-                final AnnotationEntry[] aes = runtimeAnnotations.getAnnotationEntries();
-                for (final AnnotationEntry element : aes) {
-                    addAnnotationEntry(new AnnotationEntryGen(element, cp, false));
-                }
+                runtimeAnnotations.forEach(element -> addAnnotationEntry(new AnnotationEntryGen(element, cp, false)));
             } else {
                 addAttribute(a);
             }
         }
     }
 
+    /**
+     * @since 6.0
+     */
+    public void addAnnotationsAsAttribute(final ConstantPoolGen cp) {
+        addAll(AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()));
+    }
 
-    private static byte[] getByteCodes(final Method method) {
-        final Code code = method.getCode();
-        if (code == null) {
-            throw new IllegalStateException(String.format("The method '%s' has no code.", method));
+    /**
+     * Add an attribute to the code. Currently, the JVM knows about the LineNumberTable, LocalVariableTable and StackMap
+     * attributes, where the former two will be generated automatically and the latter is used for the MIDP only. Other
+     * attributes will be ignored by the JVM but do no harm.
+     *
+     * @param a attribute to be added
+     */
+    public void addCodeAttribute(final Attribute a) {
+        codeAttrsList.add(a);
+    }
+
+    /**
+     * Add an exception possibly thrown by this method.
+     *
+     * @param className (fully qualified) name of exception
+     */
+    public void addException(final String className) {
+        throwsList.add(className);
+    }
+
+    /**
+     * Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling
+     * is done.
+     *
+     * @param startPc Start of region (inclusive)
+     * @param endPc End of region (inclusive)
+     * @param handlerPc Where handling is done
+     * @param catchType class type of handled exception or null if any exception is handled
+     * @return new exception handler object
+     */
+    public CodeExceptionGen addExceptionHandler(final InstructionHandle startPc, final InstructionHandle endPc, final InstructionHandle handlerPc,
+        final ObjectType catchType) {
+        if (startPc == null || endPc == null || handlerPc == null) {
+            throw new ClassGenException("Exception handler target is null instruction");
         }
-        return code.getCode();
+        final CodeExceptionGen c = new CodeExceptionGen(startPc, endPc, handlerPc, catchType);
+        exceptionList.add(c);
+        return c;
     }
 
     /**
-     * Adds a local variable to this method.
+     * Give an instruction a line number corresponding to the source code line.
+     *
+     * @param ih instruction to tag
+     * @return new line number object
+     * @see LineNumber
+     */
+    public LineNumberGen addLineNumber(final InstructionHandle ih, final int srcLine) {
+        final LineNumberGen l = new LineNumberGen(ih, srcLine);
+        lineNumberList.add(l);
+        return l;
+    }
+
+    /**
+     * Adds a local variable to this method and assigns an index automatically.
      *
      * @param name variable name
      * @param type variable type
-     * @param slot the index of the local variable, if type is long or double, the next available
-     * index is slot+2
-     * @param start from where the variable is valid
-     * @param end until where the variable is valid
-     * @param orig_index the index of the local variable prior to any modifications
+     * @param start from where the variable is valid, if this is null, it is valid from the start
+     * @param end until where the variable is valid, if this is null, it is valid to the end
      * @return new local variable object
      * @see LocalVariable
      */
-    public LocalVariableGen addLocalVariable( final String name, final Type type, final int slot,
-            final InstructionHandle start, final InstructionHandle end, final int orig_index ) {
-        final byte t = type.getType();
-        if (t != Const.T_ADDRESS) {
-            final int add = type.getSize();
-            if (slot + add > maxLocals) {
-                maxLocals = slot + add;
-            }
-            final LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end, orig_index);
-            int i;
-            if ((i = variableList.indexOf(l)) >= 0) {
-                variableList.set(i, l);
-            } else {
-                variableList.add(l);
-            }
-            return l;
-        }
-        throw new IllegalArgumentException("Can not use " + type
-                + " as type for local variable");
+    public LocalVariableGen addLocalVariable(final String name, final Type type, final InstructionHandle start, final InstructionHandle end) {
+        return addLocalVariable(name, type, maxLocals, start, end);
     }
 
-
     /**
      * Adds a local variable to this method.
      *
      * @param name variable name
      * @param type variable type
-     * @param slot the index of the local variable, if type is long or double, the next available
-     * index is slot+2
+     * @param slot the index of the local variable, if type is long or double, the next available index is slot+2
      * @param start from where the variable is valid
      * @param end until where the variable is valid
      * @return new local variable object
      * @see LocalVariable
      */
-    public LocalVariableGen addLocalVariable( final String name, final Type type, final int slot,
-            final InstructionHandle start, final InstructionHandle end ) {
+    public LocalVariableGen addLocalVariable(final String name, final Type type, final int slot, final InstructionHandle start, final InstructionHandle end) {
         return addLocalVariable(name, type, slot, start, end, slot);
     }
 
     /**
-     * Adds a local variable to this method and assigns an index automatically.
+     * Adds a local variable to this method.
      *
      * @param name variable name
      * @param type variable type
-     * @param start from where the variable is valid, if this is null,
-     * it is valid from the start
-     * @param end until where the variable is valid, if this is null,
-     * it is valid to the end
+     * @param slot the index of the local variable, if type is long or double, the next available index is slot+2
+     * @param start from where the variable is valid
+     * @param end until where the variable is valid
+     * @param origIndex the index of the local variable prior to any modifications
      * @return new local variable object
      * @see LocalVariable
      */
-    public LocalVariableGen addLocalVariable( final String name, final Type type, final InstructionHandle start,
-            final InstructionHandle end ) {
-        return addLocalVariable(name, type, maxLocals, start, end);
+    public LocalVariableGen addLocalVariable(final String name, final Type type, final int slot, final InstructionHandle start, final InstructionHandle end,
+        final int origIndex) {
+        final byte t = type.getType();
+        if (t != Const.T_ADDRESS) {
+            final int add = type.getSize();
+            if (slot + add > maxLocals) {
+                maxLocals = slot + add;
+            }
+            final LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end, origIndex);
+            int i;
+            if ((i = variableList.indexOf(l)) >= 0) {
+                variableList.set(i, l);
+            } else {
+                variableList.add(l);
+            }
+            return l;
+        }
+        throw new IllegalArgumentException("Can not use " + type + " as type for local variable");
     }
 
-
     /**
-     * Remove a local variable, its slot will not be reused, if you do not use
-     * addLocalVariable with an explicit index argument.
+     * Add observer for this object.
      */
-    public void removeLocalVariable(final LocalVariableGen l) {
-        variableList.remove(l);
+    public void addObserver(final MethodObserver o) {
+        if (observers == null) {
+            observers = new ArrayList<>();
+        }
+        observers.add(o);
     }
 
-
-    /**
-     * Remove all local variables.
-     */
-    public void removeLocalVariables() {
-        variableList.clear();
-    }
-
-
-    /*
-     * If the range of the variable has not been set yet, it will be set to be valid from
-     * the start to the end of the instruction list.
-     *
-     * @return array of declared local variables sorted by index
-     */
-    public LocalVariableGen[] getLocalVariables() {
-        final int size = variableList.size();
-        final LocalVariableGen[] lg = new LocalVariableGen[size];
-        variableList.toArray(lg);
-        for (int i = 0; i < size; i++) {
-            if ((lg[i].getStart() == null) && (il != null)) {
-                lg[i].setStart(il.getStart());
-            }
-            if ((lg[i].getEnd() == null) && (il != null)) {
-                lg[i].setEnd(il.getEnd());
-            }
+    public void addParameterAnnotation(final int parameterIndex, final AnnotationEntryGen annotation) {
+        ensureExistingParameterAnnotationsUnpacked();
+        if (!hasParameterAnnotations) {
+            @SuppressWarnings({"rawtypes", "unchecked"})
+            final List<AnnotationEntryGen>[] parmList = (List<AnnotationEntryGen>[])new List[argTypes.length];
+            paramAnnotations = parmList;
+            hasParameterAnnotations = true;
         }
-        if (size > 1) {
-            Arrays.sort(lg, (o1, o2) -> o1.getIndex() - o2.getIndex());
+        final List<AnnotationEntryGen> existingAnnotations = paramAnnotations[parameterIndex];
+        if (existingAnnotations != null) {
+            existingAnnotations.add(annotation);
+        } else {
+            final List<AnnotationEntryGen> l = new ArrayList<>();
+            l.add(annotation);
+            paramAnnotations[parameterIndex] = l;
         }
-        return lg;
     }
 
-
     /**
-     * @return `LocalVariableTable' attribute of all the local variables of this method.
+     * @since 6.0
      */
-    public LocalVariableTable getLocalVariableTable( final ConstantPoolGen cp ) {
-        final LocalVariableGen[] lg = getLocalVariables();
-        final int size = lg.length;
-        final LocalVariable[] lv = new LocalVariable[size];
-        for (int i = 0; i < size; i++) {
-            lv[i] = lg[i].getLocalVariable(cp);
+    public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) {
+        if (!hasParameterAnnotations) {
+            return;
+        }
+        final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations);
+        if (attrs != null) {
+            addAll(attrs);
         }
-        return new LocalVariableTable(cp.addUtf8("LocalVariableTable"), 2 + lv.length * 10, lv, cp
-                .getConstantPool());
     }
 
-    /**
-     * @return `LocalVariableTypeTable' attribute of this method.
-     */
-    public LocalVariableTypeTable getLocalVariableTypeTable() {
-        return localVariableTypeTable;
+    private Attribute[] addRuntimeAnnotationsAsAttribute(final ConstantPoolGen cp) {
+        final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
+        addAll(attrs);
+        return attrs;
     }
 
-    /**
-     * Give an instruction a line number corresponding to the source code line.
-     *
-     * @param ih instruction to tag
-     * @return new line number object
-     * @see LineNumber
-     */
-    public LineNumberGen addLineNumber( final InstructionHandle ih, final int srcLine ) {
-        final LineNumberGen l = new LineNumberGen(ih, srcLine);
-        lineNumberList.add(l);
-        return l;
+    private Attribute[] addRuntimeParameterAnnotationsAsAttribute(final ConstantPoolGen cp) {
+        if (!hasParameterAnnotations) {
+            return Attribute.EMPTY_ARRAY;
+        }
+        final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations);
+        addAll(attrs);
+        return attrs;
     }
 
-
-    /**
-     * Remove a line number.
-     */
-    public void removeLineNumber( final LineNumberGen l ) {
-        lineNumberList.remove(l);
+    private void adjustLocalVariableTypeTable(final LocalVariableTable lvt) {
+        final LocalVariable[] lv = lvt.getLocalVariableTable();
+        for (final LocalVariable element : localVariableTypeTable.getLocalVariableTypeTable()) {
+            for (final LocalVariable l : lv) {
+                if (element.getName().equals(l.getName()) && element.getIndex() == l.getOrigIndex()) {
+                    element.setLength(l.getLength());
+                    element.setStartPC(l.getStartPC());
+                    element.setIndex(l.getIndex());
+                    break;
+                }
+            }
+        }
     }
 
-
     /**
-     * Remove all line numbers.
-     */
-    public void removeLineNumbers() {
-        lineNumberList.clear();
-    }
-
-
-    /*
-     * @return array of line numbers
+     * @return deep copy of this method
      */
-    public LineNumberGen[] getLineNumbers() {
-        final LineNumberGen[] lg = new LineNumberGen[lineNumberList.size()];
-        lineNumberList.toArray(lg);
-        return lg;
+    public MethodGen copy(final String className, final ConstantPoolGen cp) {
+        final Method m = ((MethodGen) clone()).getMethod();
+        final MethodGen mg = new MethodGen(m, className, super.getConstantPool());
+        if (super.getConstantPool() != cp) {
+            mg.setConstantPool(cp);
+            mg.getInstructionList().replaceConstantPool(super.getConstantPool(), cp);
+        }
+        return mg;
     }
 
-
     /**
-     * @return `LineNumberTable' attribute of all the local variables of this method.
+     * Goes through the attributes on the method and identifies any that are RuntimeParameterAnnotations, extracting their
+     * contents and storing them as parameter annotations. There are two kinds of parameter annotation - visible and
+     * invisible. Once they have been unpacked, these attributes are deleted. (The annotations will be rebuilt as attributes
+     * when someone builds a Method object out of this MethodGen object).
      */
-    public LineNumberTable getLineNumberTable( final ConstantPoolGen cp ) {
-        final int size = lineNumberList.size();
-        final LineNumber[] ln = new LineNumber[size];
-        for (int i = 0; i < size; i++) {
-            ln[i] = lineNumberList.get(i).getLineNumber();
+    private void ensureExistingParameterAnnotationsUnpacked() {
+        if (haveUnpackedParameterAnnotations) {
+            return;
+        }
+        // Find attributes that contain parameter annotation data
+        final Attribute[] attrs = getAttributes();
+        ParameterAnnotations paramAnnVisAttr = null;
+        ParameterAnnotations paramAnnInvisAttr = null;
+        for (final Attribute attribute : attrs) {
+            if (attribute instanceof ParameterAnnotations) {
+                // Initialize paramAnnotations
+                if (!hasParameterAnnotations) {
+                    @SuppressWarnings({"rawtypes", "unchecked"})
+                    final List<AnnotationEntryGen>[] parmList = (List<AnnotationEntryGen>[])new List[argTypes.length];
+                    paramAnnotations = parmList;
+                    Arrays.setAll(paramAnnotations, i -> new ArrayList<>());
+                }
+                hasParameterAnnotations = true;
+                final ParameterAnnotations rpa = (ParameterAnnotations) attribute;
+                if (rpa instanceof RuntimeVisibleParameterAnnotations) {
+                    paramAnnVisAttr = rpa;
+                } else {
+                    paramAnnInvisAttr = rpa;
+                }
+                final ParameterAnnotationEntry[] parameterAnnotationEntries = rpa.getParameterAnnotationEntries();
+                for (int j = 0; j < parameterAnnotationEntries.length; j++) {
+                    // This returns Annotation[] ...
+                    final ParameterAnnotationEntry immutableArray = rpa.getParameterAnnotationEntries()[j];
+                    // ... which needs transforming into an AnnotationGen[] ...
+                    final List<AnnotationEntryGen> mutable = makeMutableVersion(immutableArray.getAnnotationEntries());
+                    // ... then add these to any we already know about
+                    paramAnnotations[j].addAll(mutable);
+                }
+            }
+        }
+        if (paramAnnVisAttr != null) {
+            removeAttribute(paramAnnVisAttr);
+        }
+        if (paramAnnInvisAttr != null) {
+            removeAttribute(paramAnnInvisAttr);
         }
-        return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp
-                .getConstantPool());
+        haveUnpackedParameterAnnotations = true;
     }
 
-
     /**
-     * Add an exception handler, i.e., specify region where a handler is active and an
-     * instruction where the actual handling is done.
+     * Return value as defined by given BCELComparator strategy. By default two MethodGen objects are said to be equal when
+     * their names and signatures are equal.
      *
-     * @param start_pc Start of region (inclusive)
-     * @param end_pc End of region (inclusive)
-     * @param handler_pc Where handling is done
-     * @param catch_type class type of handled exception or null if any
-     * exception is handled
-     * @return new exception handler object
+     * @see Object#equals(Object)
      */
-    public CodeExceptionGen addExceptionHandler( final InstructionHandle start_pc,
-            final InstructionHandle end_pc, final InstructionHandle handler_pc, final ObjectType catch_type ) {
-        if ((start_pc == null) || (end_pc == null) || (handler_pc == null)) {
-            throw new ClassGenException("Exception handler target is null instruction");
-        }
-        final CodeExceptionGen c = new CodeExceptionGen(start_pc, end_pc, handler_pc, catch_type);
-        exceptionList.add(c);
-        return c;
+    @Override
+    public boolean equals(final Object obj) {
+        return bcelComparator.equals(this, obj);
     }
 
-
+    // J5TODO: Should paramAnnotations be an array of arrays? Rather than an array of lists, this
+    // is more likely to suggest to the caller it is readonly (which a List does not).
     /**
-     * Remove an exception handler.
+     * Return a list of AnnotationGen objects representing parameter annotations
+     *
+     * @since 6.0
      */
-    public void removeExceptionHandler( final CodeExceptionGen c ) {
-        exceptionList.remove(c);
+    public List<AnnotationEntryGen> getAnnotationsOnParameter(final int i) {
+        ensureExistingParameterAnnotationsUnpacked();
+        if (!hasParameterAnnotations || i > argTypes.length) {
+            return null;
+        }
+        return paramAnnotations[i];
     }
 
-
-    /**
-     * Remove all line numbers.
-     */
-    public void removeExceptionHandlers() {
-        exceptionList.clear();
+    public String getArgumentName(final int i) {
+        return argNames[i];
     }
 
+    public String[] getArgumentNames() {
+        return argNames.clone();
+    }
 
-    /*
-     * @return array of declared exception handlers
-     */
-    public CodeExceptionGen[] getExceptionHandlers() {
-        final CodeExceptionGen[] cg = new CodeExceptionGen[exceptionList.size()];
-        exceptionList.toArray(cg);
-        return cg;
+    public Type getArgumentType(final int i) {
+        return argTypes[i];
     }
 
+    public Type[] getArgumentTypes() {
+        return argTypes.clone();
+    }
 
     /**
-     * @return code exceptions for `Code' attribute
+     * @return class that contains this method
      */
-    private CodeException[] getCodeExceptions() {
-        final int size = exceptionList.size();
-        final CodeException[] c_exc = new CodeException[size];
-        for (int i = 0; i < size; i++) {
-            final CodeExceptionGen c =  exceptionList.get(i);
-            c_exc[i] = c.getCodeException(super.getConstantPool());
-        }
-        return c_exc;
+    public String getClassName() {
+        return className;
     }
 
-
     /**
-     * Add an exception possibly thrown by this method.
-     *
-     * @param className (fully qualified) name of exception
+     * @return all attributes of this method.
      */
-    public void addException( final String className ) {
-        throwsList.add(className);
+    public Attribute[] getCodeAttributes() {
+        return codeAttrsList.toArray(Attribute.EMPTY_ARRAY);
     }
 
-
     /**
-     * Remove an exception.
+     * @return code exceptions for 'Code' attribute
      */
-    public void removeException( final String c ) {
-        throwsList.remove(c);
+    private CodeException[] getCodeExceptions() {
+        final int size = exceptionList.size();
+        final CodeException[] cExc = new CodeException[size];
+        Arrays.setAll(cExc, i -> exceptionList.get(i).getCodeException(super.getConstantPool()));
+        return cExc;
     }
 
-
-    /**
-     * Remove all exceptions.
+    /*
+     * @return array of declared exception handlers
      */
-    public void removeExceptions() {
-        throwsList.clear();
+    public CodeExceptionGen[] getExceptionHandlers() {
+        return exceptionList.toArray(CodeExceptionGen.EMPTY_ARRAY);
     }
 
-
     /*
      * @return array of thrown exceptions
      */
     public String[] getExceptions() {
-        return throwsList.toArray(new String[0]);
+        return throwsList.toArray(Const.EMPTY_STRING_ARRAY);
     }
 
-
     /**
-     * @return `Exceptions' attribute of all the exceptions thrown by this method.
+     * @return 'Exceptions' attribute of all the exceptions thrown by this method.
      */
-    private ExceptionTable getExceptionTable( final ConstantPoolGen cp ) {
+    private ExceptionTable getExceptionTable(final ConstantPoolGen cp) {
         final int size = throwsList.size();
         final int[] ex = new int[size];
-        for (int i = 0; i < size; i++) {
-            ex[i] = cp.addClass(throwsList.get(i));
-        }
+        Arrays.setAll(ex, i -> cp.addClass(throwsList.get(i)));
         return new ExceptionTable(cp.addUtf8("Exceptions"), 2 + 2 * size, ex, cp.getConstantPool());
     }
 
+    public InstructionList getInstructionList() {
+        return il;
+    }
 
-    /**
-     * Add an attribute to the code. Currently, the JVM knows about the
-     * LineNumberTable, LocalVariableTable and StackMap attributes,
-     * where the former two will be generated automatically and the
-     * latter is used for the MIDP only. Other attributes will be
-     * ignored by the JVM but do no harm.
-     *
-     * @param a attribute to be added
+    /*
+     * @return array of line numbers
      */
-    public void addCodeAttribute( final Attribute a ) {
-        codeAttrsList.add(a);
+    public LineNumberGen[] getLineNumbers() {
+        return lineNumberList.toArray(LineNumberGen.EMPTY_ARRAY);
     }
 
-
     /**
-     * Remove the LocalVariableTypeTable
+     * @return 'LineNumberTable' attribute of all the local variables of this method.
      */
-    public void removeLocalVariableTypeTable( ) {
-        localVariableTypeTable = null;
+    public LineNumberTable getLineNumberTable(final ConstantPoolGen cp) {
+        final int size = lineNumberList.size();
+        final LineNumber[] ln = new LineNumber[size];
+        Arrays.setAll(ln, i -> lineNumberList.get(i).getLineNumber());
+        return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp.getConstantPool());
     }
 
-    /**
-     * Remove a code attribute.
+    /*
+     * If the range of the variable has not been set yet, it will be set to be valid from the start to the end of the
+     * instruction list.
+     *
+     * @return array of declared local variables sorted by index
      */
-    public void removeCodeAttribute( final Attribute a ) {
-        codeAttrsList.remove(a);
+    public LocalVariableGen[] getLocalVariables() {
+        final int size = variableList.size();
+        final LocalVariableGen[] lg = new LocalVariableGen[size];
+        variableList.toArray(lg);
+        for (int i = 0; i < size; i++) {
+            if (lg[i].getStart() == null && il != null) {
+                lg[i].setStart(il.getStart());
+            }
+            if (lg[i].getEnd() == null && il != null) {
+                lg[i].setEnd(il.getEnd());
+            }
+        }
+        if (size > 1) {
+            Arrays.sort(lg, Comparator.comparingInt(LocalVariableGen::getIndex));
+        }
+        return lg;
     }
 
-
     /**
-     * Remove all code attributes.
+     * @return 'LocalVariableTable' attribute of all the local variables of this method.
      */
-    public void removeCodeAttributes() {
-        localVariableTypeTable = null;
-        codeAttrsList.clear();
+    public LocalVariableTable getLocalVariableTable(final ConstantPoolGen cp) {
+        final LocalVariableGen[] lg = getLocalVariables();
+        final int size = lg.length;
+        final LocalVariable[] lv = new LocalVariable[size];
+        Arrays.setAll(lv, i -> lg[i].getLocalVariable(cp));
+        return new LocalVariableTable(cp.addUtf8("LocalVariableTable"), 2 + lv.length * 10, lv, cp.getConstantPool());
     }
 
-
     /**
-     * @return all attributes of this method.
+     * @return 'LocalVariableTypeTable' attribute of this method.
      */
-    public Attribute[] getCodeAttributes() {
-        return codeAttrsList.toArray(new Attribute[0]);
+    public LocalVariableTypeTable getLocalVariableTypeTable() {
+        return localVariableTypeTable;
     }
 
-    /**
-     * @since 6.0
-     */
-    public void addAnnotationsAsAttribute(final ConstantPoolGen cp) {
-        final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
-        for (final Attribute attr : attrs) {
-            addAttribute(attr);
-        }
-    }
-
-    /**
-     * @since 6.0
-     */
-    public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) {
-        if (!hasParameterAnnotations) {
-            return;
-        }
-        final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations);
-        if (attrs != null) {
-            for (final Attribute attr : attrs) {
-                addAttribute(attr);
-            }
-        }
-    }
-
-    private Attribute[] addRuntimeAnnotationsAsAttribute(final ConstantPoolGen cp) {
-        final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
-        for (final Attribute attr : attrs) {
-            addAttribute(attr);
-        }
-        return attrs;
-    }
-
-    private Attribute[] addRuntimeParameterAnnotationsAsAttribute(final ConstantPoolGen cp) {
-        if (!hasParameterAnnotations) {
-            return new Attribute[0];
-        }
-        final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations);
-        for (final Attribute attr : attrs) {
-            addAttribute(attr);
-        }
-        return attrs;
+    public int getMaxLocals() {
+        return maxLocals;
     }
 
-    /**
-     * Would prefer to make this private, but need a way to test if client is
-     * using BCEL version 6.5.0 or later that contains fix for BCEL-329.
-     * @since 6.5.0
-     */
-    public void removeRuntimeAttributes(final Attribute[] attrs) {
-        for (final Attribute attr : attrs) {
-            removeAttribute(attr);
-        }
+    public int getMaxStack() {
+        return maxStack;
     }
 
-
     /**
-     * Get method object. Never forget to call setMaxStack() or setMaxStack(max), respectively,
-     * before calling this method (the same applies for max locals).
+     * Get method object. Never forget to call setMaxStack() or setMaxStack(max), respectively, before calling this method
+     * (the same applies for max locals).
      *
      * @return method object
      */
     public Method getMethod() {
         final String signature = getSignature();
-        final ConstantPoolGen _cp = super.getConstantPool();
-        final int name_index = _cp.addUtf8(super.getName());
-        final int signature_index = _cp.addUtf8(signature);
-        /* Also updates positions of instructions, i.e., their indices
+        final ConstantPoolGen cp = super.getConstantPool();
+        final int nameIndex = cp.addUtf8(super.getName());
+        final int signatureIndex = cp.addUtf8(signature);
+        /*
+         * Also updates positions of instructions, i.e., their indices
          */
-        byte[] byte_code = null;
-        if (il != null) {
-            byte_code = il.getByteCode();
-        }
+        final byte[] byteCode = il != null ? il.getByteCode() : null;
         LineNumberTable lnt = null;
         LocalVariableTable lvt = null;
-        /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.)
+        /*
+         * Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.)
          */
-        if ((variableList.size() > 0) && !stripAttributes) {
-            updateLocalVariableTable(getLocalVariableTable(_cp));
-            addCodeAttribute(lvt = getLocalVariableTable(_cp));
+        if (!variableList.isEmpty() && !stripAttributes) {
+            updateLocalVariableTable(getLocalVariableTable(cp));
+            addCodeAttribute(lvt = getLocalVariableTable(cp));
         }
         if (localVariableTypeTable != null) {
-            // LocalVariable length in LocalVariableTypeTable is not updated automatically. It's a difference with LocalVariableTable.
+            // LocalVariable length in LocalVariableTypeTable is not updated automatically. It's a difference with
+            // LocalVariableTable.
             if (lvt != null) {
                 adjustLocalVariableTypeTable(lvt);
             }
             addCodeAttribute(localVariableTypeTable);
         }
-        if ((lineNumberList.size() > 0) && !stripAttributes) {
-            addCodeAttribute(lnt = getLineNumberTable(_cp));
+        if (!lineNumberList.isEmpty() && !stripAttributes) {
+            addCodeAttribute(lnt = getLineNumberTable(cp));
         }
-        final Attribute[] code_attrs = getCodeAttributes();
-        /* Each attribute causes 6 additional header bytes
+        final Attribute[] codeAttrs = getCodeAttributes();
+        /*
+         * Each attribute causes 6 additional header bytes
          */
-        int attrs_len = 0;
-        for (final Attribute code_attr : code_attrs) {
-            attrs_len += code_attr.getLength() + 6;
+        int attrsLen = 0;
+        for (final Attribute codeAttr : codeAttrs) {
+            attrsLen += codeAttr.getLength() + 6;
         }
-        final CodeException[] c_exc = getCodeExceptions();
-        final int exc_len = c_exc.length * 8; // Every entry takes 8 bytes
+        final CodeException[] cExc = getCodeExceptions();
+        final int excLen = cExc.length * 8; // Every entry takes 8 bytes
         Code code = null;
-        if ((il != null) && !isAbstract() && !isNative()) {
+        if (byteCode != null && !isAbstract() && !isNative()) {
             // Remove any stale code attribute
             final Attribute[] attributes = getAttributes();
             for (final Attribute a : attributes) {
@@ -710,21 +843,20 @@ public Method getMethod() {
                     removeAttribute(a);
                 }
             }
-            code = new Code(_cp.addUtf8("Code"), 8 + byte_code.length + // prologue byte code
-                    2 + exc_len + // exceptions
-                    2 + attrs_len, // attributes
-                    maxStack, maxLocals, byte_code, c_exc, code_attrs, _cp.getConstantPool());
+            code = new Code(cp.addUtf8("Code"), 8 + byteCode.length + // prologue byte code
+                2 + excLen + // exceptions
+                2 + attrsLen, // attributes
+                maxStack, maxLocals, byteCode, cExc, codeAttrs, cp.getConstantPool());
             addAttribute(code);
         }
-        final Attribute[] annotations = addRuntimeAnnotationsAsAttribute(_cp);
-        final Attribute[] parameterAnnotations = addRuntimeParameterAnnotationsAsAttribute(_cp);
+        final Attribute[] annotations = addRuntimeAnnotationsAsAttribute(cp);
+        final Attribute[] parameterAnnotations = addRuntimeParameterAnnotationsAsAttribute(cp);
         ExceptionTable et = null;
-        if (throwsList.size() > 0) {
-            addAttribute(et = getExceptionTable(_cp));
-            // Add `Exceptions' if there are "throws" clauses
+        if (!throwsList.isEmpty()) {
+            addAttribute(et = getExceptionTable(cp));
+            // Add 'Exceptions' if there are "throws" clauses
         }
-        final Method m = new Method(super.getAccessFlags(), name_index, signature_index, getAttributes(), _cp
-                .getConstantPool());
+        final Method m = new Method(super.getAccessFlags(), nameIndex, signatureIndex, getAttributes(), cp.getConstantPool());
         // Undo effects of adding attributes
         if (lvt != null) {
             removeCodeAttribute(lvt);
@@ -746,185 +878,185 @@ public Method getMethod() {
         return m;
     }
 
-    private void updateLocalVariableTable(final LocalVariableTable a) {
-        final LocalVariable[] lv = a.getLocalVariableTable();
-        removeLocalVariables();
-        for (final LocalVariable l : lv) {
-            InstructionHandle start = il.findHandle(l.getStartPC());
-            final InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
-            // Repair malformed handles
-            if (null == start) {
-                start = il.getStart();
-            }
-            // end == null => live to end of method
-            // Since we are recreating the LocalVaraible, we must
-            // propagate the orig_index to new copy.
-            addLocalVariable(l.getName(), Type.getType(l.getSignature()), l
-                    .getIndex(), start, end, l.getOrigIndex());
-        }
+    public Type getReturnType() {
+        return getType();
     }
 
-    private void adjustLocalVariableTypeTable(final LocalVariableTable lvt) {
-        final LocalVariable[] lv = lvt.getLocalVariableTable();
-        final LocalVariable[] lvg = localVariableTypeTable.getLocalVariableTypeTable();
-
-        for (final LocalVariable element : lvg) {
-            for (final LocalVariable l : lv) {
-                if (element.getName().equals(l.getName()) && element.getIndex() == l.getOrigIndex()) {
-                    element.setLength(l.getLength());
-                    element.setStartPC(l.getStartPC());
-                    element.setIndex(l.getIndex());
-                    break;
-                }
-            }
-        }
+    @Override
+    public String getSignature() {
+        return Type.getMethodSignature(super.getType(), argTypes);
     }
 
-
     /**
-     * Remove all NOPs from the instruction list (if possible) and update every
-     * object referring to them, i.e., branch instructions, local variables and
-     * exception handlers.
+     * Return value as defined by given BCELComparator strategy. By default return the hashcode of the method's name XOR
+     * signature.
+     *
+     * @see Object#hashCode()
      */
-    public void removeNOPs() {
-        if (il != null) {
-            InstructionHandle next;
-            /* Check branch instructions.
-             */
-            for (InstructionHandle ih = il.getStart(); ih != null; ih = next) {
-                next = ih.getNext();
-                if ((next != null) && (ih.getInstruction() instanceof NOP)) {
-                    try {
-                        il.delete(ih);
-                    } catch (final TargetLostException e) {
-                        for (final InstructionHandle target : e.getTargets()) {
-                            for (final InstructionTargeter targeter : target.getTargeters()) {
-                                targeter.updateTarget(target, next);
-                            }
-                        }
-                    }
-                }
-            }
-        }
+    @Override
+    public int hashCode() {
+        return bcelComparator.hashCode(this);
     }
 
+    private List<AnnotationEntryGen> makeMutableVersion(final AnnotationEntry[] mutableArray) {
+        final List<AnnotationEntryGen> result = new ArrayList<>();
+        for (final AnnotationEntry element : mutableArray) {
+            result.add(new AnnotationEntryGen(element, getConstantPool(), false));
+        }
+        return result;
+    }
 
     /**
-     * Set maximum number of local variables.
+     * Remove a code attribute.
      */
-    public void setMaxLocals( final int m ) {
-        maxLocals = m;
+    public void removeCodeAttribute(final Attribute a) {
+        codeAttrsList.remove(a);
     }
 
-
-    public int getMaxLocals() {
-        return maxLocals;
+    /**
+     * Remove all code attributes.
+     */
+    public void removeCodeAttributes() {
+        localVariableTypeTable = null;
+        codeAttrsList.clear();
     }
 
-
     /**
-     * Set maximum stack size for this method.
+     * Remove an exception.
      */
-    public void setMaxStack( final int m ) { // TODO could be package-protected?
-        maxStack = m;
+    public void removeException(final String c) {
+        throwsList.remove(c);
     }
 
-
-    public int getMaxStack() {
-        return maxStack;
+    /**
+     * Remove an exception handler.
+     */
+    public void removeExceptionHandler(final CodeExceptionGen c) {
+        exceptionList.remove(c);
     }
 
-
-    /** @return class that contains this method
+    /**
+     * Remove all line numbers.
      */
-    public String getClassName() {
-        return className;
+    public void removeExceptionHandlers() {
+        exceptionList.clear();
     }
 
-
-    public void setClassName( final String class_name ) { // TODO could be package-protected?
-        this.className = class_name;
+    /**
+     * Remove all exceptions.
+     */
+    public void removeExceptions() {
+        throwsList.clear();
     }
 
-
-    public void setReturnType( final Type return_type ) {
-        setType(return_type);
+    /**
+     * Remove a line number.
+     */
+    public void removeLineNumber(final LineNumberGen l) {
+        lineNumberList.remove(l);
     }
 
-
-    public Type getReturnType() {
-        return getType();
+    /**
+     * Remove all line numbers.
+     */
+    public void removeLineNumbers() {
+        lineNumberList.clear();
     }
 
-
-    public void setArgumentTypes( final Type[] arg_types ) {
-        this.argTypes = arg_types;
+    /**
+     * Remove a local variable, its slot will not be reused, if you do not use addLocalVariable with an explicit index
+     * argument.
+     */
+    public void removeLocalVariable(final LocalVariableGen l) {
+        variableList.remove(l);
     }
 
-
-    public Type[] getArgumentTypes() {
-        return argTypes.clone();
+    /**
+     * Remove all local variables.
+     */
+    public void removeLocalVariables() {
+        variableList.clear();
     }
 
-
-    public void setArgumentType( final int i, final Type type ) {
-        argTypes[i] = type;
+    /**
+     * Remove the LocalVariableTypeTable
+     */
+    public void removeLocalVariableTypeTable() {
+        localVariableTypeTable = null;
     }
 
-
-    public Type getArgumentType( final int i ) {
-        return argTypes[i];
+    /**
+     * Remove all NOPs from the instruction list (if possible) and update every object referring to them, i.e., branch
+     * instructions, local variables and exception handlers.
+     */
+    public void removeNOPs() {
+        if (il != null) {
+            InstructionHandle next;
+            /*
+             * Check branch instructions.
+             */
+            for (InstructionHandle ih = il.getStart(); ih != null; ih = next) {
+                next = ih.getNext();
+                if (next != null && ih.getInstruction() instanceof NOP) {
+                    try {
+                        il.delete(ih);
+                    } catch (final TargetLostException e) {
+                        for (final InstructionHandle target : e.getTargets()) {
+                            for (final InstructionTargeter targeter : target.getTargeters()) {
+                                targeter.updateTarget(target, next);
+                            }
+                        }
+                    }
+                }
+            }
+        }
     }
 
-
-    public void setArgumentNames( final String[] arg_names ) {
-        this.argNames = arg_names;
+    /**
+     * Remove observer for this object.
+     */
+    public void removeObserver(final MethodObserver o) {
+        if (observers != null) {
+            observers.remove(o);
+        }
     }
 
-
-    public String[] getArgumentNames() {
-        return argNames.clone();
+    /**
+     * Would prefer to make this private, but need a way to test if client is using BCEL version 6.5.0 or later that
+     * contains fix for BCEL-329.
+     *
+     * @since 6.5.0
+     */
+    public void removeRuntimeAttributes(final Attribute[] attrs) {
+        for (final Attribute attr : attrs) {
+            removeAttribute(attr);
+        }
     }
 
-
-    public void setArgumentName( final int i, final String name ) {
+    public void setArgumentName(final int i, final String name) {
         argNames[i] = name;
     }
 
-
-    public String getArgumentName( final int i ) {
-        return argNames[i];
+    public void setArgumentNames(final String[] argNames) {
+        this.argNames = argNames;
     }
 
-
-    public InstructionList getInstructionList() {
-        return il;
+    public void setArgumentType(final int i, final Type type) {
+        argTypes[i] = type;
     }
 
-
-    public void setInstructionList( final InstructionList il ) { // TODO could be package-protected?
-        this.il = il;
+    public void setArgumentTypes(final Type[] argTypes) {
+        this.argTypes = argTypes;
     }
 
-
-    @Override
-    public String getSignature() {
-        return Type.getMethodSignature(super.getType(), argTypes);
+    public void setClassName(final String className) { // TODO could be package-protected?
+        this.className = className;
     }
 
-
-    /**
-     * Computes max. stack size by performing control flow analysis.
-     */
-    public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging)
-        if (il != null) {
-            maxStack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers());
-        } else {
-            maxStack = 0;
-        }
+    public void setInstructionList(final InstructionList il) { // TODO could be package-protected?
+        this.il = il;
     }
 
-
     /**
      * Compute maximum number of local variables.
      */
@@ -932,16 +1064,14 @@ public void setMaxLocals() { // TODO could be package-protected? (some tests wou
         if (il != null) {
             int max = isStatic() ? 0 : 1;
             if (argTypes != null) {
-                for (final Type arg_type : argTypes) {
-                    max += arg_type.getSize();
+                for (final Type argType : argTypes) {
+                    max += argType.getSize();
                 }
             }
             for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) {
                 final Instruction ins = ih.getInstruction();
-                if ((ins instanceof LocalVariableInstruction) || (ins instanceof RET)
-                        || (ins instanceof IINC)) {
-                    final int index = ((IndexedInstruction) ins).getIndex()
-                            + ((TypedInstruction) ins).getType(super.getConstantPool()).getSize();
+                if (ins instanceof LocalVariableInstruction || ins instanceof RET || ins instanceof IINC) {
+                    final int index = ((IndexedInstruction) ins).getIndex() + ((TypedInstruction) ins).getType(super.getConstantPool()).getSize();
                     if (index > max) {
                         max = index;
                     }
@@ -953,176 +1083,45 @@ public void setMaxLocals() { // TODO could be package-protected? (some tests wou
         }
     }
 
-
-    /** Do not/Do produce attributes code attributesLineNumberTable and
-     * LocalVariableTable, like javac -O
+    /**
+     * Set maximum number of local variables.
      */
-    public void stripAttributes( final boolean flag ) {
-        stripAttributes = flag;
-    }
-
-    static final class BranchTarget {
-
-        final InstructionHandle target;
-        final int stackDepth;
-
-
-        BranchTarget(final InstructionHandle target, final int stackDepth) {
-            this.target = target;
-            this.stackDepth = stackDepth;
-        }
-    }
-
-    static final class BranchStack {
-
-        private final Stack<BranchTarget> branchTargets = new Stack<>();
-        private final Map<InstructionHandle, BranchTarget> visitedTargets = new HashMap<>();
-
-
-        public void push( final InstructionHandle target, final int stackDepth ) {
-            if (visited(target)) {
-                return;
-            }
-            branchTargets.push(visit(target, stackDepth));
-        }
-
-
-        public BranchTarget pop() {
-            if (!branchTargets.empty()) {
-                final BranchTarget bt = branchTargets.pop();
-                return bt;
-            }
-            return null;
-        }
-
-
-        private BranchTarget visit( final InstructionHandle target, final int stackDepth ) {
-            final BranchTarget bt = new BranchTarget(target, stackDepth);
-            visitedTargets.put(target, bt);
-            return bt;
-        }
-
-
-        private boolean visited( final InstructionHandle target ) {
-            return visitedTargets.get(target) != null;
-        }
+    public void setMaxLocals(final int m) {
+        maxLocals = m;
     }
 
-
     /**
-     * Computes stack usage of an instruction list by performing control flow analysis.
-     *
-     * @return maximum stack depth used by method
+     * Computes max. stack size by performing control flow analysis.
      */
-    public static int getMaxStack( final ConstantPoolGen cp, final InstructionList il, final CodeExceptionGen[] et ) {
-        final BranchStack branchTargets = new BranchStack();
-        /* Initially, populate the branch stack with the exception
-         * handlers, because these aren't (necessarily) branched to
-         * explicitly. in each case, the stack will have depth 1,
-         * containing the exception object.
-         */
-        for (final CodeExceptionGen element : et) {
-            final InstructionHandle handler_pc = element.getHandlerPC();
-            if (handler_pc != null) {
-                branchTargets.push(handler_pc, 1);
-            }
-        }
-        int stackDepth = 0;
-        int maxStackDepth = 0;
-        InstructionHandle ih = il.getStart();
-        while (ih != null) {
-            final Instruction instruction = ih.getInstruction();
-            final short opcode = instruction.getOpcode();
-            final int delta = instruction.produceStack(cp) - instruction.consumeStack(cp);
-            stackDepth += delta;
-            if (stackDepth > maxStackDepth) {
-                maxStackDepth = stackDepth;
-            }
-            // choose the next instruction based on whether current is a branch.
-            if (instruction instanceof BranchInstruction) {
-                final BranchInstruction branch = (BranchInstruction) instruction;
-                if (instruction instanceof Select) {
-                    // explore all of the select's targets. the default target is handled below.
-                    final Select select = (Select) branch;
-                    final InstructionHandle[] targets = select.getTargets();
-                    for (final InstructionHandle target : targets) {
-                        branchTargets.push(target, stackDepth);
-                    }
-                    // nothing to fall through to.
-                    ih = null;
-                } else if (!(branch instanceof IfInstruction)) {
-                    // if an instruction that comes back to following PC,
-                    // push next instruction, with stack depth reduced by 1.
-                    if (opcode == Const.JSR || opcode == Const.JSR_W) {
-                        branchTargets.push(ih.getNext(), stackDepth - 1);
-                    }
-                    ih = null;
-                }
-                // for all branches, the target of the branch is pushed on the branch stack.
-                // conditional branches have a fall through case, selects don't, and
-                // jsr/jsr_w return to the next instruction.
-                branchTargets.push(branch.getTarget(), stackDepth);
-            } else {
-                // check for instructions that terminate the method.
-                if (opcode == Const.ATHROW || opcode == Const.RET
-                        || (opcode >= Const.IRETURN && opcode <= Const.RETURN)) {
-                    ih = null;
-                }
-            }
-            // normal case, go to the next instruction.
-            if (ih != null) {
-                ih = ih.getNext();
-            }
-            // if we have no more instructions, see if there are any deferred branches to explore.
-            if (ih == null) {
-                final BranchTarget bt = branchTargets.pop();
-                if (bt != null) {
-                    ih = bt.target;
-                    stackDepth = bt.stackDepth;
-                }
-            }
+    public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging)
+        if (il != null) {
+            maxStack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers());
+        } else {
+            maxStack = 0;
         }
-        return maxStackDepth;
     }
 
-    private List<MethodObserver> observers;
-
-
-    /** Add observer for this object.
+    /**
+     * Set maximum stack size for this method.
      */
-    public void addObserver( final MethodObserver o ) {
-        if (observers == null) {
-            observers = new ArrayList<>();
-        }
-        observers.add(o);
+    public void setMaxStack(final int m) { // TODO could be package-protected?
+        maxStack = m;
     }
 
-
-    /** Remove observer for this object.
-     */
-    public void removeObserver( final MethodObserver o ) {
-        if (observers != null) {
-            observers.remove(o);
-        }
+    public void setReturnType(final Type returnType) {
+        setType(returnType);
     }
 
-
-    /** Call notify() method on all observers. This method is not called
-     * automatically whenever the state has changed, but has to be
-     * called by the user after he has finished editing the object.
+    /**
+     * Do not/Do produce attributes code attributesLineNumberTable and LocalVariableTable, like javac -O
      */
-    public void update() {
-        if (observers != null) {
-            for (final MethodObserver observer : observers) {
-                observer.notify(this);
-            }
-        }
+    public void stripAttributes(final boolean flag) {
+        stripAttributes = flag;
     }
 
-
     /**
-     * Return string representation close to declaration format,
-     * `public static void main(String[]) throws IOException', e.g.
+     * Return string representation close to declaration format, 'public static void main(String[]) throws IOException',
+     * e.g.
      *
      * @return String representation of the method.
      */
@@ -1130,16 +1129,15 @@ public void update() {
     public final String toString() {
         final String access = Utility.accessToString(super.getAccessFlags());
         String signature = Type.getMethodSignature(super.getType(), argTypes);
-        signature = Utility.methodSignatureToString(signature, super.getName(), access, true,
-                getLocalVariableTable(super.getConstantPool()));
+        signature = Utility.methodSignatureToString(signature, super.getName(), access, true, getLocalVariableTable(super.getConstantPool()));
         final StringBuilder buf = new StringBuilder(signature);
         for (final Attribute a : getAttributes()) {
-            if (!((a instanceof Code) || (a instanceof ExceptionTable))) {
+            if (!(a instanceof Code || a instanceof ExceptionTable)) {
                 buf.append(" [").append(a).append("]");
             }
         }
 
-        if (throwsList.size() > 0) {
+        if (!throwsList.isEmpty()) {
             for (final String throwsDescriptor : throwsList) {
                 buf.append("\n\t\tthrows ").append(throwsDescriptor);
             }
@@ -1147,162 +1145,31 @@ public final String toString() {
         return buf.toString();
     }
 
-
-    /** @return deep copy of this method
-     */
-    public MethodGen copy( final String className, final ConstantPoolGen cp ) {
-        final Method m = ((MethodGen) clone()).getMethod();
-        final MethodGen mg = new MethodGen(m, className, super.getConstantPool());
-        if (super.getConstantPool() != cp) {
-            mg.setConstantPool(cp);
-            mg.getInstructionList().replaceConstantPool(super.getConstantPool(), cp);
-        }
-        return mg;
-    }
-
-    //J5TODO: Should paramAnnotations be an array of arrays? Rather than an array of lists, this
-    // is more likely to suggest to the caller it is readonly (which a List does not).
-    /**
-     * Return a list of AnnotationGen objects representing parameter annotations
-     * @since 6.0
-     */
-    public List<AnnotationEntryGen> getAnnotationsOnParameter(final int i) {
-        ensureExistingParameterAnnotationsUnpacked();
-        if (!hasParameterAnnotations || i > argTypes.length) {
-            return null;
-        }
-        return paramAnnotations[i];
-    }
-
     /**
-     * Goes through the attributes on the method and identifies any that are
-     * RuntimeParameterAnnotations, extracting their contents and storing them
-     * as parameter annotations. There are two kinds of parameter annotation -
-     * visible and invisible. Once they have been unpacked, these attributes are
-     * deleted. (The annotations will be rebuilt as attributes when someone
-     * builds a Method object out of this MethodGen object).
+     * Call notify() method on all observers. This method is not called automatically whenever the state has changed, but
+     * has to be called by the user after they have finished editing the object.
      */
-    private void ensureExistingParameterAnnotationsUnpacked()
-    {
-        if (haveUnpackedParameterAnnotations) {
-            return;
-        }
-        // Find attributes that contain parameter annotation data
-        final Attribute[] attrs = getAttributes();
-        ParameterAnnotations paramAnnVisAttr = null;
-        ParameterAnnotations paramAnnInvisAttr = null;
-        for (final Attribute attribute : attrs) {
-            if (attribute instanceof ParameterAnnotations)
-            {
-                // Initialize paramAnnotations
-                if (!hasParameterAnnotations)
-                {
-                    @SuppressWarnings({"rawtypes", "unchecked"}) // OK
-                    final List<AnnotationEntryGen>[] parmList = new List[argTypes.length];
-                    paramAnnotations = parmList;
-                    for (int j = 0; j < argTypes.length; j++) {
-                        paramAnnotations[j] = new ArrayList<>();
-                    }
-                }
-                hasParameterAnnotations = true;
-                final ParameterAnnotations rpa = (ParameterAnnotations) attribute;
-                if (rpa instanceof RuntimeVisibleParameterAnnotations) {
-                    paramAnnVisAttr = rpa;
-                } else {
-                    paramAnnInvisAttr = rpa;
-                }
-                final ParameterAnnotationEntry[] parameterAnnotationEntries = rpa.getParameterAnnotationEntries();
-                for (int j = 0; j < parameterAnnotationEntries.length; j++)
-                {
-                    // This returns Annotation[] ...
-                    final ParameterAnnotationEntry immutableArray = rpa.getParameterAnnotationEntries()[j];
-                    // ... which needs transforming into an AnnotationGen[] ...
-                    final List<AnnotationEntryGen> mutable = makeMutableVersion(immutableArray.getAnnotationEntries());
-                    // ... then add these to any we already know about
-                    paramAnnotations[j].addAll(mutable);
-                }
+    public void update() {
+        if (observers != null) {
+            for (final MethodObserver observer : observers) {
+                observer.notify(this);
             }
         }
-        if (paramAnnVisAttr != null) {
-            removeAttribute(paramAnnVisAttr);
-        }
-        if (paramAnnInvisAttr != null) {
-            removeAttribute(paramAnnInvisAttr);
-        }
-        haveUnpackedParameterAnnotations = true;
-    }
-
-    private List<AnnotationEntryGen> makeMutableVersion(final AnnotationEntry[] mutableArray)
-    {
-        final List<AnnotationEntryGen> result = new ArrayList<>();
-        for (final AnnotationEntry element : mutableArray) {
-            result.add(new AnnotationEntryGen(element, getConstantPool(),
-                    false));
-        }
-        return result;
     }
 
-    public void addParameterAnnotation(final int parameterIndex,
-            final AnnotationEntryGen annotation)
-    {
-        ensureExistingParameterAnnotationsUnpacked();
-        if (!hasParameterAnnotations)
-        {
-            @SuppressWarnings({"rawtypes", "unchecked"})
-            final List<AnnotationEntryGen>[] parmList = new List[argTypes.length];
-            paramAnnotations = parmList;
-            hasParameterAnnotations = true;
-        }
-        final List<AnnotationEntryGen> existingAnnotations = paramAnnotations[parameterIndex];
-        if (existingAnnotations != null)
-        {
-            existingAnnotations.add(annotation);
-        }
-        else
-        {
-            final List<AnnotationEntryGen> l = new ArrayList<>();
-            l.add(annotation);
-            paramAnnotations[parameterIndex] = l;
+    private void updateLocalVariableTable(final LocalVariableTable a) {
+        removeLocalVariables();
+        for (final LocalVariable l : a.getLocalVariableTable()) {
+            InstructionHandle start = il.findHandle(l.getStartPC());
+            final InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
+            // Repair malformed handles
+            if (null == start) {
+                start = il.getStart();
+            }
+            // end == null => live to end of method
+            // Since we are recreating the LocalVaraible, we must
+            // propagate the orig_index to new copy.
+            addLocalVariable(l.getName(), Type.getType(l.getSignature()), l.getIndex(), start, end, l.getOrigIndex());
         }
     }
-
-    /**
-     * @return Comparison strategy object
-     */
-    public static BCELComparator getComparator() {
-        return bcelComparator;
-    }
-
-
-    /**
-     * @param comparator Comparison strategy object
-     */
-    public static void setComparator( final BCELComparator comparator ) {
-        bcelComparator = comparator;
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default two MethodGen objects are said to be equal when
-     * their names and signatures are equal.
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals( final Object obj ) {
-        return bcelComparator.equals(this, obj);
-    }
-
-
-    /**
-     * Return value as defined by given BCELComparator strategy.
-     * By default return the hashcode of the method's name XOR signature.
-     *
-     * @see java.lang.Object#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        return bcelComparator.hashCode(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodObserver.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodObserver.java
index e3e6899fa74..22e773ea4b7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodObserver.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodObserver.java
@@ -22,11 +22,10 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Implement this interface if you're interested in changes to a MethodGen object
- * and register yourself with addObserver().
- *
+ * Implement this interface if you're interested in changes to a MethodGen object and register yourself with
+ * addObserver().
  */
 public interface MethodObserver {
 
-    void notify( MethodGen method );
+    void notify(MethodGen method);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEW.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEW.java
index 58b233919f1..53b938581ee 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEW.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEW.java
@@ -25,49 +25,31 @@
 
 /**
  * NEW - Create new object
- * <PRE>Stack: ... -&gt; ..., objectref</PRE>
  *
+ * <PRE>
+ * Stack: ... -&gt; ..., objectref
+ * </PRE>
  */
-public class NEW extends CPInstruction implements LoadClass, AllocationInstruction,
-        ExceptionThrower, StackProducer {
+public class NEW extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower, StackProducer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     NEW() {
     }
 
-
     public NEW(final int index) {
         super(com.sun.org.apache.bcel.internal.Const.NEW, index);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION,
-            ExceptionConst.ILLEGAL_ACCESS_ERROR,
-            ExceptionConst.INSTANTIATION_ERROR);
-    }
-
-
-    @Override
-    public ObjectType getLoadClassType( final ConstantPoolGen cpg ) {
-        return (ObjectType) getType(cpg);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitLoadClass(this);
         v.visitAllocationInstruction(this);
         v.visitExceptionThrower(this);
@@ -76,4 +58,15 @@ public void accept( final Visitor v ) {
         v.visitCPInstruction(this);
         v.visitNEW(this);
     }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_CLASS_AND_INTERFACE_RESOLUTION, ExceptionConst.ILLEGAL_ACCESS_ERROR,
+            ExceptionConst.INSTANTIATION_ERROR);
+    }
+
+    @Override
+    public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
+        return (ObjectType) getType(cpg);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java
index e12aee50ced..be2c64a0953 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NEWARRAY.java
@@ -27,56 +27,64 @@
 import com.sun.org.apache.bcel.internal.util.ByteSequence;
 
 /**
- * NEWARRAY -  Create new array of basic type (int, short, ...)
- * <PRE>Stack: ..., count -&gt; ..., arrayref</PRE>
- * type must be one of T_INT, T_SHORT, ...
+ * NEWARRAY - Create new array of basic type (int, short, ...)
+ *
+ * <PRE>
+ * Stack: ..., count -&gt; ..., arrayref
+ * </PRE>
  *
+ * type must be one of T_INT, T_SHORT, ...
  * @LastModified: Jan 2020
  */
-public class NEWARRAY extends Instruction implements AllocationInstruction, ExceptionThrower,
-        StackProducer {
+public class NEWARRAY extends Instruction implements AllocationInstruction, ExceptionThrower, StackProducer {
 
     private byte type;
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     NEWARRAY() {
     }
 
+    public NEWARRAY(final BasicType type) {
+        this(type.getType());
+    }
 
     public NEWARRAY(final byte type) {
         super(com.sun.org.apache.bcel.internal.Const.NEWARRAY, (short) 2);
         this.type = type;
     }
 
-
-    public NEWARRAY(final BasicType type) {
-        this(type.getType());
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitAllocationInstruction(this);
+        v.visitExceptionThrower(this);
+        v.visitStackProducer(this);
+        v.visitNEWARRAY(this);
     }
 
-
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         out.writeByte(super.getOpcode());
         out.writeByte(type);
     }
 
-
-    /**
-     * @return numeric code for basic element type
-     */
-    public final byte getTypecode() {
-        return type;
+    @Override
+    public Class<?>[] getExceptions() {
+        return new Class<?>[] {ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION};
     }
 
-
     /**
      * @return type of constructed array
      */
@@ -84,47 +92,27 @@ public final Type getType() {
         return new ArrayType(BasicType.getType(type), 1);
     }
 
-
     /**
-     * @return mnemonic for instruction
+     * @return numeric code for basic element type
      */
-    @Override
-    public String toString( final boolean verbose ) {
-        return super.toString(verbose) + " " + com.sun.org.apache.bcel.internal.Const.getTypeName(type);
+    public final byte getTypecode() {
+        return type;
     }
 
-
     /**
      * Read needed data (e.g. index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         type = bytes.readByte();
         super.setLength(2);
     }
 
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.NEGATIVE_ARRAY_SIZE_EXCEPTION
-        };
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
+     * @return mnemonic for instruction
      */
     @Override
-    public void accept( final Visitor v ) {
-        v.visitAllocationInstruction(this);
-        v.visitExceptionThrower(this);
-        v.visitStackProducer(this);
-        v.visitNEWARRAY(this);
+    public String toString(final boolean verbose) {
+        return super.toString(verbose) + " " + com.sun.org.apache.bcel.internal.Const.getTypeName(type);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NOP.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NOP.java
index 4408334f365..37f73953e0a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NOP.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NOP.java
@@ -23,7 +23,6 @@
 
 /**
  * NOP - Do nothing
- *
  */
 public class NOP extends Instruction {
 
@@ -31,17 +30,14 @@ public NOP() {
         super(com.sun.org.apache.bcel.internal.Const.NOP, (short) 1);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitNOP(this);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java
index 58ea53cf497..3b79c821956 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NameSignatureInstruction.java
@@ -27,27 +27,36 @@
 import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
 
 /**
- * Super class for FieldOrMethod and INVOKEDYNAMIC, since they both have
- * names and signatures
+ * Super class for FieldOrMethod and INVOKEDYNAMIC, since they both have names and signatures
  *
  * @since 6.0
  */
 public abstract class NameSignatureInstruction extends CPInstruction {
 
     public NameSignatureInstruction() {
-        super();
     }
 
     public NameSignatureInstruction(final short opcode, final int index) {
         super(opcode, index);
     }
 
+    /**
+     * @return name of referenced method/field.
+     */
+    public String getName(final ConstantPoolGen cpg) {
+        final ConstantPool cp = cpg.getConstantPool();
+        final ConstantNameAndType cnat = getNameAndType(cpg);
+        return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
+    }
+
     public ConstantNameAndType getNameAndType(final ConstantPoolGen cpg) {
         final ConstantPool cp = cpg.getConstantPool();
         final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
-        return  (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
+        return (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
     }
-    /** @return signature of referenced method/field.
+
+    /**
+     * @return signature of referenced method/field.
      */
     public String getSignature(final ConstantPoolGen cpg) {
         final ConstantPool cp = cpg.getConstantPool();
@@ -55,12 +64,4 @@ public String getSignature(final ConstantPoolGen cpg) {
         return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
     }
 
-    /** @return name of referenced method/field.
-     */
-    public String getName(final ConstantPoolGen cpg) {
-        final ConstantPool cp = cpg.getConstantPool();
-        final ConstantNameAndType cnat = getNameAndType(cpg);
-        return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
-    }
-
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java
index 25d9a50a176..a46e7aa2dac 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/NamedAndTyped.java
@@ -22,20 +22,15 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denote entity that has both name and type. This is true for local variables,
- * methods and fields.
- *
+ * Denote entity that has both name and type. This is true for local variables, methods and fields.
  */
 public interface NamedAndTyped {
 
     String getName();
 
-
     Type getType();
 
+    void setName(String name);
 
-    void setName( String name );
-
-
-    void setType( Type type );
+    void setType(Type type);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java
index 13cb8eaa346..46378a1b71e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ObjectType.java
@@ -24,62 +24,78 @@
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.Repository;
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
+import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
  * Denotes reference such as java.lang.String.
- *
  */
 public class ObjectType extends ReferenceType {
 
-    private final String className; // Class name of type
-
     /**
+     * Constructs a new instance.
+     *
+     * @param className fully qualified class name, e.g. java.lang.String
+     * @return a new instance.
      * @since 6.0
      */
     public static ObjectType getInstance(final String className) {
         return new ObjectType(className);
     }
 
+    private final String className; // Class name of type
+
     /**
+     * Constructs a new instance.
+     *
      * @param className fully qualified class name, e.g. java.lang.String
      */
     public ObjectType(final String className) {
-        super(Const.T_REFERENCE, "L" + className.replace('.', '/') + ";");
-        this.className = className.replace('/', '.');
+        super(Const.T_REFERENCE, "L" + Utility.packageToPath(className) + ";");
+        this.className = Utility.pathToPackage(className);
     }
 
-
-    /** @return name of referenced class
+    /**
+     * Java Virtual Machine Specification edition 2,  5.4.4 Access Control
+     *
+     * @throws ClassNotFoundException if the class referenced by this type can't be found
      */
-    public String getClassName() {
-        return className;
+    public boolean accessibleTo(final ObjectType accessor) throws ClassNotFoundException {
+        final JavaClass jc = Repository.lookupClass(className);
+        if (jc.isPublic()) {
+            return true;
+        }
+        final JavaClass acc = Repository.lookupClass(accessor.className);
+        return acc.getPackageName().equals(jc.getPackageName());
     }
 
-
-    /** @return a hash code value for the object.
+    /**
+     * @return true if both type objects refer to the same class.
      */
     @Override
-    public int hashCode() {
-        return className.hashCode();
+    public boolean equals(final Object type) {
+        return type instanceof ObjectType && ((ObjectType) type).className.equals(className);
     }
 
-
-    /** @return true if both type objects refer to the same class.
+    /**
+     * @return name of referenced class
      */
     @Override
-    public boolean equals( final Object type ) {
-        return (type instanceof ObjectType)
-                ? ((ObjectType) type).className.equals(className)
-                : false;
+    public String getClassName() {
+        return className;
     }
 
+    /**
+     * @return a hash code value for the object.
+     */
+    @Override
+    public int hashCode() {
+        return className.hashCode();
+    }
 
     /**
-     * If "this" doesn't reference a class, it references an interface
-     * or a non-existant entity.
-     * @deprecated (since 6.0) this method returns an inaccurate result
-     *   if the class or interface referenced cannot
-     *   be found: use referencesClassExact() instead
+     * If "this" doesn't reference a class, it references an interface or a non-existant entity.
+     * @deprecated (since 6.0) this method returns an inaccurate result if the class or interface referenced cannot be
+     *             found: use referencesClassExact() instead
      */
     @Deprecated
     public boolean referencesClass() {
@@ -91,13 +107,22 @@ public boolean referencesClass() {
         }
     }
 
+    /**
+     * Return true if this type references a class, false if it references an interface.
+     *
+     * @return true if the type references a class, false if it references an interface
+     * @throws ClassNotFoundException if the class or interface referenced by this type can't be found
+     */
+    public boolean referencesClassExact() throws ClassNotFoundException {
+        final JavaClass jc = Repository.lookupClass(className);
+        return jc.isClass();
+    }
 
     /**
-     * If "this" doesn't reference an interface, it references a class
-     * or a non-existant entity.
-     * @deprecated (since 6.0) this method returns an inaccurate result
-     *   if the class or interface referenced cannot
-     *   be found: use referencesInterfaceExact() instead
+     * If "this" doesn't reference an interface, it references a class or a non-existant entity.
+     *
+     * @deprecated (since 6.0) this method returns an inaccurate result if the class or interface referenced cannot be
+     *             found: use referencesInterfaceExact() instead
      */
     @Deprecated
     public boolean referencesInterface() {
@@ -109,59 +134,26 @@ public boolean referencesInterface() {
         }
     }
 
-
     /**
-     * Return true if this type references a class,
-     * false if it references an interface.
-     * @return true if the type references a class, false if
-     *   it references an interface
-     * @throws ClassNotFoundException if the class or interface
-     *   referenced by this type can't be found
-     */
-    public boolean referencesClassExact() throws ClassNotFoundException {
-        final JavaClass jc = Repository.lookupClass(className);
-        return jc.isClass();
-    }
-
-
-    /**
-     * Return true if this type references an interface,
-     * false if it references a class.
-     * @return true if the type references an interface, false if
-     *   it references a class
-     * @throws ClassNotFoundException if the class or interface
-     *   referenced by this type can't be found
+     * Return true if this type references an interface, false if it references a class.
+     *
+     * @return true if the type references an interface, false if it references a class
+     * @throws ClassNotFoundException if the class or interface referenced by this type can't be found
      */
     public boolean referencesInterfaceExact() throws ClassNotFoundException {
         final JavaClass jc = Repository.lookupClass(className);
         return !jc.isClass();
     }
 
-
     /**
      * Return true if this type is a subclass of given ObjectType.
-     * @throws ClassNotFoundException if any of this class's superclasses
-     *  can't be found
+     *
+     * @throws ClassNotFoundException if any of this class's superclasses can't be found
      */
-    public boolean subclassOf( final ObjectType superclass ) throws ClassNotFoundException {
+    public boolean subclassOf(final ObjectType superclass) throws ClassNotFoundException {
         if (this.referencesInterfaceExact() || superclass.referencesInterfaceExact()) {
             return false;
         }
         return Repository.instanceOf(this.className, superclass.className);
     }
-
-
-    /**
-     * Java Virtual Machine Specification edition 2,  5.4.4 Access Control
-     * @throws ClassNotFoundException if the class referenced by this type
-     *   can't be found
-     */
-    public boolean accessibleTo( final ObjectType accessor ) throws ClassNotFoundException {
-        final JavaClass jc = Repository.lookupClass(className);
-        if (jc.isPublic()) {
-            return true;
-        }
-        final JavaClass acc = Repository.lookupClass(accessor.className);
-        return acc.getPackageName().equals(jc.getPackageName());
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP.java
index 9683a24cebf..e826dd78ce3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP.java
@@ -24,8 +24,9 @@
 /**
  * POP - Pop top operand stack word
  *
- * <PRE>Stack: ..., word -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., word -&gt; ...
+ * </PRE>
  */
 public class POP extends StackInstruction implements PopInstruction {
 
@@ -33,17 +34,14 @@ public POP() {
         super(com.sun.org.apache.bcel.internal.Const.POP);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitPopInstruction(this);
         v.visitStackInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP2.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP2.java
index 0f52de75fc1..5124f4177fc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP2.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/POP2.java
@@ -24,8 +24,9 @@
 /**
  * POP2 - Pop two top operand stack words
  *
- * <PRE>Stack: ..., word2, word1 -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ..., word2, word1 -&gt; ...
+ * </PRE>
  */
 public class POP2 extends StackInstruction implements PopInstruction {
 
@@ -33,17 +34,14 @@ public POP2() {
         super(com.sun.org.apache.bcel.internal.Const.POP2);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitPopInstruction(this);
         v.visitStackInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUSH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUSH.java
index 532575bc519..cac2027586f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUSH.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUSH.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,79 +20,61 @@
 
 package com.sun.org.apache.bcel.internal.generic;
 
+import java.util.Objects;
+
 import com.sun.org.apache.bcel.internal.Const;
 
 /**
- * Wrapper class for push operations, which are implemented either as BIPUSH,
- * LDC or xCONST_n instructions.
- *
- * @LastModified: Jan 2020
+ * Wrapper class for push operations, which are implemented either as BIPUSH, LDC or xCONST_n instructions.
+ * @LastModified: Feb 2023
  */
 public final class PUSH implements CompoundInstruction, VariableLengthInstruction {
 
-    private Instruction instruction;
-
+    private final Instruction instruction;
 
     /**
-     * This constructor also applies for values of type short, char, byte
+     * Pushes an array type constant, for example {@code int[].class}, {@code String[].class}, and so on.
      *
-     * @param cp Constant pool
-     * @param value to be pushed
+     * @param cp generated constant pool.
+     * @param value to be pushed.
+     * @since 6.7.0
      */
-    public PUSH(final ConstantPoolGen cp, final int value) {
-        if ((value >= -1) && (value <= 5)) {
-            instruction = InstructionConst.getInstruction(Const.ICONST_0 + value);
-        } else if (Instruction.isValidByte(value)) {
-            instruction = new BIPUSH((byte) value);
-        } else if (Instruction.isValidShort(value)) {
-            instruction = new SIPUSH((short) value);
+    public PUSH(final ConstantPoolGen cp, final ArrayType value) {
+        if (value == null) {
+            instruction = InstructionConst.ACONST_NULL;
         } else {
-            instruction = new LDC(cp.addInteger(value));
+            instruction = new LDC(cp.addArrayClass(value));
         }
     }
 
-
-    /**
+   /**
      * @param cp Constant pool
      * @param value to be pushed
      */
     public PUSH(final ConstantPoolGen cp, final boolean value) {
+        Objects.requireNonNull(cp, "cp");
         instruction = InstructionConst.getInstruction(Const.ICONST_0 + (value ? 1 : 0));
     }
 
-
     /**
      * @param cp Constant pool
      * @param value to be pushed
      */
-    public PUSH(final ConstantPoolGen cp, final float value) {
-        if (value == 0.0) {
-            instruction = InstructionConst.FCONST_0;
-        } else if (value == 1.0) {
-            instruction = InstructionConst.FCONST_1;
-        } else if (value == 2.0) {
-            instruction = InstructionConst.FCONST_2;
-        } else {
-            instruction = new LDC(cp.addFloat(value));
-        }
+    public PUSH(final ConstantPoolGen cp, final Boolean value) {
+        this(cp, value.booleanValue());
     }
 
-
     /**
+     * creates a push object from a Character value. Warning: Make sure not to attempt to allow autoboxing to create this
+     * value parameter, as an alternative constructor will be called
+     *
      * @param cp Constant pool
      * @param value to be pushed
      */
-    public PUSH(final ConstantPoolGen cp, final long value) {
-        if (value == 0) {
-            instruction = InstructionConst.LCONST_0;
-        } else if (value == 1) {
-            instruction = InstructionConst.LCONST_1;
-        } else {
-            instruction = new LDC2_W(cp.addLong(value));
-        }
+    public PUSH(final ConstantPoolGen cp, final Character value) {
+        this(cp, value.charValue());
     }
 
-
     /**
      * @param cp Constant pool
      * @param value to be pushed
@@ -107,30 +89,51 @@ public PUSH(final ConstantPoolGen cp, final double value) {
         }
     }
 
-
     /**
      * @param cp Constant pool
      * @param value to be pushed
      */
-    public PUSH(final ConstantPoolGen cp, final String value) {
-        if (value == null) {
-            instruction = InstructionConst.ACONST_NULL;
+    public PUSH(final ConstantPoolGen cp, final float value) {
+        if (value == 0.0) {
+            instruction = InstructionConst.FCONST_0;
+        } else if (value == 1.0) {
+            instruction = InstructionConst.FCONST_1;
+        } else if (value == 2.0) {
+            instruction = InstructionConst.FCONST_2;
         } else {
-            instruction = new LDC(cp.addString(value));
+            instruction = new LDC(cp.addFloat(value));
         }
     }
 
     /**
+     * This constructor also applies for values of type short, char, byte
      *
-     * @param cp
-     * @param value
-     * @since 6.0
+     * @param cp Constant pool
+     * @param value to be pushed
      */
-    public PUSH(final ConstantPoolGen cp, final ObjectType value) {
-        if (value == null) {
-            instruction = InstructionConst.ACONST_NULL;
+    public PUSH(final ConstantPoolGen cp, final int value) {
+        if (value >= -1 && value <= 5) {
+            instruction = InstructionConst.getInstruction(Const.ICONST_0 + value);
+        } else if (Instruction.isValidByte(value)) {
+            instruction = new BIPUSH((byte) value);
+        } else if (Instruction.isValidShort(value)) {
+            instruction = new SIPUSH((short) value);
         } else {
-            instruction = new LDC(cp.addClass(value));
+            instruction = new LDC(cp.addInteger(value));
+        }
+    }
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed
+     */
+    public PUSH(final ConstantPoolGen cp, final long value) {
+        if (value == 0) {
+            instruction = InstructionConst.LCONST_0;
+        } else if (value == 1) {
+            instruction = InstructionConst.LCONST_1;
+        } else {
+            instruction = new LDC2_W(cp.addLong(value));
         }
     }
 
@@ -139,7 +142,7 @@ public PUSH(final ConstantPoolGen cp, final ObjectType value) {
      * @param value to be pushed
      */
     public PUSH(final ConstantPoolGen cp, final Number value) {
-        if ((value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)) {
+        if (value instanceof Integer || value instanceof Short || value instanceof Byte) {
             instruction = new PUSH(cp, value.intValue()).instruction;
         } else if (value instanceof Double) {
             instruction = new PUSH(cp, value.doubleValue()).instruction;
@@ -152,39 +155,41 @@ public PUSH(final ConstantPoolGen cp, final Number value) {
         }
     }
 
-
     /**
-     * creates a push object from a Character value. Warning: Make sure not to attempt to allow
-     * autoboxing to create this value parameter, as an alternative constructor will be called
      *
-     * @param cp Constant pool
-     * @param value to be pushed
+     * @param cp
+     * @param value
+     * @since 6.0
      */
-    public PUSH(final ConstantPoolGen cp, final Character value) {
-        this(cp, value.charValue());
+    public PUSH(final ConstantPoolGen cp, final ObjectType value) {
+        if (value == null) {
+            instruction = InstructionConst.ACONST_NULL;
+        } else {
+            instruction = new LDC(cp.addClass(value));
+        }
     }
 
-
     /**
      * @param cp Constant pool
      * @param value to be pushed
      */
-    public PUSH(final ConstantPoolGen cp, final Boolean value) {
-        this(cp, value.booleanValue());
+    public PUSH(final ConstantPoolGen cp, final String value) {
+        if (value == null) {
+            instruction = InstructionConst.ACONST_NULL;
+        } else {
+            instruction = new LDC(cp.addString(value));
+        }
     }
 
+    public Instruction getInstruction() {
+        return instruction;
+    }
 
     @Override
     public InstructionList getInstructionList() {
         return new InstructionList(instruction);
     }
 
-
-    public Instruction getInstruction() {
-        return instruction;
-    }
-
-
     /**
      * @return mnemonic for instruction
      */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java
index 10979bd2374..185a014774b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTFIELD.java
@@ -26,50 +26,37 @@
 
 /**
  * PUTFIELD - Put field in object
- * <PRE>Stack: ..., objectref, value -&gt; ...</PRE>
+ *
+ * <PRE>
+ * Stack: ..., objectref, value -&gt; ...
+ * </PRE>
+ *
  * OR
- * <PRE>Stack: ..., objectref, value.word1, value.word2 -&gt; ...</PRE>
  *
+ * <PRE>
+ * Stack: ..., objectref, value.word1, value.word2 -&gt; ...
+ * </PRE>
  */
 public class PUTFIELD extends FieldInstruction implements PopInstruction, ExceptionThrower {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     PUTFIELD() {
     }
 
-
     public PUTFIELD(final int index) {
         super(Const.PUTFIELD, index);
     }
 
-
-    @Override
-    public int consumeStack( final ConstantPoolGen cpg ) {
-        return getFieldSize(cpg) + 1;
-    }
-
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
-            ExceptionConst.NULL_POINTER_EXCEPTION,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitStackConsumer(this);
         v.visitPopInstruction(this);
@@ -80,4 +67,15 @@ public void accept( final Visitor v ) {
         v.visitFieldInstruction(this);
         v.visitPUTFIELD(this);
     }
+
+    @Override
+    public int consumeStack(final ConstantPoolGen cpg) {
+        return getFieldSize(cpg) + 1;
+    }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.NULL_POINTER_EXCEPTION,
+            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java
index 0a482566844..f74ec347e9d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PUTSTATIC.java
@@ -26,49 +26,37 @@
 
 /**
  * PUTSTATIC - Put static field in class
- * <PRE>Stack: ..., value -&gt; ...</PRE>
+ *
+ * <PRE>
+ * Stack: ..., value -&gt; ...
+ * </PRE>
+ *
  * OR
- * <PRE>Stack: ..., value.word1, value.word2 -&gt; ...</PRE>
  *
+ * <PRE>
+ * Stack: ..., value.word1, value.word2 -&gt; ...
+ * </PRE>
  */
 public class PUTSTATIC extends FieldInstruction implements ExceptionThrower, PopInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     PUTSTATIC() {
     }
 
-
     public PUTSTATIC(final int index) {
         super(Const.PUTSTATIC, index);
     }
 
-
-    @Override
-    public int consumeStack( final ConstantPoolGen cpg ) {
-        return getFieldSize(cpg);
-    }
-
-
-    @Override
-    public Class<?>[] getExceptions() {
-        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
-            ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
-    }
-
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitStackConsumer(this);
         v.visitPopInstruction(this);
@@ -79,4 +67,14 @@ public void accept( final Visitor v ) {
         v.visitFieldInstruction(this);
         v.visitPUTSTATIC(this);
     }
+
+    @Override
+    public int consumeStack(final ConstantPoolGen cpg) {
+        return getFieldSize(cpg);
+    }
+
+    @Override
+    public Class<?>[] getExceptions() {
+        return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PopInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PopInstruction.java
index e9ac138377f..206299930e3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PopInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PopInstruction.java
@@ -22,8 +22,7 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denotes an unparameterized instruction to pop a value on top from the stack,
- * such as ISTORE, POP, PUTSTATIC.
+ * Denotes an unparameterized instruction to pop a value on top from the stack, such as ISTORE, POP, PUTSTATIC.
  *
  * @see ISTORE
  * @see POP
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PushInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PushInstruction.java
index 6359f85ef6b..e792b38a83f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PushInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/PushInstruction.java
@@ -22,10 +22,10 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denotes an unparameterized instruction to produce a value on top of the stack,
- * such as ILOAD, LDC, SIPUSH, DUP, ICONST, etc.
+ * Denotes an unparameterized instruction to produce a value on top of the stack, such as ILOAD, LDC, SIPUSH, DUP,
+ * ICONST, etc.
+ *
  *
-
  * @see ILOAD
  * @see ICONST
  * @see LDC
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RET.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RET.java
index e6d2c99fbd4..a7cacc7c165 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RET.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RET.java
@@ -29,35 +29,44 @@
 /**
  * RET - Return from subroutine
  *
- * <PRE>Stack: ... -&gt; ...</PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ...
+ * </PRE>
  */
 public class RET extends Instruction implements IndexedInstruction, TypedInstruction {
 
     private boolean wide;
     private int index; // index to local variable containg the return address
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     RET() {
     }
 
-
     public RET(final int index) {
         super(com.sun.org.apache.bcel.internal.Const.RET, (short) 2);
         setIndex(index); // May set wide as side effect
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitRET(this);
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         if (wide) {
             out.writeByte(com.sun.org.apache.bcel.internal.Const.WIDE);
         }
@@ -69,22 +78,27 @@ public void dump( final DataOutputStream out ) throws IOException {
         }
     }
 
-
-    private void setWide() {
-        wide = index > com.sun.org.apache.bcel.internal.Const.MAX_BYTE;
-        if (wide) {
-            super.setLength(4); // Including the wide byte
-        } else {
-            super.setLength(2);
-        }
+    /**
+     * @return index of local variable containg the return address
+     */
+    @Override
+    public final int getIndex() {
+        return index;
     }
 
+    /**
+     * @return return address type
+     */
+    @Override
+    public Type getType(final ConstantPoolGen cp) {
+        return ReturnaddressType.NO_TARGET;
+    }
 
     /**
      * Read needed data (e.g. index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         this.wide = wide;
         if (wide) {
             index = bytes.readUnsignedShort();
@@ -95,21 +109,11 @@ protected void initFromFile( final ByteSequence bytes, final boolean wide ) thro
         }
     }
 
-
-    /**
-     * @return index of local variable containg the return address
-     */
-    @Override
-    public final int getIndex() {
-        return index;
-    }
-
-
     /**
      * Set index of local variable containg the return address
      */
     @Override
-    public final void setIndex( final int n ) {
+    public final void setIndex(final int n) {
         if (n < 0) {
             throw new ClassGenException("Negative index value: " + n);
         }
@@ -117,34 +121,20 @@ public final void setIndex( final int n ) {
         setWide();
     }
 
+    private void setWide() {
+        wide = index > com.sun.org.apache.bcel.internal.Const.MAX_BYTE;
+        if (wide) {
+            super.setLength(4); // Including the wide byte
+        } else {
+            super.setLength(2);
+        }
+    }
 
     /**
      * @return mnemonic for instruction
      */
     @Override
-    public String toString( final boolean verbose ) {
+    public String toString(final boolean verbose) {
         return super.toString(verbose) + " " + index;
     }
-
-
-    /** @return return address type
-     */
-    @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return ReturnaddressType.NO_TARGET;
-    }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitRET(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RETURN.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RETURN.java
index 271d2c91e2c..0e6b594fafa 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RETURN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RETURN.java
@@ -22,9 +22,11 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * RETURN -  Return from void method
- * <PRE>Stack: ... -&gt; &lt;empty&gt;</PRE>
+ * RETURN - Return from void method
  *
+ * <PRE>
+ * Stack: ... -&gt; &lt;empty&gt;
+ * </PRE>
  */
 public class RETURN extends ReturnInstruction {
 
@@ -32,17 +34,14 @@ public RETURN() {
         super(com.sun.org.apache.bcel.internal.Const.RETURN);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java
index ebe3db5cfbf..fe75792e213 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java
@@ -26,133 +26,204 @@
 
 /**
  * Super class for object and array types.
- *
  */
 public abstract class ReferenceType extends Type {
 
+    /**
+     * Class is non-abstract but not instantiable from the outside
+     */
+    ReferenceType() {
+        super(Const.T_OBJECT, "<null object>");
+    }
+
     protected ReferenceType(final byte t, final String s) {
         super(t, s);
     }
 
-
-    /** Class is non-abstract but not instantiable from the outside
+    /**
+     * This commutative operation returns the first common superclass (narrowest ReferenceType referencing a class, not an
+     * interface). If one of the types is a superclass of the other, the former is returned. If "this" is Type.NULL, then t
+     * is returned. If t is Type.NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If
+     * "this" or t is an ArrayType, then Type.OBJECT is returned. If "this" or t is a ReferenceType referencing an
+     * interface, then Type.OBJECT is returned. If not all of the two classes' superclasses cannot be found, "null" is
+     * returned. See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
+     *
+     * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has slightly changed semantics.
+     * @throws ClassNotFoundException on failure to find superclasses of this type, or the type passed as a parameter
      */
-    ReferenceType() {
-        super(Const.T_OBJECT, "<null object>");
+    @Deprecated
+    public ReferenceType firstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException {
+        if (this.equals(Type.NULL)) {
+            return t;
+        }
+        if (t.equals(Type.NULL) || this.equals(t)) {
+            return this;
+            /*
+             * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by Type.NULL so we can also
+             * say all the objects referenced by Type.NULL were derived from java.lang.Object. However, the Java Language's
+             * "instanceof" operator proves us wrong: "null" is not referring to an instance of java.lang.Object :)
+             */
+        }
+        if (this instanceof ArrayType || t instanceof ArrayType) {
+            return Type.OBJECT;
+            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
+        }
+        return getFirstCommonSuperclassInternal(t);
     }
 
-
     /**
-     * Return true iff this type is castable to another type t as defined in
-     * the JVM specification.  The case where this is Type.NULL is not
-     * defined (see the CHECKCAST definition in the JVM specification).
-     * However, because e.g. CHECKCAST doesn't throw a
-     * ClassCastException when casting a null reference to any Object,
-     * true is returned in this case.
+     * This commutative operation returns the first common superclass (narrowest ReferenceType referencing a class, not an
+     * interface). If one of the types is a superclass of the other, the former is returned. If "this" is Type.NULL, then t
+     * is returned. If t is Type.NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If
+     * "this" or t is an ArrayType, then Type.OBJECT is returned; unless their dimensions match. Then an ArrayType of the
+     * same number of dimensions is returned, with its basic type being the first common super class of the basic types of
+     * "this" and t. If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned. If not all of
+     * the two classes' superclasses cannot be found, "null" is returned. See the JVM specification edition 2, "4.9.2 The
+     * Bytecode Verifier".
      *
-     * @throws ClassNotFoundException if any classes or interfaces required
-     *  to determine assignment compatibility can't be found
+     * @throws ClassNotFoundException on failure to find superclasses of this type, or the type passed as a parameter
      */
-    public boolean isCastableTo( final Type t ) throws ClassNotFoundException {
+    public ReferenceType getFirstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException {
         if (this.equals(Type.NULL)) {
-            return t instanceof ReferenceType; // If this is ever changed in isAssignmentCompatible()
+            return t;
         }
-        return isAssignmentCompatibleWith(t);
-        /* Yes, it's true: It's the same definition.
-         * See vmspec2 AASTORE / CHECKCAST definitions.
-         */
+        if (t.equals(Type.NULL) || this.equals(t)) {
+            return this;
+            /*
+             * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by Type.NULL so we can also
+             * say all the objects referenced by Type.NULL were derived from java.lang.Object. However, the Java Language's
+             * "instanceof" operator proves us wrong: "null" is not referring to an instance of java.lang.Object :)
+             */
+        }
+        /* This code is from a bug report by Konstantin Shagin <konst@cs.technion.ac.il> */
+        if (this instanceof ArrayType && t instanceof ArrayType) {
+            final ArrayType arrType1 = (ArrayType) this;
+            final ArrayType arrType2 = (ArrayType) t;
+            if (arrType1.getDimensions() == arrType2.getDimensions() && arrType1.getBasicType() instanceof ObjectType
+                && arrType2.getBasicType() instanceof ObjectType) {
+                return new ArrayType(((ObjectType) arrType1.getBasicType()).getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()),
+                    arrType1.getDimensions());
+            }
+        }
+        if (this instanceof ArrayType || t instanceof ArrayType) {
+            return Type.OBJECT;
+            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
+        }
+        return getFirstCommonSuperclassInternal(t);
     }
 
+    private ReferenceType getFirstCommonSuperclassInternal(final ReferenceType t) throws ClassNotFoundException {
+        if (this instanceof ObjectType && ((ObjectType) this).referencesInterfaceExact()
+            || t instanceof ObjectType && ((ObjectType) t).referencesInterfaceExact()) {
+            return Type.OBJECT;
+            // TODO: The above line is correct comparing to the vmspec2. But one could
+            // make class file verification a bit stronger here by using the notion of
+            // superinterfaces or even castability or assignment compatibility.
+        }
+        // this and t are ObjectTypes, see above.
+        final ObjectType thiz = (ObjectType) this;
+        final ObjectType other = (ObjectType) t;
+        final JavaClass[] thizSups = Repository.getSuperClasses(thiz.getClassName());
+        final JavaClass[] otherSups = Repository.getSuperClasses(other.getClassName());
+        if (thizSups == null || otherSups == null) {
+            return null;
+        }
+        // Waaahh...
+        final JavaClass[] thisSups = new JavaClass[thizSups.length + 1];
+        final JavaClass[] tSups = new JavaClass[otherSups.length + 1];
+        System.arraycopy(thizSups, 0, thisSups, 1, thizSups.length);
+        System.arraycopy(otherSups, 0, tSups, 1, otherSups.length);
+        thisSups[0] = Repository.lookupClass(thiz.getClassName());
+        tSups[0] = Repository.lookupClass(other.getClassName());
+        for (final JavaClass tSup : tSups) {
+            for (final JavaClass thisSup : thisSups) {
+                if (thisSup.equals(tSup)) {
+                    return ObjectType.getInstance(thisSup.getClassName());
+                }
+            }
+        }
+        // Huh? Did you ask for Type.OBJECT's superclass??
+        return null;
+    }
 
     /**
-     * Return true iff this is assignment compatible with another type t
-     * as defined in the JVM specification; see the AASTORE definition
-     * there.
-     * @throws ClassNotFoundException if any classes or interfaces required
-     *  to determine assignment compatibility can't be found
+     * Return true iff this is assignment compatible with another type t as defined in the JVM specification; see the
+     * AASTORE definition there.
+     *
+     * @throws ClassNotFoundException if any classes or interfaces required to determine assignment compatibility can't be
+     *         found
      */
-    public boolean isAssignmentCompatibleWith( final Type t ) throws ClassNotFoundException {
+    public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundException {
         if (!(t instanceof ReferenceType)) {
             return false;
         }
         final ReferenceType T = (ReferenceType) t;
         if (this.equals(Type.NULL)) {
-            return true; // This is not explicitely stated, but clear. Isn't it?
+            return true; // This is not explicitly stated, but clear. Isn't it?
         }
-        /* If this is a class type then
+        /*
+         * If this is a class type then
          */
-        if ((this instanceof ObjectType) && (((ObjectType) this).referencesClassExact())) {
-            /* If T is a class type, then this must be the same class as T,
-             or this must be a subclass of T;
+        if (this instanceof ObjectType && ((ObjectType) this).referencesClassExact()) {
+            /*
+             * If T is a class type, then this must be the same class as T, or this must be a subclass of T;
              */
-            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
-                if (this.equals(T)) {
-                    return true;
-                }
-                if (Repository.instanceOf(((ObjectType) this).getClassName(), ((ObjectType) T)
-                        .getClassName())) {
-                    return true;
-                }
+            if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact()
+                && (this.equals(T) || Repository.instanceOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) {
+                return true;
             }
-            /* If T is an interface type, this must implement interface T.
+            /*
+             * If T is an interface type, this must implement interface T.
              */
-            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
-                if (Repository.implementationOf(((ObjectType) this).getClassName(),
-                        ((ObjectType) T).getClassName())) {
-                    return true;
-                }
+            if (T instanceof ObjectType && ((ObjectType) T).referencesInterfaceExact()
+                && Repository.implementationOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName())) {
+                return true;
             }
         }
-        /* If this is an interface type, then:
+        /*
+         * If this is an interface type, then:
          */
-        if ((this instanceof ObjectType) && (((ObjectType) this).referencesInterfaceExact())) {
-            /* If T is a class type, then T must be Object (2.4.7).
+        if (this instanceof ObjectType && ((ObjectType) this).referencesInterfaceExact()) {
+            /*
+             * If T is a class type, then T must be Object (2.4.7).
              */
-            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
-                if (T.equals(Type.OBJECT)) {
-                    return true;
-                }
+            if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(Type.OBJECT)) {
+                return true;
             }
-            /* If T is an interface type, then T must be the same interface
-             * as this or a superinterface of this (2.13.2).
+            /*
+             * If T is an interface type, then T must be the same interface as this or a superinterface of this (2.13.2).
              */
-            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
-                if (this.equals(T)) {
-                    return true;
-                }
-                if (Repository.implementationOf(((ObjectType) this).getClassName(),
-                        ((ObjectType) T).getClassName())) {
-                    return true;
-                }
+            if (T instanceof ObjectType && ((ObjectType) T).referencesInterfaceExact()
+                && (this.equals(T) || Repository.implementationOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) {
+                return true;
             }
         }
-        /* If this is an array type, namely, the type SC[], that is, an
-         * array of components of type SC, then:
+        /*
+         * If this is an array type, namely, the type SC[], that is, an array of components of type SC, then:
          */
         if (this instanceof ArrayType) {
-            /* If T is a class type, then T must be Object (2.4.7).
+            /*
+             * If T is a class type, then T must be Object (2.4.7).
              */
-            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
-                if (T.equals(Type.OBJECT)) {
-                    return true;
-                }
+            if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(Type.OBJECT)) {
+                return true;
             }
-            /* If T is an array type TC[], that is, an array of components
-             * of type TC, then one of the following must be true:
+            /*
+             * If T is an array type TC[], that is, an array of components of type TC, then one of the following must be true:
              */
             if (T instanceof ArrayType) {
-                /* TC and SC are the same primitive type (2.4.1).
+                /*
+                 * TC and SC are the same primitive type (2.4.1).
                  */
                 final Type sc = ((ArrayType) this).getElementType();
                 final Type tc = ((ArrayType) T).getElementType();
                 if (sc instanceof BasicType && tc instanceof BasicType && sc.equals(tc)) {
                     return true;
                 }
-                /* TC and SC are reference types (2.4.6), and type SC is
-                 * assignable to TC by these runtime rules.
+                /*
+                 * TC and SC are reference types (2.4.6), and type SC is assignable to TC by these runtime rules.
                  */
-                if (tc instanceof ReferenceType && sc instanceof ReferenceType
-                        && ((ReferenceType) sc).isAssignmentCompatibleWith(tc)) {
+                if (tc instanceof ReferenceType && sc instanceof ReferenceType && ((ReferenceType) sc).isAssignmentCompatibleWith(tc)) {
                     return true;
                 }
             }
@@ -162,7 +233,7 @@ public boolean isAssignmentCompatibleWith( final Type t ) throws ClassNotFoundEx
             // are at least two different pages where assignment compatibility is defined and
             // on one of them "interfaces implemented by arrays" is exchanged with "'Cloneable' or
             // 'java.io.Serializable'"
-            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
+            if (T instanceof ObjectType && ((ObjectType) T).referencesInterfaceExact()) {
                 for (final String element : Const.getInterfacesImplementedByArrays()) {
                     if (T.equals(ObjectType.getInstance(element))) {
                         return true;
@@ -173,160 +244,21 @@ public boolean isAssignmentCompatibleWith( final Type t ) throws ClassNotFoundEx
         return false; // default.
     }
 
-
     /**
-     * This commutative operation returns the first common superclass (narrowest ReferenceType
-     * referencing a class, not an interface).
-     * If one of the types is a superclass of the other, the former is returned.
-     * If "this" is Type.NULL, then t is returned.
-     * If t is Type.NULL, then "this" is returned.
-     * If "this" equals t ['this.equals(t)'] "this" is returned.
-     * If "this" or t is an ArrayType, then Type.OBJECT is returned;
-     * unless their dimensions match. Then an ArrayType of the same
-     * number of dimensions is returned, with its basic type being the
-     * first common super class of the basic types of "this" and t.
-     * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
-     * If not all of the two classes' superclasses cannot be found, "null" is returned.
-     * See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
+     * Return true iff this type is castable to another type t as defined in the JVM specification. The case where this is
+     * Type.NULL is not defined (see the CHECKCAST definition in the JVM specification). However, because e.g. CHECKCAST
+     * doesn't throw a ClassCastException when casting a null reference to any Object, true is returned in this case.
      *
-     * @throws ClassNotFoundException on failure to find superclasses of this
-     *  type, or the type passed as a parameter
+     * @throws ClassNotFoundException if any classes or interfaces required to determine assignment compatibility can't be
+     *         found
      */
-    public ReferenceType getFirstCommonSuperclass( final ReferenceType t ) throws ClassNotFoundException {
+    public boolean isCastableTo(final Type t) throws ClassNotFoundException {
         if (this.equals(Type.NULL)) {
-            return t;
-        }
-        if (t.equals(Type.NULL)) {
-            return this;
-        }
-        if (this.equals(t)) {
-            return this;
-            /*
-             * TODO: Above sounds a little arbitrary. On the other hand, there is
-             * no object referenced by Type.NULL so we can also say all the objects
-             * referenced by Type.NULL were derived from java.lang.Object.
-             * However, the Java Language's "instanceof" operator proves us wrong:
-             * "null" is not referring to an instance of java.lang.Object :)
-             */
-        }
-        /* This code is from a bug report by Konstantin Shagin <konst@cs.technion.ac.il> */
-        if ((this instanceof ArrayType) && (t instanceof ArrayType)) {
-            final ArrayType arrType1 = (ArrayType) this;
-            final ArrayType arrType2 = (ArrayType) t;
-            if ((arrType1.getDimensions() == arrType2.getDimensions())
-                    && arrType1.getBasicType() instanceof ObjectType
-                    && arrType2.getBasicType() instanceof ObjectType) {
-                return new ArrayType(((ObjectType) arrType1.getBasicType())
-                        .getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()), arrType1
-                        .getDimensions());
-            }
-        }
-        if ((this instanceof ArrayType) || (t instanceof ArrayType)) {
-            return Type.OBJECT;
-            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
-        }
-        if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterfaceExact())
-                || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterfaceExact())) {
-            return Type.OBJECT;
-            // TODO: The above line is correct comparing to the vmspec2. But one could
-            // make class file verification a bit stronger here by using the notion of
-            // superinterfaces or even castability or assignment compatibility.
-        }
-        // this and t are ObjectTypes, see above.
-        final ObjectType thiz = (ObjectType) this;
-        final ObjectType other = (ObjectType) t;
-        final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
-        final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
-        if ((thiz_sups == null) || (other_sups == null)) {
-            return null;
-        }
-        // Waaahh...
-        final JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
-        final JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
-        System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
-        System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
-        this_sups[0] = Repository.lookupClass(thiz.getClassName());
-        t_sups[0] = Repository.lookupClass(other.getClassName());
-        for (final JavaClass t_sup : t_sups) {
-            for (final JavaClass this_sup : this_sups) {
-                if (this_sup.equals(t_sup)) {
-                    return ObjectType.getInstance(this_sup.getClassName());
-                }
-            }
-        }
-        // Huh? Did you ask for Type.OBJECT's superclass??
-        return null;
-    }
-
-    /**
-     * This commutative operation returns the first common superclass (narrowest ReferenceType
-     * referencing a class, not an interface).
-     * If one of the types is a superclass of the other, the former is returned.
-     * If "this" is Type.NULL, then t is returned.
-     * If t is Type.NULL, then "this" is returned.
-     * If "this" equals t ['this.equals(t)'] "this" is returned.
-     * If "this" or t is an ArrayType, then Type.OBJECT is returned.
-     * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
-     * If not all of the two classes' superclasses cannot be found, "null" is returned.
-     * See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
-     *
-     * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
-     *             slightly changed semantics.
-     * @throws ClassNotFoundException on failure to find superclasses of this
-     *  type, or the type passed as a parameter
-     */
-    @Deprecated
-    public ReferenceType firstCommonSuperclass( final ReferenceType t ) throws ClassNotFoundException {
-        if (this.equals(Type.NULL)) {
-            return t;
-        }
-        if (t.equals(Type.NULL)) {
-            return this;
-        }
-        if (this.equals(t)) {
-            return this;
-            /*
-             * TODO: Above sounds a little arbitrary. On the other hand, there is
-             * no object referenced by Type.NULL so we can also say all the objects
-             * referenced by Type.NULL were derived from java.lang.Object.
-             * However, the Java Language's "instanceof" operator proves us wrong:
-             * "null" is not referring to an instance of java.lang.Object :)
-             */
-        }
-        if ((this instanceof ArrayType) || (t instanceof ArrayType)) {
-            return Type.OBJECT;
-            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
-        }
-        if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface())
-                || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface())) {
-            return Type.OBJECT;
-            // TODO: The above line is correct comparing to the vmspec2. But one could
-            // make class file verification a bit stronger here by using the notion of
-            // superinterfaces or even castability or assignment compatibility.
-        }
-        // this and t are ObjectTypes, see above.
-        final ObjectType thiz = (ObjectType) this;
-        final ObjectType other = (ObjectType) t;
-        final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
-        final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
-        if ((thiz_sups == null) || (other_sups == null)) {
-            return null;
-        }
-        // Waaahh...
-        final JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
-        final JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
-        System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
-        System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
-        this_sups[0] = Repository.lookupClass(thiz.getClassName());
-        t_sups[0] = Repository.lookupClass(other.getClassName());
-        for (final JavaClass t_sup : t_sups) {
-            for (final JavaClass this_sup : this_sups) {
-                if (this_sup.equals(t_sup)) {
-                    return ObjectType.getInstance(this_sup.getClassName());
-                }
-            }
+            return t instanceof ReferenceType; // If this is ever changed in isAssignmentCompatible()
         }
-        // Huh? Did you ask for Type.OBJECT's superclass??
-        return null;
+        return isAssignmentCompatibleWith(t);
+        /*
+         * Yes, it's true: It's the same definition. See vmspec2 AASTORE / CHECKCAST definitions.
+         */
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java
index 90a0fcbc72d..0e132f431c4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnInstruction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,19 +26,16 @@
 /**
  * Super class for the xRETURN family of instructions.
  *
- * @LastModified: Jan 2020
+ * @LastModified: Feb 2023
  */
-public abstract class ReturnInstruction extends Instruction implements ExceptionThrower,
-        TypedInstruction, StackConsumer {
+public abstract class ReturnInstruction extends Instruction implements ExceptionThrower, TypedInstruction, StackConsumer {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ReturnInstruction() {
     }
 
-
     /**
      * @param opcode of instruction
      */
@@ -46,40 +43,36 @@ protected ReturnInstruction(final short opcode) {
         super(opcode, (short) 1);
     }
 
-
-    public Type getType() {
-        final short _opcode = super.getOpcode();
-        switch (_opcode) {
-            case Const.IRETURN:
-                return Type.INT;
-            case Const.LRETURN:
-                return Type.LONG;
-            case Const.FRETURN:
-                return Type.FLOAT;
-            case Const.DRETURN:
-                return Type.DOUBLE;
-            case Const.ARETURN:
-                return Type.OBJECT;
-            case Const.RETURN:
-                return Type.VOID;
-            default: // Never reached
-                throw new ClassGenException("Unknown type " + _opcode);
-        }
-    }
-
-
     @Override
     public Class<?>[] getExceptions() {
-        return new Class<?>[] {
-            ExceptionConst.ILLEGAL_MONITOR_STATE
-        };
+        return new Class<?>[] {ExceptionConst.ILLEGAL_MONITOR_STATE};
     }
 
+    public Type getType() {
+        final short opcode = super.getOpcode();
+        switch (opcode) {
+        case Const.IRETURN:
+            return Type.INT;
+        case Const.LRETURN:
+            return Type.LONG;
+        case Const.FRETURN:
+            return Type.FLOAT;
+        case Const.DRETURN:
+            return Type.DOUBLE;
+        case Const.ARETURN:
+            return Type.OBJECT;
+        case Const.RETURN:
+            return Type.VOID;
+        default: // Never reached
+            throw new ClassGenException("Unknown type " + opcode);
+        }
+    }
 
-    /** @return type associated with the instruction
+    /**
+     * @return type associated with the instruction
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
+    public Type getType(final ConstantPoolGen cp) {
         return getType();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java
index 63ba12a15b7..a35e83d26fd 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java
@@ -33,7 +33,6 @@ public class ReturnaddressType extends Type {
     public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
     private InstructionHandle returnTarget;
 
-
     /**
      * A Returnaddress [that doesn't know where to return to].
      */
@@ -41,7 +40,6 @@ private ReturnaddressType() {
         super(Const.T_ADDRESS, "<return address>");
     }
 
-
     /**
      * Creates a ReturnaddressType object with a target.
      */
@@ -50,23 +48,11 @@ public ReturnaddressType(final InstructionHandle returnTarget) {
         this.returnTarget = returnTarget;
     }
 
-
-    /** @return a hash code value for the object.
-     */
-    @Override
-    public int hashCode() {
-        if (returnTarget == null) {
-            return 0;
-        }
-        return returnTarget.hashCode();
-    }
-
-
     /**
      * Returns if the two Returnaddresses refer to the same target.
      */
     @Override
-    public boolean equals( final Object rat ) {
+    public boolean equals(final Object rat) {
         if (!(rat instanceof ReturnaddressType)) {
             return false;
         }
@@ -77,11 +63,21 @@ public boolean equals( final Object rat ) {
         return that.returnTarget.equals(this.returnTarget);
     }
 
-
     /**
      * @return the target of this ReturnaddressType
      */
     public InstructionHandle getTarget() {
         return returnTarget;
     }
+
+    /**
+     * @return a hash code value for the object.
+     */
+    @Override
+    public int hashCode() {
+        if (returnTarget == null) {
+            return 0;
+        }
+        return returnTarget.hashCode();
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SALOAD.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SALOAD.java
index b25da298870..9499e5660f0 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SALOAD.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SALOAD.java
@@ -23,8 +23,10 @@
 
 /**
  * SALOAD - Load short from array
- * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index -&gt; ..., value
+ * </PRE>
  */
 public class SALOAD extends ArrayInstruction implements StackProducer {
 
@@ -32,17 +34,14 @@ public SALOAD() {
         super(com.sun.org.apache.bcel.internal.Const.SALOAD);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackProducer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SASTORE.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SASTORE.java
index 2c5e6565677..c9c42d3d339 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SASTORE.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SASTORE.java
@@ -23,8 +23,10 @@
 
 /**
  * SASTORE - Store into short array
- * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
  *
+ * <PRE>
+ * Stack: ..., arrayref, index, value -&gt; ...
+ * </PRE>
  */
 public class SASTORE extends ArrayInstruction implements StackConsumer {
 
@@ -32,17 +34,14 @@ public SASTORE() {
         super(com.sun.org.apache.bcel.internal.Const.SASTORE);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitExceptionThrower(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SIPUSH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SIPUSH.java
index 6d3a38804e4..513495e062f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SIPUSH.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SIPUSH.java
@@ -28,85 +28,76 @@
 /**
  * SIPUSH - Push short
  *
- * <PRE>Stack: ... -&gt; ..., value</PRE>
- *
+ * <PRE>
+ * Stack: ... -&gt; ..., value
+ * </PRE>
  */
 public class SIPUSH extends Instruction implements ConstantPushInstruction {
 
     private short b;
 
-
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     SIPUSH() {
     }
 
-
     public SIPUSH(final short b) {
         super(com.sun.org.apache.bcel.internal.Const.SIPUSH, (short) 3);
         this.b = b;
     }
 
-
     /**
-     * Dump instruction as short code to stream out.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        super.dump(out);
-        out.writeShort(b);
+    public void accept(final Visitor v) {
+        v.visitPushInstruction(this);
+        v.visitStackProducer(this);
+        v.visitTypedInstruction(this);
+        v.visitConstantPushInstruction(this);
+        v.visitSIPUSH(this);
     }
 
-
     /**
-     * @return mnemonic for instruction
+     * Dump instruction as short code to stream out.
      */
     @Override
-    public String toString( final boolean verbose ) {
-        return super.toString(verbose) + " " + b;
+    public void dump(final DataOutputStream out) throws IOException {
+        super.dump(out);
+        out.writeShort(b);
     }
 
-
     /**
-     * Read needed data (e.g. index) from file.
+     * @return Type.SHORT
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
-        super.setLength(3);
-        b = bytes.readShort();
+    public Type getType(final ConstantPoolGen cp) {
+        return Type.SHORT;
     }
 
-
     @Override
     public Number getValue() {
         return Integer.valueOf(b);
     }
 
-
-    /** @return Type.SHORT
+    /**
+     * Read needed data (e.g. index) from file.
      */
     @Override
-    public Type getType( final ConstantPoolGen cp ) {
-        return Type.SHORT;
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+        super.setLength(3);
+        b = bytes.readShort();
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
+     * @return mnemonic for instruction
      */
     @Override
-    public void accept( final Visitor v ) {
-        v.visitPushInstruction(this);
-        v.visitStackProducer(this);
-        v.visitTypedInstruction(this);
-        v.visitConstantPushInstruction(this);
-        v.visitSIPUSH(this);
+    public String toString(final boolean verbose) {
+        return super.toString(verbose) + " " + b;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWAP.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWAP.java
index 57bf1b7df22..e3c0a46de73 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWAP.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWAP.java
@@ -23,8 +23,10 @@
 
 /**
  * SWAP - Swa top operand stack word
- * <PRE>Stack: ..., word2, word1 -&gt; ..., word1, word2</PRE>
  *
+ * <PRE>
+ * Stack: ..., word2, word1 -&gt; ..., word1, word2
+ * </PRE>
  */
 public class SWAP extends StackInstruction implements StackConsumer, StackProducer {
 
@@ -32,17 +34,14 @@ public SWAP() {
         super(com.sun.org.apache.bcel.internal.Const.SWAP);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitStackProducer(this);
         v.visitStackInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java
index bd2f25413c8..aed1626ec0d 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SWITCH.java
@@ -21,91 +21,34 @@
 
 package com.sun.org.apache.bcel.internal.generic;
 
+import java.util.Arrays;
+
 /**
- * SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or
- * TABLESWITCH instruction, depending on whether the match values (int[]) can be
- * sorted with no gaps between the numbers.
- *
+ * SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or TABLESWITCH instruction, depending on
+ * whether the match values (int[]) can be sorted with no gaps between the numbers.
  */
 public final class SWITCH implements CompoundInstruction {
 
-    private int[] match;
-    private InstructionHandle[] targets;
-    private Select instruction;
-    private int matchLength;
-
-
     /**
-     * Template for switch() constructs. If the match array can be
-     * sorted in ascending order with gaps no larger than max_gap
-     * between the numbers, a TABLESWITCH instruction is generated, and
-     * a LOOKUPSWITCH otherwise. The former may be more efficient, but
-     * needs more space.
-     *
-     * Note, that the key array always will be sorted, though we leave
-     * the original arrays unaltered.
-     *
-     * @param match array of match values (case 2: ... case 7: ..., etc.)
-     * @param targets the instructions to be branched to for each case
-     * @param target the default target
-     * @param max_gap maximum gap that may between case branches
+     * @return match is sorted in ascending order with no gap bigger than maxGap?
      */
-    public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int max_gap) {
-        this.match = match.clone();
-        this.targets = targets.clone();
-        if ((matchLength = match.length) < 2) {
-            instruction = new TABLESWITCH(match, targets, target);
-        } else {
-            sort(0, matchLength - 1);
-            if (matchIsOrdered(max_gap)) {
-                fillup(max_gap, target);
-                instruction = new TABLESWITCH(this.match, this.targets, target);
-            } else {
-                instruction = new LOOKUPSWITCH(this.match, this.targets, target);
-            }
-        }
-    }
-
-
-    public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target) {
-        this(match, targets, target, 1);
-    }
-
-
-    private void fillup( final int max_gap, final InstructionHandle target ) {
-        final int max_size = matchLength + matchLength * max_gap;
-        final int[] m_vec = new int[max_size];
-        final InstructionHandle[] t_vec = new InstructionHandle[max_size];
-        int count = 1;
-        m_vec[0] = match[0];
-        t_vec[0] = targets[0];
+    private static boolean matchIsOrdered(final int[] match, final int matchLength, final int maxGap) {
         for (int i = 1; i < matchLength; i++) {
-            final int prev = match[i - 1];
-            final int gap = match[i] - prev;
-            for (int j = 1; j < gap; j++) {
-                m_vec[count] = prev + j;
-                t_vec[count] = target;
-                count++;
+            if (match[i] - match[i - 1] > maxGap) {
+                return false;
             }
-            m_vec[count] = match[i];
-            t_vec[count] = targets[i];
-            count++;
         }
-        match = new int[count];
-        targets = new InstructionHandle[count];
-        System.arraycopy(m_vec, 0, match, 0, count);
-        System.arraycopy(t_vec, 0, targets, 0, count);
+        return true;
     }
 
-
     /**
-     * Sort match and targets array with QuickSort.
+     * Sorts match and targets array with QuickSort.
      */
-    private void sort( final int l, final int r ) {
+    private static void sort(final int l, final int r, final int[] match, final InstructionHandle[] targets) {
         int i = l;
         int j = r;
         int h;
-        final int m = match[(l + r) >>> 1];
+        final int m = match[l + r >>> 1];
         InstructionHandle h2;
         do {
             while (match[i] < m) {
@@ -126,34 +69,71 @@ private void sort( final int l, final int r ) {
             }
         } while (i <= j);
         if (l < j) {
-            sort(l, j);
+            sort(l, j, match, targets);
         }
         if (i < r) {
-            sort(i, r);
+            sort(i, r, match, targets);
         }
     }
 
+    private final Select instruction;
+
+    public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target) {
+        this(match, targets, target, 1);
+    }
 
     /**
-     * @return match is sorted in ascending order with no gap bigger than max_gap?
+     * Template for switch() constructs. If the match array can be sorted in ascending order with gaps no larger than
+     * maxGap between the numbers, a TABLESWITCH instruction is generated, and a LOOKUPSWITCH otherwise. The former may be
+     * more efficient, but needs more space.
+     *
+     * Note, that the key array always will be sorted, though we leave the original arrays unaltered.
+     *
+     * @param match array of match values (case 2: ... case 7: ..., etc.)
+     * @param targets the instructions to be branched to for each case
+     * @param target the default target
+     * @param maxGap maximum gap that may between case branches
      */
-    private boolean matchIsOrdered( final int max_gap ) {
-        for (int i = 1; i < matchLength; i++) {
-            if (match[i] - match[i - 1] > max_gap) {
-                return false;
+    public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int maxGap) {
+        int[] matchClone = match.clone();
+        final InstructionHandle[] targetsClone = targets.clone();
+        final int matchLength = match.length;
+        if (matchLength < 2) {
+            instruction = new TABLESWITCH(match, targets, target);
+        } else {
+            sort(0, matchLength - 1, matchClone, targetsClone);
+            if (matchIsOrdered(matchClone, matchLength, maxGap)) {
+                final int maxSize = matchLength + matchLength * maxGap;
+                final int[] mVec = new int[maxSize];
+                final InstructionHandle[] tVec = new InstructionHandle[maxSize];
+                int count = 1;
+                mVec[0] = match[0];
+                tVec[0] = targets[0];
+                for (int i = 1; i < matchLength; i++) {
+                    final int prev = match[i - 1];
+                    final int gap = match[i] - prev;
+                    for (int j = 1; j < gap; j++) {
+                        mVec[count] = prev + j;
+                        tVec[count] = target;
+                        count++;
+                    }
+                    mVec[count] = match[i];
+                    tVec[count] = targets[i];
+                    count++;
+                }
+                instruction = new TABLESWITCH(Arrays.copyOf(mVec, count), Arrays.copyOf(tVec, count), target);
+            } else {
+                instruction = new LOOKUPSWITCH(matchClone, targetsClone, target);
             }
         }
-        return true;
     }
 
+    public Instruction getInstruction() {
+        return instruction;
+    }
 
     @Override
     public InstructionList getInstructionList() {
         return new InstructionList(instruction);
     }
-
-
-    public Instruction getInstruction() {
-        return instruction;
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java
index a9dc01e2600..a90e795e99f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java
@@ -27,34 +27,60 @@
 /**
  * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.
  *
- * <p>We use our super's {@code target} property as the default target.
+ * <p>
+ * We use our super's {@code target} property as the default target.
  *
  * @see LOOKUPSWITCH
  * @see TABLESWITCH
  * @see InstructionList
  * @LastModified: May 2021
  */
-public abstract class Select extends BranchInstruction implements VariableLengthInstruction,
-        StackConsumer /* @since 6.0 */, StackProducer {
+public abstract class Select extends BranchInstruction implements VariableLengthInstruction, StackConsumer /* @since 6.0 */, StackProducer {
 
-    private int[] match; // matches, i.e., case 1: ... TODO could be package-protected?
-    private int[] indices; // target offsets TODO could be package-protected?
-    private InstructionHandle[] targets; // target objects in instruction list TODO could be package-protected?
-    private int fixed_length; // fixed length defined by subclasses TODO could be package-protected?
-    private int match_length; // number of cases TODO could be package-protected?
-    private int padding = 0; // number of pad bytes for alignment TODO could be package-protected?
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int[] match; // matches, i.e., case 1: ... TODO could be package-protected?
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int[] indices; // target offsets TODO could be package-protected?
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected InstructionHandle[] targets; // target objects in instruction list TODO could be package-protected?
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int fixed_length; // fixed length defined by subclasses TODO could be package-protected?
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int match_length; // number of cases TODO could be package-protected?
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected int padding; // number of pad bytes for alignment TODO could be package-protected?
+
+    /**
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     Select() {
     }
 
-
     /**
-     * (Match, target) pairs for switch.
-     * `Match' and `targets' must have the same length of course.
+     * (Match, target) pairs for switch. 'Match' and 'targets' must have the same length of course.
      *
      * @param match array of matching values
      * @param targets instruction targets
@@ -71,126 +97,25 @@ public abstract class Select extends BranchInstruction implements VariableLength
             notifyTarget(null, target2, this);
         }
         if ((match_length = match.length) != targets.length) {
-            throw new ClassGenException("Match and target array have not the same length: Match length: " +
-                match.length + " Target length: " + targets.length);
+            throw new ClassGenException("Match and target array have not the same length: Match length: " + match.length + " Target length: " + targets.length);
         }
         indices = new int[match_length];
     }
 
-
-    /**
-     * Since this is a variable length instruction, it may shift the following
-     * instructions which then need to update their position.
-     *
-     * Called by InstructionList.setPositions when setting the position for every
-     * instruction. In the presence of variable length instructions `setPositions'
-     * performs multiple passes over the instruction list to calculate the
-     * correct (byte) positions and offsets by calling this function.
-     *
-     * @param offset additional offset caused by preceding (variable length) instructions
-     * @param max_offset the maximum offset that may be caused by these instructions
-     * @return additional offset caused by possible change of this instruction's length
-     */
-    @Override
-    protected int updatePosition( final int offset, final int max_offset ) {
-        setPosition(getPosition() + offset); // Additional offset caused by preceding SWITCHs, GOTOs, etc.
-        final short old_length = (short) super.getLength();
-        /* Alignment on 4-byte-boundary, + 1, because of tag byte.
-         */
-        padding = (4 - ((getPosition() + 1) % 4)) % 4;
-        super.setLength((short) (fixed_length + padding)); // Update length
-        return super.getLength() - old_length;
-    }
-
-
-    /**
-     * Dump instruction as byte code to stream out.
-     * @param out Output stream
-     */
-    @Override
-    public void dump( final DataOutputStream out ) throws IOException {
-        out.writeByte(super.getOpcode());
-        for (int i = 0; i < padding; i++) {
-            out.writeByte(0);
-        }
-        super.setIndex(getTargetOffset()); // Write default target offset
-        out.writeInt(super.getIndex());
-    }
-
-
-    /**
-     * Read needed data (e.g. index) from file.
-     */
-    @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
-        padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes
-        for (int i = 0; i < padding; i++) {
-            bytes.readByte();
-        }
-        // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH)
-        super.setIndex(bytes.readInt());
-    }
-
-
-    /**
-     * @return mnemonic for instruction
-     */
-    @Override
-    public String toString( final boolean verbose ) {
-        final StringBuilder buf = new StringBuilder(super.toString(verbose));
-        if (verbose) {
-            for (int i = 0; i < match_length; i++) {
-                String s = "null";
-                if (targets[i] != null) {
-                    s = targets[i].getInstruction().toString();
-                }
-                buf.append("(").append(match[i]).append(", ").append(s).append(" = {").append(
-                        indices[i]).append("})");
-            }
-        } else {
-            buf.append(" ...");
-        }
-        return buf.toString();
-    }
-
-
-    /**
-     * Set branch target for `i'th case
-     */
-    public void setTarget( final int i, final InstructionHandle target ) { // TODO could be package-protected?
-        notifyTarget(targets[i], target, this);
-        targets[i] = target;
-    }
-
-
-    /**
-     * @param old_ih old target
-     * @param new_ih new target
-     */
     @Override
-    public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) {
-        boolean targeted = false;
-        if (super.getTarget() == old_ih) {
-            targeted = true;
-            setTarget(new_ih);
-        }
-        for (int i = 0; i < targets.length; i++) {
-            if (targets[i] == old_ih) {
-                targeted = true;
-                setTarget(i, new_ih);
-            }
-        }
-        if (!targeted) {
-            throw new ClassGenException("Not targeting " + old_ih);
-        }
+    protected Object clone() throws CloneNotSupportedException {
+        final Select copy = (Select) super.clone();
+        copy.match = match.clone();
+        copy.indices = indices.clone();
+        copy.targets = targets.clone();
+        return copy;
     }
 
-
     /**
      * @return true, if ih is target of this instruction
      */
     @Override
-    public boolean containsTarget( final InstructionHandle ih ) {
+    public boolean containsTarget(final InstructionHandle ih) {
         if (super.getTarget() == ih) {
             return true;
         }
@@ -202,17 +127,6 @@ public boolean containsTarget( final InstructionHandle ih ) {
         return false;
     }
 
-
-    @Override
-    protected Object clone() throws CloneNotSupportedException {
-        final Select copy = (Select) super.clone();
-        copy.match = match.clone();
-        copy.indices = indices.clone();
-        copy.targets = targets.clone();
-        return copy;
-    }
-
-
     /**
      * Inform targets that they're not targeted anymore.
      */
@@ -224,14 +138,28 @@ void dispose() {
         }
     }
 
-
     /**
-     * @return array of match indices
+     * Dump instruction as byte code to stream out.
+     *
+     * @param out Output stream
      */
-    public int[] getMatchs() {
-        return match;
+    @Override
+    public void dump(final DataOutputStream out) throws IOException {
+        out.writeByte(super.getOpcode());
+        for (int i = 0; i < padding; i++) {
+            out.writeByte(0);
+        }
+        super.setIndex(getTargetOffset()); // Write default target offset
+        out.writeInt(super.getIndex());
     }
 
+    /**
+     * @return the fixed_length
+     * @since 6.0
+     */
+    final int getFixedLength() {
+        return fixed_length;
+    }
 
     /**
      * @return array of match target offsets
@@ -240,12 +168,12 @@ public int[] getIndices() {
         return indices;
     }
 
-
     /**
-     * @return array of match targets
+     * @return index entry from indices
+     * @since 6.0
      */
-    public InstructionHandle[] getTargets() {
-        return targets;
+    final int getIndices(final int index) {
+        return indices[index];
     }
 
     /**
@@ -256,13 +184,28 @@ final int getMatch(final int index) {
         return match[index];
     }
 
+    /**
+     * @return the match_length
+     * @since 6.0
+     */
+    final int getMatchLength() {
+        return match_length;
+    }
 
     /**
-     * @return index entry from indices
+     * @return array of match indices
+     */
+    public int[] getMatchs() {
+        return match;
+    }
+
+    /**
+     *
+     * @return the padding
      * @since 6.0
      */
-    final int getIndices(final int index) {
-        return indices[index];
+    final int getPadding() {
+        return padding;
     }
 
     /**
@@ -273,41 +216,47 @@ final InstructionHandle getTarget(final int index) {
         return targets[index];
     }
 
-
     /**
-     * @return the fixed_length
-     * @since 6.0
+     * @return array of match targets
      */
-    final int getFixed_length() {
-        return fixed_length;
+    public InstructionHandle[] getTargets() {
+        return targets;
     }
 
-
     /**
-     * @param fixed_length the fixed_length to set
-     * @since 6.0
+     * Read needed data (e.g. index) from file.
      */
-    final void setFixed_length(final int fixed_length) {
-        this.fixed_length = fixed_length;
+    @Override
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+        padding = (4 - bytes.getIndex() % 4) % 4; // Compute number of pad bytes
+        for (int i = 0; i < padding; i++) {
+            bytes.readByte();
+        }
+        // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH)
+        super.setIndex(bytes.readInt());
     }
 
-
     /**
-     * @return the match_length
+     * @param fixedLength the fixed_length to set
      * @since 6.0
      */
-    final int getMatch_length() {
-        return match_length;
+    final void setFixedLength(final int fixedLength) {
+        this.fixed_length = fixedLength;
     }
 
+    /** @since 6.0 */
+    final int setIndices(final int i, final int value) {
+        indices[i] = value;
+        return value; // Allow use in nested calls
+    }
 
     /**
-     * @param match_length the match_length to set
+     *
+     * @param array
      * @since 6.0
      */
-    final int setMatch_length(final int match_length) {
-        this.match_length = match_length;
-        return match_length;
+    final void setIndices(final int[] array) {
+        indices = array;
     }
 
     /**
@@ -325,17 +274,25 @@ final void setMatch(final int index, final int value) {
      * @param array
      * @since 6.0
      */
-    final void setIndices(final int[] array) {
-        indices = array;
+    final void setMatches(final int[] array) {
+        match = array;
     }
 
     /**
-     *
-     * @param array
+     * @param matchLength the match_length to set
      * @since 6.0
      */
-    final void setMatches(final int[] array) {
-        match = array;
+    final int setMatchLength(final int matchLength) {
+        this.match_length = matchLength;
+        return matchLength;
+    }
+
+    /**
+     * Set branch target for 'i'th case
+     */
+    public void setTarget(final int i, final InstructionHandle target) { // TODO could be package-protected?
+        notifyTarget(targets[i], target, this);
+        targets[i] = target;
     }
 
     /**
@@ -348,18 +305,68 @@ final void setTargets(final InstructionHandle[] array) {
     }
 
     /**
-     *
-     * @return the padding
-     * @since 6.0
+     * @return mnemonic for instruction
      */
-    final int getPadding() {
-        return padding;
+    @Override
+    public String toString(final boolean verbose) {
+        final StringBuilder buf = new StringBuilder(super.toString(verbose));
+        if (verbose) {
+            for (int i = 0; i < match_length; i++) {
+                String s = "null";
+                if (targets[i] != null) {
+                    s = targets[i].getInstruction().toString();
+                }
+                buf.append("(").append(match[i]).append(", ").append(s).append(" = {").append(indices[i]).append("})");
+            }
+        } else {
+            buf.append(" ...");
+        }
+        return buf.toString();
     }
 
+    /**
+     * Since this is a variable length instruction, it may shift the following instructions which then need to update their
+     * position.
+     *
+     * Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable
+     * length instructions 'setPositions' performs multiple passes over the instruction list to calculate the correct (byte)
+     * positions and offsets by calling this function.
+     *
+     * @param offset additional offset caused by preceding (variable length) instructions
+     * @param maxOffset the maximum offset that may be caused by these instructions
+     * @return additional offset caused by possible change of this instruction's length
+     */
+    @Override
+    protected int updatePosition(final int offset, final int maxOffset) {
+        setPosition(getPosition() + offset); // Additional offset caused by preceding SWITCHs, GOTOs, etc.
+        final short oldLength = (short) super.getLength();
+        /*
+         * Alignment on 4-byte-boundary, + 1, because of tag byte.
+         */
+        padding = (4 - (getPosition() + 1) % 4) % 4;
+        super.setLength((short) (fixed_length + padding)); // Update length
+        return super.getLength() - oldLength;
+    }
 
-    /** @since 6.0 */
-    final int setIndices(final int i, final int value) {
-        indices[i] = value;
-        return value;  // Allow use in nested calls
+    /**
+     * @param oldIh old target
+     * @param newIh new target
+     */
+    @Override
+    public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh) {
+        boolean targeted = false;
+        if (super.getTarget() == oldIh) {
+            targeted = true;
+            setTarget(newIh);
+        }
+        for (int i = 0; i < targets.length; i++) {
+            if (targets[i] == oldIh) {
+                targeted = true;
+                setTarget(i, newIh);
+            }
+        }
+        if (!targeted) {
+            throw new ClassGenException("Not targeting " + oldIh);
+        }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java
index bccb59cabaf..a4de20315d7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/SimpleElementValueGen.java
@@ -35,102 +35,84 @@
 /**
  * @since 6.0
  */
-public class SimpleElementValueGen extends ElementValueGen
-{
+public class SimpleElementValueGen extends ElementValueGen {
     // For primitive types and string type, this points to the value entry in
     // the cpGen
     // For 'class' this points to the class entry in the cpGen
-    private int idx;
+    private final int idx;
 
-    // ctors for each supported type... type could be inferred but for now lets
-    // force it to be passed
-    /**
-     * Protected ctor used for deserialization, doesn't *put* an entry in the
-     * constant pool, assumes the one at the supplied index is correct.
-     */
-    protected SimpleElementValueGen(final int type, final int idx, final ConstantPoolGen cpGen)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final boolean value) {
         super(type, cpGen);
-        this.idx = idx;
+        if (value) {
+            idx = getConstantPool().addInteger(1);
+        } else {
+            idx = getConstantPool().addInteger(0);
+        }
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final int value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final byte value) {
         super(type, cpGen);
         idx = getConstantPool().addInteger(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final long value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final char value) {
         super(type, cpGen);
-        idx = getConstantPool().addLong(value);
+        idx = getConstantPool().addInteger(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final double value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final double value) {
         super(type, cpGen);
         idx = getConstantPool().addDouble(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final float value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final float value) {
         super(type, cpGen);
         idx = getConstantPool().addFloat(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final short value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final int value) {
         super(type, cpGen);
         idx = getConstantPool().addInteger(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final byte value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final long value) {
         super(type, cpGen);
-        idx = getConstantPool().addInteger(value);
+        idx = getConstantPool().addLong(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final char value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final short value) {
         super(type, cpGen);
         idx = getConstantPool().addInteger(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final boolean value)
-    {
+    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final String value) {
         super(type, cpGen);
-        if (value) {
-            idx = getConstantPool().addInteger(1);
-        } else {
-            idx = getConstantPool().addInteger(0);
-        }
+        idx = getConstantPool().addUtf8(value);
     }
 
-    public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final String value)
-    {
+    // ctors for each supported type... type could be inferred but for now lets
+    // force it to be passed
+    /**
+     * Protected ctor used for deserialization, doesn't *put* an entry in the constant pool, assumes the one at the supplied
+     * index is correct.
+     */
+    protected SimpleElementValueGen(final int type, final int idx, final ConstantPoolGen cpGen) {
         super(type, cpGen);
-        idx = getConstantPool().addUtf8(value);
+        this.idx = idx;
     }
 
     /**
-     * The boolean controls whether we copy info from the 'old' constant pool to
-     * the 'new'. You need to use this ctor if the annotation is being copied
-     * from one file to another.
+     * The boolean controls whether we copy info from the 'old' constant pool to the 'new'. You need to use this ctor if the
+     * annotation is being copied from one file to another.
      */
-    public SimpleElementValueGen(final SimpleElementValue value,
-            final ConstantPoolGen cpool, final boolean copyPoolEntries)
-    {
+    public SimpleElementValueGen(final SimpleElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) {
         super(value.getElementValueType(), cpool);
-        if (!copyPoolEntries)
-        {
+        if (!copyPoolEntries) {
             // J5ASSERT: Could assert value.stringifyValue() is the same as
             // cpool.getConstant(SimpleElementValuevalue.getIndex())
             idx = value.getIndex();
-        }
-        else
-        {
-            switch (value.getElementValueType())
-            {
+        } else {
+            switch (value.getElementValueType()) {
             case STRING:
                 idx = cpool.addUtf8(value.getValueString());
                 break;
@@ -153,12 +135,9 @@ public SimpleElementValueGen(final SimpleElementValue value,
                 idx = cpool.addDouble(value.getValueDouble());
                 break;
             case PRIMITIVE_BOOLEAN:
-                if (value.getValueBoolean())
-                {
+                if (value.getValueBoolean()) {
                     idx = cpool.addInteger(1);
-                }
-                else
-                {
+                } else {
                     idx = cpool.addInteger(0);
                 }
                 break;
@@ -166,52 +145,63 @@ public SimpleElementValueGen(final SimpleElementValue value,
                 idx = cpool.addInteger(value.getValueShort());
                 break;
             default:
-                throw new IllegalArgumentException(
-                    "SimpleElementValueGen class does not know how to copy this type " + super.getElementValueType());
+                throw new IllegalArgumentException("SimpleElementValueGen class does not know how to copy this type " + super.getElementValueType());
             }
         }
     }
 
+    @Override
+    public void dump(final DataOutputStream dos) throws IOException {
+        dos.writeByte(super.getElementValueType()); // u1 kind of value
+        switch (super.getElementValueType()) {
+        case PRIMITIVE_INT:
+        case PRIMITIVE_BYTE:
+        case PRIMITIVE_CHAR:
+        case PRIMITIVE_FLOAT:
+        case PRIMITIVE_LONG:
+        case PRIMITIVE_BOOLEAN:
+        case PRIMITIVE_SHORT:
+        case PRIMITIVE_DOUBLE:
+        case STRING:
+            dos.writeShort(idx);
+            break;
+        default:
+            throw new IllegalStateException("SimpleElementValueGen doesnt know how to write out type " + super.getElementValueType());
+        }
+    }
+
     /**
      * Return immutable variant
      */
     @Override
-    public ElementValue getElementValue()
-    {
+    public ElementValue getElementValue() {
         return new SimpleElementValue(super.getElementValueType(), idx, getConstantPool().getConstantPool());
     }
 
-    public int getIndex()
-    {
+    public int getIndex() {
         return idx;
     }
 
-    public String getValueString()
-    {
-        if (super.getElementValueType() != STRING) {
-            throw new IllegalStateException(
-                    "Dont call getValueString() on a non STRING ElementValue");
+    public int getValueInt() {
+        if (super.getElementValueType() != PRIMITIVE_INT) {
+            throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue");
         }
-        final ConstantUtf8 c = (ConstantUtf8) getConstantPool().getConstant(idx);
+        final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx);
         return c.getBytes();
     }
 
-    public int getValueInt()
-    {
-        if (super.getElementValueType() != PRIMITIVE_INT) {
-            throw new IllegalStateException(
-                    "Dont call getValueString() on a non STRING ElementValue");
+    public String getValueString() {
+        if (super.getElementValueType() != STRING) {
+            throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue");
         }
-        final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx);
+        final ConstantUtf8 c = (ConstantUtf8) getConstantPool().getConstant(idx);
         return c.getBytes();
     }
 
     // Whatever kind of value it is, return it as a string
     @Override
-    public String stringifyValue()
-    {
-        switch (super.getElementValueType())
-        {
+    public String stringifyValue() {
+        switch (super.getElementValueType()) {
         case PRIMITIVE_INT:
             final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx);
             return Integer.toString(c.getBytes());
@@ -243,31 +233,7 @@ public String stringifyValue()
             final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx);
             return cu8.getBytes();
         default:
-            throw new IllegalStateException(
-                "SimpleElementValueGen class does not know how to stringify type " + super.getElementValueType());
-        }
-    }
-
-    @Override
-    public void dump(final DataOutputStream dos) throws IOException
-    {
-        dos.writeByte(super.getElementValueType()); // u1 kind of value
-        switch (super.getElementValueType())
-        {
-        case PRIMITIVE_INT:
-        case PRIMITIVE_BYTE:
-        case PRIMITIVE_CHAR:
-        case PRIMITIVE_FLOAT:
-        case PRIMITIVE_LONG:
-        case PRIMITIVE_BOOLEAN:
-        case PRIMITIVE_SHORT:
-        case PRIMITIVE_DOUBLE:
-        case STRING:
-            dos.writeShort(idx);
-            break;
-        default:
-            throw new IllegalStateException(
-                "SimpleElementValueGen doesnt know how to write out type " + super.getElementValueType());
+            throw new IllegalStateException("SimpleElementValueGen class does not know how to stringify type " + super.getElementValueType());
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackConsumer.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackConsumer.java
index 2740be3eedc..c0709a46b28 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackConsumer.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackConsumer.java
@@ -23,11 +23,11 @@
 
 /**
  * Denote an instruction that may consume a value from the stack.
- *
  */
 public interface StackConsumer {
 
-    /** @return how many words are consumed from stack
+    /**
+     * @return how many words are consumed from stack
      */
-    int consumeStack( ConstantPoolGen cpg );
+    int consumeStack(ConstantPoolGen cpg);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackInstruction.java
index 4306800468c..31321512295 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackInstruction.java
@@ -23,18 +23,15 @@
 
 /**
  * Super class for stack operations like DUP and POP.
- *
  */
 public abstract class StackInstruction extends Instruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     StackInstruction() {
     }
 
-
     /**
      * @param opcode instruction opcode
      */
@@ -42,10 +39,10 @@ protected StackInstruction(final short opcode) {
         super(opcode, (short) 1);
     }
 
-
-    /** @return Type.UNKNOWN
+    /**
+     * @return Type.UNKNOWN
      */
-    public Type getType( final ConstantPoolGen cp ) {
+    public Type getType(final ConstantPoolGen cp) {
         return Type.UNKNOWN;
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackProducer.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackProducer.java
index fa3c00eec27..f660e3b329f 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackProducer.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StackProducer.java
@@ -22,13 +22,12 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denote an instruction that may produce a value on top of the stack
- * (this excludes DUP_X1, e.g.)
- *
+ * Denotes an instruction that may produce a value on top of the stack (this excludes DUP_X1, e.g.)
  */
 public interface StackProducer {
 
-    /** @return how many words are produced on stack
+    /**
+     * @return how many words are produced on stack
      */
-    int produceStack( ConstantPoolGen cpg );
+    int produceStack(ConstantPoolGen cpg);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java
index be039391012..ceef3a8b794 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/StoreInstruction.java
@@ -22,42 +22,35 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denotes an unparameterized instruction to store a value into a local variable,
- * e.g. ISTORE.
- *
+ * Denotes an unparameterized instruction to store a value into a local variable, e.g. ISTORE.
  */
 public abstract class StoreInstruction extends LocalVariableInstruction implements PopInstruction {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
-     * tag and length are defined in readInstruction and initFromFile, respectively.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in
+     * readInstruction and initFromFile, respectively.
      */
-    StoreInstruction(final short canon_tag, final short c_tag) {
-        super(canon_tag, c_tag);
+    StoreInstruction(final short canonTag, final short cTag) {
+        super(canonTag, cTag);
     }
 
-
     /**
      * @param opcode Instruction opcode
-     * @param c_tag Instruction number for compact version, ASTORE_0, e.g.
+     * @param cTag Instruction number for compact version, ASTORE_0, e.g.
      * @param n local variable index (unsigned short)
      */
-    protected StoreInstruction(final short opcode, final short c_tag, final int n) {
-        super(opcode, c_tag, n);
+    protected StoreInstruction(final short opcode, final short cTag, final int n) {
+        super(opcode, cTag, n);
     }
 
-
     /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
      *
      * @param v Visitor object
      */
     @Override
-    public void accept( final Visitor v ) {
+    public void accept(final Visitor v) {
         v.visitStackConsumer(this);
         v.visitPopInstruction(this);
         v.visitTypedInstruction(this);
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java
index 3ed2e100fe4..e38da5eec77 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TABLESWITCH.java
@@ -34,83 +34,76 @@
 public class TABLESWITCH extends Select {
 
     /**
-     * Empty constructor needed for Instruction.readInstruction.
-     * Not to be used otherwise.
+     * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     TABLESWITCH() {
     }
 
-
     /**
-     * @param match sorted array of match values, match[0] must be low value,
-     * match[match_length - 1] high value
+     * @param match sorted array of match values, match[0] must be low value, match[match_length - 1] high value
      * @param targets where to branch for matched values
      * @param defaultTarget default branch
      */
     public TABLESWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) {
         super(com.sun.org.apache.bcel.internal.Const.TABLESWITCH, match, targets, defaultTarget);
         /* Alignment remainder assumed 0 here, until dump time */
-        final short _length = (short) (13 + getMatch_length() * 4);
-        super.setLength(_length);
-        setFixed_length(_length);
+        final short length = (short) (13 + getMatchLength() * 4);
+        super.setLength(length);
+        setFixedLength(length);
     }
 
+    /**
+     * Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call
+     * methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    @Override
+    public void accept(final Visitor v) {
+        v.visitVariableLengthInstruction(this);
+        v.visitStackConsumer(this);
+        v.visitBranchInstruction(this);
+        v.visitSelect(this);
+        v.visitTABLESWITCH(this);
+    }
 
     /**
      * Dump instruction as byte code to stream out.
+     *
      * @param out Output stream
      */
     @Override
-    public void dump( final DataOutputStream out ) throws IOException {
+    public void dump(final DataOutputStream out) throws IOException {
         super.dump(out);
-        final int _match_length = getMatch_length();
-        final int low = (_match_length > 0) ? super.getMatch(0) : 0;
+        final int matchLength = getMatchLength();
+        final int low = matchLength > 0 ? super.getMatch(0) : 0;
         out.writeInt(low);
-        final int high = (_match_length > 0) ? super.getMatch(_match_length - 1) : 0;
+        final int high = matchLength > 0 ? super.getMatch(matchLength - 1) : 0;
         out.writeInt(high);
-        for (int i = 0; i < _match_length; i++) {
+        for (int i = 0; i < matchLength; i++) {
             out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i))));
         }
     }
 
-
     /**
      * Read needed data (e.g. index) from file.
      */
     @Override
-    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
+    protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
         super.initFromFile(bytes, wide);
         final int low = bytes.readInt();
         final int high = bytes.readInt();
-        final int _match_length = high - low + 1;
-        setMatch_length(_match_length);
-        final short _fixed_length = (short) (13 + _match_length * 4);
-        setFixed_length(_fixed_length);
-        super.setLength((short) (_fixed_length + super.getPadding()));
-        super.setMatches(new int[_match_length]);
-        super.setIndices(new int[_match_length]);
-        super.setTargets(new InstructionHandle[_match_length]);
-        for (int i = 0; i < _match_length; i++) {
+        final int matchLength = high - low + 1;
+        setMatchLength(matchLength);
+        final short fixedLength = (short) (13 + matchLength * 4);
+        setFixedLength(fixedLength);
+        super.setLength((short) (fixedLength + super.getPadding()));
+        super.setMatches(new int[matchLength]);
+        super.setIndices(new int[matchLength]);
+        super.setTargets(new InstructionHandle[matchLength]);
+        for (int i = 0; i < matchLength; i++) {
             super.setMatch(i, low + i);
             super.setIndices(i, bytes.readInt());
         }
     }
-
-
-    /**
-     * Call corresponding visitor method(s). The order is:
-     * Call visitor methods of implemented interfaces first, then
-     * call methods according to the class hierarchy in descending order,
-     * i.e., the most specific visitXXX() call comes last.
-     *
-     * @param v Visitor object
-     */
-    @Override
-    public void accept( final Visitor v ) {
-        v.visitVariableLengthInstruction(this);
-        v.visitStackConsumer(this);
-        v.visitBranchInstruction(this);
-        v.visitSelect(this);
-        v.visitTABLESWITCH(this);
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TargetLostException.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TargetLostException.java
index 22c676c0124..40ed6ff4c38 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TargetLostException.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TargetLostException.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,14 +21,14 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Thrown by InstructionList.remove() when one or multiple disposed instructions
- * are still being referenced by an InstructionTargeter object. I.e. the
- * InstructionTargeter has to be notified that (one of) the InstructionHandle it
- * is referencing is being removed from the InstructionList and thus not valid anymore.
+ * Thrown by InstructionList.remove() when one or multiple disposed instructions are still being referenced by an
+ * InstructionTargeter object. I.e. the InstructionTargeter has to be notified that (one of) the InstructionHandle it is
+ * referencing is being removed from the InstructionList and thus not valid anymore.
  *
- * <p>Making this an exception instead of a return value forces the user to handle
- * these case explicitely in a try { ... } catch. The following code illustrates
- * how this may be done:</p>
+ * <p>
+ * Making this an exception instead of a return value forces the user to handle these case explicitly in a try { ... }
+ * catch. The following code illustrates how this may be done:
+ * </p>
  *
  * <PRE>
  *     ...
@@ -47,6 +46,7 @@
  * @see InstructionHandle
  * @see InstructionList
  * @see InstructionTargeter
+ * @LastModified: Feb 2023
  */
 public final class TargetLostException extends Exception {
 
@@ -54,13 +54,11 @@ public final class TargetLostException extends Exception {
     @SuppressWarnings("serial") // Array component type is not Serializable
     private final InstructionHandle[] targets;
 
-
     TargetLostException(final InstructionHandle[] t, final String mesg) {
         super(mesg);
         targets = t;
     }
 
-
     /**
      * @return list of instructions still being targeted.
      */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java
index 2e366dfc8d9..ea20710af2e 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java
@@ -20,26 +20,26 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.classfile.ClassFormatException;
 import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
- * Abstract super class for all possible java types, namely basic types
- * such as int, object types like String and array types, e.g. int[]
- *
+ * Abstract super class for all possible java types, namely basic types such as int, object types like String and array
+ * types, e.g. int[]
  * @LastModified: May 2021
  */
 public abstract class Type {
 
-    private final byte type;
-    private String signature; // signature for the type
     /**
      * Predefined constants
      */
     public static final BasicType VOID = new BasicType(Const.T_VOID);
+
     public static final BasicType BOOLEAN = new BasicType(Const.T_BOOLEAN);
     public static final BasicType INT = new BasicType(Const.T_INT);
     public static final BasicType SHORT = new BasicType(Const.T_SHORT);
@@ -53,176 +53,104 @@ public abstract class Type {
     public static final ObjectType STRING = new ObjectType("java.lang.String");
     public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer");
     public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable");
-    public static final Type[] NO_ARGS = new Type[0]; // EMPTY, so immutable
-    public static final ReferenceType NULL = new ReferenceType() {
-    };
-    public static final Type UNKNOWN = new Type(Const.T_UNKNOWN, "<unknown object>") {
-    };
-
-
-    protected Type(final byte t, final String s) {
-        type = t;
-        signature = s;
-    }
-
 
     /**
-     * @return hashcode of Type
+     * Empty array.
      */
-    @Override
-    public int hashCode() {
-        return type ^ signature.hashCode();
-    }
-
+    public static final Type[] NO_ARGS = {};
+    public static final ReferenceType NULL = new ReferenceType() {
+    };
 
-    /**
-     * @return whether the Types are equal
-     */
-    @Override
-    public boolean equals(final Object o) {
-          if (o instanceof Type) {
-              final Type t = (Type)o;
-              return (type == t.type) && signature.equals(t.signature);
-          }
-          return false;
-    }
+    public static final Type UNKNOWN = new Type(Const.T_UNKNOWN, "<unknown object>") {
+    };
 
+    private static final ThreadLocal<Integer> CONSUMED_CHARS = ThreadLocal.withInitial(() -> Integer.valueOf(0));
 
-    /**
-     * @return signature for given type.
-     */
-    public String getSignature() {
-        return signature;
+    // int consumed_chars=0; // Remember position in string, see getArgumentTypes
+    static int consumed(final int coded) {
+        return coded >> 2;
     }
 
-
-    /**
-     * @return type as defined in Constants
-     */
-    public byte getType() {
-        return type;
+    static int encode(final int size, final int consumed) {
+        return consumed << 2 | size;
     }
 
     /**
-     * boolean, short and char variable are considered as int in the stack or local variable area.
-     * Returns {@link Type#INT} for {@link Type#BOOLEAN}, {@link Type#SHORT} or {@link Type#CHAR}, otherwise
-     * returns the given type.
-     * @since 6.0
+     * Convert arguments of a method (signature) to an array of Type objects.
+     *
+     * @param signature signature string such as (Ljava/lang/String;)V
+     * @return array of argument types
      */
-    public Type normalizeForStackOrLocal() {
-        if (this == Type.BOOLEAN || this == Type.BYTE || this == Type.SHORT || this == Type.CHAR) {
-            return Type.INT;
+    public static Type[] getArgumentTypes(final String signature) {
+        final List<Type> vec = new ArrayList<>();
+        int index;
+        try {
+            // Skip any type arguments to read argument declarations between '(' and ')'
+            index = signature.indexOf('(') + 1;
+            if (index <= 0) {
+                throw new ClassFormatException("Invalid method signature: " + signature);
+            }
+            while (signature.charAt(index) != ')') {
+                vec.add(getType(signature.substring(index)));
+                // corrected concurrent private static field acess
+                index += unwrap(CONSUMED_CHARS); // update position
+            }
+        } catch (final StringIndexOutOfBoundsException e) { // Should never occur
+            throw new ClassFormatException("Invalid method signature: " + signature, e);
         }
-        return this;
+        final Type[] types = new Type[vec.size()];
+        vec.toArray(types);
+        return types;
     }
 
-    /**
-     * @return stack size of this type (2 for long and double, 0 for void, 1 otherwise)
-     */
-    public int getSize() {
-        switch (type) {
-            case Const.T_DOUBLE:
-            case Const.T_LONG:
-                return 2;
-            case Const.T_VOID:
-                return 0;
-            default:
-                return 1;
+    static int getArgumentTypesSize(final String signature) {
+        int res = 0;
+        int index;
+        try {
+            // Skip any type arguments to read argument declarations between '(' and ')'
+            index = signature.indexOf('(') + 1;
+            if (index <= 0) {
+                throw new ClassFormatException("Invalid method signature: " + signature);
+            }
+            while (signature.charAt(index) != ')') {
+                final int coded = getTypeSize(signature.substring(index));
+                res += size(coded);
+                index += consumed(coded);
+            }
+        } catch (final StringIndexOutOfBoundsException e) { // Should never occur
+            throw new ClassFormatException("Invalid method signature: " + signature, e);
         }
+        return res;
     }
 
-
-    /**
-     * @return Type string, e.g. `int[]'
-     */
-    @Override
-    public String toString() {
-        return ((this.equals(Type.NULL) || (type >= Const.T_UNKNOWN))) ? signature : Utility
-                .signatureToString(signature, false);
-    }
-
-
     /**
-     * Convert type to Java method signature, e.g. int[] f(java.lang.String x)
-     * becomes (Ljava/lang/String;)[I
+     * Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I
      *
-     * @param return_type what the method returns
-     * @param arg_types what are the argument types
+     * @param returnType what the method returns
+     * @param argTypes what are the argument types
      * @return method signature for given type(s).
      */
-    public static String getMethodSignature( final Type return_type, final Type[] arg_types ) {
+    public static String getMethodSignature(final Type returnType, final Type[] argTypes) {
         final StringBuilder buf = new StringBuilder("(");
-        if (arg_types != null) {
-            for (final Type arg_type : arg_types) {
-                buf.append(arg_type.getSignature());
+        if (argTypes != null) {
+            for (final Type argType : argTypes) {
+                buf.append(argType.getSignature());
             }
         }
         buf.append(')');
-        buf.append(return_type.getSignature());
+        buf.append(returnType.getSignature());
         return buf.toString();
     }
 
-    private static final ThreadLocal<Integer> consumed_chars = new ThreadLocal<Integer>() {
-
-        @Override
-        protected Integer initialValue() {
-            return Integer.valueOf(0);
-        }
-    };//int consumed_chars=0; // Remember position in string, see getArgumentTypes
-
-
-    private static int unwrap( final ThreadLocal<Integer> tl ) {
-        return tl.get().intValue();
-    }
-
-
-    private static void wrap( final ThreadLocal<Integer> tl, final int value ) {
-        tl.set(Integer.valueOf(value));
-    }
-
-
-    /**
-     * Convert signature to a Type object.
-     * @param signature signature string such as Ljava/lang/String;
-     * @return type object
-     */
-    // @since 6.0 no longer final
-    public static Type getType( final String signature ) throws StringIndexOutOfBoundsException {
-        final byte type = Utility.typeOfSignature(signature);
-        if (type <= Const.T_VOID) {
-            //corrected concurrent private static field acess
-            wrap(consumed_chars, 1);
-            return BasicType.getType(type);
-        } else if (type == Const.T_ARRAY) {
-            int dim = 0;
-            do { // Count dimensions
-                dim++;
-            } while (signature.charAt(dim) == '[');
-            // Recurse, but just once, if the signature is ok
-            final Type t = getType(signature.substring(dim));
-            //corrected concurrent private static field acess
-            //  consumed_chars += dim; // update counter - is replaced by
-            final int _temp = unwrap(consumed_chars) + dim;
-            wrap(consumed_chars, _temp);
-            return new ArrayType(t, dim);
-        } else { // type == T_REFERENCE
-            // Utility.typeSignatureToString understands how to parse generic types.
-            final String parsedSignature = Utility.typeSignatureToString(signature, false);
-            wrap(consumed_chars, parsedSignature.length() + 2); // "Lblabla;" `L' and `;' are removed
-            return ObjectType.getInstance(parsedSignature.replace('/', '.'));
-        }
-    }
-
-
     /**
      * Convert return value of a method (signature) to a Type object.
      *
      * @param signature signature string such as (Ljava/lang/String;)V
      * @return return type
      */
-    public static Type getReturnType( final String signature ) {
+    public static Type getReturnType(final String signature) {
         try {
-            // Read return type after `)'
+            // Read return type after ')'
             final int index = signature.lastIndexOf(')') + 1;
             return getType(signature.substring(index));
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
@@ -230,170 +158,242 @@ public static Type getReturnType( final String signature ) {
         }
     }
 
+    static int getReturnTypeSize(final String signature) {
+        final int index = signature.lastIndexOf(')') + 1;
+        return Type.size(getTypeSize(signature.substring(index)));
+    }
 
-    /**
-     * Convert arguments of a method (signature) to an array of Type objects.
-     * @param signature signature string such as (Ljava/lang/String;)V
-     * @return array of argument types
-     */
-    public static Type[] getArgumentTypes( final String signature ) {
-        final List<Type> vec = new ArrayList<>();
-        int index;
-        Type[] types;
-        try {
-            // Skip any type arguments to read argument declarations between `(' and `)'
-            index = signature.indexOf('(') + 1;
-            if (index <= 0) {
-                throw new ClassFormatException("Invalid method signature: " + signature);
-            }
-            while (signature.charAt(index) != ')') {
-                vec.add(getType(signature.substring(index)));
-                //corrected concurrent private static field acess
-                index += unwrap(consumed_chars); // update position
-            }
-        } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, e);
+    public static String getSignature(final java.lang.reflect.Method meth) {
+        final StringBuilder sb = new StringBuilder("(");
+        final Class<?>[] params = meth.getParameterTypes(); // avoid clone
+        for (final Class<?> param : params) {
+            sb.append(getType(param).getSignature());
         }
-        types = new Type[vec.size()];
-        vec.toArray(types);
-        return types;
+        sb.append(")");
+        sb.append(getType(meth.getReturnType()).getSignature());
+        return sb.toString();
     }
 
-
-    /** Convert runtime java.lang.Class to BCEL Type object.
-     * @param cl Java class
+    /**
+     * Convert runtime java.lang.Class to BCEL Type object.
+     *
+     * @param cls Java class
      * @return corresponding Type object
      */
-    public static Type getType( final java.lang.Class<?> cl ) {
-        if (cl == null) {
-            throw new IllegalArgumentException("Class must not be null");
-        }
-        /* That's an amzingly easy case, because getName() returns
-         * the signature. That's what we would have liked anyway.
+    public static Type getType(final Class<?> cls) {
+        Objects.requireNonNull(cls, "cls");
+        /*
+         * That's an amzingly easy case, because getName() returns the signature. That's what we would have liked anyway.
          */
-        if (cl.isArray()) {
-            return getType(cl.getName());
-        } else if (cl.isPrimitive()) {
-            if (cl == Integer.TYPE) {
-                return INT;
-            } else if (cl == Void.TYPE) {
-                return VOID;
-            } else if (cl == Double.TYPE) {
-                return DOUBLE;
-            } else if (cl == Float.TYPE) {
-                return FLOAT;
-            } else if (cl == Boolean.TYPE) {
-                return BOOLEAN;
-            } else if (cl == Byte.TYPE) {
-                return BYTE;
-            } else if (cl == Short.TYPE) {
-                return SHORT;
-            } else if (cl == Byte.TYPE) {
-                return BYTE;
-            } else if (cl == Long.TYPE) {
-                return LONG;
-            } else if (cl == Character.TYPE) {
-                return CHAR;
-            } else {
-                throw new IllegalStateException("Unknown primitive type " + cl);
-            }
-        } else { // "Real" class
-            return ObjectType.getInstance(cl.getName());
+        if (cls.isArray()) {
+            return getType(cls.getName());
+        }
+        if (!cls.isPrimitive()) { // "Real" class
+            return ObjectType.getInstance(cls.getName());
+        }
+        if (cls == Integer.TYPE) {
+            return INT;
+        }
+        if (cls == Void.TYPE) {
+            return VOID;
+        }
+        if (cls == Double.TYPE) {
+            return DOUBLE;
+        }
+        if (cls == Float.TYPE) {
+            return FLOAT;
+        }
+        if (cls == Boolean.TYPE) {
+            return BOOLEAN;
+        }
+        if (cls == Byte.TYPE) {
+            return BYTE;
+        }
+        if (cls == Short.TYPE) {
+            return SHORT;
+        }
+        if (cls == Long.TYPE) {
+            return LONG;
         }
+        if (cls == Character.TYPE) {
+            return CHAR;
+        }
+        throw new IllegalStateException("Unknown primitive type " + cls);
     }
 
+    /**
+     * Convert signature to a Type object.
+     *
+     * @param signature signature string such as Ljava/lang/String;
+     * @return type object
+     */
+    public static Type getType(final String signature) throws StringIndexOutOfBoundsException {
+        final byte type = Utility.typeOfSignature(signature);
+        if (type <= Const.T_VOID) {
+            // corrected concurrent private static field acess
+            wrap(CONSUMED_CHARS, 1);
+            return BasicType.getType(type);
+        }
+        if (type != Const.T_ARRAY) { // type == T_REFERENCE
+            // Utility.typeSignatureToString understands how to parse generic types.
+            final String parsedSignature = Utility.typeSignatureToString(signature, false);
+            wrap(CONSUMED_CHARS, parsedSignature.length() + 2); // "Lblabla;" 'L' and ';' are removed
+            return ObjectType.getInstance(Utility.pathToPackage(parsedSignature));
+        }
+        int dim = 0;
+        do { // Count dimensions
+            dim++;
+        } while (signature.charAt(dim) == '[');
+        // Recurse, but just once, if the signature is ok
+        final Type t = getType(signature.substring(dim));
+        // corrected concurrent private static field acess
+        // consumed_chars += dim; // update counter - is replaced by
+        final int temp = unwrap(CONSUMED_CHARS) + dim;
+        wrap(CONSUMED_CHARS, temp);
+        return new ArrayType(t, dim);
+    }
 
     /**
      * Convert runtime java.lang.Class[] to BCEL Type objects.
+     *
      * @param classes an array of runtime class objects
      * @return array of corresponding Type objects
      */
-    public static Type[] getTypes( final java.lang.Class<?>[] classes ) {
+    public static Type[] getTypes(final Class<?>[] classes) {
         final Type[] ret = new Type[classes.length];
-        for (int i = 0; i < ret.length; i++) {
-            ret[i] = getType(classes[i]);
-        }
+        Arrays.setAll(ret, i -> getType(classes[i]));
         return ret;
     }
 
-
-    public static String getSignature( final java.lang.reflect.Method meth ) {
-        final StringBuilder sb = new StringBuilder("(");
-        final Class<?>[] params = meth.getParameterTypes(); // avoid clone
-        for (final Class<?> param : params) {
-            sb.append(getType(param).getSignature());
+    static int getTypeSize(final String signature) throws StringIndexOutOfBoundsException {
+        final byte type = Utility.typeOfSignature(signature);
+        if (type <= Const.T_VOID) {
+            return encode(BasicType.getType(type).getSize(), 1);
         }
-        sb.append(")");
-        sb.append(getType(meth.getReturnType()).getSignature());
-        return sb.toString();
+        if (type == Const.T_ARRAY) {
+            int dim = 0;
+            do { // Count dimensions
+                dim++;
+            } while (signature.charAt(dim) == '[');
+            // Recurse, but just once, if the signature is ok
+            final int consumed = consumed(getTypeSize(signature.substring(dim)));
+            return encode(1, dim + consumed);
+        }
+        final int index = signature.indexOf(';'); // Look for closing ';'
+        if (index < 0) {
+            throw new ClassFormatException("Invalid signature: " + signature);
+        }
+        return encode(1, index + 1);
     }
 
     static int size(final int coded) {
         return coded & 3;
     }
 
-    static int consumed(final int coded) {
-        return coded >> 2;
+    private static int unwrap(final ThreadLocal<Integer> tl) {
+        return tl.get().intValue();
     }
 
-    static int encode(final int size, final int consumed) {
-        return consumed << 2 | size;
+    private static void wrap(final ThreadLocal<Integer> tl, final int value) {
+        tl.set(Integer.valueOf(value));
     }
 
-    static int getArgumentTypesSize( final String signature ) {
-        int res = 0;
-        int index;
-        try {
-            // Skip any type arguments to read argument declarations between `(' and `)'
-            index = signature.indexOf('(') + 1;
-            if (index <= 0) {
-                throw new ClassFormatException("Invalid method signature: " + signature);
-            }
-            while (signature.charAt(index) != ')') {
-                final int coded = getTypeSize(signature.substring(index));
-                res += size(coded);
-                index += consumed(coded);
-            }
-        } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, e);
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected byte type; // TODO should be final (and private)
+
+    /**
+     * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+     */
+    @Deprecated
+    protected String signature; // signature for the type TODO should be private
+
+    protected Type(final byte type, final String signature) {
+        this.type = type;
+        this.signature = signature;
+    }
+
+    /**
+     * @return whether the Types are equal
+     */
+    @Override
+    public boolean equals(final Object o) {
+        if (o instanceof Type) {
+            final Type t = (Type) o;
+            return type == t.type && signature.equals(t.signature);
         }
-        return res;
+        return false;
     }
 
-    static int getTypeSize( final String signature ) throws StringIndexOutOfBoundsException {
-        final byte type = Utility.typeOfSignature(signature);
-        if (type <= Const.T_VOID) {
-            return encode(BasicType.getType(type).getSize(), 1);
-        } else if (type == Const.T_ARRAY) {
-            int dim = 0;
-            do { // Count dimensions
-                dim++;
-            } while (signature.charAt(dim) == '[');
-            // Recurse, but just once, if the signature is ok
-            final int consumed = consumed(getTypeSize(signature.substring(dim)));
-            return encode(1, dim + consumed);
-        } else { // type == T_REFERENCE
-            final int index = signature.indexOf(';'); // Look for closing `;'
-            if (index < 0) {
-                throw new ClassFormatException("Invalid signature: " + signature);
-            }
-            return encode(1, index + 1);
+    public String getClassName() {
+        return toString();
+    }
+
+    /**
+     * @return signature for given type.
+     */
+    public String getSignature() {
+        return signature;
+    }
+
+    /**
+     * @return stack size of this type (2 for long and double, 0 for void, 1 otherwise)
+     */
+    public int getSize() {
+        switch (type) {
+        case Const.T_DOUBLE:
+        case Const.T_LONG:
+            return 2;
+        case Const.T_VOID:
+            return 0;
+        default:
+            return 1;
         }
     }
 
+    /**
+     * @return type as defined in Constants
+     */
+    public byte getType() {
+        return type;
+    }
 
-    static int getReturnTypeSize(final String signature) {
-        final int index = signature.lastIndexOf(')') + 1;
-        return Type.size(getTypeSize(signature.substring(index)));
+    /**
+     * @return hashcode of Type
+     */
+    @Override
+    public int hashCode() {
+        return type ^ signature.hashCode();
     }
 
+    /**
+     * boolean, short and char variable are considered as int in the stack or local variable area. Returns {@link Type#INT}
+     * for {@link Type#BOOLEAN}, {@link Type#SHORT} or {@link Type#CHAR}, otherwise returns the given type.
+     *
+     * @since 6.0
+     */
+    public Type normalizeForStackOrLocal() {
+        if (this == Type.BOOLEAN || this == Type.BYTE || this == Type.SHORT || this == Type.CHAR) {
+            return Type.INT;
+        }
+        return this;
+    }
 
     /*
-     * Currently only used by the ArrayType constructor.
-     * The signature has a complicated dependency on other parameter
-     * so it's tricky to do it in a call to the super ctor.
+     * Currently only used by the ArrayType constructor. The signature has a complicated dependency on other parameter so
+     * it's tricky to do it in a call to the super ctor.
      */
     void setSignature(final String signature) {
         this.signature = signature;
     }
+
+    /**
+     * @return Type string, e.g. 'int[]'
+     */
+    @Override
+    public String toString() {
+        return this.equals(Type.NULL) || type >= Const.T_UNKNOWN ? signature : Utility.signatureToString(signature, false);
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java
index 21f9f10b131..5a22942a6a7 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/TypedInstruction.java
@@ -22,11 +22,9 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Get the type associated with an instruction, int for ILOAD, or the type
- * of the field of a PUTFIELD instruction, e.g..
- *
+ * Get the type associated with an instruction, int for ILOAD, or the type of the field of a PUTFIELD instruction, e.g..
  */
 public interface TypedInstruction {
 
-    Type getType( ConstantPoolGen cpg );
+    Type getType(ConstantPoolGen cpg);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java
index 9f467cd3c64..8ccd7313e11 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/UnconditionalBranch.java
@@ -24,7 +24,6 @@
 /**
  * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR.
  *
-
  * @see GOTO
  * @see JSR
  */
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java
index c146578cea3..63504550efc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/VariableLengthInstruction.java
@@ -22,10 +22,9 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Denotes an instruction to be a variable length instruction, such as
- * GOTO, JSR, LOOKUPSWITCH and TABLESWITCH.
+ * Denotes an instruction to be a variable length instruction, such as GOTO, JSR, LOOKUPSWITCH and TABLESWITCH.
+ *
  *
-
  * @see GOTO
  * @see JSR
  * @see LOOKUPSWITCH
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Visitor.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Visitor.java
index fa26c082f5c..fd70e8cd554 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Visitor.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Visitor.java
@@ -22,556 +22,373 @@
 package com.sun.org.apache.bcel.internal.generic;
 
 /**
- * Interface implementing the Visitor pattern programming style.
- * I.e., a class that implements this interface can handle all types of
- * instructions with the properly typed methods just by calling the accept()
- * method.
- *
+ * Interface implementing the Visitor pattern programming style. I.e., a class that implements this interface can handle
+ * all types of instructions with the properly typed methods just by calling the accept() method.
  */
 public interface Visitor {
 
-    void visitStackInstruction( StackInstruction obj );
-
-
-    void visitLocalVariableInstruction( LocalVariableInstruction obj );
-
-
-    void visitBranchInstruction( BranchInstruction obj );
-
-
-    void visitLoadClass( LoadClass obj );
-
-
-    void visitFieldInstruction( FieldInstruction obj );
-
-
-    void visitIfInstruction( IfInstruction obj );
-
-
-    void visitConversionInstruction( ConversionInstruction obj );
-
-
-    void visitPopInstruction( PopInstruction obj );
-
-
-    void visitStoreInstruction( StoreInstruction obj );
-
-
-    void visitTypedInstruction( TypedInstruction obj );
-
-
-    void visitSelect( Select obj );
-
-
-    void visitJsrInstruction( JsrInstruction obj );
-
-
-    void visitGotoInstruction( GotoInstruction obj );
-
-
-    void visitUnconditionalBranch( UnconditionalBranch obj );
-
-
-    void visitPushInstruction( PushInstruction obj );
-
-
-    void visitArithmeticInstruction( ArithmeticInstruction obj );
-
-
-    void visitCPInstruction( CPInstruction obj );
-
-
-    void visitInvokeInstruction( InvokeInstruction obj );
-
-
-    void visitArrayInstruction( ArrayInstruction obj );
-
-
-    void visitAllocationInstruction( AllocationInstruction obj );
-
-
-    void visitReturnInstruction( ReturnInstruction obj );
-
-
-    void visitFieldOrMethod( FieldOrMethod obj );
-
-
-    void visitConstantPushInstruction( ConstantPushInstruction obj );
-
-
-    void visitExceptionThrower( ExceptionThrower obj );
-
-
-    void visitLoadInstruction( LoadInstruction obj );
-
-
-    void visitVariableLengthInstruction( VariableLengthInstruction obj );
-
-
-    void visitStackProducer( StackProducer obj );
-
-
-    void visitStackConsumer( StackConsumer obj );
-
-
-    void visitACONST_NULL( ACONST_NULL obj );
-
-
-    void visitGETSTATIC( GETSTATIC obj );
-
-
-    void visitIF_ICMPLT( IF_ICMPLT obj );
-
-
-    void visitMONITOREXIT( MONITOREXIT obj );
-
-
-    void visitIFLT( IFLT obj );
-
-
-    void visitLSTORE( LSTORE obj );
-
-
-    void visitPOP2( POP2 obj );
-
-
-    void visitBASTORE( BASTORE obj );
-
-
-    void visitISTORE( ISTORE obj );
-
-
-    void visitCHECKCAST( CHECKCAST obj );
-
-
-    void visitFCMPG( FCMPG obj );
-
-
-    void visitI2F( I2F obj );
-
-
-    void visitATHROW( ATHROW obj );
-
-
-    void visitDCMPL( DCMPL obj );
-
-
-    void visitARRAYLENGTH( ARRAYLENGTH obj );
-
-
-    void visitDUP( DUP obj );
-
-
-    void visitINVOKESTATIC( INVOKESTATIC obj );
-
-
-    void visitLCONST( LCONST obj );
+    void visitAALOAD(AALOAD obj);
 
+    void visitAASTORE(AASTORE obj);
 
-    void visitDREM( DREM obj );
+    void visitACONST_NULL(ACONST_NULL obj);
 
+    void visitAllocationInstruction(AllocationInstruction obj);
 
-    void visitIFGE( IFGE obj );
+    void visitALOAD(ALOAD obj);
 
+    void visitANEWARRAY(ANEWARRAY obj);
 
-    void visitCALOAD( CALOAD obj );
+    void visitARETURN(ARETURN obj);
 
+    void visitArithmeticInstruction(ArithmeticInstruction obj);
 
-    void visitLASTORE( LASTORE obj );
+    void visitArrayInstruction(ArrayInstruction obj);
 
+    void visitARRAYLENGTH(ARRAYLENGTH obj);
 
-    void visitI2D( I2D obj );
+    void visitASTORE(ASTORE obj);
 
+    void visitATHROW(ATHROW obj);
 
-    void visitDADD( DADD obj );
+    void visitBALOAD(BALOAD obj);
 
+    void visitBASTORE(BASTORE obj);
 
-    void visitINVOKESPECIAL( INVOKESPECIAL obj );
+    void visitBIPUSH(BIPUSH obj);
 
+    void visitBranchInstruction(BranchInstruction obj);
 
-    void visitIAND( IAND obj );
+    void visitBREAKPOINT(BREAKPOINT obj);
 
+    void visitCALOAD(CALOAD obj);
 
-    void visitPUTFIELD( PUTFIELD obj );
+    void visitCASTORE(CASTORE obj);
 
+    void visitCHECKCAST(CHECKCAST obj);
 
-    void visitILOAD( ILOAD obj );
+    void visitConstantPushInstruction(ConstantPushInstruction obj);
 
+    void visitConversionInstruction(ConversionInstruction obj);
 
-    void visitDLOAD( DLOAD obj );
+    void visitCPInstruction(CPInstruction obj);
 
+    void visitD2F(D2F obj);
 
-    void visitDCONST( DCONST obj );
+    void visitD2I(D2I obj);
 
+    void visitD2L(D2L obj);
 
-    void visitNEW( NEW obj );
+    void visitDADD(DADD obj);
 
+    void visitDALOAD(DALOAD obj);
 
-    void visitIFNULL( IFNULL obj );
+    void visitDASTORE(DASTORE obj);
 
+    void visitDCMPG(DCMPG obj);
 
-    void visitLSUB( LSUB obj );
+    void visitDCMPL(DCMPL obj);
 
+    void visitDCONST(DCONST obj);
 
-    void visitL2I( L2I obj );
+    void visitDDIV(DDIV obj);
 
+    void visitDLOAD(DLOAD obj);
 
-    void visitISHR( ISHR obj );
+    void visitDMUL(DMUL obj);
 
+    void visitDNEG(DNEG obj);
 
-    void visitTABLESWITCH( TABLESWITCH obj );
+    void visitDREM(DREM obj);
 
+    void visitDRETURN(DRETURN obj);
 
-    void visitIINC( IINC obj );
+    void visitDSTORE(DSTORE obj);
 
+    void visitDSUB(DSUB obj);
 
-    void visitDRETURN( DRETURN obj );
+    void visitDUP(DUP obj);
 
+    void visitDUP_X1(DUP_X1 obj);
 
-    void visitFSTORE( FSTORE obj );
+    void visitDUP_X2(DUP_X2 obj);
 
+    void visitDUP2(DUP2 obj);
 
-    void visitDASTORE( DASTORE obj );
+    void visitDUP2_X1(DUP2_X1 obj);
 
+    void visitDUP2_X2(DUP2_X2 obj);
 
-    void visitIALOAD( IALOAD obj );
+    void visitExceptionThrower(ExceptionThrower obj);
 
+    void visitF2D(F2D obj);
 
-    void visitDDIV( DDIV obj );
+    void visitF2I(F2I obj);
 
+    void visitF2L(F2L obj);
 
-    void visitIF_ICMPGE( IF_ICMPGE obj );
+    void visitFADD(FADD obj);
 
+    void visitFALOAD(FALOAD obj);
 
-    void visitLAND( LAND obj );
+    void visitFASTORE(FASTORE obj);
 
+    void visitFCMPG(FCMPG obj);
 
-    void visitIDIV( IDIV obj );
+    void visitFCMPL(FCMPL obj);
 
+    void visitFCONST(FCONST obj);
 
-    void visitLOR( LOR obj );
+    void visitFDIV(FDIV obj);
 
+    void visitFieldInstruction(FieldInstruction obj);
 
-    void visitCASTORE( CASTORE obj );
+    void visitFieldOrMethod(FieldOrMethod obj);
 
+    void visitFLOAD(FLOAD obj);
 
-    void visitFREM( FREM obj );
+    void visitFMUL(FMUL obj);
 
+    void visitFNEG(FNEG obj);
 
-    void visitLDC( LDC obj );
+    void visitFREM(FREM obj);
 
+    void visitFRETURN(FRETURN obj);
 
-    void visitBIPUSH( BIPUSH obj );
+    void visitFSTORE(FSTORE obj);
 
+    void visitFSUB(FSUB obj);
 
-    void visitDSTORE( DSTORE obj );
+    void visitGETFIELD(GETFIELD obj);
 
+    void visitGETSTATIC(GETSTATIC obj);
 
-    void visitF2L( F2L obj );
+    void visitGOTO(GOTO obj);
 
+    void visitGOTO_W(GOTO_W obj);
 
-    void visitFMUL( FMUL obj );
+    void visitGotoInstruction(GotoInstruction obj);
 
+    void visitI2B(I2B obj);
 
-    void visitLLOAD( LLOAD obj );
+    void visitI2C(I2C obj);
 
+    void visitI2D(I2D obj);
 
-    void visitJSR( JSR obj );
+    void visitI2F(I2F obj);
 
+    void visitI2L(I2L obj);
 
-    void visitFSUB( FSUB obj );
+    void visitI2S(I2S obj);
 
+    void visitIADD(IADD obj);
 
-    void visitSASTORE( SASTORE obj );
+    void visitIALOAD(IALOAD obj);
 
+    void visitIAND(IAND obj);
 
-    void visitALOAD( ALOAD obj );
+    void visitIASTORE(IASTORE obj);
 
+    void visitICONST(ICONST obj);
 
-    void visitDUP2_X2( DUP2_X2 obj );
+    void visitIDIV(IDIV obj);
 
+    void visitIF_ACMPEQ(IF_ACMPEQ obj);
 
-    void visitRETURN( RETURN obj );
+    void visitIF_ACMPNE(IF_ACMPNE obj);
 
+    void visitIF_ICMPEQ(IF_ICMPEQ obj);
 
-    void visitDALOAD( DALOAD obj );
+    void visitIF_ICMPGE(IF_ICMPGE obj);
 
+    void visitIF_ICMPGT(IF_ICMPGT obj);
 
-    void visitSIPUSH( SIPUSH obj );
+    void visitIF_ICMPLE(IF_ICMPLE obj);
 
+    void visitIF_ICMPLT(IF_ICMPLT obj);
 
-    void visitDSUB( DSUB obj );
+    void visitIF_ICMPNE(IF_ICMPNE obj);
 
+    void visitIFEQ(IFEQ obj);
 
-    void visitL2F( L2F obj );
+    void visitIFGE(IFGE obj);
 
+    void visitIFGT(IFGT obj);
 
-    void visitIF_ICMPGT( IF_ICMPGT obj );
+    void visitIfInstruction(IfInstruction obj);
 
+    void visitIFLE(IFLE obj);
 
-    void visitF2D( F2D obj );
+    void visitIFLT(IFLT obj);
 
+    void visitIFNE(IFNE obj);
 
-    void visitI2L( I2L obj );
+    void visitIFNONNULL(IFNONNULL obj);
 
+    void visitIFNULL(IFNULL obj);
 
-    void visitIF_ACMPNE( IF_ACMPNE obj );
+    void visitIINC(IINC obj);
 
+    void visitILOAD(ILOAD obj);
 
-    void visitPOP( POP obj );
+    void visitIMPDEP1(IMPDEP1 obj);
 
+    void visitIMPDEP2(IMPDEP2 obj);
 
-    void visitI2S( I2S obj );
+    void visitIMUL(IMUL obj);
 
+    void visitINEG(INEG obj);
 
-    void visitIFEQ( IFEQ obj );
-
-
-    void visitSWAP( SWAP obj );
-
-
-    void visitIOR( IOR obj );
-
-
-    void visitIREM( IREM obj );
-
-
-    void visitIASTORE( IASTORE obj );
-
-
-    void visitNEWARRAY( NEWARRAY obj );
-
-
-    void visitINVOKEINTERFACE( INVOKEINTERFACE obj );
-
-
-    void visitINEG( INEG obj );
-
-
-    void visitLCMP( LCMP obj );
-
-
-    void visitJSR_W( JSR_W obj );
-
-
-    void visitMULTIANEWARRAY( MULTIANEWARRAY obj );
-
-
-    void visitDUP_X2( DUP_X2 obj );
-
-
-    void visitSALOAD( SALOAD obj );
-
-
-    void visitIFNONNULL( IFNONNULL obj );
-
-
-    void visitDMUL( DMUL obj );
-
-
-    void visitIFNE( IFNE obj );
-
-
-    void visitIF_ICMPLE( IF_ICMPLE obj );
-
-
-    void visitLDC2_W( LDC2_W obj );
-
-
-    void visitGETFIELD( GETFIELD obj );
-
-
-    void visitLADD( LADD obj );
-
-
-    void visitNOP( NOP obj );
-
-
-    void visitFALOAD( FALOAD obj );
-
-
-    void visitINSTANCEOF( INSTANCEOF obj );
-
-
-    void visitIFLE( IFLE obj );
-
-
-    void visitLXOR( LXOR obj );
-
-
-    void visitLRETURN( LRETURN obj );
-
-
-    void visitFCONST( FCONST obj );
-
-
-    void visitIUSHR( IUSHR obj );
-
-
-    void visitBALOAD( BALOAD obj );
-
-
-    void visitDUP2( DUP2 obj );
-
-
-    void visitIF_ACMPEQ( IF_ACMPEQ obj );
-
-
-    void visitIMPDEP1( IMPDEP1 obj );
-
-
-    void visitMONITORENTER( MONITORENTER obj );
-
-
-    void visitLSHL( LSHL obj );
-
-
-    void visitDCMPG( DCMPG obj );
-
-
-    void visitD2L( D2L obj );
-
-
-    void visitIMPDEP2( IMPDEP2 obj );
-
-
-    void visitL2D( L2D obj );
-
-
-    void visitRET( RET obj );
-
-
-    void visitIFGT( IFGT obj );
-
-
-    void visitIXOR( IXOR obj );
-
-
-    void visitINVOKEVIRTUAL( INVOKEVIRTUAL obj );
-
+    void visitINSTANCEOF(INSTANCEOF obj);
 
     /**
      * @since 6.0
      */
-    void visitINVOKEDYNAMIC( INVOKEDYNAMIC obj );
-
-
-    void visitFASTORE( FASTORE obj );
-
-
-    void visitIRETURN( IRETURN obj );
-
-
-    void visitIF_ICMPNE( IF_ICMPNE obj );
-
+    void visitINVOKEDYNAMIC(INVOKEDYNAMIC obj);
 
-    void visitFLOAD( FLOAD obj );
+    void visitInvokeInstruction(InvokeInstruction obj);
 
+    void visitINVOKEINTERFACE(INVOKEINTERFACE obj);
 
-    void visitLDIV( LDIV obj );
+    void visitINVOKESPECIAL(INVOKESPECIAL obj);
 
+    void visitINVOKESTATIC(INVOKESTATIC obj);
 
-    void visitPUTSTATIC( PUTSTATIC obj );
+    void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj);
 
+    void visitIOR(IOR obj);
 
-    void visitAALOAD( AALOAD obj );
+    void visitIREM(IREM obj);
 
+    void visitIRETURN(IRETURN obj);
 
-    void visitD2I( D2I obj );
+    void visitISHL(ISHL obj);
 
+    void visitISHR(ISHR obj);
 
-    void visitIF_ICMPEQ( IF_ICMPEQ obj );
+    void visitISTORE(ISTORE obj);
 
+    void visitISUB(ISUB obj);
 
-    void visitAASTORE( AASTORE obj );
+    void visitIUSHR(IUSHR obj);
 
+    void visitIXOR(IXOR obj);
 
-    void visitARETURN( ARETURN obj );
+    void visitJSR(JSR obj);
 
+    void visitJSR_W(JSR_W obj);
 
-    void visitDUP2_X1( DUP2_X1 obj );
+    void visitJsrInstruction(JsrInstruction obj);
 
+    void visitL2D(L2D obj);
 
-    void visitFNEG( FNEG obj );
+    void visitL2F(L2F obj);
 
+    void visitL2I(L2I obj);
 
-    void visitGOTO_W( GOTO_W obj );
+    void visitLADD(LADD obj);
 
+    void visitLALOAD(LALOAD obj);
 
-    void visitD2F( D2F obj );
+    void visitLAND(LAND obj);
 
+    void visitLASTORE(LASTORE obj);
 
-    void visitGOTO( GOTO obj );
+    void visitLCMP(LCMP obj);
 
+    void visitLCONST(LCONST obj);
 
-    void visitISUB( ISUB obj );
+    void visitLDC(LDC obj);
 
+    void visitLDC2_W(LDC2_W obj);
 
-    void visitF2I( F2I obj );
+    void visitLDIV(LDIV obj);
 
+    void visitLLOAD(LLOAD obj);
 
-    void visitDNEG( DNEG obj );
+    void visitLMUL(LMUL obj);
 
+    void visitLNEG(LNEG obj);
 
-    void visitICONST( ICONST obj );
+    void visitLoadClass(LoadClass obj);
 
+    void visitLoadInstruction(LoadInstruction obj);
 
-    void visitFDIV( FDIV obj );
+    void visitLocalVariableInstruction(LocalVariableInstruction obj);
 
+    void visitLOOKUPSWITCH(LOOKUPSWITCH obj);
 
-    void visitI2B( I2B obj );
+    void visitLOR(LOR obj);
 
+    void visitLREM(LREM obj);
 
-    void visitLNEG( LNEG obj );
+    void visitLRETURN(LRETURN obj);
 
+    void visitLSHL(LSHL obj);
 
-    void visitLREM( LREM obj );
+    void visitLSHR(LSHR obj);
 
+    void visitLSTORE(LSTORE obj);
 
-    void visitIMUL( IMUL obj );
+    void visitLSUB(LSUB obj);
 
+    void visitLUSHR(LUSHR obj);
 
-    void visitIADD( IADD obj );
+    void visitLXOR(LXOR obj);
 
+    void visitMONITORENTER(MONITORENTER obj);
 
-    void visitLSHR( LSHR obj );
+    void visitMONITOREXIT(MONITOREXIT obj);
 
+    void visitMULTIANEWARRAY(MULTIANEWARRAY obj);
 
-    void visitLOOKUPSWITCH( LOOKUPSWITCH obj );
+    void visitNEW(NEW obj);
 
+    void visitNEWARRAY(NEWARRAY obj);
 
-    void visitDUP_X1( DUP_X1 obj );
+    void visitNOP(NOP obj);
 
+    void visitPOP(POP obj);
 
-    void visitFCMPL( FCMPL obj );
+    void visitPOP2(POP2 obj);
 
+    void visitPopInstruction(PopInstruction obj);
 
-    void visitI2C( I2C obj );
+    void visitPushInstruction(PushInstruction obj);
 
+    void visitPUTFIELD(PUTFIELD obj);
 
-    void visitLMUL( LMUL obj );
+    void visitPUTSTATIC(PUTSTATIC obj);
 
+    void visitRET(RET obj);
 
-    void visitLUSHR( LUSHR obj );
+    void visitRETURN(RETURN obj);
 
+    void visitReturnInstruction(ReturnInstruction obj);
 
-    void visitISHL( ISHL obj );
+    void visitSALOAD(SALOAD obj);
 
+    void visitSASTORE(SASTORE obj);
 
-    void visitLALOAD( LALOAD obj );
+    void visitSelect(Select obj);
 
+    void visitSIPUSH(SIPUSH obj);
 
-    void visitASTORE( ASTORE obj );
+    void visitStackConsumer(StackConsumer obj);
 
+    void visitStackInstruction(StackInstruction obj);
 
-    void visitANEWARRAY( ANEWARRAY obj );
+    void visitStackProducer(StackProducer obj);
 
+    void visitStoreInstruction(StoreInstruction obj);
 
-    void visitFRETURN( FRETURN obj );
+    void visitSWAP(SWAP obj);
 
+    void visitTABLESWITCH(TABLESWITCH obj);
 
-    void visitFADD( FADD obj );
+    void visitTypedInstruction(TypedInstruction obj);
 
+    void visitUnconditionalBranch(UnconditionalBranch obj);
 
-    void visitBREAKPOINT( BREAKPOINT obj );
+    void visitVariableLengthInstruction(VariableLengthInstruction obj);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Args.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Args.java
new file mode 100644
index 00000000000..a61d9d35d2a
--- /dev/null
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Args.java
@@ -0,0 +1,148 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * 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 com.sun.org.apache.bcel.internal.util;
+
+import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.classfile.ClassFormatException;
+
+/**
+ * Argument validation.
+ *
+ * @since 6.7.0
+ */
+public class Args {
+
+    /**
+     * Requires a specific value.
+     *
+     * @param value    The value to test.
+     * @param required The required value.
+     * @param message  The message prefix
+     * @return The value to test.
+     */
+    public static int require(final int value, final int required, final String message) {
+        if (value != required) {
+            throw new ClassFormatException(String.format("%s [Value must be 0: %,d]", message, value));
+        }
+        return value;
+    }
+
+    /**
+     * Requires a 0 value.
+     *
+     * @param value   The value to test.
+     * @param message The message prefix
+     * @return The value to test.
+     */
+    public static int require0(final int value, final String message) {
+        return require(value, 0, message);
+    }
+
+    /**
+     * Requires a u1 value.
+     *
+     * @param value   The value to test.
+     * @param message The message prefix
+     * @return The value to test.
+     */
+    public static int requireU1(final int value, final String message) {
+        if (value < 0 || value > Const.MAX_BYTE) {
+            throw new ClassFormatException(String.format("%s [Value out of range (0 - %,d) for type u1: %,d]", message, Const.MAX_BYTE, value));
+        }
+        return value;
+    }
+
+    /**
+     * Requires a u2 value of at least {@code min} and not above {@code max}.
+     *
+     * @param value   The value to test.
+     * @param min     The minimum required u2 value.
+     * @param max     The maximum required u2 value.
+     * @param message The message prefix
+     * @return The value to test.
+     */
+    public static int requireU2(final int value, final int min, final int max, final String message) {
+        if (max > Const.MAX_SHORT) {
+            throw new IllegalArgumentException(String.format("%s programming error: max %,d > %,d", message, max, Const.MAX_SHORT));
+        }
+        if (min < 0) {
+            throw new IllegalArgumentException(String.format("%s programming error: min %,d < 0", message, min));
+        }
+        if (value < min || value > max) {
+            throw new ClassFormatException(String.format("%s [Value out of range (%,d - %,d) for type u2: %,d]", message, min, Const.MAX_SHORT, value));
+        }
+        return value;
+    }
+
+    /**
+     * Requires a u2 value of at least {@code min}.
+     *
+     * @param value   The value to test.
+     * @param min     The minimum required value.
+     * @param message The message prefix
+     * @return The value to test.
+     */
+    public static int requireU2(final int value, final int min, final String message) {
+        return requireU2(value, min, Const.MAX_SHORT, message);
+    }
+
+    /**
+     * Requires a u2 value.
+     *
+     * @param value   The value to test.
+     * @param message The message prefix
+     * @return The value to test.
+     */
+    public static int requireU2(final int value, final String message) {
+        return requireU2(value, 0, message);
+    }
+
+    /**
+     * Requires a u4 value of at least {@code min}.
+     *
+     * @param value   The value to test.
+     * @param min     The minimum required value.
+     * @param message The message prefix
+     * @return The value to test.
+     */
+    public static int requireU4(final int value, final int min, final String message) {
+        if (min < 0) {
+            throw new IllegalArgumentException(String.format("%s programming error: min %,d < 0", message, min));
+        }
+        if (value < min) {
+            throw new ClassFormatException(
+                    String.format("%s [Value out of range (%,d - %,d) for type u2: %,d]", message, min, Integer.MAX_VALUE, value & 0xFFFFFFFFL));
+        }
+        return value;
+    }
+
+    /**
+     * Requires a u4 value.
+     *
+     * @param value   The value to test.
+     * @param message The message prefix
+     * @return The value to test.
+     */
+    public static int requireU4(final int value, final String message) {
+        return requireU4(value, 0, message);
+    }
+}
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/AttributeHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/AttributeHTML.java
index 6dafdd79b13..4a84901fc56 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/AttributeHTML.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/AttributeHTML.java
@@ -21,196 +21,175 @@
 
 package com.sun.org.apache.bcel.internal.util;
 
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.Closeable;
+import java.io.FileNotFoundException;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.classfile.Attribute;
 import com.sun.org.apache.bcel.internal.classfile.Code;
 import com.sun.org.apache.bcel.internal.classfile.CodeException;
 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
-import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
 import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
 import com.sun.org.apache.bcel.internal.classfile.ExceptionTable;
 import com.sun.org.apache.bcel.internal.classfile.InnerClass;
 import com.sun.org.apache.bcel.internal.classfile.InnerClasses;
 import com.sun.org.apache.bcel.internal.classfile.LineNumber;
 import com.sun.org.apache.bcel.internal.classfile.LineNumberTable;
-import com.sun.org.apache.bcel.internal.classfile.LocalVariable;
 import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable;
 import com.sun.org.apache.bcel.internal.classfile.SourceFile;
 import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
  * Convert found attributes into HTML file.
- *
- *
  */
-final class AttributeHTML {
+final class AttributeHTML implements Closeable {
 
-    private final String class_name; // name of current class
-    private final PrintWriter file; // file to write to
-    private int attr_count = 0;
-    private final ConstantHTML constant_html;
-    private final ConstantPool constant_pool;
+    private final String className; // name of current class
+    private final PrintWriter printWriter; // file to write to
+    private int attrCount;
+    private final ConstantHTML constantHtml;
+    private final ConstantPool constantPool;
 
-
-    AttributeHTML(final String dir, final String class_name, final ConstantPool constant_pool,
-            final ConstantHTML constant_html) throws IOException {
-        this.class_name = class_name;
-        this.constant_pool = constant_pool;
-        this.constant_html = constant_html;
-        file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html"));
-        file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
+    AttributeHTML(final String dir, final String className, final ConstantPool constantPool, final ConstantHTML constantHtml, final Charset charset)
+        throws FileNotFoundException, UnsupportedEncodingException {
+        this.className = className;
+        this.constantPool = constantPool;
+        this.constantHtml = constantHtml;
+        printWriter = new PrintWriter(dir + className + "_attributes.html", charset.name());
+        printWriter.print("<HTML><head><meta charset=\"");
+        printWriter.print(charset.name());
+        printWriter.println("\"></head>");
+        printWriter.println("<BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
     }
 
-
-    private String codeLink( final int link, final int method_number ) {
-        return "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + link
-                + "\" TARGET=Code>" + link + "</A>";
+    @Override
+    public void close() {
+        printWriter.println("</TABLE></BODY></HTML>");
+        printWriter.close();
     }
 
-
-    void close() {
-        file.println("</TABLE></BODY></HTML>");
-        file.close();
+    private String codeLink(final int link, final int methodNumber) {
+        return "<A HREF=\"" + className + "_code.html#code" + methodNumber + "@" + link + "\" TARGET=Code>" + link + "</A>";
     }
 
-
-    void writeAttribute( final Attribute attribute, final String anchor ) {
+    void writeAttribute(final Attribute attribute, final String anchor) {
         writeAttribute(attribute, anchor, 0);
     }
 
-
-    void writeAttribute( final Attribute attribute, final String anchor, final int method_number ) {
+    void writeAttribute(final Attribute attribute, final String anchor, final int methodNumber) {
         final byte tag = attribute.getTag();
         int index;
         if (tag == Const.ATTR_UNKNOWN) {
             return;
         }
-        attr_count++; // Increment number of attributes found so far
-        if (attr_count % 2 == 0) {
-            file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
+        attrCount++; // Increment number of attributes found so far
+        if (attrCount % 2 == 0) {
+            printWriter.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
         } else {
-            file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
+            printWriter.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
         }
-        file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + Const.getAttributeName(tag)
-                + "</A></H4>");
-        /* Handle different attributes
+        printWriter.println("<H4><A NAME=\"" + anchor + "\">" + attrCount + " " + Const.getAttributeName(tag) + "</A></H4>");
+        /*
+         * Handle different attributes
          */
         switch (tag) {
-            case Const.ATTR_CODE:
-                final Code c = (Code) attribute;
-                // Some directly printable values
-                file.print("<UL><LI>Maximum stack size = " + c.getMaxStack()
-                        + "</LI>\n<LI>Number of local variables = " + c.getMaxLocals()
-                        + "</LI>\n<LI><A HREF=\"" + class_name + "_code.html#method"
-                        + method_number + "\" TARGET=Code>Byte code</A></LI></UL>\n");
-                // Get handled exceptions and list them
-                final CodeException[] ce = c.getExceptionTable();
-                final int len = ce.length;
-                if (len > 0) {
-                    file.print("<P><B>Exceptions handled</B><UL>");
-                    for (final CodeException cex : ce) {
-                        final int catch_type = cex.getCatchType(); // Index in constant pool
-                        file.print("<LI>");
-                        if (catch_type != 0) {
-                            file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html
-                        } else {
-                            file.print("Any Exception");
-                        }
-                        file.print("<BR>(Ranging from lines "
-                                + codeLink(cex.getStartPC(), method_number) + " to "
-                                + codeLink(cex.getEndPC(), method_number) + ", handled at line "
-                                + codeLink(cex.getHandlerPC(), method_number) + ")</LI>");
-                    }
-                    file.print("</UL>");
-                }
-                break;
-            case Const.ATTR_CONSTANT_VALUE:
-                index = ((ConstantValue) attribute).getConstantValueIndex();
-                // Reference _cp.html
-                file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index
-                        + "\" TARGET=\"ConstantPool\">Constant value index(" + index
-                        + ")</A></UL>\n");
-                break;
-            case Const.ATTR_SOURCE_FILE:
-                index = ((SourceFile) attribute).getSourceFileIndex();
-                // Reference _cp.html
-                file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index
-                        + "\" TARGET=\"ConstantPool\">Source file index(" + index + ")</A></UL>\n");
-                break;
-            case Const.ATTR_EXCEPTIONS:
-                // List thrown exceptions
-                final int[] indices = ((ExceptionTable) attribute).getExceptionIndexTable();
-                file.print("<UL>");
-                for (final int indice : indices) {
-                    file.print("<LI><A HREF=\"" + class_name + "_cp.html#cp" + indice
-                            + "\" TARGET=\"ConstantPool\">Exception class index(" + indice
-                            + ")</A>\n");
-                }
-                file.print("</UL>\n");
-                break;
-            case Const.ATTR_LINE_NUMBER_TABLE:
-                final LineNumber[] line_numbers = ((LineNumberTable) attribute).getLineNumberTable();
-                // List line number pairs
-                file.print("<P>");
-                for (int i = 0; i < line_numbers.length; i++) {
-                    file.print("(" + line_numbers[i].getStartPC() + ",&nbsp;"
-                            + line_numbers[i].getLineNumber() + ")");
-                    if (i < line_numbers.length - 1) {
-                        file.print(", "); // breakable
+        case Const.ATTR_CODE:
+            final Code c = (Code) attribute;
+            // Some directly printable values
+            printWriter.print("<UL><LI>Maximum stack size = " + c.getMaxStack() + "</LI>\n<LI>Number of local variables = " + c.getMaxLocals()
+                + "</LI>\n<LI><A HREF=\"" + className + "_code.html#method" + methodNumber + "\" TARGET=Code>Byte code</A></LI></UL>\n");
+            // Get handled exceptions and list them
+            final CodeException[] ce = c.getExceptionTable();
+            final int len = ce.length;
+            if (len > 0) {
+                printWriter.print("<P><B>Exceptions handled</B><UL>");
+                for (final CodeException cex : ce) {
+                    final int catchType = cex.getCatchType(); // Index in constant pool
+                    printWriter.print("<LI>");
+                    if (catchType != 0) {
+                        printWriter.print(constantHtml.referenceConstant(catchType)); // Create Link to _cp.html
+                    } else {
+                        printWriter.print("Any Exception");
                     }
+                    printWriter.print("<BR>(Ranging from lines " + codeLink(cex.getStartPC(), methodNumber) + " to " + codeLink(cex.getEndPC(), methodNumber)
+                        + ", handled at line " + codeLink(cex.getHandlerPC(), methodNumber) + ")</LI>");
                 }
-                break;
-            case Const.ATTR_LOCAL_VARIABLE_TABLE:
-                final LocalVariable[] vars = ((LocalVariableTable) attribute).getLocalVariableTable();
-                // List name, range and type
-                file.print("<UL>");
-                for (final LocalVariable var : vars) {
-                    index = var.getSignatureIndex();
-                    String signature = ((ConstantUtf8) constant_pool.getConstant(index,
-                            Const.CONSTANT_Utf8)).getBytes();
-                    signature = Utility.signatureToString(signature, false);
-                    final int start = var.getStartPC();
-                    final int end = start + var.getLength();
-                    file.println("<LI>" + Class2HTML.referenceType(signature) + "&nbsp;<B>"
-                            + var.getName() + "</B> in slot %" + var.getIndex()
-                            + "<BR>Valid from lines " + "<A HREF=\"" + class_name
-                            + "_code.html#code" + method_number + "@" + start + "\" TARGET=Code>"
-                            + start + "</A> to " + "<A HREF=\"" + class_name + "_code.html#code"
-                            + method_number + "@" + end + "\" TARGET=Code>" + end + "</A></LI>");
+                printWriter.print("</UL>");
+            }
+            break;
+        case Const.ATTR_CONSTANT_VALUE:
+            index = ((ConstantValue) attribute).getConstantValueIndex();
+            // Reference _cp.html
+            printWriter
+                .print("<UL><LI><A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=\"ConstantPool\">Constant value index(" + index + ")</A></UL>\n");
+            break;
+        case Const.ATTR_SOURCE_FILE:
+            index = ((SourceFile) attribute).getSourceFileIndex();
+            // Reference _cp.html
+            printWriter
+                .print("<UL><LI><A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=\"ConstantPool\">Source file index(" + index + ")</A></UL>\n");
+            break;
+        case Const.ATTR_EXCEPTIONS:
+            // List thrown exceptions
+            final int[] indices = ((ExceptionTable) attribute).getExceptionIndexTable();
+            printWriter.print("<UL>");
+            for (final int indice : indices) {
+                printWriter
+                    .print("<LI><A HREF=\"" + className + "_cp.html#cp" + indice + "\" TARGET=\"ConstantPool\">Exception class index(" + indice + ")</A>\n");
+            }
+            printWriter.print("</UL>\n");
+            break;
+        case Const.ATTR_LINE_NUMBER_TABLE:
+            final LineNumber[] lineNumbers = ((LineNumberTable) attribute).getLineNumberTable();
+            // List line number pairs
+            printWriter.print("<P>");
+            for (int i = 0; i < lineNumbers.length; i++) {
+                printWriter.print("(" + lineNumbers[i].getStartPC() + ",&nbsp;" + lineNumbers[i].getLineNumber() + ")");
+                if (i < lineNumbers.length - 1) {
+                    printWriter.print(", "); // breakable
                 }
-                file.print("</UL>\n");
-                break;
-            case Const.ATTR_INNER_CLASSES:
-                final InnerClass[] classes = ((InnerClasses) attribute).getInnerClasses();
-                // List inner classes
-                file.print("<UL>");
-                for (final InnerClass classe : classes) {
-                    String name;
-                    String access;
-                    index = classe.getInnerNameIndex();
-                    if (index > 0) {
-                        name = ((ConstantUtf8) constant_pool.getConstant(index, Const.CONSTANT_Utf8))
-                                .getBytes();
-                    } else {
-                        name = "&lt;anonymous&gt;";
-                    }
-                    access = Utility.accessToString(classe.getInnerAccessFlags());
-                    file.print("<LI><FONT COLOR=\"#FF0000\">" + access + "</FONT> "
-                            + constant_html.referenceConstant(classe.getInnerClassIndex())
-                            + " in&nbsp;class "
-                            + constant_html.referenceConstant(classe.getOuterClassIndex())
-                            + " named " + name + "</LI>\n");
+            }
+            break;
+        case Const.ATTR_LOCAL_VARIABLE_TABLE:
+            // List name, range and type
+            printWriter.print("<UL>");
+            ((LocalVariableTable) attribute).forEach(var -> {
+                final int sigIdx = var.getSignatureIndex();
+                String signature = constantPool.getConstantUtf8(sigIdx).getBytes();
+                signature = Utility.signatureToString(signature, false);
+                final int start = var.getStartPC();
+                final int end = start + var.getLength();
+                printWriter.println("<LI>" + Class2HTML.referenceType(signature) + "&nbsp;<B>" + var.getName() + "</B> in slot %" + var.getIndex()
+                    + "<BR>Valid from lines " + "<A HREF=\"" + className + "_code.html#code" + methodNumber + "@" + start + "\" TARGET=Code>" + start
+                    + "</A> to " + "<A HREF=\"" + className + "_code.html#code" + methodNumber + "@" + end + "\" TARGET=Code>" + end + "</A></LI>");
+            });
+            printWriter.print("</UL>\n");
+            break;
+        case Const.ATTR_INNER_CLASSES:
+            // List inner classes
+            printWriter.print("<UL>");
+            for (final InnerClass clazz : ((InnerClasses) attribute).getInnerClasses()) {
+                final String name;
+                final String access;
+                index = clazz.getInnerNameIndex();
+                if (index > 0) {
+                    name = constantPool.getConstantUtf8(index).getBytes();
+                } else {
+                    name = "&lt;anonymous&gt;";
                 }
-                file.print("</UL>\n");
-                break;
-            default: // Such as Unknown attribute or Deprecated
-                file.print("<P>" + attribute);
+                access = Utility.accessToString(clazz.getInnerAccessFlags());
+                printWriter.print("<LI><FONT COLOR=\"#FF0000\">" + access + "</FONT> " + constantHtml.referenceConstant(clazz.getInnerClassIndex())
+                    + " in&nbsp;class " + constantHtml.referenceConstant(clazz.getOuterClassIndex()) + " named " + name + "</LI>\n");
+            }
+            printWriter.print("</UL>\n");
+            break;
+        default: // Such as Unknown attribute or Deprecated
+            printWriter.print("<P>" + attribute);
         }
-        file.println("</TD></TR>");
-        file.flush();
+        printWriter.println("</TD></TR>");
+        printWriter.flush();
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELComparator.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELComparator.java
index e83fd24c1cb..2e663bfdaa1 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELComparator.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELComparator.java
@@ -35,8 +35,7 @@ public interface BCELComparator {
      * @param THAT
      * @return true if and only if THIS equals THAT
      */
-    boolean equals( Object THIS, Object THAT );
-
+    boolean equals(Object THIS, Object THAT);
 
     /**
      * Return hashcode for THIS.hashCode()
@@ -44,5 +43,5 @@ public interface BCELComparator {
      * @param THIS
      * @return hashcode for THIS.hashCode()
      */
-    int hashCode( Object THIS );
+    int hashCode(Object THIS);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java
index ae7f74099e9..c931fb1e422 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -60,45 +60,85 @@
 import com.sun.org.apache.bcel.internal.generic.Type;
 
 /**
- * Factory creates il.append() statements, and sets instruction targets.
- * A helper class for BCELifier.
+ * Factory creates il.append() statements, and sets instruction targets. A helper class for BCELifier.
  *
  * @see BCELifier
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 class BCELFactory extends EmptyVisitor {
 
-    private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+".";
-    private final MethodGen _mg;
-    private final PrintWriter _out;
-    private final ConstantPoolGen _cp;
+    private static final String CONSTANT_PREFIX = Const.class.getSimpleName() + ".";
+    private final MethodGen methodGen;
+    private final PrintWriter printWriter;
+    private final ConstantPoolGen constantPoolGen;
 
+    private final Map<Instruction, InstructionHandle> branchMap = new HashMap<>();
+
+    // Memorize BranchInstructions that need an update
+    private final List<BranchInstruction> branches = new ArrayList<>();
 
     BCELFactory(final MethodGen mg, final PrintWriter out) {
-        _mg = mg;
-        _cp = mg.getConstantPool();
-        _out = out;
+        methodGen = mg;
+        constantPoolGen = mg.getConstantPool();
+        printWriter = out;
     }
 
-    private final Map<Instruction, InstructionHandle> branch_map = new HashMap<>();
+    private void createConstant(final Object value) {
+        String embed = value.toString();
+        if (value instanceof String) {
+            embed = '"' + Utility.convertString(embed) + '"';
+        } else if (value instanceof Character) {
+            embed = "(char)0x" + Integer.toHexString(((Character) value).charValue());
+        } else if (value instanceof Float) {
+            final Float f = (Float) value;
+            if (Float.isNaN(f)) {
+                embed = "Float.NaN";
+            } else if (f == Float.POSITIVE_INFINITY) {
+                embed = "Float.POSITIVE_INFINITY";
+            } else if (f == Float.NEGATIVE_INFINITY) {
+                embed = "Float.NEGATIVE_INFINITY";
+            } else {
+                embed += "f";
+            }
+        }  else if (value instanceof Double) {
+            final Double d = (Double) value;
+            if (Double.isNaN(d)) {
+                embed = "Double.NaN";
+            } else if (d == Double.POSITIVE_INFINITY) {
+                embed = "Double.POSITIVE_INFINITY";
+            } else if (d == Double.NEGATIVE_INFINITY) {
+                embed = "Double.NEGATIVE_INFINITY";
+            } else {
+                embed += "d";
+            }
+        } else if (value instanceof Long) {
+            embed += "L";
+        } else if (value instanceof ObjectType) {
+            final ObjectType ot = (ObjectType) value;
+            embed = "new ObjectType(\"" + ot.getClassName() + "\")";
+        } else if (value instanceof ArrayType) {
+            final ArrayType at = (ArrayType) value;
+            embed = "new ArrayType(" + BCELifier.printType(at.getBasicType()) + ", " + at.getDimensions() + ")";
+        }
 
+        printWriter.println("il.append(new PUSH(_cp, " + embed + "));");
+    }
 
     public void start() {
-        if (!_mg.isAbstract() && !_mg.isNative()) {
-            for (InstructionHandle ih = _mg.getInstructionList().getStart(); ih != null; ih = ih
-                    .getNext()) {
+        if (!methodGen.isAbstract() && !methodGen.isNative()) {
+            for (InstructionHandle ih = methodGen.getInstructionList().getStart(); ih != null; ih = ih.getNext()) {
                 final Instruction i = ih.getInstruction();
                 if (i instanceof BranchInstruction) {
-                    branch_map.put(i, ih); // memorize container
+                    branchMap.put(i, ih); // memorize container
                 }
                 if (ih.hasTargeters()) {
                     if (i instanceof BranchInstruction) {
-                        _out.println("    InstructionHandle ih_" + ih.getPosition() + ";");
+                        printWriter.println("    InstructionHandle ih_" + ih.getPosition() + ";");
                     } else {
-                        _out.print("    InstructionHandle ih_" + ih.getPosition() + " = ");
+                        printWriter.print("    InstructionHandle ih_" + ih.getPosition() + " = ");
                     }
                 } else {
-                    _out.print("    ");
+                    printWriter.print("    ");
                 }
                 if (!visitInstruction(i)) {
                     i.accept(this);
@@ -109,167 +149,74 @@ public void start() {
         }
     }
 
-
-    private boolean visitInstruction( final Instruction i ) {
-        final short opcode = i.getOpcode();
-        if ((InstructionConst.getInstruction(opcode) != null)
-                && !(i instanceof ConstantPushInstruction) && !(i instanceof ReturnInstruction)) { // Handled below
-            _out.println("il.append(InstructionConst."
-                    + i.getName().toUpperCase(Locale.ENGLISH) + ");");
-            return true;
-        }
-        return false;
+    private void updateBranchTargets() {
+        branches.forEach(bi -> {
+            final BranchHandle bh = (BranchHandle) branchMap.get(bi);
+            final int pos = bh.getPosition();
+            final String name = bi.getName() + "_" + pos;
+            int targetPos = bh.getTarget().getPosition();
+            printWriter.println("    " + name + ".setTarget(ih_" + targetPos + ");");
+            if (bi instanceof Select) {
+                final InstructionHandle[] ihs = ((Select) bi).getTargets();
+                for (int j = 0; j < ihs.length; j++) {
+                    targetPos = ihs[j].getPosition();
+                    printWriter.println("    " + name + ".setTarget(" + j + ", ih_" + targetPos + ");");
+                }
+            }
+        });
     }
 
-
-    @Override
-    public void visitLocalVariableInstruction( final LocalVariableInstruction i ) {
-        final short opcode = i.getOpcode();
-        final Type type = i.getType(_cp);
-        if (opcode == Const.IINC) {
-            _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement()
-                    + "));");
-        } else {
-            final String kind = (opcode < Const.ISTORE) ? "Load" : "Store";
-            _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type)
-                    + ", " + i.getIndex() + "));");
+    private void updateExceptionHandlers() {
+        final CodeExceptionGen[] handlers = methodGen.getExceptionHandlers();
+        for (final CodeExceptionGen h : handlers) {
+            final String type = h.getCatchType() == null ? "null" : BCELifier.printType(h.getCatchType());
+            printWriter.println("    method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + ", " + "ih_" + h.getEndPC().getPosition() + ", "
+                + "ih_" + h.getHandlerPC().getPosition() + ", " + type + ");");
         }
     }
 
-
-    @Override
-    public void visitArrayInstruction( final ArrayInstruction i ) {
-        final short opcode = i.getOpcode();
-        final Type type = i.getType(_cp);
-        final String kind = (opcode < Const.IASTORE) ? "Load" : "Store";
-        _out.println("il.append(_factory.createArray" + kind + "(" + BCELifier.printType(type)
-                + "));");
-    }
-
-
-    @Override
-    public void visitFieldInstruction( final FieldInstruction i ) {
-        final short opcode = i.getOpcode();
-        final String class_name = i.getReferenceType(_cp).getSignature();
-        final String field_name = i.getFieldName(_cp);
-        final Type type = i.getFieldType(_cp);
-        _out.println("il.append(_factory.createFieldAccess(\"" + class_name + "\", \"" + field_name
-                + "\", " + BCELifier.printType(type) + ", " + CONSTANT_PREFIX
-                + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));");
-    }
-
-
-    @Override
-    public void visitInvokeInstruction( final InvokeInstruction i ) {
-        final short opcode = i.getOpcode();
-        final String class_name = i.getReferenceType(_cp).getSignature();
-        final String method_name = i.getMethodName(_cp);
-        final Type type = i.getReturnType(_cp);
-        final Type[] arg_types = i.getArgumentTypes(_cp);
-        _out.println("il.append(_factory.createInvoke(\"" + class_name + "\", \"" + method_name
-                + "\", " + BCELifier.printType(type) + ", "
-                + BCELifier.printArgumentTypes(arg_types) + ", " + CONSTANT_PREFIX
-                + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));");
-    }
-
-
     @Override
     @SuppressWarnings("fallthrough") // by design for case Const.ANEWARRAY
-    public void visitAllocationInstruction( final AllocationInstruction i ) {
+    public void visitAllocationInstruction(final AllocationInstruction i) {
         Type type;
         if (i instanceof CPInstruction) {
-            type = ((CPInstruction) i).getType(_cp);
+            type = ((CPInstruction) i).getType(constantPoolGen);
         } else {
             type = ((NEWARRAY) i).getType();
         }
         final short opcode = ((Instruction) i).getOpcode();
         int dim = 1;
         switch (opcode) {
-            case Const.NEW:
-                _out.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName()
-                        + "\"));");
-                break;
-            case Const.MULTIANEWARRAY:
-                dim = ((MULTIANEWARRAY) i).getDimensions();
-                //$FALL-THROUGH$
-            case Const.ANEWARRAY:
-            case Const.NEWARRAY:
-                if (type instanceof ArrayType) {
-                    type = ((ArrayType) type).getBasicType();
-                }
-                _out.println("il.append(_factory.createNewArray(" + BCELifier.printType(type)
-                        + ", (short) " + dim + "));");
-                break;
-            default:
-                throw new IllegalArgumentException("Unhandled opcode: " + opcode);
-        }
-    }
-
-
-    private void createConstant( final Object value ) {
-        String embed = value.toString();
-        if (value instanceof String) {
-            embed = '"' + Utility.convertString(embed) + '"';
-        } else if (value instanceof Character) {
-            embed = "(char)0x" + Integer.toHexString(((Character) value).charValue());
-        } else if (value instanceof Float) {
-            embed += "f";
-        } else if (value instanceof Long) {
-            embed += "L";
-        } else if (value instanceof ObjectType) {
-            final ObjectType ot = (ObjectType) value;
-            embed = "new ObjectType(\""+ot.getClassName()+"\")";
+        case Const.NEW:
+            printWriter.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName() + "\"));");
+            break;
+        case Const.MULTIANEWARRAY:
+            dim = ((MULTIANEWARRAY) i).getDimensions();
+            //$FALL-THROUGH$
+        case Const.NEWARRAY:
+            if (type instanceof ArrayType) {
+                type = ((ArrayType) type).getBasicType();
+            }
+            //$FALL-THROUGH$
+        case Const.ANEWARRAY:
+            printWriter.println("il.append(_factory.createNewArray(" + BCELifier.printType(type) + ", (short) " + dim + "));");
+            break;
+        default:
+            throw new IllegalArgumentException("Unhandled opcode: " + opcode);
         }
-
-        _out.println("il.append(new PUSH(_cp, " + embed + "));");
-    }
-
-
-    @Override
-    public void visitLDC( final LDC i ) {
-        createConstant(i.getValue(_cp));
-    }
-
-
-    @Override
-    public void visitLDC2_W( final LDC2_W i ) {
-        createConstant(i.getValue(_cp));
     }
 
-
     @Override
-    public void visitConstantPushInstruction( final ConstantPushInstruction i ) {
-        createConstant(i.getValue());
-    }
-
-
-    @Override
-    public void visitINSTANCEOF( final INSTANCEOF i ) {
-        final Type type = i.getType(_cp);
-        _out.println("il.append(new INSTANCEOF(_cp.addClass(" + BCELifier.printType(type) + ")));");
-    }
-
-
-    @Override
-    public void visitCHECKCAST( final CHECKCAST i ) {
-        final Type type = i.getType(_cp);
-        _out.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));");
+    public void visitArrayInstruction(final ArrayInstruction i) {
+        final short opcode = i.getOpcode();
+        final Type type = i.getType(constantPoolGen);
+        final String kind = opcode < Const.IASTORE ? "Load" : "Store";
+        printWriter.println("il.append(_factory.createArray" + kind + "(" + BCELifier.printType(type) + "));");
     }
 
-
     @Override
-    public void visitReturnInstruction( final ReturnInstruction i ) {
-        final Type type = i.getType(_cp);
-        _out.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));");
-    }
-
-    // Memorize BranchInstructions that need an update
-    private final List<BranchInstruction> branches = new ArrayList<>();
-
-
-    @Override
-    public void visitBranchInstruction( final BranchInstruction bi ) {
-        final BranchHandle bh = (BranchHandle) branch_map.get(bi);
+    public void visitBranchInstruction(final BranchInstruction bi) {
+        final BranchHandle bh = (BranchHandle) branchMap.get(bi);
         final int pos = bh.getPosition();
         final String name = bi.getName() + "_" + pos;
         if (bi instanceof Select) {
@@ -284,68 +231,110 @@ public void visitBranchInstruction( final BranchInstruction bi ) {
                 }
             }
             args.append(" }");
-            _out.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH)
-                    + "(" + args + ", new InstructionHandle[] { ");
+            printWriter.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH) + "(" + args + ", new InstructionHandle[] { ");
             for (int i = 0; i < matchs.length; i++) {
-                _out.print("null");
+                printWriter.print("null");
                 if (i < matchs.length - 1) {
-                    _out.print(", ");
+                    printWriter.print(", ");
                 }
             }
-            _out.println(" }, null);");
+            printWriter.println(" }, null);");
         } else {
-            final int t_pos = bh.getTarget().getPosition();
+            final int tPos = bh.getTarget().getPosition();
             String target;
-            if (pos > t_pos) {
-                target = "ih_" + t_pos;
+            if (pos > tPos) {
+                target = "ih_" + tPos;
             } else {
                 branches.add(bi);
                 target = "null";
             }
-            _out.println("    BranchInstruction " + name + " = _factory.createBranchInstruction("
-                    + CONSTANT_PREFIX + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target
-                    + ");");
+            printWriter.println("    BranchInstruction " + name + " = _factory.createBranchInstruction(" + CONSTANT_PREFIX
+                + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target + ");");
         }
         if (bh.hasTargeters()) {
-            _out.println("    ih_" + pos + " = il.append(" + name + ");");
+            printWriter.println("    ih_" + pos + " = il.append(" + name + ");");
         } else {
-            _out.println("    il.append(" + name + ");");
+            printWriter.println("    il.append(" + name + ");");
         }
     }
 
+    @Override
+    public void visitCHECKCAST(final CHECKCAST i) {
+        final Type type = i.getType(constantPoolGen);
+        printWriter.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));");
+    }
+
+    @Override
+    public void visitConstantPushInstruction(final ConstantPushInstruction i) {
+        createConstant(i.getValue());
+    }
 
     @Override
-    public void visitRET( final RET i ) {
-        _out.println("il.append(new RET(" + i.getIndex() + ")));");
+    public void visitFieldInstruction(final FieldInstruction i) {
+        final short opcode = i.getOpcode();
+        final String className = i.getReferenceType(constantPoolGen).getClassName();
+        final String fieldName = i.getFieldName(constantPoolGen);
+        final Type type = i.getFieldType(constantPoolGen);
+        printWriter.println("il.append(_factory.createFieldAccess(\"" + className + "\", \"" + fieldName + "\", " + BCELifier.printType(type) + ", "
+            + CONSTANT_PREFIX + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));");
     }
 
+    @Override
+    public void visitINSTANCEOF(final INSTANCEOF i) {
+        final Type type = i.getType(constantPoolGen);
+        printWriter.println("il.append(_factory.createInstanceOf(" + BCELifier.printType(type) + "));");
+    }
 
-    private void updateBranchTargets() {
-        for (final BranchInstruction bi : branches) {
-            final BranchHandle bh = (BranchHandle) branch_map.get(bi);
-            final int pos = bh.getPosition();
-            final String name = bi.getName() + "_" + pos;
-            int t_pos = bh.getTarget().getPosition();
-            _out.println("    " + name + ".setTarget(ih_" + t_pos + ");");
-            if (bi instanceof Select) {
-                final InstructionHandle[] ihs = ((Select) bi).getTargets();
-                for (int j = 0; j < ihs.length; j++) {
-                    t_pos = ihs[j].getPosition();
-                    _out.println("    " + name + ".setTarget(" + j + ", ih_" + t_pos + ");");
-                }
-            }
+    private boolean visitInstruction(final Instruction i) {
+        final short opcode = i.getOpcode();
+        if (InstructionConst.getInstruction(opcode) != null && !(i instanceof ConstantPushInstruction) && !(i instanceof ReturnInstruction)) { // Handled below
+            printWriter.println("il.append(InstructionConst." + i.getName().toUpperCase(Locale.ENGLISH) + ");");
+            return true;
         }
+        return false;
     }
 
+    @Override
+    public void visitInvokeInstruction(final InvokeInstruction i) {
+        final short opcode = i.getOpcode();
+        final String className = i.getReferenceType(constantPoolGen).getClassName();
+        final String methodName = i.getMethodName(constantPoolGen);
+        final Type type = i.getReturnType(constantPoolGen);
+        final Type[] argTypes = i.getArgumentTypes(constantPoolGen);
+        printWriter.println("il.append(_factory.createInvoke(\"" + className + "\", \"" + methodName + "\", " + BCELifier.printType(type) + ", "
+            + BCELifier.printArgumentTypes(argTypes) + ", " + CONSTANT_PREFIX + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));");
+    }
 
-    private void updateExceptionHandlers() {
-        final CodeExceptionGen[] handlers = _mg.getExceptionHandlers();
-        for (final CodeExceptionGen h : handlers) {
-            final String type = (h.getCatchType() == null) ? "null" : BCELifier.printType(h
-                    .getCatchType());
-            _out.println("    method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition()
-                    + ", " + "ih_" + h.getEndPC().getPosition() + ", " + "ih_"
-                    + h.getHandlerPC().getPosition() + ", " + type + ");");
+    @Override
+    public void visitLDC(final LDC i) {
+        createConstant(i.getValue(constantPoolGen));
+    }
+
+    @Override
+    public void visitLDC2_W(final LDC2_W i) {
+        createConstant(i.getValue(constantPoolGen));
+    }
+
+    @Override
+    public void visitLocalVariableInstruction(final LocalVariableInstruction i) {
+        final short opcode = i.getOpcode();
+        final Type type = i.getType(constantPoolGen);
+        if (opcode == Const.IINC) {
+            printWriter.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() + "));");
+        } else {
+            final String kind = opcode < Const.ISTORE ? "Load" : "Store";
+            printWriter.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + ", " + i.getIndex() + "));");
         }
     }
+
+    @Override
+    public void visitRET(final RET i) {
+        printWriter.println("il.append(new RET(" + i.getIndex() + "));");
+    }
+
+    @Override
+    public void visitReturnInstruction(final ReturnInstruction i) {
+        final Type type = i.getType(constantPoolGen);
+        printWriter.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));");
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java
index efe19524cdb..151083ea71b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,13 +22,16 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.Repository;
 import com.sun.org.apache.bcel.internal.classfile.ClassParser;
 import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
+import com.sun.org.apache.bcel.internal.classfile.ExceptionTable;
 import com.sun.org.apache.bcel.internal.classfile.Field;
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
 import com.sun.org.apache.bcel.internal.classfile.Method;
@@ -40,12 +42,11 @@
 import com.sun.org.apache.bcel.internal.generic.Type;
 
 /**
- * This class takes a given JavaClass object and converts it to a
- * Java program that creates that very class using BCEL. This
- * gives new users of BCEL a useful example showing how things
- * are done with BCEL. It does not cover all features of BCEL,
- * but tries to mimic hand-written code as close as possible.
+ * This class takes a given JavaClass object and converts it to a Java program that creates that very class using BCEL.
+ * This gives new users of BCEL a useful example showing how things are done with BCEL. It does not cover all features
+ * of BCEL, but tries to mimic hand-written code as close as possible.
  *
+ * @LastModified: Feb 2023
  */
 public class BCELifier extends com.sun.org.apache.bcel.internal.classfile.EmptyVisitor {
 
@@ -53,186 +54,79 @@ public class BCELifier extends com.sun.org.apache.bcel.internal.classfile.EmptyV
      * Enum corresponding to flag source.
      */
     public enum FLAGS {
-        UNKNOWN,
-        CLASS,
-        METHOD,
+        UNKNOWN, CLASS, METHOD,
     }
 
     // The base package name for imports; assumes Const is at the top level
     // N.B we use the class so renames will be detected by the compiler/IDE
     private static final String BASE_PACKAGE = Const.class.getPackage().getName();
-    private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+".";
+    private static final String CONSTANT_PREFIX = Const.class.getSimpleName() + ".";
 
-    private final JavaClass _clazz;
-    private final PrintWriter _out;
-    private final ConstantPoolGen _cp;
-
-    /** @param clazz Java class to "decompile"
-     * @param out where to output Java program
-     */
-    public BCELifier(final JavaClass clazz, final OutputStream out) {
-        _clazz = clazz;
-        _out = new PrintWriter(out);
-        _cp = new ConstantPoolGen(_clazz.getConstantPool());
+    // Needs to be accessible from unit test code
+    static JavaClass getJavaClass(final String name) throws ClassNotFoundException, IOException {
+        JavaClass javaClass;
+        if ((javaClass = Repository.lookupClass(name)) == null) {
+            javaClass = new ClassParser(name).parse(); // May throw IOException
+        }
+        return javaClass;
     }
 
-
-    /** Start Java code generation
+    /**
+     * Default main method
      */
-    public void start() {
-        visitJavaClass(_clazz);
-        _out.flush();
-    }
-
-
-    @Override
-    public void visitJavaClass( final JavaClass clazz ) {
-        String class_name = clazz.getClassName();
-        final String super_name = clazz.getSuperclassName();
-        final String package_name = clazz.getPackageName();
-        final String inter = Utility.printArray(clazz.getInterfaceNames(), false, true);
-        if (!"".equals(package_name)) {
-            class_name = class_name.substring(package_name.length() + 1);
-            _out.println("package " + package_name + ";");
-            _out.println();
-        }
-        _out.println("import " + BASE_PACKAGE + ".generic.*;");
-        _out.println("import " + BASE_PACKAGE + ".classfile.*;");
-        _out.println("import " + BASE_PACKAGE + ".*;");
-        _out.println("import java.io.*;");
-        _out.println();
-        _out.println("public class " + class_name + "Creator {");
-        _out.println("  private InstructionFactory _factory;");
-        _out.println("  private ConstantPoolGen    _cp;");
-        _out.println("  private ClassGen           _cg;");
-        _out.println();
-        _out.println("  public " + class_name + "Creator() {");
-        _out.println("    _cg = new ClassGen(\""
-                + (("".equals(package_name)) ? class_name : package_name + "." + class_name)
-                + "\", \"" + super_name + "\", " + "\"" + clazz.getSourceFileName() + "\", "
-                + printFlags(clazz.getAccessFlags(), FLAGS.CLASS) + ", "
-                + "new String[] { " + inter + " });");
-        _out.println("    _cg.setMajor(" + clazz.getMajor() +");");
-        _out.println("    _cg.setMinor(" + clazz.getMinor() +");");
-        _out.println();
-        _out.println("    _cp = _cg.getConstantPool();");
-        _out.println("    _factory = new InstructionFactory(_cg, _cp);");
-        _out.println("  }");
-        _out.println();
-        printCreate();
-        final Field[] fields = clazz.getFields();
-        if (fields.length > 0) {
-            _out.println("  private void createFields() {");
-            _out.println("    FieldGen field;");
-            for (final Field field : fields) {
-                field.accept(this);
-            }
-            _out.println("  }");
-            _out.println();
-        }
-        final Method[] methods = clazz.getMethods();
-        for (int i = 0; i < methods.length; i++) {
-            _out.println("  private void createMethod_" + i + "() {");
-            methods[i].accept(this);
-            _out.println("  }");
-            _out.println();
+    public static void _main(final String[] argv) throws Exception {
+        if (argv.length != 1) {
+            System.out.println("Usage: BCELifier className");
+            System.out.println("\tThe class must exist on the classpath");
+            return;
         }
-        printMain();
-        _out.println("}");
+        final BCELifier bcelifier = new BCELifier(getJavaClass(argv[0]), System.out);
+        bcelifier.start();
     }
 
-
-    private void printCreate() {
-        _out.println("  public void create(OutputStream out) throws IOException {");
-        final Field[] fields = _clazz.getFields();
-        if (fields.length > 0) {
-            _out.println("    createFields();");
-        }
-        final Method[] methods = _clazz.getMethods();
-        for (int i = 0; i < methods.length; i++) {
-            _out.println("    createMethod_" + i + "();");
+    static String printArgumentTypes(final Type[] argTypes) {
+        if (argTypes.length == 0) {
+            return "Type.NO_ARGS";
         }
-        _out.println("    _cg.getJavaClass().dump(out);");
-        _out.println("  }");
-        _out.println();
-    }
-
-
-    private void printMain() {
-        final String class_name = _clazz.getClassName();
-        _out.println("  public static void main(String[] args) throws Exception {");
-        _out.println("    " + class_name + "Creator creator = new " + class_name + "Creator();");
-        _out.println("    creator.create(new FileOutputStream(\"" + class_name + ".class\"));");
-        _out.println("  }");
-    }
-
-
-    @Override
-    public void visitField( final Field field ) {
-        _out.println();
-        _out.println("    field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", "
-                + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);");
-        final ConstantValue cv = field.getConstantValue();
-        if (cv != null) {
-            final String value = cv.toString();
-            _out.println("    field.setInitValue(" + value + ")");
+        final StringBuilder args = new StringBuilder();
+        for (int i = 0; i < argTypes.length; i++) {
+            args.append(printType(argTypes[i]));
+            if (i < argTypes.length - 1) {
+                args.append(", ");
+            }
         }
-        _out.println("    _cg.addField(field.getField());");
-    }
-
-
-    @Override
-    public void visitMethod( final Method method ) {
-        final MethodGen mg = new MethodGen(method, _clazz.getClassName(), _cp);
-        _out.println("    InstructionList il = new InstructionList();");
-        _out.println("    MethodGen method = new MethodGen("
-                + printFlags(method.getAccessFlags(), FLAGS.METHOD) + ", "
-                + printType(mg.getReturnType()) + ", "
-                + printArgumentTypes(mg.getArgumentTypes()) + ", "
-                + "new String[] { " + Utility.printArray(mg.getArgumentNames(), false, true)
-                + " }, \"" + method.getName() + "\", \"" + _clazz.getClassName() + "\", il, _cp);");
-        _out.println();
-        final BCELFactory factory = new BCELFactory(mg, _out);
-        factory.start();
-        _out.println("    method.setMaxStack();");
-        _out.println("    method.setMaxLocals();");
-        _out.println("    _cg.addMethod(method.getMethod());");
-        _out.println("    il.dispose();");
+        return "new Type[] { " + args.toString() + " }";
     }
 
-
-    static String printFlags( final int flags ) {
+    static String printFlags(final int flags) {
         return printFlags(flags, FLAGS.UNKNOWN);
     }
 
     /**
      * Return a string with the flag settings
+     *
      * @param flags the flags field to interpret
      * @param location the item type
      * @return the formatted string
      * @since 6.0 made public
      */
-    public static String printFlags( final int flags, final FLAGS location ) {
+    public static String printFlags(final int flags, final FLAGS location) {
         if (flags == 0) {
             return "0";
         }
         final StringBuilder buf = new StringBuilder();
         for (int i = 0, pow = 1; pow <= Const.MAX_ACC_FLAG_I; i++) {
             if ((flags & pow) != 0) {
-                if ((pow == Const.ACC_SYNCHRONIZED) && (location == FLAGS.CLASS)) {
-                    buf.append(CONSTANT_PREFIX+"ACC_SUPER | ");
-                } else if ((pow == Const.ACC_VOLATILE) && (location == FLAGS.METHOD)) {
-                    buf.append(CONSTANT_PREFIX+"ACC_BRIDGE | ");
-                } else if ((pow == Const.ACC_TRANSIENT) && (location == FLAGS.METHOD)) {
-                    buf.append(CONSTANT_PREFIX+"ACC_VARARGS | ");
+                if (pow == Const.ACC_SYNCHRONIZED && location == FLAGS.CLASS) {
+                    buf.append(CONSTANT_PREFIX).append("ACC_SUPER | ");
+                } else if (pow == Const.ACC_VOLATILE && location == FLAGS.METHOD) {
+                    buf.append(CONSTANT_PREFIX).append("ACC_BRIDGE | ");
+                } else if (pow == Const.ACC_TRANSIENT && location == FLAGS.METHOD) {
+                    buf.append(CONSTANT_PREFIX).append("ACC_VARARGS | ");
+                } else if (i < Const.ACCESS_NAMES_LENGTH) {
+                    buf.append(CONSTANT_PREFIX).append("ACC_").append(Const.getAccessName(i).toUpperCase(Locale.ENGLISH)).append(" | ");
                 } else {
-                    if (i < Const.ACCESS_NAMES_LENGTH) {
-                        buf.append(CONSTANT_PREFIX+"ACC_")
-                                .append(Const.getAccessName(i).toUpperCase(Locale.ENGLISH))
-                                .append( " | ");
-                    } else {
-                        buf.append(String.format (CONSTANT_PREFIX+"ACC_BIT %x | ", pow));
-                    }
+                    buf.append(String.format(CONSTANT_PREFIX + "ACC_BIT %x | ", pow));
                 }
             }
             pow <<= 1;
@@ -241,68 +135,188 @@ public static String printFlags( final int flags, final FLAGS location ) {
         return str.substring(0, str.length() - 3);
     }
 
-
-    static String printArgumentTypes( final Type[] arg_types ) {
-        if (arg_types.length == 0) {
-            return "Type.NO_ARGS";
-        }
-        final StringBuilder args = new StringBuilder();
-        for (int i = 0; i < arg_types.length; i++) {
-            args.append(printType(arg_types[i]));
-            if (i < arg_types.length - 1) {
-                args.append(", ");
-            }
-        }
-        return "new Type[] { " + args.toString() + " }";
-    }
-
-
-    static String printType( final Type type ) {
-        return printType(type.getSignature());
-    }
-
-
-    static String printType( final String signature ) {
+    static String printType(final String signature) {
         final Type type = Type.getType(signature);
         final byte t = type.getType();
         if (t <= Const.T_VOID) {
             return "Type." + Const.getTypeName(t).toUpperCase(Locale.ENGLISH);
-        } else if (type.toString().equals("java.lang.String")) {
+        }
+        if (type.toString().equals("java.lang.String")) {
             return "Type.STRING";
-        } else if (type.toString().equals("java.lang.Object")) {
+        }
+        if (type.toString().equals("java.lang.Object")) {
             return "Type.OBJECT";
-        } else if (type.toString().equals("java.lang.StringBuffer")) {
+        }
+        if (type.toString().equals("java.lang.StringBuffer")) {
             return "Type.STRINGBUFFER";
-        } else if (type instanceof ArrayType) {
+        }
+        if (type instanceof ArrayType) {
             final ArrayType at = (ArrayType) type;
-            return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions()
-                    + ")";
-        } else {
-            return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")";
+            return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions() + ")";
         }
+        return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")";
     }
 
+    static String printType(final Type type) {
+        return printType(type.getSignature());
+    }
 
-    /** Default main method
+    private final JavaClass clazz;
+
+    private final PrintWriter printWriter;
+
+    private final ConstantPoolGen constantPoolGen;
+
+    /**
+     * Constructs a new instance.
+     *
+     * @param clazz Java class to "decompile".
+     * @param out where to print the Java program in UTF-8.
      */
-    public static void main( final String[] argv ) throws Exception {
-        if (argv.length != 1) {
-            System.out.println("Usage: BCELifier classname");
-            System.out.println("\tThe class must exist on the classpath");
-            return;
+    public BCELifier(final JavaClass clazz, final OutputStream out) {
+        this.clazz = clazz;
+        this.printWriter = new PrintWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8), false);
+        this.constantPoolGen = new ConstantPoolGen(this.clazz.getConstantPool());
+    }
+
+    private void printCreate() {
+        printWriter.println("  public void create(OutputStream out) throws IOException {");
+        final Field[] fields = clazz.getFields();
+        if (fields.length > 0) {
+            printWriter.println("    createFields();");
         }
-        final JavaClass java_class = getJavaClass(argv[0]);
-        final BCELifier bcelifier = new BCELifier(java_class, System.out);
-        bcelifier.start();
+        final Method[] methods = clazz.getMethods();
+        for (int i = 0; i < methods.length; i++) {
+            printWriter.println("    createMethod_" + i + "();");
+        }
+        printWriter.println("    _cg.getJavaClass().dump(out);");
+        printWriter.println("  }");
+        printWriter.println();
     }
 
+    private void printMain() {
+        final String className = clazz.getClassName();
+        printWriter.println("  public static void main(String[] args) throws Exception {");
+        printWriter.println("    " + className + "Creator creator = new " + className + "Creator();");
+        printWriter.println("    creator.create(new FileOutputStream(\"" + className + ".class\"));");
+        printWriter.println("  }");
+    }
 
-    // Needs to be accessible from unit test code
-    static JavaClass getJavaClass(final String name) throws ClassNotFoundException, IOException {
-        JavaClass java_class;
-        if ((java_class = Repository.lookupClass(name)) == null) {
-            java_class = new ClassParser(name).parse(); // May throw IOException
+    /**
+     * Start Java code generation
+     */
+    public void start() {
+        visitJavaClass(clazz);
+        printWriter.flush();
+    }
+
+    @Override
+    public void visitField(final Field field) {
+        printWriter.println();
+        printWriter.println(
+            "    field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", " + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);");
+        final ConstantValue cv = field.getConstantValue();
+        if (cv != null) {
+            printWriter.print("    field.setInitValue(");
+            if (field.getType() == Type.CHAR) {
+                printWriter.print("(char)");
+            }
+            if (field.getType() == Type.SHORT) {
+                printWriter.print("(short)");
+            }
+            if (field.getType() == Type.BYTE) {
+                printWriter.print("(byte)");
+            }
+            printWriter.print(cv);
+            if (field.getType() == Type.LONG) {
+                printWriter.print("L");
+            }
+            if (field.getType() == Type.FLOAT) {
+                printWriter.print("F");
+            }
+            if (field.getType() == Type.DOUBLE) {
+                printWriter.print("D");
+            }
+            printWriter.println(");");
+        }
+        printWriter.println("    _cg.addField(field.getField());");
+    }
+
+    @Override
+    public void visitJavaClass(final JavaClass clazz) {
+        String className = clazz.getClassName();
+        final String superName = clazz.getSuperclassName();
+        final String packageName = clazz.getPackageName();
+        final String inter = Utility.printArray(clazz.getInterfaceNames(), false, true);
+        if (packageName != null && !packageName.trim().isEmpty()) {
+            className = className.substring(packageName.length() + 1);
+            printWriter.println("package " + packageName + ";");
+            printWriter.println();
         }
-        return java_class;
+        printWriter.println("import " + BASE_PACKAGE + ".generic.*;");
+        printWriter.println("import " + BASE_PACKAGE + ".classfile.*;");
+        printWriter.println("import " + BASE_PACKAGE + ".*;");
+        printWriter.println("import java.io.*;");
+        printWriter.println();
+        printWriter.println("public class " + className + "Creator {");
+        printWriter.println("  private InstructionFactory _factory;");
+        printWriter.println("  private ConstantPoolGen    _cp;");
+        printWriter.println("  private ClassGen           _cg;");
+        printWriter.println();
+        printWriter.println("  public " + className + "Creator() {");
+        printWriter.println("    _cg = new ClassGen(\"" + (packageName.isEmpty() ? className : packageName + "." + className) + "\", \"" + superName
+            + "\", " + "\"" + clazz.getSourceFileName() + "\", " + printFlags(clazz.getAccessFlags(), FLAGS.CLASS) + ", " + "new String[] { " + inter + " });");
+        printWriter.println("    _cg.setMajor(" + clazz.getMajor() + ");");
+        printWriter.println("    _cg.setMinor(" + clazz.getMinor() + ");");
+        printWriter.println();
+        printWriter.println("    _cp = _cg.getConstantPool();");
+        printWriter.println("    _factory = new InstructionFactory(_cg, _cp);");
+        printWriter.println("  }");
+        printWriter.println();
+        printCreate();
+        final Field[] fields = clazz.getFields();
+        if (fields.length > 0) {
+            printWriter.println("  private void createFields() {");
+            printWriter.println("    FieldGen field;");
+            for (final Field field : fields) {
+                field.accept(this);
+            }
+            printWriter.println("  }");
+            printWriter.println();
+        }
+        final Method[] methods = clazz.getMethods();
+        for (int i = 0; i < methods.length; i++) {
+            printWriter.println("  private void createMethod_" + i + "() {");
+            methods[i].accept(this);
+            printWriter.println("  }");
+            printWriter.println();
+        }
+        printMain();
+        printWriter.println("}");
+    }
+
+    @Override
+    public void visitMethod(final Method method) {
+        final MethodGen mg = new MethodGen(method, clazz.getClassName(), constantPoolGen);
+        printWriter.println("    InstructionList il = new InstructionList();");
+        printWriter.println("    MethodGen method = new MethodGen(" + printFlags(method.getAccessFlags(), FLAGS.METHOD) + ", " + printType(mg.getReturnType())
+            + ", " + printArgumentTypes(mg.getArgumentTypes()) + ", " + "new String[] { " + Utility.printArray(mg.getArgumentNames(), false, true) + " }, \""
+            + method.getName() + "\", \"" + clazz.getClassName() + "\", il, _cp);");
+        final ExceptionTable exceptionTable = method.getExceptionTable();
+        if (exceptionTable != null) {
+            final String[] exceptionNames = exceptionTable.getExceptionNames();
+            for (final String exceptionName : exceptionNames) {
+                printWriter.print("    method.addException(\"");
+                printWriter.print(exceptionName);
+                printWriter.println("\");");
+            }
+        }
+        printWriter.println();
+        final BCELFactory factory = new BCELFactory(mg, printWriter);
+        factory.start();
+        printWriter.println("    method.setMaxStack();");
+        printWriter.println("    method.setMaxLocals();");
+        printWriter.println("    _cg.addMethod(method.getMethod());");
+        printWriter.println("    il.dispose();");
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ByteSequence.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ByteSequence.java
index 67ac04543ec..65dfd3f3eaf 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ByteSequence.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ByteSequence.java
@@ -25,31 +25,11 @@
 import java.io.DataInputStream;
 
 /**
- * Utility class that implements a sequence of bytes which can be read
- * via the `readByte()' method. This is used to implement a wrapper for the
- * Java byte code stream to gain some more readability.
- *
+ * Utility class that implements a sequence of bytes which can be read via the 'readByte()' method. This is used to
+ * implement a wrapper for the Java byte code stream to gain some more readability.
  */
 public final class ByteSequence extends DataInputStream {
 
-    private final ByteArrayStream byteStream;
-
-
-    public ByteSequence(final byte[] bytes) {
-        super(new ByteArrayStream(bytes));
-        byteStream = (ByteArrayStream) in;
-    }
-
-
-    public int getIndex() {
-        return byteStream.getPosition();
-    }
-
-
-    void unreadByte() {
-        byteStream.unreadByte();
-    }
-
     private static final class ByteArrayStream extends ByteArrayInputStream {
 
         ByteArrayStream(final byte[] bytes) {
@@ -67,4 +47,19 @@ void unreadByte() {
             }
         }
     }
+
+    private final ByteArrayStream byteStream;
+
+    public ByteSequence(final byte[] bytes) {
+        super(new ByteArrayStream(bytes));
+        byteStream = (ByteArrayStream) in;
+    }
+
+    public int getIndex() {
+        return byteStream.getPosition();
+    }
+
+    void unreadByte() {
+        byteStream.unreadByte();
+    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java
index 8ee30c5936d..f644c698b72 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,9 +20,12 @@
 package com.sun.org.apache.bcel.internal.util;
 
 import java.io.File;
-import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -37,89 +40,49 @@
 /**
  * Read class file(s) and convert them into HTML files.
  *
- * Given a JavaClass object "class" that is in package "package" five files
- * will be created in the specified directory.
+ * Given a JavaClass object "class" that is in package "package" five files will be created in the specified directory.
  *
  * <OL>
- * <LI> "package"."class".html as the main file which defines the frames for
- * the following subfiles.
- * <LI>  "package"."class"_attributes.html contains all (known) attributes found in the file
- * <LI>  "package"."class"_cp.html contains the constant pool
- * <LI>  "package"."class"_code.html contains the byte code
- * <LI>  "package"."class"_methods.html contains references to all methods and fields of the class
+ * <LI>"package"."class".html as the main file which defines the frames for the following subfiles.
+ * <LI>"package"."class"_attributes.html contains all (known) attributes found in the file
+ * <LI>"package"."class"_cp.html contains the constant pool
+ * <LI>"package"."class"_code.html contains the byte code
+ * <LI>"package"."class"_methods.html contains references to all methods and fields of the class
  * </OL>
  *
- * All subfiles reference each other appropriately, e.g. clicking on a
- * method in the Method's frame will jump to the appropriate method in
- * the Code frame.
+ * All subfiles reference each other appropriately, e.g. clicking on a method in the Method's frame will jump to the
+ * appropriate method in the Code frame.
  *
- * @LastModified: Jan 2020
+ * @LastModified: Feb 2023
  */
 public class Class2HTML {
 
-    private final JavaClass java_class; // current class object
-    private final String dir;
-    private static String class_package; // name of package, unclean to make it static, but ...
-    private static String class_name; // name of current class, dito
-    private static ConstantPool constant_pool;
-    private static final Set<String> basic_types = new HashSet<>();
-
+    private static String classPackage; // name of package, unclean to make it static, but ...
+    private static String className; // name of current class, dito
+    private static ConstantPool constantPool;
+    private static final Set<String> basicTypes = new HashSet<>();
     static {
-        basic_types.add("int");
-        basic_types.add("short");
-        basic_types.add("boolean");
-        basic_types.add("void");
-        basic_types.add("char");
-        basic_types.add("byte");
-        basic_types.add("long");
-        basic_types.add("double");
-        basic_types.add("float");
+        basicTypes.add("int");
+        basicTypes.add("short");
+        basicTypes.add("boolean");
+        basicTypes.add("void");
+        basicTypes.add("char");
+        basicTypes.add("byte");
+        basicTypes.add("long");
+        basicTypes.add("double");
+        basicTypes.add("float");
     }
 
-    /**
-     * Write contents of the given JavaClass into HTML files.
-     *
-     * @param java_class The class to write
-     * @param dir The directory to put the files in
-     */
-    public Class2HTML(final JavaClass java_class, final String dir) throws IOException {
-        final Method[] methods = java_class.getMethods();
-        this.java_class = java_class;
-        this.dir = dir;
-        class_name = java_class.getClassName(); // Remember full name
-        constant_pool = java_class.getConstantPool();
-        // Get package name by tacking off everything after the last `.'
-        final int index = class_name.lastIndexOf('.');
-        if (index > -1) {
-            class_package = class_name.substring(0, index);
-        } else {
-            class_package = ""; // default package
-        }
-        final ConstantHTML constant_html = new ConstantHTML(dir, class_name, class_package, methods,
-                constant_pool);
-        /* Attributes can't be written in one step, so we just open a file
-         * which will be written consequently.
-         */
-        final AttributeHTML attribute_html = new AttributeHTML(dir, class_name, constant_pool,
-                constant_html);
-        new MethodHTML(dir, class_name, methods, java_class.getFields(),
-                constant_html, attribute_html);
-        // Write main file (with frames, yuk)
-        writeMainHTML(attribute_html);
-        new CodeHTML(dir, class_name, methods, constant_pool, constant_html);
-        attribute_html.close();
-    }
-
-
-    public static void main( final String[] argv ) throws IOException {
-        final String[] file_name = new String[argv.length];
+    public static void _main(final String[] argv) throws IOException {
+        final String[] fileName = new String[argv.length];
         int files = 0;
         ClassParser parser = null;
-        JavaClass java_class = null;
-        String zip_file = null;
+        JavaClass javaClass = null;
+        String zipFile = null;
         final char sep = File.separatorChar;
         String dir = "." + sep; // Where to store HTML files
-        /* Parse command line arguments.
+        /*
+         * Parse command line arguments.
          */
         for (int i = 0; i < argv.length; i++) {
             if (argv[i].charAt(0) == '-') { // command line switch
@@ -131,108 +94,138 @@ public static void main( final String[] argv ) throws IOException {
                     final File store = new File(dir);
                     if (!store.isDirectory()) {
                         final boolean created = store.mkdirs(); // Create target directory if necessary
-                        if (!created) {
-                            if (!store.isDirectory()) {
-                                System.out.println("Tried to create the directory " + dir + " but failed");
-                            }
+                        if (!created && !store.isDirectory()) {
+                            System.out.println("Tried to create the directory " + dir + " but failed");
                         }
                     }
                 } else if (argv[i].equals("-zip")) {
-                    zip_file = argv[++i];
+                    zipFile = argv[++i];
                 } else {
                     System.out.println("Unknown option " + argv[i]);
                 }
             } else {
-                file_name[files++] = argv[i];
+                fileName[files++] = argv[i];
             }
         }
         if (files == 0) {
             System.err.println("Class2HTML: No input files specified.");
         } else { // Loop through files ...
             for (int i = 0; i < files; i++) {
-                System.out.print("Processing " + file_name[i] + "...");
-                if (zip_file == null) {
-                    parser = new ClassParser(file_name[i]); // Create parser object from file
+                System.out.print("Processing " + fileName[i] + "...");
+                if (zipFile == null) {
+                    parser = new ClassParser(fileName[i]); // Create parser object from file
                 } else {
-                    parser = new ClassParser(zip_file, file_name[i]); // Create parser object from zip file
+                    parser = new ClassParser(zipFile, fileName[i]); // Create parser object from zip file
                 }
-                java_class = parser.parse();
-                new Class2HTML(java_class, dir);
+                javaClass = parser.parse();
+                new Class2HTML(javaClass, dir);
                 System.out.println("Done.");
             }
         }
     }
 
     /**
-     * Utility method that converts a class reference in the constant pool,
-     * i.e., an index to a string.
+     * Utility method that converts a class reference in the constant pool, i.e., an index to a string.
      */
     static String referenceClass(final int index) {
-        String str = constant_pool.getConstantString(index, Const.CONSTANT_Class);
+        String str = constantPool.getConstantString(index, Const.CONSTANT_Class);
         str = Utility.compactClassName(str);
-        str = Utility.compactClassName(str, class_package + ".", true);
-        return "<A HREF=\"" + class_name + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + str
-                + "</A>";
+        str = Utility.compactClassName(str, classPackage + ".", true);
+        return "<A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + str + "</A>";
     }
 
-
-    static String referenceType( final String type ) {
-        String short_type = Utility.compactClassName(type);
-        short_type = Utility.compactClassName(short_type, class_package + ".", true);
+    static String referenceType(final String type) {
+        String shortType = Utility.compactClassName(type);
+        shortType = Utility.compactClassName(shortType, classPackage + ".", true);
         final int index = type.indexOf('['); // Type is an array?
-        String base_type = type;
+        String baseType = type;
         if (index > -1) {
-            base_type = type.substring(0, index); // Tack of the `['
+            baseType = type.substring(0, index); // Tack of the '['
         }
         // test for basic type
-        if (basic_types.contains(base_type)) {
+        if (basicTypes.contains(baseType)) {
             return "<FONT COLOR=\"#00FF00\">" + type + "</FONT>";
         }
-        return "<A HREF=\"" + base_type + ".html\" TARGET=_top>" + short_type + "</A>";
+        return "<A HREF=\"" + baseType + ".html\" TARGET=_top>" + shortType + "</A>";
     }
 
-
-    static String toHTML( final String str ) {
+    static String toHTML(final String str) {
         final StringBuilder buf = new StringBuilder();
         for (int i = 0; i < str.length(); i++) {
             char ch;
             switch (ch = str.charAt(i)) {
-                case '<':
-                    buf.append("&lt;");
-                    break;
-                case '>':
-                    buf.append("&gt;");
-                    break;
-                case '\n':
-                    buf.append("\\n");
-                    break;
-                case '\r':
-                    buf.append("\\r");
-                    break;
-                default:
-                    buf.append(ch);
+            case '<':
+                buf.append("&lt;");
+                break;
+            case '>':
+                buf.append("&gt;");
+                break;
+            case '\n':
+                buf.append("\\n");
+                break;
+            case '\r':
+                buf.append("\\r");
+                break;
+            default:
+                buf.append(ch);
             }
         }
         return buf.toString();
     }
 
+    private final JavaClass javaClass; // current class object
+
+    private final String dir;
+
+    /**
+     * Write contents of the given JavaClass into HTML files.
+     *
+     * @param javaClass The class to write
+     * @param dir The directory to put the files in
+     * @throws IOException Thrown when an I/O exception of some sort has occurred.
+     */
+    public Class2HTML(final JavaClass javaClass, final String dir) throws IOException {
+        this(javaClass, dir, StandardCharsets.UTF_8);
+    }
+
+    private Class2HTML(final JavaClass javaClass, final String dir, final Charset charset) throws IOException {
+        final Method[] methods = javaClass.getMethods();
+        this.javaClass = javaClass;
+        this.dir = dir;
+        className = javaClass.getClassName(); // Remember full name
+        constantPool = javaClass.getConstantPool();
+        // Get package name by tacking off everything after the last '.'
+        final int index = className.lastIndexOf('.');
+        if (index > -1) {
+            classPackage = className.substring(0, index);
+        } else {
+            classPackage = ""; // default package
+        }
+        final ConstantHTML constantHtml = new ConstantHTML(dir, className, classPackage, methods, constantPool, charset);
+        /*
+         * Attributes can't be written in one step, so we just open a file which will be written consequently.
+         */
+        try (AttributeHTML attributeHtml = new AttributeHTML(dir, className, constantPool, constantHtml, charset)) {
+            new MethodHTML(dir, className, methods, javaClass.getFields(), constantHtml, attributeHtml, charset);
+            // Write main file (with frames, yuk)
+            writeMainHTML(attributeHtml, charset);
+            new CodeHTML(dir, className, methods, constantPool, constantHtml, charset);
+        }
+    }
 
-    private void writeMainHTML( final AttributeHTML attribute_html ) throws IOException {
-        try (PrintWriter file = new PrintWriter(new FileOutputStream(dir + class_name + ".html"))) {
-            file.println("<HTML>\n" + "<HEAD><TITLE>Documentation for " + class_name + "</TITLE>" + "</HEAD>\n"
-                    + "<FRAMESET BORDER=1 cols=\"30%,*\">\n" + "<FRAMESET BORDER=1 rows=\"80%,*\">\n"
-                    + "<FRAME NAME=\"ConstantPool\" SRC=\"" + class_name + "_cp.html" + "\"\n MARGINWIDTH=\"0\" "
-                    + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "<FRAME NAME=\"Attributes\" SRC=\""
-                    + class_name + "_attributes.html" + "\"\n MARGINWIDTH=\"0\" "
-                    + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "</FRAMESET>\n"
-                    + "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"Code\" SRC=\"" + class_name
-                    + "_code.html\"\n MARGINWIDTH=0 " + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n"
-                    + "<FRAME NAME=\"Methods\" SRC=\"" + class_name + "_methods.html\"\n MARGINWIDTH=0 "
-                    + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + "</FRAMESET></FRAMESET></HTML>");
+    private void writeMainHTML(final AttributeHTML attributeHtml, final Charset charset) throws FileNotFoundException, UnsupportedEncodingException {
+        try (PrintWriter file = new PrintWriter(dir + className + ".html", charset.name())) {
+            file.println("<HTML>\n" + "<HEAD><TITLE>Documentation for " + className + "</TITLE>" + "</HEAD>\n" + "<FRAMESET BORDER=1 cols=\"30%,*\">\n"
+                + "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"ConstantPool\" SRC=\"" + className + "_cp.html" + "\"\n MARGINWIDTH=\"0\" "
+                + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "<FRAME NAME=\"Attributes\" SRC=\"" + className + "_attributes.html"
+                + "\"\n MARGINWIDTH=\"0\" " + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "</FRAMESET>\n"
+                + "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"Code\" SRC=\"" + className + "_code.html\"\n MARGINWIDTH=0 "
+                + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + "<FRAME NAME=\"Methods\" SRC=\"" + className + "_methods.html\"\n MARGINWIDTH=0 "
+                + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + "</FRAMESET></FRAMESET></HTML>");
         }
-        final Attribute[] attributes = java_class.getAttributes();
+        final Attribute[] attributes = javaClass.getAttributes();
         for (int i = 0; i < attributes.length; i++) {
-            attribute_html.writeAttribute(attributes[i], "class" + i);
+            attributeHtml.writeAttribute(attributes[i], "class" + i);
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassQueue.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassQueue.java
index 8120820d5c9..82c4e52168c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassQueue.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassQueue.java
@@ -24,30 +24,28 @@
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
 
 /**
- * Utility class implementing a (typesafe) queue of JavaClass
- * objects.
- *
+ * Utility class implementing a (typesafe) queue of JavaClass objects.
  * @LastModified: Jan 2020
  */
 public class ClassQueue {
 
-    private final LinkedList<JavaClass> vec = new LinkedList<>();
-
-
-    public void enqueue( final JavaClass clazz ) {
-        vec.addLast(clazz);
-    }
-
+    /**
+     * @deprecated (since 6.0) will be made private; do not access
+     */
+    @Deprecated
+    protected LinkedList<JavaClass> vec = new LinkedList<>(); // TODO not used externally
 
     public JavaClass dequeue() {
         return vec.removeFirst();
     }
 
-
     public boolean empty() {
         return vec.isEmpty();
     }
 
+    public void enqueue(final JavaClass clazz) {
+        vec.addLast(clazz);
+    }
 
     @Override
     public String toString() {
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassSet.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassSet.java
index 8e542098941..178ccc786b1 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassSet.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassSet.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,53 +20,39 @@
 
 package com.sun.org.apache.bcel.internal.util;
 
-import java.util.Collection;
+import com.sun.org.apache.bcel.internal.Const;
 import java.util.HashMap;
 import java.util.Map;
 
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
 
 /**
- * Utility class implementing a (typesafe) set of JavaClass objects.
- * Since JavaClass has no equals() method, the name of the class is
- * used for comparison.
+ * Utility class implementing a (type-safe) set of JavaClass objects. Since JavaClass has no equals() method, the name of the class is used for comparison.
  *
  * @see ClassStack
+ * @LastModified: Feb 2023
  */
 public class ClassSet {
 
     private final Map<String, JavaClass> map = new HashMap<>();
 
-
-    public boolean add( final JavaClass clazz ) {
-        boolean result = false;
-        if (!map.containsKey(clazz.getClassName())) {
-            result = true;
-            map.put(clazz.getClassName(), clazz);
-        }
-        return result;
+    public boolean add(final JavaClass clazz) {
+        return map.putIfAbsent(clazz.getClassName(), clazz) != null;
     }
 
-
-    public void remove( final JavaClass clazz ) {
-        map.remove(clazz.getClassName());
-    }
-
-
     public boolean empty() {
         return map.isEmpty();
     }
 
-
-    public JavaClass[] toArray() {
-        final Collection<JavaClass> values = map.values();
-        final JavaClass[] classes = new JavaClass[values.size()];
-        values.toArray(classes);
-        return classes;
+    public String[] getClassNames() {
+        return map.keySet().toArray(Const.EMPTY_STRING_ARRAY);
     }
 
+    public void remove(final JavaClass clazz) {
+        map.remove(clazz.getClassName());
+    }
 
-    public String[] getClassNames() {
-        return map.keySet().toArray(new String[map.size()]);
+    public JavaClass[] toArray() {
+        return map.values().toArray(JavaClass.EMPTY_ARRAY);
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassStack.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassStack.java
index e545e3625dc..cc07acf7dbc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassStack.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassStack.java
@@ -34,23 +34,19 @@ public class ClassStack {
 
     private final Stack<JavaClass> stack = new Stack<>();
 
-
-    public void push( final JavaClass clazz ) {
-        stack.push(clazz);
+    public boolean empty() {
+        return stack.empty();
     }
 
-
     public JavaClass pop() {
         return stack.pop();
     }
 
+    public void push(final JavaClass clazz) {
+        stack.push(clazz);
+    }
 
     public JavaClass top() {
         return stack.peek();
     }
-
-
-    public boolean empty() {
-        return stack.empty();
-    }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java
index fe8e9388391..723fc07509b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/CodeHTML.java
@@ -21,9 +21,9 @@
 
 package com.sun.org.apache.bcel.internal.util;
 
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.nio.charset.Charset;
 import java.util.BitSet;
 
 import com.sun.org.apache.bcel.internal.Const;
@@ -36,363 +36,349 @@
 import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref;
 import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType;
 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
-import com.sun.org.apache.bcel.internal.classfile.LocalVariable;
 import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable;
 import com.sun.org.apache.bcel.internal.classfile.Method;
 import com.sun.org.apache.bcel.internal.classfile.Utility;
 
 /**
  * Convert code into HTML file.
- *
- *
  */
 final class CodeHTML {
 
+    private static boolean wide;
     private final String className; // name of current class
-//    private Method[] methods; // Methods to print
-    private final PrintWriter file; // file to write to
+    // private Method[] methods; // Methods to print
+    private final PrintWriter printWriter; // file to write to
     private BitSet gotoSet;
     private final ConstantPool constantPool;
     private final ConstantHTML constantHtml;
-    private static boolean wide = false;
 
-
-    CodeHTML(final String dir, final String class_name, final Method[] methods, final ConstantPool constant_pool,
-            final ConstantHTML constant_html) throws IOException {
-        this.className = class_name;
+    CodeHTML(final String dir, final String className, final Method[] methods, final ConstantPool constantPool, final ConstantHTML constantHtml,
+        final Charset charset) throws IOException {
+        this.className = className;
 //        this.methods = methods;
-        this.constantPool = constant_pool;
-        this.constantHtml = constant_html;
-        file = new PrintWriter(new FileOutputStream(dir + class_name + "_code.html"));
-        file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\">");
-        for (int i = 0; i < methods.length; i++) {
-            writeMethod(methods[i], i);
+        this.constantPool = constantPool;
+        this.constantHtml = constantHtml;
+        try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_code.html", charset.name())) {
+            printWriter = newPrintWriter;
+            printWriter.print("<HTML><head><meta charset=\"");
+            printWriter.print(charset.name());
+            printWriter.println("\"></head>");
+            printWriter.println("<BODY BGCOLOR=\"#C0C0C0\">");
+            for (int i = 0; i < methods.length; i++) {
+                writeMethod(methods[i], i);
+            }
+            printWriter.println("</BODY></HTML>");
         }
-        file.println("</BODY></HTML>");
-        file.close();
     }
 
-
     /**
-     * Disassemble a stream of byte codes and return the
-     * string representation.
+     * Disassemble a stream of byte codes and return the string representation.
      *
-     * @param  stream data input stream
+     * @param stream data input stream
      * @return String representation of byte code
      */
-    private String codeToHTML( final ByteSequence bytes, final int method_number ) throws IOException {
+    private String codeToHTML(final ByteSequence bytes, final int methodNumber) throws IOException {
         final short opcode = (short) bytes.readUnsignedByte();
         String name;
         String signature;
-        int default_offset = 0;
+        int defaultOffset = 0;
         int low;
         int high;
         int index;
-        int class_index;
+        int classIndex;
         int vindex;
         int constant;
-        int[] jump_table;
-        int no_pad_bytes = 0;
+        int[] jumpTable;
+        int noPadBytes = 0;
         int offset;
         final StringBuilder buf = new StringBuilder(256); // CHECKSTYLE IGNORE MagicNumber
         buf.append("<TT>").append(Const.getOpcodeName(opcode)).append("</TT></TD><TD>");
-        /* Special case: Skip (0-3) padding bytes, i.e., the
-         * following bytes are 4-byte-aligned
+        /*
+         * Special case: Skip (0-3) padding bytes, i.e., the following bytes are 4-byte-aligned
          */
-        if ((opcode == Const.TABLESWITCH) || (opcode == Const.LOOKUPSWITCH)) {
+        if (opcode == Const.TABLESWITCH || opcode == Const.LOOKUPSWITCH) {
             final int remainder = bytes.getIndex() % 4;
-            no_pad_bytes = (remainder == 0) ? 0 : 4 - remainder;
-            for (int i = 0; i < no_pad_bytes; i++) {
+            noPadBytes = remainder == 0 ? 0 : 4 - remainder;
+            for (int i = 0; i < noPadBytes; i++) {
                 bytes.readByte();
             }
             // Both cases have a field default_offset in common
-            default_offset = bytes.readInt();
+            defaultOffset = bytes.readInt();
         }
         switch (opcode) {
-            case Const.TABLESWITCH:
-                low = bytes.readInt();
-                high = bytes.readInt();
-                offset = bytes.getIndex() - 12 - no_pad_bytes - 1;
-                default_offset += offset;
-                buf.append("<TABLE BORDER=1><TR>");
-                // Print switch indices in first row (and default)
-                jump_table = new int[high - low + 1];
-                for (int i = 0; i < jump_table.length; i++) {
-                    jump_table[i] = offset + bytes.readInt();
-                    buf.append("<TH>").append(low + i).append("</TH>");
-                }
-                buf.append("<TH>default</TH></TR>\n<TR>");
-                // Print target and default indices in second row
-            for (final int element : jump_table) {
-                buf.append("<TD><A HREF=\"#code").append(method_number).append("@").append(
-                        element).append("\">").append(element).append("</A></TD>");
+        case Const.TABLESWITCH:
+            low = bytes.readInt();
+            high = bytes.readInt();
+            offset = bytes.getIndex() - 12 - noPadBytes - 1;
+            defaultOffset += offset;
+            buf.append("<TABLE BORDER=1><TR>");
+            // Print switch indices in first row (and default)
+            jumpTable = new int[high - low + 1];
+            for (int i = 0; i < jumpTable.length; i++) {
+                jumpTable[i] = offset + bytes.readInt();
+                buf.append("<TH>").append(low + i).append("</TH>");
             }
-                buf.append("<TD><A HREF=\"#code").append(method_number).append("@").append(
-                        default_offset).append("\">").append(default_offset).append(
-                        "</A></TD></TR>\n</TABLE>\n");
-                break;
-            /* Lookup switch has variable length arguments.
-             */
-            case Const.LOOKUPSWITCH:
-                final int npairs = bytes.readInt();
-                offset = bytes.getIndex() - 8 - no_pad_bytes - 1;
-                jump_table = new int[npairs];
-                default_offset += offset;
-                buf.append("<TABLE BORDER=1><TR>");
-                // Print switch indices in first row (and default)
-                for (int i = 0; i < npairs; i++) {
-                    final int match = bytes.readInt();
-                    jump_table[i] = offset + bytes.readInt();
-                    buf.append("<TH>").append(match).append("</TH>");
-                }
-                buf.append("<TH>default</TH></TR>\n<TR>");
-                // Print target and default indices in second row
-                for (int i = 0; i < npairs; i++) {
-                    buf.append("<TD><A HREF=\"#code").append(method_number).append("@").append(
-                            jump_table[i]).append("\">").append(jump_table[i]).append("</A></TD>");
-                }
-                buf.append("<TD><A HREF=\"#code").append(method_number).append("@").append(
-                        default_offset).append("\">").append(default_offset).append(
-                        "</A></TD></TR>\n</TABLE>\n");
-                break;
-            /* Two address bytes + offset from start of byte stream form the
-             * jump target.
-             */
-            case Const.GOTO:
-            case Const.IFEQ:
-            case Const.IFGE:
-            case Const.IFGT:
-            case Const.IFLE:
-            case Const.IFLT:
-            case Const.IFNE:
-            case Const.IFNONNULL:
-            case Const.IFNULL:
-            case Const.IF_ACMPEQ:
-            case Const.IF_ACMPNE:
-            case Const.IF_ICMPEQ:
-            case Const.IF_ICMPGE:
-            case Const.IF_ICMPGT:
-            case Const.IF_ICMPLE:
-            case Const.IF_ICMPLT:
-            case Const.IF_ICMPNE:
-            case Const.JSR:
-                index = bytes.getIndex() + bytes.readShort() - 1;
-                buf.append("<A HREF=\"#code").append(method_number).append("@").append(index)
-                        .append("\">").append(index).append("</A>");
-                break;
-            /* Same for 32-bit wide jumps
-             */
-            case Const.GOTO_W:
-            case Const.JSR_W:
-                final int windex = bytes.getIndex() + bytes.readInt() - 1;
-                buf.append("<A HREF=\"#code").append(method_number).append("@").append(windex)
-                        .append("\">").append(windex).append("</A>");
-                break;
-            /* Index byte references local variable (register)
-             */
-            case Const.ALOAD:
-            case Const.ASTORE:
-            case Const.DLOAD:
-            case Const.DSTORE:
-            case Const.FLOAD:
-            case Const.FSTORE:
-            case Const.ILOAD:
-            case Const.ISTORE:
-            case Const.LLOAD:
-            case Const.LSTORE:
-            case Const.RET:
-                if (wide) {
-                    vindex = bytes.readShort();
-                    wide = false; // Clear flag
-                } else {
-                    vindex = bytes.readUnsignedByte();
-                }
-                buf.append("%").append(vindex);
-                break;
-            /*
-             * Remember wide byte which is used to form a 16-bit address in the
-             * following instruction. Relies on that the method is called again with
-             * the following opcode.
-             */
-            case Const.WIDE:
-                wide = true;
-                buf.append("(wide)");
-                break;
-            /* Array of basic type.
-             */
-            case Const.NEWARRAY:
-                buf.append("<FONT COLOR=\"#00FF00\">").append(Const.getTypeName(bytes.readByte())).append(
-                        "</FONT>");
-                break;
-            /* Access object/class fields.
-             */
-            case Const.GETFIELD:
-            case Const.GETSTATIC:
-            case Const.PUTFIELD:
-            case Const.PUTSTATIC:
-                index = bytes.readShort();
-                final ConstantFieldref c1 = (ConstantFieldref) constantPool.getConstant(index,
-                        Const.CONSTANT_Fieldref);
-                class_index = c1.getClassIndex();
-                name = constantPool.getConstantString(class_index, Const.CONSTANT_Class);
-                name = Utility.compactClassName(name, false);
-                index = c1.getNameAndTypeIndex();
-                final String field_name = constantPool.constantToString(index, Const.CONSTANT_NameAndType);
-                if (name.equals(className)) { // Local field
-                    buf.append("<A HREF=\"").append(className).append("_methods.html#field")
-                            .append(field_name).append("\" TARGET=Methods>").append(field_name)
-                            .append("</A>\n");
-                } else {
-                    buf.append(constantHtml.referenceConstant(class_index)).append(".").append(
-                            field_name);
-                }
-                break;
-            /* Operands are references to classes in constant pool
-             */
-            case Const.CHECKCAST:
-            case Const.INSTANCEOF:
-            case Const.NEW:
-                index = bytes.readShort();
-                buf.append(constantHtml.referenceConstant(index));
-                break;
-            /* Operands are references to methods in constant pool
-             */
-            case Const.INVOKESPECIAL:
-            case Const.INVOKESTATIC:
-            case Const.INVOKEVIRTUAL:
-            case Const.INVOKEINTERFACE:
-            case Const.INVOKEDYNAMIC:
-                final int m_index = bytes.readShort();
-                String str;
-                if (opcode == Const.INVOKEINTERFACE) { // Special treatment needed
-                    bytes.readUnsignedByte(); // Redundant
-                    bytes.readUnsignedByte(); // Reserved
+            buf.append("<TH>default</TH></TR>\n<TR>");
+            // Print target and default indices in second row
+            for (final int element : jumpTable) {
+                buf.append("<TD><A HREF=\"#code").append(methodNumber).append("@").append(element).append("\">").append(element).append("</A></TD>");
+            }
+            buf.append("<TD><A HREF=\"#code").append(methodNumber).append("@").append(defaultOffset).append("\">").append(defaultOffset)
+                .append("</A></TD></TR>\n</TABLE>\n");
+            break;
+        /*
+         * Lookup switch has variable length arguments.
+         */
+        case Const.LOOKUPSWITCH:
+            final int npairs = bytes.readInt();
+            offset = bytes.getIndex() - 8 - noPadBytes - 1;
+            jumpTable = new int[npairs];
+            defaultOffset += offset;
+            buf.append("<TABLE BORDER=1><TR>");
+            // Print switch indices in first row (and default)
+            for (int i = 0; i < npairs; i++) {
+                final int match = bytes.readInt();
+                jumpTable[i] = offset + bytes.readInt();
+                buf.append("<TH>").append(match).append("</TH>");
+            }
+            buf.append("<TH>default</TH></TR>\n<TR>");
+            // Print target and default indices in second row
+            for (int i = 0; i < npairs; i++) {
+                buf.append("<TD><A HREF=\"#code").append(methodNumber).append("@").append(jumpTable[i]).append("\">").append(jumpTable[i])
+                    .append("</A></TD>");
+            }
+            buf.append("<TD><A HREF=\"#code").append(methodNumber).append("@").append(defaultOffset).append("\">").append(defaultOffset)
+                .append("</A></TD></TR>\n</TABLE>\n");
+            break;
+        /*
+         * Two address bytes + offset from start of byte stream form the jump target.
+         */
+        case Const.GOTO:
+        case Const.IFEQ:
+        case Const.IFGE:
+        case Const.IFGT:
+        case Const.IFLE:
+        case Const.IFLT:
+        case Const.IFNE:
+        case Const.IFNONNULL:
+        case Const.IFNULL:
+        case Const.IF_ACMPEQ:
+        case Const.IF_ACMPNE:
+        case Const.IF_ICMPEQ:
+        case Const.IF_ICMPGE:
+        case Const.IF_ICMPGT:
+        case Const.IF_ICMPLE:
+        case Const.IF_ICMPLT:
+        case Const.IF_ICMPNE:
+        case Const.JSR:
+            index = bytes.getIndex() + bytes.readShort() - 1;
+            buf.append("<A HREF=\"#code").append(methodNumber).append("@").append(index).append("\">").append(index).append("</A>");
+            break;
+        /*
+         * Same for 32-bit wide jumps
+         */
+        case Const.GOTO_W:
+        case Const.JSR_W:
+            final int windex = bytes.getIndex() + bytes.readInt() - 1;
+            buf.append("<A HREF=\"#code").append(methodNumber).append("@").append(windex).append("\">").append(windex).append("</A>");
+            break;
+        /*
+         * Index byte references local variable (register)
+         */
+        case Const.ALOAD:
+        case Const.ASTORE:
+        case Const.DLOAD:
+        case Const.DSTORE:
+        case Const.FLOAD:
+        case Const.FSTORE:
+        case Const.ILOAD:
+        case Const.ISTORE:
+        case Const.LLOAD:
+        case Const.LSTORE:
+        case Const.RET:
+            if (wide) {
+                vindex = bytes.readShort();
+                wide = false; // Clear flag
+            } else {
+                vindex = bytes.readUnsignedByte();
+            }
+            buf.append("%").append(vindex);
+            break;
+        /*
+         * Remember wide byte which is used to form a 16-bit address in the following instruction. Relies on that the method is
+         * called again with the following opcode.
+         */
+        case Const.WIDE:
+            wide = true;
+            buf.append("(wide)");
+            break;
+        /*
+         * Array of basic type.
+         */
+        case Const.NEWARRAY:
+            buf.append("<FONT COLOR=\"#00FF00\">").append(Const.getTypeName(bytes.readByte())).append("</FONT>");
+            break;
+        /*
+         * Access object/class fields.
+         */
+        case Const.GETFIELD:
+        case Const.GETSTATIC:
+        case Const.PUTFIELD:
+        case Const.PUTSTATIC:
+            index = bytes.readShort();
+            final ConstantFieldref c1 = constantPool.getConstant(index, Const.CONSTANT_Fieldref, ConstantFieldref.class);
+            classIndex = c1.getClassIndex();
+            name = constantPool.getConstantString(classIndex, Const.CONSTANT_Class);
+            name = Utility.compactClassName(name, false);
+            index = c1.getNameAndTypeIndex();
+            final String fieldName = constantPool.constantToString(index, Const.CONSTANT_NameAndType);
+            if (name.equals(className)) { // Local field
+                buf.append("<A HREF=\"").append(className).append("_methods.html#field").append(fieldName).append("\" TARGET=Methods>").append(fieldName)
+                    .append("</A>\n");
+            } else {
+                buf.append(constantHtml.referenceConstant(classIndex)).append(".").append(fieldName);
+            }
+            break;
+        /*
+         * Operands are references to classes in constant pool
+         */
+        case Const.CHECKCAST:
+        case Const.INSTANCEOF:
+        case Const.NEW:
+            index = bytes.readShort();
+            buf.append(constantHtml.referenceConstant(index));
+            break;
+        /*
+         * Operands are references to methods in constant pool
+         */
+        case Const.INVOKESPECIAL:
+        case Const.INVOKESTATIC:
+        case Const.INVOKEVIRTUAL:
+        case Const.INVOKEINTERFACE:
+        case Const.INVOKEDYNAMIC:
+            final int mIndex = bytes.readShort();
+            String str;
+            if (opcode == Const.INVOKEINTERFACE) { // Special treatment needed
+                bytes.readUnsignedByte(); // Redundant
+                bytes.readUnsignedByte(); // Reserved
 //                    int nargs = bytes.readUnsignedByte(); // Redundant
 //                    int reserved = bytes.readUnsignedByte(); // Reserved
-                    final ConstantInterfaceMethodref c = (ConstantInterfaceMethodref) constantPool
-                            .getConstant(m_index, Const.CONSTANT_InterfaceMethodref);
-                    class_index = c.getClassIndex();
-                    index = c.getNameAndTypeIndex();
-                    name = Class2HTML.referenceClass(class_index);
-                } else if (opcode == Const.INVOKEDYNAMIC) { // Special treatment needed
-                    bytes.readUnsignedByte(); // Reserved
-                    bytes.readUnsignedByte(); // Reserved
-                    final ConstantInvokeDynamic c = (ConstantInvokeDynamic) constantPool
-                            .getConstant(m_index, Const.CONSTANT_InvokeDynamic);
-                    index = c.getNameAndTypeIndex();
-                    name = "#" + c.getBootstrapMethodAttrIndex();
-                } else {
-                    // UNDONE: Java8 now allows INVOKESPECIAL and INVOKESTATIC to
-                    // reference EITHER a Methodref OR an InterfaceMethodref.
-                    // Not sure if that affects this code or not.  (markro)
-                    final ConstantMethodref c = (ConstantMethodref) constantPool.getConstant(m_index,
-                            Const.CONSTANT_Methodref);
-                    class_index = c.getClassIndex();
-                    index = c.getNameAndTypeIndex();
-                name = Class2HTML.referenceClass(class_index);
-                }
-                str = Class2HTML.toHTML(constantPool.constantToString(constantPool.getConstant(
-                        index, Const.CONSTANT_NameAndType)));
-                // Get signature, i.e., types
-                final ConstantNameAndType c2 = (ConstantNameAndType) constantPool.getConstant(index,
-                        Const.CONSTANT_NameAndType);
-                signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8);
-                final String[] args = Utility.methodSignatureArgumentTypes(signature, false);
-                final String type = Utility.methodSignatureReturnType(signature, false);
-                buf.append(name).append(".<A HREF=\"").append(className).append("_cp.html#cp")
-                        .append(m_index).append("\" TARGET=ConstantPool>").append(str).append(
-                                "</A>").append("(");
-                // List arguments
-                for (int i = 0; i < args.length; i++) {
-                    buf.append(Class2HTML.referenceType(args[i]));
-                    if (i < args.length - 1) {
-                        buf.append(", ");
-                    }
-                }
-                // Attach return type
-                buf.append("):").append(Class2HTML.referenceType(type));
-                break;
-            /* Operands are references to items in constant pool
-             */
-            case Const.LDC_W:
-            case Const.LDC2_W:
-                index = bytes.readShort();
-                buf.append("<A HREF=\"").append(className).append("_cp.html#cp").append(index)
-                        .append("\" TARGET=\"ConstantPool\">").append(
-                                Class2HTML.toHTML(constantPool.constantToString(index,
-                                        constantPool.getConstant(index).getTag()))).append("</a>");
-                break;
-            case Const.LDC:
-                index = bytes.readUnsignedByte();
-                buf.append("<A HREF=\"").append(className).append("_cp.html#cp").append(index)
-                        .append("\" TARGET=\"ConstantPool\">").append(
-                                Class2HTML.toHTML(constantPool.constantToString(index,
-                                        constantPool.getConstant(index).getTag()))).append("</a>");
-                break;
-            /* Array of references.
-             */
-            case Const.ANEWARRAY:
-                index = bytes.readShort();
-                buf.append(constantHtml.referenceConstant(index));
-                break;
-            /* Multidimensional array of references.
-             */
-            case Const.MULTIANEWARRAY:
-                index = bytes.readShort();
-                final int dimensions = bytes.readByte();
-                buf.append(constantHtml.referenceConstant(index)).append(":").append(dimensions)
-                        .append("-dimensional");
-                break;
-            /* Increment local variable.
-             */
-            case Const.IINC:
-                if (wide) {
-                    vindex = bytes.readShort();
-                    constant = bytes.readShort();
-                    wide = false;
-                } else {
-                    vindex = bytes.readUnsignedByte();
-                    constant = bytes.readByte();
+                final ConstantInterfaceMethodref c = constantPool.getConstant(mIndex, Const.CONSTANT_InterfaceMethodref, ConstantInterfaceMethodref.class);
+                classIndex = c.getClassIndex();
+                index = c.getNameAndTypeIndex();
+                name = Class2HTML.referenceClass(classIndex);
+            } else if (opcode == Const.INVOKEDYNAMIC) { // Special treatment needed
+                bytes.readUnsignedByte(); // Reserved
+                bytes.readUnsignedByte(); // Reserved
+                final ConstantInvokeDynamic c = constantPool.getConstant(mIndex, Const.CONSTANT_InvokeDynamic, ConstantInvokeDynamic.class);
+                index = c.getNameAndTypeIndex();
+                name = "#" + c.getBootstrapMethodAttrIndex();
+            } else {
+                // UNDONE: Java8 now allows INVOKESPECIAL and INVOKESTATIC to
+                // reference EITHER a Methodref OR an InterfaceMethodref.
+                // Not sure if that affects this code or not. (markro)
+                final ConstantMethodref c = constantPool.getConstant(mIndex, Const.CONSTANT_Methodref, ConstantMethodref.class);
+                classIndex = c.getClassIndex();
+                index = c.getNameAndTypeIndex();
+                name = Class2HTML.referenceClass(classIndex);
+            }
+            str = Class2HTML.toHTML(constantPool.constantToString(constantPool.getConstant(index, Const.CONSTANT_NameAndType)));
+            // Get signature, i.e., types
+            final ConstantNameAndType c2 = constantPool.getConstant(index, Const.CONSTANT_NameAndType, ConstantNameAndType.class);
+            signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8);
+            final String[] args = Utility.methodSignatureArgumentTypes(signature, false);
+            final String type = Utility.methodSignatureReturnType(signature, false);
+            buf.append(name).append(".<A HREF=\"").append(className).append("_cp.html#cp").append(mIndex).append("\" TARGET=ConstantPool>").append(str)
+                .append("</A>").append("(");
+            // List arguments
+            for (int i = 0; i < args.length; i++) {
+                buf.append(Class2HTML.referenceType(args[i]));
+                if (i < args.length - 1) {
+                    buf.append(", ");
                 }
-                buf.append("%").append(vindex).append(" ").append(constant);
-                break;
-            default:
-                if (Const.getNoOfOperands(opcode) > 0) {
-                    for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) {
-                        switch (Const.getOperandType(opcode, i)) {
-                            case Const.T_BYTE:
-                                buf.append(bytes.readUnsignedByte());
-                                break;
-                            case Const.T_SHORT: // Either branch or index
-                                buf.append(bytes.readShort());
-                                break;
-                            case Const.T_INT:
-                                buf.append(bytes.readInt());
-                                break;
-                            default: // Never reached
-                                throw new IllegalStateException(
-                                        "Unreachable default case reached! " +
-                                                Const.getOperandType(opcode, i));
-                        }
-                        buf.append("&nbsp;");
+            }
+            // Attach return type
+            buf.append("):").append(Class2HTML.referenceType(type));
+            break;
+        /*
+         * Operands are references to items in constant pool
+         */
+        case Const.LDC_W:
+        case Const.LDC2_W:
+            index = bytes.readShort();
+            buf.append("<A HREF=\"").append(className).append("_cp.html#cp").append(index).append("\" TARGET=\"ConstantPool\">")
+                .append(Class2HTML.toHTML(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))).append("</a>");
+            break;
+        case Const.LDC:
+            index = bytes.readUnsignedByte();
+            buf.append("<A HREF=\"").append(className).append("_cp.html#cp").append(index).append("\" TARGET=\"ConstantPool\">")
+                .append(Class2HTML.toHTML(constantPool.constantToString(index, constantPool.getConstant(index).getTag()))).append("</a>");
+            break;
+        /*
+         * Array of references.
+         */
+        case Const.ANEWARRAY:
+            index = bytes.readShort();
+            buf.append(constantHtml.referenceConstant(index));
+            break;
+        /*
+         * Multidimensional array of references.
+         */
+        case Const.MULTIANEWARRAY:
+            index = bytes.readShort();
+            final int dimensions = bytes.readByte();
+            buf.append(constantHtml.referenceConstant(index)).append(":").append(dimensions).append("-dimensional");
+            break;
+        /*
+         * Increment local variable.
+         */
+        case Const.IINC:
+            if (wide) {
+                vindex = bytes.readShort();
+                constant = bytes.readShort();
+                wide = false;
+            } else {
+                vindex = bytes.readUnsignedByte();
+                constant = bytes.readByte();
+            }
+            buf.append("%").append(vindex).append(" ").append(constant);
+            break;
+        default:
+            if (Const.getNoOfOperands(opcode) > 0) {
+                for (int i = 0; i < Const.getOperandTypeCount(opcode); i++) {
+                    switch (Const.getOperandType(opcode, i)) {
+                    case Const.T_BYTE:
+                        buf.append(bytes.readUnsignedByte());
+                        break;
+                    case Const.T_SHORT: // Either branch or index
+                        buf.append(bytes.readShort());
+                        break;
+                    case Const.T_INT:
+                        buf.append(bytes.readInt());
+                        break;
+                    default: // Never reached
+                        throw new IllegalStateException("Unreachable default case reached! " + Const.getOperandType(opcode, i));
                     }
+                    buf.append("&nbsp;");
                 }
+            }
         }
         buf.append("</TD>");
         return buf.toString();
     }
 
-
     /**
-     * Find all target addresses in code, so that they can be marked
-     * with &lt;A NAME = ...&gt;. Target addresses are kept in an BitSet object.
+     * Find all target addresses in code, so that they can be marked with &lt;A NAME = ...&gt;. Target addresses are kept in
+     * an BitSet object.
      */
-    private void findGotos( final ByteSequence bytes, final Code code ) throws IOException {
+    private void findGotos(final ByteSequence bytes, final Code code) throws IOException {
         int index;
         gotoSet = new BitSet(bytes.available());
         int opcode;
-        /* First get Code attribute from method and the exceptions handled
-         * (try .. catch) in this method. We only need the line number here.
+        /*
+         * First get Code attribute from method and the exceptions handled (try .. catch) in this method. We only need the line
+         * number here.
          */
         if (code != null) {
             final CodeException[] ce = code.getExceptionTable();
@@ -405,98 +391,94 @@ private void findGotos( final ByteSequence bytes, final Code code ) throws IOExc
             final Attribute[] attributes = code.getAttributes();
             for (final Attribute attribute : attributes) {
                 if (attribute.getTag() == Const.ATTR_LOCAL_VARIABLE_TABLE) {
-                    final LocalVariable[] vars = ((LocalVariableTable) attribute)
-                            .getLocalVariableTable();
-                    for (final LocalVariable var : vars) {
+                    ((LocalVariableTable) attribute).forEach(var -> {
                         final int start = var.getStartPC();
-                        final int end = start + var.getLength();
                         gotoSet.set(start);
-                        gotoSet.set(end);
-                    }
+                        gotoSet.set(start + var.getLength());
+                    });
                     break;
                 }
             }
         }
         // Get target addresses from GOTO, JSR, TABLESWITCH, etc.
-        for (; bytes.available() > 0;) {
+        while (bytes.available() > 0) {
             opcode = bytes.readUnsignedByte();
-            //System.out.println(getOpcodeName(opcode));
+            // System.out.println(getOpcodeName(opcode));
             switch (opcode) {
-                case Const.TABLESWITCH:
-                case Const.LOOKUPSWITCH:
-                    //bytes.readByte(); // Skip already read byte
-                    final int remainder = bytes.getIndex() % 4;
-                    final int no_pad_bytes = (remainder == 0) ? 0 : 4 - remainder;
-                    int default_offset;
-                    int offset;
-                    for (int j = 0; j < no_pad_bytes; j++) {
-                        bytes.readByte();
+            case Const.TABLESWITCH:
+            case Const.LOOKUPSWITCH:
+                // bytes.readByte(); // Skip already read byte
+                final int remainder = bytes.getIndex() % 4;
+                final int noPadBytes = remainder == 0 ? 0 : 4 - remainder;
+                int defaultOffset;
+                int offset;
+                for (int j = 0; j < noPadBytes; j++) {
+                    bytes.readByte();
+                }
+                // Both cases have a field default_offset in common
+                defaultOffset = bytes.readInt();
+                if (opcode == Const.TABLESWITCH) {
+                    final int low = bytes.readInt();
+                    final int high = bytes.readInt();
+                    offset = bytes.getIndex() - 12 - noPadBytes - 1;
+                    defaultOffset += offset;
+                    gotoSet.set(defaultOffset);
+                    for (int j = 0; j < high - low + 1; j++) {
+                        index = offset + bytes.readInt();
+                        gotoSet.set(index);
                     }
-                    // Both cases have a field default_offset in common
-                    default_offset = bytes.readInt();
-                    if (opcode == Const.TABLESWITCH) {
-                        final int low = bytes.readInt();
-                        final int high = bytes.readInt();
-                        offset = bytes.getIndex() - 12 - no_pad_bytes - 1;
-                        default_offset += offset;
-                        gotoSet.set(default_offset);
-                        for (int j = 0; j < (high - low + 1); j++) {
-                            index = offset + bytes.readInt();
-                            gotoSet.set(index);
-                        }
-                    } else { // LOOKUPSWITCH
-                        final int npairs = bytes.readInt();
-                        offset = bytes.getIndex() - 8 - no_pad_bytes - 1;
-                        default_offset += offset;
-                        gotoSet.set(default_offset);
-                        for (int j = 0; j < npairs; j++) {
+                } else { // LOOKUPSWITCH
+                    final int npairs = bytes.readInt();
+                    offset = bytes.getIndex() - 8 - noPadBytes - 1;
+                    defaultOffset += offset;
+                    gotoSet.set(defaultOffset);
+                    for (int j = 0; j < npairs; j++) {
 //                            int match = bytes.readInt();
-                            bytes.readInt();
-                            index = offset + bytes.readInt();
-                            gotoSet.set(index);
-                        }
+                        bytes.readInt();
+                        index = offset + bytes.readInt();
+                        gotoSet.set(index);
                     }
-                    break;
-                case Const.GOTO:
-                case Const.IFEQ:
-                case Const.IFGE:
-                case Const.IFGT:
-                case Const.IFLE:
-                case Const.IFLT:
-                case Const.IFNE:
-                case Const.IFNONNULL:
-                case Const.IFNULL:
-                case Const.IF_ACMPEQ:
-                case Const.IF_ACMPNE:
-                case Const.IF_ICMPEQ:
-                case Const.IF_ICMPGE:
-                case Const.IF_ICMPGT:
-                case Const.IF_ICMPLE:
-                case Const.IF_ICMPLT:
-                case Const.IF_ICMPNE:
-                case Const.JSR:
-                    //bytes.readByte(); // Skip already read byte
-                    index = bytes.getIndex() + bytes.readShort() - 1;
-                    gotoSet.set(index);
-                    break;
-                case Const.GOTO_W:
-                case Const.JSR_W:
-                    //bytes.readByte(); // Skip already read byte
-                    index = bytes.getIndex() + bytes.readInt() - 1;
-                    gotoSet.set(index);
-                    break;
-                default:
-                    bytes.unreadByte();
-                    codeToHTML(bytes, 0); // Ignore output
+                }
+                break;
+            case Const.GOTO:
+            case Const.IFEQ:
+            case Const.IFGE:
+            case Const.IFGT:
+            case Const.IFLE:
+            case Const.IFLT:
+            case Const.IFNE:
+            case Const.IFNONNULL:
+            case Const.IFNULL:
+            case Const.IF_ACMPEQ:
+            case Const.IF_ACMPNE:
+            case Const.IF_ICMPEQ:
+            case Const.IF_ICMPGE:
+            case Const.IF_ICMPGT:
+            case Const.IF_ICMPLE:
+            case Const.IF_ICMPLT:
+            case Const.IF_ICMPNE:
+            case Const.JSR:
+                // bytes.readByte(); // Skip already read byte
+                index = bytes.getIndex() + bytes.readShort() - 1;
+                gotoSet.set(index);
+                break;
+            case Const.GOTO_W:
+            case Const.JSR_W:
+                // bytes.readByte(); // Skip already read byte
+                index = bytes.getIndex() + bytes.readInt() - 1;
+                gotoSet.set(index);
+                break;
+            default:
+                bytes.unreadByte();
+                codeToHTML(bytes, 0); // Ignore output
             }
         }
     }
 
-
     /**
      * Write a single method with the byte code associated with it.
      */
-    private void writeMethod( final Method method, final int method_number ) throws IOException {
+    private void writeMethod(final Method method, final int methodNumber) throws IOException {
         // Get raw signature
         final String signature = method.getSignature();
         // Get array of strings containing the argument types
@@ -505,84 +487,79 @@ private void writeMethod( final Method method, final int method_number ) throws
         final String type = Utility.methodSignatureReturnType(signature, false);
         // Get method name
         final String name = method.getName();
-        final String html_name = Class2HTML.toHTML(name);
+        final String htmlName = Class2HTML.toHTML(name);
         // Get method's access flags
         String access = Utility.accessToString(method.getAccessFlags());
         access = Utility.replace(access, " ", "&nbsp;");
         // Get the method's attributes, the Code Attribute in particular
         final Attribute[] attributes = method.getAttributes();
-        file.print("<P><B><FONT COLOR=\"#FF0000\">" + access + "</FONT>&nbsp;" + "<A NAME=method"
-                + method_number + ">" + Class2HTML.referenceType(type) + "</A>&nbsp<A HREF=\""
-                + className + "_methods.html#method" + method_number + "\" TARGET=Methods>"
-                + html_name + "</A>(");
+        printWriter.print("<P><B><FONT COLOR=\"#FF0000\">" + access + "</FONT>&nbsp;" + "<A NAME=method" + methodNumber + ">" + Class2HTML.referenceType(type)
+            + "</A>&nbsp<A HREF=\"" + className + "_methods.html#method" + methodNumber + "\" TARGET=Methods>" + htmlName + "</A>(");
         for (int i = 0; i < args.length; i++) {
-            file.print(Class2HTML.referenceType(args[i]));
+            printWriter.print(Class2HTML.referenceType(args[i]));
             if (i < args.length - 1) {
-                file.print(",&nbsp;");
+                printWriter.print(",&nbsp;");
             }
         }
-        file.println(")</B></P>");
+        printWriter.println(")</B></P>");
         Code c = null;
         byte[] code = null;
         if (attributes.length > 0) {
-            file.print("<H4>Attributes</H4><UL>\n");
+            printWriter.print("<H4>Attributes</H4><UL>\n");
             for (int i = 0; i < attributes.length; i++) {
                 byte tag = attributes[i].getTag();
                 if (tag != Const.ATTR_UNKNOWN) {
-                    file.print("<LI><A HREF=\"" + className + "_attributes.html#method"
-                            + method_number + "@" + i + "\" TARGET=Attributes>"
-                            + Const.getAttributeName(tag) + "</A></LI>\n");
+                    printWriter.print("<LI><A HREF=\"" + className + "_attributes.html#method" + methodNumber + "@" + i + "\" TARGET=Attributes>"
+                        + Const.getAttributeName(tag) + "</A></LI>\n");
                 } else {
-                    file.print("<LI>" + attributes[i] + "</LI>");
+                    printWriter.print("<LI>" + attributes[i] + "</LI>");
                 }
                 if (tag == Const.ATTR_CODE) {
                     c = (Code) attributes[i];
                     final Attribute[] attributes2 = c.getAttributes();
                     code = c.getCode();
-                    file.print("<UL>");
+                    printWriter.print("<UL>");
                     for (int j = 0; j < attributes2.length; j++) {
                         tag = attributes2[j].getTag();
-                        file.print("<LI><A HREF=\"" + className + "_attributes.html#" + "method"
-                                + method_number + "@" + i + "@" + j + "\" TARGET=Attributes>"
-                                + Const.getAttributeName(tag) + "</A></LI>\n");
+                        printWriter.print("<LI><A HREF=\"" + className + "_attributes.html#" + "method" + methodNumber + "@" + i + "@" + j
+                            + "\" TARGET=Attributes>" + Const.getAttributeName(tag) + "</A></LI>\n");
                     }
-                    file.print("</UL>");
+                    printWriter.print("</UL>");
                 }
             }
-            file.println("</UL>");
+            printWriter.println("</UL>");
         }
         if (code != null) { // No code, an abstract method, e.g.
-            //System.out.println(name + "\n" + Utility.codeToString(code, constantPool, 0, -1));
+            // System.out.println(name + "\n" + Utility.codeToString(code, constantPool, 0, -1));
             // Print the byte code
             try (ByteSequence stream = new ByteSequence(code)) {
                 stream.mark(stream.available());
                 findGotos(stream, c);
                 stream.reset();
-                file.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Byte<BR>offset</TH>"
-                        + "<TH ALIGN=LEFT>Instruction</TH><TH ALIGN=LEFT>Argument</TH>");
-                for (; stream.available() > 0;) {
+                printWriter.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Byte<BR>offset</TH>" + "<TH ALIGN=LEFT>Instruction</TH><TH ALIGN=LEFT>Argument</TH>");
+                while (stream.available() > 0) {
                     final int offset = stream.getIndex();
-                    final String str = codeToHTML(stream, method_number);
+                    final String str = codeToHTML(stream, methodNumber);
                     String anchor = "";
                     /*
-                     * Set an anchor mark if this line is targetted by a goto, jsr, etc. Defining an anchor for every
-                     * line is very inefficient!
+                     * Set an anchor mark if this line is targetted by a goto, jsr, etc. Defining an anchor for every line is very
+                     * inefficient!
                      */
                     if (gotoSet.get(offset)) {
-                        anchor = "<A NAME=code" + method_number + "@" + offset + "></A>";
+                        anchor = "<A NAME=code" + methodNumber + "@" + offset + "></A>";
                     }
                     String anchor2;
                     if (stream.getIndex() == code.length) {
-                        anchor2 = "<A NAME=code" + method_number + "@" + code.length + ">" + offset + "</A>";
+                        anchor2 = "<A NAME=code" + methodNumber + "@" + code.length + ">" + offset + "</A>";
                     } else {
                         anchor2 = "" + offset;
                     }
-                    file.println("<TR VALIGN=TOP><TD>" + anchor2 + "</TD><TD>" + anchor + str + "</TR>");
+                    printWriter.println("<TR VALIGN=TOP><TD>" + anchor2 + "</TD><TD>" + anchor + str + "</TR>");
                 }
             }
             // Mark last line, may be targetted from Attributes window
-            file.println("<TR><TD> </A></TD></TR>");
-            file.println("</TABLE>");
+            printWriter.println("<TR><TD> </A></TD></TR>");
+            printWriter.println("</TABLE>");
         }
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java
index e2d5b4b5103..b3197f6d45a 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java
@@ -21,9 +21,10 @@
 
 package com.sun.org.apache.bcel.internal.util;
 
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.FileNotFoundException;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.classfile.Constant;
@@ -39,198 +40,164 @@
 
 /**
  * Convert constant pool into HTML file.
- *
- *
  */
 final class ConstantHTML {
 
     private final String className; // name of current class
     private final String classPackage; // name of package
     private final ConstantPool constantPool; // reference to constant pool
-    private final PrintWriter file; // file to write to
+    private final PrintWriter printWriter; // file to write to
     private final String[] constantRef; // String to return for cp[i]
     private final Constant[] constants; // The constants in the cp
     private final Method[] methods;
 
-
-    ConstantHTML(final String dir, final String class_name, final String class_package, final Method[] methods,
-            final ConstantPool constant_pool) throws IOException {
-        this.className = class_name;
-        this.classPackage = class_package;
-        this.constantPool = constant_pool;
+    ConstantHTML(final String dir, final String className, final String classPackage, final Method[] methods, final ConstantPool constantPool,
+        final Charset charset) throws FileNotFoundException, UnsupportedEncodingException {
+        this.className = className;
+        this.classPackage = classPackage;
+        this.constantPool = constantPool;
         this.methods = methods;
-        constants = constant_pool.getConstantPool();
-        file = new PrintWriter(new FileOutputStream(dir + class_name + "_cp.html"));
-        constantRef = new String[constants.length];
-        constantRef[0] = "&lt;unknown&gt;";
-        file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
-        // Loop through constants, constants[0] is reserved
-        for (int i = 1; i < constants.length; i++) {
-            if (i % 2 == 0) {
-                file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
-            } else {
-                file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
-            }
-            if (constants[i] != null) {
-                writeConstant(i);
+        this.constants = constantPool.getConstantPool();
+        try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_cp.html", charset.name())) {
+            printWriter = newPrintWriter;
+            constantRef = new String[constants.length];
+            constantRef[0] = "&lt;unknown&gt;";
+            printWriter.print("<HTML><head><meta charset=\"");
+            printWriter.print(charset.name());
+            printWriter.println("\"></head>");
+            printWriter.println("<BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
+            // Loop through constants, constants[0] is reserved
+            for (int i = 1; i < constants.length; i++) {
+                if (i % 2 == 0) {
+                    printWriter.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
+                } else {
+                    printWriter.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
+                }
+                if (constants[i] != null) {
+                    writeConstant(i);
+                }
+                printWriter.print("</TD></TR>\n");
             }
-            file.print("</TD></TR>\n");
+            printWriter.println("</TABLE></BODY></HTML>");
         }
-        file.println("</TABLE></BODY></HTML>");
-        file.close();
     }
 
+    private int getMethodNumber(final String str) {
+        for (int i = 0; i < methods.length; i++) {
+            final String cmp = methods[i].getName() + methods[i].getSignature();
+            if (cmp.equals(str)) {
+                return i;
+            }
+        }
+        return -1;
+    }
 
-    String referenceConstant( final int index ) {
+    String referenceConstant(final int index) {
         return constantRef[index];
     }
 
-
-    private void writeConstant( final int index ) {
+    private void writeConstant(final int index) {
         final byte tag = constants[index].getTag();
-        int class_index;
-        int name_index;
+        int classIndex;
+        int nameIndex;
         String ref;
         // The header is always the same
-        file.println("<H4> <A NAME=cp" + index + ">" + index + "</A> " + Const.getConstantName(tag)
-                + "</H4>");
-        /* For every constant type get the needed parameters and print them appropiately
+        printWriter.println("<H4> <A NAME=cp" + index + ">" + index + "</A> " + Const.getConstantName(tag) + "</H4>");
+        /*
+         * For every constant type get the needed parameters and print them appropriately
          */
         switch (tag) {
-            case Const.CONSTANT_InterfaceMethodref:
-            case Const.CONSTANT_Methodref:
-                // Get class_index and name_and_type_index, depending on type
-                if (tag == Const.CONSTANT_Methodref) {
-                    final ConstantMethodref c = (ConstantMethodref) constantPool.getConstant(index,
-                            Const.CONSTANT_Methodref);
-                    class_index = c.getClassIndex();
-                    name_index = c.getNameAndTypeIndex();
-                } else {
-                    final ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref) constantPool
-                            .getConstant(index, Const.CONSTANT_InterfaceMethodref);
-                    class_index = c1.getClassIndex();
-                    name_index = c1.getNameAndTypeIndex();
-                }
-                // Get method name and its class
-                final String method_name = constantPool.constantToString(name_index,
-                        Const.CONSTANT_NameAndType);
-                final String html_method_name = Class2HTML.toHTML(method_name);
-                // Partially compacted class name, i.e., / -> .
-                final String method_class = constantPool.constantToString(class_index, Const.CONSTANT_Class);
-                String short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang.
-                short_method_class = Utility.compactClassName(short_method_class, classPackage
-                        + ".", true); // Remove class package prefix
-                // Get method signature
-                final ConstantNameAndType c2 = (ConstantNameAndType) constantPool.getConstant(
-                        name_index, Const.CONSTANT_NameAndType);
-                final String signature = constantPool.constantToString(c2.getSignatureIndex(),
-                        Const.CONSTANT_Utf8);
-                // Get array of strings containing the argument types
-                final String[] args = Utility.methodSignatureArgumentTypes(signature, false);
-                // Get return type string
-                final String type = Utility.methodSignatureReturnType(signature, false);
-                final String ret_type = Class2HTML.referenceType(type);
-                final StringBuilder buf = new StringBuilder("(");
-                for (int i = 0; i < args.length; i++) {
-                    buf.append(Class2HTML.referenceType(args[i]));
-                    if (i < args.length - 1) {
-                        buf.append(",&nbsp;");
-                    }
-                }
-                buf.append(")");
-                final String arg_types = buf.toString();
-                if (method_class.equals(className)) {
-                    ref = "<A HREF=\"" + className + "_code.html#method"
-                            + getMethodNumber(method_name + signature) + "\" TARGET=Code>"
-                            + html_method_name + "</A>";
-                } else {
-                    ref = "<A HREF=\"" + method_class + ".html" + "\" TARGET=_top>"
-                            + short_method_class + "</A>." + html_method_name;
-                }
-                constantRef[index] = ret_type + "&nbsp;<A HREF=\"" + className + "_cp.html#cp"
-                        + class_index + "\" TARGET=Constants>" + short_method_class
-                        + "</A>.<A HREF=\"" + className + "_cp.html#cp" + index
-                        + "\" TARGET=ConstantPool>" + html_method_name + "</A>&nbsp;" + arg_types;
-                file.println("<P><TT>" + ret_type + "&nbsp;" + ref + arg_types
-                        + "&nbsp;</TT>\n<UL>" + "<LI><A HREF=\"#cp" + class_index
-                        + "\">Class index(" + class_index + ")</A>\n" + "<LI><A HREF=\"#cp"
-                        + name_index + "\">NameAndType index(" + name_index + ")</A></UL>");
-                break;
-            case Const.CONSTANT_Fieldref:
-                // Get class_index and name_and_type_index
-                final ConstantFieldref c3 = (ConstantFieldref) constantPool.getConstant(index,
-                        Const.CONSTANT_Fieldref);
-                class_index = c3.getClassIndex();
-                name_index = c3.getNameAndTypeIndex();
-                // Get method name and its class (compacted)
-                final String field_class = constantPool.constantToString(class_index, Const.CONSTANT_Class);
-                String short_field_class = Utility.compactClassName(field_class); // I.e., remove java.lang.
-                short_field_class = Utility.compactClassName(short_field_class,
-                        classPackage + ".", true); // Remove class package prefix
-                final String field_name = constantPool
-                        .constantToString(name_index, Const.CONSTANT_NameAndType);
-                if (field_class.equals(className)) {
-                    ref = "<A HREF=\"" + field_class + "_methods.html#field" + field_name
-                            + "\" TARGET=Methods>" + field_name + "</A>";
-                } else {
-                    ref = "<A HREF=\"" + field_class + ".html\" TARGET=_top>" + short_field_class
-                            + "</A>." + field_name + "\n";
+        case Const.CONSTANT_InterfaceMethodref:
+        case Const.CONSTANT_Methodref:
+            // Get class_index and name_and_type_index, depending on type
+            if (tag == Const.CONSTANT_Methodref) {
+                final ConstantMethodref c = constantPool.getConstant(index, Const.CONSTANT_Methodref, ConstantMethodref.class);
+                classIndex = c.getClassIndex();
+                nameIndex = c.getNameAndTypeIndex();
+            } else {
+                final ConstantInterfaceMethodref c1 = constantPool.getConstant(index, Const.CONSTANT_InterfaceMethodref, ConstantInterfaceMethodref.class);
+                classIndex = c1.getClassIndex();
+                nameIndex = c1.getNameAndTypeIndex();
+            }
+            // Get method name and its class
+            final String methodName = constantPool.constantToString(nameIndex, Const.CONSTANT_NameAndType);
+            final String htmlMethodName = Class2HTML.toHTML(methodName);
+            // Partially compacted class name, i.e., / -> .
+            final String methodClass = constantPool.constantToString(classIndex, Const.CONSTANT_Class);
+            String shortMethodClass = Utility.compactClassName(methodClass); // I.e., remove java.lang.
+            shortMethodClass = Utility.compactClassName(shortMethodClass, classPackage + ".", true); // Remove class package prefix
+            // Get method signature
+            final ConstantNameAndType c2 = constantPool.getConstant(nameIndex, Const.CONSTANT_NameAndType, ConstantNameAndType.class);
+            final String signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8);
+            // Get array of strings containing the argument types
+            final String[] args = Utility.methodSignatureArgumentTypes(signature, false);
+            // Get return type string
+            final String type = Utility.methodSignatureReturnType(signature, false);
+            final String retType = Class2HTML.referenceType(type);
+            final StringBuilder buf = new StringBuilder("(");
+            for (int i = 0; i < args.length; i++) {
+                buf.append(Class2HTML.referenceType(args[i]));
+                if (i < args.length - 1) {
+                    buf.append(",&nbsp;");
                 }
-                constantRef[index] = "<A HREF=\"" + className + "_cp.html#cp" + class_index
-                        + "\" TARGET=Constants>" + short_field_class + "</A>.<A HREF=\""
-                        + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>"
-                        + field_name + "</A>";
-                file.println("<P><TT>" + ref + "</TT><BR>\n" + "<UL>" + "<LI><A HREF=\"#cp"
-                        + class_index + "\">Class(" + class_index + ")</A><BR>\n"
-                        + "<LI><A HREF=\"#cp" + name_index + "\">NameAndType(" + name_index
-                        + ")</A></UL>");
-                break;
-            case Const.CONSTANT_Class:
-                final ConstantClass c4 = (ConstantClass) constantPool.getConstant(index, Const.CONSTANT_Class);
-                name_index = c4.getNameIndex();
-                final String class_name2 = constantPool.constantToString(index, tag); // / -> .
-                String short_class_name = Utility.compactClassName(class_name2); // I.e., remove java.lang.
-                short_class_name = Utility.compactClassName(short_class_name, classPackage + ".",
-                        true); // Remove class package prefix
-                ref = "<A HREF=\"" + class_name2 + ".html\" TARGET=_top>" + short_class_name
-                        + "</A>";
-                constantRef[index] = "<A HREF=\"" + className + "_cp.html#cp" + index
-                        + "\" TARGET=ConstantPool>" + short_class_name + "</A>";
-                file.println("<P><TT>" + ref + "</TT><UL>" + "<LI><A HREF=\"#cp" + name_index
-                        + "\">Name index(" + name_index + ")</A></UL>\n");
-                break;
-            case Const.CONSTANT_String:
-                final ConstantString c5 = (ConstantString) constantPool.getConstant(index,
-                        Const.CONSTANT_String);
-                name_index = c5.getStringIndex();
-                final String str = Class2HTML.toHTML(constantPool.constantToString(index, tag));
-                file.println("<P><TT>" + str + "</TT><UL>" + "<LI><A HREF=\"#cp" + name_index
-                        + "\">Name index(" + name_index + ")</A></UL>\n");
-                break;
-            case Const.CONSTANT_NameAndType:
-                final ConstantNameAndType c6 = (ConstantNameAndType) constantPool.getConstant(index,
-                        Const.CONSTANT_NameAndType);
-                name_index = c6.getNameIndex();
-                final int signature_index = c6.getSignatureIndex();
-                file.println("<P><TT>"
-                        + Class2HTML.toHTML(constantPool.constantToString(index, tag))
-                        + "</TT><UL>" + "<LI><A HREF=\"#cp" + name_index + "\">Name index("
-                        + name_index + ")</A>\n" + "<LI><A HREF=\"#cp" + signature_index
-                        + "\">Signature index(" + signature_index + ")</A></UL>\n");
-                break;
-            default:
-                file.println("<P><TT>" + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "</TT>\n");
-        } // switch
-    }
-
-
-    private int getMethodNumber( final String str ) {
-        for (int i = 0; i < methods.length; i++) {
-            final String cmp = methods[i].getName() + methods[i].getSignature();
-            if (cmp.equals(str)) {
-                return i;
             }
-        }
-        return -1;
+            buf.append(")");
+            final String argTypes = buf.toString();
+            if (methodClass.equals(className)) {
+                ref = "<A HREF=\"" + className + "_code.html#method" + getMethodNumber(methodName + signature) + "\" TARGET=Code>" + htmlMethodName + "</A>";
+            } else {
+                ref = "<A HREF=\"" + methodClass + ".html" + "\" TARGET=_top>" + shortMethodClass + "</A>." + htmlMethodName;
+            }
+            constantRef[index] = retType + "&nbsp;<A HREF=\"" + className + "_cp.html#cp" + classIndex + "\" TARGET=Constants>" + shortMethodClass
+                + "</A>.<A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + htmlMethodName + "</A>&nbsp;" + argTypes;
+            printWriter.println("<P><TT>" + retType + "&nbsp;" + ref + argTypes + "&nbsp;</TT>\n<UL>" + "<LI><A HREF=\"#cp" + classIndex + "\">Class index("
+                + classIndex + ")</A>\n" + "<LI><A HREF=\"#cp" + nameIndex + "\">NameAndType index(" + nameIndex + ")</A></UL>");
+            break;
+        case Const.CONSTANT_Fieldref:
+            // Get class_index and name_and_type_index
+            final ConstantFieldref c3 = constantPool.getConstant(index, Const.CONSTANT_Fieldref, ConstantFieldref.class);
+            classIndex = c3.getClassIndex();
+            nameIndex = c3.getNameAndTypeIndex();
+            // Get method name and its class (compacted)
+            final String fieldClass = constantPool.constantToString(classIndex, Const.CONSTANT_Class);
+            String shortFieldClass = Utility.compactClassName(fieldClass); // I.e., remove java.lang.
+            shortFieldClass = Utility.compactClassName(shortFieldClass, classPackage + ".", true); // Remove class package prefix
+            final String fieldName = constantPool.constantToString(nameIndex, Const.CONSTANT_NameAndType);
+            if (fieldClass.equals(className)) {
+                ref = "<A HREF=\"" + fieldClass + "_methods.html#field" + fieldName + "\" TARGET=Methods>" + fieldName + "</A>";
+            } else {
+                ref = "<A HREF=\"" + fieldClass + ".html\" TARGET=_top>" + shortFieldClass + "</A>." + fieldName + "\n";
+            }
+            constantRef[index] = "<A HREF=\"" + className + "_cp.html#cp" + classIndex + "\" TARGET=Constants>" + shortFieldClass + "</A>.<A HREF=\""
+                + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + fieldName + "</A>";
+            printWriter.println("<P><TT>" + ref + "</TT><BR>\n" + "<UL>" + "<LI><A HREF=\"#cp" + classIndex + "\">Class(" + classIndex + ")</A><BR>\n"
+                + "<LI><A HREF=\"#cp" + nameIndex + "\">NameAndType(" + nameIndex + ")</A></UL>");
+            break;
+        case Const.CONSTANT_Class:
+            final ConstantClass c4 = constantPool.getConstant(index, Const.CONSTANT_Class, ConstantClass.class);
+            nameIndex = c4.getNameIndex();
+            final String className2 = constantPool.constantToString(index, tag); // / -> .
+            String shortClassName = Utility.compactClassName(className2); // I.e., remove java.lang.
+            shortClassName = Utility.compactClassName(shortClassName, classPackage + ".", true); // Remove class package prefix
+            ref = "<A HREF=\"" + className2 + ".html\" TARGET=_top>" + shortClassName + "</A>";
+            constantRef[index] = "<A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + shortClassName + "</A>";
+            printWriter.println("<P><TT>" + ref + "</TT><UL>" + "<LI><A HREF=\"#cp" + nameIndex + "\">Name index(" + nameIndex + ")</A></UL>\n");
+            break;
+        case Const.CONSTANT_String:
+            final ConstantString c5 = constantPool.getConstant(index, Const.CONSTANT_String, ConstantString.class);
+            nameIndex = c5.getStringIndex();
+            final String str = Class2HTML.toHTML(constantPool.constantToString(index, tag));
+            printWriter.println("<P><TT>" + str + "</TT><UL>" + "<LI><A HREF=\"#cp" + nameIndex + "\">Name index(" + nameIndex + ")</A></UL>\n");
+            break;
+        case Const.CONSTANT_NameAndType:
+            final ConstantNameAndType c6 = constantPool.getConstant(index, Const.CONSTANT_NameAndType, ConstantNameAndType.class);
+            nameIndex = c6.getNameIndex();
+            final int signatureIndex = c6.getSignatureIndex();
+            printWriter.println("<P><TT>" + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "</TT><UL>" + "<LI><A HREF=\"#cp" + nameIndex
+                + "\">Name index(" + nameIndex + ")</A>\n" + "<LI><A HREF=\"#cp" + signatureIndex + "\">Signature index(" + signatureIndex + ")</A></UL>\n");
+            break;
+        default:
+            printWriter.println("<P><TT>" + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "</TT>\n");
+        } // switch
     }
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java
index 46d22379524..5b045bf08cc 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/InstructionFinder.java
@@ -20,11 +20,8 @@
 
 package com.sun.org.apache.bcel.internal.util;
 
-import com.sun.org.apache.bcel.internal.Const;
-import com.sun.org.apache.bcel.internal.generic.ClassGenException;
-import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
-import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -33,16 +30,18 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import com.sun.org.apache.bcel.internal.Const;
+import com.sun.org.apache.bcel.internal.generic.ClassGenException;
+import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
+import com.sun.org.apache.bcel.internal.generic.InstructionList;
+
 /**
- * InstructionFinder is a tool to search for given instructions patterns, i.e.,
- * match sequences of instructions in an instruction list via regular
- * expressions. This can be used, e.g., in order to implement a peep hole
- * optimizer that looks for code patterns and replaces them with faster
- * equivalents.
+ * InstructionFinder is a tool to search for given instructions patterns, i.e., match sequences of instructions in an
+ * instruction list via regular expressions. This can be used, e.g., in order to implement a peep hole optimizer that
+ * looks for code patterns and replaces them with faster equivalents.
  *
  * <p>
- * This class internally uses the java.util.regex
- * package to search for regular expressions.
+ * This class internally uses the java.util.regex package to search for regular expressions.
  *
  * A typical application would look like this:
  *
@@ -68,73 +67,116 @@
  */
 public class InstructionFinder {
 
-    private static final int OFFSET = 32767; // char + OFFSET is outside of LATIN-1
-    private static final int NO_OPCODES = 256; // Potential number, some are not used
-    private static final Map<String, String> map = new HashMap<>();
-    private final InstructionList il;
-    private String ilString; // instruction list as string
-    private InstructionHandle[] handles; // map instruction
-
-
-    // list to array
     /**
-     * @param il
-     *          instruction list to search for given patterns
+     * Code patterns found may be checked using an additional user-defined constraint object whether they really match the
+     * needed criterion. I.e., check constraints that can not expressed with regular expressions.
+     *
      */
-    public InstructionFinder(final InstructionList il) {
-        this.il = il;
-        reread();
-    }
-
+    public interface CodeConstraint {
 
-    /**
-     * Reread the instruction list, e.g., after you've altered the list upon a
-     * match.
-     */
-    public final void reread() {
-        final int size = il.getLength();
-        final char[] buf = new char[size]; // Create a string with length equal to il length
-        handles = il.getInstructionHandles();
-        // Map opcodes to characters
-        for (int i = 0; i < size; i++) {
-            buf[i] = makeChar(handles[i].getInstruction().getOpcode());
-        }
-        ilString = new String(buf);
+        /**
+         * @param match array of instructions matching the requested pattern
+         * @return true if the matched area is really useful
+         */
+        boolean checkCode(InstructionHandle[] match);
     }
 
+    private static final int OFFSET = 32767; // char + OFFSET is outside of LATIN-1
+    private static final int NO_OPCODES = 256; // Potential number, some are not used
+    private static final Map<String, String> map = new HashMap<>();
 
-    /**
-     * Map symbolic instruction names like "getfield" to a single character.
-     *
-     * @param pattern
-     *          instruction pattern in lower case
-     * @return encoded string for a pattern such as "BranchInstruction".
-     */
-    private static String mapName( final String pattern ) {
-        final String result = map.get(pattern);
-        if (result != null) {
-            return result;
-        }
+    // Initialize pattern map
+    static {
+        map.put("arithmeticinstruction",
+            "(irem|lrem|iand|ior|ineg|isub|lneg|fneg|fmul|ldiv|fadd|lxor|frem|idiv|land|ixor|ishr|fsub|lshl|fdiv|iadd|lor|dmul|lsub|ishl|imul|lmul|lushr|dneg|iushr|lshr|ddiv|drem|dadd|ladd|dsub)");
+        map.put("invokeinstruction", "(invokevirtual|invokeinterface|invokestatic|invokespecial|invokedynamic)");
+        map.put("arrayinstruction",
+            "(baload|aastore|saload|caload|fastore|lastore|iaload|castore|iastore|aaload|bastore|sastore|faload|laload|daload|dastore)");
+        map.put("gotoinstruction", "(goto|goto_w)");
+        map.put("conversioninstruction", "(d2l|l2d|i2s|d2i|l2i|i2b|l2f|d2f|f2i|i2d|i2l|f2d|i2c|f2l|i2f)");
+        map.put("localvariableinstruction", "(fstore|iinc|lload|dstore|dload|iload|aload|astore|istore|fload|lstore)");
+        map.put("loadinstruction", "(fload|dload|lload|iload|aload)");
+        map.put("fieldinstruction", "(getfield|putstatic|getstatic|putfield)");
+        map.put("cpinstruction",
+            "(ldc2_w|invokeinterface|invokedynamic|multianewarray|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|ldc_w|invokestatic|invokevirtual|putfield|ldc|new|anewarray)");
+        map.put("stackinstruction", "(dup2|swap|dup2_x2|pop|pop2|dup|dup2_x1|dup_x2|dup_x1)");
+        map.put("branchinstruction",
+            "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");
+        map.put("returninstruction", "(lreturn|ireturn|freturn|dreturn|areturn|return)");
+        map.put("storeinstruction", "(istore|fstore|dstore|astore|lstore)");
+        map.put("select", "(tableswitch|lookupswitch)");
+        map.put("ifinstruction",
+            "(ifeq|ifgt|if_icmpne|if_icmpeq|ifge|ifnull|ifne|if_icmple|if_icmpge|if_acmpeq|if_icmplt|if_acmpne|ifnonnull|iflt|if_icmpgt|ifle)");
+        map.put("jsrinstruction", "(jsr|jsr_w)");
+        map.put("variablelengthinstruction", "(tableswitch|jsr|goto|lookupswitch)");
+        map.put("unconditionalbranch", "(goto|jsr|jsr_w|athrow|goto_w)");
+        map.put("constantpushinstruction", "(dconst|bipush|sipush|fconst|iconst|lconst)");
+        map.put("typedinstruction",
+            "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dastore|ret|f2d|f2i|drem|iinc|i2c|checkcast|frem|lreturn|astore|lushr|daload|dneg|fastore|istore|lshl|ldiv|lstore|areturn|ishr|ldc_w|invokeinterface|invokedynamic|aastore|lxor|ishl|l2d|i2f|return|faload|sipush|iushr|caload|instanceof|invokespecial|putfield|fmul|ireturn|laload|d2f|lneg|ixor|i2l|fdiv|lastore|multianewarray|i2b|getstatic|i2d|putstatic|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|freturn|ldc|aconst_null|castore|lmul|ldc2_w|dadd|iconst|f2l|ddiv|dstore|land|jsr|anewarray|dmul|bipush|dsub|sastore|d2i|i2s|lshr|iadd|l2i|lload|bastore|fstore|fneg|iload|fadd|baload|fconst|ior|ineg|dreturn|l2f|lconst|getfield|invokevirtual|invokestatic|iastore)");
+        map.put("popinstruction", "(fstore|dstore|pop|pop2|astore|putstatic|istore|lstore)");
+        map.put("allocationinstruction", "(multianewarray|new|anewarray|newarray)");
+        map.put("indexedinstruction",
+            "(lload|lstore|fload|ldc2_w|invokeinterface|invokedynamic|multianewarray|astore|dload|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|dstore|istore|iinc|ldc_w|ret|fstore|invokestatic|iload|putfield|invokevirtual|ldc|new|aload|anewarray)");
+        map.put("pushinstruction", "(dup|lload|dup2|bipush|fload|ldc2_w|sipush|lconst|fconst|dload|getstatic|ldc_w|aconst_null|dconst|iload|ldc|iconst|aload)");
+        map.put("stackproducer",
+            "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dup|f2d|f2i|drem|i2c|checkcast|frem|lushr|daload|dneg|lshl|ldiv|ishr|ldc_w|invokeinterface|invokedynamic|lxor|ishl|l2d|i2f|faload|sipush|iushr|caload|instanceof|invokespecial|fmul|laload|d2f|lneg|ixor|i2l|fdiv|getstatic|i2b|swap|i2d|dup2|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|ldc|arraylength|aconst_null|tableswitch|lmul|ldc2_w|iconst|dadd|f2l|ddiv|land|jsr|anewarray|dmul|bipush|dsub|d2i|newarray|i2s|lshr|iadd|lload|l2i|fneg|iload|fadd|baload|fconst|lookupswitch|ior|ineg|lconst|l2f|getfield|invokevirtual|invokestatic)");
+        map.put("stackconsumer",
+            "(imul|lsub|lor|iflt|fcmpg|if_icmpgt|iand|ifeq|if_icmplt|lrem|ifnonnull|idiv|d2l|isub|dcmpg|dastore|if_icmpeq|f2d|f2i|drem|i2c|checkcast|frem|lreturn|astore|lushr|pop2|monitorexit|dneg|fastore|istore|lshl|ldiv|lstore|areturn|if_icmpge|ishr|monitorenter|invokeinterface|invokedynamic|aastore|lxor|ishl|l2d|i2f|return|iushr|instanceof|invokespecial|fmul|ireturn|d2f|lneg|ixor|pop|i2l|ifnull|fdiv|lastore|i2b|if_acmpeq|ifge|swap|i2d|putstatic|fcmpl|ladd|irem|dcmpl|fsub|freturn|ifgt|castore|lmul|dadd|f2l|ddiv|dstore|land|if_icmpne|if_acmpne|dmul|dsub|sastore|ifle|d2i|i2s|lshr|iadd|l2i|bastore|fstore|fneg|fadd|ior|ineg|ifne|dreturn|l2f|if_icmple|getfield|invokevirtual|invokestatic|iastore)");
+        map.put("exceptionthrower",
+            "(irem|lrem|laload|putstatic|baload|dastore|areturn|getstatic|ldiv|anewarray|iastore|castore|idiv|saload|lastore|fastore|putfield|lreturn|caload|getfield|return|aastore|freturn|newarray|instanceof|multianewarray|athrow|faload|iaload|aaload|dreturn|monitorenter|checkcast|bastore|arraylength|new|invokevirtual|sastore|ldc_w|ireturn|invokespecial|monitorexit|invokeinterface|invokedynamic|ldc|invokestatic|daload)");
+        map.put("loadclass",
+            "(multianewarray|invokeinterface|invokedynamic|instanceof|invokespecial|putfield|checkcast|putstatic|invokevirtual|new|getstatic|invokestatic|getfield|anewarray)");
+        map.put("instructiontargeter",
+            "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");
+        // Some aliases
+        map.put("if_icmp", "(if_icmpne|if_icmpeq|if_icmple|if_icmpge|if_icmplt|if_icmpgt)");
+        map.put("if_acmp", "(if_acmpeq|if_acmpne)");
+        map.put("if", "(ifeq|ifne|iflt|ifge|ifgt|ifle)");
+        // Precompile some aliases first
+        map.put("iconst", precompile(Const.ICONST_0, Const.ICONST_5, Const.ICONST_M1));
+        map.put("lconst", new String(new char[] {'(', makeChar(Const.LCONST_0), '|', makeChar(Const.LCONST_1), ')'}));
+        map.put("dconst", new String(new char[] {'(', makeChar(Const.DCONST_0), '|', makeChar(Const.DCONST_1), ')'}));
+        map.put("fconst", new String(new char[] {'(', makeChar(Const.FCONST_0), '|', makeChar(Const.FCONST_1), '|', makeChar(Const.FCONST_2), ')'}));
+        map.put("lload", precompile(Const.LLOAD_0, Const.LLOAD_3, Const.LLOAD));
+        map.put("iload", precompile(Const.ILOAD_0, Const.ILOAD_3, Const.ILOAD));
+        map.put("dload", precompile(Const.DLOAD_0, Const.DLOAD_3, Const.DLOAD));
+        map.put("fload", precompile(Const.FLOAD_0, Const.FLOAD_3, Const.FLOAD));
+        map.put("aload", precompile(Const.ALOAD_0, Const.ALOAD_3, Const.ALOAD));
+        map.put("lstore", precompile(Const.LSTORE_0, Const.LSTORE_3, Const.LSTORE));
+        map.put("istore", precompile(Const.ISTORE_0, Const.ISTORE_3, Const.ISTORE));
+        map.put("dstore", precompile(Const.DSTORE_0, Const.DSTORE_3, Const.DSTORE));
+        map.put("fstore", precompile(Const.FSTORE_0, Const.FSTORE_3, Const.FSTORE));
+        map.put("astore", precompile(Const.ASTORE_0, Const.ASTORE_3, Const.ASTORE));
+        // Compile strings
+        map.forEach((key, value) -> {
+            final char ch = value.charAt(1); // Omit already precompiled patterns
+            if (ch < OFFSET) {
+                map.put(key, compilePattern(value)); // precompile all patterns
+            }
+        });
+        // Add instruction alias to match anything
+        final StringBuilder buf = new StringBuilder("(");
         for (short i = 0; i < NO_OPCODES; i++) {
-            if (pattern.equals(Const.getOpcodeName(i))) {
-                return "" + makeChar(i);
+            if (Const.getNoOfOperands(i) != Const.UNDEFINED) { // Not an invalid opcode
+                buf.append(makeChar(i));
+                if (i < NO_OPCODES - 1) {
+                    buf.append('|');
+                }
             }
         }
-        throw new IllegalArgumentException("Instruction unknown: " + pattern);
+        buf.append(')');
+        map.put("instruction", buf.toString());
     }
 
-
     /**
-     * Replace symbolic names of instructions with the appropiate character and
-     * remove all white space from string. Meta characters such as +, * are
-     * ignored.
+     * Replace symbolic names of instructions with the appropriate character and remove all white space from string. Meta
+     * characters such as +, * are ignored.
      *
-     * @param pattern
-     *          The pattern to compile
+     * @param pattern The pattern to compile
      * @return translated regular expression string
      */
-    private static String compilePattern( final String pattern ) {
-        //Bug: BCEL-77 - Instructions are assumed to be english, to avoid odd Locale issues
+    private static String compilePattern(final String pattern) {
+        // Bug: BCEL-77 - Instructions are assumed to be english, to avoid odd Locale issues
         final String lower = pattern.toLowerCase(Locale.ENGLISH);
         final StringBuilder buf = new StringBuilder();
         final int size = pattern.length();
@@ -144,11 +186,10 @@ private static String compilePattern( final String pattern ) {
                 final StringBuilder name = new StringBuilder();
                 while ((Character.isLetterOrDigit(ch) || ch == '_') && i < size) {
                     name.append(ch);
-                    if (++i < size) {
-                        ch = lower.charAt(i);
-                    } else {
+                    if (++i >= size) {
                         break;
                     }
+                    ch = lower.charAt(i);
                 }
                 i--;
                 buf.append(mapName(name.toString()));
@@ -159,245 +200,172 @@ private static String compilePattern( final String pattern ) {
         return buf.toString();
     }
 
-
     /**
-     * @return the matched piece of code as an array of instruction (handles)
+     * Convert opcode number to char.
      */
-    private InstructionHandle[] getMatch( final int matched_from, final int match_length ) {
-        final InstructionHandle[] match = new InstructionHandle[match_length];
-        System.arraycopy(handles, matched_from, match, 0, match_length);
-        return match;
+    private static char makeChar(final short opcode) {
+        return (char) (opcode + OFFSET);
     }
 
-
     /**
-     * Search for the given pattern in the instruction list. You can search for
-     * any valid opcode via its symbolic name, e.g. "istore". You can also use a
-     * super class or an interface name to match a whole set of instructions, e.g.
-     * "BranchInstruction" or "LoadInstruction". "istore" is also an alias for all
-     * "istore_x" instructions. Additional aliases are "if" for "ifxx", "if_icmp"
-     * for "if_icmpxx", "if_acmp" for "if_acmpxx".
-     *
-     * Consecutive instruction names must be separated by white space which will
-     * be removed during the compilation of the pattern.
-     *
-     * For the rest the usual pattern matching rules for regular expressions
-     * apply.
-     * <P>
-     * Example pattern:
-     *
-     * <pre>
-     * search(&quot;BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*&quot;);
-     * </pre>
-     *
-     * <p>
-     * If you alter the instruction list upon a match such that other matching
-     * areas are affected, you should call reread() to update the finder and call
-     * search() again, because the matches are cached.
+     * Map symbolic instruction names like "getfield" to a single character.
      *
-     * @param pattern
-     *          the instruction pattern to search for, where case is ignored
-     * @param from
-     *          where to start the search in the instruction list
-     * @param constraint
-     *          optional CodeConstraint to check the found code pattern for
-     *          user-defined constraints
-     * @return iterator of matches where e.nextElement() returns an array of
-     *         instruction handles describing the matched area
+     * @param pattern instruction pattern in lower case
+     * @return encoded string for a pattern such as "BranchInstruction".
      */
-    public final Iterator<InstructionHandle[]> search( final String pattern,
-            final InstructionHandle from, final CodeConstraint constraint ) {
-        final String search = compilePattern(pattern);
-        int start = -1;
-        for (int i = 0; i < handles.length; i++) {
-            if (handles[i] == from) {
-                start = i; // Where to start search from (index)
-                break;
-            }
-        }
-        if (start == -1) {
-            throw new ClassGenException("Instruction handle " + from
-                    + " not found in instruction list.");
+    private static String mapName(final String pattern) {
+        final String result = map.get(pattern);
+        if (result != null) {
+            return result;
         }
-        final Pattern regex = Pattern.compile(search);
-        final List<InstructionHandle[]> matches = new ArrayList<>();
-        final Matcher matcher = regex.matcher(ilString);
-        while (start < ilString.length() && matcher.find(start)) {
-            final int startExpr = matcher.start();
-            final int endExpr = matcher.end();
-            final int lenExpr = endExpr - startExpr;
-            final InstructionHandle[] match = getMatch(startExpr, lenExpr);
-            if ((constraint == null) || constraint.checkCode(match)) {
-                matches.add(match);
+        for (short i = 0; i < NO_OPCODES; i++) {
+            if (pattern.equals(Const.getOpcodeName(i))) {
+                return String.valueOf(makeChar(i));
             }
-            start = endExpr;
         }
-        return matches.iterator();
+        throw new IllegalArgumentException("Instruction unknown: " + pattern);
     }
 
+    private static String precompile(final short from, final short to, final short extra) {
+        final StringBuilder buf = new StringBuilder("(");
+        for (short i = from; i <= to; i++) {
+            buf.append(makeChar(i));
+            buf.append('|');
+        }
+        buf.append(makeChar(extra));
+        buf.append(")");
+        return buf.toString();
+    }
+
+    private final InstructionList il;
+
+    private String ilString; // instruction list as string
+
+    private InstructionHandle[] handles; // map instruction
 
+    // list to array
     /**
-     * Start search beginning from the start of the given instruction list.
-     *
-     * @param pattern
-     *          the instruction pattern to search for, where case is ignored
-     * @return iterator of matches where e.nextElement() returns an array of
-     *         instruction handles describing the matched area
+     * @param il instruction list to search for given patterns
      */
-    public final Iterator<InstructionHandle[]> search( final String pattern ) {
-        return search(pattern, il.getStart(), null);
+    public InstructionFinder(final InstructionList il) {
+        this.il = il;
+        reread();
     }
 
-
     /**
-     * Start search beginning from `from'.
-     *
-     * @param pattern
-     *          the instruction pattern to search for, where case is ignored
-     * @param from
-     *          where to start the search in the instruction list
-     * @return iterator of matches where e.nextElement() returns an array of
-     *         instruction handles describing the matched area
+     * @return the inquired instruction list
      */
-    public final Iterator<InstructionHandle[]> search( final String pattern,
-            final InstructionHandle from ) {
-        return search(pattern, from, null);
+    public final InstructionList getInstructionList() {
+        return il;
     }
 
-
     /**
-     * Start search beginning from the start of the given instruction list. Check
-     * found matches with the constraint object.
-     *
-     * @param pattern
-     *          the instruction pattern to search for, case is ignored
-     * @param constraint
-     *          constraints to be checked on matching code
-     * @return instruction handle or `null' if the match failed
+     * @return the matched piece of code as an array of instruction (handles)
      */
-    public final Iterator<InstructionHandle[]> search( final String pattern,
-            final CodeConstraint constraint ) {
-        return search(pattern, il.getStart(), constraint);
+    private InstructionHandle[] getMatch(final int matchedFrom, final int matchLength) {
+        return Arrays.copyOfRange(handles, matchedFrom, matchedFrom + matchLength);
     }
 
-
     /**
-     * Convert opcode number to char.
+     * Reread the instruction list, e.g., after you've altered the list upon a match.
      */
-    private static char makeChar( final short opcode ) {
-        return (char) (opcode + OFFSET);
+    public final void reread() {
+        final int size = il.getLength();
+        final char[] buf = new char[size]; // Create a string with length equal to il length
+        handles = il.getInstructionHandles();
+        // Map opcodes to characters
+        for (int i = 0; i < size; i++) {
+            buf[i] = makeChar(handles[i].getInstruction().getOpcode());
+        }
+        ilString = new String(buf);
     }
 
-
     /**
-     * @return the inquired instruction list
+     * Start search beginning from the start of the given instruction list.
+     *
+     * @param pattern the instruction pattern to search for, where case is ignored
+     * @return iterator of matches where e.nextElement() returns an array of instruction handles describing the matched area
      */
-    public final InstructionList getInstructionList() {
-        return il;
+    public final Iterator<InstructionHandle[]> search(final String pattern) {
+        return search(pattern, il.getStart(), null);
     }
 
     /**
-     * Code patterns found may be checked using an additional user-defined
-     * constraint object whether they really match the needed criterion. I.e.,
-     * check constraints that can not expressed with regular expressions.
+     * Start search beginning from the start of the given instruction list. Check found matches with the constraint object.
      *
+     * @param pattern the instruction pattern to search for, case is ignored
+     * @param constraint constraints to be checked on matching code
+     * @return instruction handle or 'null' if the match failed
      */
-    public interface CodeConstraint {
+    public final Iterator<InstructionHandle[]> search(final String pattern, final CodeConstraint constraint) {
+        return search(pattern, il.getStart(), constraint);
+    }
 
-        /**
-         * @param match
-         *          array of instructions matching the requested pattern
-         * @return true if the matched area is really useful
-         */
-        boolean checkCode( InstructionHandle[] match );
+    /**
+     * Start search beginning from 'from'.
+     *
+     * @param pattern the instruction pattern to search for, where case is ignored
+     * @param from where to start the search in the instruction list
+     * @return iterator of matches where e.nextElement() returns an array of instruction handles describing the matched area
+     */
+    public final Iterator<InstructionHandle[]> search(final String pattern, final InstructionHandle from) {
+        return search(pattern, from, null);
     }
 
-    // Initialize pattern map
-    static {
-        map.put("arithmeticinstruction","(irem|lrem|iand|ior|ineg|isub|lneg|fneg|fmul|ldiv|fadd|lxor|frem|idiv|land|ixor|ishr|fsub|lshl|fdiv|iadd|lor|dmul|lsub|ishl|imul|lmul|lushr|dneg|iushr|lshr|ddiv|drem|dadd|ladd|dsub)");
-        map.put("invokeinstruction", "(invokevirtual|invokeinterface|invokestatic|invokespecial|invokedynamic)");
-        map.put("arrayinstruction", "(baload|aastore|saload|caload|fastore|lastore|iaload|castore|iastore|aaload|bastore|sastore|faload|laload|daload|dastore)");
-        map.put("gotoinstruction", "(goto|goto_w)");
-        map.put("conversioninstruction", "(d2l|l2d|i2s|d2i|l2i|i2b|l2f|d2f|f2i|i2d|i2l|f2d|i2c|f2l|i2f)");
-        map.put("localvariableinstruction","(fstore|iinc|lload|dstore|dload|iload|aload|astore|istore|fload|lstore)");
-        map.put("loadinstruction", "(fload|dload|lload|iload|aload)");
-        map.put("fieldinstruction", "(getfield|putstatic|getstatic|putfield)");
-        map.put("cpinstruction", "(ldc2_w|invokeinterface|invokedynamic|multianewarray|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|ldc_w|invokestatic|invokevirtual|putfield|ldc|new|anewarray)");
-        map.put("stackinstruction", "(dup2|swap|dup2_x2|pop|pop2|dup|dup2_x1|dup_x2|dup_x1)");
-        map.put("branchinstruction", "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");
-        map.put("returninstruction", "(lreturn|ireturn|freturn|dreturn|areturn|return)");
-        map.put("storeinstruction", "(istore|fstore|dstore|astore|lstore)");
-        map.put("select", "(tableswitch|lookupswitch)");
-        map.put("ifinstruction", "(ifeq|ifgt|if_icmpne|if_icmpeq|ifge|ifnull|ifne|if_icmple|if_icmpge|if_acmpeq|if_icmplt|if_acmpne|ifnonnull|iflt|if_icmpgt|ifle)");
-        map.put("jsrinstruction", "(jsr|jsr_w)");
-        map.put("variablelengthinstruction", "(tableswitch|jsr|goto|lookupswitch)");
-        map.put("unconditionalbranch", "(goto|jsr|jsr_w|athrow|goto_w)");
-        map.put("constantpushinstruction", "(dconst|bipush|sipush|fconst|iconst|lconst)");
-        map.put("typedinstruction", "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dastore|ret|f2d|f2i|drem|iinc|i2c|checkcast|frem|lreturn|astore|lushr|daload|dneg|fastore|istore|lshl|ldiv|lstore|areturn|ishr|ldc_w|invokeinterface|invokedynamic|aastore|lxor|ishl|l2d|i2f|return|faload|sipush|iushr|caload|instanceof|invokespecial|putfield|fmul|ireturn|laload|d2f|lneg|ixor|i2l|fdiv|lastore|multianewarray|i2b|getstatic|i2d|putstatic|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|freturn|ldc|aconst_null|castore|lmul|ldc2_w|dadd|iconst|f2l|ddiv|dstore|land|jsr|anewarray|dmul|bipush|dsub|sastore|d2i|i2s|lshr|iadd|l2i|lload|bastore|fstore|fneg|iload|fadd|baload|fconst|ior|ineg|dreturn|l2f|lconst|getfield|invokevirtual|invokestatic|iastore)");
-        map.put("popinstruction", "(fstore|dstore|pop|pop2|astore|putstatic|istore|lstore)");
-        map.put("allocationinstruction", "(multianewarray|new|anewarray|newarray)");
-        map.put("indexedinstruction", "(lload|lstore|fload|ldc2_w|invokeinterface|invokedynamic|multianewarray|astore|dload|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|dstore|istore|iinc|ldc_w|ret|fstore|invokestatic|iload|putfield|invokevirtual|ldc|new|aload|anewarray)");
-        map.put("pushinstruction", "(dup|lload|dup2|bipush|fload|ldc2_w|sipush|lconst|fconst|dload|getstatic|ldc_w|aconst_null|dconst|iload|ldc|iconst|aload)");
-        map.put("stackproducer", "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dup|f2d|f2i|drem|i2c|checkcast|frem|lushr|daload|dneg|lshl|ldiv|ishr|ldc_w|invokeinterface|invokedynamic|lxor|ishl|l2d|i2f|faload|sipush|iushr|caload|instanceof|invokespecial|fmul|laload|d2f|lneg|ixor|i2l|fdiv|getstatic|i2b|swap|i2d|dup2|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|ldc|arraylength|aconst_null|tableswitch|lmul|ldc2_w|iconst|dadd|f2l|ddiv|land|jsr|anewarray|dmul|bipush|dsub|d2i|newarray|i2s|lshr|iadd|lload|l2i|fneg|iload|fadd|baload|fconst|lookupswitch|ior|ineg|lconst|l2f|getfield|invokevirtual|invokestatic)");
-        map.put("stackconsumer", "(imul|lsub|lor|iflt|fcmpg|if_icmpgt|iand|ifeq|if_icmplt|lrem|ifnonnull|idiv|d2l|isub|dcmpg|dastore|if_icmpeq|f2d|f2i|drem|i2c|checkcast|frem|lreturn|astore|lushr|pop2|monitorexit|dneg|fastore|istore|lshl|ldiv|lstore|areturn|if_icmpge|ishr|monitorenter|invokeinterface|invokedynamic|aastore|lxor|ishl|l2d|i2f|return|iushr|instanceof|invokespecial|fmul|ireturn|d2f|lneg|ixor|pop|i2l|ifnull|fdiv|lastore|i2b|if_acmpeq|ifge|swap|i2d|putstatic|fcmpl|ladd|irem|dcmpl|fsub|freturn|ifgt|castore|lmul|dadd|f2l|ddiv|dstore|land|if_icmpne|if_acmpne|dmul|dsub|sastore|ifle|d2i|i2s|lshr|iadd|l2i|bastore|fstore|fneg|fadd|ior|ineg|ifne|dreturn|l2f|if_icmple|getfield|invokevirtual|invokestatic|iastore)");
-        map.put("exceptionthrower","(irem|lrem|laload|putstatic|baload|dastore|areturn|getstatic|ldiv|anewarray|iastore|castore|idiv|saload|lastore|fastore|putfield|lreturn|caload|getfield|return|aastore|freturn|newarray|instanceof|multianewarray|athrow|faload|iaload|aaload|dreturn|monitorenter|checkcast|bastore|arraylength|new|invokevirtual|sastore|ldc_w|ireturn|invokespecial|monitorexit|invokeinterface|invokedynamic|ldc|invokestatic|daload)");
-        map.put("loadclass", "(multianewarray|invokeinterface|invokedynamic|instanceof|invokespecial|putfield|checkcast|putstatic|invokevirtual|new|getstatic|invokestatic|getfield|anewarray)");
-        map.put("instructiontargeter", "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");
-        // Some aliases
-        map.put("if_icmp", "(if_icmpne|if_icmpeq|if_icmple|if_icmpge|if_icmplt|if_icmpgt)");
-        map.put("if_acmp", "(if_acmpeq|if_acmpne)");
-        map.put("if", "(ifeq|ifne|iflt|ifge|ifgt|ifle)");
-        // Precompile some aliases first
-        map.put("iconst", precompile(Const.ICONST_0, Const.ICONST_5, Const.ICONST_M1));
-        map.put("lconst", new String(new char[] { '(', makeChar(Const.LCONST_0), '|', makeChar(Const.LCONST_1), ')' }));
-        map.put("dconst", new String(new char[] { '(', makeChar(Const.DCONST_0), '|', makeChar(Const.DCONST_1), ')' }));
-        map.put("fconst", new String(new char[] { '(', makeChar(Const.FCONST_0), '|', makeChar(Const.FCONST_1), '|', makeChar(Const.FCONST_2), ')' }));
-        map.put("lload", precompile(Const.LLOAD_0, Const.LLOAD_3, Const.LLOAD));
-        map.put("iload", precompile(Const.ILOAD_0, Const.ILOAD_3, Const.ILOAD));
-        map.put("dload", precompile(Const.DLOAD_0, Const.DLOAD_3, Const.DLOAD));
-        map.put("fload", precompile(Const.FLOAD_0, Const.FLOAD_3, Const.FLOAD));
-        map.put("aload", precompile(Const.ALOAD_0, Const.ALOAD_3, Const.ALOAD));
-        map.put("lstore", precompile(Const.LSTORE_0, Const.LSTORE_3, Const.LSTORE));
-        map.put("istore", precompile(Const.ISTORE_0, Const.ISTORE_3, Const.ISTORE));
-        map.put("dstore", precompile(Const.DSTORE_0, Const.DSTORE_3, Const.DSTORE));
-        map.put("fstore", precompile(Const.FSTORE_0, Const.FSTORE_3, Const.FSTORE));
-        map.put("astore", precompile(Const.ASTORE_0, Const.ASTORE_3, Const.ASTORE));
-        // Compile strings
-        for (final Map.Entry<String, String> entry : map.entrySet()) {
-            final String key = entry.getKey();
-            final String value = entry.getValue();
-            final char ch = value.charAt(1); // Omit already precompiled patterns
-            if (ch < OFFSET) {
-                map.put(key, compilePattern(value)); // precompile all patterns
+    /**
+     * Search for the given pattern in the instruction list. You can search for any valid opcode via its symbolic name, e.g.
+     * "istore". You can also use a super class or an interface name to match a whole set of instructions, e.g.
+     * "BranchInstruction" or "LoadInstruction". "istore" is also an alias for all "istore_x" instructions. Additional
+     * aliases are "if" for "ifxx", "if_icmp" for "if_icmpxx", "if_acmp" for "if_acmpxx".
+     *
+     * Consecutive instruction names must be separated by white space which will be removed during the compilation of the
+     * pattern.
+     *
+     * For the rest the usual pattern matching rules for regular expressions apply.
+     * <P>
+     * Example pattern:
+     *
+     * <pre>
+     * search(&quot;BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*&quot;);
+     * </pre>
+     *
+     * <p>
+     * If you alter the instruction list upon a match such that other matching areas are affected, you should call reread()
+     * to update the finder and call search() again, because the matches are cached.
+     *
+     * @param pattern the instruction pattern to search for, where case is ignored
+     * @param from where to start the search in the instruction list
+     * @param constraint optional CodeConstraint to check the found code pattern for user-defined constraints
+     * @return iterator of matches where e.nextElement() returns an array of instruction handles describing the matched area
+     */
+    public final Iterator<InstructionHandle[]> search(final String pattern, final InstructionHandle from, final CodeConstraint constraint) {
+        final String search = compilePattern(pattern);
+        int start = -1;
+        for (int i = 0; i < handles.length; i++) {
+            if (handles[i] == from) {
+                start = i; // Where to start search from (index)
+                break;
             }
         }
-        // Add instruction alias to match anything
-        final StringBuilder buf = new StringBuilder("(");
-        for (short i = 0; i < NO_OPCODES; i++) {
-            if (Const.getNoOfOperands(i) != Const.UNDEFINED) { // Not an invalid opcode
-                buf.append(makeChar(i));
-                if (i < NO_OPCODES - 1) {
-                    buf.append('|');
-                }
-            }
+        if (start == -1) {
+            throw new ClassGenException("Instruction handle " + from + " not found in instruction list.");
         }
-        buf.append(')');
-        map.put("instruction", buf.toString());
-    }
-
-
-    private static String precompile( final short from, final short to, final short extra ) {
-        final StringBuilder buf = new StringBuilder("(");
-        for (short i = from; i <= to; i++) {
-            buf.append(makeChar(i));
-            buf.append('|');
+        final Pattern regex = Pattern.compile(search);
+        final List<InstructionHandle[]> matches = new ArrayList<>();
+        final Matcher matcher = regex.matcher(ilString);
+        while (start < ilString.length() && matcher.find(start)) {
+            final int startExpr = matcher.start();
+            final int endExpr = matcher.end();
+            final int lenExpr = endExpr - startExpr;
+            final InstructionHandle[] match = getMatch(startExpr, lenExpr);
+            if (constraint == null || constraint.checkCode(match)) {
+                matches.add(match);
+            }
+            start = endExpr;
         }
-        buf.append(makeChar(extra));
-        buf.append(")");
-        return buf.toString();
+        return matches.iterator();
     }
 
-
     /*
      * Internal debugging routines.
      */
@@ -405,7 +373,6 @@ private static String precompile( final short from, final short to, final short
 //        return pattern2string(pattern, true);
 //    }
 
-
 //    private static final String pattern2string( String pattern, boolean make_string ) {
 //        StringBuffer buf = new StringBuffer();
 //        for (int i = 0; i < pattern.length(); i++) {
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java
index 05f25ed775e..a75a58bedbf 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/MethodHTML.java
@@ -21,14 +21,14 @@
 
 package com.sun.org.apache.bcel.internal.util;
 
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.FileNotFoundException;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 
 import com.sun.org.apache.bcel.internal.Const;
 import com.sun.org.apache.bcel.internal.classfile.Attribute;
 import com.sun.org.apache.bcel.internal.classfile.Code;
-import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
 import com.sun.org.apache.bcel.internal.classfile.ExceptionTable;
 import com.sun.org.apache.bcel.internal.classfile.Field;
 import com.sun.org.apache.bcel.internal.classfile.Method;
@@ -36,75 +36,69 @@
 
 /**
  * Convert methods and fields into HTML file.
- *
- *
  */
 final class MethodHTML {
 
     private final String className; // name of current class
-    private final PrintWriter file; // file to write to
+    private final PrintWriter printWriter; // file to write to
     private final ConstantHTML constantHtml;
-    private final AttributeHTML attribute_html;
+    private final AttributeHTML attributeHtml;
 
-
-    MethodHTML(final String dir, final String class_name, final Method[] methods, final Field[] fields,
-            final ConstantHTML constant_html, final AttributeHTML attribute_html) throws IOException {
-        this.className = class_name;
-        this.attribute_html = attribute_html;
-        this.constantHtml = constant_html;
-        file = new PrintWriter(new FileOutputStream(dir + class_name + "_methods.html"));
-        file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
-        file.println("<TR><TH ALIGN=LEFT>Access&nbsp;flags</TH><TH ALIGN=LEFT>Type</TH>"
-                + "<TH ALIGN=LEFT>Field&nbsp;name</TH></TR>");
-        for (final Field field : fields) {
-            writeField(field);
-        }
-        file.println("</TABLE>");
-        file.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Access&nbsp;flags</TH>"
-                + "<TH ALIGN=LEFT>Return&nbsp;type</TH><TH ALIGN=LEFT>Method&nbsp;name</TH>"
-                + "<TH ALIGN=LEFT>Arguments</TH></TR>");
-        for (int i = 0; i < methods.length; i++) {
-            writeMethod(methods[i], i);
+    MethodHTML(final String dir, final String className, final Method[] methods, final Field[] fields, final ConstantHTML constantHtml,
+        final AttributeHTML attributeHtml, final Charset charset) throws FileNotFoundException, UnsupportedEncodingException {
+        this.className = className;
+        this.attributeHtml = attributeHtml;
+        this.constantHtml = constantHtml;
+        try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_methods.html", charset.name())) {
+            printWriter = newPrintWriter;
+            printWriter.print("<HTML><head><meta charset=\"");
+            printWriter.print(charset.name());
+            printWriter.println("\"></head>");
+            printWriter.println("<BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
+            printWriter.println("<TR><TH ALIGN=LEFT>Access&nbsp;flags</TH><TH ALIGN=LEFT>Type</TH>" + "<TH ALIGN=LEFT>Field&nbsp;name</TH></TR>");
+            for (final Field field : fields) {
+                writeField(field);
+            }
+            printWriter.println("</TABLE>");
+            printWriter.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Access&nbsp;flags</TH>"
+                + "<TH ALIGN=LEFT>Return&nbsp;type</TH><TH ALIGN=LEFT>Method&nbsp;name</TH>" + "<TH ALIGN=LEFT>Arguments</TH></TR>");
+            for (int i = 0; i < methods.length; i++) {
+                writeMethod(methods[i], i);
+            }
+            printWriter.println("</TABLE></BODY></HTML>");
         }
-        file.println("</TABLE></BODY></HTML>");
-        file.close();
     }
 
-
     /**
      * Print field of class.
      *
      * @param field field to print
-     * @throws java.io.IOException
      */
-    private void writeField( final Field field ) throws IOException {
+    private void writeField(final Field field) {
         final String type = Utility.signatureToString(field.getSignature());
         final String name = field.getName();
         String access = Utility.accessToString(field.getAccessFlags());
         Attribute[] attributes;
         access = Utility.replace(access, " ", "&nbsp;");
-        file.print("<TR><TD><FONT COLOR=\"#FF0000\">" + access + "</FONT></TD>\n<TD>"
-                + Class2HTML.referenceType(type) + "</TD><TD><A NAME=\"field" + name + "\">" + name
-                + "</A></TD>");
+        printWriter.print("<TR><TD><FONT COLOR=\"#FF0000\">" + access + "</FONT></TD>\n<TD>" + Class2HTML.referenceType(type) + "</TD><TD><A NAME=\"field"
+            + name + "\">" + name + "</A></TD>");
         attributes = field.getAttributes();
         // Write them to the Attributes.html file with anchor "<name>[<i>]"
         for (int i = 0; i < attributes.length; i++) {
-            attribute_html.writeAttribute(attributes[i], name + "@" + i);
+            attributeHtml.writeAttribute(attributes[i], name + "@" + i);
         }
         for (int i = 0; i < attributes.length; i++) {
             if (attributes[i].getTag() == Const.ATTR_CONSTANT_VALUE) { // Default value
-                final String str = ((ConstantValue) attributes[i]).toString();
+                final String str = attributes[i].toString();
                 // Reference attribute in _attributes.html
-                file.print("<TD>= <A HREF=\"" + className + "_attributes.html#" + name + "@" + i
-                        + "\" TARGET=\"Attributes\">" + str + "</TD>\n");
+                printWriter.print("<TD>= <A HREF=\"" + className + "_attributes.html#" + name + "@" + i + "\" TARGET=\"Attributes\">" + str + "</TD>\n");
                 break;
             }
         }
-        file.println("</TR>");
+        printWriter.println("</TR>");
     }
 
-
-    private void writeMethod( final Method method, final int method_number ) {
+    private void writeMethod(final Method method, final int methodNumber) {
         // Get raw signature
         final String signature = method.getSignature();
         // Get array of strings containing the argument types
@@ -113,48 +107,44 @@ private void writeMethod( final Method method, final int method_number ) {
         final String type = Utility.methodSignatureReturnType(signature, false);
         // Get method name
         final String name = method.getName();
-        String html_name;
+        String htmlName;
         // Get method's access flags
         String access = Utility.accessToString(method.getAccessFlags());
         // Get the method's attributes, the Code Attribute in particular
         final Attribute[] attributes = method.getAttributes();
-        /* HTML doesn't like names like <clinit> and spaces are places to break
-         * lines. Both we don't want...
+        /*
+         * HTML doesn't like names like <clinit> and spaces are places to break lines. Both we don't want...
          */
         access = Utility.replace(access, " ", "&nbsp;");
-        html_name = Class2HTML.toHTML(name);
-        file.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + method_number
-                + ">" + access + "</A></FONT></TD>");
-        file.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + className
-                + "_code.html#method" + method_number + " TARGET=Code>" + html_name
-                + "</A></TD>\n<TD>(");
+        htmlName = Class2HTML.toHTML(name);
+        printWriter.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + methodNumber + ">" + access + "</A></FONT></TD>");
+        printWriter.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + className + "_code.html#method" + methodNumber + " TARGET=Code>"
+            + htmlName + "</A></TD>\n<TD>(");
         for (int i = 0; i < args.length; i++) {
-            file.print(Class2HTML.referenceType(args[i]));
+            printWriter.print(Class2HTML.referenceType(args[i]));
             if (i < args.length - 1) {
-                file.print(", ");
+                printWriter.print(", ");
             }
         }
-        file.print(")</TD></TR>");
+        printWriter.print(")</TD></TR>");
         // Check for thrown exceptions
         for (int i = 0; i < attributes.length; i++) {
-            attribute_html.writeAttribute(attributes[i], "method" + method_number + "@" + i,
-                    method_number);
+            attributeHtml.writeAttribute(attributes[i], "method" + methodNumber + "@" + i, methodNumber);
             final byte tag = attributes[i].getTag();
             if (tag == Const.ATTR_EXCEPTIONS) {
-                file.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>");
+                printWriter.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>");
                 final int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable();
                 for (int j = 0; j < exceptions.length; j++) {
-                    file.print(constantHtml.referenceConstant(exceptions[j]));
+                    printWriter.print(constantHtml.referenceConstant(exceptions[j]));
                     if (j < exceptions.length - 1) {
-                        file.print(", ");
+                        printWriter.print(", ");
                     }
                 }
-                file.println("</TD></TR>");
+                printWriter.println("</TD></TR>");
             } else if (tag == Const.ATTR_CODE) {
-                final Attribute[] c_a = ((Code) attributes[i]).getAttributes();
-                for (int j = 0; j < c_a.length; j++) {
-                    attribute_html.writeAttribute(c_a[j], "method" + method_number + "@" + i + "@"
-                            + j, method_number);
+                final Attribute[] attributeArray = ((Code) attributes[i]).getAttributes();
+                for (int j = 0; j < attributeArray.length; j++) {
+                    attributeHtml.writeAttribute(attributeArray[j], "method" + methodNumber + "@" + i + "@" + j, methodNumber);
                 }
             }
         }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java
index 9958d0a1a62..fd7cd0d2dc3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ModularRuntimeImage.java
@@ -35,7 +35,6 @@
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -54,28 +53,24 @@ public class ModularRuntimeImage implements Closeable {
 
     /**
      * Constructs a default instance.
-     *
-     * @throws IOException
-     *             an I/O error occurs accessing the file system
      */
-    public ModularRuntimeImage() throws IOException {
+    @SuppressWarnings("resource") // See #close()
+    public ModularRuntimeImage() {
         this(null, FileSystems.getFileSystem(URI.create("jrt:/")));
     }
 
     /**
      * Constructs an instance using the JRT file system implementation from a specific Java Home.
      *
-     * @param javaHome
-     *            Path to a Java 9 or greater home.
+     * @param javaHome Path to a Java 9 or greater home.
      *
-     * @throws IOException
-     *             an I/O error occurs accessing the file system
+     * @throws IOException an I/O error occurs accessing the file system
      */
     public ModularRuntimeImage(final String javaHome) throws IOException {
         final Map<String, ?> emptyMap = Collections.emptyMap();
         final Path jrePath = Paths.get(javaHome);
         final Path jrtFsPath = jrePath.resolve("lib").resolve("jrt-fs.jar");
-        this.classLoader = new URLClassLoader(new URL[] {jrtFsPath.toUri().toURL() });
+        this.classLoader = URLClassLoader.newInstance(new URL[] {jrtFsPath.toUri().toURL()});
         this.fileSystem = FileSystems.newFileSystem(URI.create("jrt:/"), emptyMap, classLoader);
     }
 
@@ -94,22 +89,21 @@ public void close() throws IOException {
         }
     }
 
+    public FileSystem getFileSystem() {
+        return fileSystem;
+    }
+
     /**
      * Lists all entries in the given directory.
      *
-     * @param dirPath
-     *            directory path.
+     * @param dirPath directory path.
      * @return a list of dir entries if an I/O error occurs
-     * @throws IOException
-     *             an I/O error occurs accessing the file system
+     * @throws IOException an I/O error occurs accessing the file system
      */
     public List<Path> list(final Path dirPath) throws IOException {
         final List<Path> list = new ArrayList<>();
         try (DirectoryStream<Path> ds = Files.newDirectoryStream(dirPath)) {
-            final Iterator<Path> iterator = ds.iterator();
-            while (iterator.hasNext()) {
-                list.add(iterator.next());
-            }
+            ds.forEach(list::add);
         }
         return list;
     }
@@ -117,11 +111,9 @@ public List<Path> list(final Path dirPath) throws IOException {
     /**
      * Lists all entries in the given directory.
      *
-     * @param dirName
-     *            directory path.
+     * @param dirName directory path.
      * @return a list of dir entries if an I/O error occurs
-     * @throws IOException
-     *             an I/O error occurs accessing the file system
+     * @throws IOException an I/O error occurs accessing the file system
      */
     public List<Path> list(final String dirName) throws IOException {
         return list(fileSystem.getPath(dirName));
@@ -131,8 +123,7 @@ public List<Path> list(final String dirName) throws IOException {
      * Lists all modules.
      *
      * @return a list of modules
-     * @throws IOException
-     *             an I/O error occurs accessing the file system
+     * @throws IOException an I/O error occurs accessing the file system
      */
     public List<Path> modules() throws IOException {
         return list(MODULES_PATH);
@@ -142,15 +133,10 @@ public List<Path> modules() throws IOException {
      * Lists all packages.
      *
      * @return a list of modules
-     * @throws IOException
-     *             an I/O error occurs accessing the file system
+     * @throws IOException an I/O error occurs accessing the file system
      */
     public List<Path> packages() throws IOException {
         return list(PACKAGES_PATH);
     }
 
-    public FileSystem getFileSystem() {
-        return fileSystem;
-    }
-
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Repository.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Repository.java
index cf2add7a506..8d1ddf493cd 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Repository.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Repository.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,42 +22,45 @@
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
 
 /**
- * Abstract definition of a class repository. Instances may be used
- * to load classes from different sources and may be used in the
- * Repository.setRepository method.
+ * Abstract definition of a class repository. Instances may be used to load classes from different sources and may be
+ * used in the Repository.setRepository method.
  *
- * @see com.sun.org.apache.bcel.internal.Repository
- * @LastModified: Jan 2020
+ * @see org.apache.bcel.Repository
+ * @LastModified: Feb 2023
  */
 public interface Repository {
 
     /**
-     * Stores the provided class under "clazz.getClassName()"
+     * Clears all entries from cache.
      */
-    void storeClass(JavaClass clazz);
+    void clear();
 
     /**
-     * Removes class from repository
+     * Finds the class with the name provided, if the class isn't there, return NULL.
      */
-    void removeClass(JavaClass clazz);
+    JavaClass findClass(String className);
 
     /**
-     * Finds the class with the name provided, if the class isn't there, return NULL.
+     * Finds the JavaClass instance for the given run-time class object.
+     *
+     * @throws ClassNotFoundException if the class can't be found.
      */
-    JavaClass findClass(String className);
+    JavaClass loadClass(Class<?> clazz) throws ClassNotFoundException;
 
     /**
      * Finds the class with the name provided, if the class isn't there, make an attempt to load it.
+     *
+     * @throws ClassNotFoundException if the class can't be found.
      */
-    JavaClass loadClass(String className) throws java.lang.ClassNotFoundException;
+    JavaClass loadClass(String className) throws ClassNotFoundException;
 
     /**
-     * Finds the JavaClass instance for the given run-time class object
+     * Removes class from repository
      */
-    JavaClass loadClass(Class<?> clazz) throws java.lang.ClassNotFoundException;
+    void removeClass(JavaClass clazz);
 
     /**
-     * Clears all entries from cache.
+     * Stores the provided class under "clazz.getClassName()"
      */
-    void clear();
+    void storeClass(JavaClass clazz);
 }
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java
index c0c708235ec..470c6ea17b6 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/SyntheticRepository.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,22 +24,23 @@
 
 import com.sun.org.apache.bcel.internal.classfile.ClassParser;
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
+import com.sun.org.apache.bcel.internal.classfile.Utility;
 import java.lang.ref.SoftReference;
 import java.util.HashMap;
 import java.util.Map;
 
 /**
- * This repository is used in situations where a Class is created outside the
- * realm of a ClassLoader. Classes are loaded from the file systems using the
- * paths specified in the given class path. By default, this is the value
- * returned by ClassPath.getClassPath(). <br>
- * This repository uses a factory design, allowing it to maintain a collection
- * of different classpaths, and as such It is designed to be used as a singleton
- * per classpath.
+ * This repository is used in situations where a Class is created outside the realm of a ClassLoader. Classes are loaded
+ * from the file systems using the paths specified in the given class path. By default, this is the value returned by
+ * ClassPath.getClassPath().
+ * <p>
+ * This repository uses a factory design, allowing it to maintain a collection of different classpaths, and as such It
+ * is designed to be used as a singleton per classpath.
+ * </p>
  *
  * @see com.sun.org.apache.bcel.internal.Repository
  *
- * @LastModified: May 2021
+ * @LastModified: Feb 2023
  */
 public class SyntheticRepository implements Repository {
 
@@ -54,20 +55,11 @@ public static SyntheticRepository getInstance() {
     }
 
     /**
-     * Store a new JavaClass instance into this Repository.
-     */
-    @Override
-    public void storeClass(final JavaClass clazz) {
-        loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz));
-        clazz.setRepository(this);
-        }
-
-    /**
-     * Remove class from repository
+     * Clear all entries from cache.
      */
     @Override
-    public void removeClass(final JavaClass clazz) {
-        loadedClasses.remove(clazz.getClassName());
+    public void clear() {
+        loadedClasses.clear();
     }
 
     /**
@@ -76,48 +68,36 @@ public void removeClass(final JavaClass clazz) {
     @Override
     public JavaClass findClass(final String className) {
         final SoftReference<JavaClass> ref = loadedClasses.get(className);
-        if (ref == null) {
-            return null;
-}
-        return ref.get();
+        return ref == null ? null : ref.get();
     }
 
     /**
-     * Finds a JavaClass object by name. If it is already in this Repository, the
-     * Repository version is returned.
-     *
-     * @param className the name of the class
-     * @return the JavaClass object
-     * @throws ClassNotFoundException if the class is not in the Repository
+     * Remove class from repository
      */
     @Override
-    public JavaClass loadClass(String className) throws ClassNotFoundException {
-        if ((className == null) || className.isEmpty()) {
-            throw new IllegalArgumentException("Invalid class name " + className);
+    public void removeClass(final JavaClass clazz) {
+        loadedClasses.remove(clazz.getClassName());
     }
-        className = className.replace('/', '.'); // Just in case, canonical form
-        final JavaClass clazz = findClass(className);
-        if (clazz != null) {
-            return clazz;
-        }
 
-        IOException e = new IOException("Couldn't find: " + className + ".class");
-        throw new ClassNotFoundException("Exception while looking for class " +
-                className + ": " + e, e);
+    /**
+     * Store a new JavaClass instance into this Repository.
+     */
+    @Override
+    public void storeClass(final JavaClass clazz) {
+        // Not calling super.storeClass because this subclass maintains the mapping.
+        loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz));
+        clazz.setRepository(this);
     }
 
     /**
-     * Find the JavaClass object for a runtime Class object. If a class with the
-     * same name is already in this Repository, the Repository version is
-     * returned. Otherwise, getResourceAsStream() is called on the Class object
-     * to find the class's representation. If the representation is found, it is
-     * added to the Repository.
+     * Finds the JavaClass object for a runtime Class object. If a class with the same name is already in this Repository,
+     * the Repository version is returned. Otherwise, getResourceAsStream() is called on the Class object to find the
+     * class's representation. If the representation is found, it is added to the Repository.
      *
      * @see Class
      * @param clazz the runtime Class object
      * @return JavaClass object for given runtime class
-     * @throws ClassNotFoundException if the class is not in the Repository, and
-     * its representation could not be found
+     * @throws ClassNotFoundException if the class is not in the Repository, and its representation could not be found
      */
     @Override
     public JavaClass loadClass(final Class<?> clazz) throws ClassNotFoundException {
@@ -125,52 +105,54 @@ public JavaClass loadClass(final Class<?> clazz) throws ClassNotFoundException {
         final JavaClass repositoryClass = findClass(className);
         if (repositoryClass != null) {
             return repositoryClass;
-    }
+        }
         String name = className;
         final int i = name.lastIndexOf('.');
         if (i > 0) {
             name = name.substring(i + 1);
         }
-        JavaClass cls = null;
-        try (InputStream clsStream = clazz.getResourceAsStream(name + ".class")) {
-            return cls = loadClass(clsStream, className);
+
+        try (InputStream clsStream = clazz.getResourceAsStream(name + JavaClass.EXTENSION)) {
+            return loadClass(clsStream, className);
         } catch (final IOException e) {
-            return cls;
+            return null;
         }
-
     }
 
-
-    private JavaClass loadClass(final InputStream is, final String className)
-            throws ClassNotFoundException {
+    private JavaClass loadClass(final InputStream inputStream, final String className) throws ClassNotFoundException {
         try {
-            if (is != null) {
-                final ClassParser parser = new ClassParser(is, className);
+            if (inputStream != null) {
+                final ClassParser parser = new ClassParser(inputStream, className);
                 final JavaClass clazz = parser.parse();
                 storeClass(clazz);
                 return clazz;
             }
         } catch (final IOException e) {
-            throw new ClassNotFoundException("Exception while looking for class "
-                    + className + ": " + e, e);
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (final IOException e) {
-                    // ignored
-                }
-            }
+            throw new ClassNotFoundException("Exception while looking for class " + className + ": " + e, e);
         }
-        throw new ClassNotFoundException("SyntheticRepository could not load "
-                + className);
+        throw new ClassNotFoundException("ClassRepository could not load " + className);
     }
 
     /**
-     * Clear all entries from cache.
+     * Finds a JavaClass object by name. If it is already in this Repository, the Repository version is returned. Otherwise,
+     * the Repository's classpath is searched for the class (and it is added to the Repository if found).
+     *
+     * @param className the name of the class
+     * @return the JavaClass object
+     * @throws ClassNotFoundException if the class is not in the Repository, and could not be found on the classpath
      */
     @Override
-    public void clear() {
-        loadedClasses.clear();
+    public JavaClass loadClass(String className) throws ClassNotFoundException {
+        if (className == null || className.isEmpty()) {
+            throw new IllegalArgumentException("Invalid class name " + className);
+        }
+        className = Utility.pathToPackage(className); // Just in case, canonical form
+        final JavaClass clazz = findClass(className);
+        if (clazz != null) {
+            return clazz;
+        }
+        IOException e = new IOException("Couldn't find: " + className + ".class");
+        throw new ClassNotFoundException("Exception while looking for class " +
+                className + ": " + e, e);
     }
 }
diff --git a/src/java.xml/share/classes/jdk/xml/internal/Utils.java b/src/java.xml/share/classes/jdk/xml/internal/Utils.java
new file mode 100644
index 00000000000..439930be15d
--- /dev/null
+++ b/src/java.xml/share/classes/jdk/xml/internal/Utils.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.xml.internal;
+
+import java.util.Arrays;
+
+/**
+ * General utility. Use JdkXmlUtils for XML processing related functions.
+ */
+public class Utils {
+    /**
+     * Creates a new array with copies of the original array and additional items
+     * appended to the end of it.
+     *
+     * @param original the original array
+     * @param items items to be appended to the original array
+     * @return a new array with copies of the original array and additional items
+     */
+    public static Class<?>[] arraysAppend(final Class<?>[] original, final Class<?>... items) {
+        if (original == null && items == null) {
+            return null;
+        }
+        if (items == null) {
+            return Arrays.copyOf(original, original.length);
+        }
+        if (original == null) {
+            return Arrays.copyOf(items, items.length);
+        }
+
+        Class<?>[] result = Arrays.copyOf(original, original.length + items.length);
+        System.arraycopy(items, 0, result, original.length, items.length);
+        return result;
+    }
+}
diff --git a/src/java.xml/share/legal/bcel.md b/src/java.xml/share/legal/bcel.md
index 6dffd077c81..2c673d6b1af 100644
--- a/src/java.xml/share/legal/bcel.md
+++ b/src/java.xml/share/legal/bcel.md
@@ -1,10 +1,10 @@
-## Apache Commons Byte Code Engineering Library (BCEL) Version 6.5.0
+## Apache Commons Byte Code Engineering Library (BCEL) Version 6.7.0
 
 ### Apache Commons BCEL Notice
 <pre>
 
     Apache Commons BCEL
-    Copyright 2004-2020 The Apache Software Foundation
+    Copyright 2004-2022 The Apache Software Foundation
 
     This product includes software developed at
     The Apache Software Foundation (https://www.apache.org/).
diff --git a/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.h b/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.h
index 4ca3d76f079..b2d95f64366 100644
--- a/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.h
+++ b/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.h
@@ -628,9 +628,8 @@ extern "C" {
     AccessibleContext getActiveDescendent (const long vmID, const AccessibleContext accessibleContext);
 
     /**
-       /**
-       * Accessible Value routines
-       */
+     * Accessible Value routines
+     */
     BOOL GetCurrentAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len);
     BOOL GetMaximumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len);
     BOOL GetMinimumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len);
diff --git a/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspector.cpp b/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspector.cpp
index 77f36351963..8f7286c878e 100644
--- a/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspector.cpp
+++ b/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspector.cpp
@@ -668,7 +668,7 @@ void HandlePropertyActiveDescendentChange( long vmID, PropertyChangeEvent event,
                            (int)(sizeof(buffer) - strlen(buffer)) );
         strncat(buffer, "\r\n\r\n", sizeof(buffer));
     }
-#endif _notdef
+#endif // _notdef
 
     if (newActiveDescendent != (AccessibleContext) 0) {
         displayAccessiblePropertyChange(vmID, newActiveDescendent, buffer);
diff --git a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java
index 7f81af9a507..a7c2c49df83 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,6 +103,14 @@ enum Kind {
          */
         ERRONEOUS,
 
+        /**
+         * Used for instances of {@link EscapeTree}
+         * representing some escaped documentation text.
+         *
+         * @since 21
+         */
+        ESCAPE,
+
         /**
          * Used for instances of {@link ThrowsTree}
          * representing an {@code @exception} tag.
@@ -250,7 +258,7 @@ enum Kind {
 
         /**
          * Used for instances of {@link TextTree}
-         * representing some documentation text.
+         * representing some plain documentation text.
          */
         TEXT,
 
diff --git a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java
index 7bfaa7acd46..d7ddbe30d9e 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -143,6 +143,22 @@ default R visitDocType(DocTypeTree node, P p) {
      */
     R visitErroneous(ErroneousTree node, P p);
 
+    /**
+     * Visits an {@code EscapeTree} node.
+     *
+     * @implSpec Visits the provided {@code EscapeTree} node
+     * by calling {@code visitOther(node, p)}.
+     *
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     *
+     * @since 21
+     */
+    default R visitEscape(EscapeTree node, P p)  {
+        return visitOther(node, p);
+    }
+
     /**
      * Visits a {@code HiddenTree} node.
      *
diff --git a/src/jdk.compiler/share/classes/com/sun/source/doctree/EscapeTree.java b/src/jdk.compiler/share/classes/com/sun/source/doctree/EscapeTree.java
new file mode 100644
index 00000000000..e29bfd31893
--- /dev/null
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/EscapeTree.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.util.Elements;
+
+/**
+ * A tree node for a character represented by an escape sequence.
+ *
+ * @apiNote This class does not itself constrain the set of valid escape sequences,
+ * although the set may be effectively constrained to those defined in the
+ * <a href="{@docRoot}/../specs/javadoc/doc-comment-spec.html#escape-sequences">
+ * Documentation Comment Specification for the Standard Doclet</a>,
+ * including the following context-sensitive escape sequences:
+ *
+ * <ul>
+ * <li>{@code @@}, representing {@code @}, where it would otherwise be treated as introducing a block or inline tag,
+ * <li>{@code @/}, representing {@code /}, as part of {@code *@/} to represent <code>&ast;&sol;</code>, and
+ * <li>{@code @*}, representing {@code *}, where it would otherwise be {@linkplain Elements#getDocComment(Element) discarded},
+ *     after whitespace at the beginning of a line.
+ * </ul>
+ *
+ * @since 21
+ */
+public interface EscapeTree extends TextTree {
+    /**
+     * {@inheritDoc}
+     *
+     * <p>Note: this method returns the escaped character, not the original escape sequence.
+     */
+    @Override
+    String getBody();
+}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
index 78e973d23d4..571db71546e 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,9 @@
 
 import java.util.List;
 
+import javax.lang.model.element.Element;
 import javax.lang.model.element.Name;
+import javax.lang.model.util.Elements;
 import javax.tools.Diagnostic;
 import javax.tools.JavaFileObject;
 
@@ -43,6 +45,7 @@
 import com.sun.source.doctree.EndElementTree;
 import com.sun.source.doctree.EntityTree;
 import com.sun.source.doctree.ErroneousTree;
+import com.sun.source.doctree.EscapeTree;
 import com.sun.source.doctree.HiddenTree;
 import com.sun.source.doctree.IdentifierTree;
 import com.sun.source.doctree.IndexTree;
@@ -175,6 +178,29 @@ DocCommentTree newDocCommentTree(List<? extends DocTree> fullBody,
      */
     ErroneousTree newErroneousTree(String text, Diagnostic<JavaFileObject> diag);
 
+    /**
+     * Creates a new {@code EscapeTree} object, to represent an escaped character.
+     *
+     * @apiNote This method does not itself constrain the set of valid escape sequences,
+     * although the set may be effectively constrained to those defined in the
+     * <a href="{@docRoot}/../specs/javadoc/doc-comment-spec.html#escape-sequences">
+     * Documentation Comment Specification for the Standard Doclet</a>,
+     * including the following context-sensitive escape sequences:
+     *
+     * <ul>
+     * <li>{@code @@}, representing {@code @}, where it would otherwise be treated as introducing a block or inline tag,
+     * <li>{@code @/}, representing {@code /}, as part of {@code *@/} to represent <code>&ast;&sol;</code>, and
+     * <li>{@code @*}, representing {@code *}, where it would otherwise be {@linkplain Elements#getDocComment(Element) discarded},
+     *     after whitespace at the beginning of a line.
+     * </ul>
+     *
+     * @param ch the character
+     * @return an {@code EscapeTree} object
+     *
+     * @since 21
+     */
+    EscapeTree newEscapeTree(char ch);
+
     /**
      * Creates a new {@code ThrowsTree} object, to represent an {@code @exception} tag.
      * @param name the name of the exception
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
index bd5a64324ca..28cc82e7378 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -277,6 +277,22 @@ public R visitErroneous(ErroneousTree node, P p) {
         return null;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @implSpec This implementation returns {@code null}.
+     *
+     * @param node  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of scanning
+     *
+     * @since 21
+     */
+    @Override
+    public R visitEscape(EscapeTree node, P p) {
+        return null;
+    }
+
     /**
      * {@inheritDoc}
      *
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
index b3a27f9e6b4..bdd6225c869 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -232,6 +232,22 @@ public R visitErroneous(ErroneousTree node, P p) {
         return defaultAction(node, p);
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @implSpec This implementation calls {@code defaultAction}.
+     *
+     * @param node {@inheritDoc}
+     * @param p {@inheritDoc}
+     * @return  the result of {@code defaultAction}
+     *
+     * @since 21
+     */
+    @Override
+    public R visitEscape(EscapeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     /**
      * {@inheritDoc}
      *
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
index 90566406680..982444a2f16 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
@@ -1364,8 +1364,7 @@ private void propagateNewClassAnnotationsToOwner(JCNewClass tree) {
                     newattrs.append(new Attribute.TypeCompound(old.type, old.values, pos));
                 }
             }
-
-            sym.owner.appendUniqueTypeAttributes(newattrs.toList());
+            appendTypeAnnotationsToOwner(sym, newattrs.toList());
         }
 
         @Override
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
index c928c7c75d1..3463439a8a2 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
@@ -539,10 +539,10 @@ private void handleSwitch(JCTree tree,
                                     pattern = parenthesized.pattern;
                                 }
                                 Assert.check(pattern.hasTag(Tag.BINDINGPATTERN));
-                                VarSymbol binding = ((JCBindingPattern) pattern).var.sym;
+                                BindingSymbol binding = (BindingSymbol) ((JCBindingPattern) pattern).var.sym;
                                 guard = makeBinary(Tag.OR,
                                                    makeBinary(Tag.EQ,
-                                                              make.Ident(binding),
+                                                              make.Ident(bindingContext.getBindingFor(binding)),
                                                               makeNull()),
                                                    guard);
                             }
@@ -740,7 +740,7 @@ public void resolve(VarSymbol commonBinding,
                         List<JCCaseLabel> newLabel;
                         if (hasUnconditional) {
                             newLabel = List.of(make.ConstantCaseLabel(makeNull()),
-                                               make.DefaultCaseLabel());
+                                    make.PatternCaseLabel(binding, newGuard));
                         } else {
                             newLabel = List.of(make.PatternCaseLabel(binding, newGuard));
                         }
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
index 1a12e939f4f..dbf5075c59a 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
@@ -152,6 +152,10 @@ void nextChar() {
         }
     }
 
+    char peekChar() {
+        return buf[bp < buflen ? bp + 1 : buflen];
+    }
+
     protected List<DCTree> blockContent() {
         return blockContent(Phase.BODY);
     }
@@ -224,9 +228,32 @@ protected List<DCTree> blockContent(Phase phase) {
                     break;
 
                 case '@':
+                    // check for context-sensitive escape sequences:
+                    //   newline whitespace @@
+                    //   newline whitespace @*
+                    //   *@/
                     if (newline) {
-                        addPendingText(trees, lastNonWhite);
-                        break loop;
+                        char peek = peekChar();
+                        if (peek == '@' || peek == '*') {
+                            addPendingText(trees, bp - 1);
+                            nextChar();
+                            trees.add(m.at(bp - 1).newEscapeTree(ch));
+                            newline = false;
+                            nextChar();
+                            textStart = bp;
+                            break;
+                        } else {
+                            addPendingText(trees, lastNonWhite);
+                            break loop;
+                        }
+                    } else if (textStart != -1 && buf[bp - 1] == '*' && peekChar() == '/') {
+                        addPendingText(trees, bp - 1);
+                        nextChar();
+                        trees.add(m.at(bp - 1).newEscapeTree('/'));
+                        newline = false;
+                        nextChar();
+                        textStart = bp;
+                        break;
                     }
                     // fallthrough
 
@@ -294,10 +321,24 @@ protected void inlineTag(ListBuffer<DCTree> list) {
         newline = false;
         nextChar();
         if (ch == '@') {
-            addPendingText(list, bp - 2);
-            list.add(inlineTag());
-            textStart = bp;
-            lastNonWhite = -1;
+            // check for context-sensitive escape-sequence
+            //   {@@
+            if (peekChar() == '@') {
+                if (textStart == -1) {
+                    textStart = bp - 1;
+                }
+                addPendingText(list, bp - 1);
+                nextChar();
+                list.add(m.at(bp - 1).newEscapeTree('@'));
+                nextChar();
+                textStart = -1;
+                lastNonWhite = bp;
+            } else {
+                addPendingText(list, bp - 2);
+                list.add(inlineTag());
+                textStart = bp;
+                lastNonWhite = -1;
+            }
         } else {
             if (textStart == -1)
                 textStart = bp - 1;
@@ -624,6 +665,33 @@ private List<DCTree> inlineContent() {
                     nextChar();
                     break;
 
+                case '@':
+                    // check for context-sensitive escape sequences:
+                    //   newline whitespace @@
+                    //   newline whitespace @*
+                    //   *@/
+                    if (newline) {
+                        char peek = peekChar();
+                        if (peek == '@' || peek == '*') {
+                            addPendingText(trees, bp - 1);
+                            nextChar();
+                            trees.add(m.at(bp - 1).newEscapeTree(ch));
+                            newline = false;
+                            nextChar();
+                            textStart = bp;
+                            break;
+                        }
+                    } else if (textStart != -1 && buf[bp - 1] == '*' && peekChar() == '/') {
+                        addPendingText(trees, bp - 1);
+                        nextChar();
+                        trees.add(m.at(bp - 1).newEscapeTree('/'));
+                        newline = false;
+                        nextChar();
+                        textStart = bp;
+                        break;
+                    }
+                    // fallthrough
+
                 default:
                     if (textStart == -1)
                         textStart = bp;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
index 197856eeab5..3e02d2e26b3 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
@@ -241,19 +241,35 @@ protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFact
      *     mode = TYPEARG     : type argument
      *     mode |= NOLAMBDA   : lambdas are not allowed
      */
-    protected static final int EXPR = 0x1;
-    protected static final int TYPE = 0x2;
-    protected static final int NOPARAMS = 0x4;
-    protected static final int TYPEARG = 0x8;
-    protected static final int DIAMOND = 0x10;
-    protected static final int NOLAMBDA = 0x20;
+    protected static final int EXPR          = 1 << 0;
+    protected static final int TYPE          = 1 << 1;
+    protected static final int NOPARAMS      = 1 << 2;
+    protected static final int TYPEARG       = 1 << 3;
+    protected static final int DIAMOND       = 1 << 4;
+    protected static final int NOLAMBDA      = 1 << 5;
+
+    protected void setMode(int mode) {
+        this.mode = mode;
+    }
+
+    protected void setLastMode(int mode) {
+        lastmode = mode;
+    }
+
+    protected boolean isMode(int mode) {
+        return (this.mode & mode) != 0;
+    }
+
+    protected boolean wasTypeMode() {
+        return (lastmode & TYPE) != 0;
+    }
 
     protected void selectExprMode() {
-        mode = (mode & NOLAMBDA) | EXPR;
+        setMode((mode & NOLAMBDA) | EXPR);
     }
 
     protected void selectTypeMode() {
-        mode = (mode & NOLAMBDA) | TYPE;
+        setMode((mode & NOLAMBDA) | TYPE);
     }
 
     /** The current mode.
@@ -477,7 +493,7 @@ public void accept(TokenKind tk, Function<TokenKind, Error> errorProvider) {
      */
     JCExpression illegal(int pos) {
         setErrorEndPos(pos);
-        if ((mode & EXPR) != 0)
+        if (isMode(EXPR))
             return syntaxError(pos, Errors.IllegalStartOfExpr);
         else
             return syntaxError(pos, Errors.IllegalStartOfType);
@@ -857,10 +873,10 @@ public JCExpression unannotatedType(boolean allowVar, int newmode) {
 
     protected JCExpression term(int newmode) {
         int prevmode = mode;
-        mode = newmode;
+        setMode(newmode);
         JCExpression t = term();
-        lastmode = mode;
-        mode = prevmode;
+        setLastMode(mode);
+        setMode(prevmode);
         return t;
     }
 
@@ -879,7 +895,7 @@ protected JCExpression term(int newmode) {
      */
     JCExpression term() {
         JCExpression t = term1();
-        if ((mode & EXPR) != 0 &&
+        if (isMode(EXPR) &&
             (token.kind == EQ || PLUSEQ.compareTo(token.kind) <= 0 && token.kind.compareTo(GTGTGTEQ) <= 0))
             return termRest(t);
         else
@@ -923,7 +939,7 @@ JCExpression termRest(JCExpression t) {
      */
     JCExpression term1() {
         JCExpression t = term2();
-        if ((mode & EXPR) != 0 && token.kind == QUES) {
+        if (isMode(EXPR) && token.kind == QUES) {
             selectExprMode();
             return term1Rest(t);
         } else {
@@ -952,7 +968,7 @@ JCExpression term1Rest(JCExpression t) {
      */
     JCExpression term2() {
         JCExpression t = term3();
-        if ((mode & EXPR) != 0 && prec(token.kind) >= TreeInfo.orPrec) {
+        if (isMode(EXPR) && prec(token.kind) >= TreeInfo.orPrec) {
             selectExprMode();
             return term2Rest(t, TreeInfo.orPrec);
         } else {
@@ -1177,13 +1193,13 @@ protected JCExpression term3() {
         List<JCExpression> typeArgs = typeArgumentsOpt(EXPR);
         switch (token.kind) {
         case QUES:
-            if ((mode & TYPE) != 0 && (mode & (TYPEARG|NOPARAMS)) == TYPEARG) {
+            if (isMode(TYPE) && isMode(TYPEARG) && !isMode(NOPARAMS)) {
                 selectTypeMode();
                 return typeArgument();
             } else
                 return illegal();
         case PLUSPLUS: case SUBSUB: case BANG: case TILDE: case PLUS: case SUB:
-            if (typeArgs == null && (mode & EXPR) != 0) {
+            if (typeArgs == null && isMode(EXPR)) {
                 TokenKind tk = token.kind;
                 nextToken();
                 selectExprMode();
@@ -1199,7 +1215,7 @@ protected JCExpression term3() {
             } else return illegal();
             break;
         case LPAREN:
-            if (typeArgs == null && (mode & EXPR) != 0) {
+            if (typeArgs == null && isMode(EXPR)) {
                 ParensResult pres = analyzeParens();
                 switch (pres) {
                     case CAST:
@@ -1235,7 +1251,7 @@ protected JCExpression term3() {
             }
             break;
         case THIS:
-            if ((mode & EXPR) != 0) {
+            if (isMode(EXPR)) {
                 selectExprMode();
                 t = to(F.at(pos).Ident(names._this));
                 nextToken();
@@ -1247,7 +1263,7 @@ protected JCExpression term3() {
             } else return illegal();
             break;
         case SUPER:
-            if ((mode & EXPR) != 0) {
+            if (isMode(EXPR)) {
                 selectExprMode();
                 t = to(F.at(pos).Ident(names._super));
                 t = superSuffix(typeArgs, t);
@@ -1257,14 +1273,14 @@ protected JCExpression term3() {
         case INTLITERAL: case LONGLITERAL: case FLOATLITERAL: case DOUBLELITERAL:
         case CHARLITERAL: case STRINGLITERAL:
         case TRUE: case FALSE: case NULL:
-            if (typeArgs == null && (mode & EXPR) != 0) {
+            if (typeArgs == null && isMode(EXPR)) {
                 selectExprMode();
                 t = literal(names.empty);
             } else return illegal();
             break;
         case NEW:
             if (typeArgs != null) return illegal();
-            if ((mode & EXPR) != 0) {
+            if (isMode(EXPR)) {
                 selectExprMode();
                 nextToken();
                 if (token.kind == LT) typeArgs = typeArguments(false);
@@ -1282,7 +1298,7 @@ protected JCExpression term3() {
 
             JCExpression expr = term3();
 
-            if ((mode & TYPE) == 0) {
+            if (!isMode(TYPE)) {
                 // Type annotations on class literals no longer legal
                 switch (expr.getTag()) {
                 case REFERENCE: {
@@ -1312,7 +1328,7 @@ protected JCExpression term3() {
             break;
         case UNDERSCORE: case IDENTIFIER: case ASSERT: case ENUM:
             if (typeArgs != null) return illegal();
-            if ((mode & EXPR) != 0 && (mode & NOLAMBDA) == 0 && peekToken(ARROW)) {
+            if (isMode(EXPR) && !isMode(NOLAMBDA) && peekToken(ARROW)) {
                 t = lambdaExpressionOrStatement(false, false, pos);
             } else {
                 t = toP(F.at(token.pos).Ident(ident()));
@@ -1337,7 +1353,7 @@ protected JCExpression term3() {
                             }
                             t = bracketsSuffix(t);
                         } else {
-                            if ((mode & EXPR) != 0) {
+                            if (isMode(EXPR)) {
                                 selectExprMode();
                                 JCExpression t1 = term();
                                 if (!annos.isEmpty()) t = illegal(annos.head.pos);
@@ -1347,7 +1363,7 @@ protected JCExpression term3() {
                         }
                         break loop;
                     case LPAREN:
-                        if ((mode & EXPR) != 0) {
+                        if (isMode(EXPR)) {
                             selectExprMode();
                             t = arguments(typeArgs, t);
                             if (!annos.isEmpty()) t = illegal(annos.head.pos);
@@ -1359,11 +1375,11 @@ protected JCExpression term3() {
                         if (token.kind == TokenKind.IDENTIFIER && typeArgs != null) {
                             return illegal();
                         }
-                        int oldmode = mode;
-                        mode &= ~NOPARAMS;
+                        int prevmode = mode;
+                        setMode(mode & ~NOPARAMS);
                         typeArgs = typeArgumentsOpt(EXPR);
-                        mode = oldmode;
-                        if ((mode & EXPR) != 0) {
+                        setMode(prevmode);
+                        if (isMode(EXPR)) {
                             switch (token.kind) {
                             case CLASS:
                                 if (typeArgs != null) return illegal();
@@ -1396,7 +1412,7 @@ protected JCExpression term3() {
                         }
 
                         List<JCAnnotation> tyannos = null;
-                        if ((mode & TYPE) != 0 && token.kind == MONKEYS_AT) {
+                        if (isMode(TYPE) && token.kind == MONKEYS_AT) {
                             tyannos = typeAnnotationsOpt();
                         }
                         // typeArgs saved for next loop iteration.
@@ -1422,7 +1438,7 @@ protected JCExpression term3() {
                         }
                         break loop;
                     case LT:
-                        if ((mode & TYPE) == 0 && isUnboundMemberRef()) {
+                        if (!isMode(TYPE) && isUnboundMemberRef()) {
                             //this is an unbound method reference whose qualifier
                             //is a generic type i.e. A<S>::m
                             int pos1 = token.pos;
@@ -1465,7 +1481,7 @@ protected JCExpression term3() {
             break;
         case VOID:
             if (typeArgs != null) illegal();
-            if ((mode & EXPR) != 0) {
+            if (isMode(EXPR)) {
                 nextToken();
                 if (token.kind == DOT) {
                     JCPrimitiveTypeTree ti = toP(F.at(pos).TypeIdent(TypeTag.VOID));
@@ -1509,6 +1525,7 @@ protected JCExpression term3() {
                     syntaxError(pos, Errors.Expected3(CASE, DEFAULT, RBRACE));
                 }
             }
+            // Not reachable.
         default:
             return illegal();
         }
@@ -1572,8 +1589,8 @@ JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
 
             if (token.kind == LBRACKET) {
                 nextToken();
-                if ((mode & TYPE) != 0) {
-                    int oldmode = mode;
+                if (isMode(TYPE)) {
+                    int prevmode = mode;
                     selectTypeMode();
                     if (token.kind == RBRACKET) {
                         nextToken();
@@ -1588,9 +1605,9 @@ JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
                         }
                         return t;
                     }
-                    mode = oldmode;
+                    setMode(prevmode);
                 }
-                if ((mode & EXPR) != 0) {
+                if (isMode(EXPR)) {
                     selectExprMode();
                     JCExpression t1 = term();
                     t = to(F.at(pos1).Indexed(t, t1));
@@ -1599,13 +1616,13 @@ JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
             } else if (token.kind == DOT) {
                 nextToken();
                 typeArgs = typeArgumentsOpt(EXPR);
-                if (token.kind == SUPER && (mode & EXPR) != 0) {
+                if (token.kind == SUPER && isMode(EXPR)) {
                     selectExprMode();
                     t = to(F.at(pos1).Select(t, names._super));
                     nextToken();
                     t = arguments(typeArgs, t);
                     typeArgs = null;
-                } else if (token.kind == NEW && (mode & EXPR) != 0) {
+                } else if (token.kind == NEW && isMode(EXPR)) {
                     if (typeArgs != null) return illegal();
                     selectExprMode();
                     int pos2 = token.pos;
@@ -1615,7 +1632,7 @@ JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
                     typeArgs = null;
                 } else {
                     List<JCAnnotation> tyannos = null;
-                    if ((mode & TYPE) != 0 && token.kind == MONKEYS_AT) {
+                    if (isMode(TYPE) && token.kind == MONKEYS_AT) {
                         // is the mode check needed?
                         tyannos = typeAnnotationsOpt();
                     }
@@ -1633,7 +1650,7 @@ JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
                     t = argumentsOpt(typeArgs, typeArgumentsOpt(t));
                     typeArgs = null;
                 }
-            } else if ((mode & EXPR) != 0 && token.kind == COLCOL) {
+            } else if (isMode(EXPR) && token.kind == COLCOL) {
                 selectExprMode();
                 if (typeArgs != null) return illegal();
                 accept(COLCOL);
@@ -1648,7 +1665,7 @@ JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
                 break;
             }
         }
-        while ((token.kind == PLUSPLUS || token.kind == SUBSUB) && (mode & EXPR) != 0) {
+        while ((token.kind == PLUSPLUS || token.kind == SUBSUB) && isMode(EXPR)) {
             selectExprMode();
             t = to(F.at(token.pos).Unary(
                   token.kind == PLUSPLUS ? POSTINC : POSTDEC, t));
@@ -1790,8 +1807,8 @@ ParensResult analyzeParens() {
                         return ParensResult.EXPLICIT_LAMBDA;
                     } else if (peekToken(lookahead, RPAREN, ARROW)) {
                         // Identifier, ')' '->' -> implicit lambda
-                        return (mode & NOLAMBDA) == 0 ? ParensResult.IMPLICIT_LAMBDA
-                                                      : ParensResult.PARENS;
+                        return !isMode(NOLAMBDA) ? ParensResult.IMPLICIT_LAMBDA
+                                                 : ParensResult.PARENS;
                     } else if (depth == 0 && peekToken(lookahead, COMMA)) {
                         defaultResult = ParensResult.IMPLICIT_LAMBDA;
                     }
@@ -2040,7 +2057,7 @@ JCPrimitiveTypeTree basicType() {
     /** ArgumentsOpt = [ Arguments ]
      */
     JCExpression argumentsOpt(List<JCExpression> typeArgs, JCExpression t) {
-        if ((mode & EXPR) != 0 && token.kind == LPAREN || typeArgs != null) {
+        if (isMode(EXPR) && token.kind == LPAREN || typeArgs != null) {
             selectExprMode();
             return arguments(typeArgs, t);
         } else {
@@ -2095,8 +2112,8 @@ boolean isInvalidUnqualifiedMethodIdentifier(int pos, Name name) {
      */
     JCExpression typeArgumentsOpt(JCExpression t) {
         if (token.kind == LT &&
-            (mode & TYPE) != 0 &&
-            (mode & NOPARAMS) == 0) {
+            isMode(TYPE) &&
+            !isMode(NOPARAMS)) {
             selectTypeMode();
             return typeArguments(t, false);
         } else {
@@ -2109,11 +2126,11 @@ List<JCExpression> typeArgumentsOpt() {
 
     List<JCExpression> typeArgumentsOpt(int useMode) {
         if (token.kind == LT) {
-            if ((mode & useMode) == 0 ||
-                (mode & NOPARAMS) != 0) {
+            if (!isMode(useMode) ||
+                isMode(NOPARAMS)) {
                 illegal();
             }
-            mode = useMode;
+            setMode(useMode);
             return typeArguments(false);
         }
         return null;
@@ -2128,15 +2145,15 @@ List<JCExpression> typeArguments(boolean diamondAllowed) {
         if (token.kind == LT) {
             nextToken();
             if (token.kind == GT && diamondAllowed) {
-                mode |= DIAMOND;
+                setMode(mode | DIAMOND);
                 nextToken();
                 return List.nil();
             } else {
                 ListBuffer<JCExpression> args = new ListBuffer<>();
-                args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
+                args.append(!isMode(EXPR) ? typeArgument() : parseType());
                 while (token.kind == COMMA) {
                     nextToken();
-                    args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
+                    args.append(!isMode(EXPR) ? typeArgument() : parseType());
                 }
                 switch (token.kind) {
 
@@ -2257,7 +2274,7 @@ private JCExpression bracketsOptCont(JCExpression t, int pos,
      *  BracketsSuffixType =
      */
     JCExpression bracketsSuffix(JCExpression t) {
-        if ((mode & EXPR) != 0 && token.kind == DOT) {
+        if (isMode(EXPR) && token.kind == DOT) {
             selectExprMode();
             int pos = token.pos;
             nextToken();
@@ -2281,7 +2298,7 @@ JCExpression bracketsSuffix(JCExpression t) {
                     syntaxError(token.pos, Errors.NoAnnotationsOnDotClass);
                 t = toP(F.at(pos).Select(t, names._class));
             }
-        } else if ((mode & TYPE) != 0) {
+        } else if (isMode(TYPE)) {
             if (token.kind != COLCOL) {
                 selectTypeMode();
             }
@@ -2340,14 +2357,14 @@ JCExpression creator(int newpos, List<JCExpression> typeArgs) {
         }
         JCExpression t = qualident(true);
 
-        int oldmode = mode;
+        int prevmode = mode;
         selectTypeMode();
         boolean diamondFound = false;
         int lastTypeargsPos = -1;
         if (token.kind == LT) {
             lastTypeargsPos = token.pos;
             t = typeArguments(t, true);
-            diamondFound = (mode & DIAMOND) != 0;
+            diamondFound = isMode(DIAMOND);
         }
         while (token.kind == DOT) {
             if (diamondFound) {
@@ -2366,10 +2383,10 @@ JCExpression creator(int newpos, List<JCExpression> typeArgs) {
             if (token.kind == LT) {
                 lastTypeargsPos = token.pos;
                 t = typeArguments(t, true);
-                diamondFound = (mode & DIAMOND) != 0;
+                diamondFound = isMode(DIAMOND);
             }
         }
-        mode = oldmode;
+        setMode(prevmode);
         if (token.kind == LBRACKET || token.kind == MONKEYS_AT) {
             // handle type annotations for non primitive arrays
             if (newAnnotations.nonEmpty()) {
@@ -2421,9 +2438,9 @@ JCExpression innerCreator(int newpos, List<JCExpression> typeArgs, JCExpression
         }
 
         if (token.kind == LT) {
-            int oldmode = mode;
+            int prevmode = mode;
             t = typeArguments(t, true);
-            mode = oldmode;
+            setMode(prevmode);
         }
         return classCreatorRest(newpos, encl, typeArgs, t);
     }
@@ -2756,7 +2773,7 @@ List<JCStatement> blockStatement() {
                 nextToken();
                 JCStatement stat = parseStatementAsBlock();
                 return List.of(F.at(pos).Labelled(prevToken.name(), stat));
-            } else if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.test(token.kind)) {
+            } else if (wasTypeMode() && LAX_IDENTIFIER.test(token.kind)) {
                 pos = token.pos;
                 JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
                 F.at(pos);
@@ -3318,9 +3335,9 @@ List<JCStatement> forInit() {
             return variableDeclarators(optFinal(0), parseType(true), stats, true).toList();
         } else {
             JCExpression t = term(EXPR | TYPE);
-            if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.test(token.kind)) {
+            if (wasTypeMode() && LAX_IDENTIFIER.test(token.kind)) {
                 return variableDeclarators(modifiersOpt(), t, stats, true).toList();
-            } else if ((lastmode & TYPE) != 0 && token.kind == COLON) {
+            } else if (wasTypeMode() && token.kind == COLON) {
                 log.error(DiagnosticFlag.SYNTAX, pos, Errors.BadInitializer("for-loop"));
                 return List.of((JCStatement)F.at(pos).VarDef(modifiersOpt(), names.error, t, null));
             } else {
@@ -3350,8 +3367,8 @@ protected List<JCAnnotation> annotationsOpt(Tag kind) {
             nextToken();
             buf.append(annotation(pos, kind));
         }
-        lastmode = mode;
-        mode = prevmode;
+        setLastMode(mode);
+        setMode(prevmode);
         List<JCAnnotation> annotations = buf.toList();
 
         return annotations;
@@ -3706,6 +3723,11 @@ JCVariableDecl variableDeclaratorId(JCModifiers mods, JCExpression type, boolean
                 JCExpression pn = qualident(false);
                 if (pn.hasTag(Tag.IDENT) && ((JCIdent)pn).name != names._this) {
                     name = ((JCIdent)pn).name;
+                } else if (lambdaParameter && type == null) {
+                    // we have a lambda parameter that is not an identifier this is a syntax error
+                    type = pn;
+                    name = names.empty;
+                    reportSyntaxError(pos, Errors.Expected(IDENTIFIER));
                 } else {
                     if (allowThisIdent) {
                         if ((mods.flags & Flags.VARARGS) != 0) {
@@ -3773,7 +3795,7 @@ protected JCTree resource() {
             return variableDeclaratorRest(token.pos, mods, t, ident(), true, null, true, false);
         }
         JCExpression t = term(EXPR | TYPE);
-        if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.test(token.kind)) {
+        if (wasTypeMode() && LAX_IDENTIFIER.test(token.kind)) {
             JCModifiers mods = F.Modifiers(0);
             return variableDeclaratorRest(token.pos, mods, t, ident(), true, null, true, false);
         } else {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
index 95cb6e0fa3c..ceab2e08f0c 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -168,6 +168,11 @@ public int getEndPosition() {
                 return err.pos + err.body.length();
             }
 
+            case ESCAPE -> {
+                DCEscape esc = (DCEscape) this;
+                return esc.pos + 2;
+            }
+
             case IDENTIFIER -> {
                 DCIdentifier ident = (DCIdentifier) this;
                 return ident.pos + ident.name.length();
@@ -641,7 +646,29 @@ public DCErroneous setPrefPos(int prefPos) {
             this.prefPos = prefPos;
             return this;
         }
+    }
 
+    public static class DCEscape extends DCTree implements EscapeTree {
+        public final char ch;
+
+        DCEscape(char ch) {
+            this.ch = ch;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public Kind getKind() {
+            return Kind.ESCAPE;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitEscape(this, d);
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public String getBody() {
+            return String.valueOf(ch);
+        }
     }
 
     public static class DCHidden extends DCBlockTag implements HiddenTree {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java
index e7c65ffac4e..8fd6e0541ae 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -245,6 +245,17 @@ public Void visitErroneous(ErroneousTree node, Void p) {
         return null;
     }
 
+    @Override @DefinedBy(Api.COMPILER_TREE)
+    public Void visitEscape(EscapeTree node, Void p) {
+        try {
+            out.write("@");
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
     @Override @DefinedBy(Api.COMPILER_TREE)
     public Void visitHidden(HiddenTree node, Void p) {
         try {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java
index cd6fdad70e6..81b9ac992c7 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@
 import com.sun.tools.javac.tree.DCTree.DCEndElement;
 import com.sun.tools.javac.tree.DCTree.DCEntity;
 import com.sun.tools.javac.tree.DCTree.DCErroneous;
+import com.sun.tools.javac.tree.DCTree.DCEscape;
 import com.sun.tools.javac.tree.DCTree.DCHidden;
 import com.sun.tools.javac.tree.DCTree.DCIdentifier;
 import com.sun.tools.javac.tree.DCTree.DCIndex;
@@ -276,6 +277,13 @@ public DCErroneous newErroneousTree(String text, Diagnostic<JavaFileObject> diag
         return tree;
     }
 
+    @Override @DefinedBy(Api.COMPILER_TREE)
+    public DCEscape newEscapeTree(char ch) {
+        DCEscape tree = new DCEscape(ch);
+        tree.pos = pos;
+        return tree;
+    }
+
     @Override @DefinedBy(Api.COMPILER_TREE)
     public DCThrows newExceptionTree(ReferenceTree name, List<? extends DocTree> description) {
         // TODO: verify the reference is just to a type (not a field or method)
diff --git a/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocFormatter.java b/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocFormatter.java
index afc10d0c988..07d3ccae510 100644
--- a/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocFormatter.java
+++ b/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocFormatter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,7 @@
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.EndElementTree;
 import com.sun.source.doctree.EntityTree;
+import com.sun.source.doctree.EscapeTree;
 import com.sun.source.doctree.InlineTagTree;
 import com.sun.source.doctree.LinkTree;
 import com.sun.source.doctree.LiteralTree;
@@ -218,6 +219,12 @@ public Object visitText(TextTree node, Object p) {
             return null;
         }
 
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public Object visitEscape(EscapeTree node, Object p) {
+            result.append(node.getBody());
+            return null;
+        }
+
         @Override @DefinedBy(Api.COMPILER_TREE)
         public Object visitLink(LinkTree node, Object p) {
             if (!node.getLabel().isEmpty()) {
diff --git a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp
index e02f5e3e419..8580d1e7cf7 100644
--- a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp
+++ b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp
@@ -1223,17 +1223,17 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_CSignature_verifyCngSignedHa
 
 #define DUMP_PROP(p) \
     if (::NCryptGetProperty(hKey, p, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \
-        sprintf(header, "%s %ls", #p, p); \
+        snprintf(header, sizeof(header), "%s %ls", #p, p); \
         dump(header, buffer, len); \
     }
 
 #define EXPORT_BLOB(p) \
     desc.cBuffers = 0; \
     if (::NCryptExportKey(hKey, NULL, p, &desc, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \
-        sprintf(header, "%s %ls (%ld)", #p, p, desc.cBuffers); \
+        snprintf(header, sizeof(header), "%s %ls (%ld)", #p, p, desc.cBuffers); \
         dump(header, buffer, len); \
         for (int i = 0; i < (int)desc.cBuffers; i++) { \
-            sprintf(header, "desc %ld", desc.pBuffers[i].BufferType); \
+            snprintf(header, sizeof(header), "desc %ld", desc.pBuffers[i].BufferType); \
             dump(header, (PBYTE)desc.pBuffers[i].pvBuffer, desc.pBuffers[i].cbBuffer); \
         } \
     }
@@ -1310,7 +1310,7 @@ void showProperty(NCRYPT_HANDLE hKey) {
     bbd.pBuffers = &bb;
     if(::NCryptExportKey(hKey, NULL, NCRYPT_PKCS8_PRIVATE_KEY_BLOB, NULL,
             (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) {
-        sprintf(header, "NCRYPT_PKCS8_PRIVATE_KEY_BLOB %ls", NCRYPT_PKCS8_PRIVATE_KEY_BLOB);
+        snprintf(header, sizeof(header), "NCRYPT_PKCS8_PRIVATE_KEY_BLOB %ls", NCRYPT_PKCS8_PRIVATE_KEY_BLOB);
         dump(header, buffer, len);
     }
     EXPORT_BLOB(NCRYPT_PROTECTED_KEY_BLOB);
@@ -1445,7 +1445,7 @@ JNIEXPORT jstring JNICALL Java_sun_security_mscapi_CKey_getKeyType
 
         } else {
             char buffer[64];
-            if (sprintf(buffer, "%lu", dwAlgId)) {
+            if (snprintf(buffer, sizeof(buffer), "%lu", dwAlgId)) {
                 return env->NewStringUTF(buffer);
             }
         }
diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
index 76153176595..530ead86c94 100644
--- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
+++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -410,7 +410,7 @@ private void handleEvent (Event r) {
                         }
                     }
                     responseCompleted (c);
-                    if (t.close || idleConnections.size() >= MAX_IDLE_CONNECTIONS) {
+                    if (t.close) {
                         c.close();
                         allConnections.remove (c);
                     } else {
@@ -961,9 +961,24 @@ void requestStarted (HttpConnection c) {
     }
 
     void markIdle(HttpConnection c) {
-        c.idleStartTime = System.currentTimeMillis();
-        c.setState(State.IDLE);
-        idleConnections.add(c);
+        boolean close = false;
+
+        synchronized(idleConnections) {
+            if (idleConnections.size() >= MAX_IDLE_CONNECTIONS) {
+                // closing the connection here could block
+                // instead set boolean and close outside the synchronized block
+                close = true;
+            } else {
+                c.idleStartTime = System.currentTimeMillis();
+                c.setState(State.IDLE);
+                idleConnections.add(c);
+            }
+        }
+
+        if (close) {
+            c.close();
+            allConnections.remove(c);
+        }
     }
 
     void markNewlyAccepted(HttpConnection c) {
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java
index 051e573939e..38be02fe70e 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -195,24 +195,51 @@ static long toLongHelper(boolean[] bits) {
         return res;
     }
 
-    @Override
+    /*package-private*/
     @ForceInline
-    public VectorMask<E> indexInRange(int offset, int limit) {
+    VectorMask<E> indexPartiallyInRange(int offset, int limit) {
         int vlength = length();
         Vector<E> iota = vectorSpecies().zero().addIndex(1);
         VectorMask<E> badMask = checkIndex0(offset, limit, iota, vlength);
-        return this.andNot(badMask);
+        return badMask.not();
     }
 
-    @Override
+    /*package-private*/
     @ForceInline
-    public VectorMask<E> indexInRange(long offset, long limit) {
+    VectorMask<E> indexPartiallyInRange(long offset, long limit) {
         int vlength = length();
         Vector<E> iota = vectorSpecies().zero().addIndex(1);
         VectorMask<E> badMask = checkIndex0(offset, limit, iota, vlength);
-        return this.andNot(badMask);
+        return badMask.not();
+    }
+
+    @Override
+    @ForceInline
+    public VectorMask<E> indexInRange(int offset, int limit) {
+        if (offset < 0) {
+            return this.and(indexPartiallyInRange(offset, limit));
+        } else if (offset >= limit) {
+            return vectorSpecies().maskAll(false);
+        } else if (limit - offset >= length()) {
+            return this;
+        }
+        return this.and(indexPartiallyInUpperRange(offset, limit));
+    }
+
+    @ForceInline
+    public VectorMask<E> indexInRange(long offset, long limit) {
+        if (offset < 0) {
+            return this.and(indexPartiallyInRange(offset, limit));
+        } else if (offset >= limit) {
+            return vectorSpecies().maskAll(false);
+        } else if (limit - offset >= length()) {
+            return this;
+        }
+        return this.and(indexPartiallyInUpperRange(offset, limit));
     }
 
+    abstract VectorMask<E> indexPartiallyInUpperRange(long offset, long limit);
+
     /*package-private*/
     @ForceInline
     AbstractVector<E>
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java
index 059adb451b6..12a6c80f21e 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -685,6 +685,15 @@ public Byte128Mask eq(VectorMask<Byte> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Byte128Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Byte128Mask) VectorSupport.indexPartiallyInUpperRange(
+                Byte128Mask.class, byte.class, VLENGTH, offset, limit,
+                (o, l) -> (Byte128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java
index e70a4bebfa1..e2050716803 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -717,6 +717,15 @@ public Byte256Mask eq(VectorMask<Byte> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Byte256Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Byte256Mask) VectorSupport.indexPartiallyInUpperRange(
+                Byte256Mask.class, byte.class, VLENGTH, offset, limit,
+                (o, l) -> (Byte256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java
index b30955a91b0..a8a5875ea7b 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -781,6 +781,15 @@ public Byte512Mask eq(VectorMask<Byte> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Byte512Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Byte512Mask) VectorSupport.indexPartiallyInUpperRange(
+                Byte512Mask.class, byte.class, VLENGTH, offset, limit,
+                (o, l) -> (Byte512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java
index 56824f34871..db3e9252944 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -669,6 +669,15 @@ public Byte64Mask eq(VectorMask<Byte> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Byte64Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Byte64Mask) VectorSupport.indexPartiallyInUpperRange(
+                Byte64Mask.class, byte.class, VLENGTH, offset, limit,
+                (o, l) -> (Byte64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java
index 984762ed7c8..0afdeab13dc 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -655,6 +655,15 @@ public ByteMaxMask eq(VectorMask<Byte> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        ByteMaxMask indexPartiallyInUpperRange(long offset, long limit) {
+            return (ByteMaxMask) VectorSupport.indexPartiallyInUpperRange(
+                ByteMaxMask.class, byte.class, VLENGTH, offset, limit,
+                (o, l) -> (ByteMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java
index cf774e3678f..2c5706fe2f0 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -646,6 +646,15 @@ public Double128Mask eq(VectorMask<Double> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Double128Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Double128Mask) VectorSupport.indexPartiallyInUpperRange(
+                Double128Mask.class, double.class, VLENGTH, offset, limit,
+                (o, l) -> (Double128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java
index 25738ae7ae7..3f4ee1bdc04 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -650,6 +650,15 @@ public Double256Mask eq(VectorMask<Double> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Double256Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Double256Mask) VectorSupport.indexPartiallyInUpperRange(
+                Double256Mask.class, double.class, VLENGTH, offset, limit,
+                (o, l) -> (Double256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java
index f4e999c808c..3f8211eef27 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -658,6 +658,15 @@ public Double512Mask eq(VectorMask<Double> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Double512Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Double512Mask) VectorSupport.indexPartiallyInUpperRange(
+                Double512Mask.class, double.class, VLENGTH, offset, limit,
+                (o, l) -> (Double512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java
index 510d739d976..9900c97f912 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -644,6 +644,15 @@ public Double64Mask eq(VectorMask<Double> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Double64Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Double64Mask) VectorSupport.indexPartiallyInUpperRange(
+                Double64Mask.class, double.class, VLENGTH, offset, limit,
+                (o, l) -> (Double64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java
index 877b14e24ba..32ff760fb36 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -643,6 +643,15 @@ public DoubleMaxMask eq(VectorMask<Double> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        DoubleMaxMask indexPartiallyInUpperRange(long offset, long limit) {
+            return (DoubleMaxMask) VectorSupport.indexPartiallyInUpperRange(
+                DoubleMaxMask.class, double.class, VLENGTH, offset, limit,
+                (o, l) -> (DoubleMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java
index 972802387f3..5414be75607 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -650,6 +650,15 @@ public Float128Mask eq(VectorMask<Float> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Float128Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Float128Mask) VectorSupport.indexPartiallyInUpperRange(
+                Float128Mask.class, float.class, VLENGTH, offset, limit,
+                (o, l) -> (Float128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java
index 79326ac6f9f..9194fbcde0e 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -658,6 +658,15 @@ public Float256Mask eq(VectorMask<Float> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Float256Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Float256Mask) VectorSupport.indexPartiallyInUpperRange(
+                Float256Mask.class, float.class, VLENGTH, offset, limit,
+                (o, l) -> (Float256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java
index 7e0489b9e6a..2e43f153b0c 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -674,6 +674,15 @@ public Float512Mask eq(VectorMask<Float> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Float512Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Float512Mask) VectorSupport.indexPartiallyInUpperRange(
+                Float512Mask.class, float.class, VLENGTH, offset, limit,
+                (o, l) -> (Float512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java
index c82adda2632..ccd75e18e06 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -646,6 +646,15 @@ public Float64Mask eq(VectorMask<Float> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Float64Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Float64Mask) VectorSupport.indexPartiallyInUpperRange(
+                Float64Mask.class, float.class, VLENGTH, offset, limit,
+                (o, l) -> (Float64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java
index 4d2c1c17876..e5b4651531b 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -643,6 +643,15 @@ public FloatMaxMask eq(VectorMask<Float> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        FloatMaxMask indexPartiallyInUpperRange(long offset, long limit) {
+            return (FloatMaxMask) VectorSupport.indexPartiallyInUpperRange(
+                FloatMaxMask.class, float.class, VLENGTH, offset, limit,
+                (o, l) -> (FloatMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java
index b51bd2e25c5..158686576f5 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -661,6 +661,15 @@ public Int128Mask eq(VectorMask<Integer> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Int128Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Int128Mask) VectorSupport.indexPartiallyInUpperRange(
+                Int128Mask.class, int.class, VLENGTH, offset, limit,
+                (o, l) -> (Int128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java
index fe1471d8d32..4f251e43f1f 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -669,6 +669,15 @@ public Int256Mask eq(VectorMask<Integer> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Int256Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Int256Mask) VectorSupport.indexPartiallyInUpperRange(
+                Int256Mask.class, int.class, VLENGTH, offset, limit,
+                (o, l) -> (Int256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java
index 675aab8ef3a..4867c377a8a 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -685,6 +685,15 @@ public Int512Mask eq(VectorMask<Integer> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Int512Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Int512Mask) VectorSupport.indexPartiallyInUpperRange(
+                Int512Mask.class, int.class, VLENGTH, offset, limit,
+                (o, l) -> (Int512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java
index e876cd83576..2f44bfecf8f 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -657,6 +657,15 @@ public Int64Mask eq(VectorMask<Integer> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Int64Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Int64Mask) VectorSupport.indexPartiallyInUpperRange(
+                Int64Mask.class, int.class, VLENGTH, offset, limit,
+                (o, l) -> (Int64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java
index 2316da250d4..b79e73f52d6 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -655,6 +655,15 @@ public IntMaxMask eq(VectorMask<Integer> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        IntMaxMask indexPartiallyInUpperRange(long offset, long limit) {
+            return (IntMaxMask) VectorSupport.indexPartiallyInUpperRange(
+                IntMaxMask.class, int.class, VLENGTH, offset, limit,
+                (o, l) -> (IntMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java
index ff08bd64b39..9b024f6e55c 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -647,6 +647,15 @@ public Long128Mask eq(VectorMask<Long> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Long128Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Long128Mask) VectorSupport.indexPartiallyInUpperRange(
+                Long128Mask.class, long.class, VLENGTH, offset, limit,
+                (o, l) -> (Long128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java
index ed62368f40a..8a1844af370 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -651,6 +651,15 @@ public Long256Mask eq(VectorMask<Long> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Long256Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Long256Mask) VectorSupport.indexPartiallyInUpperRange(
+                Long256Mask.class, long.class, VLENGTH, offset, limit,
+                (o, l) -> (Long256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java
index 290369a6874..baec813f58e 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -659,6 +659,15 @@ public Long512Mask eq(VectorMask<Long> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Long512Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Long512Mask) VectorSupport.indexPartiallyInUpperRange(
+                Long512Mask.class, long.class, VLENGTH, offset, limit,
+                (o, l) -> (Long512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java
index dfb438bf6ee..1d4110050f2 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -645,6 +645,15 @@ public Long64Mask eq(VectorMask<Long> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Long64Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Long64Mask) VectorSupport.indexPartiallyInUpperRange(
+                Long64Mask.class, long.class, VLENGTH, offset, limit,
+                (o, l) -> (Long64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java
index abcc2294d12..ecc2b393061 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -645,6 +645,15 @@ public LongMaxMask eq(VectorMask<Long> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        LongMaxMask indexPartiallyInUpperRange(long offset, long limit) {
+            return (LongMaxMask) VectorSupport.indexPartiallyInUpperRange(
+                LongMaxMask.class, long.class, VLENGTH, offset, limit,
+                (o, l) -> (LongMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java
index 0cc80590473..1f587ca54a5 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -669,6 +669,15 @@ public Short128Mask eq(VectorMask<Short> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Short128Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Short128Mask) VectorSupport.indexPartiallyInUpperRange(
+                Short128Mask.class, short.class, VLENGTH, offset, limit,
+                (o, l) -> (Short128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java
index b39b7c509c1..5e259b70b59 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -685,6 +685,15 @@ public Short256Mask eq(VectorMask<Short> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Short256Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Short256Mask) VectorSupport.indexPartiallyInUpperRange(
+                Short256Mask.class, short.class, VLENGTH, offset, limit,
+                (o, l) -> (Short256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java
index c7a07c4d283..a6cbfb4f8e4 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -717,6 +717,15 @@ public Short512Mask eq(VectorMask<Short> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Short512Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Short512Mask) VectorSupport.indexPartiallyInUpperRange(
+                Short512Mask.class, short.class, VLENGTH, offset, limit,
+                (o, l) -> (Short512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java
index 4f0d8796482..b2a2ec11952 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -661,6 +661,15 @@ public Short64Mask eq(VectorMask<Short> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        Short64Mask indexPartiallyInUpperRange(long offset, long limit) {
+            return (Short64Mask) VectorSupport.indexPartiallyInUpperRange(
+                Short64Mask.class, short.class, VLENGTH, offset, limit,
+                (o, l) -> (Short64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java
index 6724ae88682..eaf99f61896 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -655,6 +655,15 @@ public ShortMaxMask eq(VectorMask<Short> mask) {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        ShortMaxMask indexPartiallyInUpperRange(long offset, long limit) {
+            return (ShortMaxMask) VectorSupport.indexPartiallyInUpperRange(
+                ShortMaxMask.class, short.class, VLENGTH, offset, limit,
+                (o, l) -> (ShortMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template
index 69ff064ec53..14ba8d34161 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -928,6 +928,15 @@ final class $vectortype$ extends $abstractvectortype$ {
             return xor(m.not());
         }
 
+        @Override
+        @ForceInline
+        /*package-private*/
+        $masktype$ indexPartiallyInUpperRange(long offset, long limit) {
+            return ($masktype$) VectorSupport.indexPartiallyInUpperRange(
+                $masktype$.class, $type$.class, VLENGTH, offset, limit,
+                (o, l) -> ($masktype$) TRUE_MASK.indexPartiallyInRange(o, l));
+        }
+
         // Unary operations
 
         @Override
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
index 4c782d883a1..0850d3625d6 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
@@ -577,6 +577,9 @@ public Type[] getGenericParameterTypes() {
 
     @Override
     public boolean canBeInlined() {
+        if (isForceInline()) {
+            return true;
+        }
         if (hasNeverInlineDirective()) {
             return false;
         }
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
index 11818f89424..29dd88e31ec 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
@@ -67,6 +67,7 @@
 import com.sun.source.doctree.EndElementTree;
 import com.sun.source.doctree.EntityTree;
 import com.sun.source.doctree.ErroneousTree;
+import com.sun.source.doctree.EscapeTree;
 import com.sun.source.doctree.IndexTree;
 import com.sun.source.doctree.InheritDocTree;
 import com.sun.source.doctree.LinkTree;
@@ -1338,6 +1339,12 @@ public Boolean visitErroneous(ErroneousTree node, Content content) {
                     return false;
                 }
 
+                @Override
+                public Boolean visitEscape(EscapeTree node, Content content) {
+                    result.add(node.getBody());
+                    return false;
+                }
+
                 @Override
                 public Boolean visitInheritDoc(InheritDocTree node, Content content) {
                     Content output = getInlineTagOutput(element, node, context);
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java
index 7007a160f9d..008ce5ab80d 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import com.sun.source.doctree.DeprecatedTree;
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.EscapeTree;
 import com.sun.source.doctree.IdentifierTree;
 import com.sun.source.doctree.InlineTagTree;
 import com.sun.source.doctree.LinkTree;
@@ -386,6 +387,11 @@ public List<? extends DocTree> visitDocComment(DocCommentTree node, Void p) {
                 return node.getBody();
             }
 
+            @Override
+            public List<? extends DocTree> visitEscape(EscapeTree node, Void p) {
+                return asList(node.getBody());
+            }
+
             @Override
             public List<? extends DocTree> visitLiteral(LiteralTree node, Void p) {
                 return asList(node.getBody().getBody());
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
index 9bc64af8fb0..e0c83f01d9c 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
@@ -1093,22 +1093,8 @@ public TypeElement getFirstVisibleSuperClassAsTypeElement(TypeElement te) {
      *          be found.
      */
     public TypeMirror getFirstVisibleSuperClass(TypeMirror type) {
-        return getFirstVisibleSuperClass(asTypeElement(type));
-    }
-
-
-    /**
-     * Given a class, return the closest visible superclass.
-     *
-     * @param te the TypeElement to be interrogated
-     * @return the closest visible superclass.  Return null if it cannot
-     *         be found.
-     */
-    public TypeMirror getFirstVisibleSuperClass(TypeElement te) {
-        TypeMirror superType = te.getSuperclass();
-        if (isNoType(superType)) {
-            superType = getObjectType();
-        }
+        List<? extends TypeMirror> superTypes = typeUtils.directSupertypes(type);
+        TypeMirror superType = superTypes.isEmpty() ? getObjectType() : superTypes.get(0);
         TypeElement superClass = asTypeElement(superType);
         // skip "hidden" classes
         while ((superClass != null && hasHiddenTag(superClass))
@@ -1122,12 +1108,24 @@ public TypeMirror getFirstVisibleSuperClass(TypeElement te) {
             superType = supersuperType;
             superClass = supersuperClass;
         }
-        if (typeUtils.isSameType(te.asType(), superType)) {
+        if (typeUtils.isSameType(type, superType)) {
             return null;
         }
         return superType;
     }
 
+
+    /**
+     * Given a class, return the closest visible superclass.
+     *
+     * @param te the TypeElement to be interrogated
+     * @return the closest visible superclass.  Return null if it cannot
+     *         be found.
+     */
+    public TypeMirror getFirstVisibleSuperClass(TypeElement te) {
+        return getFirstVisibleSuperClass(te.asType());
+    }
+
     /**
      * Returns the name of the kind of a type element (Class, Interface, etc.).
      *
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java
index fa9d3029673..061b05db6a9 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,6 +65,7 @@
 import com.sun.source.doctree.EndElementTree;
 import com.sun.source.doctree.EntityTree;
 import com.sun.source.doctree.ErroneousTree;
+import com.sun.source.doctree.EscapeTree;
 import com.sun.source.doctree.IdentifierTree;
 import com.sun.source.doctree.IndexTree;
 import com.sun.source.doctree.InheritDocTree;
@@ -348,6 +349,7 @@ public Void visitText(TextTree tree, Void ignore) {
 
     @Override @DefinedBy(Api.COMPILER_TREE)
     public Void visitEntity(EntityTree tree, Void ignore) {
+        hasNonWhitespaceText = true;
         checkAllowsText(tree);
         markEnclosingTag(Flag.HAS_TEXT);
         String s = env.trees.getCharacters(tree);
@@ -358,6 +360,14 @@ public Void visitEntity(EntityTree tree, Void ignore) {
 
     }
 
+    @Override @DefinedBy(Api.COMPILER_TREE)
+    public Void visitEscape(EscapeTree tree, Void ignore) {
+        hasNonWhitespaceText = true;
+        checkAllowsText(tree);
+        markEnclosingTag(Flag.HAS_TEXT);
+        return null;
+    }
+
     void checkAllowsText(DocTree tree) {
         TagStackItem top = tagStack.peek();
         if (top != null
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java
index 05217917199..1e21566c6fc 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.StringJoiner;
 
 final class ArgumentParser {
     private final Map<String, Object> options = new HashMap<>();
@@ -42,6 +43,8 @@ final class ArgumentParser {
     private final Argument[] arguments;
     private int position;
 
+    private final List<String> conflictedOptions = new ArrayList<>();
+
     ArgumentParser(Argument[] arguments, String text, char delimiter) {
         this.text = text;
         this.delimiter = delimiter;
@@ -64,10 +67,36 @@ public Map<String, Object> parse() {
             addOption(key, value);
             eatDelimiter();
         }
+        checkConflict();
         checkMandatory();
         return options;
     }
 
+    protected void checkConflict() {
+        if (conflictedOptions.isEmpty()) {
+            return;
+        }
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("Option");
+
+        // If multiple options conflict, the following blocks are executed
+        if (conflictedOptions.size() > 1) {
+            sb.append("s ");
+            StringJoiner sj = new StringJoiner(", ");
+            while (conflictedOptions.size() > 1) {
+                sj.add(conflictedOptions.remove(0));
+            }
+            sb.append(sj);
+            sb.append(" and");
+        }
+
+        sb.append(" ");
+        sb.append(conflictedOptions.remove(0));
+        sb.append(" can only be specified once.");
+        throw new IllegalArgumentException(sb.toString());
+    }
+
     private void checkMandatory() {
         for (Argument arg : arguments) {
             if (!options.containsKey(arg.name())) {
@@ -94,9 +123,12 @@ private void addOption(String key, String value) {
                     }
                 } else {
                     if (options.containsKey(key)) {
-                        throw new IllegalArgumentException("Duplicates in diagnostic command arguments");
+                        if (!conflictedOptions.contains(key)) {
+                            conflictedOptions.add(key);
+                        }
+                    } else {
+                        options.put(key, v);
                     }
-                    options.put(key, v);
                 }
             }
         }
diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PerfectHashBuilder.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PerfectHashBuilder.java
index 2ffef27e64d..11b588bbade 100644
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PerfectHashBuilder.java
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PerfectHashBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -246,7 +246,7 @@ public void generate() {
                 if (bucket.getSize() != 1) {
                     // Attempt to pack entries until no collisions occur.
                     if (!collidedEntries(bucket, count)) {
-                        // Failed to pack. Meed to grow table.
+                        // Failed to pack. Need to grow table.
                         redo = true;
                         break;
                     }
diff --git a/src/jdk.management/share/native/libmanagement_ext/management_ext.c b/src/jdk.management/share/native/libmanagement_ext/management_ext.c
index 02285521042..726f1e7b5b9 100644
--- a/src/jdk.management/share/native/libmanagement_ext/management_ext.c
+++ b/src/jdk.management/share/native/libmanagement_ext/management_ext.c
@@ -57,6 +57,6 @@ JNIEXPORT jint JNICALL
 void throw_internal_error(JNIEnv* env, const char* msg) {
     char errmsg[128];
 
-    sprintf(errmsg, "errno: %d error: %s\n", errno, msg);
+    snprintf(errmsg, sizeof(errmsg), "errno: %d error: %s\n", errno, msg);
     JNU_ThrowInternalError(env, errmsg);
 }
diff --git a/test/hotspot/gtest/classfile/test_placeholders.cpp b/test/hotspot/gtest/classfile/test_placeholders.cpp
new file mode 100644
index 00000000000..9fa06d49f73
--- /dev/null
+++ b/test/hotspot/gtest/classfile/test_placeholders.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "precompiled.hpp"
+#include "classfile/classLoaderData.hpp"
+#include "classfile/placeholders.hpp"
+#include "classfile/symbolTable.hpp"
+#include "oops/symbol.hpp"
+#include "runtime/interfaceSupport.inline.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "threadHelper.inline.hpp"
+#include "unittest.hpp"
+
+// Test that multiple threads calling handle_parallel_super_load don't underflow supername refcount.
+TEST_VM(PlaceholderTable, supername) {
+  JavaThread* THREAD = JavaThread::current();
+  JavaThread* T2 = THREAD;
+  // the thread should be in vm to use locks
+  ThreadInVMfromNative tivfn(THREAD);
+
+  // Assert messages assume these symbols are unique, and the refcounts start at one.
+  TempNewSymbol A = SymbolTable::new_symbol("abc2_8_2023_class");
+  TempNewSymbol D = SymbolTable::new_symbol("def2_8_2023_class");
+  Symbol* super = SymbolTable::new_symbol("super2_8_2023_supername");
+  TempNewSymbol interf = SymbolTable::new_symbol("interface2_8_2023_supername");
+
+  ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
+
+  {
+    MutexLocker ml(THREAD, SystemDictionary_lock);
+
+    PlaceholderTable::classloadAction super_action = PlaceholderTable::LOAD_SUPER;
+    PlaceholderTable::classloadAction define_action = PlaceholderTable::DEFINE_CLASS;
+
+    // DefineClass A and D
+    PlaceholderTable::find_and_add(A, loader_data, define_action, nullptr, THREAD);
+    PlaceholderTable::find_and_add(D, loader_data, define_action, nullptr, T2);
+
+    // Load interfaces first to get supername replaced
+    PlaceholderTable::find_and_add(A, loader_data, super_action, interf, THREAD);
+    PlaceholderTable::find_and_remove(A, loader_data, super_action, THREAD);
+
+    PlaceholderTable::find_and_add(D, loader_data, super_action, interf, T2);
+    PlaceholderTable::find_and_remove(D, loader_data, super_action, T2);
+
+    ASSERT_EQ(interf->refcount(), 1) << "supername is replaced with null";
+
+    // Add placeholder to the table for loading A and super, and D also loading super
+    PlaceholderTable::find_and_add(A, loader_data, super_action, super, THREAD);
+    PlaceholderTable::find_and_add(D, loader_data, super_action, super, T2);
+
+    // Another thread comes in and finds A loading Super
+    PlaceholderEntry* placeholder = PlaceholderTable::get_entry(A, loader_data);
+    SymbolHandle supername = placeholder->supername();
+
+    // Other thread is done before handle_parallel_super_load
+    PlaceholderTable::find_and_remove(A, loader_data, super_action, THREAD);
+
+    // if THREAD drops reference to supername (loading failed or class unloaded), we're left with
+    // a supername without refcount
+    super->decrement_refcount();
+
+    // handle_parallel_super_load (same thread doesn't assert)
+    PlaceholderTable::find_and_add(A, loader_data, super_action, supername, T2);
+
+    // Refcount should be 3: one in table for class A, one in table for class D
+    // and one locally with SymbolHandle keeping it alive
+    placeholder = PlaceholderTable::get_entry(A, loader_data);
+    supername = placeholder->supername();
+    EXPECT_EQ(super->refcount(), 3) << "super class name refcount should be 3";
+
+    // Second thread's done too
+    PlaceholderTable::find_and_remove(D, loader_data, super_action, T2);
+
+    // Other threads are done.
+    PlaceholderTable::find_and_remove(A, loader_data, super_action, THREAD);
+
+    // Remove A and D define_class placeholder
+    PlaceholderTable::find_and_remove(A, loader_data, define_action, THREAD);
+    PlaceholderTable::find_and_remove(D, loader_data, define_action, T2);
+
+    placeholder = PlaceholderTable::get_entry(A, loader_data);
+    ASSERT_TRUE(placeholder == nullptr) << "placeholder should be removed";
+    placeholder = PlaceholderTable::get_entry(D, loader_data);
+    ASSERT_TRUE(placeholder == nullptr) << "placeholder should be removed";
+
+    EXPECT_EQ(super->refcount(), 1) << "super class name refcount should be 1 - kept alive in this scope";
+  }
+
+  EXPECT_EQ(A->refcount(), 1) << "first lass name refcount should be 1";
+  EXPECT_EQ(D->refcount(), 1) << "second class name refcount should be 1";
+  EXPECT_EQ(super->refcount(), 0) << "super class name refcount should be 0 - was unloaded.";
+}
diff --git a/test/hotspot/jtreg/ProblemList-svc-vthread.txt b/test/hotspot/jtreg/ProblemList-svc-vthread.txt
index 94a3c28f660..42eaf98afc5 100644
--- a/test/hotspot/jtreg/ProblemList-svc-vthread.txt
+++ b/test/hotspot/jtreg/ProblemList-svc-vthread.txt
@@ -82,8 +82,6 @@ vmTestbase/nsk/jdb/repeat/repeat001/repeat001.java  8300707 generic-all
 ####
 ## NSK JDI tests failing with wrapper
 
-vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011/TestDescription.java 8282379 generic-all
-
 ####
 ## The test expects an NPE to be uncaught, but nsk.share.MainWrapper
 ## introduces exception handlers.
diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt
index 4897c42c86f..83fd13233fe 100644
--- a/test/hotspot/jtreg/ProblemList.txt
+++ b/test/hotspot/jtreg/ProblemList.txt
@@ -96,7 +96,6 @@ runtime/os/TestTracePageSizes.java#Serial 8267460 linux-aarch64
 runtime/ErrorHandling/CreateCoredumpOnCrash.java 8267433 macosx-x64
 runtime/vthread/RedefineClass.java 8297286 generic-all
 runtime/vthread/TestObjectAllocationSampleEvent.java 8297286 generic-all
-runtime/StackGuardPages/TestStackGuardPages.java 8293452 linux-all
 
 applications/jcstress/copy.java 8229852 linux-all
 
diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups
index 31513ffeeed..28728055c0a 100644
--- a/test/hotspot/jtreg/TEST.groups
+++ b/test/hotspot/jtreg/TEST.groups
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -434,7 +434,6 @@ hotspot_appcds_dynamic = \
  -runtime/cds/appcds/javaldr/ArrayTest.java \
  -runtime/cds/appcds/javaldr/ExceptionDuringDumpAtObjectsInitPhase.java \
  -runtime/cds/appcds/javaldr/GCSharedStringsDuringDump.java \
- -runtime/cds/appcds/javaldr/HumongousDuringDump.java \
  -runtime/cds/appcds/javaldr/LockDuringDump.java \
  -runtime/cds/appcds/jcmd/JCmdTestStaticDump.java \
  -runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java \
diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyConjoint.java b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyConjoint.java
index c297e302b09..8d98628c074 100644
--- a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyConjoint.java
+++ b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyConjoint.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -232,8 +232,7 @@ public static void main(String [] args) {
 
       setup();
 
-      try {
-        for (int i = 0 ; i < 1000000 ; i++ ) {
+      for (int i = 0 ; i < 30_000 ; i++ ) {
           int index = r.nextInt(2048);
           testByte(lengths[i % lengths.length], index , index+2);
           reinit(byte.class);
@@ -262,10 +261,6 @@ public static void main(String [] args) {
           reinit(long.class);
           testLong_constant_LT64B (index , index+2);
           reinit(long.class);
-        }
-        System.out.println("PASS : " + validate_ctr);
-      } catch (Exception e) {
-        System.out.println(e.getMessage());
       }
     }
 }
diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java
index f8bcf1cc08a..162ba20048d 100644
--- a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java
+++ b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java
@@ -202,27 +202,22 @@ public static void main(String [] args) {
 
       setup();
 
-      try {
-        for (int i = 0 ; i < 1000000 ; i++ ) {
-          testByte(lengths[i % lengths.length], r.nextInt(2048) , r.nextInt(2048));
-          testByte_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
-          testByte_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
-
-          testChar(lengths[i % lengths.length] >> 1, r.nextInt(2048) , r.nextInt(2048));
-          testChar_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
-          testChar_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
-
-          testInt(lengths[i % lengths.length]  >> 2, r.nextInt(2048) , r.nextInt(2048));
-          testInt_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
-          testInt_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
-
-          testLong(lengths[i % lengths.length] >> 3, r.nextInt(2048) , r.nextInt(2048));
-          testLong_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
-          testLong_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
-        }
-        System.out.println("PASS : " + validate_ctr);
-      } catch (Exception e) {
-         System.out.println(e.getMessage());
+      for (int i = 0 ; i < 30_000 ; i++ ) {
+        testByte(lengths[i % lengths.length], r.nextInt(2048) , r.nextInt(2048));
+        testByte_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
+        testByte_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
+
+        testChar(lengths[i % lengths.length] >> 1, r.nextInt(2048) , r.nextInt(2048));
+        testChar_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
+        testChar_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
+
+        testInt(lengths[i % lengths.length]  >> 2, r.nextInt(2048) , r.nextInt(2048));
+        testInt_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
+        testInt_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
+
+        testLong(lengths[i % lengths.length] >> 3, r.nextInt(2048) , r.nextInt(2048));
+        testLong_constant_LT32B (r.nextInt(2048) , r.nextInt(2048));
+        testLong_constant_LT64B (r.nextInt(2048) , r.nextInt(2048));
       }
     }
 }
diff --git a/test/hotspot/jtreg/compiler/intrinsics/TestBitShuffleOpers.java b/test/hotspot/jtreg/compiler/intrinsics/TestBitShuffleOpers.java
index f142bfaf775..46469777771 100644
--- a/test/hotspot/jtreg/compiler/intrinsics/TestBitShuffleOpers.java
+++ b/test/hotspot/jtreg/compiler/intrinsics/TestBitShuffleOpers.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,14 @@
  * @key randomness
  * @summary To test various transforms added for bit COMPRESS_BITS and EXPAND_BITS operations
  * @requires vm.compiler2.enabled
- * @requires vm.cpu.features ~= ".*bmi2.*"
- * @requires vm.cpu.features ~= ".*bmi1.*"
- * @requires vm.cpu.features ~= ".*sse2.*"
+ * @requires (((os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64") &
+ *            (vm.cpu.features ~= ".*bmi2.*" & vm.cpu.features ~= ".*bmi1.*" &
+ *             vm.cpu.features ~= ".*sse2.*")) |
+ *            ((vm.opt.UseSVE == "null" | vm.opt.UseSVE > 1) &
+ *             os.arch=="aarch64" & vm.cpu.features ~= ".*svebitperm.*"))
  * @library /test/lib /
  * @run driver compiler.intrinsics.TestBitShuffleOpers
  */
-
 package compiler.intrinsics;
 
 import java.util.concurrent.Callable;
diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java
index ae09e95b024..0b5ee1e88fa 100644
--- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java
+++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -104,9 +104,18 @@ public static void main(String[] args) {
     }
 
     private void test() {
-        for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD + 1; i++) {
+        // Run enough iterations to reach compilation.
+        for (int i = 0; i < (CHECK_COMPILED ? 1 : 10_000); i++) {
             testNativeFrame("someString", i);
         }
+
+        if (CHECK_COMPILED) {
+            // Verify that we reached compilation at some point.
+            Asserts.assertTrue(WB.isMethodCompiled(ITERATE_FRAMES_METHOD),
+                "Expected native method to be compiled: " + ITERATE_FRAMES_METHOD);
+            Asserts.assertTrue(WB.isMethodCompiled(NATIVE_METHOD),
+                "Expected native method to be compiled: " + NATIVE_METHOD);
+        }
     }
 
     /**
@@ -125,13 +134,6 @@ private void testNativeFrame(String str, int iteration) {
 
         Asserts.assertEQ(innerHelper.string, NATIVE_METHOD_RESOLVED.getName(),
             "Native frame not found?: " + NATIVE_METHOD_RESOLVED.getName());
-
-        if (CHECK_COMPILED) {
-            Asserts.assertTrue(WB.isMethodCompiled(ITERATE_FRAMES_METHOD),
-                "Expected native method to be compiled: " + ITERATE_FRAMES_METHOD);
-            Asserts.assertTrue(WB.isMethodCompiled(NATIVE_METHOD),
-                "Expected native method to be compiled: " + NATIVE_METHOD);
-        }
     }
 
     private void testNativeFrameCallback(Helper helper, int iteration) {
diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java
index cd11d25955a..68d8d0f5aaf 100644
--- a/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java
+++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java
@@ -116,12 +116,6 @@ protected void onStart() {
 
     protected void compileMethod(DeclaredTest test) {
         final Method testMethod = test.getTestMethod();
-        TestRun.check(WHITE_BOX.isMethodCompilable(testMethod, test.getCompLevel().getValue(), false),
-                      "Method " + testMethod + " not compilable at level " + test.getCompLevel()
-                      + ". Did you use compileonly without including all @Test methods?");
-        TestRun.check(WHITE_BOX.isMethodCompilable(testMethod),
-                      "Method " + testMethod + " not compilable at level " + test.getCompLevel()
-                      + ". Did you use compileonly without including all @Test methods?");
         if (TestFramework.VERBOSE) {
             System.out.println("Compile method " + testMethod + " after warm-up...");
         }
@@ -163,7 +157,10 @@ protected void compileMethod(DeclaredTest test) {
     }
 
     private void enqueueMethodForCompilation(DeclaredTest test) {
-        TestVM.enqueueForCompilation(test.getTestMethod(), test.getCompLevel());
+        final Method testMethod = test.getTestMethod();
+        TestRun.check(WHITE_BOX.isMethodCompilable(testMethod, test.getCompLevel().getValue(), false),
+                      "Method " + testMethod + " not compilable (anymore) at level " + test.getCompLevel());
+        TestVM.enqueueForCompilation(testMethod, test.getCompLevel());
     }
 
     protected void checkCompilationLevel(DeclaredTest test) {
diff --git a/test/hotspot/jtreg/compiler/loopopts/TestCMoveWithDeadPhi.java b/test/hotspot/jtreg/compiler/loopopts/TestCMoveWithDeadPhi.java
index 5b309cafbd7..577ccad7e03 100644
--- a/test/hotspot/jtreg/compiler/loopopts/TestCMoveWithDeadPhi.java
+++ b/test/hotspot/jtreg/compiler/loopopts/TestCMoveWithDeadPhi.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,6 @@ public void run() {
         // Give thread some time to trigger compilation
         thread.setDaemon(true);
         thread.start();
-        Thread.sleep(Utils.adjustTimeout(4000));
+        Thread.sleep(Utils.adjustTimeout(500));
     }
 }
diff --git a/test/hotspot/jtreg/compiler/loopopts/TestInfLoopNearUsePlacement.java b/test/hotspot/jtreg/compiler/loopopts/TestInfLoopNearUsePlacement.java
index 24f890aae74..67b861fa083 100644
--- a/test/hotspot/jtreg/compiler/loopopts/TestInfLoopNearUsePlacement.java
+++ b/test/hotspot/jtreg/compiler/loopopts/TestInfLoopNearUsePlacement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,6 @@ public void run() {
         thread.setDaemon(true);
         thread.start();
         // Give thread some time to trigger compilation
-        Thread.sleep(Utils.adjustTimeout(5000));
+        Thread.sleep(Utils.adjustTimeout(500));
     }
 }
diff --git a/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopCCP.java b/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopCCP.java
index 770621e21f6..c536417eb10 100644
--- a/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopCCP.java
+++ b/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopCCP.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2021, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,6 +73,6 @@ public void run() {
         // Give thread some time to trigger compilation
         thread.setDaemon(true);
         thread.start();
-        Thread.sleep(Utils.adjustTimeout(4000));
+        Thread.sleep(Utils.adjustTimeout(500));
     }
 }
diff --git a/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopNest.java b/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopNest.java
index 90ca4c56368..1f14a546c2f 100644
--- a/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopNest.java
+++ b/test/hotspot/jtreg/compiler/loopopts/TestInfiniteLoopNest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2022, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,7 +66,7 @@ public void run() {
         // Give thread some time to trigger compilation
         thread.setDaemon(true);
         thread.start();
-        Thread.sleep(Utils.adjustTimeout(4000));
+        Thread.sleep(Utils.adjustTimeout(500));
     }
 
     static Boolean b;
diff --git a/test/hotspot/jtreg/compiler/loopopts/TestStrangeControl.java b/test/hotspot/jtreg/compiler/loopopts/TestStrangeControl.java
index ff361a91182..e597dc684ce 100644
--- a/test/hotspot/jtreg/compiler/loopopts/TestStrangeControl.java
+++ b/test/hotspot/jtreg/compiler/loopopts/TestStrangeControl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,6 @@ public void run() {
         thread.setDaemon(true);
         thread.start();
         // Give thread executing strange control loop enough time to trigger OSR compilation
-        Thread.sleep(Utils.adjustTimeout(4000));
+        Thread.sleep(Utils.adjustTimeout(1000));
     }
 }
diff --git a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java
index 755882ba693..2c9148b1fb4 100644
--- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java
+++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java
@@ -126,7 +126,6 @@ public boolean isAvailable() {
         new LogMessageWithLevel("Merged Howl ArrayOfCards", Level.DEBUG),
         new LogMessageWithLevel("Merged Howl BitMap", Level.DEBUG),
         new LogMessageWithLevel("Merged Howl Full", Level.DEBUG),
-        new LogMessageWithLevel("Hot Card Cache", Level.DEBUG),
         new LogMessageWithLevel("Log Buffers", Level.DEBUG),
         new LogMessageWithLevel("Dirty Cards", Level.DEBUG),
         new LogMessageWithLevel("Merged Cards", Level.DEBUG),
@@ -179,10 +178,10 @@ public boolean isAvailable() {
 
         // Post Evacuate Cleanup 2
         new LogMessageWithLevel("Post Evacuate Cleanup 2", Level.DEBUG),
-        new LogMessageWithLevel("Reset Hot Card Cache", Level.DEBUG),
         new LogMessageWithLevelC2OrJVMCIOnly("Update Derived Pointers", Level.DEBUG),
         new LogMessageWithLevel("Redirty Logged Cards", Level.DEBUG),
         new LogMessageWithLevel("Redirtied Cards", Level.DEBUG),
+        new LogMessageWithLevel("Resize TLABs", Level.DEBUG),
         new LogMessageWithLevel("Free Collection Set", Level.DEBUG),
         new LogMessageWithLevel("Serial Free Collection Set", Level.TRACE),
         new LogMessageWithLevel("Young Free Collection Set", Level.TRACE),
@@ -192,8 +191,7 @@ public boolean isAvailable() {
         new LogMessageWithLevel("Rebuild Free List", Level.DEBUG),
         new LogMessageWithLevel("Serial Rebuild Free List", Level.TRACE),
         new LogMessageWithLevel("Parallel Rebuild Free List", Level.TRACE),
-        new LogMessageWithLevel("Start New Collection Set", Level.DEBUG),
-        new LogMessageWithLevel("Resize TLABs", Level.DEBUG),
+        new LogMessageWithLevel("Prepare For Mutator", Level.DEBUG),
         new LogMessageWithLevel("Expand Heap After Collection", Level.DEBUG),
     };
 
diff --git a/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java b/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java
index be6725a6271..b9c556f94cd 100644
--- a/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java
+++ b/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java
@@ -102,7 +102,6 @@ static void checkSize(OutputAnalyzer output, long expectedSize, String pattern)
 
     static void checkSmallTables(OutputAnalyzer output, long expectedPageSize) throws Exception {
         checkSize(output, expectedPageSize, "Block Offset Table: .*page_size=([^ ]+)");
-        checkSize(output, expectedPageSize, "Card Counts Table: .*page_size=([^ ]+)");
     }
 
     static void checkBitmap(OutputAnalyzer output, long expectedPageSize) throws Exception {
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java
index 1b38c2d4c26..851115d8fee 100644
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java
@@ -39,7 +39,6 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Random;
-import jdk.internal.misc.Unsafe; // for ADDRESS_SIZE
 import jdk.test.whitebox.WhiteBox;
 
 public class TestShrinkAuxiliaryData {
@@ -61,26 +60,14 @@ public class TestShrinkAuxiliaryData {
         "-Xbootclasspath/a:.",
     };
 
-    private final int hotCardTableSize;
-
-    protected TestShrinkAuxiliaryData(int hotCardTableSize) {
-        this.hotCardTableSize = hotCardTableSize;
+    protected TestShrinkAuxiliaryData() {
     }
 
     protected void test() throws Exception {
         ArrayList<String> vmOpts = new ArrayList<>();
         Collections.addAll(vmOpts, initialOpts);
 
-        int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize()));
-        if (maxCacheSize < hotCardTableSize) {
-            throw new SkippedException(String.format(
-                    "Skiping test for %d cache size due max cache size %d",
-                    hotCardTableSize, maxCacheSize));
-        }
-
-        printTestInfo(maxCacheSize);
-
-        vmOpts.add("-XX:G1ConcRSLogCacheSize=" + hotCardTableSize);
+        printTestInfo();
 
         // for 32 bits ObjectAlignmentInBytes is not a option
         if (Platform.is32bit()) {
@@ -109,47 +96,19 @@ private void performTest(List<String> opts) throws Exception {
         output.shouldHaveExitValue(0);
     }
 
-    private void printTestInfo(int maxCacheSize) {
-
+    private void printTestInfo() {
         DecimalFormat grouped = new DecimalFormat("000,000");
         DecimalFormatSymbols formatSymbols = grouped.getDecimalFormatSymbols();
         formatSymbols.setGroupingSeparator(' ');
         grouped.setDecimalFormatSymbols(formatSymbols);
 
         System.out.format(
-                "Test will use %s bytes of memory of %s available%n"
-                + "Available memory is %s with %d bytes pointer size - can save %s pointers%n"
-                + "Max cache size: 2^%d = %s elements%n",
+                "Test will use %s bytes of memory of %s available%n",
                 grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
-                grouped.format(Runtime.getRuntime().maxMemory()),
-                grouped.format(Runtime.getRuntime().maxMemory()
-                        - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
-                Unsafe.ADDRESS_SIZE,
-                grouped.format((Runtime.getRuntime().freeMemory()
-                        - ShrinkAuxiliaryDataTest.getMemoryUsedByTest())
-                        / Unsafe.ADDRESS_SIZE),
-                maxCacheSize,
-                grouped.format((int) Math.pow(2, maxCacheSize))
+                grouped.format(Runtime.getRuntime().maxMemory())
         );
     }
 
-    /**
-     * Detects maximum possible size of G1ConcRSLogCacheSize available for
-     * current process based on maximum available process memory size
-     *
-     * @return power of two
-     */
-    private static int getMaxCacheSize() {
-        long availableMemory = Runtime.getRuntime().freeMemory()
-                - ShrinkAuxiliaryDataTest.getMemoryUsedByTest() - 1l;
-        if (availableMemory <= 0) {
-            return 0;
-        }
-
-        long availablePointersCount = availableMemory / Unsafe.ADDRESS_SIZE;
-        return (63 - (int) Long.numberOfLeadingZeros(availablePointersCount));
-    }
-
     static class ShrinkAuxiliaryDataTest {
 
         public static void main(String[] args) throws Exception {
@@ -166,19 +125,19 @@ public static void main(String[] args) throws Exception {
         /**
          * Checks is this environment suitable to run this test
          * - memory is enough to decommit (page size is not big)
-         * - RSet cache size is not too big
          *
          * @return true if test could run, false if test should be skipped
          */
         protected boolean checkEnvApplicability() {
 
             int pageSize = WhiteBox.getWhiteBox().getVMPageSize();
+            // Auxiliary data size is about ~1.9% of heap size.
+            int auxDataSize = REGION_SIZE * REGIONS_TO_ALLOCATE * 19 / 1000;
             System.out.println( "Page size = " + pageSize
                     + " region size = " + REGION_SIZE
-                    + " aux data ~= " + (REGION_SIZE * 3 / 100));
+                    + " aux data ~= " + auxDataSize);
             // If auxdata size will be less than page size it wouldn't decommit.
-            // Auxiliary data size is about ~3.6% of heap size.
-            if (pageSize >= REGION_SIZE * 3 / 100) {
+            if (pageSize >= auxDataSize) {
                 System.out.format("Skipping test for too large page size = %d",
                        pageSize
                 );
@@ -229,13 +188,10 @@ public void test() throws Exception {
             mutate();
 
             muFull = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
-            long numUsedRegions = WhiteBox.getWhiteBox().g1NumMaxRegions()
-                    - WhiteBox.getWhiteBox().g1NumFreeRegions();
             muAuxDataFull = WhiteBox.getWhiteBox().g1AuxiliaryMemoryUsage();
-            auxFull = (float)muAuxDataFull.getUsed() / numUsedRegions;
 
-            System.out.format("Full aux data  ratio= %f, regions max= %d, used= %d\n",
-                    auxFull, WhiteBox.getWhiteBox().g1NumMaxRegions(), numUsedRegions
+            System.out.format("Full -- heap capacity: %d, Aux data: %d\n",
+                    muFull.getCommitted(), muAuxDataFull.getUsed()
             );
 
             deallocate();
@@ -252,32 +208,17 @@ public void test() throws Exception {
             muFree = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
             muAuxDataFree = WhiteBox.getWhiteBox().g1AuxiliaryMemoryUsage();
 
-            numUsedRegions = WhiteBox.getWhiteBox().g1NumMaxRegions()
-                    - WhiteBox.getWhiteBox().g1NumFreeRegions();
-            auxFree = (float)muAuxDataFree.getUsed() / numUsedRegions;
-
-            System.out.format("Free aux data ratio= %f, regions max= %d, used= %d\n",
-                    auxFree, WhiteBox.getWhiteBox().g1NumMaxRegions(), numUsedRegions
+            System.out.format("Free -- heap capacity: %d, Aux data: %d\n",
+                    muFree.getCommitted(), muAuxDataFree.getUsed()
             );
 
-            Asserts.assertLessThanOrEqual(muFree.getCommitted(), muFull.getCommitted(),
-                    String.format("heap decommit failed - full > free: %d > %d",
-                            muFree.getCommitted(), muFull.getCommitted()
-                    )
+            Asserts.assertLessThan(muFree.getCommitted(), muFull.getCommitted(),
+                                   "heap decommit failed"
             );
 
-            System.out.format("State               used   committed\n");
-            System.out.format("Full aux data: %10d %10d\n", muAuxDataFull.getUsed(), muAuxDataFull.getCommitted());
-            System.out.format("Free aux data: %10d %10d\n", muAuxDataFree.getUsed(), muAuxDataFree.getCommitted());
-
-            // if decommited check that aux data has same ratio
-            if (muFree.getCommitted() < muFull.getCommitted()) {
-                Asserts.assertLessThanOrEqual(auxFree, auxFull,
-                        String.format("auxiliary data decommit failed - full > free: %f > %f",
-                                auxFree, auxFull
-                        )
-                );
-            }
+            Asserts.assertLessThan(muAuxDataFree.getUsed(), muAuxDataFull.getUsed(),
+                                   "auxiliary data decommit failed"
+            );
         }
 
         private void allocate() {
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData15.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData15.java
deleted file mode 100644
index 5993aa077b5..00000000000
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData15.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package gc.g1;
-
-/**
- * @test TestShrinkAuxiliaryData15
- * @bug 8038423 8061715 8078405
- * @key randomness
- * @summary Checks that decommitment occurs for JVM with different
- * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
- * @requires vm.gc.G1
- * @library /test/lib
- * @library /
- * @modules java.base/jdk.internal.misc
- *          java.management
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryData15
- */
-public class TestShrinkAuxiliaryData15 {
-
-    public static void main(String[] args) throws Exception {
-        new TestShrinkAuxiliaryData(15).test();
-    }
-}
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData20.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData20.java
deleted file mode 100644
index aeb859cdb96..00000000000
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData20.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package gc.g1;
-
-/**
- * @test TestShrinkAuxiliaryData20
- * @key randomness
- * @bug 8038423 8061715 8078405
- * @summary Checks that decommitment occurs for JVM with different
- * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
- * @requires vm.gc.G1
- * @library /test/lib
- * @library /
- * @modules java.base/jdk.internal.misc
-  *          java.management
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryData20
- */
-public class TestShrinkAuxiliaryData20 {
-
-    public static void main(String[] args) throws Exception {
-        new TestShrinkAuxiliaryData(20).test();
-    }
-}
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData25.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData25.java
deleted file mode 100644
index bd87ee6f473..00000000000
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData25.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package gc.g1;
-
-/**
- * @test TestShrinkAuxiliaryData25
- * @key randomness
- * @bug 8038423 8061715 8078405
- * @summary Checks that decommitment occurs for JVM with different
- * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
- * @requires vm.gc.G1
- * @library /test/lib
- * @library /
- * @modules java.base/jdk.internal.misc
- *          java.management
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryData25
- */
-public class TestShrinkAuxiliaryData25 {
-
-    public static void main(String[] args) throws Exception {
-        new TestShrinkAuxiliaryData(25).test();
-    }
-}
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData27.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData27.java
deleted file mode 100644
index d54ae18c8dd..00000000000
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData27.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package gc.g1;
-
-/**
- * @test TestShrinkAuxiliaryData27
- * @key randomness
- * @bug 8038423 8061715 8078405
- * @summary Checks that decommitment occurs for JVM with different
- * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
- * @requires vm.gc.G1
- * @library /test/lib
- * @library /
- * @modules java.base/jdk.internal.misc
- *          java.management
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryData27
- */
-public class TestShrinkAuxiliaryData27 {
-
-    public static void main(String[] args) throws Exception {
-        new TestShrinkAuxiliaryData(27).test();
-    }
-}
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData00.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryDataRunner.java
similarity index 85%
rename from test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData00.java
rename to test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryDataRunner.java
index ab8a45e07f3..309ba722787 100644
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData00.java
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryDataRunner.java
@@ -24,11 +24,10 @@
 package gc.g1;
 
 /**
- * @test TestShrinkAuxiliaryData00
+ * @test TestShrinkAuxiliaryDataRunner
  * @key randomness
  * @bug 8038423 8061715
- * @summary Checks that decommitment occurs for JVM with different
- * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @summary Checks that decommitment occurs for JVM with different ObjectAlignmentInBytes values
  * @requires vm.gc.G1
  * @library /test/lib
  * @library /
@@ -36,11 +35,11 @@
  *          java.management
  * @build jdk.test.whitebox.WhiteBox
  * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryData00
+ * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryDataRunner
  */
-public class TestShrinkAuxiliaryData00 {
+public class TestShrinkAuxiliaryDataRunner {
 
     public static void main(String[] args) throws Exception {
-        new TestShrinkAuxiliaryData(0).test();
+        new TestShrinkAuxiliaryData().test();
     }
 }
diff --git a/test/hotspot/jtreg/gtest/MetaspaceGtests.java b/test/hotspot/jtreg/gtest/MetaspaceGtests.java
index 75cb7fe52fc..20b358a9d01 100644
--- a/test/hotspot/jtreg/gtest/MetaspaceGtests.java
+++ b/test/hotspot/jtreg/gtest/MetaspaceGtests.java
@@ -37,7 +37,7 @@
  *          java.xml
  * @requires vm.debug
  * @requires vm.flagless
- * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=none -XX:VerifyMetaspaceInterval=3
+ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=none -XX:VerifyMetaspaceInterval=3
  */
 
 /* @test id=reclaim-none-ndebug
@@ -48,7 +48,7 @@
  *          java.xml
  * @requires vm.debug == false
  * @requires vm.flagless
- * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=none
+ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=none
  */
 
 
@@ -62,7 +62,7 @@
  *          java.xml
  * @requires vm.debug
  * @requires vm.flagless
- * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=aggressive -XX:VerifyMetaspaceInterval=3
+ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=aggressive -XX:VerifyMetaspaceInterval=3
  */
 
 /* @test id=reclaim-aggressive-ndebug
@@ -73,7 +73,7 @@
  *          java.xml
  * @requires vm.debug == false
  * @requires vm.flagless
- * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=aggressive
+ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=aggressive
  */
 
 
@@ -99,5 +99,5 @@
  *          java.xml
  * @requires vm.bits == 64
  * @requires vm.flagless
- * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=balanced -XX:-UseCompressedClassPointers
+ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=balanced -XX:-UseCompressedClassPointers
  */
diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
index 7f967a0a74d..b5ce0952ff6 100644
--- a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2018, 2022 SAP SE. All rights reserved.
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,43 +50,32 @@
 public class ShowRegistersOnAssertTest {
 
     private static void do_test(boolean do_assert, // true - assert, false - guarantee
-        boolean suppress_assert,
         boolean show_registers_on_assert) throws Exception
     {
-        System.out.println("Testing " + (suppress_assert ? "suppressed" : "normal") + " " + (do_assert ? "assert" : "guarantee") +
+        System.out.println("Testing " + (do_assert ? "assert" : "guarantee") +
                            " with " + (show_registers_on_assert ? "-XX:+ShowRegistersOnAssert" : "-XX:-ShowRegistersOnAssert") + "...");
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash",
             "-XX:ErrorHandlerTest=" + (do_assert ? "1" : "2"),
-            (suppress_assert ? "-XX:SuppressErrorAt=/vmError.cpp" : ""),
             (show_registers_on_assert ? "-XX:+ShowRegistersOnAssert" : "-XX:-ShowRegistersOnAssert"),
             "-version");
 
         OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
 
-        if (suppress_assert) {
-            // we should have not have crashed. See VMError::controlled_crash().
-            output_detail.shouldMatch(".*survived intentional crash.*");
-        } else {
-            // we should have crashed with an internal error. We should definitly NOT have crashed with a segfault
-            // (which would be a sign that the assert poison page mechanism does not work).
-            output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
-            output_detail.shouldMatch("# +Internal Error.*");
-        }
+        // we should have crashed with an internal error. We should definitly NOT have crashed with a segfault
+        // (which would be a sign that the assert poison page mechanism does not work).
+        output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
+        output_detail.shouldMatch("# +Internal Error.*");
     }
 
     public static void main(String[] args) throws Exception {
         // Note: for now, this is only a regression test testing that the addition of ShowRegistersOnAssert does
         // not break normal assert/guarantee handling. The feature is not implemented on all platforms and really testing
         // it requires more effort.
-        do_test(false, false, false);
-        do_test(false, false, true);
-        do_test(false, true, false);
-        do_test(false, true, true);
-        do_test(true, false, false);
-        do_test(true, false, true);
-        do_test(true, true, false);
-        do_test(true, true, true);
+        do_test(false, false);
+        do_test(false, true);
+        do_test(true, false);
+        do_test(true, true);
     }
 
 }
diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java
index c7d91637b38..a4c470e5ba4 100644
--- a/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,9 +64,6 @@ public static void main(String[] args) throws Exception {
 
         /* Output should look something like this. The actual text will depend on the OS and its core dump processing.
            Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit
-           # To suppress the following error report, specify this argument
-           # after -XX: or in .hotspotrc:  SuppressErrorAt=/debug.cpp:303
-           #
            # A fatal error has been detected by the Java Runtime Environment:
            #
            #  Internal Error (/home/cheleswer/Desktop/jdk9/dev/hotspot/src/share/vm/utilities/debug.cpp:303), pid=6212, tid=6213
diff --git a/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java
index d90a49a0adb..1eabb4ff6f3 100644
--- a/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java
+++ b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java
@@ -43,7 +43,7 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.management
- * @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:MetaspaceReclaimPolicy=none PrintMetaspaceDcmd
+ * @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=none PrintMetaspaceDcmd
  */
 
 /*
@@ -53,7 +53,7 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.management
- * @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:MetaspaceReclaimPolicy=aggressive PrintMetaspaceDcmd
+ * @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=aggressive PrintMetaspaceDcmd
  */
 
 /*
diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java b/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java
index 4877a3433a7..a9149a2e6c2 100644
--- a/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java
+++ b/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPages.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,13 +40,14 @@ public static void main(String args[]) throws Exception {
         ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("invoke",
                                                                         "test_java_overflow");
         pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
-        new OutputAnalyzer(pb.start())
-            .shouldHaveExitValue(0);
+        OutputAnalyzer output = ProcessTools.executeProcess(pb);
+        output.shouldHaveExitValue(0);
 
-        pb = ProcessTools.createNativeTestProcessBuilder("invoke", "test_native_overflow");
+        pb = ProcessTools.createNativeTestProcessBuilder("invoke",
+                                                         "test_java_overflow_initial");
         pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
-        new OutputAnalyzer(pb.start())
-            .shouldHaveExitValue(0);
+        output = ProcessTools.executeProcess(pb);
+        output.shouldHaveExitValue(0);
     }
 }
 
diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPagesNative.java b/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPagesNative.java
new file mode 100644
index 00000000000..d3a132f4b62
--- /dev/null
+++ b/test/hotspot/jtreg/runtime/StackGuardPages/TestStackGuardPagesNative.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Stack guard pages should be installed correctly and removed when thread is detached for native threads
+ * @modules java.base/jdk.internal.misc
+ * @library /test/lib
+ * @requires os.family == "linux"
+ * @compile DoOverflow.java
+ * @run main/native TestStackGuardPagesNative
+ */
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+
+public class TestStackGuardPagesNative {
+    public static void main(String args[]) throws Exception {
+
+        ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("invoke", "test_native_overflow");
+        pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
+        OutputAnalyzer output = ProcessTools.executeProcess(pb);
+        output.shouldHaveExitValue(0);
+
+        pb = ProcessTools.createNativeTestProcessBuilder("invoke", "test_native_overflow_initial");
+        pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
+        output = ProcessTools.executeProcess(pb);
+        output.shouldHaveExitValue(0);
+
+    }
+}
diff --git a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
index 50a37001fbf..abef2ea050a 100644
--- a/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
+++ b/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,10 +53,11 @@ JavaVM* _jvm;
 
 static jmp_buf  context;
 
-static int _last_si_code = -1;
-static int _failures = 0;
-static int _rec_count = 0;
-static int _kp_rec_count = 0;
+static volatile int _last_si_code = -1;
+static volatile int _failures = 0;
+static volatile int _rec_count = 0; // Number of allocations to hit stack guard page
+static volatile int _kp_rec_count = 0; // Kept record of rec_count, for retrying
+static int _peek_value = 0; // Used for accessing memory to cause SIGSEGV
 
 pid_t gettid() {
   return (pid_t) syscall(SYS_gettid);
@@ -73,7 +74,7 @@ static char* altstack = NULL;
 void set_signal_handler() {
   if (altstack == NULL) {
     // Dynamically allocated in case SIGSTKSZ is not constant
-    altstack = malloc(SIGSTKSZ);
+    altstack = (char*)malloc(SIGSTKSZ);
     if (altstack == NULL) {
       fprintf(stderr, "Test ERROR. Unable to malloc altstack space\n");
       exit(7);
@@ -116,31 +117,37 @@ size_t get_java_stacksize () {
   return jdk_args.javaStackSize;
 }
 
-void *run_java_overflow (void *p) {
+// Call DoOverflow::`method` on JVM
+void call_method_on_jvm(const char* method) {
   JNIEnv *env;
   jclass class_id;
   jmethodID method_id;
   int res;
 
-  res = (*_jvm)->AttachCurrentThread(_jvm, (void**)&env, NULL);
+  res = (*_jvm)->AttachCurrentThread(_jvm, (void **)&env, NULL);
   if (res != JNI_OK) {
     fprintf(stderr, "Test ERROR. Can't attach to current thread\n");
     exit(7);
   }
 
-  class_id = (*env)->FindClass (env, "DoOverflow");
+  class_id = (*env)->FindClass(env, "DoOverflow");
   if (class_id == NULL) {
     fprintf(stderr, "Test ERROR. Can't load class DoOverflow\n");
     exit(7);
   }
 
-  method_id = (*env)->GetStaticMethodID(env, class_id, "printIt", "()V");
+  method_id = (*env)->GetStaticMethodID(env, class_id, method, "()V");
   if (method_id == NULL) {
-    fprintf(stderr, "Test ERROR. Can't find method DoOverflow.printIt\n");
+    fprintf(stderr, "Test ERROR. Can't find method DoOverflow.%s\n", method);
     exit(7);
   }
 
   (*env)->CallStaticVoidMethod(env, class_id, method_id, NULL);
+}
+
+void *run_java_overflow (void *p) {
+  volatile int res;
+  call_method_on_jvm("printIt");
 
   res = (*_jvm)->DetachCurrentThread(_jvm);
   if (res != JNI_OK) {
@@ -151,42 +158,22 @@ void *run_java_overflow (void *p) {
 }
 
 void do_overflow(){
-  int *p = alloca(sizeof(int));
+  volatile int *p = NULL;
   if (_kp_rec_count == 0 || _rec_count < _kp_rec_count) {
-      _rec_count ++;
-      do_overflow();
+    for(;;) {
+      _rec_count++;
+      p = (int*)alloca(128);
+      _peek_value = p[0]; // Peek
+    }
   }
 }
 
 void *run_native_overflow(void *p) {
   // Test that stack guard page is correctly set for initial and non initial thread
   // and correctly removed for the initial thread
-  JNIEnv *env;
-  jclass class_id;
-  jmethodID method_id;
-  int res;
-
+  volatile int res;
   printf("run_native_overflow %ld\n", (long) gettid());
-
-  res = (*_jvm)->AttachCurrentThread(_jvm, (void **)&env, NULL);
-  if (res != JNI_OK) {
-    fprintf(stderr, "Test ERROR. Can't attach to current thread\n");
-    exit(7);
-  }
-
-  class_id = (*env)->FindClass (env, "DoOverflow");
-  if (class_id == NULL) {
-    fprintf(stderr, "Test ERROR. Can't load class DoOverflow\n");
-    exit(7);
-  }
-
-  method_id = (*env)->GetStaticMethodID (env, class_id, "printAlive", "()V");
-  if (method_id == NULL) {
-    fprintf(stderr, "Test ERROR. Can't find method DoOverflow.printAlive\n");
-    exit(7);
-  }
-
-  (*env)->CallStaticVoidMethod (env, class_id, method_id, NULL);
+  call_method_on_jvm("printAlive");
 
   // Initialize statics used in do_overflow
   _kp_rec_count = 0;
@@ -240,7 +227,18 @@ void *run_native_overflow(void *p) {
 
 void usage() {
   fprintf(stderr, "Usage: invoke test_java_overflow\n");
+  fprintf(stderr, "       invoke test_java_overflow_initial\n");
   fprintf(stderr, "       invoke test_native_overflow\n");
+  fprintf(stderr, "       invoke test_native_overflow_initial\n");
+}
+
+void init_thread_or_die(pthread_t *thr, pthread_attr_t *thread_attr) {
+  size_t stack_size = get_java_stacksize();
+  if (pthread_attr_init(thread_attr) != 0 ||
+      pthread_attr_setstacksize(thread_attr, stack_size) != 0) {
+    printf("Failed to set stacksize. Exiting test.\n");
+    exit(0);
+  }
 }
 
 
@@ -283,37 +281,53 @@ int main (int argc, const char** argv) {
     exit(7);
   }
 
-  size_t stack_size = get_java_stacksize();
   pthread_t thr;
   pthread_attr_t thread_attr;
 
-  pthread_attr_init(&thread_attr);
-  pthread_attr_setstacksize(&thread_attr, stack_size);
+  if (argc < 2) {
+    fprintf(stderr, "No test selected");
+    usage();
+    exit(7);
+  }
 
-  if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
+  if (strcmp(argv[1], "test_java_overflow_initial") == 0) {
     printf("\nTesting JAVA_OVERFLOW\n");
+    printf("Testing stack guard page behaviour for initial thread\n");
 
+    run_java_overflow(NULL);
+    // This test crash on error
+    exit(0);
+  }
+
+  if (strcmp(argv[1], "test_java_overflow") == 0) {
+    init_thread_or_die(&thr, &thread_attr);
+    printf("\nTesting JAVA_OVERFLOW\n");
     printf("Testing stack guard page behaviour for other thread\n");
 
     pthread_create(&thr, &thread_attr, run_java_overflow, NULL);
     pthread_join(thr, NULL);
 
-    printf("Testing stack guard page behaviour for initial thread\n");
-    run_java_overflow(NULL);
     // This test crash on error
     exit(0);
   }
 
-  if (argc > 1 && strcmp(argv[1], "test_native_overflow") == 0) {
+  if (strcmp(argv[1], "test_native_overflow_initial") == 0) {
     printf("\nTesting NATIVE_OVERFLOW\n");
+    printf("Testing stack guard page behaviour for initial thread\n");
 
+    run_native_overflow(NULL);
+
+    exit((_failures > 0) ? 1 : 0);
+  }
+
+  if (strcmp(argv[1], "test_native_overflow") == 0) {
+    init_thread_or_die(&thr, &thread_attr);
+    printf("\nTesting NATIVE_OVERFLOW\n");
     printf("Testing stack guard page behaviour for other thread\n");
+
     pthread_create(&thr, &thread_attr, run_native_overflow, NULL);
     pthread_join(thr, NULL);
 
-    printf("Testing stack guard page behaviour for initial thread\n");
-    run_native_overflow(NULL);
-
     exit((_failures > 0) ? 1 : 0);
   }
 
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java
index 8d7a312a840..f82f1a02b59 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java
@@ -173,7 +173,7 @@ static void testDebugBuild() throws Exception {
     static void testProductBuild() throws Exception {
         OutputAnalyzer output;
 
-        output = dumpHelloOnly("-XX:ArchiveHeapTestClass=NoSuchClass");
+        output = dumpHelloOnly("-XX:-IgnoreUnrecognizedVMOptions", "-XX:ArchiveHeapTestClass=NoSuchClass");
         mustFail(output, "VM option 'ArchiveHeapTestClass' is develop and is available only in debug version of VM.");
     }
 }
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java
index 2bcbe18e1ff..40a94a2c18f 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -149,7 +149,6 @@ public static void main(String[] args) throws Exception {
                 "-Xlog:gc+region=trace",
                 use_whitebox_jar);
         TestCommon.checkDump(output,
-            "Cannot archive the sub-graph referenced from [Ljava.lang.Integer; object",
-            "humongous regions have been found and may lead to fragmentation");
+            "Cannot archive the sub-graph referenced from [Ljava.lang.Integer; object");
     }
 }
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java
deleted file mode 100644
index 267eb5b9452..00000000000
--- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-/*
- * @test
- * @summary Test how CDS dumping handles the existence of humongous G1 regions.
- * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes
- * @requires vm.cds.write.archived.java.heap
- * @requires vm.jvmti
- * @run driver/timeout=240 HumongousDuringDump
- */
-
-import jdk.test.lib.cds.CDSOptions;
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.helpers.ClassFileInstaller;
-
-public class HumongousDuringDump {
-    public static String appClasses[] = {
-        Hello.class.getName(),
-    };
-    public static String agentClasses[] = {
-        HumongousDuringDumpTransformer.class.getName(),
-    };
-
-    public static void main(String[] args) throws Throwable {
-        String agentJar =
-            ClassFileInstaller.writeJar("HumongousDuringDumpTransformer.jar",
-                                        ClassFileInstaller.Manifest.fromSourceFile("HumongousDuringDumpTransformer.mf"),
-                                        agentClasses);
-
-        String appJar =
-            ClassFileInstaller.writeJar("HumongousDuringDumpApp.jar", appClasses);
-
-        String gcLog = Boolean.getBoolean("test.cds.verbose.gc") ?
-            "-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug" : "-showversion";
-
-        String extraArg = "-javaagent:" + agentJar;
-        String extraOption = "-XX:+AllowArchivingWithJavaAgent";
-
-        OutputAnalyzer out =
-          TestCommon.testDump(appJar, TestCommon.list(Hello.class.getName()),
-                              "-XX:+UnlockDiagnosticVMOptions", extraOption,
-                              "-Xlog:gc+region+cds",
-                              "-Xlog:gc+region=trace",
-                              extraArg, "-Xmx64m", gcLog);
-        out.shouldContain("(Unmovable) humongous regions have been found and may lead to fragmentation");
-        out.shouldContain("All free regions should be at the top end of the heap, but we found holes.");
-        out.shouldMatch("gc,region,cds. HeapRegion .* HUM. hole");
-        String pattern = "gc,region,cds. HeapRegion .*hole";
-        out.shouldMatch(pattern);
-        out.shouldNotMatch(pattern + ".*unexpected");
-
-        TestCommon.run(
-                "-cp", appJar,
-                "-verbose",
-                "-Xmx64m",
-                "-Xlog:cds=info",
-                "-XX:+UnlockDiagnosticVMOptions", extraOption,
-                gcLog,
-                Hello.class.getName())
-              .assertNormalExit();
-    }
-}
-
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDumpTransformer.java b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDumpTransformer.java
deleted file mode 100644
index 018dbb34490..00000000000
--- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDumpTransformer.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-import java.lang.instrument.ClassFileTransformer;
-import java.lang.instrument.Instrumentation;
-import java.lang.instrument.IllegalClassFormatException;
-import java.security.ProtectionDomain;
-
-// This test is sensitive to -Xmx. It must be run with -xmx64m.
-// Running with a different -Xmx requires changing the parameters and careful re-testing.
-public class HumongousDuringDumpTransformer implements ClassFileTransformer {
-    public byte[] transform(ClassLoader loader, String name, Class<?> classBeingRedefined,
-                            ProtectionDomain pd, byte[] buffer) throws IllegalClassFormatException {
-        if (name.equals("Hello")) {
-            try {
-                makeHumongousRegions();
-            } catch (Throwable t) {
-                array = null;
-                humon = null;
-                System.out.println("Unexpected error: " + t);
-                t.printStackTrace();
-            }
-        }
-        array = null;
-        return null;
-    }
-
-    private static Instrumentation savedInstrumentation;
-
-    public static void premain(String agentArguments, Instrumentation instrumentation) {
-        long xmx = Runtime.getRuntime().maxMemory();
-        if (xmx < 60 * 1024 * 1024 || xmx > 80 * 1024 * 1024) {
-            System.out.println("Running with incorrect heap size: " + xmx);
-            System.exit(1);
-        }
-
-        System.out.println("ClassFileTransformer.premain() is called");
-        instrumentation.addTransformer(new HumongousDuringDumpTransformer(), /*canRetransform=*/true);
-        savedInstrumentation = instrumentation;
-    }
-
-    public static Instrumentation getInstrumentation() {
-        return savedInstrumentation;
-    }
-
-    public static void agentmain(String args, Instrumentation inst) throws Exception {
-        premain(args, inst);
-    }
-
-    Object[] array;
-
-    static final int DUMMY_SIZE = 4096 - 16 - 8;
-    static final int HUMON_SIZE = 4 * 1024 * 1024 - 16 - 8;
-    static final int SKIP = 13;
-
-    byte humon[] = null;
-    boolean first = true;
-
-    public synchronized void makeHumongousRegions() {
-        if (!first) {
-            return;
-        }
-        System.out.println("===============================================================================");
-        first = false;
-
-        int total = 0;
-        array = new Object[100000];
-        System.out.println(array);
-
-        // (1) Allocate about 8MB of old objects.
-        for (int n=0, i=0; total < 8 * 1024 * 1024; n++) {
-            // Make enough allocations to cause a GC (for 64MB heap) to create
-            // old regions.
-            //
-            // But don't completely fill up the heap. That would cause OOM and
-            // may not be handled gracefully inside class transformation!
-            Object x = new byte[DUMMY_SIZE];
-            if ((n  % SKIP) == 0) {
-                array[i++] = x;
-                total += DUMMY_SIZE;
-            }
-        }
-
-        System.gc();
-
-        // (2) Now allocate a humongous array. It will sit above the 8MB of old regions.
-        humon = new byte[HUMON_SIZE];
-        array = null;
-        System.gc();
-    }
-}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDumpTransformer.mf b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDumpTransformer.mf
deleted file mode 100644
index 7bd4a10edc4..00000000000
--- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDumpTransformer.mf
+++ /dev/null
@@ -1,5 +0,0 @@
-Manifest-Version: 1.0
-Premain-Class: HumongousDuringDumpTransformer
-Agent-Class: HumongousDuringDumpTransformer
-Can-Retransform-Classes: true
-Can-Redefine-Classes: true
diff --git a/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java b/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java
index 61e927fd248..f15f8e1dad2 100644
--- a/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java
+++ b/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,6 @@
 /*
  * @test
  * @bug 8067744
- * @comment Test uses custom launcher that starts VM in primordial thread. This is
- *          not possible on aix.
- * @requires os.family != "aix"
  * @requires vm.flagless
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
diff --git a/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/exeFPRegs.c b/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/exeFPRegs.c
index 3b67abb4f6a..a4c2635f1d2 100644
--- a/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/exeFPRegs.c
+++ b/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/exeFPRegs.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,9 @@
 #include <jni.h>
 #include <stdlib.h>
 
+#ifdef AIX
+#include <pthread.h>
+#endif //AIX
 #ifdef WINDOWS
 #include <windows.h>
 #else
@@ -104,7 +107,15 @@ long long unsigned int d2l(double d) {
 
 #define print_reg(r) printf("%s = %f (0x%llX)\n", #r, r, d2l(r));
 
-int main(int argc, const char** argv) {
+typedef struct {
+  int argc;
+  char **argv;
+} args_list;
+
+static void* run(void* argp) {
+  args_list *arg = (args_list*) argp;
+  int argc =  arg->argc;
+  char **argv = arg->argv;
   JavaVM* jvm;
   JNIEnv* env;
   JavaVMInitArgs vm_args;
@@ -239,3 +250,24 @@ int main(int argc, const char** argv) {
   return 0;
 }
 
+int main(int argc, char *argv[]) {
+  args_list args;
+  args.argc = argc;
+  args.argv = argv;
+#ifdef AIX
+  size_t adjusted_stack_size = 1024*1024;
+  pthread_t id;
+  int result;
+  pthread_attr_t attr;
+  pthread_attr_init(&attr);
+  pthread_attr_setstacksize(&attr, adjusted_stack_size);
+  result = pthread_create(&id, &attr, run, (void *)&args);
+  if (result != 0) {
+    fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
+    return -1;
+  }
+  pthread_join(id, NULL);
+#else
+  run(&args);
+#endif //AIX
+}
diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/MissedStackMapFrames.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/MissedStackMapFrames.java
new file mode 100644
index 00000000000..52620294aa7
--- /dev/null
+++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/MissedStackMapFrames.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ *
+ * @bug 8228604
+ *
+ * @requires vm.jvmti
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @library /test/lib
+ *
+ * @run main/othervm/native -agentlib:MissedStackMapFrames MissedStackMapFrames
+ */
+
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
+
+public class MissedStackMapFrames {
+    static {
+        System.loadLibrary("MissedStackMapFrames");
+    }
+
+    /* For each test class:
+     *  - loads class (JNIEnv::FindClass);
+     *  - retransforms class (jvmtiEnv::RetransformClasses).
+     * Saves class bytes passed to ClassFileLoadHook.
+     */
+    private static native boolean doTest();
+
+    /* methods to analyze doTest results */
+    private static native int testCount();
+    private static native Class testClass(int idx);
+    private static native byte[] loadBytes(int idx);
+    private static native byte[] retransformBytes(int idx);
+
+    private static int getStackMapFrameCount(byte[] classfileBuffer) {
+        ClassReader reader = new ClassReader(classfileBuffer);
+        final int[] frameCount = {0};
+        ClassVisitor cv = new ClassVisitor(Opcodes.ASM9) {
+            @Override
+            public MethodVisitor visitMethod(int access, String name,
+                                             String descriptor, String signature,
+                                             String[] exceptions) {
+                return new MethodVisitor(Opcodes.ASM9) {
+                    private int methodFrames = 0;
+                    @Override
+                    public void visitFrame(int type, int numLocal, Object[] local,
+                                           int numStack, Object[] stack) {
+                        methodFrames++;
+                    }
+                    @Override
+                    public void visitEnd() {
+                        log("  method " + name + " - " + methodFrames + " frames");
+                        frameCount[0] += methodFrames;
+                    }
+                };
+            }
+        };
+        reader.accept(cv, 0);
+        return frameCount[0];
+    }
+
+    private static int checkStackMapFrames(String mode, byte[] classfileBuffer) {
+        log(mode + ", len = " + classfileBuffer.length);
+        int frameCount = getStackMapFrameCount(classfileBuffer);
+        log("  Has stack map frames: " + frameCount);
+        if (frameCount == 0) {
+            throw new RuntimeException(mode + " - no stack frames");
+        }
+        return frameCount;
+    }
+
+    private static void checkStackMapFrames(String mode, byte[] classfileBuffer, int expectedCount) {
+        int actualCount = checkStackMapFrames(mode, classfileBuffer);
+        if (actualCount != expectedCount) {
+            throw new RuntimeException(mode + " - unexpected stack frames count: " + actualCount
+                                       + " (expected " + expectedCount + ")");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (!doTest()) {
+            throw new RuntimeException("Test failed");
+        }
+
+        // verify results
+        for (int i = 0; i < testCount(); i++) {
+            Class cls = testClass(i);
+            byte[] loadBytes = loadBytes(i);
+            byte[] retransformBytes = retransformBytes(i);
+            int loadCount = checkStackMapFrames(cls + "(load)", loadBytes);
+            checkStackMapFrames(cls + "(retransform)", retransformBytes, loadCount);
+        }
+    }
+
+    private static void log(Object msg) {
+        System.out.println(msg);
+    }
+
+}
diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/libMissedStackMapFrames.cpp b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/libMissedStackMapFrames.cpp
new file mode 100644
index 00000000000..18d4a2e5d1d
--- /dev/null
+++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/libMissedStackMapFrames.cpp
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+#include <jvmti.h>
+#include <stdio.h>
+#include <string.h>
+
+static void _log(const char* format, ...) {
+  va_list args;
+  va_start(args, format);
+  vprintf(format, args);
+  va_end(args);
+  fflush(0);
+}
+
+static jvmtiEnv* jvmti = nullptr;
+
+static const char* testClassNames[] = {
+    "java/util/Date",               // JDK class in CDS archive
+    "java/lang/ProcessBuilder",     // JDK class not in CDS
+    "MissedStackMapFrames"          // non-JDK class
+};
+static const int testClassCount = sizeof(testClassNames) / sizeof(testClassNames[0]);
+
+struct SavedClassBytes {
+  struct Buffer {
+    unsigned char* bytes;
+    jint len;
+
+    Buffer() : bytes(nullptr), len(0) {}
+
+    void save(const unsigned char *bytes, jint len) {
+      jvmtiError err = jvmti->Allocate(len, &this->bytes);
+      if (err != JVMTI_ERROR_NONE) {
+          _log("ClassFileLoadHook: failed to allocate %ld bytes for saved class bytes: %d\n", len, err);
+          return;
+      }
+      memcpy(this->bytes, bytes, len);
+      this->len = len;
+    }
+
+    jbyteArray get(JNIEnv *env) {
+      if (bytes == nullptr) {
+        _log("SavedClassBytes: NULL\n");
+        return nullptr;
+      }
+
+      jbyteArray result = env->NewByteArray(len);
+      if (result == nullptr) {
+        _log("SavedClassBytes: NewByteArray(%ld) failed\n", len);
+      } else {
+        jbyte* arrayPtr = env->GetByteArrayElements(result, nullptr);
+        if (arrayPtr == nullptr) {
+          _log("SavedClassBytes: Failed to get array elements\n");
+          result = nullptr;
+        } else {
+          memcpy(arrayPtr, bytes, len);
+          env->ReleaseByteArrayElements(result, arrayPtr, 0);
+        }
+      }
+      return result;
+    }
+
+  };
+
+  jclass klass;
+
+  Buffer load;
+  Buffer retransform;
+
+  SavedClassBytes() : klass(nullptr) {}
+};
+
+static SavedClassBytes savedBytes[testClassCount];
+
+static int testClassIndex(const char *name) {
+  if (name != nullptr) {
+    for (int i = 0; i < testClassCount; i++) {
+      if (strcmp(name, testClassNames[i]) == 0) {
+        return i;
+      }
+    }
+  }
+  return -1;
+}
+
+
+extern "C" {
+
+JNIEXPORT void JNICALL
+callbackClassFileLoadHook(jvmtiEnv *jvmti_env,
+        JNIEnv* jni_env,
+        jclass class_being_redefined,
+        jobject loader,
+        const char* name,
+        jobject protection_domain,
+        jint class_data_len,
+        const unsigned char* class_data,
+        jint* new_class_data_len,
+        unsigned char** new_class_data) {
+  int idx = testClassIndex(name);
+  if (idx >= 0) {
+    if (class_being_redefined == nullptr) {
+      // load
+      savedBytes[idx].load.save(class_data, class_data_len);
+    } else {
+      // retransform/redefine
+      savedBytes[idx].retransform.save(class_data, class_data_len);
+    }
+  }
+}
+
+JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* jvm, char* options, void* reserved) {
+  jint res = jvm->GetEnv((void **)&jvmti, JVMTI_VERSION_1_1);
+  if (res != JNI_OK) {
+    _log("Failed to get JVMTI interface: %ld\n", res);
+    return JNI_ERR;
+  }
+
+  jvmtiCapabilities caps;
+  memset(&caps, 0, sizeof(caps));
+
+  caps.can_retransform_classes = 1;
+  jvmtiError err = jvmti->AddCapabilities(&caps);
+  if (err != JVMTI_ERROR_NONE) {
+    _log("Failed to add capabilities: %d\n", err);
+    return JNI_ERR;
+  }
+
+  jvmtiEventCallbacks eventCallbacks;
+  memset(&eventCallbacks, 0, sizeof(eventCallbacks));
+  eventCallbacks.ClassFileLoadHook = callbackClassFileLoadHook;
+  err = jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks));
+  if (err != JVMTI_ERROR_NONE) {
+    _log("Error setting event callbacks: %d\n", err);
+    return JNI_ERR;
+  }
+
+  err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr);
+  if (err != JVMTI_ERROR_NONE) {
+    _log("SetEventNotificationMode(JVMTI_ENABLE) error %d\n", err);
+    return JNI_ERR;
+  }
+
+  return JNI_OK;
+}
+
+JNIEXPORT void JNICALL
+Agent_OnUnload(JavaVM* jvm) {
+  return;
+}
+
+
+JNIEXPORT jboolean JNICALL
+Java_MissedStackMapFrames_doTest(JNIEnv* env, jclass klass) {
+
+  jboolean result = JNI_TRUE;
+  _log(">>nTest\n");
+
+  for (int i = 0; i < testClassCount; i++) {
+    _log("Loading %s...\n", testClassNames[i]);
+
+    savedBytes[i].klass = env->FindClass(testClassNames[i]);
+    if (savedBytes[i].klass == nullptr) {
+      _log("Load error\n");
+      result = JNI_FALSE;
+      continue;
+    }
+    savedBytes[i].klass = (jclass)env->NewGlobalRef(savedBytes[i].klass);
+
+    _log("Retransforming %s...\n", testClassNames[i]);
+    jvmtiError err = jvmti->RetransformClasses(1, &savedBytes[i].klass);
+    if (err != JVMTI_ERROR_NONE) {
+      _log("RetransformClasses error %d\n", err);
+      result = JNI_FALSE;
+    }
+  }
+  _log("<<nTest\n");
+  return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_MissedStackMapFrames_testCount(JNIEnv* env, jclass klass) {
+  return testClassCount;
+}
+
+JNIEXPORT jclass JNICALL
+Java_MissedStackMapFrames_testClass(JNIEnv* env, jclass klass, jint idx) {
+  return savedBytes[idx].klass;
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_MissedStackMapFrames_loadBytes(JNIEnv* env, jclass klass, jint idx) {
+  return savedBytes[idx].load.get(env);
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_MissedStackMapFrames_retransformBytes(JNIEnv* env, jclass klass, jint idx) {
+  return savedBytes[idx].retransform.get(env);
+}
+
+} // extern "C"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011.java
index c72e6bd1dfb..7d37b279382 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -209,6 +209,16 @@ private int runIt(String args[], PrintStream out) {
                 clsType.setValue(fldToExit, vm.mirrorOf(true));
 
                 invThr.join(argHandler.getWaitTime()*60000);
+                if (invThr.isAlive()) {
+                    // The join failed because the invoke never completed.
+                    log.complain("TEST FAILED: invoke never completed");
+                    tot_res = Consts.TEST_FAILED;
+                    // Do a vm.resume() to see if that helps.
+                    vm.resume();
+                    invThr.join(); // let test time out if this fails
+                    return quitDebuggee();
+                }
+
                 log.display("Thread \"" + invThr.getName() + "\" done");
 
                 // check threads status after method invocation
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java
index 7a22d2c9483..b3937d4b329 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,11 +87,15 @@ private int runIt(String args[]) {
     static volatile boolean isInvoked = false;
 
     static long dummyMeth(long l) throws InterruptedException {
+        /*
+         * WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
+         * be careful not to do anything that might block on another thread. That includes
+         * calling Thread.sleep(), which can be a problem for virtual threads.
+         */
         invokemethod011t.log.display("dummyMeth: going to loop");
         isInvoked = true;
         while(!doExit) {
             l--; l++;
-            Thread.currentThread().sleep(400);
         }
         invokemethod011t.log.display("dummyMeth: exiting");
         isInvoked = false;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012.java
index c7a02fe1738..4f2159e1c90 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -202,6 +202,15 @@ private int runIt(String args[], PrintStream out) {
 
             clsType.setValue(fldToExit, vm.mirrorOf(true));
             invThr.join(argHandler.getWaitTime()*60000);
+            if (invThr.isAlive()) {
+                // The join failed because the invoke never completed.
+                log.complain("TEST FAILED: invoke never completed");
+                tot_res = Consts.TEST_FAILED;
+                // Do a vm.resume() to see if that helps.
+                vm.resume();
+                invThr.join(); // let test time out if this fails
+                return quitDebuggee();
+            }
             log.display("Thread \"" + invThr.getName() + "\" done");
 
             // check threads status after the method invocation
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012t.java
index 9a93c682f0b..5fb9a5e059e 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012t.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@
  */
 public class invokemethod012t {
     static Log log;
-    private invokemethod012Thr thrs[] =
-        new invokemethod012Thr[invokemethod012.THRDS_NUM-1];
+    private invokemethod012Thr thrs012[] = new invokemethod012Thr[invokemethod012.THRDS_NUM-1];
+    private Thread thrs[] = new Thread[invokemethod012.THRDS_NUM-1];
     private IOPipe pipe;
 
     public static void main(String args[]) {
@@ -89,11 +89,15 @@ private int runIt(String args[]) {
     static volatile boolean isInvoked = false;
 
     static long dummyMeth(long l) throws InterruptedException {
+        /*
+         * WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
+         * be careful not to do anything that might block on another thread. That includes
+         * calling Thread.sleep(), which can be a problem for virtual threads.
+         */
         invokemethod012t.log.display("dummyMeth: going to loop");
         isInvoked = true;
         while(!doExit) {
             l--; l++;
-            Thread.currentThread().sleep(400);
         }
         invokemethod012t.log.display("dummyMeth: exiting");
         isInvoked = false;
@@ -105,8 +109,8 @@ private void startThreads() {
         Object readyObj = new Object();
 
         for (int i=0; i < invokemethod012.THRDS_NUM-1; i++) {
-            thrs[i] = new invokemethod012Thr(readyObj,
-                invokemethod012.DEBUGGEE_THRDS[i+1][0]);
+            thrs012[i] = new invokemethod012Thr(readyObj, invokemethod012.DEBUGGEE_THRDS[i+1][0]);
+            thrs[i] = JDIThreadFactory.newThread(thrs012[i]);
             thrs[i].setDaemon(true);
             log.display("Debuggee: starting thread #"
                 + i + " \"" + thrs[i].getName() + "\" ...");
@@ -129,7 +133,7 @@ private void startThreads() {
 
     private void killThreads(int waitTime) {
         for (int i=0; i < invokemethod012.THRDS_NUM-1 ; i++) {
-            thrs[i].doExit = true;
+            thrs012[i].doExit = true;
             try {
                 thrs[i].join(waitTime);
                 log.display("Debuggee: thread #"
@@ -145,7 +149,7 @@ private void killThreads(int waitTime) {
     * This is an auxiliary thread class used to check the flag
     * INVOKE_SINGLE_THREADED in the debugger.
     */
-    class invokemethod012Thr extends Thread {
+    class invokemethod012Thr extends NamedTask {
         volatile boolean doExit = false;
         private Object readyObj;
 
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013.java
index 68600892b59..a967c2c23ab 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -204,6 +204,15 @@ private int runIt(String args[], PrintStream out) {
             // finish the invocation
             clsRef.setValue(fldToExit, vm.mirrorOf(true));
             invThr.join(argHandler.getWaitTime()*60000);
+            if (invThr.isAlive()) {
+                // The join failed because the invoke never completed.
+                log.complain("TEST FAILED: invoke never completed");
+                tot_res = Consts.TEST_FAILED;
+                // Do a vm.resume() to see if that helps.
+                vm.resume();
+                invThr.join(); // let test time out if this fails
+                return quitDebuggee();
+            }
             log.display("Thread \"" + invThr.getName() + "\" done");
 
             // check threads status after the method invocation
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013t.java
index 792156b9032..94900516f74 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013t.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,11 +88,15 @@ private int runIt(String args[]) {
     static volatile boolean isInvoked = false;
 
     static long dummyMeth(long l) throws InterruptedException {
+        /*
+         * WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
+         * be careful not to do anything that might block on another thread. That includes
+         * calling Thread.sleep(), which can be a problem for virtual threads.
+         */
         invokemethod013t.log.display("dummyMeth: going to loop");
         isInvoked = true;
         while(!doExit) {
             l--; l++;
-            Thread.currentThread().sleep(400);
         }
         invokemethod013t.log.display("dummyMeth: exiting");
         isInvoked = false;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010.java
index 008301025d0..bfa2a50235c 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,16 @@ private int runIt(String args[], PrintStream out) {
                 objRef.setValue(fldToExit, vm.mirrorOf(true));
 
                 invThr.join(argHandler.getWaitTime()*60000);
+                if (invThr.isAlive()) {
+                    // The join failed because the invoke never completed.
+                    log.complain("TEST FAILED: invoke never completed");
+                    tot_res = Consts.TEST_FAILED;
+                    // Do a vm.resume() to see if that helps.
+                    vm.resume();
+                    invThr.join(); // let test time out if this fails
+                    return quitDebuggee();
+                }
+
                 log.display("Thread \"" + invThr.getName() + "\" done");
 
                 // check threads status after method invocation
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010t.java
index 2dae569f1fc..6021e34d6e4 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010t.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@
  */
 public class invokemethod010t {
     static Log log;
-    private invokemethod010Thr thrs[] =
-        new invokemethod010Thr[invokemethod010.THRDS_NUM-1];
+    private invokemethod010Thr thrs010[] = new invokemethod010Thr[invokemethod010.THRDS_NUM-1];
+    private Thread thrs[] = new Thread[invokemethod010.THRDS_NUM-1];
     private IOPipe pipe;
 
     public static void main(String args[]) {
@@ -87,8 +87,8 @@ private void startThreads() {
         Object readyObj = new Object();
 
         for (int i=0; i < invokemethod010.THRDS_NUM-1; i++) {
-            thrs[i] = new invokemethod010Thr(readyObj,
-                invokemethod010.DEBUGGEE_THRDS[i+1]);
+            thrs010[i] = new invokemethod010Thr(readyObj, invokemethod010.DEBUGGEE_THRDS[i+1]);
+            thrs[i] = JDIThreadFactory.newThread(thrs010[i]);
             thrs[i].setDaemon(true);
             log.display("Debuggee: starting thread #"
                 + i + " \"" + thrs[i].getName() + "\" ...");
@@ -111,7 +111,7 @@ private void startThreads() {
 
     private void killThreads(int waitTime) {
         for (int i=0; i < invokemethod010.THRDS_NUM-1 ; i++) {
-            thrs[i].doExit = true;
+            thrs010[i].doExit = true;
             try {
                 thrs[i].join(waitTime);
                 log.display("Debuggee: thread #"
@@ -127,7 +127,7 @@ private void killThreads(int waitTime) {
     * This is an auxiliary thread class used to check the flag
     * ObjectReference.INVOKE_SINGLE_THREADED in the debugger.
     */
-    class invokemethod010Thr extends Thread {
+    class invokemethod010Thr extends NamedTask {
         volatile boolean doExit = false;
         private Object readyObj;
 
@@ -181,11 +181,15 @@ class invokemethod010tDummyClass {
     volatile boolean isInvoked = false;
 
     long longMeth(long l) throws InterruptedException {
+        /*
+         * WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
+         * be careful not to do anything that might block on another thread. That includes
+         * calling Thread.sleep(), which can be a problem for virtual threads.
+         */
         invokemethod010t.log.display("invokemethod010tDummyClass: longMeth: going to loop");
         isInvoked = true;
         while(!doExit) {
             l--; l++;
-            Thread.currentThread().sleep(400);
         }
         invokemethod010t.log.display("invokemethod010tDummyClass: longMeth: exiting");
         isInvoked = false;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011.java
index 090546a2226..1f7c038d397 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,16 @@ private int runIt(String args[], PrintStream out) {
                 objRef.setValue(fldToExit, vm.mirrorOf(true));
 
                 invThr.join(argHandler.getWaitTime()*60000);
+                if (invThr.isAlive()) {
+                    // The join failed because the invoke never completed.
+                    log.complain("TEST FAILED: invoke never completed");
+                    tot_res = Consts.TEST_FAILED;
+                    // Do a vm.resume() to see if that helps.
+                    vm.resume();
+                    invThr.join(); // let test time out if this fails
+                    return quitDebuggee();
+                }
+
                 log.display("Thread \"" + invThr.getName() + "\" done");
 
                 // check threads status after method invocation
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011t.java
index fadc1ab0030..253aae51558 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011t.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@
  */
 public class invokemethod011t {
     static Log log;
-    private invokemethod011Thr thrs[] =
-        new invokemethod011Thr[invokemethod011.THRDS_NUM-1];
+    private invokemethod011Thr thrs011[] = new invokemethod011Thr[invokemethod011.THRDS_NUM-1];
+    private Thread thrs[] = new Thread[invokemethod011.THRDS_NUM-1];
     private IOPipe pipe;
 
     public static void main(String args[]) {
@@ -87,8 +87,8 @@ private void startThreads() {
         Object readyObj = new Object();
 
         for (int i=0; i < invokemethod011.THRDS_NUM-1; i++) {
-            thrs[i] = new invokemethod011Thr(readyObj,
-                invokemethod011.DEBUGGEE_THRDS[i+1]);
+            thrs011[i] = new invokemethod011Thr(readyObj, invokemethod011.DEBUGGEE_THRDS[i+1]);
+            thrs[i] = JDIThreadFactory.newThread(thrs011[i]);
             thrs[i].setDaemon(true);
             log.display("Debuggee: starting thread #"
                 + i + " \"" + thrs[i].getName() + "\" ...");
@@ -111,7 +111,7 @@ private void startThreads() {
 
     private void killThreads(int waitTime) {
         for (int i=0; i < invokemethod011.THRDS_NUM-1 ; i++) {
-            thrs[i].doExit = true;
+            thrs011[i].doExit = true;
             try {
                 thrs[i].join(waitTime);
                 log.display("Debuggee: thread #"
@@ -127,7 +127,7 @@ private void killThreads(int waitTime) {
     * This is an auxiliary thread class used to check the flag
     * ObjectReference.INVOKE_SINGLE_THREADED in the debugger.
     */
-    class invokemethod011Thr extends Thread {
+    class invokemethod011Thr extends NamedTask {
         volatile boolean doExit = false;
         private Object readyObj;
 
@@ -181,11 +181,15 @@ class invokemethod011tDummyClass {
     volatile boolean isInvoked = false;
 
     long longMeth(long l) throws InterruptedException {
+        /*
+         * WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
+         * be careful not to do anything that might block on another thread. That includes
+         * calling Thread.sleep(), which can be a problem for virtual threads.
+         */
         invokemethod011t.log.display("invokemethod011tDummyClass: longMeth: going to loop");
         isInvoked = true;
         while(!doExit) {
             l--; l++;
-            Thread.currentThread().sleep(400);
         }
         invokemethod011t.log.display("invokemethod011tDummyClass: longMeth: exiting");
         isInvoked = false;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012.java
index 7e83e5a3fdc..a8de6497684 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,15 @@ private int runIt(String args[], PrintStream out) {
 
             objRef.setValue(fldToExit, vm.mirrorOf(true));
             invThr.join(argHandler.getWaitTime()*60000);
+            if (invThr.isAlive()) {
+                // The join failed because the invoke never completed.
+                log.complain("TEST FAILED: invoke never completed");
+                tot_res = Consts.TEST_FAILED;
+                // Do a vm.resume() to see if that helps.
+                vm.resume();
+                invThr.join(); // let test time out if this fails
+                return quitDebuggee();
+            }
             log.display("Thread \"" + invThr.getName() + "\" done");
 
             // check threads status after the method invocation
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012t.java
index 3f4aab830ae..fb6ff926951 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod012t.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@
  */
 public class invokemethod012t {
     static Log log;
-    private invokemethod012Thr thrs[] =
-        new invokemethod012Thr[invokemethod012.THRDS_NUM-1];
+    private invokemethod012Thr thrs012[] = new invokemethod012Thr[invokemethod012.THRDS_NUM-1];
+    private Thread thrs[] = new Thread[invokemethod012.THRDS_NUM-1];
     private IOPipe pipe;
 
     public static void main(String args[]) {
@@ -87,8 +87,8 @@ private void startThreads() {
         Object readyObj = new Object();
 
         for (int i=0; i < invokemethod012.THRDS_NUM-1; i++) {
-            thrs[i] = new invokemethod012Thr(readyObj,
-                invokemethod012.DEBUGGEE_THRDS[i+1][0]);
+            thrs012[i] = new invokemethod012Thr(readyObj, invokemethod012.DEBUGGEE_THRDS[i+1][0]);
+            thrs[i] = JDIThreadFactory.newThread(thrs012[i]);
             thrs[i].setDaemon(true);
             log.display("Debuggee: starting thread #"
                 + i + " \"" + thrs[i].getName() + "\" ...");
@@ -111,7 +111,7 @@ private void startThreads() {
 
     private void killThreads(int waitTime) {
         for (int i=0; i < invokemethod012.THRDS_NUM-1 ; i++) {
-            thrs[i].doExit = true;
+            thrs012[i].doExit = true;
             try {
                 thrs[i].join(waitTime);
                 log.display("Debuggee: thread #"
@@ -127,7 +127,7 @@ private void killThreads(int waitTime) {
     * This is an auxiliary thread class used to check the flag
     * ObjectReference.INVOKE_SINGLE_THREADED in the debugger.
     */
-    class invokemethod012Thr extends Thread {
+    class invokemethod012Thr extends NamedTask {
         volatile boolean doExit = false;
         private Object readyObj;
 
@@ -181,11 +181,15 @@ class invokemethod012tDummyClass {
     volatile boolean isInvoked = false;
 
     long longMeth(long l) throws InterruptedException {
+        /*
+         * WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
+         * be careful not to do anything that might block on another thread. That includes
+         * calling Thread.sleep(), which can be a problem for virtual threads.
+         */
         invokemethod012t.log.display("invokemethod012tDummyClass: longMeth: going to loop");
         isInvoked = true;
         while(!doExit) {
             l--; l++;
-            Thread.currentThread().sleep(400);
         }
         invokemethod012t.log.display("invokemethod012tDummyClass: longMeth: exiting");
         isInvoked = false;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013.java
index 9685e515eda..ffa71463963 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -207,6 +207,15 @@ private int runIt(String args[], PrintStream out) {
 
             objRef.setValue(fldToExit, vm.mirrorOf(true));
             invThr.join(argHandler.getWaitTime()*60000);
+            if (invThr.isAlive()) {
+                // The join failed because the invoke never completed.
+                log.complain("TEST FAILED: invoke never completed");
+                tot_res = Consts.TEST_FAILED;
+                // Do a vm.resume() to see if that helps.
+                vm.resume();
+                invThr.join(); // let test time out if this fails
+                return quitDebuggee();
+            }
             log.display("Thread \"" + invThr.getName() + "\" done");
 
             // check threads status after the method invocation
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013t.java
index 7b309f07d19..e90601fe48a 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod013t.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@
  */
 public class invokemethod013t {
     static Log log;
-    private invokemethod013Thr thrs[] =
-        new invokemethod013Thr[invokemethod013.THRDS_NUM-1];
+    private invokemethod013Thr thrs013[] = new invokemethod013Thr[invokemethod013.THRDS_NUM-1];
+    private Thread thrs[] = new Thread[invokemethod013.THRDS_NUM-1];
     private IOPipe pipe;
 
     public static void main(String args[]) {
@@ -87,8 +87,8 @@ private void startThreads() {
         Object readyObj = new Object();
 
         for (int i=0; i < invokemethod013.THRDS_NUM-1; i++) {
-            thrs[i] = new invokemethod013Thr(readyObj,
-                invokemethod013.DEBUGGEE_THRDS[i+1][0]);
+            thrs013[i] = new invokemethod013Thr(readyObj, invokemethod013.DEBUGGEE_THRDS[i+1][0]);
+            thrs[i] = JDIThreadFactory.newThread(thrs013[i]);
             thrs[i].setDaemon(true);
             log.display("Debuggee: starting thread #"
                 + i + " \"" + thrs[i].getName() + "\" ...");
@@ -111,7 +111,7 @@ private void startThreads() {
 
     private void killThreads(int waitTime) {
         for (int i=0; i < invokemethod013.THRDS_NUM-1 ; i++) {
-            thrs[i].doExit = true;
+            thrs013[i].doExit = true;
             try {
                 thrs[i].join(waitTime);
                 log.display("Debuggee: thread #"
@@ -127,7 +127,7 @@ private void killThreads(int waitTime) {
     * This is an auxiliary thread class used to check method
     * invocation in the debugger.
     */
-    class invokemethod013Thr extends Thread {
+    class invokemethod013Thr extends NamedTask {
         volatile boolean doExit = false;
         private Object readyObj;
 
@@ -180,11 +180,15 @@ class invokemethod013tDummyClass {
     volatile boolean isInvoked = false;
 
     long longMeth(long l) throws InterruptedException {
+        /*
+         * WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
+         * be careful not to do anything that might block on another thread. That includes
+         * calling Thread.sleep(), which can be a problem for virtual threads.
+         */
         invokemethod013t.log.display("invokemethod013tDummyClass: longMeth: going to loop");
         isInvoked = true;
         while(!doExit) {
             l--; l++;
-            Thread.currentThread().sleep(400);
         }
         invokemethod013t.log.display("invokemethod013tDummyClass: longMeth: exiting");
         isInvoked = false;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java
index 6115673b71e..91c2d51c787 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,51 +40,6 @@
  *       method.
  *     This test is almost the same as nsk.stress.strace.strace001 except for
  *     the recursive method is a native one.
- * COMMENTS
- * Below assertion is revealed on engineer's build. It is needed to check
- * on a promoted build.
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * Started at: Fri Apr 25 15:47:13 NSK 2003
- * waiting for all threads started ...
- * >>> snapshot 1
- *         checking strace003Thread0(trace elements: 2)
- *         checking strace003Thread1(trace elements: 2)
- *         checking strace003Thread2(trace elements: 3)
- *         checking strace003Thread3(trace elements: 2)
- *         checking strace003Thread4(trace elements: 2)
- *         checking strace003Thread5(trace elements: 2)
- *         checking strace003Thread6(trace elements: 3)
- *         checking strace003Thread7(trace elements: 2)
- * # To suppress the following error report, specify this argument
- * # after -XX: or in .hotspotrc:  SuppressErrorAt=/jniHandles.hpp:157
- * #
- * # HotSpot Virtual Machine Error, assertion failure
- * # Please report this error at
- * # http://java.sun.com/cgi-bin/bugreport.cgi
- * #
- * # Java VM: Java HotSpot(TM) Client VM (1.4.1-internal-debug mixed mode)
- * #
- * # assert(result != ((oop)::badJNIHandleVal), "Pointing to zapped jni handle area")
- * #
- * # Error ID: src/share/vm/runtime/jniHandles.hpp, 157 [ Patched ]
- * #
- * # Problematic Thread: prio=5 tid=0x001b99e8 nid=0xbf runnable
- * #
- * Heap at VM Abort:
- * Heap
- *  def new generation   total 2112K, used 300K [0xf1800000, 0xf1a20000, 0xf1f10000)
- *   eden space 2048K,  14% used [0xf1800000, 0xf184b358, 0xf1a00000)
- *   from space 64K,   0% used [0xf1a00000, 0xf1a00000, 0xf1a10000)
- *   to   space 64K,   0% used [0xf1a10000, 0xf1a10000, 0xf1a20000)
- *  tenured generation   total 1408K, used 0K [0xf1f10000, 0xf2070000, 0xf5800000)
- *    the space 1408K,   0% used [0xf1f10000, 0xf1f10000, 0xf1f10200, 0xf2070000)
- *  compacting perm gen  total 4096K, used 1024K [0xf5800000, 0xf5c00000, 0xf9800000)
- *    the space 4096K,  25% used [0xf5800000, 0xf5900240, 0xf5900400, 0xf5c00000)
- * Dumping core....
- * Abort
- * Finished at: Fri Apr 25 15:48:10 NSK 2003
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
  * @library /vmTestbase
  *          /test/lib
  * @run main/othervm/native nsk.stress.strace.strace003
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java
index c0cc9cf1321..8874289e9cb 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,43 +40,6 @@
  *       method.
  *     This test is almost the same as nsk.stress.strace.strace003 except for
  *     checking is performed for java.lang.Thread.getAllStackTraces() method.
- * COMMENTS
- * java.lang.Thread.getAllStackTraces() is too slow method. So it is not successed
- * to catch an alive thread during execution of this method for the first snapshot
- * and it is needed to check on a promoted build due to the below assertion.
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * waiting for all threads started ...
- * >>> snapshot 1
- * waiting for threads finished
- * # To suppress the following error report, specify this argument
- * # after -XX: or in .hotspotrc:  SuppressErrorAt=/jniHandles.hpp:157
- * #
- * # HotSpot Virtual Machine Error, assertion failure
- * # Please report this error at
- * # http://java.sun.com/cgi-bin/bugreport.cgi
- * #
- * # Java VM: Java HotSpot(TM) Client VM (1.4.1-internal-debug mixed mode)
- * #
- * # assert(result != ((oop)::badJNIHandleVal), "Pointing to zapped jni handle area")
- * #
- * # Error ID: src/share/vm/runtime/jniHandles.hpp, 157 [ Patched ]
- * #
- * # Problematic Thread: prio=5 tid=0x001976e0 nid=0x96 runnable
- * #
- * Heap at VM Abort:
- * Heap
- *  def new generation   total 2112K, used 455K [0xf1800000, 0xf1a20000, 0xf1f10000)
- *   eden space 2048K,  22% used [0xf1800000, 0xf1871f60, 0xf1a00000)
- *   from space 64K,   0% used [0xf1a00000, 0xf1a00000, 0xf1a10000)
- *   to   space 64K,   0% used [0xf1a10000, 0xf1a10000, 0xf1a20000)
- *  tenured generation   total 1408K, used 0K [0xf1f10000, 0xf2070000, 0xf5800000)
- *    the space 1408K,   0% used [0xf1f10000, 0xf1f10000, 0xf1f10200, 0xf2070000)
- *  compacting perm gen  total 4096K, used 1025K [0xf5800000, 0xf5c00000, 0xf9800000)
- *    the space 4096K,  25% used [0xf5800000, 0xf5900660, 0xf5900800, 0xf5c00000)
- * Dumping core....
- * Abort
- * Finished at: Fri Apr 25 18:01:37 NSK 2003
- *
  * @library /vmTestbase
  *          /test/lib
  * @run main/othervm/native nsk.stress.strace.strace004
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.java
index 01f6d824411..5a4a9fae0d6 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent]
  * VM Testbase readme:
  * DESCRIPTION
- *     Single thread loads a tree of classes with signle loader.
+ *     Single thread loads a tree of classes with single loader.
  *     The test is deemed failed if loading attempt fails.
  *     The test repeats until the given number of iterations,
  *     or until EndOfMemoryError.
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.java
index dff11c2e365..42041c94fcf 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent]
  * VM Testbase readme:
  * DESCRIPTION
- *     Multiple threads load a tree of classes with signle loader.
+ *     Multiple threads load a tree of classes with single loader.
  *     The test is deemed failed if loading attempt fails.
  *     The test repeats until the given number of iterations,
  *     or until EndOfMemoryError.
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.java
index 20cc937cfb8..9861f3c051f 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent]
  * VM Testbase readme:
  * DESCRIPTION
- *     Single thread loads a tree of classes with signle loader.
+ *     Single thread loads a tree of classes with single loader.
  *     Then, memory stress is induced to unload the classes.
  *     The test is deemed failed if loading attempt fails;
  *     or if the tested VM crashes.
@@ -51,5 +51,6 @@
  *      -jarpath btree.jar${path.separator}fats.jar
  *      -useSingleLoader
  *      -stressHeap
+ *      -t 1
  */
 
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.java
index 8e1720831ec..507abcef278 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent]
  * VM Testbase readme:
  * DESCRIPTION
- *     Multiple threads load a tree of classes with signle loader.
+ *     Multiple threads load a tree of classes with single loader.
  *     Then, memory stress is induced to unload the classes.
  *     The test is deemed failed if loading attempt fails;
  *     or if the tested VM crashes.
diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt
index e94f267a38c..0af3d6d42a9 100644
--- a/test/jdk/ProblemList.txt
+++ b/test/jdk/ProblemList.txt
@@ -523,8 +523,6 @@ javax/management/MBeanServer/OldMBeanServerTest.java            8030957 aix-all
 
 javax/management/monitor/DerivedGaugeMonitorTest.java           8042211 generic-all
 
-javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215 generic-all
-
 javax/management/remote/mandatory/connection/RMIConnector_NPETest.java 8267887 generic-all
 
 ############################################################################
@@ -550,7 +548,6 @@ java/nio/channels/AsynchronousSocketChannel/StressLoopback.java 8211851 aix-ppc6
 
 java/nio/channels/DatagramChannel/ManySourcesAndTargets.java    8264385 macosx-aarch64
 
-java/nio/channels/FileChannel/FileExtensionAndMap.java          8297292 generic-all
 jdk/nio/zipfs/TestLocOffsetFromZip64EF.java                     8301183 linux-all
 
 ############################################################################
@@ -586,8 +583,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java            8161536 generic-
 
 sun/security/tools/keytool/ListKeychainStore.sh                 8156889 macosx-all
 
-javax/net/ssl/SSLEngine/EngineCloseOnAlert.java                 8298868 generic-all
-
 sun/security/smartcardio/TestChannel.java                       8039280 generic-all
 sun/security/smartcardio/TestConnect.java                       8039280 generic-all
 sun/security/smartcardio/TestConnectAgain.java                  8039280 generic-all
diff --git a/test/jdk/com/sun/net/httpserver/bugs/8300268/MaxIdleConnectionsTest.java b/test/jdk/com/sun/net/httpserver/bugs/8300268/MaxIdleConnectionsTest.java
new file mode 100644
index 00000000000..015f0773b07
--- /dev/null
+++ b/test/jdk/com/sun/net/httpserver/bugs/8300268/MaxIdleConnectionsTest.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8300268
+ * @library /test/lib
+ * @modules jdk.httpserver/sun.net.httpserver
+ * @build jdk.httpserver/sun.net.httpserver.HttpServerAccess MaxIdleConnectionsTest
+ * @run junit/othervm -Dsun.net.httpserver.maxIdleConnections=4 MaxIdleConnectionsTest
+ */
+
+import com.sun.net.httpserver.HttpServer;
+import jdk.test.lib.net.URIBuilder;
+import sun.net.httpserver.HttpServerAccess;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class MaxIdleConnectionsTest {
+
+    HttpServer server;
+    int maxIdleConnections, totalConnections;
+    CountDownLatch reqFinishedProcessing;
+
+    @BeforeAll
+    void before() throws Exception {
+        maxIdleConnections = Integer.getInteger("sun.net.httpserver.maxIdleConnections");
+        totalConnections = maxIdleConnections + 1;
+        reqFinishedProcessing = new CountDownLatch(totalConnections);
+        server = startServer(reqFinishedProcessing);
+    }
+
+    @AfterAll
+    void after() throws Exception {
+        server.stop(0);
+    }
+
+    // Issue one too many requests and assert that the idle connection pool doesn't
+    // exceed maxIdleConnections
+    @Test
+    public void test() throws Exception {
+        final int port = server.getAddress().getPort();
+
+        final List<Future<Void>> responses = new ArrayList<>();
+        try (final ExecutorService requestIssuer = Executors.newFixedThreadPool(totalConnections)) {
+            for (int i = 1; i <= totalConnections; i++) {
+                URL requestURL = URIBuilder.newBuilder()
+                        .scheme("http")
+                        .loopback()
+                        .port(port)
+                        .path("/MaxIdleConnectionTest/" + i)
+                        .toURL();
+                final Future<Void> result = requestIssuer.submit(() -> {
+                    System.out.println("Issuing request " + requestURL);
+                    final URLConnection conn = requestURL.openConnection();
+                    try (final InputStream is = conn.getInputStream()) {
+                        is.readAllBytes();
+                    }
+                    return null;
+                });
+                responses.add(result);
+            }
+            // wait for all the requests to reach each of the handlers
+            System.out.println("Waiting for all " + totalConnections + " requests to reach" +
+                    " the server side request handler");
+            reqFinishedProcessing.await();
+        }
+
+        // verify every request got served before checking idle count
+        for (int i = 0; i < totalConnections; i++) {
+            responses.get(i).get();
+            System.out.println("Received successful response for request " + i);
+        }
+
+        // assert that the limit set by maxIdleConnections was not exceeded
+        int idleConnectionCount = HttpServerAccess.getIdleConnectionCount(server);
+        System.out.println("count " + idleConnectionCount);
+        assertTrue(maxIdleConnections >= idleConnectionCount,
+                String.format("Too many idle connections: %d, limit: %d", idleConnectionCount, maxIdleConnections));
+    }
+
+    // Create HttpServer that will handle requests with multiple threads
+    private static HttpServer startServer(final CountDownLatch reqFinishedProcessing) throws IOException {
+        final var bindAddr = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
+        final HttpServer server = HttpServer.create(bindAddr, 0);
+
+        final AtomicInteger threadId = new AtomicInteger();
+        server.setExecutor(Executors.newCachedThreadPool(r -> {
+            final Thread t = new Thread(r);
+            t.setName("http-request-handler-" + threadId.incrementAndGet());
+            t.setDaemon(true);
+            return t;
+        }));
+
+        server.createContext("/MaxIdleConnectionTest/", (exchange) -> {
+            System.out.println("Request " + exchange.getRequestURI() + " received");
+            System.out.println("Sending response for request " + exchange.getRequestURI() + " from " + exchange.getRemoteAddress());
+            reqFinishedProcessing.countDown();
+            exchange.sendResponseHeaders(200, 0);
+            exchange.getResponseBody().close();
+        });
+
+        server.start();
+        System.out.println("Server started at address " + server.getAddress());
+        return server;
+    }
+}
diff --git a/test/jdk/com/sun/net/httpserver/bugs/8300268/jdk.httpserver/sun/net/httpserver/HttpServerAccess.java b/test/jdk/com/sun/net/httpserver/bugs/8300268/jdk.httpserver/sun/net/httpserver/HttpServerAccess.java
new file mode 100644
index 00000000000..7df9426381c
--- /dev/null
+++ b/test/jdk/com/sun/net/httpserver/bugs/8300268/jdk.httpserver/sun/net/httpserver/HttpServerAccess.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.net.httpserver;
+
+import com.sun.net.httpserver.HttpServer;
+import java.lang.reflect.Field;
+import java.util.Set;
+
+public class HttpServerAccess {
+
+   // Given a HttpServer object get the number of idleConnections it currently has
+    public static int getIdleConnectionCount(HttpServer server) throws Exception{
+        // Use reflection to get server object which is HTTPServerImpl
+        Field serverField = server.getClass().getDeclaredField("server");
+        serverField.setAccessible(true);
+
+        // Get the actual serverImpl class, then get the IdleConnection Field
+        Object serverImpl = serverField.get(server);
+        Field idleConnectionField = serverImpl.getClass().getDeclaredField("idleConnections");
+        idleConnectionField.setAccessible(true);
+
+        // Finally get the IdleConnection object which is of type Set<HttpConnection>
+        Object idleConnectionSet = idleConnectionField.get(serverImpl);
+        Set<HttpConnection> idleConnectionPool = (Set<HttpConnection>) idleConnectionSet;
+        return idleConnectionPool.size();
+    }
+}
diff --git a/test/jdk/java/awt/AppContext/ApplicationThreadsStop/java.policy b/test/jdk/java/awt/AppContext/ApplicationThreadsStop/java.policy
deleted file mode 100644
index 0ca7756397b..00000000000
--- a/test/jdk/java/awt/AppContext/ApplicationThreadsStop/java.policy
+++ /dev/null
@@ -1,5 +0,0 @@
-grant {
-    permission java.lang.RuntimePermission "accessClassInPackage.sun.awt";
-    permission java.awt.AWTPermission "createRobot";
-    permission java.util.PropertyPermission "AWT.EventQueueClass", "read";
-};
diff --git a/test/jdk/java/awt/image/VolatileImage/ReportRenderingError.java b/test/jdk/java/awt/image/VolatileImage/ReportRenderingError.java
new file mode 100644
index 00000000000..ee8d235fa2c
--- /dev/null
+++ b/test/jdk/java/awt/image/VolatileImage/ReportRenderingError.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+
+/*
+ * @test id=default
+ * @bug 8272288
+ * @key headful
+ * @summary Broken rendering should be reported by the contentsLost()
+ *
+ * @run main/othervm ReportRenderingError
+ */
+
+/*
+ * @test id=windows
+ * @bug 8272288
+ * @key headful
+ * @summary Broken rendering should be reported by the contentsLost()
+ * @requires (os.family == "windows")
+ *
+ * @run main/othervm -Dsun.java2d.opengl=True ReportRenderingError
+ * @run main/othervm -Dsun.java2d.d3d=True    ReportRenderingError
+ * @run main/othervm -Dsun.java2d.d3d=false   ReportRenderingError
+ */
+
+/*
+ * @test id=macos
+ * @bug 8272288
+ * @key headful
+ * @summary Broken rendering should be reported by the contentsLost()
+ *
+ * @requires (os.family == "mac")
+ * @run main/othervm -Dsun.java2d.opengl=True ReportRenderingError
+ * @run main/othervm -Dsun.java2d.metal=True  ReportRenderingError
+ */
+
+/*
+ * @test id=linux
+ * @bug 8272288
+ * @key headful
+ * @summary Broken rendering should be reported by the contentsLost()
+ *
+ * @requires (os.family == "linux")
+ * @run main/othervm -Dsun.java2d.opengl=True   ReportRenderingError
+ * @run main/othervm -Dsun.java2d.xrender=True  ReportRenderingError
+ * @run main/othervm -Dsun.java2d.xrender=false ReportRenderingError
+ */
+public final class ReportRenderingError {
+
+    public static void main(String[] args) {
+        var gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
+                                    .getDefaultScreenDevice()
+                                    .getDefaultConfiguration();
+        var vi = gc.createCompatibleVolatileImage(10, 10);
+
+        Image image = new EmptyImage();
+        BufferedImage snapshot;
+        int attempt = 0;
+        do {
+            vi.validate(gc);
+            Graphics2D g = vi.createGraphics();
+            g.setColor(Color.RED);
+            g.drawImage(image, 0, 0, null); // <- can cause InvalidPipeException
+            g.fillRect(0, 0, vi.getWidth(), vi.getHeight());
+            g.dispose();
+            snapshot = vi.getSnapshot();
+        } while (vi.contentsLost() && (++attempt <= 10));
+
+        if (vi.contentsLost()) {
+            System.out.println("Content is lost, skip the pixel validation");
+        } else {
+            if (snapshot.getRGB(5, 5) != Color.RED.getRGB()) {
+                throw new RuntimeException("Test failed");
+            }
+        }
+    }
+
+    private static final class EmptyImage extends Image {
+        @Override
+        public int getWidth(ImageObserver observer) {
+            return 10;
+        }
+
+        @Override
+        public int getHeight(ImageObserver observer) {
+            return 10;
+        }
+
+        @Override
+        public ImageProducer getSource() {
+            return null;
+        }
+
+        @Override
+        public Graphics getGraphics() {
+            return null;
+        }
+
+        @Override
+        public Object getProperty(String name, ImageObserver observer) {
+            return null;
+        }
+    }
+}
diff --git a/test/jdk/java/lang/Math/Clamp.java b/test/jdk/java/lang/Math/Clamp.java
new file mode 100644
index 00000000000..5ddca508383
--- /dev/null
+++ b/test/jdk/java/lang/Math/Clamp.java
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 8301226
+   @summary Add clamp() methods to java.lang.Math
+ */
+
+
+public class Clamp {
+    public static void main(String[] args) {
+        int failures = 0;
+
+        failures += testIntClamp();
+        failures += testLongClamp();
+        failures += testDoubleClamp();
+        failures += testFloatClamp();
+
+        if (failures > 0) {
+            System.err.println("Testing clamp incurred " + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+    private static int testIntClamp() {
+        int failures = 0;
+        long[][] tests = {
+                // value, min, max, expected
+                {0, 1, 2, 1},
+                {0, 0, 2, 0},
+                {1, 0, 2, 1},
+                {2, 0, 2, 2},
+                {3, 0, 2, 2},
+                {0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0},
+                {Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE},
+                {Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE},
+                {Long.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE},
+                {Long.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE},
+                {0, 1, 1, 1},
+                {Long.MAX_VALUE, 1, 1, 1}
+        };
+        long[][] exceptionTests = {
+                // value, min, max
+                {1, 2, 0},
+                {1, Integer.MAX_VALUE, Integer.MIN_VALUE}
+        };
+        for (long[] test : tests) {
+            long value = test[0];
+            int min = Math.toIntExact(test[1]);
+            int max = Math.toIntExact(test[2]);
+            int expected = Math.toIntExact(test[3]);
+            failures += checkEquals("(int) Math.clamp(" + value + ", " + min + ", " + max + ")", Math.clamp(value, min, max), expected);
+            failures += checkEquals("(int) StrictMath.clamp(" + value + ", " + min + ", " + max + ")", StrictMath.clamp(value, min, max), expected);
+        }
+        for (long[] test : exceptionTests) {
+            long value = test[0];
+            int min = Math.toIntExact(test[1]);
+            int max = Math.toIntExact(test[2]);
+            failures += checkIllegalArgumentException("(int) Math.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> Math.clamp(value, min, max));
+            failures += checkIllegalArgumentException("(int) StrictMath.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> StrictMath.clamp(value, min, max));
+        }
+        return failures;
+    }
+
+    private static int testLongClamp() {
+        int failures = 0;
+        long[][] tests = {
+                // value, min, max, expected
+                {0L, 1L, 2L, 1L},
+                {0L, 0L, 2L, 0L},
+                {1L, 0L, 2L, 1L},
+                {2L, 0L, 2L, 2L},
+                {3L, 0L, 2L, 2L},
+                {0L, Long.MIN_VALUE, Long.MAX_VALUE, 0},
+                {Long.MIN_VALUE, Long.MIN_VALUE, Long.MAX_VALUE, Long.MIN_VALUE},
+                {Long.MAX_VALUE, Long.MIN_VALUE, Long.MAX_VALUE, Long.MAX_VALUE},
+                {0, 1, 1, 1},
+                {Long.MAX_VALUE, 1, 1, 1}
+        };
+        long[][] exceptionTests = {
+                // value, min, max
+                {1L, 2L, 0L},
+                {1, Long.MAX_VALUE, Long.MIN_VALUE}
+        };
+        for (long[] test : tests) {
+            long value = test[0];
+            long min = test[1];
+            long max = test[2];
+            long expected = test[3];
+            failures += checkEquals("(long) Math.clamp(" + value + ", " + min + ", " + max + ")", Math.clamp(value, min, max), expected);
+            failures += checkEquals("(long) StrictMath.clamp(" + value + ", " + min + ", " + max + ")", StrictMath.clamp(value, min, max), expected);
+        }
+        for (long[] test : exceptionTests) {
+            long value = test[0];
+            long min = test[1];
+            long max = test[2];
+            failures += checkIllegalArgumentException("(long) Math.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> Math.clamp(value, min, max));
+            failures += checkIllegalArgumentException("(long) StrictMath.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> StrictMath.clamp(value, min, max));
+        }
+        return failures;
+    }
+
+    private static int testDoubleClamp() {
+        int failures = 0;
+        double[][] tests = {
+                // value, min, max, expected
+                {-0.1, 0.0, 0.5, 0.0},
+                {-0.0, 0.0, 0.5, 0.0},
+                {0.0, 0.0, 0.5, 0.0},
+                {Double.MIN_VALUE, 0.0, 0.5, Double.MIN_VALUE},
+                {0.2, 0.0, 0.5, 0.2},
+                {Math.nextDown(0.5), 0.0, 0.5, Math.nextDown(0.5)},
+                {0.5, 0.0, 0.5, 0.5},
+                {Math.nextUp(0.5), 0.0, 0.5, 0.5},
+                {0.6, 0.0, 0.5, 0.5},
+
+                {Double.MAX_VALUE, 0.0, Double.POSITIVE_INFINITY, Double.MAX_VALUE},
+                {Double.POSITIVE_INFINITY, 0.0, Double.MAX_VALUE, Double.MAX_VALUE},
+                {-Double.MAX_VALUE, Double.NEGATIVE_INFINITY, 0.0, -Double.MAX_VALUE},
+                {Double.NEGATIVE_INFINITY, -Double.MAX_VALUE, 0.0, -Double.MAX_VALUE},
+
+                {-1.0, -0.0, 0.0, -0.0},
+                {-0.0, -0.0, 0.0, -0.0},
+                {0.0, -0.0, 0.0, 0.0},
+                {1.0, -0.0, 0.0, 0.0},
+                {-1.0, 0.0, 0.0, 0.0},
+                {-0.0, 0.0, 0.0, 0.0},
+                {0.0, 0.0, 0.0, 0.0},
+                {1.0, 0.0, 0.0, 0.0},
+                {-1.0, -0.0, -0.0, -0.0},
+                {-0.0, -0.0, -0.0, -0.0},
+                {0.0, -0.0, -0.0, -0.0},
+                {1.0, -0.0, -0.0, -0.0},
+
+                {Double.NaN, 0.0, 1.0, Double.NaN},
+                {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN}
+        };
+        double[][] exceptionTests = {
+                // value, min, max
+                {0.0, Double.NaN, Double.NaN},
+                {0.0, 0.0, Double.NaN},
+                {0.0, Double.NaN, 0.0},
+                {Double.NaN, 1.0, 0.0},
+                {0.0, 0.0, -0.0},
+                {0.0, 1.0, -1.0}
+        };
+        for (double[] test : tests) {
+            double value = test[0];
+            double min = test[1];
+            double max = test[2];
+            double expected = test[3];
+            failures += checkEquals("(double) Math.clamp(" + value + ", " + min + ", " + max + ")", Math.clamp(value, min, max), expected);
+            failures += checkEquals("(double) StrictMath.clamp(" + value + ", " + min + ", " + max + ")", StrictMath.clamp(value, min, max), expected);
+        }
+        for (double[] test : exceptionTests) {
+            double value = test[0];
+            double min = test[1];
+            double max = test[2];
+            failures += checkIllegalArgumentException("(double) Math.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> Math.clamp(value, min, max));
+            failures += checkIllegalArgumentException("(double) StrictMath.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> StrictMath.clamp(value, min, max));
+        }
+        return failures;
+    }
+
+    private static int testFloatClamp() {
+        int failures = 0;
+        float[][] tests = {
+                // value, min, max, expected
+                {-0.1f, 0.0f, 0.5f, 0.0f},
+                {-0.0f, 0.0f, 0.5f, 0.0f},
+                {0.0f, 0.0f, 0.5f, 0.0f},
+                {Float.MIN_VALUE, 0.0f, 0.5f, Float.MIN_VALUE},
+                {0.2f, 0.0f, 0.5f, 0.2f},
+                {Math.nextDown(0.5f), 0.0f, 0.5f, Math.nextDown(0.5f)},
+                {0.5f, 0.0f, 0.5f, 0.5f},
+                {Math.nextUp(0.5f), 0.0f, 0.5f, 0.5f},
+                {0.6f, 0.0f, 0.5f, 0.5f},
+
+                {Float.MAX_VALUE, 0.0f, Float.POSITIVE_INFINITY, Float.MAX_VALUE},
+                {Float.POSITIVE_INFINITY, 0.0f, Float.MAX_VALUE, Float.MAX_VALUE},
+                {-Float.MAX_VALUE, Float.NEGATIVE_INFINITY, 0.0f, -Float.MAX_VALUE},
+                {Float.NEGATIVE_INFINITY, -Float.MAX_VALUE, 0.0f, -Float.MAX_VALUE},
+
+                {-1.0f, -0.0f, 0.0f, -0.0f},
+                {-0.0f, -0.0f, 0.0f, -0.0f},
+                {0.0f, -0.0f, 0.0f, 0.0f},
+                {1.0f, -0.0f, 0.0f, 0.0f},
+                {-1.0f, 0.0f, 0.0f, 0.0f},
+                {-0.0f, 0.0f, 0.0f, 0.0f},
+                {0.0f, 0.0f, 0.0f, 0.0f},
+                {1.0f, 0.0f, 0.0f, 0.0f},
+                {-1.0f, -0.0f, -0.0f, -0.0f},
+                {-0.0f, -0.0f, -0.0f, -0.0f},
+                {0.0f, -0.0f, -0.0f, -0.0f},
+                {1.0f, -0.0f, -0.0f, -0.0f},
+
+                {Float.NaN, 0.0f, 1.0f, Float.NaN},
+                {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NaN}
+        };
+        float[][] exceptionTests = {
+                // value, min, max
+                {0.0f, Float.NaN, Float.NaN},
+                {0.0f, 0.0f, Float.NaN},
+                {0.0f, Float.NaN, 0.0f},
+                {Float.NaN, 1.0f, 0.0f},
+                {0.0f, 0.0f, -0.0f},
+                {0.0f, 1.0f, -1.0f}
+        };
+        for (float[] test : tests) {
+            float value = test[0];
+            float min = test[1];
+            float max = test[2];
+            float expected = test[3];
+            failures += checkEquals("(float) Math.clamp(" + value + ", " + min + ", " + max + ")", Math.clamp(value, min, max), expected);
+            failures += checkEquals("(float) StrictMath.clamp(" + value + ", " + min + ", " + max + ")", StrictMath.clamp(value, min, max), expected);
+        }
+        for (float[] test : exceptionTests) {
+            float value = test[0];
+            float min = test[1];
+            float max = test[2];
+            failures += checkIllegalArgumentException("(float) Math.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> Math.clamp(value, min, max));
+            failures += checkIllegalArgumentException("(float) StrictMath.clamp(" + value + ", " + min + ", " + max + ")",
+                    () -> StrictMath.clamp(value, min, max));
+        }
+        return failures;
+    }
+
+    private static int checkIllegalArgumentException(String what, Runnable r) {
+        try {
+            r.run();
+        }
+        catch (IllegalArgumentException ex) {
+            return 0;
+        }
+        System.err.println(what+": missing expected exception");
+        return 1;
+    }
+
+    private static int checkEquals(String what, double actual, double expected) {
+        if (Double.doubleToLongBits(actual) != Double.doubleToLongBits(expected)) {
+            System.err.println(what + ": expected = " + expected + "; actual = " + actual);
+            return 1;
+        }
+        return 0;
+    }
+
+    private static int checkEquals(String what, long actual, long expected) {
+        if (actual != expected) {
+            System.err.println(what + ": expected = " + expected + "; actual = " + actual);
+            return 1;
+        }
+        return 0;
+    }
+}
diff --git a/test/jdk/java/lang/Math/LogTests.java b/test/jdk/java/lang/Math/LogTests.java
new file mode 100644
index 00000000000..eaaa58d80ed
--- /dev/null
+++ b/test/jdk/java/lang/Math/LogTests.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8301202
+ * @build Tests
+ * @build LogTests
+ * @run main LogTests
+ * @summary Tests for {Math, StrictMath}.log
+ */
+
+public class LogTests {
+    private LogTests(){}
+
+    public static void main(String... args) {
+        int failures = 0;
+
+        failures += testLogSpecialCases();
+
+        if (failures > 0) {
+            System.err.println("Testing log incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+    private static final double infinityD = Double.POSITIVE_INFINITY;
+    private static final double NaNd = Double.NaN;
+
+    /**
+     * From the spec for Math.log:
+     * "Special cases:
+     *
+     * If the argument is NaN or less than zero, then the result is NaN.
+     * If the argument is positive infinity, then the result is positive infinity.
+     * If the argument is positive zero or negative zero, then the result is negative infinity.
+     * If the argument is 1.0, then the result is positive zero.
+     */
+    private static int testLogSpecialCases() {
+        int failures = 0;
+
+        double [][] testCases = {
+            {Double.NaN,                NaNd},
+            {Double.NEGATIVE_INFINITY,  NaNd},
+            {-Double.MAX_VALUE,         NaNd},
+            {-1.0,                      NaNd},
+            {-Double.MIN_NORMAL,        NaNd},
+            {-Double.MIN_VALUE,         NaNd},
+
+            {Double.POSITIVE_INFINITY,  infinityD},
+
+            {-0.0,                      -infinityD},
+            {+0.0,                      -infinityD},
+
+            {+1.0,                      0.0},
+        };
+
+        for(int i = 0; i < testCases.length; i++) {
+            failures += testLogCase(testCases[i][0],
+                                    testCases[i][1]);
+        }
+
+        return failures;
+    }
+
+    private static int testLogCase(double input, double expected) {
+        int failures=0;
+
+        failures+=Tests.test("Math.log",       input, Math::log,       expected);
+        failures+=Tests.test("StrictMath.log", input, StrictMath::log, expected);
+
+        return failures;
+    }
+}
diff --git a/test/jdk/java/lang/StrictMath/ExhaustingTests.java b/test/jdk/java/lang/StrictMath/ExhaustingTests.java
new file mode 100644
index 00000000000..09e182d4e16
--- /dev/null
+++ b/test/jdk/java/lang/StrictMath/ExhaustingTests.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8301833
+ * @build Tests
+ * @build FdlibmTranslit
+ * @build ExhaustingTests
+ * @run main ExhaustingTests
+ * @summary Compare StrictMath.foo and FdlibmTranslit.foo for many inputs.
+ */
+
+/*
+ * Note on usage: for more exhaustive testing to help validate changes
+ * to StrictMath, the DEFAULT_SHIFT setting should be set to 0. This
+ * will test all float values against the unary methods. Running all
+ * the float values for a single method takes on the order of a minute
+ * or two. The default setting is a shift of 10, meaning every 1024th
+ * float value is tested and the overall test runs within the typical
+ * time expectations of a tier 1 test.
+ */
+
+import java.util.function.DoubleBinaryOperator;
+import java.util.function.DoubleUnaryOperator;
+
+public class ExhaustingTests {
+    public static void main(String... args) {
+        long failures = 0;
+
+        failures += testUnaryMethods();
+        failures += testBinaryMethods();
+
+        if (failures > 0) {
+            System.err.println("Comparing StrictMath and FdlibmTranslit"
+                               + " incurred " + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+    private static final int DEFAULT_SHIFT = 10;
+
+    /**
+     * Test the unary (one-argument) StrictMath methods from FDLIBM.
+     */
+    private static long testUnaryMethods() {
+        long failures = 0;
+        UnaryTestCase[] testCases = {
+         // new UnaryTestCase("sqrt",  FdlibmTranslit::sqrt,  StrictMath::sqrt,  DEFAULT_SHIFT),
+            new UnaryTestCase("cbrt",  FdlibmTranslit::cbrt,  StrictMath::cbrt,  DEFAULT_SHIFT),
+
+            new UnaryTestCase("log",   FdlibmTranslit::log,   StrictMath::log,   DEFAULT_SHIFT),
+            new UnaryTestCase("log10", FdlibmTranslit::log10, StrictMath::log10, DEFAULT_SHIFT),
+            new UnaryTestCase("log1p", FdlibmTranslit::log1p, StrictMath::log1p, DEFAULT_SHIFT),
+
+         // new UnaryTestCase("exp",   FdlibmTranslit::exp,   StrictMath::exp,   DEFAULT_SHIFT),
+            new UnaryTestCase("expm1", FdlibmTranslit::expm1, StrictMath::expm1, DEFAULT_SHIFT),
+
+         // new UnaryTestCase("sinh",  FdlibmTranslit::sinh,  StrictMath::sinh,  DEFAULT_SHIFT),
+         // new UnaryTestCase("cosh",  FdlibmTranslit::cosh,  StrictMath::cosh,  DEFAULT_SHIFT),
+         // new UnaryTestCase("tanh",  FdlibmTranslit::tanh,  StrictMath::tanh,  DEFAULT_SHIFT),
+
+         // new UnaryTestCase("sin",   FdlibmTranslit::sin,   StrictMath::sin,   DEFAULT_SHIFT),
+         // new UnaryTestCase("cos",   FdlibmTranslit::cos,   StrictMath::cos,   DEFAULT_SHIFT),
+         // new UnaryTestCase("tan",   FdlibmTranslit::tan,   StrictMath::tan,   DEFAULT_SHIFT),
+
+         // new UnaryTestCase("asin",  FdlibmTranslit::asin,  StrictMath::asin,  DEFAULT_SHIFT),
+         // new UnaryTestCase("acos",  FdlibmTranslit::acos,  StrictMath::acos,  DEFAULT_SHIFT),
+         // new UnaryTestCase("atan",  FdlibmTranslit::atan,  StrictMath::atan,  DEFAULT_SHIFT),
+        };
+
+        for (var testCase : testCases) {
+            System.out.println("Testing " + testCase.name());
+            System.out.flush();
+            int i = Integer.MAX_VALUE; // overflow to Integer.MIN_VALUE at start of loop
+            int increment = 1 << testCase.shiftDistance;
+            do {
+                i += increment;
+                double input = (double)Float.intBitsToFloat(i);
+                failures += Tests.test(testCase.name(),
+                                       input,
+                                       testCase.strictMath,
+                                       testCase.translit.applyAsDouble(input));
+            } while (i != Integer.MAX_VALUE);
+        }
+        return failures;
+    }
+
+    private static record UnaryTestCase(String name,
+                                        DoubleUnaryOperator translit,
+                                        DoubleUnaryOperator strictMath,
+                                        int shiftDistance) {
+        UnaryTestCase {
+            if (shiftDistance < 0 || shiftDistance >= 31) {
+                throw new IllegalArgumentException("Shift out of range");
+            }
+        }
+    }
+
+    /**
+     * Test the binary (two-argument) StrictMath methods from FDLIBM.
+     */
+    private static long testBinaryMethods() {
+        long failures = 0;
+        // Note: pow does _not_ have translit a port
+
+        // Shift of 16 for a binary method gives comparable running
+        // time to exhaustive testing of a unary method (testing every
+        // 2^16 floating point values over two arguments is 2^32
+        // probes).
+        BinaryTestCase[] testCases = {
+            new BinaryTestCase("hypot", FdlibmTranslit::hypot, StrictMath::hypot, 20, 20),
+         // new BinaryTestCase("atan2", FdlibmTranslit::atan2, StrictMath::atan2, 20, 20),
+        };
+
+        for (var testCase : testCases) {
+            System.out.println("Testing " + testCase.name());
+            System.out.flush();
+
+            int iIncrement = 1 << testCase.xShift;
+            int jIncrement = 1 << testCase.yShift;
+
+            for (long i = Integer.MIN_VALUE; i <= Integer.MAX_VALUE; i += iIncrement) {
+                for (long j = Integer.MIN_VALUE; j <= Integer.MAX_VALUE; j += jIncrement) {
+                    double input1 = (double)Float.intBitsToFloat((int)i);
+                    double input2 = (double)Float.intBitsToFloat((int)j);
+                    failures += Tests.test(testCase.name(),
+                                           input1, input2,
+                                           testCase.strictMath,
+                                           testCase.translit.applyAsDouble(input1, input2));
+                }
+            }
+        }
+        return failures;
+    }
+
+    private static record BinaryTestCase(String name,
+                                         DoubleBinaryOperator translit,
+                                         DoubleBinaryOperator strictMath,
+                                         int xShift,
+                                         int yShift) {
+        BinaryTestCase {
+            if (xShift < 0 || xShift >= 31 ||
+                yShift < 0 || yShift >= 31 ) {
+                throw new IllegalArgumentException("Shift out of range");
+            }
+        }
+    }
+}
diff --git a/test/jdk/java/lang/StrictMath/FdlibmTranslit.java b/test/jdk/java/lang/StrictMath/FdlibmTranslit.java
index 565bd69dc2f..d20dbb16bb1 100644
--- a/test/jdk/java/lang/StrictMath/FdlibmTranslit.java
+++ b/test/jdk/java/lang/StrictMath/FdlibmTranslit.java
@@ -78,6 +78,10 @@ public static double cbrt(double x) {
         return Cbrt.compute(x);
     }
 
+    public static double log(double x) {
+        return Log.compute(x);
+    }
+
     public static double log10(double x) {
         return Log10.compute(x);
     }
@@ -401,6 +405,125 @@ else if(hx < 0x3e300000)  {     /* when |x|<2**-28 */
         }
     }
 
+    /**
+     * Return the logarithm of x
+     *
+     * Method :
+     *   1. Argument Reduction: find k and f such that
+     *                      x = 2^k * (1+f),
+     *         where  sqrt(2)/2 < 1+f < sqrt(2) .
+     *
+     *   2. Approximation of log(1+f).
+     *      Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+     *               = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+     *               = 2s + s*R
+     *      We use a special Reme algorithm on [0,0.1716] to generate
+     *      a polynomial of degree 14 to approximate R The maximum error
+     *      of this polynomial approximation is bounded by 2**-58.45. In
+     *      other words,
+     *                      2      4      6      8      10      12      14
+     *          R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s  +Lg6*s  +Lg7*s
+     *      (the values of Lg1 to Lg7 are listed in the program)
+     *      and
+     *          |      2          14          |     -58.45
+     *          | Lg1*s +...+Lg7*s    -  R(z) | <= 2
+     *          |                             |
+     *      Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+     *      In order to guarantee error in log below 1ulp, we compute log
+     *      by
+     *              log(1+f) = f - s*(f - R)        (if f is not too large)
+     *              log(1+f) = f - (hfsq - s*(hfsq+R)).     (better accuracy)
+     *
+     *      3. Finally,  log(x) = k*ln2 + log(1+f).
+     *                          = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+     *         Here ln2 is split into two floating point number:
+     *                      ln2_hi + ln2_lo,
+     *         where n*ln2_hi is always exact for |n| < 2000.
+     *
+     * Special cases:
+     *      log(x) is NaN with signal if x < 0 (including -INF) ;
+     *      log(+INF) is +INF; log(0) is -INF with signal;
+     *      log(NaN) is that NaN with no signal.
+     *
+     * Accuracy:
+     *      according to an error analysis, the error is always less than
+     *      1 ulp (unit in the last place).
+     *
+     * Constants:
+     * The hexadecimal values are the intended ones for the following
+     * constants. The decimal values may be used, provided that the
+     * compiler will convert from decimal to binary accurately enough
+     * to produce the hexadecimal values shown.
+     */
+    private static final class Log {
+        private static final  double
+            ln2_hi  =  6.93147180369123816490e-01,  /* 3fe62e42 fee00000 */
+            ln2_lo  =  1.90821492927058770002e-10,  /* 3dea39ef 35793c76 */
+            two54   =  1.80143985094819840000e+16,  /* 43500000 00000000 */
+            Lg1 = 6.666666666666735130e-01,  /* 3FE55555 55555593 */
+            Lg2 = 3.999999999940941908e-01,  /* 3FD99999 9997FA04 */
+            Lg3 = 2.857142874366239149e-01,  /* 3FD24924 94229359 */
+            Lg4 = 2.222219843214978396e-01,  /* 3FCC71C5 1D8E78AF */
+            Lg5 = 1.818357216161805012e-01,  /* 3FC74664 96CB03DE */
+            Lg6 = 1.531383769920937332e-01,  /* 3FC39A09 D078C69F */
+            Lg7 = 1.479819860511658591e-01;  /* 3FC2F112 DF3E5244 */
+
+        private static double zero   =  0.0;
+
+        static double compute(double x) {
+            double hfsq,f,s,z,R,w,t1,t2,dk;
+            int k,hx,i,j;
+            /*unsigned*/ int lx;
+
+            hx = __HI(x);           /* high word of x */
+            lx = __LO(x);           /* low  word of x */
+
+            k=0;
+            if (hx < 0x00100000) {                  /* x < 2**-1022  */
+                if (((hx&0x7fffffff)|lx)==0)
+                    return -two54/zero;             /* log(+-0)=-inf */
+                if (hx<0) return (x-x)/zero;        /* log(-#) = NaN */
+                k -= 54; x *= two54; /* subnormal number, scale up x */
+                hx = __HI(x);               /* high word of x */
+            }
+            if (hx >= 0x7ff00000) return x+x;
+            k += (hx>>20)-1023;
+            hx &= 0x000fffff;
+            i = (hx+0x95f64)&0x100000;
+            // __HI(x) = hx|(i^0x3ff00000);    /* normalize x or x/2 */
+            x =__HI(x, hx|(i^0x3ff00000));    /* normalize x or x/2 */
+            k += (i>>20);
+            f = x-1.0;
+            if((0x000fffff&(2+hx))<3) {     /* |f| < 2**-20 */
+                if(f==zero) {
+                    if (k==0) return zero;
+                    else {dk=(double)k; return dk*ln2_hi+dk*ln2_lo;}
+                }
+                R = f*f*(0.5-0.33333333333333333*f);
+                if(k==0) return f-R; else {dk=(double)k;
+                    return dk*ln2_hi-((R-dk*ln2_lo)-f);}
+            }
+            s = f/(2.0+f);
+            dk = (double)k;
+            z = s*s;
+            i = hx-0x6147a;
+            w = z*z;
+            j = 0x6b851-hx;
+            t1= w*(Lg2+w*(Lg4+w*Lg6));
+            t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
+            i |= j;
+            R = t2+t1;
+            if(i>0) {
+                hfsq=0.5*f*f;
+                if(k==0) return f-(hfsq-s*(hfsq+R)); else
+                    return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
+            } else {
+                if(k==0) return f-s*(f-R); else
+                    return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
+            }
+        }
+    }
+
     /**
      * Return the base 10 logarithm of x
      *
@@ -464,7 +587,7 @@ public static double compute(double x) {
             hx = (hx&0x000fffff)|((0x3ff-i)<<20);
             y  = (double)(k+i);
             x = __HI(x, hx); //original: __HI(x) = hx;
-            z  = y*log10_2lo + ivln10*StrictMath.log(x); // TOOD: switch to Translit.log when available
+            z  = y*log10_2lo + ivln10*log(x);
             return  z+y*log10_2hi;
         }
     }
diff --git a/test/jdk/java/lang/StrictMath/LogTests.java b/test/jdk/java/lang/StrictMath/LogTests.java
new file mode 100644
index 00000000000..a3e29b5cd08
--- /dev/null
+++ b/test/jdk/java/lang/StrictMath/LogTests.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8301202
+ * @key randomness
+ * @library /test/lib
+ * @build jdk.test.lib.RandomFactory
+ * @build Tests
+ * @build FdlibmTranslit
+ * @build LogTests
+ * @run main LogTests
+ * @summary Tests for StrictMath.log
+ */
+
+import jdk.test.lib.RandomFactory;
+
+public class LogTests {
+    private LogTests(){}
+
+    public static void main(String... args) {
+        int failures = 0;
+
+        failures += testLog();
+        failures += testAgainstTranslit();
+
+        if (failures > 0) {
+            System.err.println("Testing log incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
+    static int testLogCase(double input, double expected) {
+        return Tests.test("StrictMath.log(double)", input,
+                          StrictMath::log, expected);
+    }
+
+    // Inputs where Math.log and StrictMath.log differ for at least
+    // one Math.log implementation.
+    static int testLog() {
+        int failures = 0;
+
+        double [][] testCases = {
+            {0x1.000000089cd6fp-43, -0x1.dce2a0697a102p4},
+            {0x1.0000000830698p182,  0x1.f89c7428dd67ap6},
+            {0x1.0000000744b3ap632,  0x1.b611ab2bd53cep8},
+            {0x1.000000037d81fp766,  0x1.0979b1dbc4a42p9},
+            {0x1.000000024028p991,   0x1.577455642bb92p9},
+        };
+
+        for (double[] testCase: testCases)
+            failures+=testLogCase(testCase[0], testCase[1]);
+
+        return failures;
+    }
+
+    // Initialize shared random number generator
+    private static java.util.Random random = RandomFactory.getRandom();
+
+    /**
+     * Test StrictMath.log against transliteration port of log.
+     */
+    private static int testAgainstTranslit() {
+        int failures = 0;
+        double x;
+
+        // Test just above subnormal threshold...
+        x = Double.MIN_NORMAL;
+        failures += testRange(x, Math.ulp(x), 1000);
+
+        // ... and just below subnormal threshold ...
+        x = Math.nextDown(Double.MIN_NORMAL);
+        failures += testRange(x, -Math.ulp(x), 1000);
+
+        // Probe near decision points in the FDLIBM algorithm.
+        double[] decisionPoints = {
+            0x1.0p-1022,
+
+            0x1.0p-20,
+        };
+
+        for (double testPoint : decisionPoints) {
+            failures += testRangeMidpoint(testPoint, Math.ulp(testPoint), 1000);
+        }
+
+         x = Tests.createRandomDouble(random);
+
+         // Make the increment twice the ulp value in case the random
+         // value is near an exponent threshold. Don't worry about test
+         // elements overflowing to infinity if the starting value is
+         // near Double.MAX_VALUE.
+         failures += testRange(x, 2.0 * Math.ulp(x), 1000);
+
+         return failures;
+    }
+
+    private static int testRange(double start, double increment, int count) {
+        int failures = 0;
+        double x = start;
+        for (int i = 0; i < count; i++, x += increment) {
+            failures += testLogCase(x, FdlibmTranslit.log(x));
+        }
+        return failures;
+    }
+
+    private static int testRangeMidpoint(double midpoint, double increment, int count) {
+        int failures = 0;
+        double x = midpoint - increment*(count / 2) ;
+        for (int i = 0; i < count; i++, x += increment) {
+            failures += testLogCase(x, FdlibmTranslit.log(x));
+        }
+        return failures;
+    }
+}
diff --git a/test/jdk/java/lang/invoke/VarHandles/describeConstable/DescribeConstableTest.java b/test/jdk/java/lang/invoke/VarHandles/describeConstable/DescribeConstableTest.java
new file mode 100644
index 00000000000..ecda61cac48
--- /dev/null
+++ b/test/jdk/java/lang/invoke/VarHandles/describeConstable/DescribeConstableTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8302260
+ * @build p.C p.D p.I p.q.Q
+ * @run junit DescribeConstableTest
+ * @summary Test VarHandle::describeConstable on static fields
+ */
+
+import java.lang.constant.ClassDesc;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodHandles.Lookup;
+import java.lang.invoke.VarHandle;
+import java.lang.invoke.VarHandle.VarHandleDesc;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.Arguments;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class DescribeConstableTest {
+    private static final Lookup LOOKUP = MethodHandles.lookup();
+    private static Stream<Arguments> testCases() {
+        return Stream.of(
+                // static field defined in p.C only
+                Arguments.of(p.C.class, "cString", String.class, p.C.class, "CClass"),
+                // static fields defined in both superinterface p.I and superclass p.q.Q
+                // resolved to the one defined in the direct superinterface of C
+                Arguments.of(p.C.class, "stringField", String.class, p.I.class, "I"),
+                Arguments.of(p.C.class, "longField", long.class, p.I.class, 10L),
+                // static fields defined in superclass p.q.Q only
+                Arguments.of(p.C.class, "stringField2", String.class, p.q.Q.class, "QClass2"),
+                Arguments.of(p.C.class, "longField2", long.class, p.q.Q.class, 102L),
+                // static fields defined in superinterface p.I only
+                Arguments.of(p.C.class, "stringField3", String.class, p.I.class, "I3"),
+                Arguments.of(p.C.class, "longField3", long.class, p.I.class, 13L),
+                // static fields defined in p.D only
+                Arguments.of(p.D.class, "dString", String.class, p.D.class, "DClass"),
+                Arguments.of(p.D.class, "dLong", long.class, p.D.class, 1L),
+                // static fields defined in both superinterface p.I and superclass p.q.Q
+                // resolved to the one defined in the direct superinterface of D
+                Arguments.of(p.D.class, "stringField", String.class, p.I.class, "I"),
+                Arguments.of(p.D.class, "longField", long.class, p.I.class, 10L)
+        );
+    }
+
+    @ParameterizedTest
+    @MethodSource("testCases")
+    void test(Class<?> refc, String name, Class<?> type, Class<?> declaringClass, Object value) throws Throwable {
+        var vh = LOOKUP.findStaticVarHandle(refc, name, type);
+        assertEquals(value, vh.get());
+
+        var refcDesc = refc.describeConstable().orElseThrow();
+        var typeDesc = type.describeConstable().orElseThrow();
+        var vhd = vh.describeConstable().orElseThrow();
+        var vhd2 = VarHandleDesc.ofStaticField(refcDesc, name, typeDesc);
+
+        assertEquals(value, vhd.resolveConstantDesc(LOOKUP).get());
+        assertEquals(value, vhd2.resolveConstantDesc(LOOKUP).get());
+
+        assertEquals(vhd.toString(), varHandleDescString(declaringClass, name, type, true));
+    }
+
+    static String varHandleDescString(Class<?> declaringClass, String name, Class<?> type, boolean staticField) {
+        return String.format("VarHandleDesc[%s%s.%s:%s]",
+                             staticField ? "static " : "",
+                             declaringClass.describeConstable().orElseThrow().displayName(), name,
+                             type.describeConstable().orElseThrow().displayName());
+    }
+}
diff --git a/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/C.java b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/C.java
new file mode 100644
index 00000000000..353bd26dcf5
--- /dev/null
+++ b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/C.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+public class C extends p.q.Q implements I {
+    public static String cString =  "CClass";
+}
diff --git a/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/D.java b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/D.java
new file mode 100644
index 00000000000..e82ef217b0d
--- /dev/null
+++ b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/D.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+public class D extends p.q.Q implements I {
+    public static String dString =  "DClass";
+    public static long dLong = 1L;
+}
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData10.java b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/I.java
similarity index 55%
rename from test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData10.java
rename to test/jdk/java/lang/invoke/VarHandles/describeConstable/p/I.java
index ed33d65cfe8..8fce020f4d2 100644
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData10.java
+++ b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/I.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,26 +21,12 @@
  * questions.
  */
 
-package gc.g1;
+package p;
 
-/**
- * @test TestShrinkAuxiliaryData10
- * @key randomness
- * @bug 8038423 8061715 8078405
- * @summary Checks that decommitment occurs for JVM with different
- * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
- * @requires vm.gc.G1
- * @library /test/lib
- * @library /
- * @modules java.base/jdk.internal.misc
- *          java.management
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryData10
- */
-public class TestShrinkAuxiliaryData10 {
+public interface I {
+    String stringField = "I";
+    long longField = 10l;
 
-    public static void main(String[] args) throws Exception {
-        new TestShrinkAuxiliaryData(10).test();
-    }
+    String stringField3 = "I3";
+    long longField3 = 13L;
 }
diff --git a/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/q/Q.java b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/q/Q.java
new file mode 100644
index 00000000000..b3bbb8adafc
--- /dev/null
+++ b/test/jdk/java/lang/invoke/VarHandles/describeConstable/p/q/Q.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p.q;
+
+public class Q {
+    public static String stringField = "QClass";
+    public static long longField = 100L;
+
+    public static String stringField2 = "QClass2";
+    public static long longField2 = 102L;
+}
diff --git a/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java b/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java
index 2e5c4837282..b016b2f6899 100644
--- a/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java
+++ b/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -222,7 +222,7 @@ void unload() {
         }
 
         boolean tryUnload() {
-            return ForceGC.wait(() -> weakRef.refersTo(null));
+            return ForceGC.waitFor(() -> weakRef.refersTo(null), 2000L);
         }
     }
 
diff --git a/test/jdk/java/lang/reflect/exeCallerAccessTest/CallerAccessTest.java b/test/jdk/java/lang/reflect/exeCallerAccessTest/CallerAccessTest.java
index 85ee270244d..a6d17f90632 100644
--- a/test/jdk/java/lang/reflect/exeCallerAccessTest/CallerAccessTest.java
+++ b/test/jdk/java/lang/reflect/exeCallerAccessTest/CallerAccessTest.java
@@ -25,10 +25,7 @@
 /**
  * @test
  * @bug 8221530 8221642
- * @summary Test uses custom launcher that starts VM using JNI that verifies
- *          reflection API with null caller class
  * @library /test/lib
- * @requires os.family != "aix"
  * @run main/native CallerAccessTest
  */
 
diff --git a/test/jdk/java/lang/reflect/exeCallerAccessTest/exeCallerAccessTest.c b/test/jdk/java/lang/reflect/exeCallerAccessTest/exeCallerAccessTest.c
index 31710138aac..42be2b06c39 100644
--- a/test/jdk/java/lang/reflect/exeCallerAccessTest/exeCallerAccessTest.c
+++ b/test/jdk/java/lang/reflect/exeCallerAccessTest/exeCallerAccessTest.c
@@ -23,6 +23,9 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef AIX
+#include <pthread.h>
+#endif //AIX
 
 #include "jni.h"
 #include "assert.h"
@@ -42,7 +45,7 @@ int setAccessible(JNIEnv *env, char* declaringClass_name, char* field_name);
 int trySetAccessible(JNIEnv *env, char* declaringClass_name, char* field_name, jboolean canAccess);
 int checkAccess(JNIEnv *env, char* declaringClass_name, char* field_name, jboolean canAccess);
 
-int main(int argc, char** args) {
+static void* run(void* argp) {
     JavaVM *jvm;
     JNIEnv *env;
     JavaVMInitArgs vm_args;
@@ -236,3 +239,22 @@ int checkAccess(JNIEnv *env, char* declaringClass_name, char* field_name, jboole
     }
     return 0;
 }
+
+int main(int argc, char *argv[]) {
+#ifdef AIX
+    size_t adjusted_stack_size = 1024*1024;
+    pthread_t id;
+    int result;
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setstacksize(&attr, adjusted_stack_size);
+    result = pthread_create(&id, &attr, run, (void *)&argv);
+    if (result != 0)  {
+      fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
+      return -1;
+    }
+    pthread_join(id, NULL);
+#else
+    run(&argv);
+#endif //AIX
+}
diff --git a/test/jdk/java/net/httpclient/DigestEchoClient.java b/test/jdk/java/net/httpclient/DigestEchoClient.java
index 9f963e71658..3b6d1a1773f 100644
--- a/test/jdk/java/net/httpclient/DigestEchoClient.java
+++ b/test/jdk/java/net/httpclient/DigestEchoClient.java
@@ -507,7 +507,7 @@ void testBasic(Version clientVersion, Version serverVersion, boolean async,
                 System.gc();
                 if (queue.remove(100) == ref) break;
             }
-            var error = TRACKER.checkShutdown(500);
+            var error = TRACKER.checkShutdown(900);
             if (error != null) throw error;
         }
         System.out.println("OK");
diff --git a/test/jdk/java/net/httpclient/http2/IdleConnectionTimeoutTest.java b/test/jdk/java/net/httpclient/http2/IdleConnectionTimeoutTest.java
index d0008b9884c..ac060e8722b 100644
--- a/test/jdk/java/net/httpclient/http2/IdleConnectionTimeoutTest.java
+++ b/test/jdk/java/net/httpclient/http2/IdleConnectionTimeoutTest.java
@@ -51,14 +51,19 @@
  *                                                                   IdleConnectionTimeoutTest
  */
 
+import jdk.httpclient.test.lib.http2.BodyOutputStream;
+import jdk.httpclient.test.lib.http2.Http2TestExchangeImpl;
+import jdk.httpclient.test.lib.http2.Http2TestServerConnection;
+import jdk.internal.net.http.common.HttpHeadersBuilder;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.PrintStream;
-import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.http.HttpClient;
+import java.net.http.HttpHeaders;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
 import java.util.concurrent.CompletableFuture;
@@ -66,13 +71,15 @@
 import jdk.httpclient.test.lib.http2.Http2TestExchange;
 import jdk.httpclient.test.lib.http2.Http2Handler;
 
+import javax.net.ssl.SSLSession;
+
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.net.http.HttpClient.Version.HTTP_2;
 import static org.testng.Assert.assertEquals;
 
 public class IdleConnectionTimeoutTest {
 
-    Http2TestServer http2TestServer;
+    static Http2TestServer http2TestServer;
     URI timeoutUri;
     URI noTimeoutUri;
     final String IDLE_CONN_PROPERTY = "jdk.httpclient.keepalive.timeout.h2";
@@ -86,6 +93,7 @@ public void setup() throws Exception {
         http2TestServer = new Http2TestServer(false, 0);
         http2TestServer.addHandler(new ServerTimeoutHandler(), TIMEOUT_PATH);
         http2TestServer.addHandler(new ServerNoTimeoutHandler(), NO_TIMEOUT_PATH);
+        http2TestServer.setExchangeSupplier(TestExchangeSupplier::new);
 
         http2TestServer.start();
         int port = http2TestServer.getAddress().getPort();
@@ -154,40 +162,66 @@ private HttpResponse<String> runRequest(HttpClient hc, HttpRequest req, int slee
 
     static class ServerTimeoutHandler implements Http2Handler {
 
-        InetSocketAddress remote;
+        volatile Object firstConnection = null;
 
         @Override
         public void handle(Http2TestExchange exchange) throws IOException {
-            if (remote == null) {
-                remote = exchange.getRemoteAddress();
-                exchange.sendResponseHeaders(200, 0);
-            } else if (!remote.equals(exchange.getRemoteAddress())) {
-                testLog.println("ServerTimeoutHandler: New Connection was used, idleConnectionTimeoutEvent fired."
-                        + " First remote: " + remote + ", Second Remote: " + exchange.getRemoteAddress());
-                exchange.sendResponseHeaders(200, 0);
-            } else {
-                exchange.sendResponseHeaders(400, 0);
+            if (exchange instanceof TestExchangeSupplier exch) {
+                if (firstConnection == null) {
+                    firstConnection = exch.getTestConnection();
+                    exch.sendResponseHeaders(200, 0);
+                } else {
+                    var secondConnection = exch.getTestConnection();
+
+                    if (firstConnection != secondConnection) {
+                        testLog.println("ServerTimeoutHandler: New Connection was used, idleConnectionTimeoutEvent fired."
+                                + " First Connection Hash: " + firstConnection + ", Second Connection Hash: " + secondConnection);
+                        exch.sendResponseHeaders(200, 0);
+                    } else {
+                        testLog.println("ServerTimeoutHandler: Same Connection was used, idleConnectionTimeoutEvent did not fire."
+                                + " First Connection Hash: " + firstConnection + ", Second Connection Hash: " + secondConnection);
+                        exch.sendResponseHeaders(400, 0);
+                    }
+                }
             }
         }
     }
 
     static class ServerNoTimeoutHandler implements Http2Handler {
 
-        InetSocketAddress oldRemote;
+        volatile Object firstConnection = null;
 
         @Override
         public void handle(Http2TestExchange exchange) throws IOException {
-            InetSocketAddress newRemote = exchange.getRemoteAddress();
-            if (oldRemote == null) {
-                oldRemote = newRemote;
-                exchange.sendResponseHeaders(200, 0);
-            } else if (oldRemote.equals(newRemote)) {
-                testLog.println("ServerNoTimeoutHandler: Same Connection was used, idleConnectionTimeoutEvent did not fire."
-                        + " First remote: " + oldRemote + ", Second Remote: " + newRemote);
-                exchange.sendResponseHeaders(200, 0);
-            } else {
-                exchange.sendResponseHeaders(400, 0);
+            if (exchange instanceof TestExchangeSupplier exch) {
+                if (firstConnection == null) {
+                    firstConnection = exch.getTestConnection();
+                    exch.sendResponseHeaders(200, 0);
+                } else {
+                    var secondConnection = exch.getTestConnection();
+
+                    if (firstConnection == secondConnection) {
+                        testLog.println("ServerTimeoutHandler: Same Connection was used, idleConnectionTimeoutEvent did not fire."
+                                + " First Connection Hash: " + firstConnection + ", Second Connection Hash: " + secondConnection);
+                        exch.sendResponseHeaders(200, 0);
+                    } else {
+                        testLog.println("ServerTimeoutHandler: Different Connection was used, idleConnectionTimeoutEvent fired."
+                                + " First Connection Hash: " + firstConnection + ", Second Connection Hash: " + secondConnection);
+                        exch.sendResponseHeaders(400, 0);
+                    }
+                }
             }
         }
     }
-}
+
+    static class TestExchangeSupplier extends Http2TestExchangeImpl {
+
+        public TestExchangeSupplier(int streamid, String method, HttpHeaders reqheaders, HttpHeadersBuilder rspheadersBuilder, URI uri, InputStream is, SSLSession sslSession, BodyOutputStream os, Http2TestServerConnection conn, boolean pushAllowed) {
+            super(streamid, method, reqheaders, rspheadersBuilder, uri, is, sslSession, os, conn, pushAllowed);
+        }
+
+        public Http2TestServerConnection getTestConnection() {
+            return this.conn;
+        }
+    }
+}
\ No newline at end of file
diff --git a/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java b/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java
new file mode 100644
index 00000000000..c6eb7f709fa
--- /dev/null
+++ b/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ @test
+ * @summary Trailing headers should be ignored by the client when using HTTP/2
+ *          and not affect the rest of the exchange.
+ * @bug 8296410
+ * @library /test/jdk/java/net/httpclient/lib
+ * @build jdk.httpclient.test.lib.http2.Http2TestServer
+ * @run testng/othervm -Djdk.httpclient.HttpClient.log=all TrailingHeadersTest
+ */
+
+import jdk.httpclient.test.lib.http2.OutgoingPushPromise;
+import jdk.internal.net.http.common.HttpHeadersBuilder;
+import jdk.internal.net.http.frame.DataFrame;
+import jdk.internal.net.http.frame.HeaderFrame;
+import jdk.internal.net.http.frame.HeadersFrame;
+import org.testng.TestException;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import javax.net.ssl.SSLSession;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpHeaders;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.net.http.HttpResponse.BodyHandlers;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executors;
+import java.util.function.BiPredicate;
+
+import jdk.httpclient.test.lib.http2.Http2TestServer;
+import jdk.httpclient.test.lib.http2.Http2TestServerConnection;
+import jdk.httpclient.test.lib.http2.Http2TestExchangeImpl;
+import jdk.httpclient.test.lib.http2.Http2TestExchange;
+import jdk.httpclient.test.lib.http2.Http2Handler;
+import jdk.httpclient.test.lib.http2.BodyOutputStream;
+
+import static java.net.http.HttpClient.Version.HTTP_2;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.testng.Assert.assertEquals;
+
+public class TrailingHeadersTest {
+
+    Http2TestServer http2TestServer;
+    URI trailingURI, trailng1xxURI, trailingPushPromiseURI, warmupURI;
+    static PrintStream testLog = System.err;
+
+    // Set up simple client-side push promise handler
+    ConcurrentMap<HttpRequest, CompletableFuture<HttpResponse<String>>> pushPromiseMap = new ConcurrentHashMap<>();
+
+    @BeforeMethod
+    public void beforeMethod() {
+        pushPromiseMap = new ConcurrentHashMap<>();
+    }
+
+    @BeforeTest
+    public void setup() throws Exception {
+        Properties props = new Properties();
+        // For triggering trailing headers to send after Push Promise Response headers are sent
+        props.setProperty("sendTrailingHeadersAfterPushPromise", "1");
+
+        http2TestServer = new Http2TestServer("Test_Server",
+                                              false,
+                                              0,
+                                              null,
+                                              0,
+                                              props,
+                                       null);
+        http2TestServer.setExchangeSupplier(TrailingHeadersExchange::new);
+        http2TestServer.addHandler(new ResponseTrailersHandler(), "/ResponseTrailingHeaders");
+        http2TestServer.addHandler(new InformationalTrailersHandler(), "/InfoRespTrailingHeaders");
+        http2TestServer.addHandler(new PushPromiseTrailersHandler(), "/PushPromiseTrailingHeaders");
+        http2TestServer.addHandler(new WarmupHandler(), "/WarmupHandler");
+
+        http2TestServer.start();
+
+        trailingURI = URI.create("http://" + http2TestServer.serverAuthority() + "/ResponseTrailingHeaders");
+        trailng1xxURI = URI.create("http://" + http2TestServer.serverAuthority() + "/InfoRespTrailingHeaders");
+        trailingPushPromiseURI = URI.create("http://" + http2TestServer.serverAuthority() + "/PushPromiseTrailingHeaders");
+
+        // Used to ensure HTTP/2 upgrade takes place
+        warmupURI = URI.create("http://" + http2TestServer.serverAuthority() + "/WarmupHandler");
+    }
+
+    @AfterTest
+    public void teardown() {
+        http2TestServer.stop();
+    }
+
+    @Test(dataProvider = "httpRequests")
+    public void testTrailingHeaders(String description, HttpRequest hRequest, HttpResponse.PushPromiseHandler<String> pph) {
+        testLog.println("testTrailingHeaders(): " + description);
+        HttpClient httpClient = HttpClient.newBuilder().build();
+        performWarmupRequest(httpClient);
+        CompletableFuture<HttpResponse<String>> cf = httpClient.sendAsync(hRequest, BodyHandlers.ofString(UTF_8), pph);
+
+        testLog.println("testTrailingHeaders(): Performing request: " + hRequest);
+        HttpResponse<String> resp = cf.join();
+
+        assertEquals(resp.statusCode(), 200, "Status code of response should be 200");
+
+        // Verify Push Promise was successful if necessary
+        if (pph != null)
+            verifyPushPromise();
+
+        testLog.println("testTrailingHeaders(): Request successfully completed");
+    }
+
+    private void verifyPushPromise()  {
+        assertEquals(pushPromiseMap.size(), 1, "Push Promise should not be greater than 1");
+        // This will only iterate once
+        for (HttpRequest r : pushPromiseMap.keySet()) {
+            CompletableFuture<HttpResponse<String>> serverPushResp = pushPromiseMap.get(r);
+            // Get the push promise HttpResponse result if present
+            HttpResponse<String> resp = serverPushResp.join();
+            assertEquals(resp.body(), "Sample_Push_Data", "Unexpected Push Promise response body");
+            assertEquals(resp.statusCode(), 200, "Status code of Push Promise response should be 200");
+        }
+    }
+
+    private void performWarmupRequest(HttpClient httpClient) {
+        HttpRequest warmupReq = HttpRequest.newBuilder(warmupURI).version(HTTP_2)
+                .GET()
+                .build();
+        httpClient.sendAsync(warmupReq, BodyHandlers.discarding()).join();
+    }
+
+    @DataProvider(name = "httpRequests")
+    public Object[][] uris() {
+        HttpResponse.PushPromiseHandler<String> pph = (initial, pushRequest, acceptor) -> {
+            HttpResponse.BodyHandler<String> s = HttpResponse.BodyHandlers.ofString(UTF_8);
+            pushPromiseMap.put(pushRequest, acceptor.apply(s));
+        };
+
+        HttpRequest httpGetTrailing = HttpRequest.newBuilder(trailingURI).version(HTTP_2)
+                .GET()
+                .build();
+
+        HttpRequest httpPost1xxTrailing = HttpRequest.newBuilder(trailng1xxURI).version(HTTP_2)
+                .POST(HttpRequest.BodyPublishers.ofString("Test Post"))
+                .expectContinue(true)
+                .build();
+
+        HttpRequest httpGetPushPromiseTrailing = HttpRequest.newBuilder(trailingPushPromiseURI).version(HTTP_2)
+                .GET()
+                .build();
+
+        return new Object[][] {
+                { "Test GET with Trailing Headers", httpGetTrailing, null },
+                { "Test POST with 1xx response & Trailing Headers", httpPost1xxTrailing, null },
+                { "Test Push Promise with Trailing Headers", httpGetPushPromiseTrailing, pph }
+        };
+    }
+
+    static class TrailingHeadersExchange extends Http2TestExchangeImpl {
+
+        byte[] resp = "Sample_Data".getBytes(StandardCharsets.UTF_8);
+
+
+        TrailingHeadersExchange(int streamid, String method, HttpHeaders reqheaders, HttpHeadersBuilder rspheadersBuilder,
+                                 URI uri, InputStream is, SSLSession sslSession, BodyOutputStream os,
+                                 Http2TestServerConnection conn, boolean pushAllowed) {
+            super(streamid, method, reqheaders, rspheadersBuilder, uri, is, sslSession, os, conn, pushAllowed);
+        }
+
+        public void sendResponseThenTrailers() throws IOException {
+            /*
+            HttpHeadersBuilder hb = this.conn.createNewHeadersBuilder();
+            hb.setHeader("x-sample", "val");
+            HeaderFrame headerFrame = new HeadersFrame(this.streamid, 0, this.conn.encodeHeaders(hb.build()));
+            */
+            // TODO: see if there is a safe way to encode headers without interrupting connection thread
+            HeaderFrame headerFrame = new HeadersFrame(this.streamid, 0, List.of());
+            headerFrame.setFlag(HeaderFrame.END_HEADERS);
+            headerFrame.setFlag(HeaderFrame.END_STREAM);
+
+            this.sendResponseHeaders(200, resp.length);
+            DataFrame dataFrame = new DataFrame(this.streamid, 0, ByteBuffer.wrap(resp));
+            this.conn.addToOutputQ(dataFrame);
+            this.conn.addToOutputQ(headerFrame);
+        }
+
+        @Override
+        public void serverPush(URI uri, HttpHeaders headers, InputStream content) {
+            HttpHeadersBuilder headersBuilder = new HttpHeadersBuilder();
+            headersBuilder.setHeader(":method", "GET");
+            headersBuilder.setHeader(":scheme", uri.getScheme());
+            headersBuilder.setHeader(":authority", uri.getAuthority());
+            headersBuilder.setHeader(":path", uri.getPath());
+            for (Map.Entry<String,List<String>> entry : headers.map().entrySet()) {
+                for (String value : entry.getValue())
+                    headersBuilder.addHeader(entry.getKey(), value);
+            }
+            HttpHeaders combinedHeaders = headersBuilder.build();
+            OutgoingPushPromise pp = new OutgoingPushPromise(streamid, uri, combinedHeaders, content);
+            pp.setFlag(HeaderFrame.END_HEADERS);
+
+            try {
+                this.conn.addToOutputQ(pp);
+            } catch (IOException ex) {
+                testLog.println("serverPush(): pushPromise exception: " + ex);
+            }
+        }
+    }
+
+    static class WarmupHandler implements Http2Handler {
+
+        @Override
+        public void handle(Http2TestExchange exchange) throws IOException {
+            exchange.sendResponseHeaders(200, 0);
+        }
+    }
+
+    static class ResponseTrailersHandler implements Http2Handler {
+
+        @Override
+        public void handle(Http2TestExchange exchange) throws IOException {
+            if (exchange.getProtocol().equals("HTTP/2")) {
+                if (exchange instanceof TrailingHeadersExchange trailingHeadersExchange) {
+                    trailingHeadersExchange.sendResponseThenTrailers();
+                }
+            } else {
+                testLog.println("ResponseTrailersHandler: Incorrect protocol version");
+                exchange.sendResponseHeaders(400, 0);
+            }
+        }
+    }
+
+    static class InformationalTrailersHandler implements Http2Handler {
+
+        @Override
+        public void handle(Http2TestExchange exchange) throws IOException {
+            if (exchange.getProtocol().equals("HTTP/2")) {
+                if (exchange instanceof TrailingHeadersExchange trailingHeadersExchange) {
+                    testLog.println(this.getClass().getCanonicalName() + ": Sending status 100");
+                    trailingHeadersExchange.sendResponseHeaders(100, 0);
+
+                    try (InputStream is = exchange.getRequestBody()) {
+                        is.readAllBytes();
+                        trailingHeadersExchange.sendResponseThenTrailers();
+                    }
+                }
+            } else {
+                testLog.println("InformationalTrailersHandler: Incorrect protocol version");
+                exchange.sendResponseHeaders(400, 0);
+            }
+        }
+    }
+
+    static class PushPromiseTrailersHandler implements Http2Handler {
+
+        @Override
+        public void handle(Http2TestExchange exchange) throws IOException {
+            if (exchange.getProtocol().equals("HTTP/2")) {
+                if (exchange instanceof TrailingHeadersExchange trailingHeadersExchange) {
+                    try (InputStream is = exchange.getRequestBody()) {
+                        is.readAllBytes();
+                    }
+
+                    if (exchange.serverPushAllowed()) {
+                        pushPromise(trailingHeadersExchange);
+                    }
+
+                    try (OutputStream os = trailingHeadersExchange.getResponseBody()) {
+                        byte[] bytes = "Sample_Data".getBytes(UTF_8);
+                        trailingHeadersExchange.sendResponseHeaders(200, bytes.length);
+                        os.write(bytes);
+                    }
+                }
+            }
+        }
+
+        static final BiPredicate<String,String> ACCEPT_ALL = (x, y) -> true;
+
+        private void pushPromise(Http2TestExchange exchange) {
+            URI requestURI = exchange.getRequestURI();
+            URI uri = requestURI.resolve("/promise");
+            InputStream is = new ByteArrayInputStream("Sample_Push_Data".getBytes(UTF_8));
+            Map<String, List<String>> map = new HashMap<>();
+            map.put("x-promise", List.of("promise-header"));
+            HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL);
+            exchange.serverPush(uri, headers, is);
+            testLog.println("PushPromiseTrailersHandler: Push Promise complete");
+        }
+    }
+}
\ No newline at end of file
diff --git a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/BodyOutputStream.java b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/BodyOutputStream.java
index d043f81390e..81b1d973239 100644
--- a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/BodyOutputStream.java
+++ b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/BodyOutputStream.java
@@ -130,10 +130,14 @@ public void close() {
             closed = true;
         }
         try {
-            send(EMPTY_BARRAY, 0, 0, DataFrame.END_STREAM);
+            sendEndStream();
         } catch (IOException ex) {
             System.err.println("TestServer: OutputStream.close exception: " + ex);
             ex.printStackTrace();
         }
     }
+
+    protected void sendEndStream() throws IOException {
+        send(EMPTY_BARRAY, 0, 0, DataFrame.END_STREAM);
+    }
 }
diff --git a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServer.java b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServer.java
index e13ceaef875..46c20a8eee1 100644
--- a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServer.java
+++ b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServer.java
@@ -192,7 +192,7 @@ public Http2TestServer(InetAddress localAddr,
         this.secure = secure;
         this.exec = exec == null ? getDefaultExecutor() : exec;
         this.handlers = Collections.synchronizedMap(new HashMap<>());
-        this.properties = properties;
+        this.properties = properties == null ? new Properties() : properties;
         this.connections = ConcurrentHashMap.newKeySet();
     }
 
diff --git a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServerConnection.java b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServerConnection.java
index 62059baa632..94f11e843ce 100644
--- a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServerConnection.java
+++ b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2/Http2TestServerConnection.java
@@ -960,13 +960,25 @@ private void handlePush(OutgoingPushPromise op) throws IOException {
         final BodyOutputStream oo = new BodyOutputStream(
                 promisedStreamid,
                 clientSettings.getParameter(
-                        SettingsFrame.INITIAL_WINDOW_SIZE), this);
+                        SettingsFrame.INITIAL_WINDOW_SIZE), this) {
+
+            @Override
+            protected void sendEndStream() throws IOException {
+                if (properties.getProperty("sendTrailingHeadersAfterPushPromise", "0").equals("1")) {
+                    conn.outputQ.put(getTrailingHeadersFrame(promisedStreamid, List.of()));
+                } else {
+                    super.sendEndStream();
+                }
+            }
+        };
+
         outStreams.put(promisedStreamid, oo);
         oo.goodToGo();
         exec.submit(() -> {
             try {
                 ResponseHeaders oh = getPushResponse(promisedStreamid);
                 outputQ.put(oh);
+
                 ii.transferTo(oo);
             } catch (Throwable ex) {
                 System.err.printf("TestServer: pushing response error: %s\n",
@@ -979,6 +991,11 @@ private void handlePush(OutgoingPushPromise op) throws IOException {
 
     }
 
+    private HeadersFrame getTrailingHeadersFrame(int promisedStreamid, List<ByteBuffer> headerBlocks) {
+        // TODO: see if there is a safe way to encode headers without interrupting connection thread
+        return new HeadersFrame(promisedStreamid, (HeaderFrame.END_HEADERS | HeaderFrame.END_STREAM), headerBlocks);
+    }
+
     // returns a minimal response with status 200
     // that is the response to the push promise just sent
     private ResponseHeaders getPushResponse(int streamid) {
diff --git a/test/jdk/java/nio/channels/FileChannel/FileExtensionAndMap.java b/test/jdk/java/nio/channels/FileChannel/FileExtensionAndMap.java
deleted file mode 100644
index 37ca610e231..00000000000
--- a/test/jdk/java/nio/channels/FileChannel/FileExtensionAndMap.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 8168628
- * @summary Test extending files to very large sizes without hitting a SIGBUS
- * @requires (os.family == "linux")
- * @requires (sun.arch.data.model == "64")
- * @library /test/lib/
- * @run main/othervm/timeout=600 -Xms4g -Xmx4g FileExtensionAndMap
- * @run main/othervm/timeout=600 -Xms4g -Xmx4g FileExtensionAndMap true
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileChannel.MapMode;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.StandardOpenOption;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.Semaphore;
-import java.util.stream.IntStream;
-import jtreg.SkippedException;
-
-public class FileExtensionAndMap {
-
-    private static final ExecutorService CACHED_EXECUTORSERVICE =
-        Executors.newCachedThreadPool();
-
-    private static final String TMPDIR = System.getProperty("test.dir", ".");
-
-    private static boolean useRaf = false;
-
-    private static final long FILESIZE = 3L * 1024L * 1024L * 1024L;
-    private static final int PARALLELISM = 3;
-
-    public static void main(String args[]) throws Exception {
-        if (args.length > 2) {
-            throw new IllegalArgumentException
-                ("Arguments: [true|false [targetFolder]]");
-        }
-
-        String defaultFolder = TMPDIR + File.separator + "target";
-        if (args.length > 0) {
-            useRaf = Boolean.valueOf(args[0]);
-            if (args.length > 1) {
-                defaultFolder = args[1];
-            }
-        }
-
-        final String targetFolder = defaultFolder;
-        Path p = Paths.get(targetFolder);
-        boolean targetExists = Files.exists(p);
-        if (!targetExists) {
-            Files.createDirectory(p);
-        }
-
-        checkRequiredDiskSpace(defaultFolder);
-
-        System.out.printf("Using RandomAccessFile: %s; target folder: %s%n",
-            useRaf, targetFolder);
-
-        ForkJoinPool fjPool = new ForkJoinPool(PARALLELISM);
-        fjPool.submit(() -> {
-            IntStream.range(0, 20).parallel().forEach((index) -> {
-                String fileName = "testBigFile_" + index + ".dat";
-                Path source = null;
-                Path target = null;
-                try {
-                    source = Paths.get(TMPDIR, fileName);
-                    testCreateBigFile(source);
-                    target = Paths.get(targetFolder, fileName);
-                    testFileCopy(source, target);
-                } catch (Throwable th) {
-                    System.err.println("Error copying file with fileName: "
-                        + fileName + " : " + th.getMessage());
-                    th.printStackTrace(System.err);
-                } finally {
-                    try {
-                        if (source != null) {
-                            Files.deleteIfExists(source);
-                        }
-                    } catch (Throwable ignored) {
-                    }
-                    try {
-                        if (target != null) {
-                            Files.deleteIfExists(target);
-                        }
-                    } catch (Throwable ignored) {
-                    }
-                }
-            });
-        }).join();
-
-        if (!targetExists) {
-            Files.delete(p);
-        }
-    }
-
-    private static void checkRequiredDiskSpace(String destinationFolder) throws IOException {
-        Path destinationPath = Path.of(destinationFolder);
-        Path tmpDir = Path.of(TMPDIR);
-
-        long totalDiskSpaceNeeded = FILESIZE * PARALLELISM;
-
-        if (Files.getFileStore(tmpDir).equals(Files.getFileStore(destinationPath))) {
-            totalDiskSpaceNeeded *= 2; // writing and copying to same FS
-            long usableDiskSpace = Files.getFileStore(tmpDir).getUsableSpace();
-            if (usableDiskSpace < totalDiskSpaceNeeded) {
-                throw new SkippedException("Insufficient disk space on " + TMPDIR
-                        + ". Test requires: " + totalDiskSpaceNeeded
-                        + ". Available on disk: " + usableDiskSpace);
-            }
-
-        } else {
-            for (Path p : List.of(destinationPath, tmpDir)) {
-                long usableDiskSpace = Files.getFileStore(p).getUsableSpace();
-                if (usableDiskSpace < totalDiskSpaceNeeded) {
-                    throw new SkippedException("Insufficient disk space on " + p
-                            + ". Test requires: " + totalDiskSpaceNeeded
-                            + ". Available on disk: " + usableDiskSpace);
-                }
-            }
-        }
-    }
-
-    private static void testFileCopy(Path source, Path target)
-        throws IOException {
-        Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
-        System.out.println("Finished copying file with fileName: "
-                + source.getFileName());
-    }
-
-    private static void testCreateBigFile(Path segmentFile)
-        throws IOException {
-        final Semaphore concurrencySemaphore = new Semaphore(5);
-
-        int blockSize = 10 * 1024 * 1024;
-        int loopCount = (int) Math.floorDiv(FILESIZE, blockSize);
-
-        String fileName = segmentFile.getFileName().toString();
-        if (useRaf) {
-            try (RandomAccessFile raf
-                = new RandomAccessFile(segmentFile.toFile(), "rw")) {
-                raf.setLength(FILESIZE);
-                try (FileChannel fc = raf.getChannel()) {
-                    for (int i = 0; i < loopCount; i++) {
-                        final long startPosition = 1L * blockSize * i;
-                        concurrencySemaphore.acquireUninterruptibly();
-                        CACHED_EXECUTORSERVICE.submit(() -> {
-                            writeTemplateData(fileName, fc, startPosition,
-                                    blockSize, concurrencySemaphore);
-                        });
-                    }
-                } finally {
-                    concurrencySemaphore.acquireUninterruptibly(5);
-                }
-            }
-        } else {
-            Path file = Files.createFile(segmentFile);
-            try (FileChannel fc = FileChannel.open(file,
-                StandardOpenOption.READ, StandardOpenOption.WRITE)) {
-                for (int i = 0; i < loopCount; i++) {
-                    final long startPosition = 1L * blockSize * i;
-                    concurrencySemaphore.acquireUninterruptibly();
-                    CACHED_EXECUTORSERVICE.submit(() -> {
-                        writeTemplateData(fileName, fc, startPosition,
-                                blockSize, concurrencySemaphore);
-                    });
-                }
-            }
-        }
-    }
-
-    private static void writeTemplateData(String fileName,
-        FileChannel fc, long startPosition, int blockSize,
-        Semaphore concurrencySemaphore) {
-        try {
-            byte[] EMPTY_RECORD = new byte[blockSize / 256];
-
-            MappedByteBuffer mappedByteBuffer = fc.map(MapMode.READ_WRITE,
-                startPosition, blockSize);
-            IntStream.range(0, 256).forEach((recordIndex) -> {
-                try {
-                    mappedByteBuffer.position((int) (recordIndex *
-                        EMPTY_RECORD.length));
-                    mappedByteBuffer.put(EMPTY_RECORD, 0, EMPTY_RECORD.length);
-                } catch (Throwable th) {
-                    System.err.println
-                        ("Error in FileExtensionAndMap.writeTemplateData empty record for fileName: "
-                        + fileName + ", startPosition: " + startPosition + ", recordIndex: "
-                        + recordIndex + " : " + th.getMessage());
-                    th.printStackTrace(System.err);
-                }
-            });
-
-            mappedByteBuffer.force();
-        } catch (Throwable th) {
-            if (!(th instanceof ClosedChannelException)) {
-                System.err.println
-                    ("Error in FileExtensionAndMap.writeTemplateData empty record for fileName: "
-                    + fileName + ", startPosition: " + startPosition + " : "
-                    + th.getMessage());
-                th.printStackTrace(System.err);
-            }
-        } finally {
-            concurrencySemaphore.release();
-        }
-    }
-}
diff --git a/test/jdk/java/rmi/server/UnicastRemoteObject/serialFilter/FilterUROTest.java b/test/jdk/java/rmi/server/UnicastRemoteObject/serialFilter/FilterUROTest.java
index c5e73b95e03..f87f4e51d7b 100644
--- a/test/jdk/java/rmi/server/UnicastRemoteObject/serialFilter/FilterUROTest.java
+++ b/test/jdk/java/rmi/server/UnicastRemoteObject/serialFilter/FilterUROTest.java
@@ -31,6 +31,7 @@
 import java.rmi.server.UnicastRemoteObject;
 
 import java.util.Objects;
+import java.lang.ref.Reference;
 
 import org.testng.Assert;
 import org.testng.annotations.DataProvider;
@@ -76,6 +77,7 @@ public void useExportObject(String name, Object obj, int expectedFilterCount) th
             int count = client.filterCount(obj);
             System.out.printf("count: %d, obj: %s%n", count, obj);
             Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
+            Reference.reachabilityFence(impl);
         } catch (RemoteException rex) {
             if (expectedFilterCount == -1 &&
                     UnmarshalException.class.equals(rex.getCause().getClass()) &&
@@ -103,6 +105,7 @@ public void useExportObject2(String name, Object obj, int expectedFilterCount) t
             int count = client.filterCount(obj);
             System.out.printf("count: %d, obj: %s%n", count, obj);
             Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
+            Reference.reachabilityFence(impl);
         } catch (RemoteException rex) {
             if (expectedFilterCount == -1 &&
                     UnmarshalException.class.equals(rex.getCause().getClass()) &&
diff --git a/test/jdk/javax/management/MBeanServer/ExceptionTest.java b/test/jdk/javax/management/MBeanServer/ExceptionTest.java
index 3ea04f7d7ca..bb58e941242 100644
--- a/test/jdk/javax/management/MBeanServer/ExceptionTest.java
+++ b/test/jdk/javax/management/MBeanServer/ExceptionTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -123,10 +123,13 @@ public void run(Map<String, Object> args) {
         } finally {
             try {
                 // Close JMX Connector Client
-                cc.close();
+                if (cc != null) {
+                    cc.close();
+                }
                 // Stop connertor server
-                cs.stop();
-
+                if (cs != null) {
+                    cs.stop();
+                }
             } catch (Exception e) {
                 Utils.printThrowable(e, true);
                 throw new RuntimeException(
diff --git a/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java b/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java
index 72319d72cb9..3f16ed00369 100644
--- a/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java
+++ b/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,10 @@ public static void main(String[] args) throws Exception {
         JMXServiceURL addr = server.getAddress();
         JMXConnector client = JMXConnectorFactory.connect(addr, env);
 
-        Thread.sleep(100); // let pass the first client open notif if there is
+        // Sleeping here was an attempt to avoid seeing an initial notification.
+        // This does not work, but does not matter.
+        // Thread.sleep(100);
+
         client.getMBeanServerConnection().addNotificationListener(oname,
                                                                   listener,
                                                                   null,
@@ -100,12 +103,13 @@ public static void main(String[] args) throws Exception {
 
         synchronized(lock) {
             while(clientState == null && System.currentTimeMillis() < end) {
+                System.out.println("Calling sendNotifications");
                 mbs.invoke(oname, "sendNotifications",
                            new Object[] {new Notification("MyType", "", 0)},
                            new String[] {"javax.management.Notification"});
 
                 try {
-                    lock.wait(10);
+                    lock.wait(1000); // sleep as no point in constant notifications
                 } catch (Exception e) {}
             }
         }
@@ -143,10 +147,10 @@ public interface NotificationEmitterMBean {
     private final static NotificationListener listener = new NotificationListener() {
             public void handleNotification(Notification n, Object hb) {
 
-                // treat the client notif to know the end
+                System.out.println("handleNotification: " + n);
                 if (n instanceof JMXConnectionNotification) {
                     if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) {
-
+                        // Expected: [type=jmx.remote.connection.opened][message=Reconnected to server]
                         clientState = n.getType();
                         System.out.println(
                            ">>> The client state has been changed to: "+clientState);
@@ -159,7 +163,7 @@ public void handleNotification(Notification n, Object hb) {
                     return;
                 }
 
-                System.out.println(">>> Do sleep to make reconnection.");
+                System.out.println(">>> sleeping in NotificationListener to force reconnection.");
                 synchronized(lock) {
                     try {
                         lock.wait(listenerSleep);
@@ -170,9 +174,11 @@ public void handleNotification(Notification n, Object hb) {
             }
         };
 
-    private static final long serverTimeout = 1000;
+    // serverTimeout increased to avoid occasional problems with initial connect.
+    // Not using Utils.adjustTimeout to avoid accidentally making it too long.
+    private static final long serverTimeout = 2000;
     private static final long listenerSleep = serverTimeout*6;
 
-    private static String clientState = null;
+    private volatile static String clientState = null;
     private static final int[] lock = new int[0];
 }
diff --git a/test/jdk/javax/management/security/HashedPasswordFileTest.java b/test/jdk/javax/management/security/HashedPasswordFileTest.java
index e7b0af4cab7..e2d5bd7deb6 100644
--- a/test/jdk/javax/management/security/HashedPasswordFileTest.java
+++ b/test/jdk/javax/management/security/HashedPasswordFileTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -200,6 +200,12 @@ private JMXServiceURL createServerSide(boolean useHash)
         return cs.getAddress();
     }
 
+    private void stopServerSide() throws IOException {
+        if (cs != null) {
+            cs.stop();
+        }
+    }
+
     @Test
     public void testClearTextPasswordFile() throws IOException {
         Boolean[] bvals = new Boolean[]{true, false};
@@ -217,7 +223,7 @@ public void testClearTextPasswordFile() throws IOException {
                 }
                 Assert.assertEquals(isPasswordFileHashed(), bval);
             } finally {
-                cs.stop();
+                stopServerSide();
             }
         }
     }
@@ -241,7 +247,7 @@ public void testReadOnlyPasswordFile() throws IOException {
                 }
                 Assert.assertEquals(isPasswordFileHashed(), false);
             } finally {
-                cs.stop();
+                stopServerSide();
             }
         }
     }
@@ -263,7 +269,7 @@ public void testHashedPasswordFile() throws IOException {
                     }
                 }
             } finally {
-                cs.stop();
+                stopServerSide();
             }
         }
     }
@@ -400,7 +406,7 @@ public void testPasswordChange() throws IOException {
                 }
             }
         } finally {
-            cs.stop();
+            stopServerSide();
         }
     }
 
diff --git a/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java b/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java
index 1ddd9edfa59..7a4f71d8171 100644
--- a/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java
+++ b/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,7 @@
  * @bug 8133632
  * @summary javax.net.ssl.SSLEngine does not properly handle received
  *      SSL fatal alerts
- *
- * @run main/othervm EngineCloseOnAlert
+ * @run main EngineCloseOnAlert
  */
 
 import java.io.FileInputStream;
@@ -40,23 +39,20 @@
 
 public class EngineCloseOnAlert {
 
-    private static final String pathToStores = "../etc";
-    private static final String keyStoreFile = "keystore";
-    private static final String trustStoreFile = "truststore";
+    private static final String PATH_TO_STORES = "../etc";
+    private static final String KEYSTORE_FILENAME = "keystore";
+    private static final String TRUSTSTORE_FILENAME = "truststore";
     private static final String passwd = "passphrase";
-    private static final String keyFilename =
-            System.getProperty("test.src", ".") + "/" + pathToStores +
-                "/" + keyStoreFile;
-    private static final String trustFilename =
-            System.getProperty("test.src", ".") + "/" + pathToStores +
-                "/" + trustStoreFile;
+    private static final String KEYSTORE_PATH =
+            System.getProperty("test.src", ".") + "/" + PATH_TO_STORES +
+                "/" + KEYSTORE_FILENAME;
+    private static final String TRUSTSTORE_PATH =
+            System.getProperty("test.src", ".") + "/" + PATH_TO_STORES +
+                "/" + TRUSTSTORE_FILENAME;
 
     private static KeyManagerFactory KMF;
     private static TrustManagerFactory TMF;
-    private static TrustManagerFactory EMPTY_TMF;
 
-    private static final String[] TLS10ONLY = { "TLSv1" };
-    private static final String[] TLS12ONLY = { "TLSv1.2" };
     private static final String[] ONECIPHER =
             { "TLS_RSA_WITH_AES_128_CBC_SHA" };
 
@@ -91,6 +87,7 @@ public static void main(String[] args) throws Exception {
         }
     }
 
+    private static final String TLSv12 = "TLSv1.2";
     private static final TestCase clientReceivesAlert = new TestCase() {
         @Override
         public void runTest() throws Exception {
@@ -104,7 +101,9 @@ public void runTest() throws Exception {
             // match the requested ciphers offered by the client.  This
             // will generate an alert from the server to the client.
 
-            SSLContext context = SSLContext.getDefault();
+            SSLContext context = SSLContext.getInstance(TLSv12);
+            context.init(null, null, null);
+
             SSLEngine client = context.createSSLEngine();
             SSLEngine server = context.createSSLEngine();
             client.setUseClientMode(true);
@@ -136,7 +135,8 @@ public void runTest() throws Exception {
                 serverResult = server.wrap(plain, raw);
                 System.out.println("Server result: " + serverResult);
                 runDelegatedTasks(serverResult, server);
-            } catch (SSLException e) {
+                throw new RuntimeException("The expected SSLHandshakeException was not thrown.");
+            } catch (SSLHandshakeException e) {
                 // This is the expected code path
                 System.out.println("Server throws exception: " + e);
                 System.out.println("Server engine state: " +
@@ -147,16 +147,13 @@ public void runTest() throws Exception {
             }
             raw.clear();
 
-            // The above should show that isInboundDone returns true, and
-            // handshake status is NEED_WRAP. That is the correct behavior,
-            // wrap will put a fatal alert message in the buffer.
             serverResult = server.wrap(plain, raw);
             System.out.println("Server result (wrap after exception): " +
                     serverResult);
             System.out.println("Server engine closure state: isInboundDone="
                     + server.isInboundDone() + ", isOutboundDone="
                     + server.isOutboundDone());
-            checkEngineState(server, NEED_UNWRAP, true, true);
+            checkEngineState(server, NOT_HANDSHAKING, true, true);
             raw.flip();
 
             System.out.println("Server-to-Client:\n-----------------\n" +
@@ -167,7 +164,8 @@ public void runTest() throws Exception {
                 clientResult = client.unwrap(raw, plain);
                 System.out.println("Client result (unwrap alert): " +
                     clientResult);
-            } catch (SSLException e) {
+                throw new RuntimeException("Client did not throw the expected SSLException.");
+            } catch (SSLHandshakeException e) {
                 System.out.println("Client throws exception: " + e);
                 System.out.println("Engine closure status: isInboundDone="
                         + client.isInboundDone() + ", isOutboundDone="
@@ -188,17 +186,16 @@ public void runTest() throws Exception {
     private static final TestCase serverReceivesAlert = new TestCase() {
         @Override
         public void runTest() throws Exception {
-            SSLContext cliContext = SSLContext.getDefault();
-            SSLContext servContext = SSLContext.getInstance("TLS");
+            SSLContext cliContext = SSLContext.getInstance(TLSv12);
+            cliContext.init(null, null, null);
+            SSLContext servContext = SSLContext.getInstance(TLSv12);
             servContext.init(KMF.getKeyManagers(), TMF.getTrustManagers(),
                     null);
             SSLEngine client = cliContext.createSSLEngine();
             SSLEngine server = servContext.createSSLEngine();
             client.setUseClientMode(true);
-            client.setEnabledProtocols(TLS12ONLY);
             client.setEnabledCipherSuites(ONECIPHER);
             server.setUseClientMode(false);
-            server.setEnabledProtocols(TLS10ONLY);
             SSLEngineResult clientResult;
             SSLEngineResult serverResult;
             ByteBuffer raw = ByteBuffer.allocate(32768);
@@ -232,36 +229,41 @@ public void runTest() throws Exception {
             System.out.println("Server-to-Client:\n-----------------\n" +
                     dumpHexBytes(raw, 16, "\n", ":"));
 
-            // The client should parse this and throw an exception because
-            // It is unwiling to do TLS 1.0
+            // Change the handshake type field to client_hello which will
+            // cause the client to generate an unexpected_message alert
+            raw.put(5, (byte)0x1);
             clientResult = client.unwrap(raw, plain);
             checkEngineState(client, NEED_TASK, false, false);
             runDelegatedTasks(clientResult, client);
-            checkEngineState(client, NEED_UNWRAP, false, false);
+            checkEngineState(client, NEED_WRAP, true, false);
+            raw.clear();
 
+            // Now the client should wrap the exception
             try {
-                client.unwrap(raw, plain);
-            } catch (SSLException e) {
-                System.out.println("Client throws exception: " + e);
-                System.out.println("Engine closure status: isInboundDone="
-                        + client.isInboundDone() + ", isOutboundDone="
-                        + client.isOutboundDone() + ", handshake status="
-                        + client.getHandshakeStatus());
+                client.wrap(plain, raw);
+                throw new RuntimeException("The expected exception was not "
+                    + "thrown after the client processed an unexpected message.");
+            } catch (SSLProtocolException exc) {
+                // this is the expected code path
+                System.out.println("Client throws expected exception: " + exc);
+                System.out.println("Client engine state: " +
+                        "isInboundDone = "+ client.isInboundDone() +
+                        ", isOutboundDone = " + client.isOutboundDone() +
+                        ", handshake status = " + client.getHandshakeStatus());
                 checkEngineState(client, NEED_WRAP, true, false);
             }
             raw.clear();
-
-            // Now the client should wrap the exception
             client.wrap(plain, raw);
-            checkEngineState(client, NEED_UNWRAP, true, true);
-            raw.flip();
+            checkEngineState(client, NOT_HANDSHAKING, true, true);
             System.out.println("Client-to-Server:\n-----------------\n" +
                     dumpHexBytes(raw, 16, "\n", ":"));
+            raw.flip();
 
             try {
                 server.unwrap(raw, plain);
-                checkEngineState(server, NEED_UNWRAP, false, false);
-            } catch (SSLException e) {
+                throw new RuntimeException("The server did not throw an "
+                        + "SSLProtocolException after parsing an alert message.");
+            } catch (SSLProtocolException e) {
                 System.out.println("Server throws exception: " + e);
                 System.out.println("Engine closure status: isInboundDone="
                         + server.isInboundDone() + ", isOutboundDone="
@@ -338,15 +340,15 @@ private static void createManagerFactories()
         KeyStore empty_ts = KeyStore.getInstance("PKCS12");
         char[] passphrase = passwd.toCharArray();
 
-        keystore.load(new FileInputStream(keyFilename), passphrase);
-        truststore.load(new FileInputStream(trustFilename), passphrase);
+        keystore.load(new FileInputStream(KEYSTORE_PATH), passphrase);
+        truststore.load(new FileInputStream(TRUSTSTORE_PATH), passphrase);
         empty_ts.load(null, "".toCharArray());
 
         KMF = KeyManagerFactory.getInstance("PKIX");
         KMF.init(keystore, passphrase);
         TMF = TrustManagerFactory.getInstance("PKIX");
         TMF.init(truststore);
-        EMPTY_TMF = TrustManagerFactory.getInstance("PKIX");
+        TrustManagerFactory EMPTY_TMF = TrustManagerFactory.getInstance("PKIX");
         EMPTY_TMF.init(truststore);
     }
 
diff --git a/test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java b/test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java
deleted file mode 100644
index 69c38b535d2..00000000000
--- a/test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.awt.AWTException;
-import java.awt.Color;
-import java.awt.GridBagLayout;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Robot;
-import java.awt.image.MultiResolutionImage;
-import java.awt.image.RenderedImage;
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import javax.imageio.ImageIO;
-import javax.swing.JFrame;
-import javax.swing.JInternalFrame;
-import javax.swing.JLabel;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-
-/*
- * @test
- * @bug 8015739
- * @key headful
- * @summary Tests whether background color of JInternalFrame is visible
- * in the border region at different scales by checking the midpoints
- * and corners of the border.
- *
- * @requires (os.family == "windows")
- * @run main/othervm -Dsun.java2d.uiScale=1 InternalFrameBorderTest
- * @run main/othervm -Dsun.java2d.uiScale=1.25 InternalFrameBorderTest
- * @run main/othervm -Dsun.java2d.uiScale=1.5 InternalFrameBorderTest
- * @run main/othervm -Dsun.java2d.uiScale=1.75 InternalFrameBorderTest
- * @run main/othervm -Dsun.java2d.uiScale=2 InternalFrameBorderTest
- * @run main/othervm -Dsun.java2d.uiScale=2.5 InternalFrameBorderTest
- * @run main/othervm -Dsun.java2d.uiScale=3 InternalFrameBorderTest
- */
-
-/*
- * @test
- * @bug 8015739
- * @key headful
- * @summary Tests whether background color of JInternalFrame is visible
- * in the border region at different scales by checking the midpoints
- * and corners of the border.
- *
- * @requires (os.family == "mac" | os.family == "linux")
- * @run main/othervm -Dsun.java2d.uiScale=1 InternalFrameBorderTest
- * @run main/othervm -Dsun.java2d.uiScale=2 InternalFrameBorderTest
- */
-
-public class InternalFrameBorderTest {
-    private static final int FRAME_SIZE = 300;
-    private static final int INTFRAME_SIZE = 150;
-    private static final int MIDPOINT = INTFRAME_SIZE / 2;
-    private static final int BORDER_THICKNESS = 4;
-
-    private static final StringBuffer errorLog = new StringBuffer();
-
-    private static JFrame jFrame;
-    private static Rectangle jFrameBounds;
-    private static JInternalFrame iFrame;
-    private static Point iFrameLoc;
-    private static int iFrameMaxX;
-    private static int iFrameMaxY;
-
-    private static Robot robot;
-    private static String uiScale;
-
-    public static void main(String[] args) throws AWTException,
-            InterruptedException, InvocationTargetException {
-        try {
-            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
-        } catch (Exception e) {
-            System.out.println("Metal LAF class not supported");
-            return;
-        }
-
-        try {
-            robot = new Robot();
-            robot.setAutoDelay(200);
-            uiScale = System.getProperty("sun.java2d.uiScale");
-
-            SwingUtilities.invokeAndWait(InternalFrameBorderTest::createAndShowGUI);
-            robot.waitForIdle();
-            robot.delay(500);
-
-            SwingUtilities.invokeAndWait(() -> {
-                iFrameLoc = iFrame.getLocationOnScreen();
-                iFrameMaxX = iFrameLoc.x + INTFRAME_SIZE;
-                iFrameMaxY = iFrameLoc.y + INTFRAME_SIZE;
-                jFrameBounds = jFrame.getBounds();
-            });
-
-            // Check Borders
-            checkBorderMidPoints("TOP");
-            checkBorderMidPoints("RIGHT");
-            checkBorderMidPoints("BOTTOM");
-            checkBorderMidPoints("LEFT");
-
-            // Check Corner Diagonals
-            checkCorners("TOP_LEFT");
-            checkCorners("TOP_RIGHT");
-            checkCorners("BOTTOM_RIGHT");
-            checkCorners("BOTTOM_LEFT");
-
-            if (!errorLog.isEmpty()) {
-                saveScreenCapture("JIF_uiScale_" + uiScale + ".png");
-                throw new RuntimeException("Following error(s) occurred: \n"
-                        + errorLog);
-            }
-        } finally {
-            if (jFrame != null) {
-                jFrame.dispose();
-            }
-            robot.delay(500);
-        }
-    }
-
-    private static void checkBorderMidPoints(String borderDirection) {
-        int x, y;
-        int start, stop;
-
-        switch (borderDirection) {
-            case "TOP" -> {
-                x = iFrameLoc.x + MIDPOINT;
-                y = iFrameLoc.y + BORDER_THICKNESS;
-                start = iFrameLoc.y;
-                stop = iFrameLoc.y + BORDER_THICKNESS - 1;
-            }
-            case "RIGHT" -> {
-                x = iFrameMaxX - BORDER_THICKNESS;
-                y = iFrameLoc.y + MIDPOINT;
-                start = iFrameMaxX - BORDER_THICKNESS + 1;
-                stop = iFrameMaxX;
-            }
-            case "BOTTOM" -> {
-                x = iFrameLoc.x + MIDPOINT;
-                y = iFrameMaxY - BORDER_THICKNESS;
-                start = iFrameMaxY - BORDER_THICKNESS + 1;
-                stop = iFrameMaxY;
-            }
-            case "LEFT" -> {
-                x = iFrameLoc.x;
-                y = iFrameLoc.y + MIDPOINT;
-                start = iFrameLoc.x;
-                stop = iFrameLoc.x + BORDER_THICKNESS - 1;
-            }
-            default -> throw new IllegalStateException("Unexpected value: "
-                    + borderDirection);
-        }
-
-        boolean isVertical = borderDirection.equals("RIGHT")
-                || borderDirection.equals("LEFT");
-        boolean isHorizontal = borderDirection.equals("TOP")
-                || borderDirection.equals("BOTTOM");
-
-        robot.mouseMove(x, y);
-        for (int i = start; i < stop; i++) {
-            int locX = isVertical ? i : (iFrameLoc.x + MIDPOINT);
-            int locY = isHorizontal ? i : (iFrameLoc.y + MIDPOINT);
-            if (Color.RED.equals(robot.getPixelColor(locX, locY))) {
-                errorLog.append("At uiScale: " + uiScale
-                        + ", Red background color detected at "
-                        + borderDirection + " border.\n");
-                break;
-            }
-        }
-        robot.delay(300);
-    }
-
-    private static void checkCorners(String cornerLocation) {
-        int x, y;
-
-        switch (cornerLocation) {
-            case "TOP_LEFT" -> {
-                x = iFrameLoc.x;
-                y = iFrameLoc.y;
-            }
-            case "TOP_RIGHT" -> {
-                x = iFrameMaxX;
-                y = iFrameLoc.y;
-            }
-            case "BOTTOM_RIGHT" -> {
-                x = iFrameMaxX;
-                y = iFrameMaxY;
-            }
-            case "BOTTOM_LEFT" -> {
-                x = iFrameLoc.x;
-                y = iFrameMaxY;
-            }
-            default -> throw new IllegalStateException("Unexpected value: "
-                    + cornerLocation);
-        }
-
-        boolean isTop = cornerLocation.equals("TOP_LEFT")
-                || cornerLocation.equals("TOP_RIGHT");
-        boolean isLeft = cornerLocation.equals("TOP_LEFT")
-                || cornerLocation.equals("BOTTOM_LEFT");
-
-        robot.mouseMove(x, y);
-        for (int i = 0; i < BORDER_THICKNESS - 1; i++) {
-            int locX = isLeft ? (x + i) : (x - i);
-            int locY = isTop ? (y + i) : (y - i);
-            if (Color.RED.equals(robot.getPixelColor(locX, locY))) {
-                errorLog.append("At uiScale: " + uiScale + ", Red background color"
-                        + " detected at " + cornerLocation + " corner.\n");
-                break;
-            }
-        }
-        robot.delay(300);
-    }
-
-    private static void createAndShowGUI() {
-        jFrame = new JFrame();
-        jFrame.setSize(FRAME_SIZE, FRAME_SIZE);
-        jFrame.setLayout(null);
-        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-
-        JLabel scale = new JLabel("UI Scale: " + uiScale);
-        iFrame = new JInternalFrame("iframe", true);
-        iFrame.setLayout(new GridBagLayout());
-        iFrame.setBackground(Color.RED);
-        iFrame.add(scale);
-        iFrame.setLocation(30, 30);
-        jFrame.getContentPane().add(iFrame);
-        iFrame.setSize(INTFRAME_SIZE, INTFRAME_SIZE);
-        iFrame.setVisible(true);
-        jFrame.setLocation(150, 150);
-        jFrame.setVisible(true);
-    }
-
-    private static void saveScreenCapture(String filename) {
-        MultiResolutionImage mrImage = robot.createMultiResolutionScreenCapture(jFrameBounds);
-        List<Image> variants = mrImage.getResolutionVariants();
-        RenderedImage image = (RenderedImage) variants.get(variants.size() - 1);
-        try {
-            ImageIO.write(image, "png", new File(filename));
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}
diff --git a/test/jdk/javax/swing/plaf/metal/MetalBorders/ScaledMetalBorderTest.java b/test/jdk/javax/swing/plaf/metal/MetalBorders/ScaledMetalBorderTest.java
new file mode 100644
index 00000000000..ecf7b81b713
--- /dev/null
+++ b/test/jdk/javax/swing/plaf/metal/MetalBorders/ScaledMetalBorderTest.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.AWTException;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.GridBagLayout;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.image.MultiResolutionImage;
+import java.awt.image.RenderedImage;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import javax.imageio.ImageIO;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+
+/*
+ * @test
+ * @bug 8015739 8294484
+ * @key headful
+ * @summary Tests whether Metal borders for JFrame, JDialog and JInternalFrame
+ * scales correctly without any distortions by checking the midpoints and
+ * corners of the border.
+ *
+ * @requires (os.family == "windows")
+ * @run main/othervm -Dsun.java2d.uiScale=1 ScaledMetalBorderTest
+ * @run main/othervm -Dsun.java2d.uiScale=1.25 ScaledMetalBorderTest
+ * @run main/othervm -Dsun.java2d.uiScale=1.5 ScaledMetalBorderTest
+ * @run main/othervm -Dsun.java2d.uiScale=1.75 ScaledMetalBorderTest
+ * @run main/othervm -Dsun.java2d.uiScale=2 ScaledMetalBorderTest
+ * @run main/othervm -Dsun.java2d.uiScale=2.5 ScaledMetalBorderTest
+ * @run main/othervm -Dsun.java2d.uiScale=3 ScaledMetalBorderTest
+ */
+
+/*
+ * @test
+ * @bug 8015739 8294484
+ * @key headful
+ * @summary Tests whether Metal borders for JFrame, JDialog and JInternalFrame
+ * scales correctly without any distortions by checking the midpoints and
+ * corners of the border.
+ *
+ * @requires (os.family == "mac" | os.family == "linux")
+ * @run main/othervm -Dsun.java2d.uiScale=1 ScaledMetalBorderTest
+ * @run main/othervm -Dsun.java2d.uiScale=2 ScaledMetalBorderTest
+ */
+
+public class ScaledMetalBorderTest {
+    private static final int SIZE = 250;
+    private static final int INTFRAME_SIZE = 180;
+    private static int MIDPOINT = SIZE / 2;
+    private static final int BORDER_THICKNESS = 4;
+
+    private static final StringBuffer errorLog = new StringBuffer();
+
+    private static JFrame jFrame;
+    private static JDialog jDialog;
+    private static JInternalFrame iFrame;
+    private static Rectangle windowBounds;
+    private static Point windowLoc;
+    private static int windowMaxX;
+    private static int windowMaxY;
+
+    private static Robot robot;
+    private static String uiScale;
+    private static JLabel scale;
+
+    public static void main(String[] args) throws AWTException,
+            InterruptedException, InvocationTargetException {
+        try {
+            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+            JFrame.setDefaultLookAndFeelDecorated(true);
+            JDialog.setDefaultLookAndFeelDecorated(true);
+        } catch (Exception e) {
+            System.out.println("Metal LAF class not supported");
+            return;
+        }
+
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(100);
+            uiScale = System.getProperty("sun.java2d.uiScale");
+            scale = new JLabel("UI Scale: " + uiScale);
+
+            //Case 1: JFrame
+            SwingUtilities.invokeAndWait(ScaledMetalBorderTest::createFrame);
+            robot.waitForIdle();
+            robot.delay(100);
+            runTests("JFrame");
+
+            if (!errorLog.isEmpty()) {
+                saveScreenCapture("Frame_uiScale_" + uiScale + ".png");
+                System.err.println("JFrame at uiScale: " + uiScale);
+                throw new RuntimeException("Following error(s) occurred: \n"
+                        + errorLog);
+            }
+            errorLog.setLength(0); // to clear the StringBuffer before next test.
+
+            //Case 2: JDialog
+            SwingUtilities.invokeAndWait(ScaledMetalBorderTest::createDialog);
+            robot.waitForIdle();
+            robot.delay(100);
+            runTests("JDialog");
+
+            if (!errorLog.isEmpty()) {
+                saveScreenCapture("Dialog_uiScale_" + uiScale + ".png");
+                System.err.println("JDialog at uiScale: " + uiScale);
+                throw new RuntimeException("Following error(s) occurred: \n"
+                        + errorLog);
+            }
+            errorLog.setLength(0); // to clear the StringBuffer before next test.
+
+            //Case 3: JInternalFrame
+            SwingUtilities.invokeAndWait(ScaledMetalBorderTest::createJInternalFrame);
+            robot.waitForIdle();
+            robot.delay(100);
+            runTests("JIF");
+
+            if (!errorLog.isEmpty()) {
+                saveScreenCapture("JIF_uiScale_" + uiScale + ".png");
+                System.err.println("JInternalFrame at uiScale: " + uiScale);
+                throw new RuntimeException("Following error(s) occurred: \n"
+                        + errorLog);
+            }
+        } finally {
+            SwingUtilities.invokeAndWait(() ->{
+                if (jFrame != null) {
+                    jFrame.dispose();
+                }
+                if (jDialog != null) {
+                    jDialog.dispose();
+                }
+            });
+            robot.delay(200);
+        }
+    }
+
+    private static void runTests(String windowType) throws InterruptedException,
+                                                           InvocationTargetException {
+        SwingUtilities.invokeAndWait(() -> {
+            switch (windowType) {
+                case "JFrame" -> {
+                    windowLoc = jFrame.getLocationOnScreen();
+                    windowBounds = jFrame.getBounds();
+                    windowMaxX = windowLoc.x + SIZE;
+                    windowMaxY = windowLoc.y + SIZE;
+                }
+                case "JDialog" -> {
+                    windowLoc = jDialog.getLocationOnScreen();
+                    windowBounds = jDialog.getBounds();
+                    windowMaxX = windowLoc.x + SIZE;
+                    windowMaxY = windowLoc.y + SIZE;
+                }
+                case "JIF" -> {
+                    MIDPOINT = INTFRAME_SIZE / 2;
+                    windowLoc = iFrame.getLocationOnScreen();
+                    windowBounds = jFrame.getBounds();
+                    windowMaxX = windowLoc.x + INTFRAME_SIZE;
+                    windowMaxY = windowLoc.y + INTFRAME_SIZE;
+                }
+            }
+        });
+
+        // Check Borders
+        checkBorderMidPoints("TOP");
+        checkBorderMidPoints("RIGHT");
+        checkBorderMidPoints("BOTTOM");
+        checkBorderMidPoints("LEFT");
+
+        // Check Corner Diagonals
+        checkCorners("TOP_LEFT");
+        checkCorners("TOP_RIGHT");
+        checkCorners("BOTTOM_RIGHT");
+        checkCorners("BOTTOM_LEFT");
+    }
+
+    private static void checkBorderMidPoints(String borderDirection) {
+        int x, y;
+        int start, stop;
+
+        switch (borderDirection) {
+            case "TOP" -> {
+                x = windowLoc.x + MIDPOINT;
+                y = windowLoc.y + BORDER_THICKNESS;
+                start = windowLoc.y;
+                stop = windowLoc.y + BORDER_THICKNESS - 1;
+            }
+            case "RIGHT" -> {
+                x = windowMaxX - BORDER_THICKNESS;
+                y = windowLoc.y + MIDPOINT;
+                start = windowMaxX - BORDER_THICKNESS + 1;
+                stop = windowMaxX;
+            }
+            case "BOTTOM" -> {
+                x = windowLoc.x + MIDPOINT;
+                y = windowMaxY - BORDER_THICKNESS;
+                start = windowMaxY - BORDER_THICKNESS + 1;
+                stop = windowMaxY;
+            }
+            case "LEFT" -> {
+                x = windowLoc.x;
+                y = windowLoc.y + MIDPOINT;
+                start = windowLoc.x;
+                stop = windowLoc.x + BORDER_THICKNESS - 1;
+            }
+            default -> throw new IllegalStateException("Unexpected value: "
+                    + borderDirection);
+        }
+
+        boolean isVertical = borderDirection.equals("RIGHT")
+                || borderDirection.equals("LEFT");
+        boolean isHorizontal = borderDirection.equals("TOP")
+                || borderDirection.equals("BOTTOM");
+
+        robot.mouseMove(x, y);
+        for (int i = start; i < stop; i++) {
+            int locX = isVertical ? i : (windowLoc.x + MIDPOINT);
+            int locY = isHorizontal ? i : (windowLoc.y + MIDPOINT);
+            if (Color.RED.equals(robot.getPixelColor(locX, locY))) {
+                errorLog.append("At uiScale: " + uiScale
+                        + ", Red background color detected at "
+                        + borderDirection + " border.\n");
+                break;
+            }
+        }
+        robot.delay(100);
+    }
+
+    private static void checkCorners(String cornerLocation) {
+        int x, y;
+
+        switch (cornerLocation) {
+            case "TOP_LEFT" -> {
+                x = windowLoc.x;
+                y = windowLoc.y;
+            }
+            case "TOP_RIGHT" -> {
+                x = windowMaxX;
+                y = windowLoc.y;
+            }
+            case "BOTTOM_RIGHT" -> {
+                x = windowMaxX;
+                y = windowMaxY;
+            }
+            case "BOTTOM_LEFT" -> {
+                x = windowLoc.x;
+                y = windowMaxY;
+            }
+            default -> throw new IllegalStateException("Unexpected value: "
+                    + cornerLocation);
+        }
+
+        boolean isTop = cornerLocation.equals("TOP_LEFT")
+                || cornerLocation.equals("TOP_RIGHT");
+        boolean isLeft = cornerLocation.equals("TOP_LEFT")
+                || cornerLocation.equals("BOTTOM_LEFT");
+
+        robot.mouseMove(x, y);
+        for (int i = 0; i < BORDER_THICKNESS - 1; i++) {
+            int locX = isLeft ? (x + i) : (x - i);
+            int locY = isTop ? (y + i) : (y - i);
+            if (Color.RED.equals(robot.getPixelColor(locX, locY))) {
+                errorLog.append("At uiScale: " + uiScale + ", Red background color"
+                        + " detected at " + cornerLocation + " corner.\n");
+                break;
+            }
+        }
+        robot.delay(100);
+    }
+
+    private static void createFrame() {
+        jFrame = new JFrame("Frame with Metal Border");
+        jFrame.setSize(SIZE, SIZE);
+        jFrame.setBackground(Color.RED);
+        jFrame.getContentPane().setBackground(Color.RED);
+        jFrame.setLayout(new GridBagLayout());
+        jFrame.getContentPane().add(scale);
+        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        jFrame.setLocation(150, 150);
+        jFrame.setVisible(true);
+    }
+
+    private static void createDialog() {
+        jDialog = new JDialog((Frame) null , "Dialog with Metal Border");
+        jDialog.setSize(SIZE, SIZE);
+        jDialog.setBackground(Color.RED);
+        jDialog.getContentPane().setBackground(Color.RED);
+        jDialog.setLayout(new GridBagLayout());
+        jDialog.getContentPane().add(scale);
+        jDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+        jDialog.setLocation(150, 150);
+        jDialog.setVisible(true);
+    }
+
+    private static void createJInternalFrame() {
+        jFrame = new JFrame("JIF with Metal Border");
+        jFrame.setSize(SIZE, SIZE);
+        jFrame.setLayout(null);
+        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+
+        iFrame = new JInternalFrame("iframe", true);
+        iFrame.setLayout(new GridBagLayout());
+        iFrame.setBackground(Color.RED);
+        iFrame.add(scale);
+        iFrame.setLocation(30, 30);
+        jFrame.getContentPane().add(iFrame);
+        iFrame.setSize(INTFRAME_SIZE, INTFRAME_SIZE);
+        iFrame.setVisible(true);
+        jFrame.setLocation(150, 150);
+        jFrame.setVisible(true);
+    }
+
+    private static void saveScreenCapture(String filename) {
+        MultiResolutionImage mrImage = robot.createMultiResolutionScreenCapture(windowBounds);
+        List<Image> variants = mrImage.getResolutionVariants();
+        RenderedImage image = (RenderedImage) variants.get(variants.size() - 1);
+        try {
+            ImageIO.write(image, "png", new File(filename));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/test/hotspot/jtreg/gc/g1/TestNoUseHCC.java b/test/jdk/javax/swing/text/DefaultCaret/SetCaretRateTest.java
similarity index 56%
rename from test/hotspot/jtreg/gc/g1/TestNoUseHCC.java
rename to test/jdk/javax/swing/text/DefaultCaret/SetCaretRateTest.java
index 1f9595e4454..894ebfe5c71 100644
--- a/test/hotspot/jtreg/gc/g1/TestNoUseHCC.java
+++ b/test/jdk/javax/swing/text/DefaultCaret/SetCaretRateTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,27 +21,26 @@
  * questions.
  */
 
-package gc.g1;
+import javax.swing.text.Caret;
+import javax.swing.text.DefaultCaret;
 
 /*
- * @test TestNoUseHCC
- * @summary Check that G1 survives a GC without HCC enabled
- * @requires vm.gc.G1
- * @modules java.base/jdk.internal.misc
- * @library /test/lib
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -Xlog:gc+phases=debug -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx64M -XX:G1ConcRSLogCacheSize=0 gc.g1.TestNoUseHCC
+ * @test
+ * @bug 8301989
+ * @summary Test checks that there is no exception happens
+ *          when setting blink rate on a javax.swing.DefaultCaret that is not
+ *          associated with any text component
+ * @run main SetCaretRateTest
  */
-
-import jdk.test.whitebox.WhiteBox;
-
-public class TestNoUseHCC {
-
-    private static final WhiteBox WB = WhiteBox.getWhiteBox();
-
-    public static void main(String [] args) {
-        WB.youngGC();
+public class SetCaretRateTest {
+    public static void main(String[] args) {
+        Caret caret = new DefaultCaret();
+        caret.setBlinkRate(0);
+        caret.setBlinkRate(100);
+        caret.setBlinkRate(0);
+        caret = new DefaultCaret();
+        caret.setBlinkRate(100);
+        caret.setBlinkRate(0);
+        caret.setBlinkRate(100);
     }
 }
-
diff --git a/test/jdk/javax/xml/crypto/dsig/SecureValidationSystemProperty.java b/test/jdk/javax/xml/crypto/dsig/SecureValidationSystemProperty.java
new file mode 100644
index 00000000000..b58d2c28322
--- /dev/null
+++ b/test/jdk/javax/xml/crypto/dsig/SecureValidationSystemProperty.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8301260
+ * @summary Check that secureValidation system property works correctly
+ * @library /test/lib
+ * @run main/othervm -Dorg.jcp.xml.dsig.secureValidation=true SecureValidationSystemProperty
+ */
+
+/**
+ * @test
+ * @bug 8301260
+ * @summary Check that secureValidation system property works correctly
+ * @library /test/lib
+ * @run main/othervm -Dorg.jcp.xml.dsig.secureValidation=false SecureValidationSystemProperty
+ */
+
+import java.io.File;
+import javax.xml.crypto.dsig.XMLSignatureException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import org.w3c.dom.Document;
+
+import jdk.test.lib.security.SecurityUtils;
+import jdk.test.lib.security.XMLUtils;
+import static jdk.test.lib.security.XMLUtils.Validator;
+
+public class SecureValidationSystemProperty {
+
+    private final static String DIR = System.getProperty("test.src", ".");
+    private final static String DATA_DIR =
+        DIR + System.getProperty("file.separator") + "data";
+
+    public static void main(String[] args) throws Exception{
+        // Re-enable sha1 algs. We just want to make sure DSA keys less than
+        // 1024 bits are rejected correctly.
+        SecurityUtils.removeAlgsFromDSigPolicy("sha1");
+
+        String prop = System.getProperty("org.jcp.xml.dsig.secureValidation");
+        if (prop == null) {
+            throw new Exception("Secure validation system property not set");
+        }
+        boolean isSet = Boolean.parseBoolean(prop);
+
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        Document doc = dbf.newDocumentBuilder()
+            .parse(new File(DATA_DIR, "signature-enveloped-dsa-512.xml"));
+        Validator validator = XMLUtils.validator();
+
+        // try again and make sure system property supersedes
+        // XMLContext property
+        validator.secureValidation(!isSet);
+        validate(validator, doc, isSet);
+    }
+
+    private static void validate(Validator validator, Document doc,
+            boolean isSet) throws Exception {
+        try {
+            validator.validate(doc);
+            if (isSet) {
+                throw new Exception("signature expected to be rejected " +
+                    "because it was signed with a 512-bit DSA key which is " +
+                    "restricted");
+            }
+        } catch (XMLSignatureException e) {
+            if (!isSet) {
+                throw new Exception("signature not expected to be rejected " +
+                    "because secure validation mode is not enabled");
+            } else {
+                Throwable cause = e.getCause();
+                if (cause == null || !cause.getMessage().equals(
+                        "DSA keys less than 1024 bits are forbidden when " +
+                        "secure validation is enabled")) {
+                    throw new Exception("signature rejected for wrong reason", e);
+                }
+            }
+        }
+    }
+}
diff --git a/test/jdk/javax/xml/crypto/dsig/data/signature-enveloped-dsa-512.xml b/test/jdk/javax/xml/crypto/dsig/data/signature-enveloped-dsa-512.xml
new file mode 100644
index 00000000000..4f19ee2d3eb
--- /dev/null
+++ b/test/jdk/javax/xml/crypto/dsig/data/signature-enveloped-dsa-512.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><Envelope xmlns="http://example.org/envelope"><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>l73jZE8SFKG5at7i5Yj+q2aNIzU=</DigestValue></Reference></SignedInfo><SignatureValue>RJiGe6of7CxloaPR9yq6Hw5r+aElz72MAVAfKBgpqnQaNFnDp8dNiQ==</SignatureValue><KeyInfo><KeyValue><DSAKeyValue><P>/KaCzo4Syrom78z3EQ5SbbB4sF7ey80etKII864WF64B81uRpH5t9jQTxeEu0ImbzRMqzVDZkVG9
+xD7nN1kuFw==</P><Q>li7dzDacuo67Jg7mtqEm2TRuOMU=</Q><G>Z4Rxsnqc9E7pGknFFH2xqaryRPBaQ01khpMdLRQnG541Awtx/XPaF5Bpsy4pNWMOHCBiNU0Nogps
+QW5QvnlMpA==</G><Y>nBZMgkVdGHADOfd+XQ4x9cirI5pZg1Ly0cQDLgrXpKn4CP8MJwL9HUnVJ1k7OpXdzOyzJSY75T3u
+vwu1XEEGHg==</Y></DSAKeyValue></KeyValue></KeyInfo></Signature></Envelope>
diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java
index acdae0711d1..a375e9de7ea 100644
--- a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java
+++ b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java
@@ -97,7 +97,6 @@ public static void main(String[] args) throws IOException {
             "CLDGRoots",
             "CMRefRoots",
             "MergeER",
-            "MergeHCC",
             "MergeRS",
             "MergeLB",
             "ScanHR",
@@ -106,7 +105,7 @@ public static void main(String[] args) throws IOException {
             "Termination",
             "RedirtyCards",
             "RecalculateUsed",
-            "ResetHotCardCache",
+            "ResizeTLABs",
             "FreeCSet",
             "UpdateDerivedPointers",
             "EagerlyReclaimHumongousObjects",
diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData05.java b/test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java
similarity index 60%
rename from test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData05.java
rename to test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java
index 01704eca297..bb057cce386 100644
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData05.java
+++ b/test/jdk/jdk/jfr/jcmd/TestJcmdOptionSpecifiedOnce.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -20,27 +20,27 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
-package gc.g1;
+package jdk.jfr.jcmd;
 
 /**
- * @test TestShrinkAuxiliaryData05
- * @key randomness
- * @bug 8038423 8061715 8078405
- * @summary Checks that decommitment occurs for JVM with different
- * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
- * @requires vm.gc.G1
- * @library /test/lib
- * @library /
- * @modules java.base/jdk.internal.misc
- *          java.management
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/timeout=720 gc.g1.TestShrinkAuxiliaryData05
+ * @test
+ * @summary The test verifies that options can only be specified once with jcmd JFR
+ * @key jfr
+ * @requires vm.hasJFR
+ * @library /test/lib /test/jdk
+ * @modules jdk.jfr/jdk.jfr.internal.dcmd
+ * @run main/othervm jdk.jfr.jcmd.TestJcmdOptionSpecifiedOnce
  */
-public class TestShrinkAuxiliaryData05 {
+public class TestJcmdOptionSpecifiedOnce {
 
     public static void main(String[] args) throws Exception {
-        new TestShrinkAuxiliaryData(5).test();
+
+        testJCmdConflict();
+    }
+
+    private static void testJCmdConflict() {
+        var output= JcmdHelper.jcmd("JFR.start name=hello name=greetings");
+        output.shouldContain("name can only be specified once");
     }
 }
+
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java b/test/jdk/jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java
new file mode 100644
index 00000000000..756402b0c60
--- /dev/null
+++ b/test/jdk/jdk/jfr/startupargs/TestStartupOptionSpecifiedOnce.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.jfr.startupargs;
+
+import jdk.test.lib.process.ProcessTools;
+
+/**
+ * @test The test verifies that options can only be specified once with --XX:StartFlightRecording
+ * @key jfr
+ * @requires vm.hasJFR
+ * @library /test/lib /test/jdk
+ * @run main jdk.jfr.startupargs.TestStartupOptionSpecifiedOnce
+ */
+public class TestStartupOptionSpecifiedOnce {
+
+    public static void main(String[] args) throws Exception {
+        testStartFlightRecordingConflict();
+        testConflictThreeOptions();
+        testAbleMultipleOption();
+    }
+
+    private static void testStartFlightRecordingConflict() throws Exception {
+        var output = ProcessTools.executeTestJava("-XX:StartFlightRecording:disk=true,disk=false,name=cat,name=dog");
+        output.shouldContain("disk and name can only be specified once.");
+    }
+
+    private static void testConflictThreeOptions() throws Exception {
+        var output = ProcessTools.executeTestJava("-XX:StartFlightRecording:name=abc,name=def,disk=true,disk=false,delay=1s,delay=2s");
+        output.shouldContain("name, disk and delay can only be specified once.");
+    }
+
+    private static void testAbleMultipleOption() throws Exception {
+        var output = ProcessTools.executeTestJava("-XX:StartFlightRecording:settings=default,settings=profile");
+        output.shouldNotContain("settings can only be specified once");
+    }
+}
diff --git a/test/jdk/jni/nullCaller/NullCallerTest.java b/test/jdk/jni/nullCaller/NullCallerTest.java
index 810e0245b86..c7a25b693d0 100644
--- a/test/jdk/jni/nullCaller/NullCallerTest.java
+++ b/test/jdk/jni/nullCaller/NullCallerTest.java
@@ -32,7 +32,6 @@
  *          jdk.compiler
  * @build NullCallerTest
  *        jdk.test.lib.compiler.CompilerUtils
- * @requires os.family != "aix"
  * @run main/native NullCallerTest
  */
 
diff --git a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp
index fef6818d66c..3d79befd941 100644
--- a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp
+++ b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp
@@ -22,6 +22,9 @@
  */
 
 #include "CallHelper.hpp"
+#ifdef AIX
+#include <pthread.h>
+#endif //AIX
 
 /*
  * Test for JDK-8280902
@@ -156,7 +159,7 @@ void getResourceAsStream(JNIEnv *env) {
         class_ClosedResources, env->NewStringUTF("test.txt"));
 }
 
-int main(int argc, char** args) {
+static void* run(void *arg) {
     JavaVM *jvm;
     JNIEnv *env;
     JavaVMInitArgs vm_args;
@@ -184,3 +187,22 @@ int main(int argc, char** args) {
     return 0;
 }
 
+int main(int argc, char *argv[]) {
+#ifdef AIX
+    size_t adjusted_stack_size = 1024*1024;
+    pthread_t id;
+    int result;
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setstacksize(&attr, adjusted_stack_size);
+    result = pthread_create(&id, &attr, run, (void *)argv);
+    if (result != 0) {
+      fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
+      return -1;
+    }
+    pthread_join(id, NULL);
+#else
+    run(&argv);
+#endif //AIX
+}
+
diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java
new file mode 100644
index 00000000000..5e058233370
--- /dev/null
+++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8245654
+ * @summary Interoperability tests with Certigna Root CA from Dhimyotis
+ * @build ValidatePathWithParams
+ * @run main/othervm -Djava.security.debug=certpath CertignaCA OCSP
+ * @run main/othervm -Djava.security.debug=certpath CertignaCA CRL
+ */
+
+/*
+ * Obtain TLS test artifacts for Certigna Root CA from:
+ *
+ * Valid TLS Certificates:
+ * https://valid.servicesca.dhimyotis.com/
+ *
+ * Revoked TLS Certificates:
+ * https://revoked.servicesca.dhimyotis.com/
+ */
+public class CertignaCA {
+
+    // Owner: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036,
+    // OU=0002 48146308100036, O=DHIMYOTIS, C=FR
+    // Issuer: CN=Certigna, O=Dhimyotis, C=FR
+    // Serial number: 6f82fa28acd6f784bb5b120ba87367ad
+    // Valid from: Wed Nov 25 03:33:52 PST 2015 until: Sat Nov 22 03:33:52 PST 2025
+    private static final String INT = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIGFjCCBP6gAwIBAgIQb4L6KKzW94S7WxILqHNnrTANBgkqhkiG9w0BAQsFADA0\n" +
+            "MQswCQYDVQQGEwJGUjESMBAGA1UECgwJRGhpbXlvdGlzMREwDwYDVQQDDAhDZXJ0\n" +
+            "aWduYTAeFw0xNTExMjUxMTMzNTJaFw0yNTExMjIxMTMzNTJaMH0xCzAJBgNVBAYT\n" +
+            "AkZSMRIwEAYDVQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgx\n" +
+            "MDAwMzYxHTAbBgNVBGEMFE5UUkZSLTQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQQDDBRD\n" +
+            "ZXJ0aWduYSBTZXJ2aWNlcyBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC\n" +
+            "ggIBALPM+7LpWBz9wFcPaTc3xnB+5g0XrnptB0EPPfrR04vO52Ykm4ky1d4ZLd10\n" +
+            "tbM1fa1RqNSOVWWg93O4pL7zCFKlz6JV74ZZVhHpEAwzBwv2oPnxvVbxtSN67xsS\n" +
+            "Y66ahUYxjzs8+3FhmsiRxqwnTYvK2u70uglUvRisOKyTL/M6JnrC4y8tlmoz7OSa\n" +
+            "5BmBMVplJFQtvmON6N9aHLvYMz+EyJPCbXL6pELxeHjFT5QmIaRamsr2DOTaCjtB\n" +
+            "ZKI1Wnh3X7lnbjM8MESJiV2t7E9tIQNG0Z/HI3tO4aaUMum3KysY5sC8v3vi7rry\n" +
+            "GidgzHQhrtP0ZXWW5UH/k7umLS/P/XXWnCFpc2Lxa1uDGfc2im7xibRoPP+JNZsz\n" +
+            "N76euFlls6jyEXAiwnVr14tVVTewLK0OWs5SJHpEKp8PGMZRDj59EmMvokWwzL6Q\n" +
+            "zNZ6vVAp00oOm05sbspNY9+MFqGKKUsKvhFGEa4XmRNxDe6KswLcjPZB+NKHZ0QW\n" +
+            "Fd4ip5C5XmEK/8qIPjwVr9dah9+oiHGGO8Wx7gJAMF5DTmkvW7GhqCKj1LmHnabj\n" +
+            "zc8av6kxWVQZi/C7HCm9i/W4wio+JA2EAFLqNL3GPNbK9kau4yPhQt/c7zxzo0OH\n" +
+            "nlsV4THCG7oOCd3cfCiyfQcb3FBt6OSpaKRZxjCLBwP00r0fAgMBAAGjggHZMIIB\n" +
+            "1TASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU\n" +
+            "rOyGj0s3HLh/FxsZ0K7oTuM0XBIwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF\n" +
+            "9lo53BGhOKQ2MDQxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAP\n" +
+            "BgNVBAMMCENlcnRpZ25hggkA/tzjAQ/JSP8wSQYDVR0gBEIwQDA+BgoqgXoBgTEB\n" +
+            "AAECMDAwLgYIKwYBBQUHAgEWImh0dHBzOi8vd3d3LmNlcnRpZ25hLmZyL2F1dG9y\n" +
+            "aXRlcy8wfAYIKwYBBQUHAQEEcDBuMDQGCCsGAQUFBzAChihodHRwOi8vYXV0b3Jp\n" +
+            "dGUuY2VydGlnbmEuZnIvY2VydGlnbmEuZGVyMDYGCCsGAQUFBzAChipodHRwOi8v\n" +
+            "YXV0b3JpdGUuZGhpbXlvdGlzLmNvbS9jZXJ0aWduYS5kZXIwYQYDVR0fBFowWDAp\n" +
+            "oCegJYYjaHR0cDovL2NybC5jZXJ0aWduYS5mci9jZXJ0aWduYS5jcmwwK6ApoCeG\n" +
+            "JWh0dHA6Ly9jcmwuZGhpbXlvdGlzLmNvbS9jZXJ0aWduYS5jcmwwDQYJKoZIhvcN\n" +
+            "AQELBQADggEBAGLft7gIuGPZVfg0cTM+HT2xAZFPDb/2+siH06x+dH044zMKbBIN\n" +
+            "bRzhKipwB1A3MW8FQjveE9tyrfyuqZE/X+o2SlGcdNV44ybYkxo4f6kcLEavV/IW\n" +
+            "+oFEnojZlhpksYcxrvQoEyqkAwshe8IS2KtZHKVACrt+XSs0lwvy7ALGmHaF7A4b\n" +
+            "y6cZWItA7Lhj8XWp+8tBJDj7HocRbWtxzEODdBuyMgJzFrNjc+97J0vH/K0+3yjm\n" +
+            "kczpKshMA0tM+MF9XDMN/MuwrPmUWGO/fHiqHgUp8yqeWtl1n44ZxkkK1t9GRwhn\n" +
+            "DWLv73/xhTmdhWYQ/reo0GbgBoLiltKmIJQ=\n" +
+            "-----END CERTIFICATE-----";
+
+    // Owner: SERIALNUMBER=S230100953, CN=valid.servicesca.dhimyotis.com,
+    // OU=0002 48146308100036, O=DHIMYOTIS, L=VILLENEUVE D'ASCQ, C=FR
+    // Issuer: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036,
+    // OU=0002 48146308100036, O=DHIMYOTIS, C=FR
+    // Serial number: 2959798fe2e0e7b43810169ae938bc5f
+    // Valid from: Sun Mar 13 16:00:00 PDT 2022 until: Mon Mar 13 15:59:59 PDT 2023
+    private static final String VALID = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIIkzCCBnugAwIBAgIQKVl5j+Lg57Q4EBaa6Ti8XzANBgkqhkiG9w0BAQsFADB9\n" +
+            "MQswCQYDVQQGEwJGUjESMBAGA1UECgwJREhJTVlPVElTMRwwGgYDVQQLDBMwMDAy\n" +
+            "IDQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQRhDBROVFJGUi00ODE0NjMwODEwMDAzNjEd\n" +
+            "MBsGA1UEAwwUQ2VydGlnbmEgU2VydmljZXMgQ0EwHhcNMjIwMzEzMjMwMDAwWhcN\n" +
+            "MjMwMzEzMjI1OTU5WjCBmTELMAkGA1UEBhMCRlIxGjAYBgNVBAcMEVZJTExFTkVV\n" +
+            "VkUgRCdBU0NRMRIwEAYDVQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgx\n" +
+            "NDYzMDgxMDAwMzYxJzAlBgNVBAMMHnZhbGlkLnNlcnZpY2VzY2EuZGhpbXlvdGlz\n" +
+            "LmNvbTETMBEGA1UEBRMKUzIzMDEwMDk1MzCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" +
+            "ADCCAQoCggEBALpeGHbzRGnv1C0PdJS0nT+Cx98Pw8ctaw51m9Vlk2j8AFGZRu8r\n" +
+            "lX3noQYX0AIfcbk6KqPAreIvJQV0UgM5jxt3mIQF7iU+55MG4mWmSJgKDDq4b3ck\n" +
+            "WdBy0KpSBqLmB9sHyTNk9NilNu7VwG03HGIltWA2uQFJGC8CkxwAFpMCQ9RVYw2Z\n" +
+            "NkL/SsiPgrRLiCJZjesk1oAcLnLp7hbelfUB2Z71VmuDDlom7CsLvdN8eIG+Lj+V\n" +
+            "wkGmH6AbVGvbFniFDLCNDSJWCQ9AHeO+i0CM/wd2gBRSgm993p2YMxu5mVZjz/rp\n" +
+            "ELaCYjulvNZKvPIFoNe8qsxlXRWeqWaHuPsCAwEAAaOCA/AwggPsMIHkBggrBgEF\n" +
+            "BQcBAQSB1zCB1DA4BggrBgEFBQcwAoYsaHR0cDovL2F1dG9yaXRlLmRoaW15b3Rp\n" +
+            "cy5jb20vc2VydmljZXNjYS5kZXIwNgYIKwYBBQUHMAKGKmh0dHA6Ly9hdXRvcml0\n" +
+            "ZS5jZXJ0aWduYS5mci9zZXJ2aWNlc2NhLmRlcjAwBggrBgEFBQcwAYYkaHR0cDov\n" +
+            "L3NlcnZpY2VzY2Eub2NzcC5kaGlteW90aXMuY29tMC4GCCsGAQUFBzABhiJodHRw\n" +
+            "Oi8vc2VydmljZXNjYS5vY3NwLmNlcnRpZ25hLmZyMB8GA1UdIwQYMBaAFKzsho9L\n" +
+            "Nxy4fxcbGdCu6E7jNFwSMAkGA1UdEwQCMAAwYQYDVR0gBFowWDAIBgZngQwBAgIw\n" +
+            "TAYLKoF6AYExAgUBAQEwPTA7BggrBgEFBQcCARYvaHR0cHM6Ly93d3cuY2VydGln\n" +
+            "bmEuY29tL2F1dG9yaXRlLWNlcnRpZmljYXRpb24wZQYDVR0fBF4wXDAroCmgJ4Yl\n" +
+            "aHR0cDovL2NybC5jZXJ0aWduYS5mci9zZXJ2aWNlc2NhLmNybDAtoCugKYYnaHR0\n" +
+            "cDovL2NybC5kaGlteW90aXMuY29tL3NlcnZpY2VzY2EuY3JsMBMGA1UdJQQMMAoG\n" +
+            "CCsGAQUFBwMBMA4GA1UdDwEB/wQEAwIFoDBIBgNVHREEQTA/gh12YWxpZC5zZXJ2\n" +
+            "aWNlc2NhLmNlcnRpZ25hLmNvbYIedmFsaWQuc2VydmljZXNjYS5kaGlteW90aXMu\n" +
+            "Y29tMB0GA1UdDgQWBBSGQwwMIdxiI7P+CFU/Z968XZaSGzCCAX0GCisGAQQB1nkC\n" +
+            "BAIEggFtBIIBaQFnAHUArfe++nz/EMiLnT2cHj4YarRnKV3PsQwkyoWGNOvcgooA\n" +
+            "AAF/h9eOGgAABAMARjBEAiBaneK2CTn9lH28CUnL2C2/WklUYkvygMiDrtCIUXfw\n" +
+            "gQIgJrGxwgGlsYzUdZyZY/oNWSLByO8/Jb5LXbNibdk5SnAAdwDoPtDaPvUGNTLn\n" +
+            "Vyi8iWvJA9PL0RFr7Otp4Xd9bQa9bgAAAX+H14/NAAAEAwBIMEYCIQCVtuV9p/Ug\n" +
+            "IhwVoMUjPp1KzGte/FmDaKPx432VjOpD+AIhANKWkDEuVnMzPH8sdJCL+eXoB0Q7\n" +
+            "0mpe5dHEiFJS8lTBAHUAs3N3B+GEUPhjhtYFqdwRCUp5LbFnDAuH3PADDnk2pZoA\n" +
+            "AAF/h9eTcQAABAMARjBEAiAjdYhnzPe9lJksk94ngl7PLDRi71tSRN7SslibEyv+\n" +
+            "XAIgLQ5NKQAaJnF8oA7WnHB8gyJ/8kqZi52d1WFgARDLR30wDQYJKoZIhvcNAQEL\n" +
+            "BQADggIBAJhLhW5Gh9yOPKsrMhABd7U5juc5ev97c6s7Az70Yr5/EtH6TlgC6a1N\n" +
+            "i0yzFOeXzAR8Svsq6HzqP9kMJkEFIrdWH8JZdEv871EjYetEzLLnO0m+dNEROJAh\n" +
+            "fcJ2w2LufPNaQ327tGY/DxDH9jdtgquReO01bPlJ0Yc5J3maz4XapeUm/kQ8dRzS\n" +
+            "0UBOxfUlEMpDatZzg7wugy7g9vOndW/VbtbN5Iioq2bjuykPJZfZUx4cCAmLUS7w\n" +
+            "bqPThQ54PnybiPXaF8cH1Gq0Rs/lGB1erzRXRXHgMy61mFY944r13oATnSdTy8Gm\n" +
+            "QoMsVp9w7WBRo8O4PR606Ke8Ufm9Kg2GJ1sHClf70FNFO/OSFlr3BLDG0vEMdgVW\n" +
+            "9QLu6UQXa9PhWMoo030k5fmUySzIUljXnstj3rgcD2HE1UrobTqyRHbbQ8JVWaF0\n" +
+            "PrPR4WDFI9dY0jixVQucKlX6FCqsyNrJF8GWDlZH+Cd8bk+MA9fKUuX/vmoOc2d+\n" +
+            "bvOCliME7YjAJkyclk6yiFIMnqyh+TD0d8WbjE94YC/293Xqb6WGkRhhsCX9RUrk\n" +
+            "I6QbS2uicCFGjRsPmjvMkDDxS00MShRl2K/KpsAx68Cv/Gcw3bv31obwNXTB2IBg\n" +
+            "gI0MfBHnjIp1nmNvCNmVIP52YrGQyC2JE7+GZUWTuwUVeDgBhiEZ\n" +
+            "-----END CERTIFICATE-----";
+
+    // Owner: SERIALNUMBER=S230120951, CN=revoked.servicesca.dhimyotis.com,
+    // OU=0002 48146308100036, O=DHIMYOTIS, L=VILLENEUVE D'ASCQ, C=FR
+    // Issuer: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036,
+    // OU=0002 48146308100036, O=DHIMYOTIS, C=FR
+    // Serial number: f88f2566b3dbf73763622db9b2bf9cc
+    // Valid from: Sun Mar 13 16:00:00 PDT 2022 until: Mon Mar 13 15:59:59 PDT 2023
+    private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIImTCCBoGgAwIBAgIQD4jyVms9v3N2NiLbmyv5zDANBgkqhkiG9w0BAQsFADB9\n" +
+            "MQswCQYDVQQGEwJGUjESMBAGA1UECgwJREhJTVlPVElTMRwwGgYDVQQLDBMwMDAy\n" +
+            "IDQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQRhDBROVFJGUi00ODE0NjMwODEwMDAzNjEd\n" +
+            "MBsGA1UEAwwUQ2VydGlnbmEgU2VydmljZXMgQ0EwHhcNMjIwMzEzMjMwMDAwWhcN\n" +
+            "MjMwMzEzMjI1OTU5WjCBmzELMAkGA1UEBhMCRlIxGjAYBgNVBAcMEVZJTExFTkVV\n" +
+            "VkUgRCdBU0NRMRIwEAYDVQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgx\n" +
+            "NDYzMDgxMDAwMzYxKTAnBgNVBAMMIHJldm9rZWQuc2VydmljZXNjYS5kaGlteW90\n" +
+            "aXMuY29tMRMwEQYDVQQFEwpTMjMwMTIwOTUxMIIBIjANBgkqhkiG9w0BAQEFAAOC\n" +
+            "AQ8AMIIBCgKCAQEAouvIzemKChCjYICW+TzRigLkqaTdMLnaPlGaXyCCoEUS6nkK\n" +
+            "QnrwTgebf1X9/mwSAuvTo3Ck7CVgE8AMqsPTluSjezCJuED/F3HYy2YsbIhnVK/i\n" +
+            "uSzKsDGVY3RlVNm2MA2viVTNBbOFhk4kefYqpDCmp3EGvIDOCb7Y5PTuKKQ79s97\n" +
+            "uDm+0WoBnOdwSuZMUg+hvINBgu2JQFwiWP0g/SxoK6Ci9SVokM3zR4KgECkMVArf\n" +
+            "cH0dN+5SYvByaGegQJy7TdKqDsf1lIHM19tUXcxOBNRgV3Rf7WMNIlERtLXjRfke\n" +
+            "IWXf8QtXRVIH/i/PoVTDo2qvQOMnZFY/Eb5dFQIDAQABo4ID9DCCA/AwgeQGCCsG\n" +
+            "AQUFBwEBBIHXMIHUMDgGCCsGAQUFBzAChixodHRwOi8vYXV0b3JpdGUuZGhpbXlv\n" +
+            "dGlzLmNvbS9zZXJ2aWNlc2NhLmRlcjA2BggrBgEFBQcwAoYqaHR0cDovL2F1dG9y\n" +
+            "aXRlLmNlcnRpZ25hLmZyL3NlcnZpY2VzY2EuZGVyMDAGCCsGAQUFBzABhiRodHRw\n" +
+            "Oi8vc2VydmljZXNjYS5vY3NwLmRoaW15b3Rpcy5jb20wLgYIKwYBBQUHMAGGImh0\n" +
+            "dHA6Ly9zZXJ2aWNlc2NhLm9jc3AuY2VydGlnbmEuZnIwHwYDVR0jBBgwFoAUrOyG\n" +
+            "j0s3HLh/FxsZ0K7oTuM0XBIwCQYDVR0TBAIwADBhBgNVHSAEWjBYMAgGBmeBDAEC\n" +
+            "AjBMBgsqgXoBgTECBQEBATA9MDsGCCsGAQUFBwIBFi9odHRwczovL3d3dy5jZXJ0\n" +
+            "aWduYS5jb20vYXV0b3JpdGUtY2VydGlmaWNhdGlvbjBlBgNVHR8EXjBcMCugKaAn\n" +
+            "hiVodHRwOi8vY3JsLmNlcnRpZ25hLmZyL3NlcnZpY2VzY2EuY3JsMC2gK6Aphido\n" +
+            "dHRwOi8vY3JsLmRoaW15b3Rpcy5jb20vc2VydmljZXNjYS5jcmwwEwYDVR0lBAww\n" +
+            "CgYIKwYBBQUHAwEwDgYDVR0PAQH/BAQDAgWgMEwGA1UdEQRFMEOCH3Jldm9rZWQu\n" +
+            "c2VydmljZXNjYS5jZXJ0aWduYS5jb22CIHJldm9rZWQuc2VydmljZXNjYS5kaGlt\n" +
+            "eW90aXMuY29tMB0GA1UdDgQWBBTGIed1eHBS8Z1H3PdMkItpjyjq2TCCAX0GCisG\n" +
+            "AQQB1nkCBAIEggFtBIIBaQFnAHcArfe++nz/EMiLnT2cHj4YarRnKV3PsQwkyoWG\n" +
+            "NOvcgooAAAF/h9g4MAAABAMASDBGAiEAp/1fQB730JrX9YGD3d1Uq7rTAL95tMKe\n" +
+            "G6kgUP1GEWoCIQCzi6feA3cImTH6tVZALNEmve/n8SVFAvD2AvX8ioCD9QB1AOg+\n" +
+            "0No+9QY1MudXKLyJa8kD08vREWvs62nhd31tBr1uAAABf4fYNHcAAAQDAEYwRAIg\n" +
+            "Dnd8oOV7/MuaiyR23qbdRVf1kBSsDxnLp1/vRdD0JTYCIAw7LuZalEVa/0KpuNHs\n" +
+            "NIdUJgV4Vioa2xkb9fdPIhtkAHUAs3N3B+GEUPhjhtYFqdwRCUp5LbFnDAuH3PAD\n" +
+            "Dnk2pZoAAAF/h9g7nwAABAMARjBEAiA80M1W3V3iKjm6Dwn+hKkmvGiuXZoM6o3f\n" +
+            "QJsZ2ZOx0QIgUiS3I83WzoCdD4qO9rlmDQhRD69CeVzCgLtkaTPz3JYwDQYJKoZI\n" +
+            "hvcNAQELBQADggIBADKub0gNyasTvURoYukQCllqDC+SvWA4TURBcmQMNjdVkreJ\n" +
+            "B3O91HZhTyhrCBJxybeIG89zuRI6rjTpHCQGFqtP7968NA3eUlxGGnAPpw6VbN47\n" +
+            "Ake+CRI9XnhxcKmTGm987DjtIBH42BedS59P1T56grZP5ysOog9Hz4eYo2ytbZqt\n" +
+            "P/DHggivymaaiIaBsqup8C7/XN3vVAa/yo1FeLJ48i1d0M9hjGBUFMajd8Y5+pE7\n" +
+            "p6Nb5mT1LXbetORYXMyG3MiJQPBAr1dLnRGnOZxc1Kxa1QwoAFQAFIXFpqfBwfHi\n" +
+            "NaSDdFS/wLbpe7UvtC8FWLq9sgITDEkPqDPCsbu8Vc7OxaMhBJ7HQGaAYMReGADG\n" +
+            "Elx9ffAc+dFR62zFnqMLouaEznZ7FVNmU3cYbrFVBvnGmoDRe0AKUoYv5DCiawUg\n" +
+            "qeQS69DgG7DOE5VIDaWX2Cevy81mz7O8EVQsyS15J/MUxzWfQpRaHUqkge6G9FSH\n" +
+            "hF/Nm48oWgpWop5aIF2O6bA/Bt1VvAWdypUPUr4gtpYIQoOQBzTFgBVWUeOTOImE\n" +
+            "avvpzSwGQfZkB7t5PcAQ+zYGxWq7fr30/qY3geePcXJCGWS6PXyj8lNn4CaJ2sMF\n" +
+            "GKxNJGD49/5uoxi3b3TzGUn/3eG2qP2RZoXZ6ZPLAo+moIy3XLwMoZm3Im8r\n" +
+            "-----END CERTIFICATE-----";
+
+    public static void main(String[] args) throws Exception {
+
+        ValidatePathWithParams pathValidator;
+        String[] validChainToValidate;
+        String[] revChainToValidate;
+
+        if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) {
+            pathValidator = new ValidatePathWithParams(null);
+            pathValidator.enableCRLCheck();
+
+            validChainToValidate = new String[]{VALID, INT};
+            revChainToValidate = new String[]{REVOKED, INT};
+        } else {
+            // OCSP check by default
+            // int certificate doesn't specify OCSP responder
+            pathValidator = new ValidatePathWithParams(new String[]{INT});
+            pathValidator.enableOCSPCheck();
+
+            validChainToValidate = new String[]{VALID};
+            revChainToValidate = new String[]{REVOKED};
+        }
+
+        // Validate valid
+        pathValidator.validate(validChainToValidate,
+                ValidatePathWithParams.Status.GOOD, null, System.out);
+
+        // Validate Revoked
+        pathValidator.validate(revChainToValidate,
+                ValidatePathWithParams.Status.REVOKED,
+                "Mon Mar 14 03:00:16 PDT 2022", System.out);
+    }
+}
+
diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
index 00abee89191..476da451ad4 100644
--- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
+++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @bug 8189131 8198240 8191844 8189949 8191031 8196141 8204923 8195774 8199779
  *      8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136
  *      8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320
- *      8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083
+ *      8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654
  * @summary Check root CA entries in cacerts file
  */
 import java.io.ByteArrayInputStream;
@@ -54,12 +54,12 @@ public class VerifyCACerts {
             + File.separator + "security" + File.separator + "cacerts";
 
     // The numbers of certs now.
-    private static final int COUNT = 89;
+    private static final int COUNT = 90;
 
     // SHA-256 of cacerts, can be generated with
     // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95
     private static final String CHECKSUM
-            = "0D:9C:40:8F:CE:B1:C7:27:89:54:FD:80:DA:B6:91:F4:C9:94:15:C4:8D:25:62:34:D4:70:32:60:1A:6F:13:27";
+            = "A3:57:D9:69:62:ED:00:ED:72:83:1E:15:46:02:93:F3:12:0F:49:83:E3:E6:D0:9F:96:34:05:9C:43:EB:D6:05";
 
     // Hex formatter to upper case with ":" delimiter
     private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase();
@@ -246,6 +246,8 @@ public class VerifyCACerts {
                     "A0:40:92:9A:02:CE:53:B4:AC:F4:F2:FF:C6:98:1C:E4:49:6F:75:5E:6D:45:FE:0B:2A:69:2B:CD:52:52:3F:36");
             put("haricaeccrootca2015 [jdk]",
                     "44:B5:45:AA:8A:25:E6:5A:73:CA:15:DC:27:FC:36:D2:4C:1C:B9:95:3A:06:65:39:B1:15:82:DC:48:7B:48:33");
+            put("certignaca [jdk]",
+                    "E3:B6:A2:DB:2E:D7:CE:48:84:2F:7A:C5:32:41:C7:B7:1D:54:14:4B:FB:40:C1:1F:3F:1D:0B:42:F5:EE:A1:2D");
         }
     };
 
diff --git a/test/jdk/sun/security/ssl/DHKeyExchange/DHEKeySizing.java b/test/jdk/sun/security/ssl/DHKeyExchange/DHEKeySizing.java
index 8aede6a3432..9618cae88a3 100644
--- a/test/jdk/sun/security/ssl/DHKeyExchange/DHEKeySizing.java
+++ b/test/jdk/sun/security/ssl/DHKeyExchange/DHEKeySizing.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
 
 /*
  * @test
- * @bug 6956398
+ * @bug 6956398 8301700
  * @summary make ephemeral DH key match the length of the certificate key
  * @run main/othervm -Djdk.tls.client.enableSessionTicketExtension=false
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1643 267
@@ -54,7 +54,7 @@
  *
  * @run main/othervm -Djsse.enableFFDHE=false
  *      -Djdk.tls.client.enableSessionTicketExtension=false
- *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1387 139
+ *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1643 267
  * @run main/othervm -Djsse.enableFFDHE=false
  *      -Djdk.tls.ephemeralDHKeySize=legacy
  *      -Djdk.tls.client.enableSessionTicketExtension=false
@@ -70,7 +70,7 @@
  *
  * @run main/othervm -Djsse.enableFFDHE=false
  *      -Djdk.tls.client.enableSessionTicketExtension=false
- *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 361 139
+ *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 617 267
  * @run main/othervm -Djsse.enableFFDHE=false
  *      -Djdk.tls.client.enableSessionTicketExtension=false
  *      -Djdk.tls.ephemeralDHKeySize=legacy
@@ -78,7 +78,7 @@
  * @run main/othervm -Djsse.enableFFDHE=false
  *      -Djdk.tls.client.enableSessionTicketExtension=false
  *      -Djdk.tls.ephemeralDHKeySize=matched
- *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 361 139
+ *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 617 267
  * @run main/othervm -Djsse.enableFFDHE=false
  *      -Djdk.tls.client.enableSessionTicketExtension=false
  *      -Djdk.tls.ephemeralDHKeySize=1024
@@ -106,7 +106,7 @@
  *        } dh_public;
  *    } ClientDiffieHellmanPublic;
  *
- * Fomr above structures, it is clear that if the DH key size increasing 128
+ * From the above structures, it is clear that if the DH key size increases 128
  * bits (16 bytes), the ServerHello series messages increases 48 bytes
  * (becuase dh_p, dh_g and dh_Ys each increase 16 bytes) and ClientKeyExchange
  * increases 16 bytes (because of the size increasing of dh_Yc).
@@ -117,7 +117,7 @@
  *   512-bit  |          1259 bytes  |           75 bytes |        233 bytes
  *   768-bit  |          1323 bytes  |          107 bytes |        297 bytes
  *  1024-bit  |          1387 bytes  |          139 bytes |        361 bytes
- *  2048-bit  |          1643 bytes  |          267 bytes |        361 bytes
+ *  2048-bit  |          1643 bytes  |          267 bytes |        617 bytes
  */
 
 import javax.net.ssl.*;
diff --git a/test/langtools/jdk/javadoc/doclet/testInheritance/TestInheritance.java b/test/langtools/jdk/javadoc/doclet/testInheritance/TestInheritance.java
new file mode 100644
index 00000000000..fc08c53467c
--- /dev/null
+++ b/test/langtools/jdk/javadoc/doclet/testInheritance/TestInheritance.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug      8302324
+ * @summary  Inheritance tree does not show correct type parameters/arguments
+ * @library  /tools/lib ../../lib
+ * @modules  jdk.javadoc/jdk.javadoc.internal.tool
+ * @build    toolbox.ToolBox javadoc.tester.*
+ * @run main TestInheritance
+ */
+
+import java.nio.file.Path;
+
+import javadoc.tester.JavadocTester;
+import toolbox.ToolBox;
+
+public class TestInheritance extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        var test = new TestInheritance();
+        test.runTests();
+    }
+
+    @Test
+    public void testInheritanceGeneric(Path base) throws Exception {
+        Path src = base.resolve("src");
+        new ToolBox().writeJavaFiles(src, """
+                    package pkg;
+                    /**
+                     * Base class
+                     * @param <M> param M
+                     * @param <N> param N
+                     */
+                    public class A<M, N> { private A() { } }
+                    """,
+                """
+                    package pkg;
+                    /**
+                     * First subclass
+                     * @param <O> param O
+                     * @param <P> param P
+                     */
+                    public class B<O, P> extends A<O, P> { private B() { } }
+                    """,
+                """
+                    package pkg;
+                    /**
+                     * Second subclass
+                     * @param <Q> param Q
+                     */
+                    public class C<Q> extends B<String, Q> { private C() { } }
+                    """,
+                """
+                    package pkg;
+                    /**
+                     * Second subclass
+                     * @param <R> param R
+                     * @param <S> param S
+                     */
+                    public class D<R, S> extends B<S, B> { private D() { } }
+                    """);
+        javadoc("-d", base.resolve("docs").toString(),
+                "-sourcepath", src.toString(),
+                "--no-platform-links",
+                "pkg");
+        checkExit(Exit.OK);
+        checkOrder("pkg/A.html", """
+                     <div class="inheritance" title="Inheritance Tree">java.lang.Object
+                     <div class="inheritance">pkg.A&lt;M,<wbr>N&gt;</div>""");
+        checkOrder("pkg/B.html", """
+                     <div class="inheritance" title="Inheritance Tree">java.lang.Object
+                     <div class="inheritance"><a href="A.html" title="class in pkg">pkg.A</a>&lt;O,<wbr>P&gt;
+                     <div class="inheritance">pkg.B&lt;O,<wbr>P&gt;</div>""");
+        checkOrder("pkg/C.html", """
+                     <div class="inheritance" title="Inheritance Tree">java.lang.Object
+                     <div class="inheritance"><a href="A.html" title="class in pkg">pkg.A</a>&lt;java.lang.String,<wbr>Q&gt;
+                     <div class="inheritance"><a href="B.html" title="class in pkg">pkg.B</a>&lt;java.lang.String,<wbr>Q&gt;
+                     <div class="inheritance">pkg.C&lt;Q&gt;</div>""");
+        checkOrder("pkg/D.html", """
+                     <div class="inheritance" title="Inheritance Tree">java.lang.Object
+                     <div class="inheritance"><a href="A.html" title="class in pkg">pkg.A</a>&lt;S,<wbr><a href="B.html" title="class in pkg">B</a>&gt;
+                     <div class="inheritance"><a href="B.html" title="class in pkg">pkg.B</a>&lt;S,<wbr><a href="B.html" title="class in pkg">B</a>&gt;
+                     <div class="inheritance">pkg.D&lt;R,<wbr>S&gt;</div>""");
+    }
+}
diff --git a/test/langtools/tools/doclint/HtmlTagsTest.java b/test/langtools/tools/doclint/HtmlTagsTest.java
index b922a67d8f1..cb0aa2eb984 100644
--- a/test/langtools/tools/doclint/HtmlTagsTest.java
+++ b/test/langtools/tools/doclint/HtmlTagsTest.java
@@ -66,6 +66,14 @@ public void text_not_allowed() { }
      */
     public void inline_not_allowed() { }
 
+    /**
+     * <ul> &amp; <li> ... </li> </ul>
+     */
+    public void entity_not_allowed() { }
 
+    /**
+     * <ul> *@/ <li> ... </li> </ul>
+     */
+    public void escape_not_allowed() { }
 }
 
diff --git a/test/langtools/tools/doclint/HtmlTagsTest.out b/test/langtools/tools/doclint/HtmlTagsTest.out
index 8117de21dc1..8e8b1441888 100644
--- a/test/langtools/tools/doclint/HtmlTagsTest.out
+++ b/test/langtools/tools/doclint/HtmlTagsTest.out
@@ -43,5 +43,11 @@ HtmlTagsTest.java:60: error: text not allowed in <ul> element
 HtmlTagsTest.java:65: error: tag not allowed here: <b>
      * <ul> <b>text</b> <li> ... </li> </ul>
             ^
-13 errors
+HtmlTagsTest.java:70: error: text not allowed in <ul> element
+     * <ul> &amp; <li> ... </li> </ul>
+            ^
+HtmlTagsTest.java:75: error: text not allowed in <ul> element
+     * <ul> *@/ <li> ... </li> </ul>
+           ^
+15 errors
 2 warnings
diff --git a/test/langtools/tools/doclint/ReturnTest.java b/test/langtools/tools/doclint/ReturnTest.java
new file mode 100644
index 00000000000..9b3b819f94c
--- /dev/null
+++ b/test/langtools/tools/doclint/ReturnTest.java
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @modules jdk.javadoc/jdk.javadoc.internal.doclint
+ * @build DocLintTester
+ * @run main DocLintTester -ref ReturnTest.out ReturnTest.java
+ */
+
+/** No comment. */
+public class ReturnTest {
+    /**
+     {@return legal} **/
+    public int m_legal() { return 0; }
+
+    /** <p> {@return illegal} **/
+    public int m_illegal_html() { return 0; }
+
+    /** text {@return illegal} **/
+    public int m_illegal_text() { return 0; }
+
+    /** &amp;{@return illegal} **/
+    public int m_illegal_entity() { return 0; }
+
+    /** @@{@return illegal} **/
+    public int m_illegal_escape() { return 0; }
+
+    /** {@return legal} text {@return illegal} **/
+    public int m_illegal_repeat() { return 0; }
+
+    /** . */
+    private ReturnTest() { }
+}
diff --git a/test/langtools/tools/doclint/ReturnTest.out b/test/langtools/tools/doclint/ReturnTest.out
new file mode 100644
index 00000000000..85937e07fcd
--- /dev/null
+++ b/test/langtools/tools/doclint/ReturnTest.out
@@ -0,0 +1,19 @@
+ReturnTest.java:14: warning: {@return} not at beginning of description
+    /** <p> {@return illegal} **/
+            ^
+ReturnTest.java:17: warning: {@return} not at beginning of description
+    /** text {@return illegal} **/
+             ^
+ReturnTest.java:20: warning: {@return} not at beginning of description
+    /** &amp;{@return illegal} **/
+             ^
+ReturnTest.java:23: warning: {@return} not at beginning of description
+    /** @@{@return illegal} **/
+          ^
+ReturnTest.java:26: warning: @return has already been specified
+    /** {@return legal} text {@return illegal} **/
+                             ^
+ReturnTest.java:26: warning: {@return} not at beginning of description
+    /** {@return legal} text {@return illegal} **/
+                             ^
+6 warnings
\ No newline at end of file
diff --git a/test/langtools/tools/doclint/SummaryTest.java b/test/langtools/tools/doclint/SummaryTest.java
index 595374739f1..d6b27e418e1 100644
--- a/test/langtools/tools/doclint/SummaryTest.java
+++ b/test/langtools/tools/doclint/SummaryTest.java
@@ -9,13 +9,22 @@
 public class SummaryTest {
     /**
      {@summary legal} **/
-    public void m0() {}
+    public void m_legal() {}
 
     /** <p> {@summary illegal} **/
-    public void m1() {}
+    public void m_illegal_html() {}
+
+    /** text {@summary illegal} **/
+    public void m_illegal_text() {}
+
+    /** &amp;{@summary illegal} **/
+    public void m_illegal_entity() {}
+
+    /** @@{@summary illegal} **/
+    public void m_illegal_escape() {}
 
     /** {@summary legal} text {@summary illegal} **/
-    public void m2() {}
+    public void m_illegal_repeat() {}
 
     /** . */
     private SummaryTest() { }
diff --git a/test/langtools/tools/doclint/SummaryTest.out b/test/langtools/tools/doclint/SummaryTest.out
index 026def99cf7..9557ad93c75 100644
--- a/test/langtools/tools/doclint/SummaryTest.out
+++ b/test/langtools/tools/doclint/SummaryTest.out
@@ -2,6 +2,15 @@ SummaryTest.java:14: warning: invalid use of @summary
     /** <p> {@summary illegal} **/
             ^
 SummaryTest.java:17: warning: invalid use of @summary
+    /** text {@summary illegal} **/
+             ^
+SummaryTest.java:20: warning: invalid use of @summary
+    /** &amp;{@summary illegal} **/
+             ^
+SummaryTest.java:23: warning: invalid use of @summary
+    /** @@{@summary illegal} **/
+          ^
+SummaryTest.java:26: warning: invalid use of @summary
     /** {@summary legal} text {@summary illegal} **/
                               ^
-2 warnings
+5 warnings
diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/classfile/AnonymousClassTest.java b/test/langtools/tools/javac/annotations/typeAnnotations/classfile/AnonymousClassTest.java
index dd4503bdaa5..68867cb7ac0 100644
--- a/test/langtools/tools/javac/annotations/typeAnnotations/classfile/AnonymousClassTest.java
+++ b/test/langtools/tools/javac/annotations/typeAnnotations/classfile/AnonymousClassTest.java
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8198945 8207018
+ * @bug 8198945 8207018 8207017
  * @summary Invalid RuntimeVisibleTypeAnnotations for annotation on anonymous class type parameter
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
@@ -94,11 +94,22 @@ private void g() {
         new @TA(3) AnonymousClassTest.@TA(4) Inner() {};
     }
 
+    // intance initializer
+    {
+        new @TA(5) Object() {};
+    }
+
+    // static initializer
+    static {
+        new @TA(6) Object() {};
+    }
+
     public static void main(String args[]) throws Exception {
         testAnonymousClassDeclaration();
         testTopLevelMethod();
         testInnerClassMethod();
         testQualifiedSuperType();
+        testInstanceAndClassInit();
     }
 
     static void testAnonymousClassDeclaration() throws Exception {
@@ -165,6 +176,21 @@ static void testQualifiedSuperType() throws Exception {
         }
     }
 
+    static void testInstanceAndClassInit() throws Exception {
+        ClassFile cf = ClassFile.read(Paths.get(ToolBox.testClasses, "AnonymousClassTest.class"));
+        Method method = findMethod(cf, "<init>");
+        Set<TypeAnnotation> annotations = getRuntimeVisibleTypeAnnotations(method);
+        assertEquals(
+                Set.of("@LAnonymousClassTest$TA;(5) NEW, offset=4, location=[INNER_TYPE]"),
+                annotations.stream().map(a -> annotationDebugString(cf, a)).collect(toSet()) );
+
+        method = findMethod(cf, "<clinit>");
+        annotations = getRuntimeVisibleTypeAnnotations(method);
+        assertEquals(
+                Set.of("@LAnonymousClassTest$TA;(6) NEW, offset=0, location=[INNER_TYPE]"),
+                annotations.stream().map(a -> annotationDebugString(cf, a)).collect(toSet()) );
+    }
+
     // Returns the Method's RuntimeVisibleTypeAnnotations, and asserts that there are no RVTIs
     // erroneously associated with the Method instead of its Code attribute.
     private static Set<TypeAnnotation> getRuntimeVisibleTypeAnnotations(Method method) {
diff --git a/test/langtools/tools/javac/doctree/AtEscapeTest.java b/test/langtools/tools/javac/doctree/AtEscapeTest.java
new file mode 100644
index 00000000000..83e1806f391
--- /dev/null
+++ b/test/langtools/tools/javac/doctree/AtEscapeTest.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8300914
+ * @summary Allow `@` as an escape in documentation comments
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @build DocCommentTester
+ * @run main DocCommentTester AtEscapeTest.java
+ */
+
+class AtEscapeTest {
+    /**
+     * abc
+     * @@tag
+     * def
+     */
+    void escape_block_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc|_]
+    Escape[ESCAPE, pos:6, @]
+    Text[TEXT, pos:8, tag|_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@@tag} def
+     */
+    void escape_inline_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_{]
+    Escape[ESCAPE, pos:6, @]
+    Text[TEXT, pos:8, tag}_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc /* def *@/ ghi
+     */
+    void escape_end_comment() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_/*_def_*]
+    Escape[ESCAPE, pos:13, /]
+    Text[TEXT, pos:15, _ghi]
+  body: empty
+  block tags: empty
+]
+*/
+    /**
+     abc
+     @* def
+     ghi
+     */
+    void escape_asterisk() { }
+/*
+DocComment[DOC_COMMENT, pos:5
+  firstSentence: 3
+    Text[TEXT, pos:5, abc|_____]
+    Escape[ESCAPE, pos:14, *]
+    Text[TEXT, pos:16, _def|_____ghi]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc.
+     * not an escaped tag @@tag;
+     * xyz.
+     */
+    void not_escaped_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: 1
+    Text[TEXT, pos:7, not_an_escaped_tag_@@tag;|_xyz.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc.
+     * not an escaped asterisk @*;
+     * xyz.
+     */
+    void not_escaped_asterisk() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: 1
+    Text[TEXT, pos:7, not_an_escaped_asterisk_@*;|_xyz.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc.
+     * not an escaped solidus @/.
+     * xyz.
+     */
+    void not_escaped_solidus() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: 1
+    Text[TEXT, pos:7, not_an_escaped_solidus_@/.|_xyz.]
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/langtools/tools/javac/doctree/DocCommentTester.java b/test/langtools/tools/javac/doctree/DocCommentTester.java
index 023e295c78e..641e58a379d 100644
--- a/test/langtools/tools/javac/doctree/DocCommentTester.java
+++ b/test/langtools/tools/javac/doctree/DocCommentTester.java
@@ -462,6 +462,11 @@ public Void visitErroneous(ErroneousTree node, Void p) {
                 return null;
             }
 
+            public Void visitEscape(EscapeTree node, Void p) {
+                header(node, node.getBody());
+                return null;
+            }
+
             public Void visitHidden(HiddenTree node, Void p) {
                 header(node);
                 indent(+1);
@@ -933,7 +938,7 @@ void check(TreePath path, Name name) throws Exception {
          * @return the normalized content
          */
         String normalize(String s, boolean normalizeTags) {
-            String s2 = s.trim().replaceFirst("\\.\\s*\\n *@", ".\n@");
+            String s2 = s.trim().replaceFirst("\\.\\s*\\n *@(?![@*])", ".\n@");
             StringBuilder sb = new StringBuilder();
             Pattern p = Pattern.compile("(?i)\\{@([a-z][a-z0-9.:-]*)( )?");
             Matcher m = p.matcher(s2);
@@ -952,7 +957,7 @@ String normalize(String s, boolean normalizeTags) {
         }
 
         String normalizeFragment(String s) {
-            return s.replaceAll("\n[ \t]+@", "\n@");
+            return s.replaceAll("\n[ \t]+@(?![@*])", "\n@");
         }
 
         int copyLiteral(String s, int start, StringBuilder sb) {
diff --git a/test/langtools/tools/javac/lambda/8131742/T8131742.java b/test/langtools/tools/javac/lambda/8131742/T8131742.java
index 3c39ed884e6..1fe47709ecf 100644
--- a/test/langtools/tools/javac/lambda/8131742/T8131742.java
+++ b/test/langtools/tools/javac/lambda/8131742/T8131742.java
@@ -1,9 +1,17 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 8131742
+ * @bug 8131742 8301374
  * @summary Syntactically meaningless code accepted by javac
  * @compile/fail/ref=T8131742.out -XDrawDiagnostics T8131742.java
  */
 class T8131742 {
     static Runnable r = (__GAR BAGE__.this) -> { };
+
+    interface F {
+        void apply(E e);
+    }
+    enum E {
+        ONE
+    }
+    F f = (E.ONE) -> {};
 }
diff --git a/test/langtools/tools/javac/lambda/8131742/T8131742.out b/test/langtools/tools/javac/lambda/8131742/T8131742.out
index efc3c1c97fa..2d13bc46ec9 100644
--- a/test/langtools/tools/javac/lambda/8131742/T8131742.out
+++ b/test/langtools/tools/javac/lambda/8131742/T8131742.out
@@ -1,2 +1,3 @@
 T8131742.java:8:39: compiler.err.this.as.identifier
-1 error
+T8131742.java:16:12: compiler.err.expected: token.identifier
+2 errors
diff --git a/test/langtools/tools/javac/patterns/DeconstructionDesugaring.java b/test/langtools/tools/javac/patterns/DeconstructionDesugaring.java
index 47b988b6284..09bf4813113 100644
--- a/test/langtools/tools/javac/patterns/DeconstructionDesugaring.java
+++ b/test/langtools/tools/javac/patterns/DeconstructionDesugaring.java
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8291769
+ * @bug 8291769 8301858
  * @summary Verify more complex switches work properly
  * @compile --enable-preview -source ${jdk.version} DeconstructionDesugaring.java
  * @run main/othervm --enable-preview DeconstructionDesugaring
@@ -43,6 +43,8 @@ private void test() {
         assertEquals(runCheckExpressionWithUnconditional(new R5(new R4(null))), 3);
         assertEquals(runCheckExpressionWithUnconditional1(new R5(new R4(null))), 2);
         assertEquals(runCheckExpressionWithUnconditional1(new R5(null)), 3);
+        assertEquals(runCheckExpressionWithUnconditionalAndParams(new R1(42)), 1);
+        assertEquals(runCheckExpressionWithUnconditionalAndParams(new R1(new Object())), 2);
     }
 
     private void test(ToIntFunction<Object> task) {
@@ -103,6 +105,17 @@ private int runCheckExpressionWithUnconditional1(R5 o) {
         };
     }
 
+    public static int runCheckExpressionWithUnconditionalAndParams(R1 r) {
+        switch (r) {
+            case R1(Integer i):
+                return meth_I(i);
+            case R1(Object o):
+                return meth_O(o);
+        }
+    }
+    public static int meth_I(Integer i) { return 1; }
+    public static int meth_O(Object o) { return 2;}
+
     private void assertEquals(int expected, int actual) {
         if (expected != actual) {
             throw new AssertionError("expected: " + expected + ", " +
diff --git a/test/lib-test/jdk/test/lib/process/exejvm-test-launcher.c b/test/lib-test/jdk/test/lib/process/exejvm-test-launcher.c
index 550f0f3c9dc..dec70b6a2f5 100644
--- a/test/lib-test/jdk/test/lib/process/exejvm-test-launcher.c
+++ b/test/lib-test/jdk/test/lib/process/exejvm-test-launcher.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,12 @@
 #include <jni.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef AIX
+#include <pthread.h>
+#endif //AIX
 
-JNIEnv* create_vm(JavaVM **jvm)
-{
+static void* run(void *arg) {
+    JavaVM *jvm;
     JNIEnv* env;
     JavaVMInitArgs args;
     JavaVMOption options[1];
@@ -41,39 +44,43 @@ JNIEnv* create_vm(JavaVM **jvm)
     args.options = &options[0];
     args.ignoreUnrecognized = 0;
 
-    int ret = JNI_CreateJavaVM(jvm, (void**)&env, &args);
+    int ret = JNI_CreateJavaVM(&jvm, (void**)&env, &args);
     if (ret < 0) {
       exit(10);
     }
 
-    return env;
-}
-
-
-void run(JNIEnv *env) {
-  jclass test_class;
-  jmethodID test_method;
+    jclass test_class;
+    jmethodID test_method;
 
-  test_class = (*env)->FindClass(env, "TestNativeProcessBuilder$Test");
-  if (test_class == NULL) {
-    exit(11);
-  }
+    test_class = (*env)->FindClass(env, "TestNativeProcessBuilder$Test");
+    if (test_class == NULL) {
+      exit(11);
+    }
 
-  test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V");
-  if (test_method == NULL) {
-    exit(12);
-  }
+    test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V");
+    if (test_method == NULL) {
+      exit(12);
+    }
 
-  (*env)->CallStaticVoidMethod(env, test_class, test_method);
+    (*env)->CallStaticVoidMethod(env, test_class, test_method);
+    return 0;
 }
 
-
-int main(int argc, char **argv)
-{
-  JavaVM *jvm;
-  JNIEnv *env = create_vm(&jvm);
-
-  run(env);
-
-  return 0;
+int main(int argc, char *argv[]) {
+#ifdef AIX
+    size_t adjusted_stack_size = 1024*1024;
+    pthread_t id;
+    int result;
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setstacksize(&attr, adjusted_stack_size);
+    result = pthread_create(&id, &attr, run, (void *)argv);
+    if (result != 0) {
+      fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
+      return -1;
+    }
+    pthread_join(id, NULL);
+#else
+    run(&argv);
+#endif //AIX
 }
diff --git a/test/lib-test/jdk/test/whitebox/vm_flags/StringTest.java b/test/lib-test/jdk/test/whitebox/vm_flags/StringTest.java
index ac4b4f2bf65..80ef2048387 100644
--- a/test/lib-test/jdk/test/whitebox/vm_flags/StringTest.java
+++ b/test/lib-test/jdk/test/whitebox/vm_flags/StringTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,14 +36,14 @@
 
 public class StringTest {
     private static final String FLAG_NAME = "CompileOnly";
-    private static final String FLAG_DEBUG_NAME = "SuppressErrorAt";
+    private static final String FLAG_DEBUG_NAME = "ExitOnFullCodeCache";
     private static final String[] TESTS = {"StringTest::*", ""};
 
     public static void main(String[] args) throws Exception {
         VmFlagTest.runTest(FLAG_NAME, TESTS,
             VmFlagTest.WHITE_BOX::setStringVMFlag,
             VmFlagTest.WHITE_BOX::getStringVMFlag);
-        VmFlagTest.runTest(FLAG_DEBUG_NAME, VmFlagTest.WHITE_BOX::getStringVMFlag);
+        VmFlagTest.runTest(FLAG_DEBUG_NAME, VmFlagTest.WHITE_BOX::getBooleanVMFlag);
     }
 }
 
diff --git a/test/lib/jdk/test/lib/util/ForceGC.java b/test/lib/jdk/test/lib/util/ForceGC.java
index 3c9ebc4d35e..19bbef1f7e4 100644
--- a/test/lib/jdk/test/lib/util/ForceGC.java
+++ b/test/lib/jdk/test/lib/util/ForceGC.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,14 +38,43 @@ public class ForceGC {
 
     /**
      * Causes the current thread to wait until the {@code booleanSupplier}
-     * returns true, or a specific waiting time elapses.  The waiting time
-     * is 1 second scaled with the jtreg testing timeout factor.
+     * returns true, or the waiting time elapses.  The waiting time
+     * is 1 second scaled with the jtreg testing timeout factor. This method
+     * is equivalent to calling {@link #waitFor(BooleanSupplier, long)
+     * waitFor(booleanSupplier, Math.round(1000L * JTREG_TIMEOUT_FACTOR)}
+     * where {@code JTREG_TIMEOUT_FACTOR} is the value of
+     * "test.timeout.factor" system property.
+     *
+     * @apiNote If the given {@code booleanSupplier} is expected to never
+     * return true, for example to check if an object that is expected
+     * to be strongly reachable is still alive,
+     * {@link #waitFor(BooleanSupplier, long)} can be used to specify
+     * the timeout for the wait method to return.
      *
      * @param booleanSupplier boolean supplier
      * @return true if the {@code booleanSupplier} returns true, or false
-     *     if did not complete after the specific waiting time.
+     *     if did not complete after the waiting time.
+
      */
     public static boolean wait(BooleanSupplier booleanSupplier) {
+        return waitFor(booleanSupplier, Math.round(1000L * TIMEOUT_FACTOR));
+    }
+
+    /**
+     * Causes the current thread to wait until the {@code booleanSupplier}
+     * returns true, or the specified waiting time elapses.
+     *
+     * @apiNote If the given {@code booleanSupplier} is expected to never
+     * return true, for example to check if an object that is expected
+     * to be strongly reachable is still alive, this method can be used
+     * to specify the timeout independent of the jtreg timeout factor.
+     *
+     * @param booleanSupplier boolean supplier
+     * @param timeout the maximum time to wait, in milliseconds
+     * @return true if the {@code booleanSupplier} returns true, or false
+     *     if did not complete after the specified waiting time.
+     */
+    public static boolean waitFor(BooleanSupplier booleanSupplier, long timeout) {
         ReferenceQueue<Object> queue = new ReferenceQueue<>();
         Object obj = new Object();
         PhantomReference<Object> ref = new PhantomReference<>(obj, queue);
@@ -53,7 +82,7 @@ public static boolean wait(BooleanSupplier booleanSupplier) {
         Reference.reachabilityFence(obj);
         Reference.reachabilityFence(ref);
 
-        int retries = (int)(Math.round(1000L * TIMEOUT_FACTOR) / 200);
+        int retries = (int)(timeout / 200);
         for (; retries >= 0; retries--) {
             if (booleanSupplier.getAsBoolean()) {
                 return true;
diff --git a/test/micro/org/openjdk/bench/java/lang/StringBuilders.java b/test/micro/org/openjdk/bench/java/lang/StringBuilders.java
index e2a72a9ecb8..40f41659e7c 100644
--- a/test/micro/org/openjdk/bench/java/lang/StringBuilders.java
+++ b/test/micro/org/openjdk/bench/java/lang/StringBuilders.java
@@ -51,7 +51,9 @@ public class StringBuilders {
     private String[] str3p9p8;
     private String[] str22p40p31;
     private StringBuilder sbLatin1;
+    private StringBuilder sbLatin2;
     private StringBuilder sbUtf16;
+    private StringBuilder sbUtf17;
 
     @Setup
     public void setup() {
@@ -64,7 +66,9 @@ public void setup() {
         str3p9p8 = new String[]{"123", "123456789", "12345678"};
         str22p40p31 = new String[]{"1234567890123456789012", "1234567890123456789012345678901234567890", "1234567890123456789012345678901"};
         sbLatin1 = new StringBuilder("Latin1 string");
+        sbLatin2 = new StringBuilder("Latin1 string");
         sbUtf16 = new StringBuilder("UTF-\uFF11\uFF16 string");
+        sbUtf17 = new StringBuilder("UTF-\uFF11\uFF16 string");
     }
 
     @Benchmark
@@ -250,6 +254,15 @@ public String toStringCharWithFloat8() {
         return result.toString();
     }
 
+    @Benchmark
+    public int compareToLatin1() {
+        return sbLatin1.compareTo(sbLatin2);
+    }
+
+    @Benchmark
+    public int compareToUTF16() {
+        return sbUtf16.compareTo(sbUtf17);
+    }
 
     @Benchmark
     public String toStringCharWithMixed8() {
diff --git a/test/micro/org/openjdk/bench/java/lang/StringComparisons.java b/test/micro/org/openjdk/bench/java/lang/StringComparisons.java
new file mode 100644
index 00000000000..b18b56bee2a
--- /dev/null
+++ b/test/micro/org/openjdk/bench/java/lang/StringComparisons.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.bench.java.lang;
+
+import org.openjdk.jmh.annotations.*;
+
+import java.util.concurrent.TimeUnit;
+
+/*
+ * This benchmark naively explores String::startsWith and other String
+ * comparison methods
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Benchmark)
+@Warmup(iterations = 5, time = 1)
+@Measurement(iterations = 5, time = 1)
+@Fork(value = 3)
+public class StringComparisons {
+
+    @Param({"6", "15", "1024"})
+    public int size;
+
+    @Param({"true", "false"})
+    public boolean utf16;
+
+    public String string;
+    public String equalString;
+    public String endsWithA;
+    public String endsWithB;
+    public String startsWithA;
+
+    @Setup
+    public void setup() {
+        String c = utf16 ? "\uff11" : "c";
+        string = c.repeat(size);
+        equalString = c.repeat(size);
+        endsWithA = c.repeat(size).concat("A");
+        endsWithB = c.repeat(size).concat("B");
+        startsWithA = "A" + (c.repeat(size));
+    }
+
+    @Benchmark
+    public boolean startsWith() {
+        return endsWithA.startsWith(string);
+    }
+
+    @Benchmark
+    public boolean endsWith() {
+        return startsWithA.endsWith(string);
+    }
+
+    @Benchmark
+    public boolean regionMatches() {
+        return endsWithA.regionMatches(0, endsWithB, 0, endsWithB.length());
+    }
+
+    @Benchmark
+    public boolean regionMatchesRange() {
+        return startsWithA.regionMatches(1, endsWithB, 0, endsWithB.length() - 1);
+    }
+
+    @Benchmark
+    public boolean regionMatchesCI() {
+        return endsWithA.regionMatches(true, 0, endsWithB, 0, endsWithB.length());
+    }
+}
diff --git a/test/micro/org/openjdk/bench/java/lang/StringConstructor.java b/test/micro/org/openjdk/bench/java/lang/StringConstructor.java
index bd6ba5200ec..1509d6b798f 100644
--- a/test/micro/org/openjdk/bench/java/lang/StringConstructor.java
+++ b/test/micro/org/openjdk/bench/java/lang/StringConstructor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,47 +28,53 @@
 import java.nio.charset.StandardCharsets;
 import java.util.concurrent.TimeUnit;
 
-@Fork(5)
 @State(Scope.Thread)
 @BenchmarkMode(Mode.AverageTime)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
-@Warmup(iterations = 5, time = 5)
-@Measurement(iterations = 10, time = 5)
+@Warmup(iterations = 5, time = 3)
+@Measurement(iterations = 5, time = 3)
+@Fork(3)
 public class StringConstructor {
+
+  @Param({"7", "64"})
+  public int size;
+
+  // Offset to use for ranged newStrings
+  @Param("1")
+  public int offset;
   private byte[] array;
 
   @Setup
   public void setup() {
-    array = "".getBytes(StandardCharsets.UTF_8);
+      if (offset > size) {
+        offset = size;
+      }
+      array = "a".repeat(size).getBytes(StandardCharsets.UTF_8);
   }
 
   @Benchmark
   public String newStringFromArray() {
-    return new String(array);
+      return new String(array);
   }
 
   @Benchmark
   public String newStringFromArrayWithCharset() {
-    return new String(array, StandardCharsets.UTF_8);
+      return new String(array, StandardCharsets.UTF_8);
   }
 
   @Benchmark
   public String newStringFromArrayWithCharsetName() throws Exception {
-    return new String(array, StandardCharsets.UTF_8.name());
+      return new String(array, StandardCharsets.UTF_8.name());
   }
 
   @Benchmark
   public String newStringFromRangedArray() {
-    return new String(array, 0, 0);
+    return new String(array, offset, array.length - offset);
   }
 
   @Benchmark
   public String newStringFromRangedArrayWithCharset() {
-    return new String(array, 0, 0, StandardCharsets.UTF_8);
+      return new String(array, offset, array.length - offset, StandardCharsets.UTF_8);
   }
 
-  @Benchmark
-  public String newStringFromRangedArrayWithCharsetName() throws Exception {
-    return new String(array, 0, 0, StandardCharsets.UTF_8.name());
-  }
 }
diff --git a/test/micro/org/openjdk/bench/java/lang/StringOther.java b/test/micro/org/openjdk/bench/java/lang/StringOther.java
index e6bee3f0376..99ebca8c3d1 100644
--- a/test/micro/org/openjdk/bench/java/lang/StringOther.java
+++ b/test/micro/org/openjdk/bench/java/lang/StringOther.java
@@ -49,17 +49,9 @@ public class StringOther {
     private String testString;
     private Random rnd;
 
-    private String str1, str2, str3, str4;
-    private String str1UP;
-
     @Setup
     public void setup() {
         testString = "Idealism is what precedes experience; cynicism is what follows.";
-        str1 = "vm-guld vm-guld vm-guld";
-        str1UP = str1.toUpperCase(Locale.ROOT);
-        str2 = "vm-guld vm-guld vm-guldx";
-        str3 = "vm-guld vm-guld vm-guldx";
-        str4 = "adadaskasdjierudks";
         rnd = new Random();
     }
 
@@ -70,15 +62,6 @@ public void charAt(Blackhole bh) {
         }
     }
 
-    @Benchmark
-    public int compareTo() {
-        int total = 0;
-        total += str1.compareTo(str2);
-        total += str2.compareTo(str3);
-        total += str3.compareTo(str4);
-        return total;
-    }
-
     /**
      * Creates (hopefully) unique Strings and internizes them, creating a zillion forgettable strings in the JVMs string
      * pool.
@@ -94,10 +77,4 @@ public String internUnique() {
         return String.valueOf(rnd.nextInt()).intern();
     }
 
-    @Benchmark
-    public void regionMatchesLatin1(Blackhole bh) {
-        bh.consume(str1.regionMatches(true, 0, str2, 0, str1.length()));
-        bh.consume(str2.regionMatches(true, 16, str1UP, 0, 8));
-        bh.consume(str3.regionMatches(true, 6, str4, 1, 2));
-    }
 }
diff --git a/test/micro/org/openjdk/bench/java/util/Base64Decode.java b/test/micro/org/openjdk/bench/java/util/Base64Decode.java
index 568f2835b90..2e399efc973 100644
--- a/test/micro/org/openjdk/bench/java/util/Base64Decode.java
+++ b/test/micro/org/openjdk/bench/java/util/Base64Decode.java
@@ -31,18 +31,18 @@
 import java.util.ArrayList;
 import java.util.concurrent.TimeUnit;
 
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
 @State(Scope.Thread)
 @Warmup(iterations = 4, time = 2)
 @Measurement(iterations = 4, time = 2)
 @Fork(value = 3)
 public class Base64Decode {
 
-    private Base64.Encoder encoder, mimeEncoder;
-    private Base64.Decoder decoder, mimeDecoder;
-    private ArrayList<byte[]> encoded, mimeEncoded, errorEncoded;
-    private byte[] decoded, mimeDecoded, errorDecoded;
+    private Base64.Encoder encoder, mimeEncoder, urlEncoder;
+    private Base64.Decoder decoder, mimeDecoder, urlDecoder;
+    private ArrayList<byte[]> encoded, mimeEncoded, urlEncoded, errorEncoded;
+    private byte[] decoded, mimeDecoded, urlDecoded, errorDecoded;
 
     private static final int TESTSIZE = 1000;
 
@@ -60,6 +60,9 @@ public class Base64Decode {
     @Param({"144"})
     private int errorIndex;
 
+    @Param({"0"})
+    private int addSpecial;
+
     @Setup
     public void setup() {
         Random r = new Random(1123);
@@ -74,6 +77,11 @@ public void setup() {
         mimeDecoder = Base64.getMimeDecoder();
         mimeEncoded = new ArrayList<byte[]> ();
 
+        urlDecoded = new byte[maxNumBytes + 1];
+        urlEncoder = Base64.getUrlEncoder();
+        urlDecoder = Base64.getUrlDecoder();
+        urlEncoded = new ArrayList<byte[]> ();
+
         errorDecoded = new byte[errorIndex + 100];
         errorEncoded = new ArrayList<byte[]> ();
 
@@ -83,6 +91,10 @@ public void setup() {
             byte[] dst = new byte[((srcLen + 2) / 3) * 4];
             r.nextBytes(src);
             encoder.encode(src, dst);
+            if(addSpecial != 0){
+              dst[0] = '/';
+              dst[1] = '+';
+            }
             encoded.add(dst);
 
             int mimeSrcLen = 1 + r.nextInt(maxNumBytes);
@@ -92,13 +104,24 @@ public void setup() {
             mimeEncoder.encode(mimeSrc, mimeDst);
             mimeEncoded.add(mimeDst);
 
+            int urlSrcLen = 1 + r.nextInt(maxNumBytes);
+            byte[] urlSrc = new byte[urlSrcLen];
+            byte[] urlDst = new byte[((urlSrcLen + 2) / 3) * 4];
+            r.nextBytes(urlSrc);
+            urlEncoder.encode(urlSrc, urlDst);
+            if(addSpecial != 0){
+              urlDst[0] = '_';
+              urlDst[1] = '-';
+            }
+            urlEncoded.add(urlDst);
+
             int errorSrcLen = errorIndex + r.nextInt(100);
             byte[] errorSrc = new byte[errorSrcLen];
             byte[] errorDst = new byte[(errorSrcLen + 2) / 3 * 4];
             r.nextBytes(errorSrc);
             encoder.encode(errorSrc, errorDst);
-            errorEncoded.add(errorDst);
             errorDst[errorIndex] = (byte) '?';
+            errorEncoded.add(errorDst);
         }
     }
 
@@ -120,6 +143,15 @@ public void testBase64MIMEDecode(Blackhole bh) {
         }
     }
 
+    @Benchmark
+    @OperationsPerInvocation(TESTSIZE)
+    public void testBase64URLDecode(Blackhole bh) {
+        for (byte[] s : urlEncoded) {
+            urlDecoder.decode(s, urlDecoded);
+            bh.consume(urlDecoded);
+        }
+    }
+
     @Benchmark
     @OperationsPerInvocation(TESTSIZE)
     public void testBase64WithErrorInputsDecode (Blackhole bh) {
diff --git a/test/micro/org/openjdk/bench/java/util/Base64Encode.java b/test/micro/org/openjdk/bench/java/util/Base64Encode.java
index 8501f78d9c8..d62eae23887 100644
--- a/test/micro/org/openjdk/bench/java/util/Base64Encode.java
+++ b/test/micro/org/openjdk/bench/java/util/Base64Encode.java
@@ -31,8 +31,8 @@
 import java.util.ArrayList;
 import java.util.concurrent.TimeUnit;
 
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
 @State(Scope.Thread)
 @Warmup(iterations = 4, time = 2)
 @Measurement(iterations = 4, time = 2)
diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java
new file mode 100644
index 00000000000..da4842bc34a
--- /dev/null
+++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java
@@ -0,0 +1,101 @@
+//
+// Copyright (c) 2023, Arm Limited. All rights reserved.
+// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+//
+// This code is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License version 2 only, as
+// published by the Free Software Foundation.
+//
+// This code is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// version 2 for more details (a copy is included in the LICENSE file that
+// accompanied this code).
+//
+// You should have received a copy of the GNU General Public License version
+// 2 along with this work; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+// or visit www.oracle.com if you need additional information or have any
+// questions.
+//
+//
+package org.openjdk.bench.jdk.incubator.vector;
+
+import java.util.concurrent.TimeUnit;
+import jdk.incubator.vector.*;
+import org.openjdk.jmh.annotations.*;
+
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+@State(Scope.Benchmark)
+@Warmup(iterations = 3, time = 1)
+@Measurement(iterations = 5, time = 1)
+@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
+public class IndexInRangeBenchmark {
+    @Param({"7", "256", "259", "512"})
+    private int size;
+
+    private boolean[] mask;
+
+    private static final VectorSpecies<Byte> bspecies = VectorSpecies.ofLargestShape(byte.class);
+    private static final VectorSpecies<Short> sspecies = VectorSpecies.ofLargestShape(short.class);
+    private static final VectorSpecies<Integer> ispecies = VectorSpecies.ofLargestShape(int.class);
+    private static final VectorSpecies<Long> lspecies = VectorSpecies.ofLargestShape(long.class);
+    private static final VectorSpecies<Float> fspecies = VectorSpecies.ofLargestShape(float.class);
+    private static final VectorSpecies<Double> dspecies = VectorSpecies.ofLargestShape(double.class);
+
+    @Setup(Level.Trial)
+    public void Setup() {
+        mask = new boolean[512];
+    }
+
+    @Benchmark
+    public void byteIndexInRange() {
+        for (int i = 0; i < size; i += bspecies.length()) {
+            var m = bspecies.indexInRange(i, size);
+            m.intoArray(mask, i);
+        }
+    }
+
+    @Benchmark
+    public void shortIndexInRange() {
+        for (int i = 0; i < size; i += sspecies.length()) {
+            var m = sspecies.indexInRange(i, size);
+            m.intoArray(mask, i);
+        }
+    }
+
+    @Benchmark
+    public void intIndexInRange() {
+        for (int i = 0; i < size; i += ispecies.length()) {
+            var m = ispecies.indexInRange(i, size);
+            m.intoArray(mask, i);
+        }
+    }
+
+    @Benchmark
+    public void longIndexInRange() {
+        for (int i = 0; i < size; i += lspecies.length()) {
+            var m = lspecies.indexInRange(i, size);
+            m.intoArray(mask, i);
+        }
+    }
+
+    @Benchmark
+    public void floatIndexInRange() {
+        for (int i = 0; i < size; i += fspecies.length()) {
+            var m = fspecies.indexInRange(i, size);
+            m.intoArray(mask, i);
+        }
+    }
+
+    @Benchmark
+    public void doubleIndexInRange() {
+        for (int i = 0; i < size; i += dspecies.length()) {
+            var m = dspecies.indexInRange(i, size);
+            m.intoArray(mask, i);
+        }
+    }
+}