Default to non static library loading for JNI #6911
+363
−37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Static library loading causes a lot of trouble for tools, and also some indeterminism. It's generally only useful for robot projects and tests. However, even for tests its not as useful because HAL.Initialize is generally required.
This PR changes the default to not load libraries on static initialization. It can still be enabled the same way old apps used to disable it.
For robot projects, this is basically not a behavior change. Right at the beginning of startRobot, we load the required libraries (ntcore, wpinet, wpimath, hal and wpiutil). We then set all the vision libraries (april tag, opencv and cscore) to load when statically requested. Since these libraries are resource intensive, we don't want to load them by default.
This broke most of our test projects. A test extension was added to force initialize the right things.
This also broke the example unit tests. All of these tests already have a call to Hal.initialize. That Hal.initialize call is magic, because it includes 2 magic numbers that we never change. To solve this, a new method has been added; RobotBase.loadLibrariesAndInitializeHal(). This returns a boolean like Hal.Initialize used to do, but also sets up the libraries exactly like a robot project does (in fact this is the method now called in robotbase). Users would change their manual calls to Hal.Initialize to this new method, and things would just work.