Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using JNF (Was: Calling Java from native code)



On Nov 2, 2009, at 2:25 PM, Greg Guerin wrote:

I see a 300+ KB file at JavaVM.framework/Versions/A/Frameworks/ JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation. And the 'file' command tells me it's a fat mach-O dylib, which is exactly what I would expect for a framework.

OK. I have that. I didn't realize *that* contained the code.

If you don't have that, then maybe you have a damaged install, or a version of Java that doesn't have JNF.

After some more probing, I noticed JNFAutoreleasePool.h that has the declarations:


JNF_EXPORT JNFAutoreleasePoolToken *JNFNativeMethodEnter();
JNF_EXPORT void JNFNativeMethodExit(JNFAutoreleasePoolToken *token);

where JNF_EXPORT is defined in JNFJNI.h as:

#define JNF_EXPORT extern

This is wrong when compiling using a C++ compiler. However, the context for the declaration in JNFJNI.h is:

#if !defined(JNF_EXPORT)
        #define JNF_EXPORT extern
#endif

If in my own code I do:

#ifdef __cplusplus
#   ifdef JNF_EXPORT
#       undef JNF_EXPORT
#   endif
#   define JNF_EXPORT extern "C"
#endif
#import <JavaNativeFoundation/JavaNativeFoundation.h>

then recompile and link, it links correctly. It would seem that the JNFJNI.h header is wrong in that it ignores the possibility of compiling with a C++ compiler (but at least allows a work-around).

File a bug?

- Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Using JNF (Was: Calling Java from native code) (From: Greg Guerin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.