File tree 1 file changed +8
-3
lines changed
src/java.base/share/classes/java/io
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -308,12 +308,12 @@ private static class Caches {
308
308
309
309
/**
310
310
* Property to override the implementation limit on the number
311
- * of interfaces allowed for Proxies.
311
+ * of interfaces allowed for Proxies. The property value is clamped to 0..65535.
312
312
* The maximum number of interfaces allowed for a proxy is limited to 65535 by
313
313
* {@link java.lang.reflect.Proxy#newProxyInstance(ClassLoader, Class[], InvocationHandler)}.
314
314
*/
315
- static final int PROXY_INTERFACE_LIMIT = Math .min (65535 , GetIntegerAction
316
- .privilegedGetProperty ("jdk.serialProxyInterfaceLimit" , 65535 ));
315
+ static final int PROXY_INTERFACE_LIMIT = Math .max ( 0 , Math . min (65535 , GetIntegerAction
316
+ .privilegedGetProperty ("jdk.serialProxyInterfaceLimit" , 65535 ))) ;
317
317
}
318
318
319
319
/*
@@ -1981,6 +1981,11 @@ private ObjectStreamClass readProxyDesc(boolean unshared)
1981
1981
totalObjectRefs ++;
1982
1982
depth ++;
1983
1983
desc .initProxy (cl , resolveEx , readClassDesc (false ));
1984
+ } catch (OutOfMemoryError memerr ) {
1985
+ IOException ex = new InvalidObjectException ("Proxy interface limit exceeded: " +
1986
+ Arrays .toString (ifaces ));
1987
+ ex .initCause (memerr );
1988
+ throw ex ;
1984
1989
} finally {
1985
1990
depth --;
1986
1991
}
You can’t perform that action at this time.
0 commit comments