Commit 9688eaf9 authored by Roman Shevchenko's avatar Roman Shevchenko
Browse files

[platform] allows the IDE to shutdown gracefully when JNA isn't loaded (IDEA-159824)

parent 687d63de
Showing with 39 additions and 4 deletions
+39 -4
......@@ -19,6 +19,7 @@ import com.intellij.ide.customize.CustomizeIDEWizardDialog;
import com.intellij.ide.customize.CustomizeIDEWizardStepsProvider;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.startupWizard.StartupWizard;
import com.intellij.jna.JnaLoader;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.ConfigImportHelper;
......@@ -37,7 +38,6 @@ import com.intellij.util.Consumer;
import com.intellij.util.EnvironmentUtil;
import com.intellij.util.PlatformUtils;
import com.intellij.util.lang.UrlClassLoader;
import com.sun.jna.Native;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.PatternLayout;
......@@ -340,8 +340,7 @@ public class StartupUtil {
System.setProperty("jna.nosys", "true"); // prefer bundled JNA dispatcher lib
}
try {
long t = System.currentTimeMillis();
log.info("JNA library loaded (" + (Native.POINTER_SIZE * 8) + "-bit) in " + (System.currentTimeMillis() - t) + " ms");
JnaLoader.load(log);
}
catch (Throwable t) {
logError(log, "Unable to load JNA library", t);
......
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.jna;
import com.intellij.openapi.diagnostic.Logger;
import com.sun.jna.Native;
public class JnaLoader {
private static volatile boolean ourJnaLoaded = false;
public static void load(Logger logger) {
long t = System.currentTimeMillis();
int ptrSize = Native.POINTER_SIZE;
t = System.currentTimeMillis() - t;
logger.info("JNA library (" + (ptrSize << 3) + "-bit) loaded in " + t + " ms");
ourJnaLoaded = true;
}
public static boolean isLoaded() {
return ourJnaLoaded;
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@
*/
package com.intellij.util;
import com.intellij.jna.JnaLoader;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtilRt;
......@@ -46,7 +47,7 @@ public class Restarter {
return true;
}
if (SystemInfo.isWindows) {
return new File(PathManager.getBinPath(), "restarter.exe").exists();
return JnaLoader.isLoaded() && new File(PathManager.getBinPath(), "restarter.exe").exists();
}
if (SystemInfo.isMac) {
return PathManager.getHomePath().contains(".app");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment