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

Check if object creation failed, happens for abstract classes. #26

Closed
wants to merge 1 commit into from

Conversation

cypof
Copy link
Contributor

@cypof cypof commented Jul 28, 2015

Not sure if the exception should be cleared. JavaCPP currently segfaults a bit later, I guess it would be better to raise the exception on the Java side.

saudet added a commit that referenced this pull request Jul 30, 2015
@saudet
Copy link
Member

saudet commented Jul 30, 2015

AllocObject() returns NULL when it fails, and it usually gets called just before returning to Java (but not always, might have to study this a bit further), so we might as well let it propagate the exception back to Java. I fixed a couple of missing NULL checks in the commit above, and now when calling FloatLayer.layer_by_name(), for example, we get a proper stack trace like this:

java.lang.InstantiationException: org.bytedeco.javacpp.caffe$FloatLayer
    at org.bytedeco.javacpp.caffe$FloatNet.layer_by_name(Native Method)
    at caffe$3.command(caffe.java:238)
    at caffe.main(caffe.java:392)

Is this satisfactory?

@cypof
Copy link
Contributor Author

cypof commented Jul 30, 2015

Yes that's great, a java exception is better than just a message, thanks

@cypof cypof closed this Jul 30, 2015
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.

None yet

2 participants