From: David P G. <gr...@us...> - 2005-08-19 07:17:00
|
jik...@li... wrote on 08/16/2005 06:57:02 PM: > What version of the JVM and JLS specs does JikesRVM aspire to? I think it's fair to say we aspire to 1.4, but some features of 1.4 aren't there yet. Of course legally speaking Jikes RVM isn't a JVM at all, so in some sense this isn't an entirely well-formed question. ;-) I'd encourage you to open a bug report against Jikes RVM with your example program (and a patch with a proposed fix would be fantastic if you happen to have the time to dig in and look). My guess is that this would be relatively simple to fix. > I've got a demo which, if compiled with jikes or with 'javac -target > 1.4' will cause JikesRVM to abort with an exception, but compiled with > 'javac -target 1.2' will work. I'm wondering if this is a bug, or if > JikesRVM isn't trying to play at the 1.4 level. > > The demo is this, put in a file called TestImpl.java: > ------------------------------------------------------------ > interface DummyIF {static final Integer BASE_FIELD = new Integer(6);} > public class TestImpl implements DummyIF { > public static final int TEST_FIELD = BASE_FIELD.intValue(); > public static void main(String argv[]) { > System.out.println("Value: " + TEST_FIELD); > } > } > ------------------------------------------------------------ > > The execution surprise exhibits like this: > ------ > > javac -target 1.2 TestImpl.java > > rvm TestImpl > Value: 6 > > javac -target 1.4 TestImpl.java > > rvm TestImpl > Exception in thread "main": java.lang.ExceptionInInitializerError: While > initializing TestImpl > at com.ibm.JikesRVM.classloader.VM_Class.initialize(VM_Class.java:1414) > Caused by: java.lang.NullPointerException > at TestImpl.<clinit>(TestImpl.java:5) > at com.ibm.JikesRVM.classloader.VM_Class.initialize(VM_Class.java:1410) > JikesRVM: exit 113 > ------ > > The source of the difference seems to be that at 1.2, the constant > pool entry for BASE_FIELD in TestImpl.class refers to it as > DummyIF.BASE_FIELD, whereas with 1.4 (or with jikes, which defaults to > 1.4 semantics) the entry in TestImpl.class refers to it as > TestImpl.BASE_FIELD. In the latter case, in JikesRVM > 'fieldRef.needsDynamicLink(method)' returns false, which causes > DummyIF never to get initialized. > > At first I thought this was a bug in the jikes compiler, and I made a > suitable fool of myself over on their bug tracker and mailing list > getting straightened out. I figure before I submit a bug against > JikesRVM, I should ask if this is a real bug, or just an artifact of > JikesRVM targetting an earlier version of the specs. > > Thanks, > Jeremy |