Several methods in URLConnection throws IllegalAccessError to indicate
that the method is being performed after the connection has already been established. IllegalAccessError is a runtime linkage error thrown to indicate that the program has attempted to access a member for which it does not have access. Clearly, IllegalAccessError has nothing to do with URLs.
A more appropriate exception to throw is IllegalStateException (a runtime exception introduced in 1.1).
that the method is being performed after the connection has already been established. IllegalAccessError is a runtime linkage error thrown to indicate that the program has attempted to access a member for which it does not have access. Clearly, IllegalAccessError has nothing to do with URLs.
A more appropriate exception to throw is IllegalStateException (a runtime exception introduced in 1.1).