java.io.OptionalDataException类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(353)

本文整理了Java中java.io.OptionalDataException类的一些代码示例,展示了OptionalDataException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OptionalDataException类的具体详情如下:
包路径:java.io.OptionalDataException
类名称:OptionalDataException

OptionalDataException介绍

[英]Signals that the ObjectInputStream class encountered a primitive type ( int, char etc.) instead of an object instance in the input stream.
[中]表示ObjectInputStream类在输入流中遇到的是基元类型(int、char等),而不是对象实例。

代码示例

代码示例来源:origin: robovm/robovm

checkReadPrimitiveTypes();
if (primitiveData.available() > 0) {
  OptionalDataException e = new OptionalDataException();
  e.length = primitiveData.available();
  throw e;
    case TC_ENDBLOCKDATA: // Can occur reading class annotation
      pushbackTC();
      OptionalDataException e = new OptionalDataException();
      e.eof = true;
      throw e;

代码示例来源:origin: wildfly/wildfly

static OptionalDataException createOptionalDataException(final boolean eof) {
  final OptionalDataException optionalDataException = createOptionalDataException();
  final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
  final StackTraceElement[] copyStackTrace = new StackTraceElement[stackTrace.length - 1];
  System.arraycopy(stackTrace, 1, copyStackTrace, 0, copyStackTrace.length);
  optionalDataException.setStackTrace(copyStackTrace);
  optionalDataException.eof = eof;
  return optionalDataException;
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-jmx

throw new IOException(optionaldataexception.getMessage());

代码示例来源:origin: org.drools/drools-compiler

@Test
public void testJBRULES_1946() {
  KieBase kbase = loadKnowledgeBase("../Sample.drl" );
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream( baos );
    oos.writeObject( kbase );
    oos.flush();
    oos.close();
    baos.flush();
    baos.close();
    byte[] serializedKb = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream( serializedKb );
    ObjectInputStream ois = new ObjectInputStream( bais );
    KieBase kb2 = (KieBase) ois.readObject();
  } catch ( OptionalDataException ode ) {
    ode.printStackTrace();
    fail( "EOF? " + ode.eof );
  } catch ( Exception e ) {
    e.printStackTrace();
    fail( "Unexpected exception: " + e.getMessage() );
  }
}

代码示例来源:origin: org.jboss.mx/jboss-jmx

throw new IOException(optionaldataexception.getMessage());

代码示例来源:origin: org.drools/drools-compiler

@Test
public void testJBRULES_1946_2() {
  KieBase kbase = loadKnowledgeBase("../Sample.drl" );
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DroolsObjectOutputStream oos = new DroolsObjectOutputStream( baos );
    oos.writeObject( kbase );
    oos.flush();
    oos.close();
    baos.flush();
    baos.close();
    byte[] serializedKb = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream( serializedKb );
    DroolsObjectInputStream ois = new DroolsObjectInputStream( bais );
    KieBase kb2 = (KieBase) ois.readObject();
  } catch ( OptionalDataException ode ) {
    ode.printStackTrace();
    fail( "EOF? " + ode.eof );
  } catch ( Exception e ) {
    e.printStackTrace();
    fail( "Unexpected exception: " + e.getMessage() );
  }
}

代码示例来源:origin: org.apache.oodt/oodt-commons

