NPE in parser->getDOMImplementation() with CNI
Andrew Haley
aph@redhat.com
Tue Jun 23 10:45:00 GMT 2009
Chris Burdess wrote:
> Andrew Haley wrote:
>> Sam Ruby wrote:
>>> Generating a header file for javax::xml::xpath::XPathExpression produces
>>> a file that looks like the following:
>>>
>>> http://git.etherboot.org/scm/people/mcb30/gcc/libjava/javax/xml/xpath/XPathExpression.h
>>>
>>>
>>>
>>> Attempting to include this file produces:
>>>
>>> headers/javax/xml/xpath/XPathExpression.h:16: error: expected identifier
>>> before ‘namespace’
>>> headers/javax/xml/xpath/XPathExpression.h:42: error: expected identifier
>>> before ‘namespace’
>>> headers/javax/xml/xpath/XPathExpression.h:42: error: expected ‘,’ or
>>> ‘...’ before ‘namespace’
>>>
>>> Presumably somebody has encountered this before, and there is an obvious
>>> solution...
>>
>> 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.
>
>> I think you'll have to edit the header file by hand.
>
> 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, that's right.
gjavah does have code to handle this, but it isn't being called.
Here, in CniPrintStream.java is where the package names are emitted:
// Open new parts.
for (int j = commonIndex; j < pkgParts.length; ++j)
{
indent(out, j + 1);
out.print("namespace ");
out.println(pkgParts[j]);
This line should be
out.println(Keywords.getCxxName(pkgParts[j]));
but there are many places where identifiers are emitted but getCxxName is
not called. This is very odd: for correctness, getCxxName must be called
whenever an identifier is emitted.
Andrew.
More information about the Java
mailing list