java.io.ObjectInputStream.resolveClass()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(239)

本文整理了Java中java.io.ObjectInputStream.resolveClass()方法的一些代码示例,展示了ObjectInputStream.resolveClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectInputStream.resolveClass()方法的具体详情如下:
包路径:java.io.ObjectInputStream
类名称:ObjectInputStream
方法名:resolveClass

ObjectInputStream.resolveClass介绍

[英]Loads the Java class corresponding to the class descriptor osClass that has just been read from the source stream.
[中]加载与刚从源流中读取的类描述符类相对应的Java类。

代码示例

代码示例来源:origin: baomidou/mybatis-plus

@Override
  protected Class<?> resolveClass(ObjectStreamClass objectStreamClass) throws IOException, ClassNotFoundException {
    Class<?> clazz = super.resolveClass(objectStreamClass);
    return clazz == java.lang.invoke.SerializedLambda.class ? SerializedLambda.class : clazz;
  }
}) {

代码示例来源:origin: redisson/redisson

@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);
  }
}

代码示例来源:origin: redisson/redisson

@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);
  }
}

代码示例来源:origin: wildfly/wildfly

protected Class<?> resolveClass(final ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    final String name = desc.getName();
    switch (name) {
      case SecurityVaultData.PICKETBOX_CLASS_NAME: return SecurityVaultData.class;
      default: return super.resolveClass(desc);
    }
  }
}

代码示例来源:origin: commons-io/commons-io

/**
 * Resolve a class specified by the descriptor using the
 * specified ClassLoader or the super ClassLoader.
 *
 * @param objectStreamClass  descriptor of the class
 * @return the Class object described by the ObjectStreamClass
 * @throws IOException in case of an I/O error
 * @throws ClassNotFoundException if the Class cannot be found
 */
@Override
protected Class<?> resolveClass(final ObjectStreamClass objectStreamClass)
    throws IOException, ClassNotFoundException {
  try {
    return Class.forName(objectStreamClass.getName(), false, classLoader);
  } catch (final ClassNotFoundException cnfe) {
    // delegate to super class loader which can resolve primitives
    return super.resolveClass(objectStreamClass);
  }
}

代码示例来源:origin: netty/netty

@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
  Class<?> clazz;
  try {
    clazz = classResolver.resolve(desc.getName());
  } catch (ClassNotFoundException ignored) {
    clazz = super.resolveClass(desc);
  }
  return clazz;
}

代码示例来源:origin: com.h2database/h2

@Override
  protected Class<?> resolveClass(ObjectStreamClass desc)
      throws IOException, ClassNotFoundException {
    try {
      return Class.forName(desc.getName(), true, loader);
    } catch (ClassNotFoundException e) {
      return super.resolveClass(desc);
    }
  }
};

代码示例来源:origin: commons-io/commons-io

@Override
protected Class<?> resolveClass(final ObjectStreamClass osc) throws IOException, ClassNotFoundException {
  validateClassName(osc.getName());
  return super.resolveClass(osc);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
  try {
    if (this.classLoader != null) {
      // Use the specified ClassLoader to resolve local classes.
      return ClassUtils.forName(classDesc.getName(), this.classLoader);
    }
    else {
      // Use the default ClassLoader...
      return super.resolveClass(classDesc);
    }
  }
  catch (ClassNotFoundException ex) {
    return resolveFallbackIfPossible(classDesc.getName(), ex);
  }
}

代码示例来源:origin: geoserver/geoserver

@Override
  protected Class<?> resolveClass(ObjectStreamClass desc)
      throws IOException, ClassNotFoundException {
    String name = desc.getName();
    try {
      return Class.forName(name, false, classLoader);
    } catch (ClassNotFoundException ex) {
      return super.resolveClass(desc);
    }
  }
}

代码示例来源:origin: redisson/redisson

@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
  Class<?> clazz;
  try {
    clazz = classResolver.resolve(desc.getName());
  } catch (ClassNotFoundException ignored) {
    clazz = super.resolveClass(desc);
  }
  return clazz;
}

代码示例来源:origin: lealone/Lealone

@Override
  protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    try {
      return Class.forName(desc.getName(), true, loader);
    } catch (ClassNotFoundException e) {
      return super.resolveClass(desc);
    }
  }
};

代码示例来源:origin: apache/flink

@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
  if (classLoader != null) {
    String name = desc.getName();
    try {
      return Class.forName(name, false, classLoader);
    } catch (ClassNotFoundException ex) {
      // check if class is a primitive class
      Class<?> cl = primitiveClasses.get(name);
      if (cl != null) {
        // return primitive class
        return cl;
      } else {
        // throw ClassNotFoundException
        throw ex;
      }
    }
  }
  return super.resolveClass(desc);
}

代码示例来源:origin: ben-manes/caffeine

@Override
 protected Class<?> resolveClass(ObjectStreamClass desc)
   throws IOException, ClassNotFoundException {
  try {
   return Class.forName(desc.getName(), /* initialize */ false, getClassLoader());
  } catch (ClassNotFoundException ex) {
   return super.resolveClass(desc);
  }
 }
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
  @Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    String clsName = desc.getName();
    if (clsFilter != null && !clsFilter.apply(clsName))
      throw new RuntimeException("Deserialization of class " + clsName + " is disallowed.");
    return super.resolveClass(desc);
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Override
protected Class<?> resolveClass(final ObjectStreamClass desc) throws IOException, ClassNotFoundException {
  String name = desc.getName();
  if (!(isAllowedByDefault(name) || allowedClasses.contains(name))) {
    throw new InvalidObjectException("Class is not allowed for deserialization: " + name);
  }
  return super.resolveClass(desc);
}

代码示例来源:origin: wildfly/wildfly

@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
  Class<?> clazz;
  try {
    clazz = classResolver.resolve(desc.getName());
  } catch (ClassNotFoundException ignored) {
    clazz = super.resolveClass(desc);
  }
  return clazz;
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
  protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
    Optional<Class> aClass = ClassUtils.forName(desc.getName(), requiredType.getClassLoader());
    if (aClass.isPresent()) {
      return aClass.get();
    }
    return super.resolveClass(desc);
  }
};

代码示例来源:origin: org.springframework/spring-core

@Override
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
  try {
    if (this.classLoader != null) {
      // Use the specified ClassLoader to resolve local classes.
      return ClassUtils.forName(classDesc.getName(), this.classLoader);
    }
    else {
      // Use the default ClassLoader...
      return super.resolveClass(classDesc);
    }
  }
  catch (ClassNotFoundException ex) {
    return resolveFallbackIfPossible(classDesc.getName(), ex);
  }
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

protected Class resolveClass(ObjectStreamClass desc)
  throws IOException, ClassNotFoundException {
  ClassLoader classLoader = classLoaderReference.getReference();
  if (classLoader == null) {
    return super.resolveClass(desc);
  } else {
    return Class.forName(desc.getName(), false, classLoader);
  }
}

相关文章

ObjectInputStream类方法