Skip to content

Commit

Permalink
v11r1
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbudda committed Aug 16, 2020
1 parent c69e8fc commit 72ba559
Show file tree
Hide file tree
Showing 73 changed files with 2,370 additions and 1,974 deletions.
2 changes: 1 addition & 1 deletion installer/launch4j/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.

Copyright (c) 2004, 2015 Grzegorz Kowal
Copyright (c) 2004, 2017 Grzegorz Kowal
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
Binary file modified installer/launch4j/demo/ConsoleApp/ConsoleApp.exe
Binary file not shown.
Binary file modified installer/launch4j/demo/ConsoleApp/ConsoleApp.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion installer/launch4j/demo/ConsoleApp/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${launch4j.dir}/launch4j.jar
:${launch4j.dir}/lib/xstream.jar" />
<launch4j>
<config headerType="console" jar="ConsoleApp.jar" outfile="ConsoleApp.exe" errTitle="ConsoleApp" chdir="." icon="l4j/ConsoleApp.ico">
<config headerType="console" jarPath="ConsoleApp.jar" dontWrapJar="true" outfile="ConsoleApp.exe" errTitle="ConsoleApp" chdir="." icon="l4j/ConsoleApp.ico">
<singleInstance mutexName="net.sf.launch4j.example.ConsoleApp" />
<jre minVersion="1.6.0" />
</config>
Expand Down
Binary file modified installer/launch4j/demo/SimpleApp/SimpleApp.exe
Binary file not shown.
Binary file modified installer/launch4j/demo/SimpleApp/SimpleApp.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion installer/launch4j/demo/SimpleApp/l4j/SimpleApp.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<launch4jConfig>
<headerType>gui</headerType>
<jar>../SimpleApp.jar</jar>
<jar>SimpleApp.jar</jar>
<dontWrapJar>true</dontWrapJar>
<outfile>../SimpleApp.exe</outfile>
<errTitle>SimpleApp</errTitle>
<chdir>.</chdir>
Expand Down
Binary file modified installer/launch4j/head/head.o
Binary file not shown.
Binary file modified installer/launch4j/head_jni_BETA/head.o
Binary file not shown.
Binary file modified installer/launch4j/head_jni_BETA/jnihead.o
Binary file not shown.
175 changes: 149 additions & 26 deletions installer/launch4j/head_src/head.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ BOOL loadString(const int resID, char* buffer)
HRSRC hResource;
HGLOBAL hResourceLoaded;
LPBYTE lpBuffer;
debugAll("Resource %d:\t", resID);

hResource = FindResourceEx(hModule, RT_RCDATA, MAKEINTRESOURCE(resID),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT));
Expand All @@ -224,10 +225,7 @@ BOOL loadString(const int resID, char* buffer)
buffer[x] = (char) lpBuffer[x];
} while (buffer[x++] != 0);

if (debugAll)
{
debug("Resource %d:\t%s\n", resID, buffer);
}
debugAll("%s\n", buffer);
return TRUE;
}
}
Expand All @@ -237,6 +235,8 @@ BOOL loadString(const int resID, char* buffer)
SetLastError(0);
buffer[0] = 0;
}

debugAll("<NULL>\n");
return FALSE;
}

Expand Down Expand Up @@ -312,27 +312,118 @@ BOOL regQueryValue(const char* regPath, unsigned char* buffer,
return result;
}

int findNextVersionPart(const char* startAt)
{
if (startAt == NULL || strlen(startAt) == 0)
{
return 0;
}

char* firstSeparatorA = strchr(startAt, '.');
char* firstSeparatorB = strchr(startAt, '_');
char* firstSeparator;
if (firstSeparatorA == NULL)
{
firstSeparator = firstSeparatorB;
}
else if (firstSeparatorB == NULL)
{
firstSeparator = firstSeparatorA;
}
else
{
firstSeparator = min(firstSeparatorA, firstSeparatorB);
}

if (firstSeparator == NULL)
{
return strlen(startAt);
}

return firstSeparator - startAt;
}

