From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29897 invoked by alias); 5 Feb 2003 04:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 29868 invoked by uid 71); 5 Feb 2003 04:36:01 -0000 Resent-Date: 5 Feb 2003 04:36:01 -0000 Resent-Message-ID: <20030205043601.29867.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, java-prs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, rmathew@hotmail.com Received: (qmail 14323 invoked by uid 48); 5 Feb 2003 04:29:39 -0000 Message-Id: <20030205042939.14322.qmail@sources.redhat.com> Date: Wed, 05 Feb 2003 04:36:00 -0000 From: rmathew@hotmail.com Reply-To: rmathew@hotmail.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: java/9577: Linker error for legal Java/CNI code if method parameters are reversed X-SW-Source: 2003-02/txt/msg00244.txt.bz2 List-Id: >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 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: