summaryrefslogtreecommitdiffstats
path: root/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java')
-rw-r--r--src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
index 395df1b..416b831 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
@@ -28,9 +28,6 @@ import org.jetbrains.java.decompiler.struct.gen.VarType;
import org.jetbrains.java.decompiler.util.InterpreterUtil;
import org.jetbrains.java.decompiler.util.ListStack;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -260,29 +257,16 @@ public class NewExprent extends Exprent {
buf.setLength(0);
}
- StringWriter strwriter = new StringWriter();
- BufferedWriter bufstrwriter = new BufferedWriter(strwriter);
-
- ClassWriter clwriter = new ClassWriter();
- try {
- if (lambda) {
- clwriter.classLambdaToJava(child, bufstrwriter, (constructor == null ? null : constructor.getInstance()), indent);
- }
- else {
- clwriter.classToJava(child, bufstrwriter, indent);
+ if (lambda) {
+ if (!DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS)) {
+ buf.setLength(0); // remove the usual 'new <class>()', it will be replaced with lambda style '() ->'
}
- bufstrwriter.flush();
- }
- catch (IOException ex) {
- throw new RuntimeException(ex);
+ Exprent methodObject = constructor == null ? null : constructor.getInstance();
+ new ClassWriter().classLambdaToJava(child, buf, methodObject, indent);
}
-
- if (lambda && !DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS)) {
- buf.setLength(0); // remove the usual 'new <class>()', it will
- // be replaced with lambda style '() ->'
+ else {
+ new ClassWriter().classToJava(child, buf, indent);
}
-
- buf.append(strwriter.toString());
}
else if (directArrayInit) {
VarType leftType = newtype.copy();
@@ -293,10 +277,7 @@ public class NewExprent extends Exprent {
if (i > 0) {
buf.append(", ");
}
- StringBuilder buff = new StringBuilder();
- ExprProcessor.getCastedExprent(lstArrayElements.get(i), leftType, buff, indent, false);
-
- buf.append(buff);
+ ExprProcessor.getCastedExprent(lstArrayElements.get(i), leftType, buf, indent, false);
}
buf.append("}");
}