IDEA-143614 Could not run IDEA with debug parameters in idea.vmoptions on OSX

IDEA-141559 IDEA crashes natively on startup when idea.vmoptions has line for debugging and port is already in use
IDEA-139969 Show error message if idea.exe.vmoptions not found
IDEA-138637 idea.log logs JVM options from boths .vmoptions file (custom and bundled)
IDEA-136975 Change the order of .vmoptions file processing from default to more specific
This commit is contained in:
Vladimir.Orlov
2015-08-19 14:35:44 +03:00
parent 4fa9140f85
commit da528cb7f9
6 changed files with 68 additions and 47 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -136,18 +136,22 @@ if [ -n "$@@product_uc@@_PROPERTIES" ]; then
IDE_PROPERTIES_PROPERTY="-Didea.properties.file=$@@product_uc@@_PROPERTIES"
fi
vm_options_file="$IDE_BIN_HOME/@@vm_options@@$BITS.vmoptions"
user_vm_options_file="$HOME/.@@system_selector@@/@@vm_options@@$BITS.vmoptions"
if [ -r "$user_vm_options_file" ]; then
vm_options_file="$user_vm_options_file"
fi
if [ -n "$@@product_uc@@_VM_OPTIONS" ]; then
vm_options_file="$@@product_uc@@_VM_OPTIONS"
fi
VM_OPTIONS=""
VM_OPTIONS_FILES_USED=""
for vm_opts_file in "$IDE_BIN_HOME/@@vm_options@@$BITS.vmoptions" "$OS_SPECIFIC_BIN_DIR/@@vm_options@@$BITS.vmoptions" "$HOME/.@@system_selector@@/@@vm_options@@$BITS.vmoptions" "$@@product_uc@@_VM_OPTIONS"; do
if [ -r "$vm_opts_file" ]; then
VM_OPTIONS_DATA=`"$CAT" "$vm_opts_file" | "$GREP" -v "^#.*" | "$TR" '\n' ' '`
if [ -r "$vm_options_file" ]; then
VM_OPTIONS_DATA=`"$CAT" "$vm_options_file" | "$GREP" -v "^#.*" | "$TR" '\n' ' '`
VM_OPTIONS="$VM_OPTIONS $VM_OPTIONS_DATA"
if [ -n "$VM_OPTIONS_FILES_USED" ]; then
VM_OPTIONS_FILES_USED="$VM_OPTIONS_FILES_USED,"
fi
VM_OPTIONS_FILES_USED="$VM_OPTIONS_FILES_USED$vm_opts_file"
fi
done
else
message "Cannot find VM options file."
fi
IS_EAP="@@isEap@@"
if [ "$IS_EAP" = "true" ]; then
@@ -172,7 +176,7 @@ LD_LIBRARY_PATH="$IDE_BIN_HOME:$LD_LIBRARY_PATH" "$JDK/jre/bin/java" \
$AGENT \
"-Xbootclasspath/a:$IDE_HOME/lib/boot.jar" \
-classpath "$CLASSPATH" \
$VM_OPTIONS "-Djb.vmOptionsFile=$VM_OPTIONS_FILES_USED" \
$VM_OPTIONS "-Djb.vmOptionsFile=$vm_options_file" \
"-XX:ErrorFile=$HOME/java_error_in_@@product_uc@@_%p.log" \
-Djb.restart.code=88 -Didea.paths.selector=@@system_selector@@ \
$IDE_PROPERTIES_PROPERTY \

Binary file not shown.

View File

