--- old/test/java/lang/reflect/Proxy/ClassRestrictions.java 2012-12-13 15:09:55.069000000 +0400 +++ new/test/java/lang/reflect/Proxy/ClassRestrictions.java 2012-12-13 15:09:53.861000000 +0400 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4227192 + * @bug 4227192 8004928 * @summary This is a test of the restrictions on the parameters that may * be passed to the Proxy.getProxyClass method. * @author Peter Jones @@ -31,6 +31,7 @@ * @run main ClassRestrictions */ +import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; import java.net.URLClassLoader; @@ -47,7 +48,9 @@ interface Bashful { void foo(); } - + + public static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants"; + public static void main(String[] args) { System.err.println( @@ -65,7 +68,7 @@ try { interfaces = new Class[] { Object.class }; proxyClass = Proxy.getProxyClass(loader, interfaces); - throw new RuntimeException( + throw new Error( "proxy class created with java.lang.Object as interface"); } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -75,7 +78,7 @@ try { interfaces = new Class[] { Integer.TYPE }; proxyClass = Proxy.getProxyClass(loader, interfaces); - throw new RuntimeException( + throw new Error( "proxy class created with int.class as interface"); } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -90,7 +93,7 @@ try { interfaces = new Class[] { Bar.class, Bar.class }; proxyClass = Proxy.getProxyClass(loader, interfaces); - throw new RuntimeException( + throw new Error( "proxy class created with repeated interfaces"); } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -109,7 +112,7 @@ try { interfaces = new Class[] { altBarClass }; proxyClass = Proxy.getProxyClass(loader, interfaces); - throw new RuntimeException( + throw new Error( "proxy class created with interface " + "not visible to class loader"); } catch (IllegalArgumentException e) { @@ -122,34 +125,16 @@ * All non-public interfaces must be in the same package. */ Class nonPublic1 = Bashful.class; - Class nonPublic2 = null; - String[] nonPublicInterfaces = new String[] { - "java.awt.Conditional", - "java.util.zip.ZipConstants", - "javax.swing.GraphicsWrapper", - "javax.swing.JPopupMenu$Popup", - "javax.swing.JTable$Resizable2", - "javax.swing.JTable$Resizable3", - "javax.swing.ToolTipManager$Popup", - "sun.audio.Format", - "sun.audio.HaePlayable", - "sun.tools.agent.StepConstants", - }; - for (int i = 0; i < nonPublicInterfaces.length; i++) { - try { - nonPublic2 = Class.forName(nonPublicInterfaces[i]); - break; - } catch (ClassNotFoundException e) { - } - } - if (nonPublic2 == null) { - throw new RuntimeException( - "no second non-public interface found for test"); + Class nonPublic2 = Class.forName(nonPublicIntrfaceName); + if (Modifier.isPublic(nonPublic2.getModifiers())) { + throw new Error( + "Interface " + nonPublicIntrfaceName + + " is public and need to be changed!"); } try { interfaces = new Class[] { nonPublic1, nonPublic2 }; proxyClass = Proxy.getProxyClass(loader, interfaces); - throw new RuntimeException( + throw new Error( "proxy class created with two non-public interfaces " + "in different packages"); } catch (IllegalArgumentException e) { @@ -165,7 +150,7 @@ try { interfaces = new Class[] { Bar.class, Baz.class }; proxyClass = Proxy.getProxyClass(loader, interfaces); - throw new RuntimeException( + throw new Error( "proxy class created with conflicting methods"); } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -178,10 +163,10 @@ */ System.err.println("\nTEST PASSED"); - } catch (Exception e) { + } catch (Throwable e) { System.err.println("\nTEST FAILED:"); e.printStackTrace(); - throw new RuntimeException("TEST FAILED: " + e.toString()); + throw new Error("TEST FAILED: ", e); } } }