I have been plagued by this problem and managed to narrow it down to a small file that fails throwing the java.lang.VerifyError when invoked from Ant with fork set to false in the <java> task but succeeds when fork is set to true.
The self-contained file is:
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);
}
}
When invoked with Ant and fork set to false it throws:
[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)
When invoked with fork set to true it succeeds. The specific exception VerifyError especially when combined with "Bad type on operand stack" points to a compiler bug from what I've read but why should it succeed or fail depending on the fork attribute of the <java> Ant task is beyond me. Any thoughts? I am running Ubuntu 12.04 with the following java tools:
$ 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
important update
When invoked from Ant with fork set to false I also have to explicitly add /usr/lib/jvm/jdk1.7.0/jre/lib/rt.jar to the CLASSPATH in order to trigger the VerifyError exception. Otherwise it fails before reaching that point with:
javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
Of course having to add rt.jar in the CLASSPATH is mighty strange especially since it is the rt.jar of the java version I am using.
ant -diagnostics | grep java.vmsay? - Grzegorz Żur