@@ -375,23 +375,28 @@ NSString *getOverrideVMOptionsPath() {
}
NSArray *parseVMOptions() {
NSArray *files = @[getApplicationVMOptionsPath(),
getUserVMOptionsPath(),
getOverrideVMOptionsPath()];
NSString *vmOptionsFile = getApplicationVMOptionsPath();
NSString *userVMOptiosFile = getUserVMOptionsPath();
NSString *envVarVMOptiosFile = getOverrideVMOptionsPath();
if ([[NSFileManager defaultManager] fileExistsAtPath:userVMOptiosFile]) {
vmOptionsFile = userVMOptiosFile;
}
if ([[NSFileManager defaultManager] fileExistsAtPath:envVarVMOptiosFile]) {
vmOptionsFile = envVarVMOptiosFile;
}
NSMutableArray *options = [NSMutableArray array];
NSMutableArray *used = [NSMutableArray array];
for (NSString *file in files) {
NSLog(@"Processing VMOptions file at %@", file);
NSArray *contents = [VMOptionsReader readFile:file];
if (contents != nil) {
NSLog(@"Done");
[used addObject:file];
[options addObjectsFromArray:contents];
} else {
NSLog(@"No content found");
}
NSLog(@"Processing VMOptions file at %@", vmOptionsFile);
NSArray *contents = [VMOptionsReader readFile:vmOptionsFile];
if (contents != nil) {
NSLog(@"Done");
[used addObject:vmOptionsFile];
[options addObjectsFromArray:contents];
} else {
NSLog(@"No content found at %@ ", vmOptionsFile);
}
[options addObject:[NSString stringWithFormat:@"-Djb.vmOptionsFile=%@", [used componentsJoinedByString:@","]]];

View File

@@ -374,6 +374,29 @@ bool AddClassPathOptions(std::vector<std::string>& vmOptionLines)
return true;
}
//return VMOptions from one of the files in the following order:
//$<IDE-NAME>_VM_OPTIONS
//$CONFIG_DIRECTORY/<ide-name>[64][.exe].vmoptions
//bin/<ide-name>[64][.exe].vmoptions
bool FindValidVMOptions(std::vector<std::wstring> files, std::wstring& used, std::vector<std::string>& vmOptionLines)
{
if (files.size() != 0)
{
for (int i = 0; i < files.size(); i++)
{
if (GetFileAttributes(files[i].c_str()) != INVALID_FILE_ATTRIBUTES)
{
if (LoadVMOptionsFile(files[i].c_str(), vmOptionLines))
{
used += (used.size() ? L"," : L"") + files[i];
return true;
}
}
}
}
return false;
}
void AddPredefinedVMOptions(std::vector<std::string>& vmOptionLines)
{
std::string vmOptions = LoadStdString(IDS_VM_OPTIONS);
@@ -403,8 +426,13 @@ bool LoadVMOptions()
GetModuleFileName(NULL, buffer, _MAX_PATH);
std::wstring module(buffer);
files.push_back(module + L".vmoptions");
if (LoadString(hInst, IDS_VM_OPTIONS_ENV_VAR, buffer, _MAX_PATH))
{
if (GetEnvironmentVariableW(buffer, copy, _MAX_PATH)) {
ExpandEnvironmentStrings(copy, buffer, _MAX_PATH);
files.push_back(std::wstring(buffer));
}
}
if (LoadString(hInst, IDS_VM_OPTIONS_PATH, buffer, _MAX_PATH))
{
@@ -413,33 +441,17 @@ bool LoadVMOptions()
files.push_back(selector + module.substr(module.find_last_of('\\')) + L".vmoptions");
}
if (LoadString(hInst, IDS_VM_OPTIONS_ENV_VAR, buffer, _MAX_PATH))
{
if (GetEnvironmentVariableW(buffer, copy, _MAX_PATH)) {
ExpandEnvironmentStrings(copy, buffer, _MAX_PATH);
files.push_back(std::wstring(buffer));
}
}
files.push_back(module + L".vmoptions");
std::wstring used;
std::vector<std::string> vmOptionLines;
if (files.size() == 0) {
if (!FindValidVMOptions(files, used, vmOptionLines))
{
std::string error = LoadStdString(IDS_ERROR_LAUNCHING_APP);
MessageBoxA(NULL, "Cannot find VM options file", error.c_str(), MB_OK);
return false;
}
std::wstring used;
std::vector<std::string> vmOptionLines;
for (int i = 0; i < files.size(); i++)
{
if (GetFileAttributes(files[i].c_str()) != INVALID_FILE_ATTRIBUTES)
{
if (LoadVMOptionsFile(files[i].c_str(), vmOptionLines))
{
used += (used.size() ? L"," : L"") + files[i];
}
}
}
vmOptionLines.push_back(std::string("-Djb.vmOptions=") + EncodeWideACP(used));
if (!AddClassPathOptions(vmOptionLines)) return false;