JAL-4356 release date for 2.11.3.3 is 22nd May 2025
[jalview.git] / src / jalview / javascript / JSFunctionExec.java
index 4ed9a08..32f1972 100644 (file)
@@ -1,28 +1,31 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
  *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.javascript;
 
+import jalview.bin.JalviewLite;
+
 import java.net.URL;
 import java.util.Vector;
 
 import netscape.javascript.JSObject;
-import jalview.bin.JalviewLite;
 
 public class JSFunctionExec implements Runnable
 {
@@ -36,17 +39,6 @@ public class JSFunctionExec implements Runnable
     jvlite.setExecutor(this);
   }
 
-  public void finalize()
-  {
-    jvlite = null;
-    executor = null;
-    if (jsExecQueue != null)
-    {
-      jsExecQueue.clear();
-    }
-    jsExecQueue = null;
-  }
-
   private Vector jsExecQueue;
 
   private Thread executor = null;
@@ -79,6 +71,7 @@ public class JSFunctionExec implements Runnable
     executor = null;
   }
 
+  @Override
   public void run()
   {
     while (jsExecQueue != null)
@@ -161,6 +154,7 @@ public class JSFunctionExec implements Runnable
     final Exception[] jsex = new Exception[1];
     Runnable exec = new Runnable()
     {
+      @Override
       public void run()
       {
         try
@@ -177,7 +171,7 @@ public class JSFunctionExec implements Runnable
           {
             if (jvlite.debug && dbgMsg != null)
             {
-              System.err.println(dbgMsg);
+              jalview.bin.Console.errPrintln(dbgMsg);
             }
             scriptObject.call(_listener, objects);
           }
@@ -188,18 +182,19 @@ public class JSFunctionExec implements Runnable
           {
             if (jvlite.debug)
             {
-              System.err.println(jex);
+              jalview.bin.Console.errPrintln(jex);
             }
             if (jex instanceof netscape.javascript.JSException
                     && jvlite.jsfallbackEnabled)
             {
-              jsex[0] = (netscape.javascript.JSException) jex;
+              jsex[0] = jex;
               if (jvlite.debug)
               {
-                System.err.println("Falling back to javascript: url call");
+                jalview.bin.Console
+                        .errPrintln("Falling back to javascript: url call");
               }
-              StringBuffer sb = new StringBuffer("javascript:" + _listener
-                      + "(");
+              StringBuffer sb = new StringBuffer(
+                      "javascript:" + _listener + "(");
               for (int i = 0; objects != null && i < objects.length; i++)
               {
                 if (i > 0)
@@ -209,9 +204,8 @@ public class JSFunctionExec implements Runnable
                 sb.append("\"");
                 // strip out nulls and complex objects that we can't pass this
                 // way.
-                if (objects[i] != null
-                        && !(objects[i].getClass().getName()
-                                .indexOf("jalview") == 0))
+                if (objects[i] != null && !(objects[i].getClass().getName()
+                        .indexOf("jalview") == 0))
                 {
                   sb.append(objects[i].toString());
                 }
@@ -220,7 +214,7 @@ public class JSFunctionExec implements Runnable
               sb.append(")");
               if (jvlite.debug)
               {
-                System.err.println(sb.toString());
+                jalview.bin.Console.errPrintln(sb.toString());
               }
               // alternate
               URL url = null;