System.err.println("Unable to read Incident from packet: " + ex.getMessage());
} catch (OptionalDataException ex) {
  System.err.println("Primitive data instead of Incident in packet: " + ex.getMessage());
} catch (IOException ex) {
  throw new IllegalStateException("Unexpected IOException: " + ex.getMessage());

代码示例来源:origin: stackoverflow.com

readObject0(false).

private Object readObject0(boolean unshared) throws IOException {
  boolean oldMode = bin.getBlockDataMode();
  if (oldMode) {
    int remain = bin.currentBlockRemaining();
    if (remain > 0) {
    throw new OptionalDataException(remain);
    } else if (defaultDataEnd) {
    /*
     * Fix for 4360508: stream is currently at the end of a field
     * value block written via default serialization; since there
     * is no terminating TC_ENDBLOCKDATA tag, simulate
     * end-of-custom-data behavior explicitly.
     */
    throw new OptionalDataException(true);
    }
    bin.setBlockDataMode(false);
  }

  byte tc;
  while ((tc = bin.peekByte()) == TC_RESET) {
    bin.readByte();
    handleReset();
  }

代码示例来源:origin: devinhu/androidone

e.printStackTrace();
} catch (OptionalDataException e) {
  e.printStackTrace();
} catch (FileNotFoundException e) {
  e.printStackTrace();

代码示例来源:origin: org.jboss.marshalling/jboss-marshalling-osgi

static OptionalDataException createOptionalDataException(final boolean eof) {
  final OptionalDataException optionalDataException = createOptionalDataException();
  final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
  final StackTraceElement[] copyStackTrace = new StackTraceElement[stackTrace.length - 1];
  System.arraycopy(stackTrace, 1, copyStackTrace, 0, copyStackTrace.length);
  optionalDataException.setStackTrace(copyStackTrace);
  optionalDataException.eof = eof;
  return optionalDataException;
}

代码示例来源:origin: apache/oodt

System.err.println("Unable to read Incident from packet: " + ex.getMessage());
} catch (OptionalDataException ex) {
  System.err.println("Primitive data instead of Incident in packet: " + ex.getMessage());
} catch (IOException ex) {
  throw new IllegalStateException("Unexpected IOException: " + ex.getMessage());

代码示例来源:origin: org.apidesign.bck2brwsr/emul

int remain = bin.currentBlockRemaining();
if (remain > 0) {
  throw new OptionalDataException(remain);
} else if (defaultDataEnd) {
  throw new OptionalDataException(true);
      bin.setBlockDataMode(true);
      throw new OptionalDataException(
        bin.currentBlockRemaining());
    } else {
      throw new OptionalDataException(true);
    } else {
      throw new StreamCorruptedException(

代码示例来源:origin: org.drools/drools-reteoo

@Test
public void testJBRULES_1946() {
  KnowledgeBase kbase = loadKnowledgeBase("../Sample.drl" );
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream( baos );
    oos.writeObject( kbase );
    oos.flush();
    oos.close();
    baos.flush();
    baos.close();
    byte[] serializedKb = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream( serializedKb );
    ObjectInputStream ois = new ObjectInputStream( bais );
    KnowledgeBase kb2 = (KnowledgeBase) ois.readObject();
  } catch ( OptionalDataException ode ) {
    ode.printStackTrace();
    fail( "EOF? " + ode.eof );
  } catch ( Exception e ) {
    e.printStackTrace();
    fail( "Unexpected exception: " + e.getMessage() );
  }
}

代码示例来源:origin: org.jboss.marshalling/jboss-marshalling

static OptionalDataException createOptionalDataException(final boolean eof) {
  final OptionalDataException optionalDataException = createOptionalDataException();
  final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
  final StackTraceElement[] copyStackTrace = new StackTraceElement[stackTrace.length - 1];
  System.arraycopy(stackTrace, 1, copyStackTrace, 0, copyStackTrace.length);
  optionalDataException.setStackTrace(copyStackTrace);
  optionalDataException.eof = eof;
  return optionalDataException;
}

代码示例来源:origin: org.jboss.spec.javax.sql/jboss-javax-sql-api_7.0_spec

throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.clonefail").toString() , ex.getMessage()));
} catch (OptionalDataException ex) {
  throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.clonefail").toString() , ex.getMessage()));
} catch (IOException ex) {
  throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.clonefail").toString() , ex.getMessage()));

代码示例来源:origin: jtulach/bck2brwsr

int remain = bin.currentBlockRemaining();
if (remain > 0) {
  throw new OptionalDataException(remain);
} else if (defaultDataEnd) {
  throw new OptionalDataException(true);
      bin.setBlockDataMode(true);
      throw new OptionalDataException(
        bin.currentBlockRemaining());
    } else {
      throw new OptionalDataException(true);
    } else {
      throw new StreamCorruptedException(

代码示例来源:origin: JChemPaint/jchempaint

public void redo() throws CannotRedoException {
  this.atom.setSymbol(symbol);
  try {
    IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder());
    this.atom.setMassNumber(ifac.getMajorIsotope(symbol).getMassNumber());
    chemModelRelay.updateAtom(atom);
    ifac.configure(atom);
  } catch (OptionalDataException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}

代码示例来源:origin: jboss-remoting/jboss-marshalling

static OptionalDataException createOptionalDataException(final boolean eof) {
  final OptionalDataException optionalDataException = createOptionalDataException();
  final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
  final StackTraceElement[] copyStackTrace = new StackTraceElement[stackTrace.length - 1];
  System.arraycopy(stackTrace, 1, copyStackTrace, 0, copyStackTrace.length);
  optionalDataException.setStackTrace(copyStackTrace);
  optionalDataException.eof = eof;
  return optionalDataException;
}

代码示例来源:origin: org.objectweb.jonas/jonas-commons

logger.log(BasicLevel.DEBUG, "Cannot get object from bytes : " + ode.getMessage());

代码示例来源:origin: com.jtransc/jtransc-rt

checkReadPrimitiveTypes();
if (primitiveData.available() > 0) {
  OptionalDataException e = new OptionalDataException();
  e.length = primitiveData.available();
  throw e;
    case TC_ENDBLOCKDATA: // Can occur reading class annotation
      pushbackTC();
      OptionalDataException e = new OptionalDataException();
      e.eof = true;
      throw e;

相关文章