docs: private static SubjectCookie setInvocationSubject(Subject s) {
          final SubjectCookie cookie = new SubjectCookie();
          SubjectManagerService sms = smServiceRef.getService();
          if (sms != null) {
              if (s == null) {
                  s = new Subject();
              }
  
              Subject currentInvocationSubject = sms.getInvocationSubject();
              sms.setInvocationSubject(s);
  
              cookie.subject = currentInvocationSubject;
  
              // If SYNC-TO-OS-THREAD support is enabled for the server and configured for this app,
              // then sync the Subject's identity to the thread.  The returned token is handed back
              // to the ThreadIdentityManager when we restore of the previous invocation subject
              // (under restoreInvocationSubject).
              try {
                  cookie.token = ThreadIdentityManager.setAppThreadIdentity(s);
              } catch (ThreadIdentityException e) {
                  throw new SecurityException(e);
              }
          }
          return cookie;
      }