當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectStreamClass.getName方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:ObjectInputStreamResolveClass.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:TestObjectStreamClass.java

示例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);
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:17,代碼來源:InternalDataSerializer.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:RMIJRMPServerImpl.java

示例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);
    }
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:12,代碼來源:CustomClassLoaderObjectInputStream.java

示例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;
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:32,代碼來源:SSObjectInputStream.java

示例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;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:11,代碼來源:SerialClone.java

示例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);
    }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:10,代碼來源:CustomObjectInputStream.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:FailureAtomicity.java

示例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);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:20,代碼來源:ReplicationStream.java

示例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;
		}
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:44,代碼來源:CustomObjectInputStream.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:UnnamedPackageSwitchTest.java

示例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);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:TransferableProxy.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:ObjectInputStreamWithLoader.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:Beans.java


注:本文中的java.io.ObjectStreamClass.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。