src/share/classes/java/io/ObjectInputStream.java

Print this page

        

*** 687,699 **** ClassLoader latestLoader = latestUserDefinedLoader(); ClassLoader nonPublicLoader = null; boolean hasNonPublicInterface = false; // define proxy in class loader of non-public interface(s), if any ! Class[] classObjs = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { ! Class cl = Class.forName(interfaces[i], false, latestLoader); if ((cl.getModifiers() & Modifier.PUBLIC) == 0) { if (hasNonPublicInterface) { if (nonPublicLoader != cl.getClassLoader()) { throw new IllegalAccessError( "conflicting non-public interface class loaders"); --- 687,699 ---- ClassLoader latestLoader = latestUserDefinedLoader(); ClassLoader nonPublicLoader = null; boolean hasNonPublicInterface = false; // define proxy in class loader of non-public interface(s), if any ! Class<?>[] classObjs = new Class<?>[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { ! Class<?> cl = Class.forName(interfaces[i], false, latestLoader); if ((cl.getModifiers() & Modifier.PUBLIC) == 0) { if (hasNonPublicInterface) { if (nonPublicLoader != cl.getClassLoader()) { throw new IllegalAccessError( "conflicting non-public interface class loaders");
*** 1227,1237 **** * without violating security constraints: the subclass must not override * security-sensitive non-final methods, or else the * "enableSubclassImplementation" SerializablePermission is checked. */ private void verifySubclass() { ! Class cl = getClass(); if (cl == ObjectInputStream.class) { return; } SecurityManager sm = System.getSecurityManager(); if (sm == null) { --- 1227,1237 ---- * without violating security constraints: the subclass must not override * security-sensitive non-final methods, or else the * "enableSubclassImplementation" SerializablePermission is checked. */ private void verifySubclass() { ! Class<?> cl = getClass(); if (cl == ObjectInputStream.class) { return; } SecurityManager sm = System.getSecurityManager(); if (sm == null) {
*** 1471,1486 **** * Reads in and returns class object. Sets passHandle to class object's * assigned handle. Returns null if class is unresolvable (in which case a * ClassNotFoundException will be associated with the class' handle in the * handle table). */ ! private Class readClass(boolean unshared) throws IOException { if (bin.readByte() != TC_CLASS) { throw new InternalError(); } ObjectStreamClass desc = readClassDesc(false); ! Class cl = desc.forClass(); passHandle = handles.assign(unshared ? unsharedMarker : cl); ClassNotFoundException resolveEx = desc.getResolveException(); if (resolveEx != null) { handles.markException(passHandle, resolveEx); --- 1471,1486 ---- * Reads in and returns class object. Sets passHandle to class object's * assigned handle. Returns null if class is unresolvable (in which case a * ClassNotFoundException will be associated with the class' handle in the * handle table). */ ! private Class<?> readClass(boolean unshared) throws IOException { if (bin.readByte() != TC_CLASS) { throw new InternalError(); } ObjectStreamClass desc = readClassDesc(false); ! Class<?> cl = desc.forClass(); passHandle = handles.assign(unshared ? unsharedMarker : cl); ClassNotFoundException resolveEx = desc.getResolveException(); if (resolveEx != null) { handles.markException(passHandle, resolveEx);
*** 1540,1550 **** String[] ifaces = new String[numIfaces]; for (int i = 0; i < numIfaces; i++) { ifaces[i] = bin.readUTF(); } ! Class cl = null; ClassNotFoundException resolveEx = null; bin.setBlockDataMode(true); try { if ((cl = resolveProxyClass(ifaces)) == null) { resolveEx = new ClassNotFoundException("null class"); --- 1540,1550 ---- String[] ifaces = new String[numIfaces]; for (int i = 0; i < numIfaces; i++) { ifaces[i] = bin.readUTF(); } ! Class<?> cl = null; ClassNotFoundException resolveEx = null; bin.setBlockDataMode(true); try { if ((cl = resolveProxyClass(ifaces)) == null) { resolveEx = new ClassNotFoundException("null class");
*** 1584,1594 **** } catch (ClassNotFoundException ex) { throw (IOException) new InvalidClassException( "failed to read class descriptor").initCause(ex); } ! Class cl = null; ClassNotFoundException resolveEx = null; bin.setBlockDataMode(true); try { if ((cl = resolveClass(readDesc)) == null) { resolveEx = new ClassNotFoundException("null class"); --- 1584,1594 ---- } catch (ClassNotFoundException ex) { throw (IOException) new InvalidClassException( "failed to read class descriptor").initCause(ex); } ! Class<?> cl = null; ClassNotFoundException resolveEx = null; bin.setBlockDataMode(true); try { if ((cl = resolveClass(readDesc)) == null) { resolveEx = new ClassNotFoundException("null class");
*** 1641,1651 **** ObjectStreamClass desc = readClassDesc(false); int len = bin.readInt(); Object array = null; ! Class cl, ccl = null; if ((cl = desc.forClass()) != null) { ccl = cl.getComponentType(); array = Array.newInstance(ccl, len); } --- 1641,1651 ---- ObjectStreamClass desc = readClassDesc(false); int len = bin.readInt(); Object array = null; ! Class<?> cl, ccl = null; if ((cl = desc.forClass()) != null) { ccl = cl.getComponentType(); array = Array.newInstance(ccl, len); }
*** 1694,1704 **** /** * Reads in and returns enum constant, or null if enum type is * unresolvable. Sets passHandle to enum constant's assigned handle. */ ! private Enum readEnum(boolean unshared) throws IOException { if (bin.readByte() != TC_ENUM) { throw new InternalError(); } ObjectStreamClass desc = readClassDesc(false); --- 1694,1704 ---- /** * Reads in and returns enum constant, or null if enum type is * unresolvable. Sets passHandle to enum constant's assigned handle. */ ! private Enum<?> readEnum(boolean unshared) throws IOException { if (bin.readByte() != TC_ENUM) { throw new InternalError(); } ObjectStreamClass desc = readClassDesc(false);
*** 1711,1738 **** if (resolveEx != null) { handles.markException(enumHandle, resolveEx); } String name = readString(false); ! Enum en = null; ! Class cl = desc.forClass(); if (cl != null) { try { ! en = Enum.valueOf(cl, name); } catch (IllegalArgumentException ex) { throw (IOException) new InvalidObjectException( "enum constant " + name + " does not exist in " + cl).initCause(ex); } if (!unshared) { ! handles.setObject(enumHandle, en); } } handles.finish(enumHandle); passHandle = enumHandle; ! return en; } /** * Reads and returns "ordinary" (i.e., not a String, Class, * ObjectStreamClass, array, or enum constant) object, or null if object's --- 1711,1740 ---- if (resolveEx != null) { handles.markException(enumHandle, resolveEx); } String name = readString(false); ! Enum<?> result = null; ! Class<?> cl = desc.forClass(); if (cl != null) { try { ! @SuppressWarnings("unchecked") ! Enum<?> en = Enum.valueOf((Class)cl, name); ! result = en; } catch (IllegalArgumentException ex) { throw (IOException) new InvalidObjectException( "enum constant " + name + " does not exist in " + cl).initCause(ex); } if (!unshared) { ! handles.setObject(enumHandle, result); } } handles.finish(enumHandle); passHandle = enumHandle; ! return result; } /** * Reads and returns "ordinary" (i.e., not a String, Class, * ObjectStreamClass, array, or enum constant) object, or null if object's
*** 1939,1949 **** */ private void defaultReadFields(Object obj, ObjectStreamClass desc) throws IOException { // REMIND: is isInstance check necessary? ! Class cl = desc.forClass(); if (cl != null && obj != null && !cl.isInstance(obj)) { throw new ClassCastException(); } int primDataSize = desc.getPrimDataSize(); --- 1941,1951 ---- */ private void defaultReadFields(Object obj, ObjectStreamClass desc) throws IOException { // REMIND: is isInstance check necessary? ! Class<?> cl = desc.forClass(); if (cl != null && obj != null && !cl.isInstance(obj)) { throw new ClassCastException(); } int primDataSize = desc.getPrimDataSize();
*** 2138,2148 **** * If no matching field is found in the (incoming) class * descriptor but a matching field is present in the associated local * class descriptor, returns -1. Throws IllegalArgumentException if * neither incoming nor local class descriptor contains a match. */ ! private int getFieldOffset(String name, Class type) { ObjectStreamField field = desc.getField(name, type); if (field != null) { return field.getOffset(); } else if (desc.getLocalDesc().getField(name, type) != null) { return -1; --- 2140,2150 ---- * If no matching field is found in the (incoming) class * descriptor but a matching field is present in the associated local * class descriptor, returns -1. Throws IllegalArgumentException if * neither incoming nor local class descriptor contains a match. */ ! private int getFieldOffset(String name, Class<?> type) { ObjectStreamField field = desc.getField(name, type); if (field != null) { return field.getOffset(); } else if (desc.getLocalDesc().getField(name, type) != null) { return -1;
*** 2836,2845 **** --- 2838,2848 ---- public String readUTF() throws IOException { return readUTFBody(readUnsignedShort()); } + @SuppressWarnings("deprecation") public String readLine() throws IOException { return din.readLine(); // deprecated, not worth optimizing } /* -------------- primitive data array input methods --------------- */