docs: public static BeanId getBeanId(ByteArray byteArray, // d140003.12
                                     EJSContainer container)
                      throws IOException,
                      ClassNotFoundException
      {
          BeanId id = null;
          int pkeyIndex;
  
          Serializable pkey = null;
          byte[] j2eeNameBytes;
          boolean isHome = false;
          J2EEName j2eeName = null;
          byte[] bytes = byteArray.getBytes(); // d140003.12
  
          // 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, bytes do not represent a BeanId.");
  
                  // Should be rare that we get an old BeanId.
                  throw new IOException("Invalid BeanId header '" + new String(bytes) + "', bytes not a BeanId");
              }
          }
  
          // Make a determination on the type of the bean from the type byte
          byte typeId = bytes[HEADER_LEN];
  
          // Determine if the bean module is version capable                  F54184
          boolean isVersionCapable = ((typeId & MODULE_VERSION_CAPABLE) != 0);
  
          switch (typeId & ~MODULE_VERSION_CAPABLE)
          {
          // If it is a home bean, set the isHome flag. We then have
          // to read the J2EEName and the primary key
              case HOME_BEAN:
                  isHome = true;
                  // Fall through
  
                  // Bean types that contain state must read the J2EEName and primary key
              case STATEFUL_BEAN:
              case STATEFUL_BEAN + USES_BEAN_MANAGED_TX:
              case ENTITY_BEAN:
                  j2eeNameBytes = readJ2EENameBytes(bytes);
                  j2eeName = container.getJ2EENameFactory().create(j2eeNameBytes);
                  if (!isHome && isVersionCapable) {
                      j2eeName = EJSContainer.homeOfHomes.getVersionedJ2EEName(j2eeName);
                  }
                  pkeyIndex = HEADER_LEN +
                              BEAN_TYPE_LEN +
                              J2EE_NAME_LEN +
                              j2eeNameBytes.length;
                  pkey = readPKey(bytes, pkeyIndex, j2eeName);
                  break;
  
              // Simplest case : A stateless bean. Read the Java EE name
              // and we are done
              // MessageDriven are just like Stateless....                  d176974
              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:
                  j2eeNameBytes = readJ2EENameBytes(bytes);
                  j2eeName = container.getJ2EENameFactory().create(j2eeNameBytes);
                  if (isVersionCapable) {
                      j2eeName = EJSContainer.homeOfHomes.getVersionedJ2EEName(j2eeName);
                  }
                  // pkey = null;
                  break;
  
              default:
                  // Nothing can be done.... this is not a type 1 BeanId, so either
                  // the stream is corrupt, or a new bean type has been added,
                  // but not added to the list above.                           LI2281-3
                  if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                      Tr.event(tc, "Unable to parse bean id: unsupported EJB type: " +
                                   bytes[HEADER_LEN]);
                  throw new IOException("Unsupported EJB Type: " + bytes[HEADER_LEN]);
          }
  
          // Now, lookup the home based on the J2EEName read above.
          HomeInternal home = container.getHomeOfHomes().getHome(j2eeName);
  
          // If the home was not found, then the application has either not
          // been installed or started, or possibly failed to start.
          // Log a meaningful warning, and throw a meaningful exception.    LI2281-3
          if (home == null)
          {
              Tr.warning(tc, "HOME_NOT_FOUND_CNTR0092W", j2eeName.toString());
              throw new EJBNotFoundException(j2eeName.toString());
          }
  
          // 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 (home.isStatefulSessionHome())
          {
              pkey = EJSContainer.sessionKeyFactory.create((byte[]) pkey);
          }
  
          // For homes, convert the byte array to a J2EEName object
          if (isHome)
          {
              if (home != EJSContainer.homeOfHomes && // d621921
                  home != EJSContainer.homeOfHomes.ivEJBFactoryHome) // d639148
              {
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                      Tr.debug(tc, "invalid home bean type id for " + j2eeName, byteArray);
                  throw new IOException("Invalid home bean type id");
              }
  
              pkey = container.getJ2EENameFactory().create((byte[]) pkey);
              if (isVersionCapable) {
                  pkey = EJSContainer.homeOfHomes.getVersionedJ2EEName((J2EEName) pkey);
              }
          }
          else
          {
              if (getBeanType(home.getBeanMetaData(j2eeName), false) != typeId) // d621921
              {
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                      Tr.debug(tc, "invalid bean type id for " + j2eeName, byteArray);
                  throw new IOException("Invalid bean type id");
              }
          }
  
          // Create the BeanId from the deserialized pieces.... note that
          // this includes calculating the hash value.
          id = new BeanId(home, pkey, isHome);
  
          // Set the byteArray used to create this BeanId in the BeanId
          // itself, so it won't have to be created later.  Note that the
          // caller must not modify the passed byteArray after this.  d140003.12
          id.byteArray = byteArray;
  
          return id;
      }