本文整理匯總了Java中java.io.ObjectStreamClass.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectStreamClass.getName方法的具體用法?Java ObjectStreamClass.getName怎麽用?Java ObjectStreamClass.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.ObjectStreamClass
的用法示例。
在下文中一共展示了ObjectStreamClass.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
protected Class<?> resolveClass(ObjectStreamClass desc)
throws IOException,
ClassNotFoundException
{
Class<?> cls = null;
String className = desc.getName();
// if it is primitive class, for example, long.class
// we resolve them by getting them from the hashMaps
cls = _PRIMITIVE_CLASSES.get(className);
if (null == cls)
{
// TRINIDAD-1062 It has been noticed that in OC4J and Weblogic that the
// classes being resolved are having problems by not finding
// them using the context class loader. Therefore, we are adding
// this work-around until the problem with these application
// servers can be better understood
cls = ClassLoaderUtils.loadClass(desc.getName());
}
return cls;
}
示例2: main
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
ObjectOutputStream output = new ObjectOutputStream(byteOutput);
output.writeObject(new TestClass());
ByteArrayInputStream bais = new ByteArrayInputStream(byteOutput.toByteArray());
TestObjectInputStream input = new TestObjectInputStream(bais);
input.readObject();
ObjectStreamClass osc = input.getDescriptor();
// All OSC public API methods should complete without throwing.
osc.getName();
osc.forClass();
osc.getField("str");
osc.getFields();
osc.getSerialVersionUID();
osc.toString();
}
示例3: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
protected Class resolveClass(ObjectStreamClass desc)
throws IOException, ClassNotFoundException {
String className = desc.getName();
OldClientSupportService svc = getOldClientSupportService();
if (svc != null) {
className = svc.processIncomingClassName(className);
}
try {
Class clazz = getCachedClass(className);
return clazz;
} catch (ClassNotFoundException ex) {
return super.resolveClass(desc);
}
}
示例4: check
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
public void check(Method method, ObjectStreamClass descriptor,
int paramIndex, int callID) {
String type = descriptor.getName();
if (!allowedTypes.contains(type)) {
throw new ClassCastException("Unsupported type: " + type);
}
}
示例5: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws ClassNotFoundException, IOException {
try {
String name = desc.getName();
return Class.forName(name, false, classLoader);
}
catch (ClassNotFoundException e) {
return super.resolveClass(desc);
}
}
示例6: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
protected Class<?> resolveClass(@NotNull final ObjectStreamClass desc) throws IOException, ClassNotFoundException {
try {
return super.resolveClass(desc);
} catch (final ClassNotFoundException e) {
final String name = desc.getName();
try (final Reference ref = ReferenceFactory.takeFromTLPool(ReferenceType.OBJECT)) {
final PluginManager pluginManager = PluginManager.getInstance();
pluginManager.handlePlugins(plugin -> {
if (ref.getObject() != null) return;
final ClassLoader classLoader = plugin.getClassLoader();
try {
ref.setObject(classLoader.loadClass(name));
} catch (final ClassNotFoundException ex) {
}
});
if (ref.getObject() != null) {
return (Class<?>) ref.getObject();
}
}
throw e;
}
}
示例7: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
protected Class<?> resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException {
Class<?> c = output.classQueue.poll();
String expected = osc.getName();
String found = (c == null) ? null : c.getName();
if (!expected.equals(found)) {
throw new InvalidClassException("Classes desynchronized: found " + found + " when expecting " + expected);
}
return c;
}
示例8: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
try {
String name = desc.getName();
return Class.forName(name, false, classLoader);
} catch (ClassNotFoundException e) {
return super.resolveClass(desc);
}
}
示例9: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
protected Class<?> resolveClass(ObjectStreamClass desc)
throws IOException, ClassNotFoundException {
try {
return super.resolveClass(desc);
} catch (ClassNotFoundException x) {
String name = desc.getName();
return Class.forName(name, false, loader);
}
}
示例10: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
/**
* Load the local class equivalent of the specified stream class
* description, by using the class loader assigned to this Context.
*
* @param classDesc Class description from the input stream
*
* @exception ClassNotFoundException if this class cannot be found
* @exception IOException if an input/output error occurs
*/
@Override
public Class<?> resolveClass(ObjectStreamClass classDesc)
throws ClassNotFoundException, IOException {
String name = classDesc.getName();
try {
return resolveClass(name);
} catch (ClassNotFoundException e) {
return super.resolveClass(classDesc);
}
}
示例11: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
/**
* Load the local class equivalent of the specified stream class
* description, by using the class loader assigned to this Context.
*
* @param classDesc
* Class description from the input stream
*
* @exception ClassNotFoundException
* if this class cannot be found
* @exception IOException
* if an input/output error occurs
*/
@Override
public Class<?> resolveClass(ObjectStreamClass classDesc) throws ClassNotFoundException, IOException {
String name = classDesc.getName();
if (allowedClassNamePattern != null) {
boolean allowed = allowedClassNamePattern.matcher(name).matches();
if (!allowed) {
boolean doLog = warnOnFailure && reportedClasses.add(name);
String msg = sm.getString("customObjectInputStream.nomatch", name, allowedClassNameFilter);
if (doLog) {
log.warn(msg);
} else if (log.isDebugEnabled()) {
log.debug(msg);
}
throw new InvalidClassException(msg);
}
}
try {
return Class.forName(name, false, classLoader);
} catch (ClassNotFoundException e) {
try {
// Try also the superclass because of primitive types
return super.resolveClass(classDesc);
} catch (ClassNotFoundException e2) {
// Rethrow original exception, as it can have more information
// about why the class was not found. BZ 48007
throw e;
}
}
}
示例12: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
protected Class resolveClass(ObjectStreamClass desc)
throws IOException, ClassNotFoundException
{
String name = desc.getName();
if (name.equals("A")) {
return pkg.A.class;
} else if (name.equals("pkg.A")) {
return A.class;
} else {
return super.resolveClass(desc);
}
}
示例13: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
protected Class<?> resolveClass(ObjectStreamClass classDesc)
throws IOException, ClassNotFoundException {
String className = classDesc.getName();
Set<String> s = new HashSet<String>(1);
s.add(className);
ClassLoader classLoader = map.get(s);
if (classLoader != null) {
return Class.forName(className, false, classLoader);
} else {
return super.resolveClass(classDesc);
}
}
示例14: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
@Override
protected Class<?> resolveClass(ObjectStreamClass aClass)
throws IOException, ClassNotFoundException {
if (loader == null) {
return super.resolveClass(aClass);
} else {
String name = aClass.getName();
ReflectUtil.checkPackageAccess(name);
// Query the class loader ...
return Class.forName(name, false, loader);
}
}
示例15: resolveClass
import java.io.ObjectStreamClass; //導入方法依賴的package包/類
/**
* Use the given ClassLoader rather than using the system class
*/
@SuppressWarnings("rawtypes")
protected Class resolveClass(ObjectStreamClass classDesc)
throws IOException, ClassNotFoundException {
String cname = classDesc.getName();
return ClassFinder.resolveClass(cname, this.loader);
}