InvokeDynamic throws NoClassDefFoundError

Kirill Shirokov Kirill.Shirokov at Sun.COM
Thu Feb 18 01:44:11 PST 2010


John,

I don't know if it is a known issue, but I noticed that InvokeDynamic
throws NoClassDefFoundError in the following test:

    package test;

    import java.dyn.InvokeDynamic;
    import java.dyn.InvokeDynamicBootstrapError;

    public class Self {
      public static void main(String[] args) {
            try {
                InvokeDynamic.<void>greet(new Self());
            } catch ( InvokeDynamicBootstrapError e ) {
                System.out.println("TEST PASSED");
            } catch ( Throwable t ) {
                System.err.println("Oops!");
                t.printStackTrace();
            }
        }   
    }


...when it is launched with -classpath:

$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic
-classpath bin test.Self
Oops!
java.lang.NoClassDefFoundError: test/Self
        at test.Self.main(Self.java:10)

If we replace -classpath with -Xbootclasspath:

$ java -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic
-Xbootclasspath/a:bin test.Self
TEST PASSED

The JDK was 7 b82.

Best regards,
Kirill


More information about the mlvm-dev mailing list