/**
* This method will take java version from `originalVersion` string and convert/format it
* into `version` string that can be used for string comparison with other versions.
*
* Due to different version schemas <=8 vs. >=9 it will "normalize" versions to 1 format
* so we can directly compare old and new versions.
*/
void formatJavaVersion(char* version, const char* originalVersion)
{
char* updatePart = strchr(originalVersion, '_');
strcpy(version, "");
if (originalVersion == NULL || strlen(originalVersion) == 0)
{
return;
}

int partsAdded = 0;
int i;
char* pos = (char*) originalVersion;
int curPartLen;

if (updatePart != NULL)
while ((curPartLen = findNextVersionPart(pos)) > 0)
{
// skip underscore
updatePart++;
char number[curPartLen + 1];
memset(number, 0, curPartLen + 1);
strncpy(number, pos, curPartLen);

if (strlen(updatePart) < 3)
if (partsAdded == 0 && (curPartLen != 1 || number[0] != '1'))
{
const int majorVersionLength = updatePart - originalVersion;
strncpy(version, originalVersion, majorVersionLength);
*(version + majorVersionLength) = 0;
strcat(version, "0");
strcat(version, updatePart);
return;
}
}

strcpy(version, originalVersion);
// NOTE: When it's java 9+ we'll add "1" as the first part of the version
strcpy(version, "1");
partsAdded++;
}

if (partsAdded < 3)
{
if (partsAdded > 0)
{
strcat(version, ".");
}
for (i = 0;
(partsAdded > 0)
&& (i < JRE_VER_MAX_DIGITS_PER_PART - strlen(number));
i++)
{
strcat(version, "0");
}
strcat(version, number);
}
else if (partsAdded == 3)
{
// add as an update
strcat(version, "_");
for (i = 0; i < JRE_VER_MAX_DIGITS_PER_PART - strlen(number); i++)
{
strcat(version, "0");
}
strcat(version, number);
}
else if (partsAdded >= 4)
{
debug("Warning:\tformatJavaVersion() too many parts added.\n");
break;
}
partsAdded++;

pos += curPartLen + 1;
if (pos >= originalVersion + strlen(originalVersion))
{
break;
}
}

for (i = partsAdded; i < 3; i++)
{
strcat(version, ".");
int j;
for (j = 0; j < JRE_VER_MAX_DIGITS_PER_PART; j++)
{
strcat(version, "0");
}
}
}

void regSearch(const char* keyName, const int searchType)
Expand Down Expand Up @@ -419,10 +510,6 @@ BOOL isJavaHomeValid(const char* keyName, const int searchType)
path[i] = buffer[i];
} while (path[i++] != 0);

if (searchType & FOUND_SDK)
{
appendPath(path, "jre");
}
valid = isLauncherPathValid(path);
}
RegCloseKey(hKey);
Expand Down Expand Up @@ -511,6 +598,10 @@ void regSearchWow(const char* keyName, const int searchType)
case USE_32_BIT_RUNTIME:
regSearch(keyName, searchType);
break;

default:
debug("Runtime bits:\tFailed to load.\n");
break;
}
}

