Use an interface instead of method reflection to call the API#523
Use an interface instead of method reflection to call the API#523SquidDev wants to merge 1 commit intodan200:masterfrom
Conversation
This makes it easier to verify at compile time that API methods are valid.
Lignum
left a comment
There was a problem hiding this comment.
I also think it makes the API code substantially easier to read, but that may just be me.
Not just you, this is beautiful. Looks good to me.
Definitely a much better way to do it! Though if ComputerCraft is using Java 8 then it could be made a little cleaner with |
It could be made even cleaner on top of that using Guava's e.g. write a supplier to get an optional containing the API impl, memoize it with Guava, and then just use |
This is originally based on dan200/ComputerCraft#523, but being more liberal in how it breaks backwards compatibility. 1.14 and all that after all. There's several reasons for this change: - Make the API code cleaner and less error prone by removing reflection. - Try to make ComputerCraft.java less monolithic by moving functionality into separate module-specific classes. - Hopefully make the core class less Minecraft dependent, meaning emulators are a little less dependent on anything outside of /core.
This is originally based on dan200/ComputerCraft#523, but being more liberal in how it breaks backwards compatibility. 1.14 and all that after all. There's several reasons for this change: - Make the API code cleaner and less error prone by removing reflection. - Try to make ComputerCraft.java less monolithic by moving functionality into separate module-specific classes. - Hopefully make the core class less Minecraft dependent, meaning emulators are a little less dependent on anything outside of /core.
This is originally based on dan200/ComputerCraft#523, but being more liberal in how it breaks backwards compatibility. 1.14 and all that after all. There's several reasons for this change: - Make the API code cleaner and less error prone by removing reflection. - Try to make ComputerCraft.java less monolithic by moving functionality into separate module-specific classes. - Hopefully make the core class less Minecraft dependent, meaning emulators are a little less dependent on anything outside of /core.
This makes it easier to verify at compile time that API methods are valid. I also think it makes the API code substantially easier to read, but that may just be me.