Use JVM property to check if application and JVM are different bitness

This commit is contained in:
Dale Schultz 2022-02-02 08:41:48 -05:00
parent c2d65e1592
commit 3b1e418e20
No known key found for this signature in database
GPG Key ID: EA2C8AD6CB5C2AF2
8 changed files with 129 additions and 176 deletions

View File

@ -3,7 +3,7 @@
<!-- Master build file for RomRaider
RomRaider Open-Source Tuning, Logging and Reflashing
Copyright (C) 2006-2021 RomRaider.com
Copyright (C) 2006-2022 RomRaider.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -54,8 +54,15 @@
<tstamp>
<format property="time.rfc822" pattern="EEE, dd MMM yyyy HH:mm:ss Z" />
<format property="time.year" pattern="yyyy" />
<format property="mnth.day" pattern="MMMDD" />
</tstamp>
<scriptdef language="javascript" name="toUpper">
project.setProperty("mnth.day",
project.getProperty("mnth.day").toUpperCase());
</scriptdef>
<toUpper/>
<!-- set os specific properties -->
<property name="os.windows" value="windows" />
<property name="ext.windows" value="bat" />
@ -76,10 +83,10 @@
<!-- java compiler properties -->
<property name="javac.source" value="1.6" />
<property name="javac.target" value="1.6" />
<condition property="bootclasspath.dir" value="${env.JRE_DIR}/lib"
else="C:\Program Files (x86)\Java\jdk1.6.0_45\jre\lib">
<isset property="env.JRE_DIR" />
</condition>
<condition property="bootclasspath.dir" value="${env.JRE_DIR}/lib"
else="C:\Program Files (x86)\Java\jdk1.6.0_45\jre\lib">
<isset property="env.JRE_DIR" />
</condition>
<property name="debug" value="off" />
<property name="deprecation" value="on" />
<property name="javac.verbose" value="off" />
@ -167,6 +174,7 @@
<filter token="version.extra" value="${version.extra}" />
<filter token="version.extra1" value="${version.extra1}" />
<filter token="min.logger.def.version" value="${min.logger.def.version}" />
<filter token="build.arch" value="${build.arch}" />
<filter token="jvm.args.win" value="${jvm.args.win}" />
<filter token="jvm.args.linux" value="${jvm.args.linux}" />
</filterset>

View File

@ -1,5 +1,5 @@
SUPPORT = When requesting assistance at {0}, please include the System Properties information below:
COMPATJRE = Incompatible JRE detected.\n{0} requires a 32-bit JRE for some operations.\nSome features may be unavailable.
COMPATJRE = Incompatible JRE detected.\n{0} Editor requires a {1}-bit JRE for full feature support.
JREWARN = JRE Compatibility Warning
ISRUNNING = {0} is already running.
ERRROM = Error opening ROM

View File

