From 6f70918c3b44fb66739da0254cb266e220531487 Mon Sep 17 00:00:00 2001 From: upnotes Date: Fri, 10 Aug 2018 15:05:01 +0200 Subject: [PATCH] Addressed review comments + additional test --- .../decompiler/main/extern/IFernflowerPreferences.java | 4 ++-- .../decompiler/main/rels/MethodProcessorRunnable.java | 4 ++-- testData/src/pkg/TestPrivateEmptyConstructor.java | 1 + testData/src/pkg/TestSynchronizedUnprotected.kt | 8 ++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 testData/src/pkg/TestSynchronizedUnprotected.kt diff --git a/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java b/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java index 3c1f622..612b425 100644 --- a/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java +++ b/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java @@ -17,7 +17,7 @@ public interface IFernflowerPreferences { String HIDE_DEFAULT_CONSTRUCTOR = "hdc"; String DECOMPILE_GENERIC_SIGNATURES = "dgs"; String NO_EXCEPTIONS_RETURN = "ner"; - String KT_SYNCHRONIZED_MONITOR = "ksm"; + String ENSURE_SYNCHRONIZED_MONITOR = "esm"; String DECOMPILE_ENUM = "den"; String REMOVE_GET_CLASS_NEW = "rgn"; String LITERALS_AS_IS = "lit"; @@ -62,7 +62,7 @@ public interface IFernflowerPreferences { defaults.put(HIDE_DEFAULT_CONSTRUCTOR, "1"); defaults.put(DECOMPILE_GENERIC_SIGNATURES, "0"); defaults.put(NO_EXCEPTIONS_RETURN, "1"); - defaults.put(KT_SYNCHRONIZED_MONITOR, "1"); + defaults.put(ENSURE_SYNCHRONIZED_MONITOR, "1"); defaults.put(DECOMPILE_ENUM, "1"); defaults.put(REMOVE_GET_CLASS_NEW, "1"); defaults.put(LITERALS_AS_IS, "0"); diff --git a/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java b/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java index cc5417a..32cdbc3 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java +++ b/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java @@ -88,8 +88,8 @@ public class MethodProcessorRunnable implements Runnable { ExceptionDeobfuscator.removeEmptyRanges(graph); } - if (DecompilerContext.getOption(IFernflowerPreferences.KT_SYNCHRONIZED_MONITOR)) { - // special case: search for 'synchronized' ranges w/o monitorexit instruction (generated by the Kotlin compiler) + if (DecompilerContext.getOption(IFernflowerPreferences.ENSURE_SYNCHRONIZED_MONITOR)) { + // special case: search for 'synchronized' ranges w/o monitorexit instruction (as generated by Kotlin and Scala) DeadCodeHelper.extendSynchronizedRangeToMonitorexit(graph); } diff --git a/testData/src/pkg/TestPrivateEmptyConstructor.java b/testData/src/pkg/TestPrivateEmptyConstructor.java index 2a54b6a..3548536 100644 --- a/testData/src/pkg/TestPrivateEmptyConstructor.java +++ b/testData/src/pkg/TestPrivateEmptyConstructor.java @@ -1,3 +1,4 @@ +package pkg; public final class PrivateEmptyConstructor { diff --git a/testData/src/pkg/TestSynchronizedUnprotected.kt b/testData/src/pkg/TestSynchronizedUnprotected.kt new file mode 100644 index 0000000..a6c04e9 --- /dev/null +++ b/testData/src/pkg/TestSynchronizedUnprotected.kt @@ -0,0 +1,8 @@ + +object TestSynchronizedUnprotected { + fun test() { + synchronized(this) { + println("Boom") + } + } +} \ No newline at end of file