jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Cornwall" <andrew.pack...@gmail.com>
Subject Having trouble with example in the manual
Date Thu, 04 Oct 2007 00:01:19 GMT
I'm trying to get the example in the manual running. The first thing I
noticed was:

      mg.addExceptionHandler(try_start, try_end, handler, "
java.io.IOException");

which under 5.2 doesn't seem to work. I replaced that with:

      mg.addExceptionHandler(try_start, try_end, handler, new ObjectType("
java.io.IOException"));


After doing this, I get a .class file - but when I try to run the class
under JDK 1.5, I see:

Exception in thread "main" java.lang.ClassFormatError: Illegal exception
table range in class file HelloWorld
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(
SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

javap lists the exception table as being from 20 to 36 target 36 - which
looks valid to me:

   20:    getstatic    #27; //Field
java/lang/System.out:Ljava/io/PrintStream;
   23:    ldc    #29; //String Please enter your name>
   25:    invokevirtual    #35; //Method
java/io/PrintStream.print:(Ljava/lang/String;)V
   28:    aload_1
   29:    invokevirtual    #39; //Method
java/io/BufferedReader.readLine:()Ljava/lang/String;
   32:    astore_2
   33:    goto    37
   36:    return

Any idea why this might not be working?

Thanks!

    Andrew Jr.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message