public Object unmarshal0(XMLStreamReader reader, JaxBeanInfo expectedType) throws JAXBException {
    if (reader == null) {
      throw new IllegalArgumentException(Messages.format(Messages.NULL_READER));
    }

    int eventType = reader.getEventType();
    if (eventType != XMLStreamConstants.START_ELEMENT
        && eventType != XMLStreamConstants.START_DOCUMENT) {
      // TODO: convert eventType into event name
      throw new IllegalStateException(Messages.format(Messages.ILLEGAL_READER_STATE, eventType));
    }

    XmlVisitor h = createUnmarshallerHandler(null, false, expectedType);
    StAXConnector connector = StAXStreamConnector.create(reader, h);

    try {
      connector.bridge();
    } catch (XMLStreamException e) {
      throw handleStreamException(e);
    }

    Object retVal = h.getContext().getResult();
    h.getContext().clearResult();
    return retVal;
  }
  private Object unmarshal0(XMLEventReader reader, JaxBeanInfo expectedType) throws JAXBException {
    if (reader == null) {
      throw new IllegalArgumentException(Messages.format(Messages.NULL_READER));
    }

    try {
      XMLEvent event = reader.peek();

      if (!event.isStartElement() && !event.isStartDocument()) {
        // TODO: convert event into event name
        throw new IllegalStateException(
            Messages.format(Messages.ILLEGAL_READER_STATE, event.getEventType()));
      }

      // Quick hack until SJSXP fixes 6270116
      boolean isZephyr = reader.getClass().getName().equals("com.sun.xml.stream.XMLReaderImpl");
      XmlVisitor h = createUnmarshallerHandler(null, false, expectedType);
      if (!isZephyr) h = new InterningXmlVisitor(h);
      new StAXEventConnector(reader, h).bridge();
      return h.getContext().getResult();
    } catch (XMLStreamException e) {
      throw handleStreamException(e);
    }
  }