Index: vm/tests/kernel/java/lang/ClassLoaderTest.java =================================================================== --- vm/tests/kernel/java/lang/ClassLoaderTest.java (revision 465130) +++ vm/tests/kernel/java/lang/ClassLoaderTest.java (working copy) @@ -1,11 +1,10 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable. * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -644,7 +643,7 @@ //assertTrue("Error1", tcl.findLoadedClass("javax.imageio.IIOImage") // .getName().equals("javax.imageio.IIOImage")); } catch (ClassNotFoundException _) { - } catch (Throwable e) { + } catch (Throwable e) {e.printStackTrace(); fail("Error2: " + e.toString()); } @@ -918,7 +917,6 @@ new a3().main(new String[] { "" }); } - /** * */ @@ -952,6 +950,35 @@ fail("Error3"); } } + + /** + * + */ + public void test_findResource_Str_2() { + class LCL extends ClassLoader { + // only for special case + + public Class findClass(String name) { + return null; + } + + public java.net.URL findResource(String name) { + return super.findResource(name); + } + + public LCL() { + super(); + } + } + + LCL tcl = new LCL(); + // TEST CASE #1: + try { + assertTrue("Error1", tcl.findResource(null) == null); + } catch (NullPointerException _) { + fail("Error2"); + } + } /** * @@ -988,6 +1015,13 @@ } catch (Exception _) { fail("Error3"); } + + try { + tcl.findResources(null); + } catch (NullPointerException _) { + fail("Error5"); + } catch (java.io.IOException _) { + } } /** @@ -1275,12 +1309,11 @@ ClassLoader cl = ClassLoader.getSystemClassLoader(); // TEST CASE #1: -// Commented because of the drlvm issue. -// try { -// cl.getResource(null); -// fail("Error1: NullPointerException is not thrown for null argument"); -// } catch (NullPointerException _) { -// } + try { + cl.getResource(null); + fail("Error1: NullPointerException is not thrown for null argument"); + } catch (NullPointerException _) { + } // TEST CASE #2: assertTrue("Error1: unexpected:" @@ -1335,12 +1368,11 @@ ClassLoader cl = ClassLoader.getSystemClassLoader(); // TEST CASE #1: -// Commented because of the drlvm issue. -// try { -// cl.getResourceAsStream(null); -// fail("Error1: NullPointerException is not thrown for null argument"); -// } catch (NullPointerException _) { -// } + try { + cl.getResourceAsStream(null); + fail("Error1: NullPointerException is not thrown for null argument"); + } catch (NullPointerException _) { + } // TEST CASE #2: byte magic[] = new byte[4]; @@ -1520,12 +1552,11 @@ ClassLoader.getSystemClassLoader(); // TEST CASE #1: -// Commented because of the drlvm issue. -// try { -// ClassLoader.getSystemResource(null); -// fail("Error1: NullPointerException is not thrown for null argument"); -// } catch (NullPointerException _) { -// } + try { + ClassLoader.getSystemResource(null); + fail("Error1: NullPointerException is not thrown for null argument"); + } catch (NullPointerException _) { + } // TEST CASE #2: assertTrue("Error1: unexpected:" @@ -1582,12 +1613,11 @@ ClassLoader.getSystemClassLoader(); // TEST CASE #1: -// Commented because of the drlvm issue. -// try { -// ClassLoader.getSystemResourceAsStream(null); -// fail("Error1: NullPointerException is not thrown for null argument"); -// } catch (NullPointerException _) { -// } + try { + ClassLoader.getSystemResourceAsStream(null); + fail("Error1: NullPointerException is not thrown for null argument"); + } catch (NullPointerException _) { + } // TEST CASE #2: byte magic[] = new byte[4]; @@ -2201,5 +2231,35 @@ Number i[][][] = new Number[1][2][3]; ClassLoader.getSystemClassLoader().setSigners(i.getClass(), (Object[]) null); - } -} \ No newline at end of file + } + /** + * a "system class loader" serving for + * start an application should automatically grant the exitVM permission + * to all code loaded from the application class path + */ + public void test_SystemClassLoader_grants_exitVM_permission() { + String r=""; + String c = System.getProperty("java.home")+File.separator+"bin"+File.separator+"java" + + " -classpath "+System.getProperty("-Xbootclasspath/a:")+":." + " GrantedExitVMTst"; + try { + Process p = Runtime.getRuntime().exec(c); + java.io.InputStream is1 = p.getInputStream(); + p.waitFor(); + int ll = 0; + while ((ll=is1.available())!=0) { + byte b[]= new byte[ll]; + is1.read(b); + String ttt=new String(b); + r += ttt; + //System.out.print(ttt); + } + + if (p.waitFor() != 0 || r.indexOf("GrantedExitVMTst case #1 passed") == -1 || r.indexOf("GrantedExitVMTst case #2 passed") == -1) { + fail("TEST FAILED: Incorrect exitValue: "+p.exitValue()); + } + } catch (Exception e) { + e.printStackTrace(); + fail("TEST FAILED: Unexpected error: "+e); + } + } +}