But it has a meaning for JLS+JVMS, if you change the final static and the native code depends on its value, and you forget to rerun javah, then something will break. A final static field that is used from native, is as bound to the running Java program as any native method is. Change something without rerunning javah, and it breaks.
The native keyword is good because it tells the programmer that if you change this final static, then you have to verify the C-code as well! The real bad design decision was to export all final statics by default to the generated c header file. //Fredrik ----- jonathan.gibb...@oracle.com skrev: > The rationale for not allowing it is that it has no meaning at either > > the JLS or JVMS level. It would simply be a hint for tools, and hints > > for tools are best done by annotations. > > -- Jon > > On 05/24/2012 12:02 PM, Fredrik Öhrström wrote: > > Not by me anyway. In fact, I think that solution is the best one! > > > > //Fredrik > > > > 2012/5/23 Jonathan Gibbons<jonathan.gibb...@oracle.com>: > >> I wanted to be able to declare fields as native, but that was > deemed > >> unacceptable. > >> > >> -- Jon > >> > >> > >> On 05/23/2012 10:05 AM, Alan Bateman wrote: > >>> On 23/05/2012 17:50, Kelly O'Hair wrote: > >>>> Has anyone tried creating an unused native method declaration in > the > >>>> class to trigger the native header > >>>> generation? public native void GenerateNativeHeader(); ??? > Is that > >>>> too ugly? > >>>> > >>>> -kto > >>> As Jon put it, for the classes in the base module, "we are > delicate > >>> bootstrapping ground" so if you add something like "private static > native > >>> void dummy()" rather than the annotation to the classes in the > base module > >>> then it could be a solution for the short term. This means the > following > >>> sources in the webrev: > >>> > >>> src/share/classes/java/lang/Integer.java > >>> src/share/classes/java/lang/Long.java > >>> src/share/classes/java/net/SocketOptions.java > >>> src/windows/classes/sun/nio/ch/PollArrayWrapper.java > >>> > >>> Also it would be good to remove it from > >>> src/share/classes/sun/nio/ch/IOStatus.java too (it got the > annotation in the > >>> first round). > >>> > >>> -Alan. > >>>