未验证 提交 14fd88b2 编写于 作者: S Skylot

fix(gui): add volatile and update sync for decompiler field in wrapper (#1518)

上级 20657e8b
......@@ -39,11 +39,14 @@ import static jadx.core.dex.nodes.ProcessState.GENERATED_AND_UNLOADED;
import static jadx.core.dex.nodes.ProcessState.NOT_LOADED;
import static jadx.core.dex.nodes.ProcessState.PROCESS_COMPLETE;
@SuppressWarnings("ConstantConditions")
public class JadxWrapper {
private static final Logger LOG = LoggerFactory.getLogger(JadxWrapper.class);
private static final Object DECOMPILER_UPDATE_SYNC = new Object();
private final MainWindow mainWindow;
private @Nullable JadxDecompiler decompiler;
private volatile @Nullable JadxDecompiler decompiler;
public JadxWrapper(MainWindow mainWindow) {
this.mainWindow = mainWindow;
......@@ -52,6 +55,7 @@ public class JadxWrapper {
public void open() {
close();
try {
synchronized (DECOMPILER_UPDATE_SYNC) {
JadxProject project = getProject();
JadxArgs jadxArgs = getSettings().toJadxArgs();
jadxArgs.setInputFiles(FileUtils.toFiles(project.getFilePaths()));
......@@ -60,6 +64,7 @@ public class JadxWrapper {
this.decompiler = new JadxDecompiler(jadxArgs);
this.decompiler.load();
initCodeCache();
}
} catch (Exception e) {
LOG.error("Jadx decompiler wrapper init error", e);
close();
......@@ -77,13 +82,15 @@ public class JadxWrapper {
public void close() {
try {
synchronized (DECOMPILER_UPDATE_SYNC) {
if (decompiler != null) {
decompiler.close();
decompiler = null;
}
}
} catch (Exception e) {
LOG.error("Jadx decompiler close error", e);
} finally {
decompiler = null;
mainWindow.getCacheObject().reset();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册