/** Reads an object from the given object input. * The object had to be saved by the {@link NbObjectOutputStream#writeSafely} method. * * @param oi object input * @return the read object * @exception IOException if IO error occured * @exception SafeException if the operation failed but the stream is ok * for further reading */ public static Object readSafely(ObjectInput oi) throws IOException { int size = oi.readInt(); byte[] byteArray = new byte[size]; oi.readFully(byteArray, 0, size); try { ByteArrayInputStream bis = new ByteArrayInputStream(byteArray); NbObjectInputStream ois = new NbObjectInputStream(bis); Object obj = ois.readObject(); bis.close(); return obj; } catch (Exception exc) { // encapsulate all exceptions into safe exception throw new SafeException(exc); } catch (LinkageError le) { throw new SafeException(new InvocationTargetException(le)); } }
/** Create a new object input. * @param is underlying input stream * @throws IOException for the usual reasons */ public NbObjectInputStream(InputStream is) throws IOException { super(is); try { enableResolveObject(true); } catch (SecurityException ex) { throw new IOException(ex.toString()); } }
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { ClassLoader cl = getNBClassLoader(); try { return Class.forName(v.getName(), false, cl); } catch (ClassNotFoundException cnfe) { String msg = "Offending classloader: " + cl; // NOI18N Exceptions.attachMessage(cnfe, msg); throw cnfe; } }
ObjectInputStream ois = new NbObjectInputStream(bin);
org.openide.util.io.NbObjectInputStream nbis = new org.openide.util.io.NbObjectInputStream(bis); Object o = nbis.readObject(); nbis.close(); return o; } else {
public static void load() throws IOException { FileObject ser = getLoaderPoolStorage(false); if (ser != null) { try { ObjectInputStream ois = new NbObjectInputStream(ser.getInputStream()); try { NbObjectInputStream.readSafely(ois); } finally { ois.close(); } } catch (IOException x) { ser.delete(); // #144158: probably not valuable, just kill it throw x; } } } private static final String LOADER_POOL_NAME = "loaders.ser"; // NOI18N
ObjectInputStream ois = new NbObjectInputStream(bis); Object ret = ois.readObject();
/** Reads an object from the given object input. * The object had to be saved by the {@link NbObjectOutputStream#writeSafely} method. * * @param oi object input * @return the read object * @exception IOException if IO error occured * @exception SafeException if the operation failed but the stream is ok * for further reading */ public static Object readSafely (ObjectInput oi) throws IOException { int size = oi.readInt (); byte[] byteArray = new byte [size]; oi.readFully (byteArray, 0, size); try { ByteArrayInputStream bis = new ByteArrayInputStream (byteArray); NbObjectInputStream ois = new NbObjectInputStream (bis); Object obj = ois.readObject (); bis.close (); return obj; } catch (Exception exc) { // encapsulate all exceptions into safe exception throw new SafeException (exc); } catch (LinkageError le) { throw new SafeException (new InvocationTargetException (le)); } }
ObjectInputStream ois = new org.openide.util.io.NbObjectInputStream(fis); Object o = ois.readObject();
ClassLoader cl = getNBClassLoader(); Class clazz = Class.forName(newN, false, cl);
/** Create a new object input. * @param is underlying input stream * @throws IOException for the usual reasons */ public NbObjectInputStream(InputStream is) throws IOException { super (is); try { enableResolveObject (true); } catch (SecurityException ex) { throw new IOException (ex.toString ()); } }
/** Reads an object from the given object input. * The object had to be saved by the {@link NbObjectOutputStream#writeSafely} method. * * @param oi object input * @return the read object * @exception IOException if IO error occured * @exception SafeException if the operation failed but the stream is ok * for further reading */ public static Object readSafely(ObjectInput oi) throws IOException { int size = oi.readInt(); byte[] byteArray = new byte[size]; oi.readFully(byteArray, 0, size); try { ByteArrayInputStream bis = new ByteArrayInputStream(byteArray); NbObjectInputStream ois = new NbObjectInputStream(bis); Object obj = ois.readObject(); bis.close(); return obj; } catch (Exception exc) { // encapsulate all exceptions into safe exception throw new SafeException(exc); } catch (LinkageError le) { throw new SafeException(new InvocationTargetException(le)); } }
ObjectInputStream ois = new NbObjectInputStream(bin);
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { ClassLoader cl = getNBClassLoader(); try { return Class.forName(v.getName(), false, cl); } catch (ClassNotFoundException cnfe) { String msg = "Offending classloader: " + cl; // NOI18N Exceptions.attachMessage(cnfe, msg); throw cnfe; } }
/** Create a new object input. * @param is underlying input stream * @throws IOException for the usual reasons */ public NbObjectInputStream(InputStream is) throws IOException { super (is); try { enableResolveObject (true); } catch (SecurityException ex) { throw new IOException (ex.toString ()); } }
/** Reads an object from the given object input. * The object had to be saved by the {@link NbObjectOutputStream#writeSafely} method. * * @param oi object input * @return the read object * @exception IOException if IO error occured * @exception SafeException if the operation failed but the stream is ok * for further reading */ public static Object readSafely(ObjectInput oi) throws IOException { int size = oi.readInt(); byte[] byteArray = new byte[size]; oi.readFully(byteArray, 0, size); try { ByteArrayInputStream bis = new ByteArrayInputStream(byteArray); NbObjectInputStream ois = new NbObjectInputStream(bis); Object obj = ois.readObject(); bis.close(); return obj; } catch (Exception exc) { // encapsulate all exceptions into safe exception throw new SafeException(exc); } catch (LinkageError le) { throw new SafeException(new InvocationTargetException(le)); } }
ObjectInputStream ois = new NbObjectInputStream(bin);
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { ClassLoader cl = getNBClassLoader(); try { return Class.forName(v.getName(), false, cl); } catch (ClassNotFoundException cnfe) { String msg = "Offending classloader: " + cl; // NOI18N Exceptions.attachMessage(cnfe, msg); throw cnfe; } }
/** Create a new object input. * @param is underlying input stream * @throws IOException for the usual reasons */ public NbObjectInputStream(InputStream is) throws IOException { super(is); try { enableResolveObject(true); } catch (SecurityException ex) { throw new IOException(ex.toString()); } }
/** Reads an object from the given object input. * The object had to be saved by the {@link NbObjectOutputStream#writeSafely} method. * * @param oi object input * @return the read object * @exception IOException if IO error occured * @exception SafeException if the operation failed but the stream is ok * for further reading */ public static Object readSafely (ObjectInput oi) throws IOException { int size = oi.readInt (); byte[] byteArray = new byte [size]; oi.readFully (byteArray, 0, size); try { ByteArrayInputStream bis = new ByteArrayInputStream (byteArray); NbObjectInputStream ois = new NbObjectInputStream (bis); Object obj = ois.readObject (); bis.close (); return obj; } catch (Exception exc) { // encapsulate all exceptions into safe exception throw new SafeException (exc); } catch (LinkageError le) { throw new SafeException (new InvocationTargetException (le)); } }