dev@glassfish.java.net

Why does WebappClassLoader.getResourceAsStream not delegate to getResource()?

From: Sanjeeb Sahoo <Sahoo_at_Sun.COM>
Date: Sat, 30 Oct 2010 10:23:31 +0530

Can anyone who knows the history of WebappClassLoader explain why
WebappClassLoader overrides getResourceAsStream() in the first place
instead of inheritting the implementation that exists in ClassLoader,
which looks like this:

     // ClassLoader.java
     public InputStream getResourceAsStream(String name) {
     URL url = getResource(name);
     try {
         return url != null ? url.openStream() : null;
     } catch (IOException e) {
         return null;
     }
     }

Not only does WebappClassLoader reimplement getResourceAsStream(), it in
fact duplicates the entire resource lookup logic instead of delegating
to getResource() implementation.

Sahoo