This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCJ adding extra underscore to enum value symbol name?


I'm running into a problem compiling a Java enum using GCJ 4.3.0 20070323, with the 
ecj front end. It appears as though GCJ is inserting an extra underscore character 
into the symbol name of certain Java enum values when compiling to an object file.

Take this example Java enum:
////////////////////////////
public enum TestEnum
{
  TEST,
  PREREQUISITE,
  TEST_PREREQUISITE,
  TEST_TEST_PREREQUISITE,
  TEST_TEST_TEST_TEST
}
////////////////////////////

And this C++ code that uses the enum value TestEnum.TEST_TEST_PREREQUISITE:
////////////////////////////
#include "TestEnum.h"

TestEnum* e = TestEnum::TEST_TEST_PREREQUISITE;
////////////////////////////

After compiling the Java enum to an object file, these are the symbol names that nm 
emits:
_ZN8TestEnum4TESTE
_ZN8TestEnum12PREREQUISITEE
_ZN8TestEnum17TEST_PREREQUISITEE
_ZN8TestEnum23TEST_TEST_PREREQU_ISITEE
_ZN8TestEnum19TEST_TEST_TEST_TESTE

Notice that the second last symbol name has an extra underscore between the U and the 
I, and that this underscore does not exist in the Java enum value's name. This 
appears to be causing problems when linking via CNI to C++ code that does not expect 
that underscore to be present. According to nm run on the object file for the above 
C++ code, the _ZN8TestEnum22TEST_TEST_PREREQUISITEE symbol is expected.

Can anyone shed some light onto why this is happening? Is it a bug in GCJ?

By the way, here's how I configured GCC:
Using built-in specs.
Target: i386-unknown-freebsd6.1
Configured 
with: ../configure --prefix=/home/fred/gcc --disable-nls --enable-java-awt=xlib,gtk --enable-gtk-cairo --disable-rpath --disable-checking --enable-languages=java --disable-debug --disable-static --enable-shared --with-gc=zone --enable-libgcj --with-ecj-jar=/home/fred/ecj.jar
Thread model: posix
gcc version 4.3.0 20070323 (experimental)

     Many thanks,
       Fred

  
       
------------------------------------------------------------------------------------
X-Mail.net Communications Center




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]