|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2000, 2022 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2024 IBM Corporation and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials
|
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0
|
|
49 | 49 | import org.apache.tools.ant.Task;
|
50 | 50 | import org.apache.tools.ant.TaskAdapter;
|
51 | 51 | import org.apache.tools.ant.UnknownElement;
|
52 |
| -import org.apache.tools.ant.util.JavaEnvUtils; |
53 | 52 | import org.eclipse.ant.core.AntCorePlugin;
|
54 | 53 | import org.eclipse.ant.core.AntCorePreferences;
|
55 | 54 | import org.eclipse.ant.core.AntSecurityException;
|
|
59 | 58 | import org.eclipse.ant.internal.core.AntCoreUtil;
|
60 | 59 | import org.eclipse.ant.internal.core.AntSecurityManager;
|
61 | 60 | import org.eclipse.ant.internal.core.IAntCoreConstants;
|
| 61 | +import org.eclipse.ant.internal.core.ant.InternalAntRunner; |
62 | 62 | import org.eclipse.ant.internal.ui.AntUIPlugin;
|
63 | 63 | import org.eclipse.ant.internal.ui.AntUtil;
|
64 | 64 | import org.eclipse.ant.internal.ui.editor.DecayCodeCompletionDataStructuresThread;
|
|
90 | 90 | @SuppressWarnings("removal") // SecurityManager
|
91 | 91 | public class AntModel implements IAntModel {
|
92 | 92 |
|
93 |
| - private static final boolean IS_SECURITY_MANAGER_SUPPORTED = isSecurityManagerAllowed(); |
94 |
| - |
95 |
| - private static boolean isSecurityManagerAllowed() { |
96 |
| - String sm = System.getProperty("java.security.manager"); //$NON-NLS-1$ |
97 |
| - if (sm == null) { // default is 'disallow' since 18 and was 'allow' before |
98 |
| - return !JavaEnvUtils.isAtLeastJavaVersion("18"); //$NON-NLS-1$ |
99 |
| - } |
100 |
| - // Value is either 'disallow' or 'allow' or specifies the SecurityManager class to set |
101 |
| - return !"disallow".equals(sm); //$NON-NLS-1$ |
102 |
| - } |
103 |
| - |
104 | 93 | private static ClassLoader fgClassLoader;
|
105 | 94 | private static int fgInstanceCount = 0;
|
106 | 95 | private static Object loaderLock = new Object();
|
@@ -375,7 +364,9 @@ private void parseDocument(IDocument input) {
|
375 | 364 | SecurityManager origSM = System.getSecurityManager();
|
376 | 365 | processAntHome(true);
|
377 | 366 | try {
|
378 |
| - if (IS_SECURITY_MANAGER_SUPPORTED) { |
| 367 | + @SuppressWarnings("restriction") |
| 368 | + boolean isSecurityManagerSupported = InternalAntRunner.IS_SECURITY_MANAGER_SUPPORTED; |
| 369 | + if (isSecurityManagerSupported) { |
379 | 370 | // set a security manager to disallow system exit and system property setting
|
380 | 371 | System.setSecurityManager(new AntSecurityManager(origSM, Thread.currentThread(), false));
|
381 | 372 | }
|
|
0 commit comments