luben / zstd-jni

JNI binding for Zstd
Other
853 stars 168 forks source link

Show better error message, when the src/dst offset is negative #312

Closed gzsombor closed 4 months ago

gzsombor commented 4 months ago

Thanks for the explanation, that's a reasonable concern. I guess, src/main/native/zstd_errors.h is also coming from upstream, so you would rather not touch that too, am I right? I can imagine, creating separate error constants in jni_fast_zstd.c and put the error message somewhere there could work, but I'm afraid that it will be a bit more complicated. Would you merge a solution like that, or any idea, how to solve this problem?

luben commented 4 months ago

Right, native/zstd_errors.h also comes from upstream. I also don't think that maintaining our own message types in jni_fast_zstd is good idea.

I think for that case, may be better approach is to check for negative offsets on the Java side, before calling the JNI code and raising an exception from there.