8249927: Specify limits of jdk.serialProxyInterfaceLimit

corrections to limits defined by 8236862 implemented by 8248183

Reviewed-by: smarks, rhalade, skoivu
This commit is contained in:
Roger Riggs 2020-07-31 14:03:39 -04:00 committed by Henry Jen
parent d6cef99050
commit 0d35235723

View file

@ -308,12 +308,12 @@ public class ObjectInputStream
/**
* Property to override the implementation limit on the number
* of interfaces allowed for Proxies.
* of interfaces allowed for Proxies. The property value is clamped to 0..65535.
* The maximum number of interfaces allowed for a proxy is limited to 65535 by
* {@link java.lang.reflect.Proxy#newProxyInstance(ClassLoader, Class[], InvocationHandler)}.
*/
static final int PROXY_INTERFACE_LIMIT = Math.min(65535, GetIntegerAction
.privilegedGetProperty("jdk.serialProxyInterfaceLimit", 65535));
static final int PROXY_INTERFACE_LIMIT = Math.max(0, Math.min(65535, GetIntegerAction
.privilegedGetProperty("jdk.serialProxyInterfaceLimit", 65535)));
}
/*
@ -1981,6 +1981,11 @@ public class ObjectInputStream
totalObjectRefs++;
depth++;
desc.initProxy(cl, resolveEx, readClassDesc(false));
} catch (OutOfMemoryError memerr) {
IOException ex = new InvalidObjectException("Proxy interface limit exceeded: " +
Arrays.toString(ifaces));
ex.initCause(memerr);
throw ex;
} finally {
depth--;
}