title: How is an object which does not subclass BindingProvider be casted explicitly into a BindingProvider object?
body: <p>I have a web service where I'm manipulating the SOAP headers using the service interface object in the client API. </p>
  
  <p>I needed to type cast the port object into a <code>BindingProvider</code> object. But my port object does not directly subclass that class. So how is it possible that the JVM doesn't complain?</p>
  
  <p>And it works too. No runtime error of ClassCastException</p>
  
  <p>Code snippet:</p>
  
  <pre><code>    public SearchDocument getSearchDocumentService(String wsdlUri, AuthBean auth){
      SearchDocument_Service serv = null;
      serv = SearchDocument_Service.getServiceInstance(wsdlUri);
      SearchDocument searchDoc = serv.getSearchDocument();
  
      populateAuthAndHandlerInfo((BindingProvider)searchDoc, auth);//how is it that jvm doesn't complain here
      return searchDoc;
      }
  
      private void populateAuthAndHandlerInfo(BindingProvider port, AuthBean auth) {
      Binding binding = port.getBinding();
                List&lt;Handler&gt; handlerList = binding.getHandlerChain();
                handlerList.add(new EDMSSoapAuthHandler());
                binding.setHandlerChain(handlerList);
          Map&lt;String, Object&gt; context = port.getRequestContext();
          context.put("clientAuthInfo", auth);
          }
  </code></pre>
  
  <p>SearchDocument.java:</p>
  
  <pre><code>    @WebService(name = "SearchDocument", targetNamespace = "http://services.abc.com/Technology/SearchDocument/service/v1")
  @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
  @XmlSeeAlso({
      ObjectFactory.class
  })
  public interface SearchDocument {
  
  
      /**
       * 
       * @param body
       * @return
       *     returns com.abc.technology.search.document.client.v1.SearchOnMetadataResponse
       * @throws AbcServiceException
       * @throws AbcInvalidMessageException
       * @throws AbcProducerApplicationException
       */
      @WebMethod(action = "http://services.abc.com/Technology/SearchDocument/service/v1/soap11/SearchDocument/searchOnMetadata")
      @WebResult(name = "SearchOnMetadataResponse", targetNamespace = "http://services.abc.com/Technology/SearchDocument/contract/v1", partName = "body")
      public SearchOnMetadataResponse searchOnMetadata(
          @WebParam(name = "SearchOnMetadata", targetNamespace = "http://services.abc.com/Technology/SearchDocument/contract/v1", partName = "body")
          SearchOnMetadataRequest body)
          throws AbcInvalidMessageException, AbcProducerApplicationException, AbcServiceException
      ;
  
  }
  </code></pre>