public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/30999]  New: support for GCC4.0's fvisibility option in JNIEXPORT macro
@ 2007-02-28 22:00 jan dot nijtmans at gmail dot com
  2007-02-28 22:05 ` [Bug java/30999] " jan dot nijtmans at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jan dot nijtmans at gmail dot com @ 2007-02-28 22:00 UTC (permalink / raw)
  To: java-prs

For a patch implementing this proposal, see the end of this Description.

This proposal has been submitted to SUN as well, for inclusion
in a future JDK. Below is the full text of the proposal to SUN
and the answer.

************************************************
Dear Java Developer,

Thank you for your interest in improving the quality of Java Technology.

Your report has been assigned an internal review ID of 680323, which is NOT
visible on the Sun Developer Network (SDN).

Please be aware that the large volume of reports we receive sometimes prevents
us from responding individually to each message.

We currently have a three week average response time.  If the information is
determined to be a new Bug or RFE, or a duplicate of a known Bug or RFE, you
will receive a followup email containing a seven digit bug number.  You may
search for, view, or vote for this bug in the Bug Database at
http://bugs.sun.com/.

If you just reported an issue that could have a major impact on your project
and require a timely response, please consider purchasing one of the support
offerings described at http://java.sun.com/support/index.html.

The Sun Developer Network (http://developers.sun.com) is a free service that
Sun offers. To join, visit http://developers.sun.com/global/join_sdn.html.

For a limited time, SDN members can obtain fully licensed Java IDEs for web and
enterprise development.  More information is at
http://developers.sun.com/prodtech/javatools/free/.

Thank you for using our bug submit page.

Regards,
Java Developer Bug Report Review Team



---------------------------------------------------------------


dateCreated: Fri Apr 07 07:41:29 MDT 2006
type:        rfe
cust_name:   Jan Nijtmans
cust_email:  jan.nijtmans@gmail.com
jdcid:       nijtmans
status:      Waiting
category:    java
subcategory: native_interface
company:     LogicaCMG
release:     5.0
hardware:    x86
OSversion:   linux
priority:    4
synopsis:    support for GCC4.0's -fvisibility option in JNIEXPORT macro
description: A DESCRIPTION OF THE REQUEST :
Currently, the macro JNIEXPORT is defined in jni_md.h as empty:
#define JNIEXPORT
This means that on UNIX, marking a symbols as exportable has no effect.

However, GCC 4.x has a new option -fvisibility=hidden which allows all symbols
which are not marked specially to be hidden from a shared library. This feature
is similar to Windows, where only symbols marked with  __declspec(dllexport)
are exported from dll's.

Therefore I suggest to change this line to:

#if defined(__GNUC__) && __GNUC__ > 3
#define JNIEXPORT __attribute__ ((visibility("default")))
#else
#define JNIEXPORT
#endif

This allows code to be compiled with gcc 4.x to be compiled with
-fvisibility=hidden, while still all JNI functions are exported.


JUSTIFICATION :
This enhancements makes it possible to reduce the size of JNI libraries
significantly. This helps the start-up time a lot. For more information, see:
     http://gcc.gnu.org/wiki/Visibility
This page explains much better what is going on that I could do it here.

For gcc 3.x and earlier or any other compiler, this change has no effect.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If a JNI library is compiled with GCC 4.x using the option -fvisibility=hidden,
I expect that still all JNI functions are exported.
ACTUAL -
When using -fvisibility=hidden with GCC 4.x, all JNI functions would be hidden,
so this option is not usable with JNI libraries.

CUSTOMER SUBMITTED WORKAROUND :
A workaround is placing the following in all JNI code:

#include <jni.h>
#if !defined(_WIN32) && defined(__GNUC__) && __GNUC__ > 3
#undef JNIEXPORT
#define JNIEXPORT __attribute__ ((visibility("default")))
#endif
workaround:
comments:    (company - LogicaCMG , email - jan.nijtmans@gmail.com)



Index: libjava/include/jni_md.h
===================================================================
--- libjava/include/jni_md.h    (revision 122411)
+++ libjava/include/jni_md.h    (working copy)
@@ -124,6 +124,19 @@

 #define JNICALL          __stdcall

+#else /* !( _WIN32 || __WIN32__ || WIN32) */
+
+#define JNIIMPORT
+#if defined(__GNUC__) && __GNUC__ > 3
+#define JNIEXPORT __attribute__ ((visibility("default")))
+#else
+#define JNIEXPORT
+#endif
+
+#define JNICALL
+
+#endif /* !( _WIN32 || __WIN32__ || WIN32) */
+
 /* These defines apply to symbols in libgcj */
 #ifdef __GCJ_DLL__
 # ifdef __GCJ_JNI_IMPL__
@@ -135,14 +148,4 @@
 # define _CLASSPATH_JNIIMPEXP
 #endif /*  __GCJ_DLL__ */

-#else /* !( _WIN32 || __WIN32__ || WIN32) */
-
-#define JNIIMPORT
-#define JNIEXPORT
-#define JNICALL
-#define _CLASSPATH_JNIIMPEXP
-
-#endif /* !( _WIN32 || __WIN32__ || WIN32) */
-
-
 #endif /* __GCJ_JNI_MD_H__ */


-- 
           Summary: support for GCC4.0's fvisibility option in JNIEXPORT
                    macro
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jan dot nijtmans at gmail dot com
GCC target triplet: any target, except win32


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30999


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug java/30999] support for GCC4.0's fvisibility option in JNIEXPORT macro
  2007-02-28 22:00 [Bug java/30999] New: support for GCC4.0's fvisibility option in JNIEXPORT macro jan dot nijtmans at gmail dot com
@ 2007-02-28 22:05 ` jan dot nijtmans at gmail dot com
  2007-03-26 18:27 ` [Bug libgcj/30999] " tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jan dot nijtmans at gmail dot com @ 2007-02-28 22:05 UTC (permalink / raw)
  To: java-prs



------- Comment #1 from jan dot nijtmans at gmail dot com  2007-02-28 22:05 -------
Created an attachment (id=13126)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13126&action=view)
implementation of this request

This patch implements this request


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30999


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libgcj/30999] support for GCC4.0's fvisibility option in JNIEXPORT macro
  2007-02-28 22:00 [Bug java/30999] New: support for GCC4.0's fvisibility option in JNIEXPORT macro jan dot nijtmans at gmail dot com
  2007-02-28 22:05 ` [Bug java/30999] " jan dot nijtmans at gmail dot com
