Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JNA optional for tests and move classes to bootstrap package #11378

Merged
merged 1 commit into from May 27, 2015

Conversation

jaymode
Copy link
Member

@jaymode jaymode commented May 27, 2015

Today, JNA is a optional dependency in the build but when running tests or running
with mlockall set to true, JNA must be on the classpath for Windows systems since
we always try to load JNA classes when using mlockall.

The old Natives class was renamed to JNANatives, and a new Natives class is
introduced without any direct imports on JNA classes. The Natives class checks to
see if JNA classes are available at startup. If the classes are available the Natives
class will delegate to the JNANatives class. If the classes are not available the
Natives class will not use the JNANatives class, which results in no additional attempts
to load JNA classes.

Additionally, all of the JNA classes were moved to the bootstrap package and made
package private as this is the only place they should be called from.

Closes #11360

@rmuir
Copy link
Contributor

rmuir commented May 27, 2015

This looks great: it makes this stuff way more contained. thanks for the cleanup.

@gmarz
Copy link
Contributor

gmarz commented May 27, 2015

Nice @jaymode ! LGTM.

I tested to make sure mlockall still works properly on Windows with these changes, and it looks good.

Can/should this be back ported into 1.x?

@jaymode jaymode added the v1.6.0 label May 27, 2015
@jaymode
Copy link
Member Author

jaymode commented May 27, 2015

@gmarz thanks for checking it out!

I think we should backport to 1.x since we can have the same issue if bootstrap.mlockall is set to true in the configuration file.

@gmarz
Copy link
Contributor

gmarz commented May 27, 2015

@jaymode Yea, I agree.

Today, JNA is a optional dependency in the build but when running tests or running
with mlockall set to true, JNA must be on the classpath for Windows systems since
we always try to load JNA classes when using mlockall.

The old Natives class was renamed to JNANatives, and a new Natives class is
introduced without any direct imports on JNA classes. The Natives class checks to
see if JNA classes are available at startup. If the classes are available the Natives
class will delegate to the JNANatives class. If the classes are not available the
Natives class will not use the JNANatives class, which results in no additional attempts
to load JNA classes.

Additionally, all of the JNA classes were moved to the bootstrap package and made
package private as this is the only place they should be called from.

Closes elastic#11360
@jaymode jaymode merged commit e54dd68 into elastic:master May 27, 2015
@kevinkluge kevinkluge removed the review label May 27, 2015
@clintongormley clintongormley changed the title make JNA optional for tests and move classes to bootstrap package Make JNA optional for tests and move classes to bootstrap package Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JNA is not optional when testing on windows
5 participants