@ -1,43 +1,43 @@
TITLE = ECU/TCU Logger
FILENAMEEXTENTION = Right-click to select or type text to add to the saved logfile name.
TTTEXTF11 = Hides the parameter list and saves the state on exit (F11)
TTTEXTF9 = Un-select all selected parameters/switches on all tabs! (F9)
STARTFILELOG = Start file log
STOPFILELOG = Stop file log
TTTEXTF1 = Start/stop file logging (F1)
INITIALIZELOGGER = Initializing Logger ...
INCOMPJRE = Incompatible JRE detected.\n{0} RomRaider Logger requires a 32-bit JRE.\nLogger will now exit."
INCOMPJREERR = JRE Incompatibility Error
LOADINGDEFS = Loading Logger Defs ...
LOADINGPLUG = Loading Plugins ...
LOADINGPARAMS = Loading Logging Parameters ...
STARTINGLOGGER = Starting Logger ...
COMPLETE = Complete ...
READY = Ready ...
YES = Yes
NO = No
LOGGERDEFERROR = Error loading definition:
LOGGERDEFNOTCFG = Logger definition not configured.\nGo online to download the latest definition file?
LOGGERCONFIG = Logger Configuration
CFGEDFSMENU = The Logger definition file needs to be configured before connecting to the ECU.\nMenu: Settings > Logger Definition Location ...\nOnce configured, restart the Logger application.
PROFILENAME = Profile: {0}
LOAD = Load
CANCEL = Cancel
PROFILEWRONGPROTO = This profile was created for logging protocol {0}.\nSome parameters may not be selected by this profile if\nyou continue. Change protocols in the Settings menu\nthen reload this profile.
PROTOCOLMISMATCH = Protocol Mismatch
LOADPLUGINERR = Error loading plugin: {0} v{1}
BTNGAUGESTYLE = Gauge Style
BTNUNSELECTALL = Un-select ALL
BTNPARAMLIST = Parameter List
LOGFILETEXT = Logfile Text
TARGETID = Use Current {0} ID
PT = Part Throttle
WOT = Wide Open Throttle
CLT = Clear Logfile Text
COMPORT = COM Port:
TTTEXTRECON = Reconnect to {0}
TTTEXTDISCON = Disconnect from {0}
TTTEXTEXTERNALS = {0} Polling. Uncheck all boxes for Externals logging only.
RESET = Reset {0} [{1}]
RESETDATA = Reset Data
ERROR = Error: {0}
TITLE = ECU/TCU Logger
FILENAMEEXTENTION = Right-click to select or type text to add to the saved logfile name.
TTTEXTF11 = Hides the parameter list and saves the state on exit (F11)
TTTEXTF9 = Un-select all selected parameters/switches on all tabs! (F9)
STARTFILELOG = Start file log
STOPFILELOG = Stop file log
TTTEXTF1 = Start/stop file logging (F1)
INITIALIZELOGGER = Initializing Logger ...
INCOMPJRE = Incompatible JRE detected.\n{0} Logger requires a {1}-bit JRE.\nLogger will now exit.
INCOMPJREERR = JRE Incompatibility Error
LOADINGDEFS = Loading Logger Defs ...
LOADINGPLUG = Loading Plugins ...
LOADINGPARAMS = Loading Logging Parameters ...
STARTINGLOGGER = Starting Logger ...
COMPLETE = Complete ...
READY = Ready ...
YES = Yes
NO = No
LOGGERDEFERROR = Error loading definition:
LOGGERDEFNOTCFG = Logger definition not configured.\nGo online to download the latest definition file?
LOGGERCONFIG = Logger Configuration
CFGEDFSMENU = The Logger definition file needs to be configured before connecting to the ECU.\nMenu: Settings > Logger Definition Location ...\nOnce configured, restart the Logger application.
PROFILENAME = Profile: {0}
LOAD = Load
CANCEL = Cancel
PROFILEWRONGPROTO = This profile was created for logging protocol {0}.\nSome parameters may not be selected by this profile if\nyou continue. Change protocols in the Settings menu\nthen reload this profile.
PROTOCOLMISMATCH = Protocol Mismatch
LOADPLUGINERR = Error loading plugin: {0} v{1}
BTNGAUGESTYLE = Gauge Style
BTNUNSELECTALL = Un-select ALL
BTNPARAMLIST = Parameter List
LOGFILETEXT = Logfile Text
TARGETID = Use Current {0} ID
PT = Part Throttle
WOT = Wide Open Throttle
CLT = Clear Logfile Text
COMPORT = COM Port:
TTTEXTRECON = Reconnect to {0}
TTTEXTDISCON = Disconnect from {0}
TTTEXTEXTERNALS = {0} Polling. Uncheck all boxes for Externals logging only.
RESET = Reset {0} [{1}]
RESETDATA = Reset Data
ERROR = Error: {0}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2019 RomRaider.com
* Copyright (C) 2006-2022 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -46,7 +46,6 @@ import org.apache.log4j.Logger;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.util.JREChecker;
import com.romraider.util.ResourceUtil;
public class ECUExec {
@ -76,12 +75,15 @@ public class ECUExec {
LOGGER.info("System Properties: \n\t"
+ System.getProperties().toString().replace(COMMA, "\n\t"));
// 64-bit won't work with the native libs (e.g. serial rxtx) but won't
// fail until we actually try to use them we'll just warn here
if (!JREChecker.is32bit() &&
/**
* Bitness of supporting libraries must match the bitness of RomRaider
* and the running JRE. Notify if mixed bitness is detected.
*/
if (!System.getProperty("sun.arch.data.model").equals(Version.BUILD_ARCH) &&
!containsLoggerArg(args)) {
showMessageDialog(null,
MessageFormat.format(rb.getString("COMPATJRE"), PRODUCT_NAME),
MessageFormat.format(
rb.getString("COMPATJRE"), PRODUCT_NAME, Version.BUILD_ARCH),
rb.getString("JREWARN"),
WARNING_MESSAGE);
}
@ -92,10 +94,10 @@ public class ECUExec {
// set look and feel
initLookAndFeel();
setExecType(args);
// check if already running
if (isRunning()) {
//The other exectuable will open us, close this app
if (isRunning()) {
// The other executable will open us, close this app
EditorLoggerCommunication.sendTypeToOtherExec(args);
} else {
// open editor or logger
@ -104,7 +106,7 @@ public class ECUExec {
} else {
openEditor(DISPOSE_ON_CLOSE, args);
}
startExecCommunication();
}
}
@ -113,7 +115,7 @@ public class ECUExec {
Exec_type execType = containsLoggerArg(args) ? Exec_type.LOGGER : Exec_type.EDITOR;
EditorLoggerCommunication.setExectable(execType, args);
}
public static void showAlreadyRunningMessage() {
showMessageDialog(null,
MessageFormat.format(rb.getString("ISRUNNING"), PRODUCT_NAME),
@ -122,7 +124,7 @@ public class ECUExec {
private static boolean containsLoggerArg(String[] args) {
for (String arg : args) {
if ( arg.equalsIgnoreCase(START_LOGGER_ARG) ||
if ( arg.equalsIgnoreCase(START_LOGGER_ARG) ||
arg.equalsIgnoreCase(START_LOGGER_FULLSCREEN_ARG) ||
arg.equalsIgnoreCase(LOGGER_TOUCH_ARG)) {
return true;
@ -150,31 +152,31 @@ public class ECUExec {
while (true) {
try {
ExecutableInstance instance = EditorLoggerCommunication.waitForOtherExec();
if(instance.execType == Exec_type.LOGGER) {
if(EditorLoggerCommunication.getExecutableType() == Exec_type.LOGGER ||
EcuLogger.getEcuLoggerWithoutCreation() != null) {
showAlreadyRunningMessage();
continue;
}
openLogger(DISPOSE_ON_CLOSE, instance.currentArgs);
openLogger(DISPOSE_ON_CLOSE, instance.currentArgs);
LOGGER.info("Opening Logger with args: " + Arrays.toString(instance.currentArgs));
}
else if(instance.execType == Exec_type.EDITOR) {
openEditor(DISPOSE_ON_CLOSE, instance.currentArgs);
if(EditorLoggerCommunication.getExecutableType() == Exec_type.LOGGER) {
openEditor(DISPOSE_ON_CLOSE, instance.currentArgs);
if(EditorLoggerCommunication.getExecutableType() == Exec_type.LOGGER) {
EcuLogger.getEcuLoggerWithoutCreation().setEcuEditor(
ECUEditorManager.getECUEditorWithoutCreation());
}
LOGGER.info("Opening Editor with args: " + Arrays.toString(instance.currentArgs));
}
else {
LOGGER.error("Unknown type in Editor/Logger communication with args: " + Arrays.toString(instance.currentArgs));
}
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -35,6 +35,7 @@ public final class Version {
public static final String RELEASE_NOTES = "@release_notes@";
public static final ImageIcon ABOUT_ICON = new ImageIcon(Version.class.getClass().getResource("/graphics/romraider-ico-large.gif"));
public static final int MIN_LOG_DEF_VERSION = @min.logger.def.version@;
public static final String BUILD_ARCH = "@build.arch@";
private Version() {
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2021 RomRaider.com
* Copyright (C) 2006-2022 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -114,6 +114,7 @@ import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import com.romraider.Settings;
import com.romraider.Version;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.io.serial.port.SerialPortRefresher;
@ -191,7 +192,6 @@ import com.romraider.logger.external.core.ExternalDataSourceLoaderImpl;
import com.romraider.swing.AbstractFrame;
import com.romraider.swing.SetFont;
import com.romraider.util.FormatFilename;
import com.romraider.util.JREChecker;
import com.romraider.util.ResourceUtil;
import com.romraider.util.SettingsManager;
@ -297,13 +297,13 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
private Map<String, Object> componentList = new HashMap<String, Object>();
private static boolean touchEnabled = false;
private final JPanel moduleSelectPanel = new JPanel(new FlowLayout());
private static EcuLogger instance;
public static EcuLogger getEcuLoggerWithoutCreation() {
return instance;
}
public static EcuLogger getEcuLogger(ECUEditor ecuEditor) {
if (instance != null ) return instance;
else {
@ -311,34 +311,35 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
return instance;
}
}
private EcuLogger(ECUEditor ecuEditor) {
super(ECU_LOGGER_TITLE);
this.ecuEditor = ecuEditor;
construct();
}
public void setEcuEditor(ECUEditor ecuEditor) {
this.ecuEditor = ecuEditor;
mafTab = new MafTabImpl(mafTabBroker, ecuEditor);
injectorTab = new InjectorTabImpl(injectorTabBroker, ecuEditor);
dynoTab = new DynoTabImpl(dynoTabBroker, ecuEditor);
injectorUpdateHandler.setInjectorTab(injectorTab);
mafUpdateHandler.setMafTab(mafTab);
dynoUpdateHandler.setDynoTab(dynoTab);
}
private void construct() {
// 64-bit won't work with the native libs (e.g. serial rxtx) but won't
// fail until we actually try to use them since the logger requires
// these libraries, this is a hard error here
if (!JREChecker.is32bit()) {
/**
* Bitness of supporting libraries must match the bitness of RomRaider
* and the running JRE. Notify and exit if mixed bitness is detected.
*/
if (!System.getProperty("sun.arch.data.model").equals(Version.BUILD_ARCH)) {
showMessageDialog(null,
MessageFormat.format(
rb.getString("INCOMPJRE"),
PRODUCT_NAME),
PRODUCT_NAME, Version.BUILD_ARCH),
rb.getString("INCOMPJREERR"),
ERROR_MESSAGE);
// this will generate a NullPointerException because we never got
@ -392,6 +393,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
if (!isLogging()) startLogging();
ecuEditor.getStatusPanel().update(rb.getString("READY"),0);
}
this.toFront();
}
private void bootstrap() {
@ -445,22 +447,22 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
controller = new LoggerControllerImpl(ecuInitCallback, this, liveDataUpdateHandler,
graphUpdateHandler, dashboardUpdateHandler, mafUpdateHandler, injectorUpdateHandler,
dynoUpdateHandler, fileUpdateHandler, TableUpdateHandler.getInstance());
mafHandlerManager = new DataUpdateHandlerManagerImpl();
mafTabBroker = new DataRegistrationBrokerImpl(controller, mafHandlerManager);
mafTab = new MafTabImpl(mafTabBroker, ecuEditor);
mafTabBroker = new DataRegistrationBrokerImpl(controller, mafHandlerManager);
mafTab = new MafTabImpl(mafTabBroker, ecuEditor);
mafUpdateHandler.setMafTab(mafTab);
injectorHandlerManager = new DataUpdateHandlerManagerImpl();
injectorHandlerManager = new DataUpdateHandlerManagerImpl();
injectorTabBroker = new DataRegistrationBrokerImpl(controller, injectorHandlerManager);
injectorTab = new InjectorTabImpl(injectorTabBroker, ecuEditor);
injectorTab = new InjectorTabImpl(injectorTabBroker, ecuEditor);
injectorUpdateHandler.setInjectorTab(injectorTab);
dynoHandlerManager = new DataUpdateHandlerManagerImpl();
dynoTabBroker = new DataRegistrationBrokerImpl(controller, dynoHandlerManager);
dynoTab = new DynoTabImpl(dynoTabBroker, ecuEditor);
dynoUpdateHandler.setDynoTab(dynoTab);
resetManager = new ResetManagerImpl(this);
messageLabel = new JLabel(ECU_LOGGER_TITLE);
calIdLabel = new JLabel(buildEcuInfoLabelText(CAL_ID_LABEL, null));
@ -483,9 +485,6 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
dashboardTabParamListTableModel = new ParameterListTableModel(dashboardTabBroker, HEADING_PARAMETERS);
dashboardTabSwitchListTableModel = new ParameterListTableModel(dashboardTabBroker, HEADING_SWITCHES);
dashboardTabExternalListTableModel = new ParameterListTableModel(dashboardTabBroker, HEADING_EXTERNAL);
}
public void loadLoggerParams() {
@ -629,7 +628,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
}
}
}
private void showErrorConfigDialog(Exception e) {
Object[] options = {"OK"};
showOptionDialog(this,
@ -641,7 +640,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
options,
options[0]);
}
private void showMissingConfigDialog() {
Object[] options = {rb.getString("YES"), rb.getString("NO")};
int answer = showOptionDialog(this,
@ -1000,7 +999,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
buildToggleGaugeStyleButton());
tabbedPane.add("MAF", mafTab.getPanel());
tabbedPane.add("Injector", injectorTab.getPanel());
tabbedPane.add("Dyno", dynoTab.getPanel());
tabbedPane.add("Dyno", dynoTab.getPanel());
}
else
{
@ -1039,9 +1038,10 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
tabbedPane.add("<html><body leftmargin=15 topmargin=15 marginwidth=15 marginheight=15>" + "Injector"+ "</body></html>", injectorTab.getPanel());
tabbedPane.add("<html><body leftmargin=15 topmargin=15 marginwidth=15 marginheight=15>" + "Dyno" + "</body></html>", dynoTab.getPanel());
}
//Check for definitions only when we open the dyno tab
tabbedPane.addChangeListener(new ChangeListener() {
tabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if(tabbedPane.getSelectedComponent() == dynoTab.getPanel())
{
@ -1049,7 +1049,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
}
}
});
return tabbedPane;
}
@ -1590,7 +1590,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
cb.setSelected(true);
setTarget(module.getName());
}
cb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
@ -1606,7 +1606,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
startLogging();
}
});
moduleGroup.add(cb);
moduleSelectPanel.add(cb);
moduleSelectPanel.validate();
@ -1666,7 +1666,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
private Transport getTransportById(String id) {
Transport loggerTransport = null;
Map<Transport, Collection<Module>> transportMap = getTransportMap();
for (Transport transport : transportMap.keySet()) {
if (transport.getId().equalsIgnoreCase(id))
loggerTransport = transport;
@ -1675,17 +1675,17 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
return loggerTransport;
}
public void updateElmSelectable() {
public void updateElmSelectable() {
boolean value = getSettings().isObdProtocol();
RadioButtonMenuItem c = (RadioButtonMenuItem)getComponentList().get("elmEnabled");
c.setEnabled(value);
c.setEnabled(value);
if(!value) {
c.setSelected(false);
getSettings().setElm327Enabled(false);
}
}
private Map<Transport, Collection<Module>> getTransportMap() {
return protocolList.get(getSettings().getLoggerProtocol());
}
@ -1928,10 +1928,10 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
saveSettings();
backupCurrentProfile();
LOGGER.info("Logger shutdown successful");
if(ECUEditorManager.getECUEditorWithoutCreation() == null) {
if(ECUEditorManager.getECUEditorWithoutCreation() == null) {
System.exit(0);
}
}
else {
instance = null;
}
@ -2073,8 +2073,8 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
getSettings().setRefreshMode(refreshMode);
refresher.setRefreshMode(refreshMode);
}
public void setElmEnabled(Boolean value) {
public void setElmEnabled(Boolean value) {
getSettings().setElm327Enabled(value);
}
@ -2112,7 +2112,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
private static boolean containsFullScreenArg(String... args) {
if(args == null) return false;
for (String arg : args) {
if (LOGGER_FULLSCREEN_ARG.equalsIgnoreCase(arg)) return true;
}
@ -2121,7 +2121,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
private static boolean setTouchEnabled(String... args) {
if(args == null) return false;
for (String arg : args) {
if (LOGGER_TOUCH_ARG.equalsIgnoreCase(arg)) return true;
}

View File

@ -1,59 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.util;
/**
* @author Steve Wadsworth <lizzardo on RomRaider forum>
* @since 2012-12-30
*
* This class is intended to contain utility methods needed to determine various
* parameters of the JVM in which the application is running.
*
*/
public final class JREChecker {
/**
* Check to see if the JVM is 32-bit
*
* @return true if JVM is 32-bit
*/
public static boolean is32bit() {
// determine if we're running in a 32-bit JVM
// this may need to be extended for other JVM providers and versions
String bitness = System.getProperty("sun.arch.data.model", "unknown");
// if we don't know, try harder - additional tests can be added here as
// necessary
if (bitness.equals("unknown")) {
// if sun.arch.data.model isn't found, we may be on a non-Sun
// (Oracle) VM try some other properties
if (System.getProperty("java.vm.name").indexOf("64") >= 0 ||
System.getProperty("sun.cpu.isalist").indexOf("64") >= 0) {
bitness = "64";
}
}
// should be either 32, 64, or still unknown. only known 32 should
// return true
if (bitness.equals("32")) {
return true;
}
return false;
}
}

View File

@ -22,9 +22,10 @@ version.major=0
version.minor=8
version.patch=2
version.buildnumber=1059
version.extra=DEC04
version.extra1=2021
version.extra=${mnth.day}
version.extra1=${time.year}
min.logger.def.version=370
build.arch=${sun.arch.data.model}
# the starting class for the application
class.start=com.romraider.ECUExec