@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
int type = read();
if( type < 0 )
throw new EOFException();
switch( type )
{
case 0:
return super.readClassDescriptor();
case 1:
Class<?> clazz = loadClass(readUTF());
return ObjectStreamClass.lookup(clazz);
default:
throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
}
}
java类java.io.StreamCorruptedException的实例源码
CompactedObjectInputStream.java 文件源码
项目:dubbox
阅读 24
收藏 0
点赞 0
评论 0
CompactedObjectInputStream.java 文件源码
项目:dubbo
阅读 22
收藏 0
点赞 0
评论 0
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
int type = read();
if( type < 0 )
throw new EOFException();
switch( type )
{
case 0:
return super.readClassDescriptor();
case 1:
Class<?> clazz = loadClass(readUTF());
return ObjectStreamClass.lookup(clazz);
default:
throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
}
}
CompactedObjectInputStream.java 文件源码
项目:dubbo3
阅读 27
收藏 0
点赞 0
评论 0
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException,ClassNotFoundException
{
int type = read();
if( type < 0 )
throw new EOFException();
switch( type )
{
case 0:
return super.readClassDescriptor();
case 1:
Class<?> clazz = loadClass(readUTF());
return ObjectStreamClass.lookup(clazz);
default:
throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
}
}
StreamRemoteCall.java 文件源码
项目:jdk8u_jdk
阅读 26
收藏 0
点赞 0
评论 0
/**
* Returns an output stream (may put out header information
* relating to the success of the call).
* @param success If true, indicates normal return, else indicates
* exceptional return.
* @exception StreamCorruptedException If result stream previously
* acquired
* @exception IOException For any other problem with I/O.
*/
public ObjectOutput getResultStream(boolean success) throws IOException {
/* make sure result code only marshaled once. */
if (resultStarted)
throw new StreamCorruptedException("result already in progress");
else
resultStarted = true;
// write out return header
// return header, part 1 (read by Transport)
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
wr.writeByte(TransportConstants.Return);// transport op
getOutputStream(true); // creates a MarshalOutputStream
// return header, part 2 (read by client-side RemoteCall)
if (success) //
out.writeByte(TransportConstants.NormalReturn);
else
out.writeByte(TransportConstants.ExceptionalReturn);
out.writeID(); // write id for gcAck
return out;
}
Direction.java 文件源码
项目:Skript
阅读 19
收藏 0
点赞 0
评论 0
@Override
public boolean excessiveField(@NonNull final FieldContext field) throws StreamCorruptedException {
if (field.getID().equals("mod")) {
final double[] mod = field.getObject(double[].class);
if (mod == null)
return true;
if (mod.length != 3)
throw new StreamCorruptedException();
set("pitchOrX", mod[0]);
set("yawOrY", mod[1]);
set("lengthOrZ", mod[1]);
return true;
} else if (field.getID().equals("pitch")) {
set("pitchOrX", field.getPrimitive(double.class));
return true;
} else if (field.getID().equals("yaw")) {
set("yawOrY", field.getPrimitive(double.class));
return true;
} else if (field.getID().equals("length")) {
set("lengthOrZ", field.getPrimitive(double.class));
return true;
} else {
return false;
}
}
Utils.java 文件源码
项目:offloading-framework-android
阅读 23
收藏 0
点赞 0
评论 0
public static Object byteArrayToObject(byte[] bytes)
throws StreamCorruptedException, IOException, ClassNotFoundException {
Object obj = null;
ByteArrayInputStream bis = null;
ObjectInputStream ois = null;
try {
bis = new ByteArrayInputStream(bytes);
ois = new ObjectInputStream(bis);
obj = ois.readObject();
} finally {
if (bis != null) {
bis.close();
}
if (ois != null) {
ois.close();
}
}
return obj;
}
Fields.java 文件源码
项目:Skript
阅读 22
收藏 0
点赞 0
评论 0
public void setField(final Object o, final Field f, final Yggdrasil y) throws StreamCorruptedException {
if (Modifier.isStatic(f.getModifiers()))
throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is static");
if (Modifier.isTransient(f.getModifiers()))
throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is transient");
if (f.getType().isPrimitive() != isPrimitiveValue)
throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is " + (f.getType().isPrimitive() ? "" : "not ") + "primitive");
try {
f.setAccessible(true);
f.set(o, value);
} catch (final IllegalArgumentException e) {
if (!(o instanceof YggdrasilRobustSerializable) || !((YggdrasilRobustSerializable) o).incompatibleField(f, this))
y.incompatibleField(o, f, this);
} catch (final IllegalAccessException e) {
assert false;
}
}
Fields.java 文件源码
项目:Skript
阅读 23
收藏 0
点赞 0
评论 0
/**
* Sets all fields of the given Object to the values stored in this Fields object.
*
* @param o The object whose fields should be set
* @throws StreamCorruptedException
* @throws NotSerializableException
* @throws YggdrasilException If this was called on a Fields object not created by Yggdrasil itself
*/
public void setFields(final Object o) throws StreamCorruptedException, NotSerializableException {
final Yggdrasil y = yggdrasil;
if (y == null)
throw new YggdrasilException("");
final Set<FieldContext> excessive = new HashSet<FieldContext>(fields.values());
final Class<?> oc = o.getClass();
assert oc != null;
for (final Field f : getFields(oc)) {
assert f != null;
final String id = Yggdrasil.getID(f);
final FieldContext c = fields.get(id);
if (c == null) {
if (!(o instanceof YggdrasilRobustSerializable) || !((YggdrasilRobustSerializable) o).missingField(f))
y.missingField(o, f);
} else {
c.setField(o, f, y);
}
excessive.remove(c);
}
for (final FieldContext f : excessive) {
assert f != null;
if (!(o instanceof YggdrasilRobustSerializable) || !((YggdrasilRobustSerializable) o).excessiveField(f))
y.excessiveField(o, f);
}
}
Ser.java 文件源码
项目:jdk8u_jdk
阅读 32
收藏 0
点赞 0
评论 0
private static Object readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException {
switch (type) {
case DURATION_TYPE: return Duration.readExternal(in);
case INSTANT_TYPE: return Instant.readExternal(in);
case LOCAL_DATE_TYPE: return LocalDate.readExternal(in);
case LOCAL_DATE_TIME_TYPE: return LocalDateTime.readExternal(in);
case LOCAL_TIME_TYPE: return LocalTime.readExternal(in);
case ZONE_DATE_TIME_TYPE: return ZonedDateTime.readExternal(in);
case ZONE_OFFSET_TYPE: return ZoneOffset.readExternal(in);
case ZONE_REGION_TYPE: return ZoneRegion.readExternal(in);
case OFFSET_TIME_TYPE: return OffsetTime.readExternal(in);
case OFFSET_DATE_TIME_TYPE: return OffsetDateTime.readExternal(in);
case YEAR_TYPE: return Year.readExternal(in);
case YEAR_MONTH_TYPE: return YearMonth.readExternal(in);
case MONTH_DAY_TYPE: return MonthDay.readExternal(in);
case PERIOD_TYPE: return Period.readExternal(in);
default:
throw new StreamCorruptedException("Unknown serialized type");
}
}
YggXMLInputStream.java 文件源码
项目:Skript
阅读 17
收藏 0
点赞 0
评论 0
@SuppressWarnings("null")
private Class<?> getType(String s) throws StreamCorruptedException {
int dim = 0;
while (s.endsWith("[]")) {
s = "" + s.substring(0, s.length() - 2);
dim++;
}
Class<?> c;
final Tag t = Tag.byName(s);
if (t != null)
c = t.c;
else
c = yggdrasil.getClass(s);
if (c == null)
throw new StreamCorruptedException("Invalid type " + s);
if (dim == 0)
return c;
while (dim-- > 0)
c = Array.newInstance(c, 0).getClass();
return c;
}