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

@ -6,7 +6,7 @@ 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."
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 ...

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);
}
@ -95,7 +97,7 @@ public class ECUExec {
// check if already running
if (isRunning()) {
//The other exectuable will open us, close this app
// The other executable will open us, close this app
EditorLoggerCommunication.sendTypeToOtherExec(args);
} else {
// open editor or logger

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;
@ -331,14 +331,15 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
}
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() {
@ -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() {
@ -1042,6 +1041,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
//Check for definitions only when we open the dyno tab
tabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if(tabbedPane.getSelectedComponent() == dynoTab.getPanel())
{

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