Observations: URLClassPath and HTTP request

Alan Bateman alan.bateman at oracle.com
Sun Feb 22 14:43:16 UTC 2026



On 22/02/2026 14:29, Eirik Bjørsnøs wrote:
> :
>
> 1) getResourceAsStream calls HEAD before calling GET. I don't quite 
> understand why this is necessary, it seems it would be better to do 
> the GET unconditionally to save a request.
>
I don't know if URLClassLoader is used much these days for remote class 
loading but it may be that getResourceAsStream is using getResource to 
get a URL to the resource, then it opens a connection. Locating the 
resource on a HTTP server should only require a HEAD. To access the 
resources would need GET of course.

-Alan


More information about the net-dev mailing list