Interesting discovery. There is another imprecision in the
specification. But worse! "javah" is imprecise too! Try this:
javah somepackage.SomeClass
then try this:
javah somepackage/SomeClass
The first command will encode methods as
"Java_somepackage_SomeClass_somemethod", but the second will encode them
as "Java_0002fsomepackage_0002fSomeClass_somemethod".
Now, usually, when using the JNI, one writes the name of classes using
"/" as package separator. (in findClass(), for example). So, you would
think that this is the name that should be used for encoding method
names. Furthermore, in the conversion table (on page 152 of the
specification, "The Java Native Interface, Programmer's guide and
Specification" ISBN 0-201-32577-2) there is no mention for a special
handling of either "/" or ".". But you won't find anything about what
range of characters shouldn't be converted using the "_0XXXX" escape
sequence, neither.
Tom Tromey wrote:
>
> Where is this? The JNI spec that I read online (the 1.2 spec:
> http://java.sun.com/products/jdk/1.2/docs/guide/jni/spec/jniTOC.doc.html)
> doesn't have a chapter 11.
"The Java Native Interface, Programmer's guide and Specification", ISBN
0-201-32577-2
> Here is what the spec says about the class name:
>
> We use the underscore ("_") character as the substitute for the
> slash ("/") in fully qualified class names.
Do you have a direct link to this text? I don't remeber seing this in
the book. Maybe I missed it?
> This occurs in favor of the other mangling that happens.
>
> Etienne> In Classpath, it seems that the name
> Etienne> "Java_java_io_File_createInternal" is used, instead.
>
> I believe this is correct.
It would make sense to treat "/" specially. What fooled me is "javah"
handling of "somepackage/SomeClass".
Etienne
--
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc. e-mail: [EMAIL PROTECTED]
Author of SableVM: http://www.sablevm.org/
----------------------------------------------------------------------