|
|
@ -149,8 +149,7 @@ public class ClassWriter { |
|
|
|
|
|
|
|
|
|
|
|
methodLambdaToJava(node, classNode, mt, buffer, indent + 1, !lambdaToAnonymous, tracer); |
|
|
|
methodLambdaToJava(node, classNode, mt, buffer, indent + 1, !lambdaToAnonymous, tracer); |
|
|
|
|
|
|
|
|
|
|
|
InterpreterUtil.appendIndent(buffer, indent); |
|
|
|
buffer.appendIndent(indent).append("}"); |
|
|
|
buffer.append("}"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
finally { |
|
|
|
finally { |
|
|
@ -265,8 +264,7 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
InterpreterUtil.appendIndent(buffer, indent); |
|
|
|
buffer.appendIndent(indent).append('}'); |
|
|
|
buffer.append('}'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (node.type != ClassNode.CLASS_ANONYMOUS) { |
|
|
|
if (node.type != ClassNode.CLASS_ANONYMOUS) { |
|
|
|
buffer.append(lineSeparator); |
|
|
|
buffer.append(lineSeparator); |
|
|
@ -281,7 +279,6 @@ public class ClassWriter { |
|
|
|
|
|
|
|
|
|
|
|
private void writeClassDefinition(ClassNode node, TextBuffer buffer, int indent) { |
|
|
|
private void writeClassDefinition(ClassNode node, TextBuffer buffer, int indent) { |
|
|
|
String lineSeparator = DecompilerContext.getNewLineSeparator(); |
|
|
|
String lineSeparator = DecompilerContext.getNewLineSeparator(); |
|
|
|
String indentString = InterpreterUtil.getIndentString(indent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (node.type == ClassNode.CLASS_ANONYMOUS) { |
|
|
|
if (node.type == ClassNode.CLASS_ANONYMOUS) { |
|
|
|
buffer.append(" {"); |
|
|
|
buffer.append(" {"); |
|
|
@ -300,7 +297,7 @@ public class ClassWriter { |
|
|
|
boolean isAnnotation = (flags & CodeConstants.ACC_ANNOTATION) != 0; |
|
|
|
boolean isAnnotation = (flags & CodeConstants.ACC_ANNOTATION) != 0; |
|
|
|
|
|
|
|
|
|
|
|
if (isDeprecated) { |
|
|
|
if (isDeprecated) { |
|
|
|
appendDeprecation(buffer, indentString, lineSeparator); |
|
|
|
appendDeprecation(buffer, indent, lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (interceptor != null) { |
|
|
|
if (interceptor != null) { |
|
|
@ -309,12 +306,12 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isSynthetic) { |
|
|
|
if (isSynthetic) { |
|
|
|
appendComment(buffer, "synthetic class", indentString, lineSeparator); |
|
|
|
appendComment(buffer, "synthetic class", indent, lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appendAnnotations(buffer, cl, indent, lineSeparator); |
|
|
|
appendAnnotations(buffer, cl, indent, lineSeparator); |
|
|
|
|
|
|
|
|
|
|
|
buffer.append(indentString); |
|
|
|
buffer.appendIndent(indent); |
|
|
|
|
|
|
|
|
|
|
|
if (isEnum) { |
|
|
|
if (isEnum) { |
|
|
|
// remove abstract and final flags (JLS 8.9 Enums)
|
|
|
|
// remove abstract and final flags (JLS 8.9 Enums)
|
|
|
@ -391,7 +388,6 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void fieldToJava(ClassWrapper wrapper, StructClass cl, StructField fd, TextBuffer buffer, int indent, BytecodeMappingTracer tracer) { |
|
|
|
private void fieldToJava(ClassWrapper wrapper, StructClass cl, StructField fd, TextBuffer buffer, int indent, BytecodeMappingTracer tracer) { |
|
|
|
String indentString = InterpreterUtil.getIndentString(indent); |
|
|
|
|
|
|
|
String lineSeparator = DecompilerContext.getNewLineSeparator(); |
|
|
|
String lineSeparator = DecompilerContext.getNewLineSeparator(); |
|
|
|
|
|
|
|
|
|
|
|
boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE); |
|
|
|
boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE); |
|
|
@ -399,7 +395,7 @@ public class ClassWriter { |
|
|
|
boolean isEnum = fd.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM); |
|
|
|
boolean isEnum = fd.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM); |
|
|
|
|
|
|
|
|
|
|
|
if (isDeprecated) { |
|
|
|
if (isDeprecated) { |
|
|
|
appendDeprecation(buffer, indentString, lineSeparator); |
|
|
|
appendDeprecation(buffer, indent, lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (interceptor != null) { |
|
|
|
if (interceptor != null) { |
|
|
@ -408,12 +404,12 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (fd.isSynthetic()) { |
|
|
|
if (fd.isSynthetic()) { |
|
|
|
appendComment(buffer, "synthetic field", indentString, lineSeparator); |
|
|
|
appendComment(buffer, "synthetic field", indent, lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appendAnnotations(buffer, fd, indent, lineSeparator); |
|
|
|
appendAnnotations(buffer, fd, indent, lineSeparator); |
|
|
|
|
|
|
|
|
|
|
|
buffer.append(indentString); |
|
|
|
buffer.appendIndent(indent); |
|
|
|
|
|
|
|
|
|
|
|
if (!isEnum) { |
|
|
|
if (!isEnum) { |
|
|
|
appendModifiers(buffer, fd.getAccessFlags(), FIELD_ALLOWED, isInterface, FIELD_EXCLUDED); |
|
|
|
appendModifiers(buffer, fd.getAccessFlags(), FIELD_ALLOWED, isInterface, FIELD_EXCLUDED); |
|
|
@ -494,7 +490,7 @@ public class ClassWriter { |
|
|
|
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(lambdaNode.lambda_information.method_descriptor); |
|
|
|
MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(lambdaNode.lambda_information.method_descriptor); |
|
|
|
|
|
|
|
|
|
|
|
if (!codeOnly) { |
|
|
|
if (!codeOnly) { |
|
|
|
InterpreterUtil.appendIndent(buffer, indent); |
|
|
|
buffer.appendIndent(indent); |
|
|
|
buffer.append("public "); |
|
|
|
buffer.append("public "); |
|
|
|
buffer.append(method_name); |
|
|
|
buffer.append(method_name); |
|
|
|
buffer.append("("); |
|
|
|
buffer.append("("); |
|
|
@ -547,7 +543,7 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (methodWrapper.decompiledWithErrors) { |
|
|
|
if (methodWrapper.decompiledWithErrors) { |
|
|
|
InterpreterUtil.appendIndent(buffer, indent); |
|
|
|
buffer.appendIndent(indent); |
|
|
|
buffer.append("// $FF: Couldn't be decompiled"); |
|
|
|
buffer.append("// $FF: Couldn't be decompiled"); |
|
|
|
buffer.append(DecompilerContext.getNewLineSeparator()); |
|
|
|
buffer.append(DecompilerContext.getNewLineSeparator()); |
|
|
|
} |
|
|
|
} |
|
|
@ -555,7 +551,7 @@ public class ClassWriter { |
|
|
|
if (!codeOnly) { |
|
|
|
if (!codeOnly) { |
|
|
|
indent -= 1; |
|
|
|
indent -= 1; |
|
|
|
|
|
|
|
|
|
|
|
InterpreterUtil.appendIndent(buffer, indent); |
|
|
|
buffer.appendIndent(indent); |
|
|
|
buffer.append('}'); |
|
|
|
buffer.append('}'); |
|
|
|
buffer.append(DecompilerContext.getNewLineSeparator()); |
|
|
|
buffer.append(DecompilerContext.getNewLineSeparator()); |
|
|
|
} |
|
|
|
} |
|
|
@ -573,7 +569,6 @@ public class ClassWriter { |
|
|
|
boolean hideMethod = false; |
|
|
|
boolean hideMethod = false; |
|
|
|
int start_index_method = buffer.length(); |
|
|
|
int start_index_method = buffer.length(); |
|
|
|
|
|
|
|
|
|
|
|
String indentString = InterpreterUtil.getIndentString(indent); |
|
|
|
|
|
|
|
String lineSeparator = DecompilerContext.getNewLineSeparator(); |
|
|
|
String lineSeparator = DecompilerContext.getNewLineSeparator(); |
|
|
|
|
|
|
|
|
|
|
|
MethodWrapper outerWrapper = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER); |
|
|
|
MethodWrapper outerWrapper = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER); |
|
|
@ -606,7 +601,7 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isDeprecated) { |
|
|
|
if (isDeprecated) { |
|
|
|
appendDeprecation(buffer, indentString, lineSeparator); |
|
|
|
appendDeprecation(buffer, indent, lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (interceptor != null) { |
|
|
|
if (interceptor != null) { |
|
|
@ -617,15 +612,15 @@ public class ClassWriter { |
|
|
|
boolean isSynthetic = (flags & CodeConstants.ACC_SYNTHETIC) != 0 || mt.getAttributes().containsKey("Synthetic"); |
|
|
|
boolean isSynthetic = (flags & CodeConstants.ACC_SYNTHETIC) != 0 || mt.getAttributes().containsKey("Synthetic"); |
|
|
|
boolean isBridge = (flags & CodeConstants.ACC_BRIDGE) != 0; |
|
|
|
boolean isBridge = (flags & CodeConstants.ACC_BRIDGE) != 0; |
|
|
|
if (isSynthetic) { |
|
|
|
if (isSynthetic) { |
|
|
|
appendComment(buffer, "synthetic method", indentString, lineSeparator); |
|
|
|
appendComment(buffer, "synthetic method", indent, lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
if (isBridge) { |
|
|
|
if (isBridge) { |
|
|
|
appendComment(buffer, "bridge method", indentString, lineSeparator); |
|
|
|
appendComment(buffer, "bridge method", indent, lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appendAnnotations(buffer, mt, indent, lineSeparator); |
|
|
|
appendAnnotations(buffer, mt, indent, lineSeparator); |
|
|
|
|
|
|
|
|
|
|
|
buffer.append(indentString); |
|
|
|
buffer.appendIndent(indent); |
|
|
|
|
|
|
|
|
|
|
|
appendModifiers(buffer, flags, METHOD_ALLOWED, isInterface, METHOD_EXCLUDED); |
|
|
|
appendModifiers(buffer, flags, METHOD_ALLOWED, isInterface, METHOD_EXCLUDED); |
|
|
|
|
|
|
|
|
|
|
@ -811,8 +806,7 @@ public class ClassWriter { |
|
|
|
|
|
|
|
|
|
|
|
//TODO: for now only start line set
|
|
|
|
//TODO: for now only start line set
|
|
|
|
buffer.setCurrentLine(startLine); |
|
|
|
buffer.setCurrentLine(startLine); |
|
|
|
buffer.append('{'); |
|
|
|
buffer.append('{').appendLineSeparator(); |
|
|
|
buffer.append(lineSeparator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RootStatement root = wrapper.getMethodWrapper(mt.getName(), mt.getDescriptor()).root; |
|
|
|
RootStatement root = wrapper.getMethodWrapper(mt.getName(), mt.getDescriptor()).root; |
|
|
|
|
|
|
|
|
|
|
@ -834,14 +828,12 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (methodWrapper.decompiledWithErrors) { |
|
|
|
if (methodWrapper.decompiledWithErrors) { |
|
|
|
buffer.append(InterpreterUtil.getIndentString(indent + 1)); |
|
|
|
buffer.appendIndent(indent + 1); |
|
|
|
buffer.append("// $FF: Couldn't be decompiled"); |
|
|
|
buffer.append("// $FF: Couldn't be decompiled"); |
|
|
|
buffer.append(lineSeparator); |
|
|
|
buffer.append(lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
buffer.append(indentString); |
|
|
|
buffer.appendIndent(indent).append('}').appendLineSeparator(); |
|
|
|
buffer.append('}'); |
|
|
|
|
|
|
|
buffer.append(lineSeparator); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
finally { |
|
|
|
finally { |
|
|
@ -872,8 +864,8 @@ public class ClassWriter { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void appendDeprecation(TextBuffer buffer, String indentString, String lineSeparator) { |
|
|
|
private static void appendDeprecation(TextBuffer buffer, int indent, String lineSeparator) { |
|
|
|
buffer.append(indentString).append("/** @deprecated */").append(lineSeparator); |
|
|
|
buffer.appendIndent(indent).append("/** @deprecated */").append(lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private enum MType {CLASS, FIELD, METHOD} |
|
|
|
private enum MType {CLASS, FIELD, METHOD} |
|
|
@ -881,7 +873,7 @@ public class ClassWriter { |
|
|
|
private static void appendRenameComment(TextBuffer buffer, String oldName, MType type, int indent, String lineSeparator) { |
|
|
|
private static void appendRenameComment(TextBuffer buffer, String oldName, MType type, int indent, String lineSeparator) { |
|
|
|
if (oldName == null) return; |
|
|
|
if (oldName == null) return; |
|
|
|
|
|
|
|
|
|
|
|
InterpreterUtil.appendIndent(buffer, indent); |
|
|
|
buffer.appendIndent(indent); |
|
|
|
buffer.append("// $FF: renamed from: "); |
|
|
|
buffer.append("// $FF: renamed from: "); |
|
|
|
|
|
|
|
|
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
@ -926,8 +918,8 @@ public class ClassWriter { |
|
|
|
return typeText; |
|
|
|
return typeText; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void appendComment(TextBuffer buffer, String comment, String indentString, String lineSeparator) { |
|
|
|
private static void appendComment(TextBuffer buffer, String comment, int indent, String lineSeparator) { |
|
|
|
buffer.append(indentString).append("// $FF: ").append(comment).append(lineSeparator); |
|
|
|
buffer.appendIndent(indent).append("// $FF: ").append(comment).append(lineSeparator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static final String[] ANNOTATION_ATTRIBUTES = { |
|
|
|
private static final String[] ANNOTATION_ATTRIBUTES = { |
|
|
|