From a599c30171fe2b1557ad967d61048656fdb8c752 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Thu, 21 Nov 2024 00:49:25 +0000 Subject: [PATCH] 8344471: Remove SecurityManager related code from java.compiler module Reviewed-by: rriggs, jlahoda, jjg --- .../classes/javax/tools/ToolProvider.java | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/java.compiler/share/classes/javax/tools/ToolProvider.java b/src/java.compiler/share/classes/javax/tools/ToolProvider.java index 8cdfd63b17d..03a56139fdd 100644 --- a/src/java.compiler/share/classes/javax/tools/ToolProvider.java +++ b/src/java.compiler/share/classes/javax/tools/ToolProvider.java @@ -25,8 +25,6 @@ package javax.tools; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Objects; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; @@ -118,29 +116,13 @@ public class ToolProvider { try { ServiceLoader sl = ServiceLoader.load(clazz, ClassLoader.getSystemClassLoader()); for (T tool : sl) { - if (matches(tool, moduleName)) + if (Objects.equals(tool.getClass().getModule().getName(), moduleName)) { return tool; + } } } catch (ServiceConfigurationError e) { throw new Error(e); } return null; } - - /** - * Determine if this is the desired tool instance. - * @param the interface of the tool - * @param tool the instance of the tool - * @param moduleName the name of the module containing the desired implementation - * @return true if and only if the tool matches the specified criteria - */ - @SuppressWarnings("removal") - private static boolean matches(T tool, String moduleName) { - PrivilegedAction pa = () -> { - Module toolModule = tool.getClass().getModule(); - String toolModuleName = toolModule.getName(); - return Objects.equals(toolModuleName, moduleName); - }; - return AccessController.doPrivileged(pa); - } }