shannah / Java-Objective-C-Bridge

A thin bridge that allows for two-way communication from Java to Objective-C.
123 stars 25 forks source link

RuntimeUtils.msg(...) argument validation logic might be faulty #27

Closed Marcono1234 closed 3 years ago

Marcono1234 commented 3 years ago

It appears the argument validation logic in RuntimeUtils.msg(...) might be faulty: https://github.com/shannah/Java-Objective-C-Bridge/blob/473221aeef8f12ca9a659d899f3ca7092aed27ef/src/main/java/ca/weblite/objc/RuntimeUtils.java#L587-L589

I am not really familiar with this project, but I assume it should check for numArgs >= 2 (instead of == 2)? Otherwise the calculation numArgs-2 in the error message is redundant because it would always be 0.

It might also be good to throw a more specific exception, e.g. IllegalArgumentException. (Same for the other methods throwing RuntimeException when illegal arguments are provided)