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.rt` and `initialized` field should be final (and private / removed?) #26

Closed Marcono1234 closed 3 years ago

Marcono1234 commented 3 years ago

The RuntimeUtils class has the public fields rt and loaded: https://github.com/shannah/Java-Objective-C-Bridge/blob/473221aeef8f12ca9a659d899f3ca7092aed27ef/src/main/java/ca/weblite/objc/RuntimeUtils.java#L51 https://github.com/shannah/Java-Objective-C-Bridge/blob/473221aeef8f12ca9a659d899f3ca7092aed27ef/src/main/java/ca/weblite/objc/RuntimeUtils.java#L58

These field should likely be final to prevent users from reassigning them. And maybe rt should also be private (or be completely removed) because having two fields providing the same instance might be irritating.

Also note that RuntimeUtils should have an explicit private constructor because it currently has a public default constructor.

Marcono1234 commented 3 years ago

Thanks, though if the loaded field is not exposed anymore, would it make sense to remove it? And additionally not swallow any exceptions in the static initializer, as pointed out in #28?