This is the mail archive of the java-patches@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]

[libava/win32]: Don't add dll[im/ex]port attributes to libgcj, unless dll build


The marking of JNI_* functions as dll[im/ex]port causes problems
when libgcj.a is built as static lib.

It seems that the JNIIMPORT and JNIEXPORT are used in two different ways
in jni.h
1) To declare dll linkage of functions when building or using
libgcj itself as dll.
2) To declare dll linkage of functions defined in user code (eg,
JNI_On[Un]Load). As I understand, JNIIMPORT and JNIEXPORT are 'standard'
macros that are defined in other implementations and user code expects them
to be defined in jni.h

These different meanings should be separated.

The following patch is ugly, but fixes the problem with static
libgcj.a  on windows, while allowing the declaration of dllimport/export
attributes if building libgcj.as dll.

I have also removed the attributes from the definitions of the JNI_* exports
in jni.cc, since putting the attribute on the declaration is sufficient.

This compiles and builds a working static lib, but I haven't tested with
dll's.


Danny


ChangeLog

	2003-08-06  Danny Smith  <dannysmith@users.sourceforge.net>

	* jni.cc (JNI_CreateJavaVM): Remove JNIEXPORT.
	(JNI_GetCreatedJavaVMs): Likewise.
	(JNI_GetDefaultJavaVMInitArgs): Likewise.
	* include/jni.h (JNIIMPEXP): Remove definition
	and replace with...
	(__GCJ_JNIIMPEXP): New macro, applicable only to libgcj
	symbols,
	(__GCJ_DLL): New macro, controlling __GCJ_JNIIMPEXP.
	 

Index: jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.73
diff -c -3 -p -r1.73 jni.cc
*** jni.cc	21 Jul 2003 01:54:05 -0000	1.73
--- jni.cc	6 Aug 2003 02:28:58 -0000
*************** static jint
*** 2389,2395 ****
    return 0;
  }
  
! JNIEXPORT jint JNICALL
  JNI_GetDefaultJavaVMInitArgs (void *args)
  {
    jint version = * (jint *) args;
--- 2389,2395 ----
    return 0;
  }
  
! jint JNICALL
  JNI_GetDefaultJavaVMInitArgs (void *args)
  {
    jint version = * (jint *) args;
*************** JNI_GetDefaultJavaVMInitArgs (void *args
*** 2406,2412 ****
    return 0;
  }
  
! JNIEXPORT jint JNICALL
  JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args)
  {
    JvAssert (! the_vm);
--- 2406,2412 ----
    return 0;
  }
  
! jint JNICALL
  JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args)
  {
    JvAssert (! the_vm);
*************** JNI_CreateJavaVM (JavaVM **vm, void **pe
*** 2471,2477 ****
    return 0;
  }
  
! JNIEXPORT jint JNICALL
  JNI_GetCreatedJavaVMs (JavaVM **vm_buffer, jsize buf_len, jsize *n_vms)
  {
    if (buf_len <= 0)
--- 2471,2477 ----
    return 0;
  }
  
! jint JNICALL
  JNI_GetCreatedJavaVMs (JavaVM **vm_buffer, jsize buf_len, jsize *n_vms)
  {
    if (buf_len <= 0)
Index: include/jni.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/jni.h,v
retrieving revision 1.25
diff -c -3 -p -r1.25 jni.h
*** include/jni.h	28 Dec 2002 06:38:52 -0000	1.25
--- include/jni.h	6 Aug 2003 02:29:00 -0000
*************** typedef void *jmethodID;
*** 178,198 ****
  
  #define JNIIMPORT        __declspec(dllimport)
  #define JNIEXPORT        __declspec(dllexport)
  #define JNICALL          __stdcall
  
! #else
  
  #define JNIIMPORT
  #define JNIEXPORT
  #define JNICALL
  
  #endif /* !( _WIN32 || __WIN32__ || WIN32) */
  
- #ifdef __GCJ_JNI_IMPL__
- #define JNIIMPEXP JNIEXPORT
- #else
- #define JNIIMPEXP JNIIMPORT
- #endif /* ! __GCJ_JNI_IMPL__ */
  
  #ifdef __cplusplus
  extern "C"
--- 178,206 ----
  
  #define JNIIMPORT        __declspec(dllimport)
  #define JNIEXPORT        __declspec(dllexport)
+ 
  #define JNICALL          __stdcall
  
! /* These defines apply to symbols in libgcj */
! #ifdef __GCJ_DLL
! # ifdef __GCJ_JNI_IMPL__
! #  define __GCJ_JNIIMPEXP JNIEXPORT
! # else
! #  define __GCJ_JNIIMPEXP JNIIMPORT
! # endif /* ! __GCJ_JNI_IMPL__ */
! #else /* ! __GCJ_DLL */
! # define __GCJ_JNIIMPEXP
! #endif /*  __GCJ_DLL */
! 
! #else /* !( _WIN32 || __WIN32__ || WIN32) */
  
  #define JNIIMPORT
  #define JNIEXPORT
  #define JNICALL
+ #define __GCJ_JNIIMPEXP
  
  #endif /* !( _WIN32 || __WIN32__ || WIN32) */
  
  
  #ifdef __cplusplus
  extern "C"
*************** extern JNIEXPORT void JNICALL JNI_OnUnlo
*** 206,214 ****
  
  /* These functions are called by user code to start using the
     invocation API.  */
! extern JNIIMPEXP jint JNICALL JNI_GetDefaultJavaVMInitArgs (void *);
! extern JNIIMPEXP jint JNICALL JNI_CreateJavaVM (JavaVM **, void **, void *);
! extern JNIIMPEXP jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *);
  
  #ifdef __cplusplus
  }
--- 214,222 ----
  
  /* These functions are called by user code to start using the
     invocation API.  */
! extern __GCJ_JNIIMPEXP jint JNICALL JNI_GetDefaultJavaVMInitArgs (void *);
! extern __GCJ_JNIIMPEXP jint JNICALL JNI_CreateJavaVM (JavaVM **, void **, void *);
! extern __GCJ_JNIIMPEXP jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *);
  
  #ifdef __cplusplus
  }

http://personals.yahoo.com.au - Yahoo! Personals
-  New people, new possibilities! Try Yahoo! Personals, FREE for a limited period!


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