From 46a33b990d4ff81cedcaa908342d7f1081ac00de Mon Sep 17 00:00:00 2001 From: Stephane Dallongeville <stephane.dallongeville@pasteur.fr> Date: Wed, 17 Nov 2021 17:22:51 +0100 Subject: [PATCH] Fixed access to internals MMStudio fields to make it compatible with Java 17 --- .../MicroManager/gui/MMMainFrame.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/plugins/tprovoost/Microscopy/MicroManager/gui/MMMainFrame.java b/src/main/java/plugins/tprovoost/Microscopy/MicroManager/gui/MMMainFrame.java index 0e1771d..0e3947f 100644 --- a/src/main/java/plugins/tprovoost/Microscopy/MicroManager/gui/MMMainFrame.java +++ b/src/main/java/plugins/tprovoost/Microscopy/MicroManager/gui/MMMainFrame.java @@ -131,11 +131,11 @@ public class MMMainFrame extends IcyFrame try { // we have our own load config frame so we hide the one from MicroManager - final MMOptions options = new MMOptions(); - options.loadSettings(); - doNotAskConfigFileSave = options.doNotAskForConfigFile_; - options.doNotAskForConfigFile_ = true; - options.saveSettings(); + final MMOptions opt = new MMOptions(); + opt.loadSettings(); + doNotAskConfigFileSave = opt.doNotAskForConfigFile_; + opt.doNotAskForConfigFile_ = true; + opt.saveSettings(); } catch (Throwable t) { @@ -163,7 +163,8 @@ public class MMMainFrame extends IcyFrame { try { - options = (MMOptions) ReflectionUtil.getFieldObject(mmstudio, "options_", true); + // use reflection to access it as it was private (we patched the class to make it public) + options = (MMOptions) ReflectionUtil.getFieldObject(mmstudio, "options_"); // patch some settings hideMDADisplaySave = options.hideMDADisplay_; @@ -178,10 +179,11 @@ public class MMMainFrame extends IcyFrame try { - mainPreferences = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "mainPrefs_", true); - colorPrefs = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "colorPrefs_", true); - exposurePrefs = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "exposurePrefs_", true); - contrastPrefs = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "contrastPrefs_", true); + // use reflection to access them as they were private (we patched the class to make them public) + mainPreferences = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "mainPrefs_"); + colorPrefs = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "colorPrefs_"); + exposurePrefs = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "exposurePrefs_"); + contrastPrefs = (Preferences) ReflectionUtil.getFieldObject(mmstudio, "contrastPrefs_"); } catch (Exception ex) { -- GitLab