@SuppressWarnings("checkstyle:magicnumber")
    public static String getInternalBinaryName(byte[] classBytes) {
        try {
            ByteBuffer buffer = ByteBuffer.wrap(classBytes);
            buffer.order(ByteOrder.BIG_ENDIAN);

            // Skip magic number and major/minor versions
            buffer.position(8);

            int constantPoolCount = buffer.getShort() & 0xFFFF;
            Object[] constantPool = new Object[constantPoolCount];

            // Iterate constant pool, collecting UTF8 strings (could be our class name) and looking for CONSTANT_Class tags
            //   to identify our desired UTF8 string representing the class name. Skips appropriate bytes for all other tags.
            // While it is generally convention for the index referenced by a CONSTANT_Class value to already be populated in
            //   the constant pool (forward references), it is not forbidden by JVM Spec to use backward references.
            // We need to skip the payload of all irrelevant tags, by the amount defined in the JVM spec (see javadoc)
            for (int i = 1; i < constantPoolCount; i++) {
                int tag = buffer.get() & 0xFF;
                switch (tag) {
                    case 1: // CONSTANT_Utf8
                        int length = buffer.getShort() & 0xFFFF;
                        byte[] bytes = new byte[length];
                        buffer.get(bytes);
                        constantPool[i] = new String(bytes, StandardCharsets.UTF_8);
                        break;
                    case 7: // CONSTANT_Class
                        constantPool[i] = buffer.getShort() & 0xFFFF; // Store index
                        break;
                    case 8: // CONSTANT_String
                    case 16: // CONSTANT_MethodType
                    case 19: // CONSTANT_Module
                    case 20: // CONSTANT_Package
                        skipBytes(buffer, 2);
                        break;
                    case 15: // CONSTANT_MethodHandle
                        skipBytes(buffer, 3);
                        break;
                    case 3: // CONSTANT_Integer
                    case 4: // CONSTANT_Float
                    case 9: // CONSTANT_Fieldref
                    case 10: // CONSTANT_Methodref
                    case 11: // CONSTANT_InterfaceMethodref
                    case 12: // CONSTANT_NameAndType
                    case 18: // CONSTANT_InvokeDynamic
                    case 17: // CONSTANT_Dynamic
                        skipBytes(buffer, 4);
                        break;
                    case 5: // CONSTANT_Long
                    case 6: // CONSTANT_Double
                        skipBytes(buffer, 8);
                        i++;
                        break;
                    default:
                        throw new IllegalArgumentException("Invalid constant pool tag: " + tag);
                }
            }

            // Skip access flag
            skipBytes(buffer, 2);

            // Read this_class index which points to the constantPool index which holds the value of
            //     the index to find the current classes' internal binary name
            int thisClassIndex = buffer.getShort() & 0xFFFF;
            return (String) constantPool[(int) constantPool[thisClassIndex]];
        } catch (Exception e) {
            throw new IllegalArgumentException("Unable to local package/class names from class bytes!", e);
        }
    }
@Test
    public void testAllConstantTagsReadable_whenReadingInternalBinaryName() {
        // To read an internal binary name, we need to read (and skip values for) all constant pool bytes
        //    in the class file, so we need to make sure all 17 (as of JDK 21) are handled correctly
        byte[] classBytes = generateClassFileHeaderWithAllConstants();
        assertEquals("com.hazelcast.test.FakeClass", ReflectionUtils.getInternalBinaryName(classBytes));
    }