@ 2007-03-26 18:27 ` tromey at gcc dot gnu dot org
  2007-06-28 19:35 ` tromey at gcc dot gnu dot org
  2007-06-28 19:59 ` tromey at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-03-26 18:27 UTC (permalink / raw)
  To: java-prs



------- Comment #2 from tromey at gcc dot gnu dot org  2007-03-26 19:27 -------
This seems reasonable to me.
Could you write a ChangeLog entry and submit the patch to
java-patches@gcc.gnu.org?


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-26 19:27:27
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30999


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libgcj/30999] support for GCC4.0's fvisibility option in JNIEXPORT macro
  2007-02-28 22:00 [Bug java/30999] New: support for GCC4.0's fvisibility option in JNIEXPORT macro jan dot nijtmans at gmail dot com
  2007-02-28 22:05 ` [Bug java/30999] " jan dot nijtmans at gmail dot com
  2007-03-26 18:27 ` [Bug libgcj/30999] " tromey at gcc dot gnu dot org
@ 2007-06-28 19:35 ` tromey at gcc dot gnu dot org
  2007-06-28 19:59 ` tromey at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-06-28 19:35 UTC (permalink / raw)
  To: java-prs



------- Comment #3 from tromey at gcc dot gnu dot org  2007-06-28 19:35 -------
Subject: Bug 30999

Author: tromey
Date: Thu Jun 28 19:35:25 2007
New Revision: 126090

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126090
Log:
2007-06-28  Jan Nijtmans  <nijtmans@users.sourceforge.net>

        PR libgcj/30999:
        * jni_md.h: Add the possibility to compile jni code with.
        -fvisibility=hidden. This causes all symbols to be hidden
        except the JNI functions which need to be exported.

Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/include/jni_md.h


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30999


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libgcj/30999] support for GCC4.0's fvisibility option in JNIEXPORT macro
  2007-02-28 22:00 [Bug java/30999] New: support for GCC4.0's fvisibility option in JNIEXPORT macro jan dot nijtmans at gmail dot com
                   ` (2 preceding siblings ...)
  2007-06-28 19:35 ` tromey at gcc dot gnu dot org
@ 2007-06-28 19:59 ` tromey at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-06-28 19:59 UTC (permalink / raw)
  To: java-prs



------- Comment #4 from tromey at gcc dot gnu dot org  2007-06-28 19:59 -------
Fix checked in.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30999


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-06-28 19:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-28 22:00 [Bug java/30999] New: support for GCC4.0's fvisibility option in JNIEXPORT macro jan dot nijtmans at gmail dot com
2007-02-28 22:05 ` [Bug java/30999] " jan dot nijtmans at gmail dot com
2007-03-26 18:27 ` [Bug libgcj/30999] " tromey at gcc dot gnu dot org
2007-06-28 19:35 ` tromey at gcc dot gnu dot org
2007-06-28 19:59 ` tromey at gcc dot gnu dot org

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).