-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace usage of SecurityManager and AccessController#doPrivileged
The SecurityManager class is deprecated for removal since JDK 17. Its getClassContext method is used to optain the calling class when Native#register and Native#unregister are used without the target class being passed in. With JDK 9 the StalkWalker was introduced to make that information available. This change makes both methods available using method handles and prefers the StalkWalker codepath as that is the path expected to be invoked in most cases (on JDK 9+). The AccessController#doProvileged call is replaced by a method handle, assuming, that in an environment where WebStart is available, AccessController is also available. Closes: #1636
- Loading branch information
1 parent
9e1e377
commit 69955bd
Showing
3 changed files
with
149 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* Copyright (c) 2024 Matthias Bläsing, All Rights Reserved | ||
* | ||
* The contents of this file is dual-licensed under 2 | ||
* alternative Open Source/Free licenses: LGPL 2.1 or later and | ||
* Apache License 2.0. (starting with JNA version 4.0.0). | ||
* | ||
* You can freely decide which license you want to apply to | ||
* the project. | ||
* | ||
* You may obtain a copy of the LGPL License at: | ||
* | ||
* http://www.gnu.org/licenses/licenses.html | ||
* | ||
* A copy is also included in the downloadable source code package | ||
* containing JNA, in file "LGPL2.1". | ||
* | ||
* You may obtain a copy of the Apache License at: | ||
* | ||
* http://www.apache.org/licenses/ | ||
* | ||
* A copy is also included in the downloadable source code package | ||
* containing JNA, in file "AL2.0". | ||
*/ | ||
package com.sun.jna; | ||
|
||
/** | ||
* Helper class to make {@link SecurityManager#getClassContext()} accessible | ||
* from {@link Native}. It is used as a fallback, if {@link StackWalker} is not | ||
* availble. | ||
*/ | ||
class SecurityManagerExposer extends SecurityManager { | ||
|
||
@Override | ||
protected Class<?>[] getClassContext() { | ||
return super.getClassContext(); | ||
} | ||
|
||
} |