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

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

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

ObjectInputStream.resolveObject介绍

[英]Allows trusted subclasses to substitute the specified original object with a new object. Object substitution has to be activated first with calling enableResolveObject(true). This implementation just returns object.
[中]允许受信任的子类用新对象替换指定的原始对象。必须首先通过调用enableResolveObject(true)激活对象替换。这个实现只返回对象。

代码示例

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

/** {@inheritDoc} */
  @Override protected Object resolveObject(Object o) throws IOException {
    if (o != null && o.getClass().equals(JdkMarshallerDummySerializable.class))
      return new Object();

    return super.resolveObject(o);
  }
}

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

@Override
protected Object resolveObject(Object obj) throws IOException {
  if (obj instanceof Wrapper) {
    try {
      (obj = ConfigurationSerialization.deserializeObject(((Wrapper<?>) obj).map)).getClass(); // NPE
    } catch (Throwable ex) {
      throw newIOException("Failed to deserialize object", ex);
    }
  }
  return super.resolveObject(obj);
}

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

/**
 * Read a string encoded in {@link DataInput modified UTF-8} from the
 * receiver. Return the string read.
 *
 * @param unshared
 *            read the object unshared
 * @return the string just read.
 * @throws IOException
 *             If an IO exception happened when reading the String.
 */
private Object readNewString(boolean unshared) throws IOException {
  Object result = input.readUTF();
  if (enableResolve) {
    result = resolveObject(result);
  }
  registerObjectRead(result, nextHandle(), unshared);
  return result;
}

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

@SuppressWarnings({ "unchecked", "rawtypes" })
  @Override
  protected Object resolveObject(Object obj) throws IOException
  {
    if (obj instanceof ReferenceReplacement)
    {
      final ReferenceReplacement replacement = (ReferenceReplacement) obj;
      if (replacement.address != null)
      {
        return runtime.getRemoteObserverReference(replacement.address, (Class) replacement.interfaceClass, replacement.id);
      }
      return runtime.getReference((Class) replacement.interfaceClass, replacement.id);

    }
    return super.resolveObject(obj);
  }
}

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

/**
 * Read a new String in UTF format from the receiver. Return the string
 * read.
 *
 * @param unshared
 *            read the object unshared
 * @return the string just read.
 *
 * @throws IOException
 *             If an IO exception happened when reading the String.
 */
private Object readNewLongString(boolean unshared) throws IOException {
  long length = input.readLong();
  Object result = input.decodeUTF((int) length);
  if (enableResolve) {
    result = resolveObject(result);
  }
  registerObjectRead(result, nextHandle(), unshared);
  return result;
}

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

result = resolveObject(result);
registerObjectRead(result, newHandle, false);

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

result = resolveObject(result);

代码示例来源:origin: org.apache.wicket/wicket-core

@Override
  protected Object resolveObject(Object obj) throws IOException
  {
    Object replaced = replacedComponents.get(obj);
    if (replaced != null)
    {
      return replaced;
    }
    return super.resolveObject(obj);
  }
}

代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service

@Override
  protected Object resolveObject(Object obj) throws IOException
  {
    Object replaced = replacedComponents.get(obj);
    if (replaced != null)
    {
      return replaced;
    }
    return super.resolveObject(obj);
  }
}

代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket

protected Object resolveObject(Object obj) throws IOException
  {
    Object replaced = replacedComponents.get(obj);
    if (replaced != null)
    {
      return replaced;
    }
    return super.resolveObject(obj);
  }
}

代码示例来源:origin: org.apache.ignite/ignite-core

/** {@inheritDoc} */
  @Override protected Object resolveObject(Object o) throws IOException {
    if (o != null && o.getClass().equals(JdkMarshallerDummySerializable.class))
      return new Object();

    return super.resolveObject(o);
  }
}

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

/** {@inheritDoc} */
  @Override protected Object resolveObject(Object o) throws IOException {
    if (o != null && o.getClass().equals(GridJdkMarshallerDummySerializable.class))
      return new Object();

    return super.resolveObject(o);
  }
}

代码示例来源:origin: arquillian/arquillian-core

@Override
  protected Object resolveObject(Object obj) throws IOException {
    return super.resolveObject(obj);
  }
};

代码示例来源:origin: jenkinsci/remoting

@Override 
  protected Object resolveObject(Object obj) throws IOException {
    if(obj instanceof URL){
      // SECURITY-637, URL deserialization could lead to DNS query
      return URLDeserializationHelper.wrapIfRequired((URL) obj);
    }
    return super.resolveObject(obj);
  }
}

代码示例来源:origin: jenkinsci/remoting

@Override
  protected Object resolveObject(Object obj) throws IOException {
    if(obj instanceof URL){
      // SECURITY-637, URL deserialization could lead to DNS query
      return URLDeserializationHelper.wrapIfRequired((URL) obj);
    }
    return super.resolveObject(obj);
  }
}

代码示例来源:origin: SpigotMC/Spigot-API

@Override
protected Object resolveObject(Object obj) throws IOException {
  if (obj instanceof Wrapper) {
    try {
      (obj = ConfigurationSerialization.deserializeObject(((Wrapper<?>) obj).map)).getClass(); // NPE
    } catch (Throwable ex) {
      throw newIOException("Failed to deserialize object", ex);
    }
  }
  return super.resolveObject(obj);
}

代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service

@Override
protected final Object resolveObject(Object object) throws IOException {
  if (object instanceof ReplaceBundleContext) {
    ReplaceBundleContext replaceBundleContext = (ReplaceBundleContext) object;
    return replaceBundleContext.getBundleContext();
  } else if (object instanceof ReplaceBundle) {
    ReplaceBundle replaceBundle = (ReplaceBundle) object;
    return replaceBundle.getBundle();
  } else {
    return super.resolveObject(object);
  }
}

代码示例来源:origin: org.ops4j.pax.wicket/org.ops4j.pax.wicket.service

/** {@inheritDoc} */
@Override
protected final Object resolveObject(Object object) throws IOException {
  if (object instanceof ReplaceBundleContext) {
    ReplaceBundleContext replaceBundleContext = (ReplaceBundleContext) object;
    return replaceBundleContext.getBundleContext();
  } else if (object instanceof ReplaceBundle) {
    ReplaceBundle replaceBundle = (ReplaceBundle) object;
    return replaceBundle.getBundle();
  } else {
    return super.resolveObject(object);
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Read a string encoded in {@link DataInput modified UTF-8} from the
 * receiver. Return the string read.
 *
 * @param unshared
 *            read the object unshared
 * @return the string just read.
 * @throws IOException
 *             If an IO exception happened when reading the String.
 */
private Object readNewString(boolean unshared) throws IOException {
  Object result = input.readUTF();
  if (enableResolve) {
    result = resolveObject(result);
  }
  registerObjectRead(result, nextHandle(), unshared);
  return result;
}

代码示例来源:origin: ops4j/org.ops4j.pax.wicket

/** {@inheritDoc} */
@Override
protected final Object resolveObject(Object object) throws IOException {
  if (object instanceof ReplaceBundleContext) {
    ReplaceBundleContext replaceBundleContext = (ReplaceBundleContext) object;
    return replaceBundleContext.getBundleContext();
  } else if (object instanceof ReplaceBundle) {
    ReplaceBundle replaceBundle = (ReplaceBundle) object;
    return replaceBundle.getBundle();
  } else {
    return super.resolveObject(object);
  }
}

相关文章

ObjectInputStream类方法