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

Use reflection to get native file descriptors lazily on first access #109

Merged
merged 1 commit into from Oct 10, 2017

Conversation

Projects
None yet
2 participants
@eregon
Contributor

eregon commented Oct 4, 2017

  • As it creates warnings on Java 9.
  • Fixes #108.
Use reflection to get native file descriptors lazily on first access
* As it creates warnings on Java 9.
* Fixes #108.
@headius

This comment has been minimized.

Member

headius commented Oct 10, 2017

I may be missing the key change here, but why does this work? After a couple readthroughs all I can see is that you moved the static fields + init into a static inner class. That avoids the warnings how?

@eregon

This comment has been minimized.

Contributor

eregon commented Oct 10, 2017

@headius It avoids the warnings in the case these fields are not accessed at runtime. This reflection is only needed for a couple cases listed in #108 (tests and functions taking a FileDescriptor) and we actually don't use them at all in TruffleRuby.
For JRuby, this will also fix the warnings if e.g. fstat(FileDescriptor) is not used. I don't know of any workaround possible if that usage is needed.
So at least it delays the warnings until the first usage that actually needs it, instead of warning when loading jnr-posix.

@headius

This comment has been minimized.

Member

headius commented Oct 10, 2017

@eregon Ahh I see, by moving them into a static inner class the lazy booting of classes prevents the initialization until we actually call those reflecting utility methods.

Ok, merging.

@headius headius merged commit 768c773 into jnr:master Oct 10, 2017

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@headius headius modified the milestones: 3.0.40, 3.0.42 Oct 10, 2017

@eregon eregon deleted the eregon:lazy_fd_reflective_access branch Oct 10, 2017

@eregon

This comment has been minimized.

Contributor

eregon commented Oct 10, 2017

Yes, I should have added a comment to clarify in the code.
I can do that in another PR if you'd like.

@dwnusbaum dwnusbaum referenced this pull request Jun 18, 2018

Merged

[JENKINS-46725] Update jnr-posix to 3.0.45 #3502

3 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment