本文整理了Java中java.io.ObjectInputStream.readClassDescriptor()
方法的一些代码示例,展示了ObjectInputStream.readClassDescriptor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectInputStream.readClassDescriptor()
方法的具体详情如下:
包路径:java.io.ObjectInputStream
类名称:ObjectInputStream
方法名:readClassDescriptor
[英]Reads a class descriptor from the source stream.
[中]从源流中读取类描述符。
代码示例来源:origin: apache/incubator-dubbo
@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);
}
}
代码示例来源:origin: apache/incubator-dubbo
@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);
}
}
代码示例来源:origin: facebook/facebook-android-sdk
@Override
protected ObjectStreamClass readClassDescriptor()
throws IOException, ClassNotFoundException {
ObjectStreamClass resultClassDescriptor = super.readClassDescriptor();
if (resultClassDescriptor.getName().equals(
ACCESS_TOKEN_APP_ID_PAIR_SERIALIZATION_PROXY_V1_CLASS_NAME)) {
resultClassDescriptor = ObjectStreamClass.lookup(
AccessTokenAppIdPair.SerializationProxyV1.class);
} else if (resultClassDescriptor.getName().equals(
APP_EVENT_SERIALIZATION_PROXY_V1_CLASS_NAME)) {
resultClassDescriptor = ObjectStreamClass.lookup(
AppEvent.SerializationProxyV1.class);
}
return resultClassDescriptor;
}
}
代码示例来源:origin: netty/netty
@Override
protected ObjectStreamClass readClassDescriptor()
throws IOException, ClassNotFoundException {
int type = read();
if (type < 0) {
throw new EOFException();
}
switch (type) {
case CompactObjectOutputStream.TYPE_FAT_DESCRIPTOR:
return super.readClassDescriptor();
case CompactObjectOutputStream.TYPE_THIN_DESCRIPTOR:
String className = readUTF();
Class<?> clazz = classResolver.resolve(className);
return ObjectStreamClass.lookupAny(clazz);
default:
throw new StreamCorruptedException(
"Unexpected class descriptor type: " + type);
}
}
代码示例来源:origin: redisson/redisson
@Override
protected ObjectStreamClass readClassDescriptor()
throws IOException, ClassNotFoundException {
int type = read();
if (type < 0) {
throw new EOFException();
}
switch (type) {
case CompactObjectOutputStream.TYPE_FAT_DESCRIPTOR:
return super.readClassDescriptor();
case CompactObjectOutputStream.TYPE_THIN_DESCRIPTOR:
String className = readUTF();
Class<?> clazz = classResolver.resolve(className);
return ObjectStreamClass.lookupAny(clazz);
default:
throw new StreamCorruptedException(
"Unexpected class descriptor type: " + type);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected ObjectStreamClass readClassDescriptor()
throws IOException, ClassNotFoundException {
int type = read();
if (type < 0) {
throw new EOFException();
}
switch (type) {
case CompactObjectOutputStream.TYPE_FAT_DESCRIPTOR:
return super.readClassDescriptor();
case CompactObjectOutputStream.TYPE_THIN_DESCRIPTOR:
String className = readUTF();
Class<?> clazz = classResolver.resolve(className);
return ObjectStreamClass.lookupAny(clazz);
default:
throw new StreamCorruptedException(
"Unexpected class descriptor type: " + type);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-util
ObjectStreamClass ose = super.readClassDescriptor();
代码示例来源:origin: io.netty/netty
return super.readClassDescriptor();
case CompactObjectOutputStream.TYPE_THIN_DESCRIPTOR:
String className = readUTF();
代码示例来源:origin: redisson/redisson
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
boolean isProxy = readBoolean();
if (isProxy) {
String name = (String)readObject();
Class superClass = loader.loadClass(name);
int length = readInt();
Class[] interfaces = new Class[length];
for (int i = 0; i < length; i++) {
name = (String)readObject();
interfaces[i] = loader.loadClass(name);
}
length = readInt();
byte[] signature = new byte[length];
read(signature);
ProxyFactory factory = new ProxyFactory();
// we must always use the cache and never use writeReplace when using
// ProxyObjectOutputStream and ProxyObjectInputStream
factory.setUseCache(true);
factory.setUseWriteReplace(false);
factory.setSuperclass(superClass);
factory.setInterfaces(interfaces);
Class proxyClass = factory.createClass(signature);
return ObjectStreamClass.lookup(proxyClass);
} else {
return super.readClassDescriptor();
}
}
代码示例来源:origin: org.javassist/javassist
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
boolean isProxy = readBoolean();
if (isProxy) {
String name = (String)readObject();
Class<?> superClass = loader.loadClass(name);
int length = readInt();
Class<?>[] interfaces = new Class[length];
for (int i = 0; i < length; i++) {
name = (String)readObject();
interfaces[i] = loader.loadClass(name);
}
length = readInt();
byte[] signature = new byte[length];
read(signature);
ProxyFactory factory = new ProxyFactory();
// we must always use the cache and never use writeReplace when using
// ProxyObjectOutputStream and ProxyObjectInputStream
factory.setUseCache(true);
factory.setUseWriteReplace(false);
factory.setSuperclass(superClass);
factory.setInterfaces(interfaces);
Class<?> proxyClass = factory.createClass(signature);
return ObjectStreamClass.lookup(proxyClass);
}
return super.readClassDescriptor();
}
代码示例来源:origin: scouter-project/scouter
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
boolean isProxy = readBoolean();
if (isProxy) {
String name = (String)readObject();
Class<?> superClass = loader.loadClass(name);
int length = readInt();
Class<?>[] interfaces = new Class[length];
for (int i = 0; i < length; i++) {
name = (String)readObject();
interfaces[i] = loader.loadClass(name);
}
length = readInt();
byte[] signature = new byte[length];
read(signature);
ProxyFactory factory = new ProxyFactory();
// we must always use the cache and never use writeReplace when using
// ProxyObjectOutputStream and ProxyObjectInputStream
factory.setUseCache(true);
factory.setUseWriteReplace(false);
factory.setSuperclass(superClass);
factory.setInterfaces(interfaces);
Class<?> proxyClass = factory.createClass(signature);
return ObjectStreamClass.lookup(proxyClass);
}
return super.readClassDescriptor();
}
代码示例来源:origin: scouter-project/scouter
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
boolean isProxy = readBoolean();
if (isProxy) {
String name = (String)readObject();
Class superClass = loader.loadClass(name);
int length = readInt();
Class[] interfaces = new Class[length];
for (int i = 0; i < length; i++) {
name = (String)readObject();
interfaces[i] = loader.loadClass(name);
}
length = readInt();
byte[] signature = new byte[length];
read(signature);
ProxyFactory factory = new ProxyFactory();
// we must always use the cache and never use writeReplace when using
// ProxyObjectOutputStream and ProxyObjectInputStream
factory.setUseCache(true);
factory.setUseWriteReplace(false);
factory.setSuperclass(superClass);
factory.setInterfaces(interfaces);
Class proxyClass = factory.createClass(signature);
return ObjectStreamClass.lookup(proxyClass);
} else {
return super.readClassDescriptor();
}
}
代码示例来源:origin: robovm/robovm
private ObjectStreamClass readEnumDescInternal() throws IOException, ClassNotFoundException {
ObjectStreamClass classDesc;
primitiveData = input;
int oldHandle = descriptorHandle;
descriptorHandle = nextHandle();
classDesc = readClassDescriptor();
registerObjectRead(classDesc, descriptorHandle, false);
descriptorHandle = oldHandle;
primitiveData = emptyStream;
classDesc.setClass(resolveClass(classDesc));
// Consume unread class annotation data and TC_ENDBLOCKDATA
discardData();
ObjectStreamClass superClass = readClassDesc();
checkedSetSuperClassDesc(classDesc, superClass);
// Check SUIDs, note all SUID for Enum is 0L
if (0L != classDesc.getSerialVersionUID() || 0L != superClass.getSerialVersionUID()) {
throw new InvalidClassException(superClass.getName(),
"Incompatible class (SUID): " + superClass + " but expected " + superClass);
}
byte tc = nextTC();
// discard TC_ENDBLOCKDATA after classDesc if any
if (tc == TC_ENDBLOCKDATA) {
// read next parent class. For enum, it may be null
superClass.setSuperclass(readClassDesc());
} else {
// not TC_ENDBLOCKDATA, push back for next read
pushbackTC();
}
return classDesc;
}
代码示例来源:origin: robovm/robovm
int oldHandle = descriptorHandle;
descriptorHandle = nextHandle();
ObjectStreamClass newClassDesc = readClassDescriptor();
registerObjectRead(newClassDesc, descriptorHandle, unshared);
descriptorHandle = oldHandle;
代码示例来源:origin: killme2008/xmemcached
@Override
protected ObjectStreamClass readClassDescriptor()
throws IOException, ClassNotFoundException {
int type = read();
if (type < 0) {
throw new EOFException();
}
switch (type) {
case 0: // Primitive types
return super.readClassDescriptor();
case 1: // Non-primitive types
String className = readUTF();
Class<?> clazz = Class.forName(className, true, classLoader);
return ObjectStreamClass.lookup(clazz);
default:
throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
}
}
代码示例来源:origin: au.net.zeus.jgdms/jgdms-platform
@Override
public ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
return super.readClassDescriptor();
}
}
代码示例来源:origin: com.github.veithen.visualwas/connector
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
nextIsClassName = true;
return super.readClassDescriptor();
}
代码示例来源:origin: cinchapi/concourse
@Override
protected ObjectStreamClass readClassDescriptor()
throws IOException, ClassNotFoundException {
ObjectStreamClass read = super.readClassDescriptor();
if(read.getName().equals(
"com.cinchapi.concourse.server.storage.ByteableFunnel")) {
upgrade.set(true);
return ObjectStreamClass.lookup(ByteableFunnel.class);
}
return read;
}
代码示例来源:origin: com.voodoodyne.trivet/trivet
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
ObjectStreamClass read = super.readClassDescriptor();
if (read.forClass() == null && read.getName().endsWith("Exception")) {
log.warning(read.getName() + " is not present on the client classpath; substituting " + SUBSTITUTE_EXCEPTION.forClass().getSimpleName());
return SUBSTITUTE_EXCEPTION;
} else {
return read;
}
}
}
代码示例来源:origin: jenkinsci/remoting
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
ObjectStreamClass d = super.readClassDescriptor();
// this can be used to filter out classes
System.out.println(d.getName());
return d;
}
};
内容来源于网络,如有侵权,请联系作者删除!