title: java.lang.VerifyError: Bad type on operand stack in method com.sun.net.httpserver.spi.HttpServerProvider
body: <p>I have been plagued by this problem and managed to narrow it down to a small file that <strong>fails</strong> throwing the <code>java.lang.VerifyError</code> when invoked from Ant with <code>fork</code> set to <code>false</code> in the <code>&lt;java&gt;</code> task but <strong>succeeds</strong> when <code>fork</code> is set to <code>true</code>.</p>
  
  <p>The self-contained file is:</p>
  
  <pre><code>package foo;
  
  import javax.xml.ws.Endpoint;
  
  import javax.jws.WebService;
  
  @WebService
  class Hello  {
      public String sayHello() {
          return "hello";
      }
  }
  
  
  public class FooMain {
      public static void main(String args[]) throws Exception {
          Object implementor = new Hello();
          String address = "http://localhost:9000/SoapContext/SoapPort";
          Endpoint.publish(address, implementor);
      }
  }
  </code></pre>
  
  <p>When invoked with Ant and <code>fork</code> set to <code>false</code> it throws:</p>
  
  <pre><code> [java] java.lang.VerifyError: Bad type on operand stack
   [java] Exception Details:
   [java]   Location:
   [java]     com/sun/net/httpserver/spi/HttpServerProvider$1.run()Ljava/lang/Object; @27: invokestatic
   [java]   Reason:
   [java]     Type 'sun/net/httpserver/DefaultHttpServerProvider' (current frame, stack[0]) is not assignable to 'com/sun/net/httpserver/spi/HttpServerProvider'
   [java]   Current Frame:
   [java]     bci: @27
   [java]     flags: { }
   [java]     locals: { 'com/sun/net/httpserver/spi/HttpServerProvider$1' }
   [java]     stack: { 'sun/net/httpserver/DefaultHttpServerProvider' }
   [java]   Bytecode:
   [java]     0000000: b800 2599 0007 b800 27b0 b800 2699 0007
   [java]     0000010: b800 27b0 bb00 1a59 b700 2ab8 0028 57b8
   [java]     0000020: 0027 b0                                
   [java]   Stackmap Table:
   [java]     same_frame(@10)
  </code></pre>
  
  <p>When invoked with <code>fork</code> set to <code>true</code> it succeeds. The specific exception <code>VerifyError</code> especially when combined with "<code>Bad type on operand stack</code>" points to a compiler bug from what I've read but why should it succeed or fail depending on the <code>fork</code> attribute of the <code>&lt;java&gt;</code> Ant task is beyond me. Any thoughts? I am running <code>Ubuntu 12.04</code> with the following java tools:</p>
  
  <pre><code>$ java -version
  java version "1.7.0_40"
  Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
  Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode)
  $ javac -version
  javac 1.7.0_40
  $ ant -version
  Apache Ant(TM) version 1.8.2 compiled on December 3 2011
  $ ant -diagnostics | grep java.vm
  java.vm.version : 24.0-b56
  java.vm.vendor : Oracle Corporation
  java.vm.name : Java HotSpot(TM) Server VM
  java.vm.specification.name : Java Virtual Machine Specification
  java.vm.specification.vendor : Oracle Corporation
  java.vm.specification.version : 1.7
  java.vm.info : mixed mode
  </code></pre>
  
  <h1>important update</h1>
  
  <p>When invoked from Ant with <code>fork</code> set to <code>false</code> I also have to explicitly add <code>/usr/lib/jvm/jdk1.7.0/jre/lib/rt.jar</code> to the CLASSPATH in order to trigger the <code>VerifyError</code> exception. Otherwise it fails before reaching that point with:</p>
  
  <pre><code>javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
  </code></pre>
  
  <p>Of course having to add <code>rt.jar</code> in the CLASSPATH is mighty strange especially since it is the <code>rt.jar</code> of the <code>java</code> version I am using.</p>