Skip to content

Use direct mapping call in Kernel32Library#9923

Merged
tlrx merged 1 commit intoelastic:masterfrom
tlrx:fix/9802
Mar 2, 2015
Merged

Use direct mapping call in Kernel32Library#9923
tlrx merged 1 commit intoelastic:masterfrom
tlrx:fix/9802

Conversation

@tlrx
Copy link
Copy Markdown
Member

@tlrx tlrx commented Feb 27, 2015

This commit modifies the Kernel32Library to use direct mapping instead of a proxy class when doing native calls on Windows platforms. It also adds the "createSecurityManager" permission to the tests.policy file, and adds unit tests that should have failed when the Java security manager is enabled.

Closes #9802

@tlrx
Copy link
Copy Markdown
Member Author

tlrx commented Feb 27, 2015

@rmuir @s1monw Can you have a look please?

@rmuir
Copy link
Copy Markdown
Contributor

rmuir commented Feb 27, 2015

This looks much simpler to me!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this boolean? There is only one constructor for this class, so if it succeeds, then we loaded. otherwise we have no object to call addConsoleCtrlHandler() on, so we can remove the check for it there, too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and i guess where we instantiate singleton, we just let Kernel32Library be null if it cant load? I dont know if its cleaner actually, it means callers woudl have to check for that. i just think its wierd to have all methods have to check isLoaded and do nothing. Currently there are only a few, but if the class increases...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I understand your point. I think we can remove the boolean and the method isLoaded(). If the native lib cannot be loaded, the singleton is still instantiated and not null, but any call to a native method (or call to Kernel32Library.addConsoleCtrlHandler which calls the native SetConsoleCtrlHandler) will throw an UnsatisfiedLinkError which is completely acceptable to me since, well, we are doing native calls :)

@rmuir
Copy link
Copy Markdown
Contributor

rmuir commented Feb 27, 2015

@tlrx i added a comment, but this looks good to me.

@rmuir
Copy link
Copy Markdown
Contributor

rmuir commented Feb 28, 2015

+1, looks great.

This commit modifies the Kernel32Library to use direct mapping instead of a proxy class when doing native calls on Windows platforms. It also adds the "createSecurityManager" permission to the tests.policy file, and adds unit tests that should have failed when the Java security manager is enabled.

Closes elastic#9802
@tlrx tlrx merged commit c457499 into elastic:master Mar 2, 2015
@clintongormley clintongormley changed the title [Native] Use direct mapping call in Kernel32Library Use direct mapping call in Kernel32Library Jun 8, 2015
@clintongormley clintongormley added >enhancement :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts labels Jun 8, 2015
@tlrx tlrx deleted the fix/9802 branch May 19, 2016 09:53
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement Team:Delivery Meta label for Delivery team v2.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel32LibraryTests creates JNA proxy classes

4 participants