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

Prevent exception in constructor of GValueArray #61

Merged
merged 2 commits into from
Jun 23, 2017

Conversation

lafoletc
Copy link
Contributor

@lafoletc lafoletc commented Dec 18, 2016

Add check with null pointer
Due to method Structure.validate(), an exception was raised when JNA try to invoke constructor of GValueArray with "new Pointer(0)"

@neilcsmith-net
Copy link
Member

Thanks. But why should we protect against this? Is there a particular concern you're trying to address?

Also, JNA already has Pointer.NULL and/or Pointer.nativeValue(Pointer p)

@lafoletc
Copy link
Contributor Author

lafoletc commented Dec 27, 2016

I have tried to use interface Decodebin.AUTOPLUG_FACTORIES and JNA instanciate a default result using a Pointer(0), that raise an exception

@neilcsmith-net
Copy link
Member

That sounds like our problem not JNA. More likely the type mapper needs updating to handle null (Pointer.NULL) results?

@lafoletc
Copy link
Contributor Author

lafoletc commented Dec 27, 2016

In case of function, JNA try to create a default instance of the result to check the callback.
As GValueArray is a Structure, CallbackReference.getNativeType(cls) invoke Structure.validate(cls) which instanciates a new instance of GValueArray with Pointer(0) as argument to verify if JNA will be able to convert the C result in Java object.

@lafoletc
Copy link
Contributor Author

"type mapper" can not help us : it is use to convert object between Java and C.
Here, we are in full Java
See method Structure.validate() => Structure.newInstance(cls, PLACEHOLDER_MEMORY)

@neilcsmith-net
Copy link
Member

Ah, OK, thanks. Missed the context of where this was coming from. Confused by the fact that we're registering this class in our type mapper - that needs looking at, but it's nothing to do with this then. Couple that with the fact I'd misread from the JavaDoc that Pointer.NULL was new Pointer(0) when it's just null. Sorry, I failed all around on this one! 😞

I'll pull this in ASAP.

@neilcsmith-net neilcsmith-net merged commit 9162865 into gstreamer-java:master Jun 23, 2017
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

Successfully merging this pull request may close these issues.

2 participants