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]

Weird GCJ/CNI Behaviour


Hi,

I was trying out something recently and came across
this problem - it flummoxes me and I would really appreciate
insights into the cause of the problem. It happens with
both 3.2 as well as 3.3 on MinGW.

Here're the two files in question:
------------------------ Foo.java ----------------------------------
1 import java.io.File;
2
3 public class Foo {
4 public static void main( String[] args) { }
5
6 public native void bar( String[] s, File f);
7 // public native void bar( File f, String[] s);
8 }
------------------------ Foo.java ----------------------------------

------------------------ snafu.cc ----------------------------------
1 #include "Foo.h"
2 #include <java/io/File.h>
3
4 void Foo::bar( jstringArray s, java::io::File* f) { }
5 // void Foo::bar( java::io::File* f, jstringArray s) { }
------------------------ snafu.cc ----------------------------------

I then do:
gcj -C Foo.java
gcjh Foo
gcj --main=Foo Foo.java snafu.cc

If defined this way, I get undefined reference errors like this:
------------------------------------------------------------------
/e/src/tmp > gcj --main=Foo Foo.java snafu.cc
D:\TEMP/cc0Aaaaa.o(.data+0x20): In function `ZN3FooC1Ev':
e:/src/tmp/Foo.java:1: undefined reference to `Foo::bar(JArray<java::lang::String*>*, java::io::File*)'
D:\TEMP/cc0Aaaaa.o(.data+0x64):e:/src/tmp/Foo.java:1: undefined reference to `Foo::bar(JArray<java::lang::String*>*, java::io::File*)'
------------------------------------------------------------------

which is weird, since I obviously have it defined and piping
the output of nm on snafu.o through c++filt confirms it.

However, the weirder thing is that I get *no error* if the
commented lines in each file above replace their uncommented
peers!

Why should the order make a difference?
Does it happen on other platforms as well?

Thanks in advance for your insights.

Ranjit.

--
Ranjit Mathew Email: rmathew AT hotmail DOT com

Bangalore, INDIA. Web: http://ranjitmathew.tripod.com/


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