|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2019 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 |
|
14 | 14 | package org.eclipse.ant.internal.core; |
15 | 15 |
|
16 | 16 | import java.io.FileDescriptor; |
17 | | -import java.lang.reflect.InvocationTargetException; |
18 | | -import java.lang.reflect.Method; |
19 | 17 | import java.net.InetAddress; |
20 | 18 | import java.net.SocketPermission; |
21 | 19 | import java.security.Permission; |
22 | 20 | import java.util.PropertyPermission; |
23 | 21 |
|
24 | | -import org.eclipse.ant.core.AntCorePlugin; |
25 | 22 | import org.eclipse.ant.core.AntSecurityException; |
26 | | -import org.eclipse.core.runtime.ILog; |
27 | | -import org.eclipse.core.runtime.IStatus; |
28 | | -import org.eclipse.core.runtime.Status; |
29 | 23 |
|
30 | 24 | /** |
31 | 25 | * A security manager that always throws an <code>AntSecurityException</code> if the calling thread attempts to cause the Java Virtual Machine to |
@@ -277,148 +271,4 @@ public ThreadGroup getThreadGroup() { |
277 | 271 | return super.getThreadGroup(); |
278 | 272 | } |
279 | 273 |
|
280 | | - // -------------------------------------------------------------------------------- |
281 | | - // Below are SecurityManager methods deprecated in Java 9 and removed in Java 10. |
282 | | - // They are accessed through reflections to support Java 8 and 11 at the same time. |
283 | | - // XXX: This also means you must not add @Override annotations even if Eclipse try to add them. |
284 | | - // -------------------------------------------------------------------------------- |
285 | | - |
286 | | - /** |
287 | | - * @deprecated super class method has been removed in JDK 10 |
288 | | - */ |
289 | | - @Deprecated |
290 | | - public void checkAwtEventQueueAccess() { |
291 | | - if (fSecurityManager != null) { |
292 | | - try { |
293 | | - final Method m = fSecurityManager.getClass().getMethod("checkAwtEventQueueAccess"); //$NON-NLS-1$ |
294 | | - m.invoke(fSecurityManager); |
295 | | - } |
296 | | - catch (NoSuchMethodException e) { |
297 | | - logDeprecatedAccess(e); |
298 | | - } |
299 | | - catch (InvocationTargetException e) { |
300 | | - if (e.getTargetException() instanceof RuntimeException) { |
301 | | - throw (RuntimeException) e.getTargetException(); |
302 | | - } |
303 | | - logException(e); |
304 | | - } |
305 | | - catch (IllegalAccessException | IllegalArgumentException e) { |
306 | | - logException(e); |
307 | | - } |
308 | | - } |
309 | | - } |
310 | | - |
311 | | - /** |
312 | | - * @deprecated super class method has been removed in JDK 10 |
313 | | - */ |
314 | | - @Deprecated |
315 | | - public void checkMemberAccess(Class<?> clazz, int which) { |
316 | | - if (fSecurityManager != null) { |
317 | | - try { |
318 | | - final Method m = fSecurityManager.getClass().getMethod("checkMemberAccess", Class.class, int.class); //$NON-NLS-1$ |
319 | | - m.invoke(fSecurityManager, clazz, which); |
320 | | - } |
321 | | - catch (NoSuchMethodException e) { |
322 | | - logDeprecatedAccess(e); |
323 | | - } |
324 | | - catch (InvocationTargetException e) { |
325 | | - if (e.getTargetException() instanceof RuntimeException) { |
326 | | - throw (RuntimeException) e.getTargetException(); |
327 | | - } |
328 | | - logException(e); |
329 | | - } |
330 | | - catch (IllegalAccessException | IllegalArgumentException e) { |
331 | | - logException(e); |
332 | | - } |
333 | | - } |
334 | | - } |
335 | | - |
336 | | - /** |
337 | | - * @deprecated super class method has been removed in JDK 10 |
338 | | - */ |
339 | | - @Deprecated |
340 | | - public void checkSystemClipboardAccess() { |
341 | | - if (fSecurityManager != null) { |
342 | | - try { |
343 | | - final Method m = fSecurityManager.getClass().getMethod("checkSystemClipboardAccess"); //$NON-NLS-1$ |
344 | | - m.invoke(fSecurityManager); |
345 | | - } |
346 | | - catch (NoSuchMethodException e) { |
347 | | - logDeprecatedAccess(e); |
348 | | - } |
349 | | - catch (InvocationTargetException e) { |
350 | | - if (e.getTargetException() instanceof RuntimeException) { |
351 | | - throw (RuntimeException) e.getTargetException(); |
352 | | - } |
353 | | - logException(e); |
354 | | - } |
355 | | - catch (IllegalAccessException | IllegalArgumentException e) { |
356 | | - logException(e); |
357 | | - } |
358 | | - } |
359 | | - } |
360 | | - |
361 | | - /** |
362 | | - * @deprecated super class method has been removed in JDK 10 |
363 | | - */ |
364 | | - @Deprecated |
365 | | - public boolean checkTopLevelWindow(Object window) { |
366 | | - try { |
367 | | - if (fSecurityManager != null) { |
368 | | - final Method m = fSecurityManager.getClass().getMethod("checkTopLevelWindow", Object.class); //$NON-NLS-1$ |
369 | | - return (boolean) m.invoke(fSecurityManager, window); |
370 | | - } |
371 | | - final Method m = SecurityManager.class.getMethod("checkTopLevelWindow", Object.class); //$NON-NLS-1$ |
372 | | - return (boolean) m.invoke(new SecurityManager(), window); |
373 | | - } |
374 | | - catch (NoSuchMethodException e) { |
375 | | - logDeprecatedAccess(e); |
376 | | - } |
377 | | - catch (InvocationTargetException e) { |
378 | | - if (e.getTargetException() instanceof RuntimeException) { |
379 | | - throw (RuntimeException) e.getTargetException(); |
380 | | - } |
381 | | - logException(e); |
382 | | - } |
383 | | - catch (IllegalAccessException | IllegalArgumentException e) { |
384 | | - logException(e); |
385 | | - } |
386 | | - return false; |
387 | | - } |
388 | | - |
389 | | - /** |
390 | | - * @deprecated super class method has been removed in JDK 10 |
391 | | - */ |
392 | | - @Deprecated |
393 | | - public boolean getInCheck() { |
394 | | - try { |
395 | | - if (fSecurityManager != null) { |
396 | | - final Method m = fSecurityManager.getClass().getMethod("getInCheck"); //$NON-NLS-1$ |
397 | | - return (boolean) m.invoke(fSecurityManager); |
398 | | - } |
399 | | - final Method m = SecurityManager.class.getMethod("getInCheck"); //$NON-NLS-1$ |
400 | | - return (boolean) m.invoke(new SecurityManager()); |
401 | | - } |
402 | | - catch (NoSuchMethodException e) { |
403 | | - logDeprecatedAccess(e); |
404 | | - } |
405 | | - catch (InvocationTargetException e) { |
406 | | - if (e.getTargetException() instanceof RuntimeException) { |
407 | | - throw (RuntimeException) e.getTargetException(); |
408 | | - } |
409 | | - logException(e); |
410 | | - } |
411 | | - catch (IllegalAccessException | IllegalArgumentException e) { |
412 | | - logException(e); |
413 | | - } |
414 | | - return false; |
415 | | - } |
416 | | - |
417 | | - private static void logDeprecatedAccess(Throwable e) { |
418 | | - ILog.of(AntCorePlugin.getPlugin().getBundle()).log(new Status(IStatus.WARNING, AntCorePlugin.PI_ANTCORE, InternalCoreAntMessages.AntSecurityManager_0, e)); |
419 | | - } |
420 | | - |
421 | | - private static void logException(Throwable e) { |
422 | | - ILog.of(AntCorePlugin.getPlugin().getBundle()).log(new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, e.getLocalizedMessage(), e)); |
423 | | - } |
424 | 274 | } |
0 commit comments