code: protected void set(String protocol, String host, int port,
                         String authority, String userInfo, String path,
                         String query, String ref) {
          synchronized (this) {
              this.protocol = protocol;
              this.host = host;
              this.port = port;
              this.file = (query == null || query.isEmpty()) ? path : path + "?" + query;
              this.userInfo = userInfo;
              this.path = path;
              this.ref = ref;
              /* This is very important. We must recompute this after the
               * URL has been changed. */
              hashCode = -1;
              hostAddress = null;
              this.query = query;
              this.authority = authority;
          }
      }
docs: Sets the specified 8 fields of the URL. This is not a public method so
  that only URLStreamHandlers can modify URL fields. URLs are otherwise
  constant.
  
  @param protocol the name of the protocol to use
  @param host the name of the host
  @param port the port number on the host
  @param authority the authority part for the url
  @param userInfo the username and password
  @param path the file on the host
  @param ref the internal reference in the URL
  @param query the query part of this URL
  @since 1.3