Expand Down Expand Up @@ -538,10 +629,25 @@ void regSearchJreSdk(const char* jreKeyName, const char* sdkKeyName,

BOOL findJavaHome(char* path, const int jdkPreference)
{
debugAll("findJavaHome()\n");
regSearchJreSdk("SOFTWARE\\JavaSoft\\Java Runtime Environment",
"SOFTWARE\\JavaSoft\\Java Development Kit",
jdkPreference);

// Java 9 support
regSearchJreSdk("SOFTWARE\\JavaSoft\\JRE",
"SOFTWARE\\JavaSoft\\JDK",
jdkPreference);

// IBM Java 1.8
if (search.foundJava == NO_JAVA_FOUND)
{
regSearchJreSdk("SOFTWARE\\IBM\\Java Runtime Environment",
"SOFTWARE\\IBM\\Java Development Kit",
jdkPreference);
}

// IBM Java 1.7 and earlier
if (search.foundJava == NO_JAVA_FOUND)
{
regSearchJreSdk("SOFTWARE\\IBM\\Java2 Runtime Environment",
Expand Down Expand Up @@ -648,6 +754,10 @@ BOOL expandVars(char *dst, const char *src, const char *exePath, const int pathL
else if (strstr(varName, HKEY_STR) == varName)
{
regQueryValue(varName, dst + strlen(dst), BIG_STR);
}
else if (strcmp(varName, "") == 0)
{
strcat(dst, "%");
}
else if (GetEnvironmentVariable(varName, varValue, MAX_VAR_SIZE) > 0)
{
Expand Down Expand Up @@ -768,6 +878,7 @@ BOOL createMutex()

if (*mutexName)
{
debug("Create mutex:\t%s\n", mutexName);
SECURITY_ATTRIBUTES security;
security.nLength = sizeof(SECURITY_ATTRIBUTES);
security.bInheritHandle = TRUE;
Expand Down Expand Up @@ -802,8 +913,16 @@ void setWorkingDirectory(const char *exePath, const int pathLen)

BOOL bundledJreSearch(const char *exePath, const int pathLen)
{
debugAll("bundledJreSearch()\n");
char tmpPath[_MAX_PATH] = {0};
BOOL is64BitJre = loadBool(BUNDLED_JRE_64_BIT);

if (!wow64 && is64BitJre)
{
debug("Bundled JRE:\tCannot use 64-bit runtime on 32-bit OS.\n");
return FALSE;
}

if (loadString(JRE_PATH, tmpPath))
{
char jrePath[MAX_ARGS] = {0};
Expand All @@ -824,9 +943,7 @@ BOOL bundledJreSearch(const char *exePath, const int pathLen)

if (isLauncherPathValid(launcher.cmd))
{
search.foundJava = (wow64 && loadBool(BUNDLED_JRE_64_BIT))
? FOUND_BUNDLED | KEY_WOW64_64KEY
: FOUND_BUNDLED;
search.foundJava = is64BitJre ? FOUND_BUNDLED | KEY_WOW64_64KEY : FOUND_BUNDLED;
strcpy(search.foundJavaHome, launcher.cmd);
return TRUE;
}
Expand All @@ -837,6 +954,7 @@ BOOL bundledJreSearch(const char *exePath, const int pathLen)

BOOL installedJreSearch()
{
debugAll("installedJreSearch()\n");
return *search.javaMinVer && findJavaHome(launcher.cmd, loadInt(JDK_PREFERENCE));
}

Expand Down Expand Up @@ -883,13 +1001,16 @@ void createJreSearchError()

BOOL jreSearch(const char *exePath, const int pathLen)
{
debugAll("jreSearch()\n");
BOOL result = TRUE;

search.bundledJreAsFallback = loadBool(BUNDLED_JRE_AS_FALLBACK);
loadString(JAVA_MIN_VER, search.originalJavaMinVer);
formatJavaVersion(search.javaMinVer, search.originalJavaMinVer);
debug("Java min ver:\t%s\n", search.javaMinVer);
loadString(JAVA_MAX_VER, search.originalJavaMaxVer);
formatJavaVersion(search.javaMaxVer, search.originalJavaMaxVer);
debug("Java max ver:\t%s\n", search.javaMaxVer);

if (search.bundledJreAsFallback)
{
Expand Down Expand Up @@ -978,6 +1099,8 @@ void setMainClassAndClassPath(const char *exePath, const int pathLen)

if (loadString(MAIN_CLASS, launcher.mainClass))
{
debug("Main class:\t%s\n", launcher.mainClass);

if (!loadString(CLASSPATH, classPath))
{
debug("Info:\t\tClasspath not defined.\n");
Expand Down
5 changes: 4 additions & 1 deletion installer/launch4j/head_src/head.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
#include <process.h>

#define LAUNCH4j "Launch4j"
#define VERSION "3.9"
#define VERSION "3.12"

#define JRE_VER_MAX_DIGITS_PER_PART 3

#define NO_JAVA_FOUND 0
#define FOUND_JRE 1
Expand Down Expand Up @@ -91,6 +93,7 @@

#define ERROR_FORMAT "Error:\t\t%s\n"
#define debug(args...) if (hLog != NULL) fprintf(hLog, ## args);
#define debugAll(args...) if (debugAll && hLog != NULL) fprintf(hLog, ## args);

typedef void (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

Expand Down
16 changes: 10 additions & 6 deletions installer/launch4j/head_src/jnihead.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ JavaVM* g_pJavaVM = NULL;
JNIEnv* g_pJNIEnv = NULL;
JavaVMInitArgs g_sJavaVMInitArgs;
char g_rgcMnClsArgs[MAX_ARGS] = {0};
char g_rgcClsPth[MAX_ARGS] = {0};
char g_rgcMnCls[_MAX_PATH] = {0};
char g_rgcCurrJrePth[_MAX_PATH] = {0};
HINSTANCE g_hInstance;
Expand Down Expand Up @@ -67,6 +66,8 @@ void saveJvmOptions(const char *jrePath, const char *mainClass, const char *pcOp
char *pcCurrOpt;
char **prgcVmArgs = NULL;
strncpy(rgcOptCpy, pcOpts, MAX_ARGS - 1);


iArgCnt = getArgCount(rgcOptCpy);
if (iArgCnt > 0)
{
Expand All @@ -80,6 +81,7 @@ void saveJvmOptions(const char *jrePath, const char *mainClass, const char *pcOp
/* Allocat iArgCnt JavaVMOptions for the g_sJavaVMInitArgs struct */
g_sJavaVMInitArgs.options = malloc(iArgCnt * sizeof(JavaVMOption));
memset(g_sJavaVMInitArgs.options, 0, iArgCnt * sizeof(JavaVMOption));
char* rgcClsPth = 0;
/* Copy the tokenized array into the allocated JavaVMOption array,
* with some special handling for classpath related arguments */
for (iCurrArg = 0; iCurrArg < iArgCnt; iCurrArg++)
Expand All @@ -100,16 +102,18 @@ void saveJvmOptions(const char *jrePath, const char *mainClass, const char *pcOp
rgcTmp[strlen(rgcTmp)-1] = '\0';
/* If we haven't defined a classpath yet start one, otherwise
* we just append the this classpath to it */
if (g_rgcClsPth[0] == '\0')
if (!rgcClsPth)
{
sprintf(g_rgcClsPth,"-Djava.class.path=%s", rgcTmp);
g_sJavaVMInitArgs.options[iCurrArg - iSkipArgCnt].optionString = g_rgcClsPth;
rgcClsPth = malloc(MAX_ARGS * sizeof(char));
memset(rgcClsPth, 0, MAX_ARGS * sizeof(char));
sprintf(rgcClsPth,"-Djava.class.path=%s", rgcTmp);
g_sJavaVMInitArgs.options[iCurrArg - iSkipArgCnt].optionString = rgcClsPth;
}
else
{
iSkipArgCnt++;
strcat(g_rgcClsPth,";");
strcat(g_rgcClsPth,rgcTmp);
strcat(rgcClsPth,";");
strcat(rgcClsPth,rgcTmp);
}

}
Expand Down
Binary file modified installer/launch4j/launch4j.exe
Binary file not shown.
Binary file modified installer/launch4j/launch4j.jar
Binary file not shown.
Binary file modified installer/launch4j/launch4jc.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions installer/launch4j/maven/assembly/assemble-linux.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<outputDirectory>${finalName}-workdir-linux</outputDirectory>
<includes>
<include>w32api/**/*</include>
<include>w32api_jni/**/*</include>
<include>head/**/*</include>
<include>head_jni_BETA/**/*</include>
</includes>
</fileSet>
</fileSets>
Expand Down
Loading

0 comments on commit 72ba559

Please sign in to comment.