/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This test runs in othervm mode as it tests ClassLoader.findSystemClass
* and getSystemResource methods.
*/
/* @test
@bug 4147599 4478150
@summary In 1.2beta4-I ClassLoader loaded classes can not link
against application classes.
*/
/*
* We are trying to test that certain methods of ClassLoader look at the same
* paths as they did in 1.1. To run this test on 1.1, you will have to pass
* "-1.1" as option on the command line.
*
* The required files are:
*
* - Loader.java (a 1.1 style class loader)
* - Loadee.java (source for a class that refers to Loader)
* - Loadee.classfile (to test findSystemClass)
* - Loadee.resource (to test getSystemResource)
* - java/lang/Object.class (to test getSystemResources)
*
* The extension ".classfile" is so the class file is not seen by any loader
* other than Loader. If you need to make any changes you will have to
* compile Loadee.java and rename Loadee.class to Loadee.classfile.
*/
/**
* A 1.1-style ClassLoader. The only class it can really load is "Loadee".
* For other classes it might be asked to load, it relies on loaders set up by
* the launcher.
*/
throws ClassNotFoundException {
try {
c = findSystemClass(name);
} catch (ClassNotFoundException cnfe) {
}
if (c == null) {
throw new Error("java.lang.ClassLoader.findSystemClass() " +
"did not find class " + name);
byte[] b = locateBytes();
}
if (resolve) {
resolveClass(c);
}
return c;
}
private byte[] locateBytes() {
try {
"Loadee.classfile");
long l = f.length();
byte[] b = new byte[(int)l];
new DataInputStream(new FileInputStream(f));
return b;
} catch (IOException ioe) {
throw new Error("Test failed due to IOException!");
}
}
}
report("findSystemClass()");
ClassLoader l = new Loader();
Object o = c.newInstance();
}
report("getSystemResource()");
if (u == null)
throw new Exception
("java.lang.ClassLoader.getSystemResource() test failed!");
}
report("getSystemResources()");
while (e.hasMoreElements()) {
if (u == null)
break;
}
throw
new Exception("java.lang.ClassLoader.getSystemResources()"+
" did not find all resources");
}
}
}
}
}