Hi, On Wed, 2002-02-06 at 15:40, Mark Wielaard wrote: > > I am going to play a bit more with this to see if I can see were some of > the other errors come from to better understand what libgcj is doing and > wether I am not feeding you completely bogus data.
I changed the program a little bit to force loading all classes through the same ClassLoader when possible. Now it actually seems to work. But a lot of the VerifyErrors seem to be wrong. For example the verifier doesn't like something like the following: Method name:"compareTo" public Signature: 108=(java.lang.Object)int Attribute "Code", length:56, max_stack:2, max_locals:2, code_length:24 0: aload_1 1: instanceof #1=<Class java.math.BigInteger> 4: ifeq 16 7: aload_0 8: aload_1 9: checkcast #1=<Class java.math.BigInteger> 12: invokestatic #110=<Method java.math.BigInteger.compareTo (java.math.BigInteger,java.math.BigInteger)int> 15: ireturn 16: new #111=<Class java.lang.ClassCastException> 19: dup 20: invokespecial #113=<Method java.lang.ClassCastException.<init> ()void> 23: athrow $ ./verifyclass java/math/BigInteger.class Verifying: java/math/BigInteger.class java.lang.VerifyError: verification failed at PC 23 in java.math.BigInteger:compareTo((Ljava.lang.Object;)I): incompatible type on stack But the bytecode looks good to me. I attach the VerifyClass code so people can play with it. I also tried compiling jikes from CVS but I am unable to compile Classpath with it. Simple test programs work though. Needs some debugging. Eric, is jikes from CVS 'stable'? Cheers, Mark
import java.io.*; public class VerifyClass extends ClassLoader { public static void main(String args[]) { if (args.length == 1) { System.out.println("Verifying: " + args[0]); try { VerifyClass verifier = new VerifyClass(); Class c = verifier.load(args[0]); verifier.resolveClass(c); } catch (Throwable t) { System.err.println(t); } } else System.out.println("argument must be a class file"); } Class load(String classFile) throws IOException { InputStream is = new FileInputStream(classFile); ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] buf = new byte[2048]; int read = is.read(buf); while(read > 0) { os.write(buf, 0, read); read = is.read(buf); } byte[] data = os.toByteArray(); return defineClass(data, 0, data.length); } protected Class loadClass(String name, boolean link) throws java.lang.ClassNotFoundException { if (!"java.lang.Object".equals(name)) { try { Class c = load(name.replace('.','/') + ".class"); if (link) resolveClass(c); return c; } catch(IOException ioe) { } } return super.loadClass(name, link); } }