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
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.
This is most likely due to the mismatch between java versions, I see you are running 1.7.0_40 and 1.7.0_24. Ensure JAVA_HOME is set to the 1.7.0_40 JDK prior to invoking Ant. See the following post for additional information on how to do that. How do I change the JAVA_HOME for ant?
Well, most likely, it just is a compiler bug, see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8006684
And it does not really depend on the fork property as per your description, only the classpath does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With