Skip to content

Commit

Permalink
Merge 068b9d5 into 8b9bf75
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerRiggs authored Jan 23, 2024
2 parents 8b9bf75 + 068b9d5 commit 8337828
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/java.base/share/classes/java/io/ObjectInputStream.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1987,9 +1987,8 @@ private ObjectStreamClass readProxyDesc(boolean unshared)
resolveEx = ex;
} catch (IllegalAccessError aie) {
throw new InvalidClassException(aie.getMessage(), aie);
} catch (OutOfMemoryError memerr) {
throw new InvalidObjectException("Proxy interface limit exceeded: " +
Arrays.toString(ifaces), memerr);
} catch (OutOfMemoryError oome) {
throw genInvalidObjectException(oome, ifaces);
}

// Call filterCheck on the class before reading anything else
Expand All @@ -2001,9 +2000,8 @@ private ObjectStreamClass readProxyDesc(boolean unshared)
totalObjectRefs++;
depth++;
desc.initProxy(cl, resolveEx, readClassDesc(false));
} catch (OutOfMemoryError memerr) {
throw new InvalidObjectException("Proxy interface limit exceeded: " +
Arrays.toString(ifaces), memerr);
} catch (OutOfMemoryError oome) {
throw genInvalidObjectException(oome, ifaces);
} finally {
depth--;
}
Expand All @@ -2013,6 +2011,13 @@ private ObjectStreamClass readProxyDesc(boolean unshared)
return desc;
}

// Generate an InvalidObjectException for an OutOfMemoryError
// Use String.concat() to avoid string formatting code generation
private static InvalidObjectException genInvalidObjectException(OutOfMemoryError oome, String[] ifaces) {
return new InvalidObjectException("Proxy interface limit exceeded: "
.concat(Arrays.toString(ifaces)), oome);
}

/**
* Reads in and returns class descriptor for a class that is not a dynamic
* proxy class. Sets passHandle to class descriptor's assigned handle. If
Expand Down

0 comments on commit 8337828

Please sign in to comment.