-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
JDK-8344058 : Remove doPrivileged calls from macos platform sources in the java.desktop module #22159
Conversation
👋 Welcome back honkar! A progress list of the required criteria for merging this PR into |
@honkar-jdk This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 66 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
@honkar-jdk The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
ResourceBundle platformResources = null; | ||
try { | ||
platformResources = ResourceBundle.getBundle("sun.awt.resources.awtosx"); | ||
} catch (MissingResourceException e) { | ||
// No resource file; defaults will be used. | ||
} | ||
|
||
loadLibrary(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-depth review required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you are doing is fine.
Unrelated, that System.err.flush() seems odd. I've filed a bug to look at it afterwards since it has NOTHING to do with the doPrivileged.
private static void loadLibrary() { | ||
System.loadLibrary("awt"); | ||
System.loadLibrary("fontmanager"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored System.loadLibrary() calls to a separate static method since they require @SuppressWarnings("restricted") annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, because static { .. } doesn't accept an annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, That's right.
@@ -151,7 +145,6 @@ public static final boolean isScreenMenuBar(final JMenuBar c) { | |||
public static boolean getScreenMenuBarProperty() { | |||
// Do not allow AWT to set the screen menu bar if it's embedded in another UI toolkit | |||
if (LWCToolkit.isEmbedded()) return false; | |||
return AccessController.doPrivileged(new GetBooleanAction( | |||
AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar")); | |||
return Boolean.getBoolean(AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks OK
@@ -59,8 +59,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { | |||
private static double fMaxImageSize = 128.0; | |||
|
|||
static { | |||
@SuppressWarnings("removal") | |||
String propValue = java.security.AccessController.doPrivileged(new sun.security.action.GetPropertyAction("apple.awt.dnd.defaultDragImageSize")); | |||
String propValue = System.getProperty("apple.awt.dnd.defaultDragImageSize"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok
@@ -151,7 +145,6 @@ public static final boolean isScreenMenuBar(final JMenuBar c) { | |||
public static boolean getScreenMenuBarProperty() { | |||
// Do not allow AWT to set the screen menu bar if it's embedded in another UI toolkit | |||
if (LWCToolkit.isEmbedded()) return false; | |||
return AccessController.doPrivileged(new GetBooleanAction( | |||
AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar")); | |||
return Boolean.getBoolean(AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks OK
@@ -59,8 +59,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { | |||
private static double fMaxImageSize = 128.0; | |||
|
|||
static { | |||
@SuppressWarnings("removal") | |||
String propValue = java.security.AccessController.doPrivileged(new sun.security.action.GetPropertyAction("apple.awt.dnd.defaultDragImageSize")); | |||
String propValue = System.getProperty("apple.awt.dnd.defaultDragImageSize"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok
private static void loadLibrary() { | ||
System.loadLibrary("awt"); | ||
System.loadLibrary("fontmanager"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, because static { .. } doesn't accept an annotation.
ResourceBundle platformResources = null; | ||
try { | ||
platformResources = ResourceBundle.getBundle("sun.awt.resources.awtosx"); | ||
} catch (MissingResourceException e) { | ||
// No resource file; defaults will be used. | ||
} | ||
|
||
loadLibrary(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you are doing is fine.
Unrelated, that System.err.flush() seems odd. I've filed a bug to look at it afterwards since it has NOTHING to do with the doPrivileged.
@Override | ||
public Boolean run() { | ||
return !Boolean.parseBoolean( | ||
= !Boolean.parseBoolean( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have simplified this to use Boolean.getBoolean() but this is closer to the original so that's fine.
/integrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for a couple of nits.
public class PlatformGraphicsInfo { | ||
|
||
static { | ||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { | ||
System.loadLibrary("awt"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decrease indentation?
@@ -77,16 +77,10 @@ class CAccessibility implements PropertyChangeListener { | |||
loadAWTLibrary(); | |||
} | |||
|
|||
@SuppressWarnings({"removal", "restricted"}) | |||
@SuppressWarnings("restricted") | |||
private static void loadAWTLibrary() { | |||
// Need to load the native library for this code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decrease indentation?
.createSecondaryLoop(); | ||
} | ||
}); | ||
printingLoop = Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if you preserved line wrapping, I find it easier to read chained calls in this way.
There's also an extra space after =
.
public LWCToolkit() { | ||
final String extraButtons = "sun.awt.enableExtraMouseButtons"; | ||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { | ||
areExtraMouseButtonsEnabled = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decrease indentation?
Going to push as commit 92271af.
Your commit was automatically rebased without conflicts. |
@honkar-jdk Pushed as commit 92271af. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Post JEP-486 (Permanently Disable the Security Manager) cleanup.
Calls to java.security.AccessController.doPrivileged are obsolete thus removed in this PR.
This PR addresses removal of AccessController.doPrivileged() calls from macos-platform files in the java.desktop module.Any SM related imports that are no longer needed are removed.
This PR is limited to removing doPrivileged() calls and excludes any refactoring, reformatting, or other clean up that is out-of-scope for this fix.
PS: I have explicitly add comments to the changes where a more watchful review is required.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22159/head:pull/22159
$ git checkout pull/22159
Update a local copy of the PR:
$ git checkout pull/22159
$ git pull https://git.openjdk.org/jdk.git pull/22159/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22159
View PR using the GUI difftool:
$ git pr show -t 22159
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22159.diff
Using Webrev
Link to Webrev Comment