]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/AWTThread.java
Move platform to only work with JDK's >= 11
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / AWTThread.java
index 3b9d5b258d8a72163e1846dae2425e9c7af5ed3d..a5683be49ebac271b18f24331fc943e57bce4d54 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2020 Association for Decentralized Information Management
  * in Industry THTH ry.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - gitlab #522 - removed reflection hack
  *******************************************************************************/
 /*
  *
@@ -16,8 +17,6 @@
 package org.simantics.utils.threads;
 
 import java.awt.EventQueue;
-import java.awt.Toolkit;
-import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import java.util.concurrent.AbstractExecutorService;
@@ -36,36 +35,10 @@ public class AWTThread extends AbstractExecutorService implements IThreadWorkQue
                return INSTANCE;
        }
        
-       Field dispatchThread;
-       
-       AWTThread() {
-               dispatchThread = getDispatchThreadField();
-       }
-       
-       private Field getDispatchThreadField()
-       {
-               try {
-                       Field f = EventQueue.class.getDeclaredField("dispatchThread");
-                       f.setAccessible(true);
-                       return f;
-               } catch (SecurityException e) {
-                       throw new RuntimeException(e);
-               } catch (NoSuchFieldException e) {
-                       throw new RuntimeException(e);
-               }
-       }
-       
        @Override
        public Thread asyncExec(Runnable runnable) {
-               EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
                EventQueue.invokeLater(runnable);
-               try {
-                       return (Thread) dispatchThread.get(eq);
-               } catch (IllegalArgumentException e1) {
-                       throw new RuntimeException(e1);
-               } catch (IllegalAccessException e1) {
-                       throw new RuntimeException(e1);
-               }
+               return null;
        }
 
        @Override
@@ -93,14 +66,7 @@ public class AWTThread extends AbstractExecutorService implements IThreadWorkQue
 
        @Override
        public Thread getThread() {
-               EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
-               try {
-                       return (Thread) dispatchThread.get(eq);
-               } catch (IllegalArgumentException e1) {
-                       throw new RuntimeException(e1);
-               } catch (IllegalAccessException e1) {
-                       throw new RuntimeException(e1);
-               }
+               return null;
        }
        
        public String toString() {
@@ -135,6 +101,6 @@ public class AWTThread extends AbstractExecutorService implements IThreadWorkQue
        public boolean awaitTermination(long timeout, TimeUnit unit)
                        throws InterruptedException {
                return false;
-       }       
+       }
 
 }