Merge branch 'develop' into releases/Release_2_11_2_Branch
authorJim Procter <j.procter@dundee.ac.uk>
Mon, 8 Aug 2022 17:28:28 +0000 (18:28 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Mon, 8 Aug 2022 17:28:28 +0000 (18:28 +0100)
build.gradle
help/markdown/releases/release-2_11_2_4.md
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/bin/Cache.java
src/jalview/bin/Jalview.java
src/jalview/bin/Launcher.java
src/jalview/gui/Desktop.java
src/jalview/gui/SliderPanel.java
src/jalview/util/LaunchUtils.java

index a62e85a..bde50b5 100644 (file)
@@ -1640,6 +1640,7 @@ task createBuildProperties(type: WriteProperties) {
   property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
   property "VERSION", JALVIEW_VERSION
   property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
+  property "JAVA_COMPILE_VERSION", JAVA_INTEGER_VERSION
   if (getdownSetAppBaseProperty) {
     property "GETDOWNAPPBASE", getdownAppBase
     property "GETDOWNAPPDISTDIR", getdownAppDistDir
index 8eae620..4f7c584 100644 (file)
@@ -10,11 +10,11 @@ channel: "release"
 - <!-- JAL-4036 --> Migrated Uniprot Free Text Search to latest Uniprot search API
 - <!-- JAL-4034 --> Improved Structure Chooser's 3D-Beacons search button design and visual delay indicators
 - <!-- JAL-4034 --> 3D beacons Fetch Uniprot References confirmation dialog is only shown when number of sequences exceeds a threshold
+- <!-- JAL-3991 --> Warning when Jalview compiled for Java 1.8 is run in a Java 11+ JRE
 - <!-- JAL-4056 --> Updated tldr; section of Jalview's build documentation  (doc/building.md)
 
-
-
-
 ## Issues Resolved
 
 - <!-- JAL-4045 --> buggy PCA plot axes rendering can make them appear to be non-orthogonal
+- <!-- JAL-3993 --> Enable 'All groups' option when conservation slider is opened and 'Colour All Groups' is enabled in Colours menu
+
index ed3e06b..a25114e 100644 (file)
@@ -1334,6 +1334,7 @@ label.backupfiles_confirm_save_file_backupfiles_roll_wrong = Something possibly
 label.backupfiles_confirm_save_new_saved_file_ok = The new saved file seems okay.
 label.backupfiles_confirm_save_new_saved_file_not_ok = The new saved file might not be okay.
 label.continue_operation = Continue operation?
+label.continue = Continue
 label.backups = Backups
 label.backup = Backup
 label.backup_files = Backup Files
@@ -1414,3 +1415,5 @@ label.maximum_memory_tooltip = Enter memory as an integer number optionally foll
 label.adjustments_for_this_computer = Adjustments for this computer
 label.memory_example_text = Maximum memory that would be used with these settings on this computer
 label.memory_example_tooltip = The memory allocated to Jalview is the smaller of the percentage of physical memory (default 90%) and the maximum absolute memory (default 32GB). If your computer's memory cannot be ascertained then the maximum absolute memory defaults to 8GB (if not customised).<br>Jalview will always try and reserve 512MB for the OS and at least 512MB for itself.
+warning.wrong_jvm_version_title = Wrong Java Version
+warning.wrong_jvm_version_message = The Java version being used (Java {0}) may lead to problems.\nThis installation of Jalview should be used with Java {1}.
index d8772ef..88fa161 100644 (file)
@@ -1324,6 +1324,7 @@ label.backupfiles_confirm_save_file_backupfiles_roll_wrong = Posiblemente algo e
 label.backupfiles_confirm_save_new_saved_file_ok = El nuevo archivo guardado parece estar bien.
 label.backupfiles_confirm_save_new_saved_file_not_ok = El nuevo archivo guardado podría no estar bien.
 label.continue_operation = ¿Continuar operación?
+label.continue = Continua
 label.backups = Respaldos
 label.backup = Respaldo
 label.backup_files = Archivos de respaldos
@@ -1404,3 +1405,6 @@ label.maximum_memory_tooltip = Ingrese la memoria como un n
 label.adjustments_for_this_computer = Ajustes para esta computadora
 label.memory_example_text = Memoria máxima que se usaría con esta configuración en esta computadora
 label.memory_example_tooltip = La memoria asignada a Jalview es el menor entre el porcentaje de memoria física (predeterminado 90%) y la memoria absoluta máxima (predeterminado 32 GB). Si no se puede determinar la memoria de su computadora, la memoria absoluta máxima predeterminada es de 8 GB (si no está personalizada).<br>Jalview siempre intentará reservar 512 MB para el sistema operativo y al menos 512 MB para sí mismo.
+warning.wrong_jvm_version_title = Versión incorrecta de Java
+warning.wrong_jvm_version_message = La versión de Java que se está utilizando (Java {0}) puede generar problemas.\nEsta instalación de Jalview debe usarse con Java {1}.
+
index 0ec0e78..370a243 100755 (executable)
@@ -630,6 +630,11 @@ public class Cache
         applicationProperties.put("VERSION",
                 buildProperties.getProperty("VERSION"));
       }
+      if (buildProperties.getProperty("JAVA_COMPILE_VERSION", null) != null)
+      {
+        applicationProperties.put("JAVA_COMPILE_VERSION",
+                buildProperties.getProperty("JAVA_COMPILE_VERSION"));
+      }
     } catch (Exception ex)
     {
       System.out.println("Error reading build details: " + ex);
index fd1783a..d1056bf 100755 (executable)
@@ -45,6 +45,7 @@ import java.util.logging.ConsoleHandler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.swing.JOptionPane;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.UIManager.LookAndFeelInfo;
@@ -76,6 +77,7 @@ import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
 import jalview.util.ChannelProperties;
 import jalview.util.HttpUtils;
+import jalview.util.LaunchUtils;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.ws.jws2.Jws2Discoverer;
@@ -433,6 +435,35 @@ public class Jalview
        * @j2sIgnore
        */
       {
+
+        /**
+         * Check to see that the JVM version being run is suitable for the Java
+         * version this Jalview was compiled for. Popup a warning if not.
+         */
+        if (!LaunchUtils.checkJavaVersion())
+        {
+          Console.warn("The Java version being used (Java "
+                  + LaunchUtils.getJavaVersion()
+                  + ") may lead to problems. This installation of Jalview should be used with Java "
+                  + LaunchUtils.getJavaCompileVersion() + ".");
+
+          if (!LaunchUtils
+                  .getBooleanUserPreference("IGNORE_JVM_WARNING_POPUP"))
+          {
+            Object[] options = {
+                MessageManager.getString("label.continue") };
+            JOptionPane.showOptionDialog(null,
+                    MessageManager.formatMessage(
+                            "warning.wrong_jvm_version_message",
+                            LaunchUtils.getJavaVersion(),
+                            LaunchUtils.getJavaCompileVersion()),
+                    MessageManager
+                            .getString("warning.wrong_jvm_version_title"),
+                    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
+                    null, options, options[0]);
+          }
+        }
+
         if (!aparser.contains("nowebservicediscovery"))
         {
           desktop.startServiceDiscovery();
@@ -494,6 +525,16 @@ public class Jalview
       }
     }
 
+    // Check if JVM and compile version might cause problems and log if it
+    // might.
+    if (headless && !Platform.isJS() && !LaunchUtils.checkJavaVersion())
+    {
+      Console.warn("The Java version being used (Java "
+              + LaunchUtils.getJavaVersion()
+              + ") may lead to problems. This installation of Jalview should be used with Java "
+              + LaunchUtils.getJavaCompileVersion() + ".");
+    }
+
     // Move any new getdown-launcher-new.jar into place over old
     // getdown-launcher.jar
     String appdirString = System.getProperty("getdownappdir");
index 1ea17d6..a55146d 100644 (file)
  */
 package jalview.bin;
 
-import java.util.Locale;
-
 import java.io.File;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 
 import jalview.util.ChannelProperties;
 import jalview.util.LaunchUtils;
@@ -63,6 +62,14 @@ public class Launcher
    */
   public static void main(String[] args)
   {
+    if (!LaunchUtils.checkJavaVersion())
+    {
+      System.err.println("WARNING - The Java version being used (Java "
+              + LaunchUtils.getJavaVersion()
+              + ") may lead to problems. This installation of Jalview should be used with Java "
+              + LaunchUtils.getJavaCompileVersion() + ".");
+    }
+
     final String javaBin = System.getProperty("java.home") + File.separator
             + "bin" + File.separator + "java";
 
index 3ad5384..16603df 100644 (file)
@@ -121,6 +121,7 @@ import jalview.urls.IdOrgSettings;
 import jalview.util.BrowserLauncher;
 import jalview.util.ChannelProperties;
 import jalview.util.ImageMaker.TYPE;
+import jalview.util.LaunchUtils;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.util.ShortcutKeyMaskExWrapper;
@@ -413,6 +414,11 @@ public class Desktop extends jalview.jbgui.GDesktop
      */
     if (Platform.isLinux())
     {
+      if (LaunchUtils.getJavaVersion() >= 11)
+      {
+        jalview.bin.Console.info(
+                "Linux platform only! You may have the following warning next: \"WARNING: An illegal reflective access operation has occurred\"\nThis is expected and cannot be avoided, sorry about that.");
+      }
       try
       {
         Toolkit xToolkit = Toolkit.getDefaultToolkit();
index 46b47a2..5e1357a 100755 (executable)
  */
 package jalview.gui;
 
-import jalview.analysis.Conservation;
-import jalview.datamodel.SequenceGroup;
-import jalview.jbgui.GSliderPanel;
-import jalview.renderer.ResidueShaderI;
-import jalview.util.MessageManager;
-
-import java.awt.event.ActionEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.beans.PropertyVetoException;
@@ -39,6 +32,12 @@ import javax.swing.event.ChangeListener;
 import javax.swing.event.InternalFrameAdapter;
 import javax.swing.event.InternalFrameEvent;
 
+import jalview.analysis.Conservation;
+import jalview.datamodel.SequenceGroup;
+import jalview.jbgui.GSliderPanel;
+import jalview.renderer.ResidueShaderI;
+import jalview.util.MessageManager;
+
 /**
  * DOCUMENT ME!
  * 
@@ -178,6 +177,8 @@ public class SliderPanel extends GSliderPanel
     if (groups != null && !groups.isEmpty())
     {
       sliderPanel.setAllGroupsCheckEnabled(true);
+      sliderPanel.allGroupsCheck
+              .setSelected(ap.av.getColourAppliesToAllGroups());
     }
     else
     {
index f4d7e27..5bd4a08 100644 (file)
@@ -24,6 +24,9 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.Properties;
 
 public class LaunchUtils
@@ -73,4 +76,114 @@ public class LaunchUtils
   {
     return Boolean.parseBoolean(getUserPreference(key));
   }
+
+  public static int JAVA_COMPILE_VERSION = 0;
+
+  public static int getJavaCompileVersion()
+  {
+    if (Platform.isJS())
+    {
+      return -1;
+    }
+    else if (JAVA_COMPILE_VERSION > 0)
+    {
+      return JAVA_COMPILE_VERSION;
+    }
+    String buildDetails = "jar:".concat(LaunchUtils.class
+            .getProtectionDomain().getCodeSource().getLocation().toString()
+            .concat("!" + "/.build_properties"));
+    try
+    {
+      URL localFileURL = new URL(buildDetails);
+      InputStream in = localFileURL.openStream();
+      Properties buildProperties = new Properties();
+      buildProperties.load(in);
+      in.close();
+      String JCV = buildProperties.getProperty("JAVA_COMPILE_VERSION",
+              null);
+      if (JCV == null)
+      {
+        System.out.println(
+                "Could not obtain JAVA_COMPILE_VERSION for comparison");
+        return -2;
+      }
+      JAVA_COMPILE_VERSION = Integer.parseInt(JCV);
+    } catch (MalformedURLException e)
+    {
+      System.err.println("Could not find " + buildDetails);
+      return -3;
+    } catch (IOException e)
+    {
+      System.err.println("Could not load " + buildDetails);
+      return -4;
+    } catch (NumberFormatException e)
+    {
+      System.err.println("Could not parse JAVA_COMPILE_VERSION");
+      return -5;
+    }
+
+    return JAVA_COMPILE_VERSION;
+  }
+
+  public static int JAVA_VERSION = 0;
+
+  public static int getJavaVersion()
+  {
+    if (Platform.isJS())
+    {
+      return -1;
+    }
+    else if (JAVA_VERSION > 0)
+    {
+      return JAVA_VERSION;
+    }
+    try
+    {
+      String JV = System.getProperty("java.version");
+      if (JV == null)
+      {
+        System.out.println("Could not obtain java.version for comparison");
+        return -2;
+      }
+      if (JV.startsWith("1."))
+      {
+        JV = JV.substring(2);
+      }
+      JAVA_VERSION = JV.indexOf(".") == -1 ? Integer.parseInt(JV)
+              : Integer.parseInt(JV.substring(0, JV.indexOf(".")));
+    } catch (NumberFormatException e)
+    {
+      System.err.println("Could not parse java.version");
+      return -3;
+    }
+    return JAVA_VERSION;
+  }
+
+  public static boolean checkJavaVersion()
+  {
+    if (Platform.isJS())
+    {
+      return true;
+    }
+    String buildDetails = "jar:".concat(LaunchUtils.class
+            .getProtectionDomain().getCodeSource().getLocation().toString()
+            .concat("!" + "/.build_properties"));
+
+    int java_compile_version = getJavaCompileVersion();
+    int java_version = getJavaVersion();
+
+    if (java_compile_version <= 0 || java_version <= 0)
+    {
+      System.out.println("Could not make Java version check");
+      return true;
+    }
+    // Warn if these java.version and JAVA_COMPILE_VERSION conditions exist
+    // Usually this means a Java 11 compiled JAR being run by a Java 11 JVM
+    if (java_version >= 11 && java_compile_version < 11)
+    {
+      return false;
+    }
+
+    return true;
+  }
 }