namespace namespace (was: NPE in parser->getDOMImplementation() with CNI)

Sam Ruby rubys@intertwingly.net
Tue Jun 23 10:55:00 GMT 2009


Bryce McKinlay wrote:
> On Tue, Jun 23, 2009 at 10:39 AM, Chris Burdess<dog@bluezoo.org> wrote:
>>>> Some genius (?) has a namespace called "namespace" :-)
>> That would be Sun. And in Java "namespace" is not a keyword so it's a
>> perfectly legal package name.

namespace also happens to be the name of a concept in XML...
>>> I think you'll have to edit the header file by hand.

To what? Specifically, what should namespace "namespace" be mapped to? 
 Presumably these names matter to the linker, so this should match what 
is in the library. nm doesn't provide me any insight when run against 
libgcj.so.90, but greping my way through the output of strings, I can't 
figure out what namespace is mapped to... actually I see things like 
_ZN5javax3xml9namespace5QName6class$E which lead me to believe that 
namespace isn't mapped???
Indeed, if I create my own trivial app and examine the executable I see 
a namespace named namespace:
$ nm --demangle hello | grep Hello
0000000000601390 d _CD_namespace_HelloWorld
00000000006013a0 d _CT_namespace_HelloWorld
0000000000601340 d _MT_namespace_HelloWorld
0000000000400bc2 T void 
namespace::HelloWorld::main(JArray<java::lang::String*>*)
0000000000601400 D namespace::HelloWorld::class$
0000000000400d88 R namespace::HelloWorld::class$$
0000000000400ba0 T namespace::HelloWorld::HelloWorld()
00000000006012e0 D vtable for namespace::HelloWorld
00000000006013c0 d _catch_classes_namespace_HelloWorld
$ nm hello | grep Hello
0000000000601390 d _CD_namespace_HelloWorld
00000000006013a0 d _CT_namespace_HelloWorld
0000000000601340 d _MT_namespace_HelloWorld
0000000000400bc2 T 
_ZN9namespace10HelloWorld4mainEJvP6JArrayIPN4java4lang6StringEE
0000000000601400 D _ZN9namespace10HelloWorld6class$E
0000000000400d88 R _ZN9namespace10HelloWorld7class$$E
0000000000400ba0 T _ZN9namespace10HelloWorldC1Ev
00000000006012e0 D _ZTVN9namespace10HelloWorldE
00000000006013c0 d _catch_classes_namespace_HelloWorld
It is beginning to appear to me that gcj/g++ will do name mangling of 
Java packages without regard to C++ reserved words, resulting in entry 
points that can't conveniently be referenced in C++ using CNI.
>> Should this not be handled by some automatic munging/unmunging in gcjh/gcj?
>> It may prove to be a problem in other places where names are not keywords in
>> Java but might be in C/C++/whatever.
>> Yes it should. The "old" gcjh certainly did this, but perhaps some of
> the C++ keyword handling got lost a while back when gcjh was rewritten
> in Java. The code is in
> libjava/classpath/tools/gnu/classpath/tools/javah if you want to take
> a look.

Where can I find the "old" gcjh? The current code is in Java, which 
presumably does *not* have the mapping:
http://cvs.savannah.gnu.org/viewvc/classpath/tools/gnu/classpath/tools/javah/?root=classpath
> Bryce

- Sam Ruby


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /