public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/9577: Linker error for legal Java/CNI code if method parameters are reversed
@ 2003-02-05  4:36 rmathew
  0 siblings, 0 replies; only message in thread
From: rmathew @ 2003-02-05  4:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9577
>Category:       java
>Synopsis:       Linker error for legal Java/CNI code if method parameters are reversed
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 05 04:36:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     rmathew@hotmail.com
>Release:        3.3
>Organization:
>Environment:
MinGW (Win98SE).
Independently confirmed on RedHat Linux 8.0 as well.
>Description:
I have a Java file "Foo.java" like so:
-------------------------- 8< -----------------------------
import java.io.File;

public class Foo {
  public native void bar( String[] s, File f);
//public native void bar( File f, String[] s);
  public static void main( String[] args) { /* Dummy */ }
}
-------------------------- 8< -----------------------------

and a C++ implementation file "snafu.cc" like so:
-------------------------- 8< -----------------------------
#include "Foo.h"
#include <java/io/File.h>

  void Foo::bar (jstringArray s, java::io::File* f) { /* Dummy */ }
//void Foo::bar (java::io::File* f, jstringArray s) { /* Dummy */ }
-------------------------- 8< -----------------------------

This set produces a linker "undefined reference" error
for the native method Foo::bar( ).

However, if I reverse the order of the parameters of this
method in both Foo.java and snafu.cc (as shown by the
commented lines) it works!

In the case where one gets the linker error, it seems that
there is a possible name mangling error:
-------------------------- 8< -----------------------------
/e/tmp > nm Foo.o |grep bar
         U __ZN3Foo3barEP6JArrayIPN4java4lang6StringEEPN4java2io4FileE

/e/tmp > nm snafu.o |grep bar
00000000 T __ZN3Foo3barEP6JArrayIPN4java4lang6StringEEPNS1_2io4FileE
-------------------------- 8< -----------------------------
>How-To-Repeat:
Save the two files as Foo.java and snafu.cc respectively.
Execute:

    gcj -C Foo.java
    gcjh Foo
    gcj --main=Foo Foo.java snafu.cc

(the same error is produced even if I link the object files
separately)
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-05  4:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-05  4:36 java/9577: Linker error for legal Java/CNI code if method parameters are reversed rmathew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).