code: private void checkReadPrimitiveTypes() throws IOException {
          // If we still have primitive data, it is ok to read primitive data
          if (primitiveData == input || primitiveData.available() > 0) {
              return;
          }
  
          // If we got here either we had no Stream previously created or
          // we no longer have data in that one, so get more bytes
          do {
              int next = 0;
              if (hasPushbackTC) {
                  hasPushbackTC = false;
              } else {
                  next = input.read();
                  pushbackTC = (byte) next;
              }
              switch (pushbackTC) {
                  case TC_BLOCKDATA:
                      primitiveData = new ByteArrayInputStream(readBlockData());
                      return;
                  case TC_BLOCKDATALONG:
                      primitiveData = new ByteArrayInputStream(readBlockDataLong());
                      return;
                  case TC_RESET:
                      resetState();
                      break;
                  default:
                      if (next != -1) {
                          pushbackTC();
                      }
                      return;
              }
              // Only TC_RESET falls through
          } while (true);
      }
docs: Checks to if it is ok to read primitive types from this stream at
  this point. One is not supposed to read primitive types when about to
  read an object, for example, so an exception has to be thrown.
  
  @throws IOException
  If any IO problem occurred when trying to read primitive type
  or if it is illegal to read primitive types