Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in Native.getCallingClass() when attempting Direct Mapping on Android #218

Closed
mlanting opened this issue Apr 15, 2013 · 2 comments

Comments

@mlanting
Copy link

Native.register() fails on android with a null pointer exception in Native.getCallingClass(). It looks like the SecurityManager class on android only exists so people can try to call it and get null values (used to be functional, but functionality was removed at some point), so the call to SecurityManager.getClassContext() in getCallingClass() does just that.

I was a little surprised that I didn't see anything about this around here - did I miss something or am I more likely just doing something wrong, or has this not really come up before?

@twall
Copy link
Contributor

twall commented Apr 15, 2013

Maybe no one's been using direct mapping? It'd be easy enough to provide a register variant that explicitly provides the class.

I ran some tests on a simulator, maybe that has a different security manager implementation?

On Apr 15, 2013, at 12:09 PM, Matt Lanting wrote:

Native.register() fails on android with a null pointer exception in Native.getCallingClass(). It looks like the SecurityManager class on android only exists so people can try to call it and get null values (used to be functional, but functionality was removed at some point), so the call to SecurityManager.getClassContext() in getCallingClass() does just that.

I was a little surprised that I didn't see anything about this around here - did I miss something or am I just doing something wrong, or has this not really come up before?


Reply to this email directly or view it on GitHub.

@mlanting
Copy link
Author

Maybe - I'm on an actual device and using ndk r8 and the latest (or close to latest) sdk. My SecurityManager assumptions are based on this: http://stackoverflow.com/questions/9403473/attempting-to-get-class-name-on-android-using-getclasscontext1-getname

@twall twall closed this as completed in 85e962c Apr 18, 2013
ochafik pushed a commit to nativelibs4java/JNAerator that referenced this issue Mar 9, 2015
Avoid error “The SecurityManager implementation on this platform is broken; you must explicitly provide the class to register” due to stub SecurityManager on Android as described in java-native-access/jna#218 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants