Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

It is possible to register any Class as an OpMode #97

Closed
calebsander opened this issue Dec 3, 2015 · 7 comments
Closed

It is possible to register any Class as an OpMode #97

calebsander opened this issue Dec 3, 2015 · 7 comments

Comments

@calebsander
Copy link

Due to the use of reflection to store OpModes, trying to run a non-OpMode class as an OpMode throws some cryptic errors at runtime. It seems like this could be pretty easily solved by changing the method signature of OpModeManager.register() from public void register(String name, Class opMode) to public void register(String name, Class<? extends OpMode> opMode).

@strugee
Copy link

strugee commented Dec 7, 2015

@calebsander if you have the code to solve this (anything, really), you should consider sending a Pull Request!

@calebsander
Copy link
Author

The issue is that the code is contained in one of the precompiled libraries, so it isn't really possible for the general public to submit pull requests until they decide to open-source the code.

@calebsander
Copy link
Author

Still an issue in 16.01.04

@calebsander
Copy link
Author

Still an issue in yesterday's release

@calebsander
Copy link
Author

I would recommend removing the class-based register method in favor of the instance-based method because it makes explicit when the constructor is called.

@magneticflux-
Copy link

Perhaps something similar to how the Runnable or Function<E, F> interfaces are used. On the other hand, that would complicate providing instances of them. A no-args constructor useable via reflection might be the best option, barring some sort of Java 8-esque Supplier<? extends OpMode> system.

@calebsander
Copy link
Author

Fixed in 2.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants