Merge remote-tracking branch 'upstream/master'

master
Graham 4 years ago
commit 843dbb5278
  1. 2
      src/org/jetbrains/java/decompiler/modules/decompiler/IfHelper.java
  2. 2
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java
  3. 50
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
  4. 2
      src/org/jetbrains/java/decompiler/struct/StructClass.java
  5. 5
      test/org/jetbrains/java/decompiler/BulkDecompilationTest.java
  6. BIN
      testData/kt25937.jar
  7. 3
      testData/kt25937/META-INF/MANIFEST.MF
  8. 26
      testData/kt25937/kt/Kt25937Kt.java
  9. 49
      testData/kt25937/kt/Kt25937_1Kt.java

@ -100,7 +100,7 @@ public class IfHelper {
break; break;
} }
res |= true; res = true;
} }
return res; return res;

@ -28,7 +28,7 @@ public class ConstExprent extends Exprent {
CHAR_ESCAPES.put(0xC, "\\f"); /* \u000c: form feed FF */ CHAR_ESCAPES.put(0xC, "\\f"); /* \u000c: form feed FF */
CHAR_ESCAPES.put(0xD, "\\r"); /* \u000d: carriage return CR */ CHAR_ESCAPES.put(0xD, "\\r"); /* \u000d: carriage return CR */
//CHAR_ESCAPES.put(0x22, "\\\""); /* \u0022: double quote " */ //CHAR_ESCAPES.put(0x22, "\\\""); /* \u0022: double quote " */
CHAR_ESCAPES.put(0x27, "\\\'"); /* \u0027: single quote ' */ CHAR_ESCAPES.put(0x27, "\\'"); /* \u0027: single quote ' */
CHAR_ESCAPES.put(0x5C, "\\\\"); /* \u005c: backslash \ */ CHAR_ESCAPES.put(0x5C, "\\\\"); /* \u005c: backslash \ */
} }

@ -143,6 +143,8 @@ public class NewExprent extends Exprent {
if (anonymous) { if (anonymous) {
ClassNode child = DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value); ClassNode child = DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value);
boolean selfReference = DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE) == child;
// IDEA-204310 - avoid backtracking later on for lambdas (causes spurious imports) // IDEA-204310 - avoid backtracking later on for lambdas (causes spurious imports)
if (!enumConst && (!lambda || DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS))) { if (!enumConst && (!lambda || DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS))) {
String enclosing = null; String enclosing = null;
@ -156,33 +158,37 @@ public class NewExprent extends Exprent {
buf.append("new "); buf.append("new ");
String typename = ExprProcessor.getCastTypeName(child.anonymousClassType); if (selfReference) {
if (enclosing != null) { buf.append("<anonymous constructor>");
ClassNode anonymousNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(child.anonymousClassType.value); } else {
if (anonymousNode != null) { String typename = ExprProcessor.getCastTypeName(child.anonymousClassType);
typename = anonymousNode.simpleName; if (enclosing != null) {
} ClassNode anonymousNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(child.anonymousClassType.value);
else { if (anonymousNode != null) {
typename = typename.substring(typename.lastIndexOf('.') + 1); typename = anonymousNode.simpleName;
}
else {
typename = typename.substring(typename.lastIndexOf('.') + 1);
}
} }
}
GenericClassDescriptor descriptor = ClassWriter.getGenericClassDescriptor(child.classStruct); GenericClassDescriptor descriptor = ClassWriter.getGenericClassDescriptor(child.classStruct);
if (descriptor != null) { if (descriptor != null) {
if (descriptor.superinterfaces.isEmpty()) { if (descriptor.superinterfaces.isEmpty()) {
buf.append(GenericMain.getGenericCastTypeName(descriptor.superclass)); buf.append(GenericMain.getGenericCastTypeName(descriptor.superclass));
}
else {
if (descriptor.superinterfaces.size() > 1 && !lambda) {
DecompilerContext.getLogger().writeMessage("Inconsistent anonymous class signature: " + child.classStruct.qualifiedName,
IFernflowerLogger.Severity.WARN);
}
buf.append(GenericMain.getGenericCastTypeName(descriptor.superinterfaces.get(0)));
}
} }
else { else {
if (descriptor.superinterfaces.size() > 1 && !lambda) { buf.append(typename);
DecompilerContext.getLogger().writeMessage("Inconsistent anonymous class signature: " + child.classStruct.qualifiedName,
IFernflowerLogger.Severity.WARN);
}
buf.append(GenericMain.getGenericCastTypeName(descriptor.superinterfaces.get(0)));
} }
} }
else {
buf.append(typename);
}
} }
buf.append('('); buf.append('(');
@ -226,7 +232,7 @@ public class NewExprent extends Exprent {
buf.append(clsBuf); buf.append(clsBuf);
tracer.incrementCurrentSourceLine(clsBuf.countLines()); tracer.incrementCurrentSourceLine(clsBuf.countLines());
} }
else { else if (!selfReference) {
TextBuffer clsBuf = new TextBuffer(); TextBuffer clsBuf = new TextBuffer();
new ClassWriter().classToJava(child, clsBuf, indent, tracer); new ClassWriter().classToJava(child, clsBuf, indent, tracer);
buf.append(clsBuf); buf.append(clsBuf);

@ -166,7 +166,7 @@ public class StructClass extends StructMember {
} }
public int getBytecodeVersion() { public int getBytecodeVersion() {
return majorVersion < CodeConstants.BYTECODE_JAVA_LE_4 ? CodeConstants.BYTECODE_JAVA_LE_4 : majorVersion; return Math.max(majorVersion, CodeConstants.BYTECODE_JAVA_LE_4);
} }
@Override @Override

@ -47,6 +47,11 @@ public class BulkDecompilationTest {
doTestJar("bulk"); doTestJar("bulk");
} }
@Test
public void testKtJar() {
doTestJar("kt25937");
}
@Test @Test
public void testObfuscated() { public void testObfuscated() {
doTestJar("obfuscated"); doTestJar("obfuscated");

Binary file not shown.

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Created-By: 1.8.0_171 (Oracle Corporation)

@ -0,0 +1,26 @@
package kt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
@Metadata(
mv = {1, 1, 16},
bv = {1, 0, 3},
k = 2,
d1 = {"\u0000\u001c\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\u001a,\u0010\u0000\u001a\u00020\u00012\u001c\u0010\u0002\u001a\u0018\b\u0001\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00050\u0004\u0012\u0006\u0012\u0004\u0018\u00010\u00060\u0003ø\u0001\u0000¢\u0006\u0002\u0010\u0007\u001a\u0006\u0010\b\u001a\u00020\u0001\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\t"},
d2 = {"callSuspendBlock", "", "block", "Lkotlin/Function1;", "Lkotlin/coroutines/Continuation;", "", "", "(Lkotlin/jvm/functions/Function1;)I", "callSuspendBlockGood", "kotlinx-test"}
)
public final class Kt25937Kt {
public static final int callSuspendBlock(@NotNull Function1<? super Continuation<? super Unit>, ? extends Object> block) {
Intrinsics.checkParameterIsNotNull(block, "block");
return 1;
}
public static final int callSuspendBlockGood() {
return 1;
}
}

@ -0,0 +1,49 @@
package kt;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Metadata(
mv = {1, 1, 17},
bv = {1, 0, 3},
k = 2,
d1 = {"\u0000\b\n\u0000\n\u0002\u0010\b\n\u0000\u001a\u0006\u0010\u0000\u001a\u00020\u0001¨\u0006\u0002"},
d2 = {"some1", "", "ide-kotlin-test.kotlinx-test.main"}
)
public final class Kt25937_1Kt {
public static final int some1() {
return Kt25937Kt.callSuspendBlock((Function1)(new Function1<Continuation<? super Unit>, Object>((Continuation)null) {
int label;
@Nullable
public final Object invokeSuspend(@NotNull Object $result) {
Object var2 = IntrinsicsKt.getCOROUTINE_SUSPENDED();
switch(this.label) {
case 0:
ResultKt.throwOnFailure($result);
return Unit.INSTANCE;
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
}
@NotNull
public final Continuation<Unit> create(@NotNull Continuation<?> completion) {
Intrinsics.checkParameterIsNotNull(completion, "completion");
Function1 var2 = new <anonymous constructor>(completion);
return var2;
}
public final Object invoke(Object var1) {
return ((<undefinedtype>)this.create((Continuation)var1)).invokeSuspend(Unit.INSTANCE);
}
}));
}
}
Loading…
Cancel
Save