use of java.io.InvalidObjectException in project jdk8u_jdk by JetBrains.
the class ConvertingMethod method invokeWithOpenReturn.
private Object invokeWithOpenReturn(Object obj, Object[] params) throws MBeanException, IllegalAccessException, InvocationTargetException {
final Object[] javaParams;
try {
javaParams = fromOpenParameters(params);
} catch (InvalidObjectException e) {
// probably can't happen
final String msg = methodName() + ": cannot convert parameters " + "from open values: " + e;
throw new MBeanException(e, msg);
}
final Object javaReturn = MethodUtil.invoke(method, obj, javaParams);
try {
return returnMapping.toOpenValue(javaReturn);
} catch (OpenDataException e) {
// probably can't happen
final String msg = methodName() + ": cannot convert return " + "value to open value: " + e;
throw new MBeanException(e, msg);
}
}
use of java.io.InvalidObjectException in project sis by apache.
the class AbstractAttribute method readObject.
/**
* Invoked on deserialization for restoring the {@link #characteristics} field.
*
* @param in the input stream from which to deserialize an attribute.
* @throws IOException if an I/O error occurred while reading or if the stream contains invalid data.
* @throws ClassNotFoundException if the class serialized on the stream is not on the classpath.
*/
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
try {
final AbstractAttribute<?>[] characterizedBy = (AbstractAttribute<?>[]) in.readObject();
if (characterizedBy != null) {
characteristics = newCharacteristicsMap();
characteristics.values().addAll(Arrays.asList(characterizedBy));
}
} catch (RuntimeException e) {
// At least ClassCastException, NullPointerException, IllegalArgumentException and IllegalStateException.
throw (IOException) new InvalidObjectException(e.getLocalizedMessage()).initCause(e);
}
}
use of java.io.InvalidObjectException in project Bytecoder by mirkosertic.
the class URI method readObject.
/**
* Reconstitutes a URI from the given serial stream.
*
* <p> The {@link java.io.ObjectInputStream#defaultReadObject()} method is
* invoked to read the value of the {@code string} field. The result is
* then parsed in the usual way.
*
* @param is The object-input stream from which this object
* is being read
*/
private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
// Argh
port = -1;
is.defaultReadObject();
try {
new Parser(string).parse(false);
} catch (URISyntaxException x) {
IOException y = new InvalidObjectException("Invalid URI");
y.initCause(x);
throw y;
}
}
use of java.io.InvalidObjectException in project Bytecoder by mirkosertic.
the class InetSocketAddress method readObject.
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
// Don't call defaultReadObject()
ObjectInputStream.GetField oisFields = in.readFields();
final String oisHostname = (String) oisFields.get("hostname", null);
final InetAddress oisAddr = (InetAddress) oisFields.get("addr", null);
final int oisPort = oisFields.get("port", -1);
// Check that our invariants are satisfied
checkPort(oisPort);
if (oisHostname == null && oisAddr == null)
throw new InvalidObjectException("hostname and addr " + "can't both be null");
InetSocketAddressHolder h = new InetSocketAddressHolder(oisHostname, oisAddr, oisPort);
UNSAFE.putObject(this, FIELDS_OFFSET, h);
}
use of java.io.InvalidObjectException in project Bytecoder by mirkosertic.
the class HashMap method readObject.
/**
* Reconstitute the {@code HashMap} instance from a stream (i.e.,
* deserialize it).
*/
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
// Read in the threshold (ignored), loadfactor, and any hidden stuff
s.defaultReadObject();
reinitialize();
if (loadFactor <= 0 || Float.isNaN(loadFactor))
throw new InvalidObjectException("Illegal load factor: " + loadFactor);
// Read and ignore number of buckets
s.readInt();
// Read number of mappings (size)
int mappings = s.readInt();
if (mappings < 0)
throw new InvalidObjectException("Illegal mappings count: " + mappings);
else if (mappings > 0) {
// (if zero, use defaults)
// Size the table using given load factor only if within
// range of 0.25...4.0
float lf = Math.min(Math.max(0.25f, loadFactor), 4.0f);
float fc = (float) mappings / lf + 1.0f;
int cap = ((fc < DEFAULT_INITIAL_CAPACITY) ? DEFAULT_INITIAL_CAPACITY : (fc >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : tableSizeFor((int) fc));
float ft = (float) cap * lf;
threshold = ((cap < MAXIMUM_CAPACITY && ft < MAXIMUM_CAPACITY) ? (int) ft : Integer.MAX_VALUE);
@SuppressWarnings({ "rawtypes", "unchecked" }) Node<K, V>[] tab = (Node<K, V>[]) new Node[cap];
table = tab;
// Read the keys and values, and put the mappings in the HashMap
for (int i = 0; i < mappings; i++) {
@SuppressWarnings("unchecked") K key = (K) s.readObject();
@SuppressWarnings("unchecked") V value = (V) s.readObject();
putVal(hash(key), key, value, false, false);
}
}
}
Aggregations