1 /* |
1 /* |
2 * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
45 protected final Object readObjectOverride() |
45 protected final Object readObjectOverride() |
46 throws OptionalDataException, ClassNotFoundException, IOException { |
46 throws OptionalDataException, ClassNotFoundException, IOException { |
47 |
47 |
48 Object readResult = null; |
48 Object readResult = null; |
49 Object prevObject = currentObject; |
49 Object prevObject = currentObject; |
50 Class prevDesc = currentClassDescriptor; |
50 Class<?> prevDesc = currentClassDescriptor; |
51 |
51 |
52 boolean NotImplemented = true; |
52 boolean NotImplemented = true; |
53 if (NotImplemented) |
53 if (NotImplemented) |
54 throw new IOException("readObjectOverride not implemented"); |
54 throw new IOException("readObjectOverride not implemented"); |
55 |
55 |
254 * |
254 * |
255 * Look for the readObject method |
255 * Look for the readObject method |
256 * Set the accessible flag on it here. ObjectOutputStream |
256 * Set the accessible flag on it here. ObjectOutputStream |
257 * will call it as necessary. |
257 * will call it as necessary. |
258 */ |
258 */ |
259 public static Method getReadObjectMethod(final Class cl) { |
259 public static Method getReadObjectMethod(final Class<?> cl) { |
260 |
260 |
261 Method readObjectMethod = (Method) |
261 Method readObjectMethod = |
262 java.security.AccessController.doPrivileged |
262 java.security.AccessController.doPrivileged |
263 (new java.security.PrivilegedAction() { |
263 (new java.security.PrivilegedAction<Method>() { |
264 public Object run() { |
264 public Method run() { |
265 Method m = null; |
265 Method m = null; |
266 try { |
266 try { |
267 Class[] args = {ObjectInputStream.class}; |
267 Class<?>[] args = {ObjectInputStream.class}; |
268 m = cl.getDeclaredMethod("readObject", args); |
268 m = cl.getDeclaredMethod("readObject", args); |
269 int mods = m.getModifiers(); |
269 int mods = m.getModifiers(); |
270 // Method must be private and non-static |
270 // Method must be private and non-static |
271 if (!Modifier.isPrivate(mods) || |
271 if (!Modifier.isPrivate(mods) || |
272 Modifier.isStatic(mods)) { |
272 Modifier.isStatic(mods)) { |
290 final Object[] argList) |
290 final Object[] argList) |
291 throws IOException |
291 throws IOException |
292 { |
292 { |
293 try { |
293 try { |
294 java.security.AccessController.doPrivileged |
294 java.security.AccessController.doPrivileged |
295 (new java.security.PrivilegedExceptionAction() { |
295 (new java.security.PrivilegedExceptionAction<Void>() { |
296 public Object run() throws InvocationTargetException, |
296 public Void run() throws InvocationTargetException, |
297 java.lang.IllegalAccessException { |
297 java.lang.IllegalAccessException { |
298 m.invoke(obj, argList); |
298 m.invoke(obj, argList); |
299 return null; |
299 return null; |
300 } |
300 } |
301 }); |
301 }); |