mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-10 18:38:27 +00:00
8267598: jpackage removes system libraries from java.library.path
Reviewed-by: almatvee, asemenyuk
This commit is contained in:
parent
52d8215a1e
commit
af3df6300e
@ -66,6 +66,7 @@ void launchApp() {
|
||||
appLauncher
|
||||
.setImageRoot(appImageRoot)
|
||||
.setAppDir(FileUtils::mkpath() << appImageRoot << _T("lib/app"))
|
||||
.setLibEnvVariableName(_T("LD_LIBRARY_PATH"))
|
||||
.setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot
|
||||
<< _T("lib/runtime"));
|
||||
} else {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -56,6 +56,7 @@ void initJvmLauncher() {
|
||||
// add backup - older version such as JDK11 have it in jli sub-dir
|
||||
.addJvmLibName(_T("Contents/Home/lib/jli/libjli.dylib"))
|
||||
.setAppDir(FileUtils::mkpath() << appImageRoot << _T("Contents/app"))
|
||||
.setLibEnvVariableName(_T("DYLD_LIBRARY_PATH"))
|
||||
.setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot
|
||||
<< _T("Contents/runtime"))
|
||||
.createJvmLauncher();
|
||||
|
||||
@ -112,14 +112,14 @@ Jvm* AppLauncher::createJvmLauncher() const {
|
||||
PropertyName::arguments, args);
|
||||
}
|
||||
|
||||
SysInfo::setEnvVariable(libEnvVarName, SysInfo::getEnvVariable(
|
||||
std::nothrow, libEnvVarName) + _T(";") + appDirPath);
|
||||
|
||||
std::unique_ptr<Jvm> jvm(new Jvm());
|
||||
|
||||
(*jvm)
|
||||
.setPath(findJvmLib(cfgFile, defaultRuntimePath, jvmLibNames))
|
||||
.addArgument(launcherPath)
|
||||
.addArgument(_T("-Djava.library.path=")
|
||||
+ appDirPath + FileUtils::pathSeparator
|
||||
+ FileUtils::dirname(launcherPath));
|
||||
.addArgument(launcherPath);
|
||||
|
||||
if (initJvmFromCmdlineOnly) {
|
||||
tstring_array::const_iterator argIt = args.begin();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,6 +50,11 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
AppLauncher& setLibEnvVariableName(const tstring& v) {
|
||||
libEnvVarName = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AppLauncher& setInitJvmFromCmdlineOnly(bool v) {
|
||||
initJvmFromCmdlineOnly = v;
|
||||
return *this;
|
||||
@ -69,6 +74,7 @@ private:
|
||||
tstring launcherPath;
|
||||
tstring defaultRuntimePath;
|
||||
tstring appDirPath;
|
||||
tstring libEnvVarName;
|
||||
tstring imageRoot;
|
||||
tstring_array jvmLibNames;
|
||||
bool initJvmFromCmdlineOnly;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -83,10 +83,16 @@ namespace SysInfo {
|
||||
tstring getEnvVariable(const std::nothrow_t&, const tstring& name,
|
||||
const tstring& defValue=tstring());
|
||||
|
||||
/**
|
||||
* Sets the value of environment variable with the given name to the given value.
|
||||
*/
|
||||
void setEnvVariable(const tstring& name, const tstring& value);
|
||||
|
||||
/**
|
||||
* Returns 'true' if environment variable with the given name is set.
|
||||
*/
|
||||
bool isEnvVariableSet(const tstring& name);
|
||||
|
||||
}
|
||||
|
||||
#endif // SYSINFO_H
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,6 +55,10 @@ bool isEnvVariableSet(const tstring& name) {
|
||||
return ::getenv(name.c_str()) != 0;
|
||||
}
|
||||
|
||||
void setEnvVariable(const tstring& name, const tstring& value) {
|
||||
::setenv(name.c_str(), value.c_str(), 1);
|
||||
}
|
||||
|
||||
|
||||
int argc = 0;
|
||||
char** argv = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -145,6 +145,7 @@ void launchApp() {
|
||||
.setImageRoot(appImageRoot)
|
||||
.addJvmLibName(_T("bin\\jli.dll"))
|
||||
.setAppDir(FileUtils::mkpath() << appImageRoot << _T("app"))
|
||||
.setLibEnvVariableName(_T("PATH"))
|
||||
.setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot
|
||||
<< _T("runtime"))
|
||||
.createJvmLauncher());
|
||||
|
||||
@ -122,6 +122,10 @@ void setEnvVariable(const tstring& name, const tstring& value)
|
||||
<< name << ", " << value
|
||||
<< ") failed", SetEnvironmentVariable));
|
||||
}
|
||||
|
||||
if (0 != _tputenv_s(name.c_str(), value.c_str())) {
|
||||
JP_THROW(tstrings::any() << "_tputenv_s(" << name << ", " << value << ") failed: " << lastCRTError());
|
||||
}
|
||||
}
|
||||
|
||||
tstring getCurrentModulePath()
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,8 +43,6 @@ namespace SysInfo {
|
||||
// Returns handle of the current module (exe or dll).
|
||||
// The function assumes this code is statically linked to the module.
|
||||
HMODULE getCurrentModuleHandle();
|
||||
|
||||
void setEnvVariable(const tstring& name, const tstring& value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user