GCJ/C++ name mangling incompatibility

Bryce McKinlay bryce@albatross.co.nz
Sun Mar 11 16:17:00 GMT 2001


In the following test case, where we want to pass an inner class
reference to a native function, GCJ and C++ will produce conflicting
name manglings. They seem to have different interpretations of the "$"
character!

$ nm ./Test.o | grep foo
00000000 r _Utf1foo
         U _ZN4Test3fooEPN13Test__U24_BarE

$ nm ./natTest.o | grep foo
00000000 T _ZN4Test3fooEP8Test$Bar


// Test.java
public class Test
{
  class Bar {}
  native void foo(Bar b);

  void a()
  {
    foo(new Bar());
  }
}

// natTest.cc
#include <Test.h>
#include <Test$Bar.h>
#include <gcj/cni.h>

void
Test::foo (Test$Bar *)
{
}

regards

  [ bryce ]




More information about the Java mailing list