8241353: NPE in ToolProvider.getSystemJavaCompiler
Reviewed-by: vromero
This commit is contained in:
parent
87644a2bb7
commit
6b4b676550
@ -27,7 +27,7 @@ package javax.tools;
|
|||||||
|
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.Iterator;
|
import java.util.Objects;
|
||||||
import java.util.ServiceConfigurationError;
|
import java.util.ServiceConfigurationError;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
@ -118,8 +118,7 @@ public class ToolProvider {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ServiceLoader<T> sl = ServiceLoader.load(clazz, ClassLoader.getSystemClassLoader());
|
ServiceLoader<T> sl = ServiceLoader.load(clazz, ClassLoader.getSystemClassLoader());
|
||||||
for (Iterator<T> iter = sl.iterator(); iter.hasNext(); ) {
|
for (T tool : sl) {
|
||||||
T tool = iter.next();
|
|
||||||
if (matches(tool, moduleName))
|
if (matches(tool, moduleName))
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
@ -140,7 +139,7 @@ public class ToolProvider {
|
|||||||
PrivilegedAction<Boolean> pa = () -> {
|
PrivilegedAction<Boolean> pa = () -> {
|
||||||
Module toolModule = tool.getClass().getModule();
|
Module toolModule = tool.getClass().getModule();
|
||||||
String toolModuleName = toolModule.getName();
|
String toolModuleName = toolModule.getName();
|
||||||
return toolModuleName.equals(moduleName);
|
return Objects.equals(toolModuleName, moduleName);
|
||||||
};
|
};
|
||||||
return AccessController.doPrivileged(pa);
|
return AccessController.doPrivileged(pa);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user