docs: public void setState(int newState) throws SystemException
      {
          if (tc.isEntryEnabled())
              Tr.entry(tc, "setState", "from " + stateToString(_state) + " to " + stateToString(newState));
  
          final int oldState = _state;
  
          // Check that the state change is valid
          if (validStateChange[_state][newState])
          {
              // Change state.  This is the point at which some log records may be written
              _state = newState;
  
              //
              // Unconditional add of state information to 
              // log for various states.
              //
              if ((newState == STATE_COMMITTING) ||
                  (newState == STATE_LAST_PARTICIPANT) ||
                  (_tran.isSubordinate() &&
                  (newState == STATE_PREPARED ||
                   newState == STATE_HEURISTIC_ON_COMMIT ||
                  newState == STATE_HEURISTIC_ON_ROLLBACK
                  )
                  ))
              {
                  byteData[0] = (byte) _state;
  
                  // For a recovered transaction (peer or local), _logSection is always populated by the reconstruct call. As
                  // a result we don't need to worry here about which log (ie a peer or a local) to use.
                  if (_logSection != null)
                  {
                      try
                      {
                          _logSection.addData(byteData);
                          if (tc.isDebugEnabled())
                              Tr.debug(tc, "State logged ok");
                      } catch (Exception e)
                      {
                          FFDCFilter.processException(e, "com.ibm.tx.jta.impl.TransactionState.setState", "416", this);
                          if (tc.isEventEnabled())
                              Tr.event(tc, "addData failed during setState!");
                      }
                  }
                  else if (!_loggingFailed) // First time through only - trap any failed attempts
                  {
                      try
                      {
                          _tranLog = _tran.getLog();
  
                          if (_tranLog != null)
                          {
                              if (tc.isDebugEnabled())
                                  Tr.debug(tc, "Create sections in the Log for Recovery Coordinator"); // PK84994
                              // Create sections in the Log for Recovery coordinator                                         // PK84994
  
                              if (_tran.isRAImport())
                              {
                                  //  We were imported from an RA
                                  //  Write the recoveryId of the partner log entry for this provider to the tran log
                                  //  and the imported JCA Xid
                                  final JCARecoveryData jcard = _tran.getJCARecoveryData();
  
                                  if (tc.isEventEnabled())
                                      Tr.event(tc, "TX is imported from provider: " + jcard.getWrapper().getProviderId());
  
                                  jcard.logRecoveryEntry();
  
                                  final RecoverableUnitSection raSection = _tranLog.createSection(TransactionImpl.RESOURCE_ADAPTER_SECTION, true);
  
                                  final byte[] longBytes = Util.longToBytes(jcard.getRecoveryId()); // @249308A
                                  final byte[] xidBytes = ((XidImpl) _tran.getJCAXid()).toBytes(); // @249308A
                                  final byte[] logBytes = new byte[xidBytes.length + longBytes.length]; // @249308A
                                  System.arraycopy(longBytes, 0, logBytes, 0, longBytes.length); // @249308A
                                  System.arraycopy(xidBytes, 0, logBytes, longBytes.length, xidBytes.length); // @249308A
  
                                  raSection.addData(logBytes); // @249308C
                              }
                              else if (_tran.isSubordinate())
                              {
                                  logSupOrRecCoord();
                              }
                              else if (tc.isEventEnabled())
                              {
                                  Tr.event(tc, "Superior transaction.");
                              }
                              // PK84994 starts here
                              if (tc.isDebugEnabled())
                                  Tr.debug(tc, "Create sections in the Log for XID and TransactionState");
                              // Create sections in the Log for XID and TransactionState
                              RecoverableUnitSection gtidSection = _tranLog.createSection(TransactionImpl.GLOBALID_SECTION, true);
                              gtidSection.addData(_tran.getXidImpl().toBytes());
                              _logSection = _tranLog.createSection(TransactionImpl.TRAN_STATE_SECTION, true);
                              _logSection.addData(byteData);
                              // PK84994 ends here
                          }
                      } catch (Exception e)
                      {
                          FFDCFilter.processException(e, "com.ibm.tx.jta.impl.TransactionState.setState", "408", this);
                          if (tc.isEntryEnabled())
                              Tr.exit(tc, "setState : CreateSection failed", e);
                          _logSection = null; // Reset this so we do not write a rollback to the log
                          _loggingFailed = true; // Force no further subordinate logging
                          throw new SystemException(e.toString());
                      }
                  }
              }
  
              // Defect 1441
              //
              // Do we need to write to the log? Have
              // we written any data to our section?
              //
              if (_logSection != null)
              {
                  //
                  // Conditional add of state data to the log.
                  // this only happens if a RecoverableUnitSection
                  // has been created previously. This stops 1PC
                  // transactions from having any state written to
                  // the log.
                  //
                  if (newState == STATE_COMMITTED ||
                      newState == STATE_ROLLED_BACK ||
                      newState == STATE_ROLLING_BACK ||
                      (_tran.isSubordinate() && newState == STATE_HEURISTIC_ON_ROLLBACK))
                  {
                      byteData[0] = (byte) _state;
  
                      try
                      {
                          _logSection.addData(byteData);
                      } catch (Exception e)
                      {
                          FFDCFilter.processException(e, "com.ibm.tx.jta.impl.TransactionState.setState", "500", this);
                          if (tc.isEventEnabled())
                              Tr.event(tc, "addData failed during setState!");
                      }
                  }
  
                  try
                  {
                      switch (newState)
                      {
                          case STATE_PREPARED:
                              //
                              // Subordinate transactions need to force a
                              // write before returning vote to root tran.
                              //
                              if (_tran.isSubordinate())
                              {
                                  _tranLog.forceSections();
                              }
                              break;
  
                          case STATE_COMMITTING:
                          case STATE_ROLLING_BACK:
                              //
                              // If we are a root or RA transaction then we need
                              // to force logging once our completion direction
                              // has been chosen. Normally subordinates simply do an
                              // unforced write, but we always force since we reply
                              // early on commit and if a resource has failed and we
                              // crash, the superior may have already forgotten everything.
                              // 
                              _tranLog.forceSections();
                              break;
  
                          case STATE_HEURISTIC_ON_COMMIT:
                          case STATE_HEURISTIC_ON_ROLLBACK:
  
                              // Always force heuristic and we only do it on a subordinate...
                              if (_tran.isSubordinate())
                              {
                                  // Need to force sections here for the case where
                                  // we get a heuristic on prepare
                                  _tranLog.forceSections();
                              }
                              break;
  
                          case STATE_COMMITTED:
                          case STATE_ROLLED_BACK:
                              //
                              // Transaction has finished completion so write
                              // a non-forced log update.
                              //
                              // We only need to update the state to the log
                              // No need to log as we will be logging a removeRecoverableUnit anyway
                              // _logSection.write();
                              break;
  
                          case STATE_LAST_PARTICIPANT:
                              // All 2PC resources have been prepared and we 
                              // are waiting on the outcome of the 1PC last
                              // participant before confirming our completion
                              // direction.
                              _tranLog.forceSections();
                              break;
                      }
                  } catch (Exception e)
                  {
                      FFDCFilter.processException(e, "com.ibm.tx.jta.impl.TransactionState.setState", "505", this);
                      if (_partnerLogTable != null)
                          FFDCFilter.processException(e, "com.ibm.ws.Transaction.JTA.TransactionState.setState", "506", _partnerLogTable);
                      if (e instanceof LogFullException)
                          Tr.error(tc, "WTRN0083_LOG_FULL_ERROR", _tran.getTranName());
                      else
                          Tr.error(tc, "WTRN0066_LOG_WRITE_ERROR", e);
                      // If this is the first log write and it fails, then stop further logging
                      if (oldState == STATE_PREPARING)
                      {
                          _logSection = null; // Reset this so we do not write a rollback to the log
                          _loggingFailed = true; // Force no further subordinate logging
                          _state = oldState; // Reset state so we can rollback
                      }
                      if (tc.isEntryEnabled())
                          Tr.exit(tc, "setState: Error writing log record", e);
                      throw new SystemException(e.toString());
                  }
              }
          }
          else
          {
              if (tc.isDebugEnabled())
                  Tr.debug(tc, "TransactionState change FAILED from: " + stateToString(_state) + ", to: " + stateToString(newState));
              if (tc.isEntryEnabled())
                  Tr.exit(tc, "setState");
              throw new SystemException();
          }
  
          if (tc.isEntryEnabled())
              Tr.exit(tc, "setState");
      }