I have some legacy code that reads a configuration file from an existing jar, like:
URL url = SomeClass.class.getResource(\"/configuration.properties\");
//
A typical implementation of ClassLoader.getResourceAsStream
is:
public InputStream getResourceAsStream(String name) {
URL url = getResource(name);
try {
return url != null ? url.openStream() : null;
} catch (IOException e) {
return null;
}
}
Class.getResource
and getResourceAsStream
behave the same as each other.
So it looks like either you are using a strange and broken subclass of ClassLoader
, or there is some mistake in the tests on your side.