docs: protected static Serializable getPrimaryKey(byte[] bytes)
                      throws CSIException
      {
          int pkeyIndex;
          boolean isStateful = false;
          Serializable pkey = null;
          byte[] j2eeNameBytes = null;
          J2EEName j2eeName = null;
  
          // Match up the header with the new format. If it does not match
          // then we have an incoming type 1 BeanId.
          for (int i = 0; i < HEADER_LEN; i++)
          {
              if (bytes[i] != header[i])
              {
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                      Tr.debug(tc, "Header mismatch, attempting to deserialize BeanId");
  
                  // Should be rare that we get an old beanid
                  throw new CSIException("Parser Error: header mismatch");
              }
          }
  
          // Make sure this is a valid bean type, and if so, if there is a
          // primary key, then read the Java EE Name bytes from the key bytes,
          // followed by the primary key.
          switch (bytes[HEADER_LEN])
          {
              case HOME_BEAN:
              case SINGLETON_BEAN:
              case SINGLETON_BEAN + USES_BEAN_MANAGED_TX:
              case STATELESS_BEAN:
              case STATELESS_BEAN + USES_BEAN_MANAGED_TX:
              case MESSAGEDRIVEN_BEAN:
              case MESSAGEDRIVEN_BEAN + USES_BEAN_MANAGED_TX:
                  // No primary key associated with these types
                  break;
  
              case STATEFUL_BEAN:
              case STATEFUL_BEAN + USES_BEAN_MANAGED_TX:
                  isStateful = true;
              case ENTITY_BEAN:
                  j2eeNameBytes = readJ2EENameBytes(bytes);
                  j2eeName = EJSContainer.getDefaultContainer().getJ2EENameFactory().create(j2eeNameBytes);
                  pkeyIndex = HEADER_LEN +
                              BEAN_TYPE_LEN +
                              J2EE_NAME_LEN +
                              j2eeNameBytes.length;
                  try
                  {
                      pkey = readPKey(bytes, pkeyIndex, j2eeName);
                  } catch (Throwable th)
                  {
                      if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                          Tr.event(tc, "Unable to parse bean id: primary key: " + th);
                      throw new CSIException("Unable to read primary key", th);
                  }
                  break;
  
              default:
                  if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                      Tr.event(tc, "Unable to parse bean id: unsupported EJB type: " +
                                   bytes[HEADER_LEN]);
                  throw new CSIException("Unsupported EJB Type: " + bytes[HEADER_LEN]);
          }
  
          // If we are dealing with a stateful bean, then the pkey has to
          // be converted back into it's CSI implementation before it can
          // be used.
          if (isStateful)
          {
              pkey = EJSContainer.sessionKeyFactory.create((byte[]) pkey);
          }
  
          return pkey;
      }