mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8280642: ObjectInputStream.readObject should throw InvalidClassException instead of IllegalAccessError
Reviewed-by: naoto, mchung
This commit is contained in:
parent
d95de5c7fe
commit
fdd9ca74bd
2 changed files with 13 additions and 8 deletions
|
@ -1995,6 +1995,10 @@ public class ObjectInputStream
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
resolveEx = ex;
|
resolveEx = ex;
|
||||||
|
} catch (IllegalAccessError aie) {
|
||||||
|
IOException ice = new InvalidClassException(aie.getMessage());
|
||||||
|
ice.initCause(aie);
|
||||||
|
throw ice;
|
||||||
} catch (OutOfMemoryError memerr) {
|
} catch (OutOfMemoryError memerr) {
|
||||||
IOException ex = new InvalidObjectException("Proxy interface limit exceeded: " +
|
IOException ex = new InvalidObjectException("Proxy interface limit exceeded: " +
|
||||||
Arrays.toString(ifaces));
|
Arrays.toString(ifaces));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
*
|
* @bug 8280642
|
||||||
* @summary functional test for RMIClassLoader.loadProxyClass; test
|
* @summary functional test for RMIClassLoader.loadProxyClass; test
|
||||||
* ensures that the default RMI class loader provider implements
|
* ensures that the default RMI class loader provider implements
|
||||||
* RMIClassLoader.loadProxyClass correctly.
|
* RMIClassLoader.loadProxyClass correctly.
|
||||||
|
@ -48,6 +48,7 @@ import java.rmi.MarshalledObject;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.io.InvalidClassException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -205,20 +206,20 @@ public class LoadProxyClasses {
|
||||||
currentThread.getContextClassLoader();
|
currentThread.getContextClassLoader();
|
||||||
currentThread.setContextClassLoader(nonpublicLoaderB);
|
currentThread.setContextClassLoader(nonpublicLoaderB);
|
||||||
|
|
||||||
IllegalAccessError illegal = null;
|
InvalidClassException invalid = null;
|
||||||
try {
|
try {
|
||||||
unmarshalProxyClass(proxy4, fnnLoader2, nonpublicLoaderB,
|
unmarshalProxyClass(proxy4, fnnLoader2, nonpublicLoaderB,
|
||||||
4, null);
|
4, null);
|
||||||
} catch (IllegalAccessError e) {
|
} catch (InvalidClassException e) {
|
||||||
illegal = e;
|
invalid = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (illegal == null) {
|
if (invalid == null) {
|
||||||
TestLibrary.bomb("case4: IllegalAccessError not thrown " +
|
TestLibrary.bomb("case4: InvalidClassException not thrown " +
|
||||||
"when multiple nonpublic interfaces have \n" +
|
"when multiple nonpublic interfaces have \n" +
|
||||||
"different class loaders");
|
"different class loaders");
|
||||||
} else {
|
} else {
|
||||||
System.err.println("\ncase4: IllegalAccessError correctly " +
|
System.err.println("\ncase4: InvalidClassException correctly " +
|
||||||
"thrown \n when trying to load proxy " +
|
"thrown \n when trying to load proxy " +
|
||||||
"with multiple nonpublic interfaces in \n" +
|
"with multiple nonpublic interfaces in \n" +
|
||||||
" different class loaders");
|
" different class loaders");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue