Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added back the old debugging information to the tree weaver, and move…

…d all the new ASM output to a new debug level, dev
  • Loading branch information...
commit c8ab1987c120e320c83a29207a02b655a3050665 1 parent e140474
@hraberg authored
View
7 build.xml
@@ -93,6 +93,7 @@
<jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath refid="enumerable.test.classpath" />
<batchtest todir="target/junit">
@@ -120,6 +121,7 @@
<arg value="target/enumerable-test-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath refid="enumerable.test.classpath" />
</java>
@@ -130,6 +132,7 @@
<junit fork="yes" forkmode="once" printsummary="withOutAndErr" failureproperty="tests.failed">
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath refid="enumerable.classpath" />
<classpath location="target/enumerable-test-${enumerable.version}.jar" />
@@ -153,6 +156,7 @@
<jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath location="target/example-classes" />
</java>
@@ -163,6 +167,7 @@
<jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="true" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath location="target/example-classes" />
<classpath>
@@ -176,6 +181,7 @@
<arg value="lambda.enumerable.EnumerableExample" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath refid="enumerable.example.classpath" />
</java>
@@ -186,6 +192,7 @@
<jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath refid="enumerable.example.classpath" />
</java>
View
1  lambda.weaving.properties
@@ -1,4 +1,5 @@
lambda.weaving.debug=false
lambda.weaving.debug.classes.dir=target/generated-classes
+ lambda.weaving.debug.dev=false
lambda.weaving.tree=false
lambda.weaving.skipped.packages=
View
3  src/example/project/build.xml
@@ -23,6 +23,7 @@
<arg value="target/classes" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath location="../enumerable-agent-${enumerable.version}.jar" />
<classpath location="target/classes" />
@@ -33,6 +34,7 @@
<java fork="yes" classname="lambda.enumerable.EnumerableExample" failonerror="yes">
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath location="../enumerable-agent-${enumerable.version}.jar" />
<classpath location="target/classes" />
@@ -54,6 +56,7 @@
<jvmarg value="-javaagent:../enumerable-agent-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
+ <sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath location="target/classes" />
</java>
View
6 src/main/java/lambda/weaving/Debug.java
@@ -4,6 +4,7 @@
public class Debug {
public static boolean debug = Boolean.valueOf(getProperty("lambda.weaving.debug"));
+ public static boolean devDebug = Boolean.valueOf(getProperty("lambda.weaving.debug.dev"));
static String debugIndentation = "";
public static void debugIndent() {
@@ -18,4 +19,9 @@ public static void debug(String msg) {
if (debug)
out.println(debugIndentation + msg);
}
+
+ public static void devDebug(String msg) {
+ if (devDebug)
+ out.println(debugIndentation + msg);
+ }
}
View
231 src/main/java/lambda/weaving/tree/LambdaTreeWeaver.java
@@ -9,12 +9,12 @@
import static org.objectweb.asm.tree.AbstractInsnNode.*;
import java.io.IOException;
-import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -64,8 +64,6 @@
Map<String, MethodNode> methodsThatNeedStaticAccessMethod = new HashMap<String, MethodNode>();
ClassReader cr;
- StringWriter errors = new StringWriter();
-
LambdaTreeWeaver(ClassReader cr) {
this.cr = cr;
}
@@ -79,8 +77,8 @@ LambdaTreeWeaver analyze() {
c = new ClassNode();
cr.accept(c, EXPAND_FRAMES);
- debug(c.name);
- debug("");
+ devDebug(c.name);
+ devDebug("");
for (MethodNode m : (List<MethodNode>) c.methods) {
MethodAnalyzer ma = new MethodAnalyzer(m);
@@ -89,7 +87,6 @@ LambdaTreeWeaver analyze() {
}
return this;
} catch (Exception e) {
- out.println(errors);
throw uncheck(e);
}
}
@@ -99,12 +96,19 @@ ClassNode transform() {
if (c == null)
analyze();
- for (MethodAnalyzer ma : (methods))
- ma.transform();
+ debug("transforming " + getObjectType(c.name).getClassName());
+
+ for (MethodAnalyzer ma : (methods)) {
+ try {
+ debugIndent();
+ ma.transform();
+ } finally {
+ debugDedent();
+ }
+ }
return c;
} catch (IOException e) {
- out.println(errors);
throw uncheck(e);
}
}
@@ -125,7 +129,9 @@ boolean hasLambdas() {
class MethodAnalyzer {
MethodNode m;
+ Method method;
Frame[] frames;
+ int currentLambda = 0;
List<LambdaAnalyzer> lambdas = new ArrayList<LambdaAnalyzer>();
Map<String, LocalVariableNode> methodLocals = new LinkedHashMap<String, LocalVariableNode>();
@@ -133,13 +139,19 @@ boolean hasLambdas() {
MethodAnalyzer(MethodNode m) {
this.m = m;
+ method = new Method(m.name, m.desc);
}
void transform() throws IOException {
if (lambdas.isEmpty())
return;
- int currentLambda = 0;
+ debug("processing " + method);
+ Collections.sort(lambdas, new Comparator<LambdaAnalyzer>() {
+ public int compare(LambdaAnalyzer o1, LambdaAnalyzer o2) {
+ return o1.start - o2.start;
+ }
+ });
InsnList instructions = m.instructions;
@@ -151,16 +163,20 @@ void transform() throws IOException {
if (currentLambda < lambdas.size() && i == lambdas.get(currentLambda).start) {
LambdaAnalyzer lambda = lambdas.get(currentLambda);
- lambda.transform(instructions);
- lambda.instantiate(m);
-
i = lambdas.get(currentLambda).end;
-
currentLambda++;
+ try {
+ debugIndent();
+ lambda.transform(instructions);
+ } finally {
+ debugDedent();
+ }
+
+ lambda.instantiate(m);
+
} else if (n.getType() == VAR_INSN) {
VarInsnNode vin = (VarInsnNode) n;
-
LocalVariableNode local = getLocalVariable(vin.var);
if (local != null && getLocalsMutableFromLambdas().containsKey(local.name)) {
@@ -192,25 +208,18 @@ void transform() throws IOException {
}
m.visitMaxs(0, 0);
- debug("after ================= ");
- print(m, debug ? new OutputStreamWriter(out) : errors);
+ devDebug("after ================= ");
+ devDebugAsm(m);
}
LocalVariableNode getLocalVariable(int var) {
if (var < m.localVariables.size())
return (LocalVariableNode) m.localVariables.get(var);
- // for (LocalVariableNode local : (List<LocalVariableNode>)
- // m.localVariables) {
- // if (local.index == var)
- // return local;
- // }
return null;
}
void analyze() throws Exception {
- debug(m.name + m.desc);
- StringWriter before = new StringWriter();
- print(m, before);
+ devDebug(m.name + m.desc);
frames = new Analyzer(new BasicInterpreter()).analyze(c.name, m);
@@ -242,9 +251,9 @@ void analyze() throws Exception {
}
if (!lambdas.isEmpty()) {
- debug("");
- debug("before ================ ");
- debug(before.toString());
+ devDebug("");
+ devDebug("before ================ ");
+ devDebugAsm(m);
}
}
@@ -471,6 +480,8 @@ else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE)
ClassNode lambda;
MethodNode saMethod;
+ ASMifierMethodVisitor devDebugAsm = new ASMifierMethodVisitor();
+
LambdaAnalyzer(int id, int line, MethodInsnNode mi, int start, int end) {
this.id = id;
this.line = line;
@@ -489,7 +500,9 @@ else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE)
lambdaType = resolveLambdaType();
}
- void transform(InsnList insns) throws IOException {
+ void transform(InsnList instructions) throws IOException {
+ debugLambdaStart();
+
lambda = new ClassNode();
lambda.visit(V1_5, ACC_FINAL | ACC_SYNTHETIC, lambdaClass(), null,
getSuperType().getInternalName(), getLambdaInterfaces());
@@ -499,10 +512,21 @@ void transform(InsnList insns) throws IOException {
for (Map.Entry<String, int[]> defaultParameter : parametersWithDefaultValue.entrySet())
captureDefaultParameterValue(defaultParameter.getKey(), defaultParameter.getValue()[0],
- defaultParameter.getValue()[1], insns);
+ defaultParameter.getValue()[1], instructions);
for (int i = start; i <= end; i++) {
- AbstractInsnNode n = insns.get(i);
+ AbstractInsnNode n = instructions.get(i);
+
+ if (currentLambda < lambdas.size() && i == lambdas.get(currentLambda).start) {
+ System.out.println("TRYING TO CREATE LAMBDA INSIDE LAMBDA");
+ LambdaAnalyzer lambda = lambdas.get(currentLambda);
+
+ i = lambdas.get(currentLambda).end;
+ currentLambda++;
+
+ lambda.transform(instructions);
+ lambda.instantiate(saMethod);
+ }
if (isInSAMBody(i))
handleInsnNodeInSAM(n);
@@ -515,22 +539,32 @@ void transform(InsnList insns) throws IOException {
c.visitInnerClass(lambdaClass(), c.name, null, 0);
- debug("new lambda ================= ");
- if (debug)
+ devDebug("new lambda ================= ");
+ if (devDebug)
lambda.accept(new ASMifierClassVisitor(new PrintWriter(out)));
}
+ void debugLambdaStart() {
+ String localsString = "";
+ if (!locals.isEmpty())
+ localsString = " closing over " + locals.keySet();
+
+ debug("lambda #" + getSimpleClassName(expressionType) + getTypedParametersString() + localsString
+ + " as " + sam + " in " + getSimpleClassName(lambdaType) + " at " + sourceAndLine());
+ }
+
void handleInsnNodeInSAM(AbstractInsnNode n) throws IOException {
int type = n.getType();
if (type == VAR_INSN) {
VarInsnNode vin = (VarInsnNode) n;
LocalVariableNode local = getLocalVariable(vin.var);
+ debugLocalVariableAccess(local, isStoreInstruction(vin));
+
if (local == null) {
n.accept(saMethod);
- }
- if (getLocalsMutableFromLambdas().containsKey(local.name)) {
+ } else if (getLocalsMutableFromLambdas().containsKey(local.name)) {
loadLambdaField(local, toArrayType(getType(local.desc)));
if (isStoreInstruction(vin))
storeTopOfStackInArray(saMethod, getType(local.desc));
@@ -600,6 +634,21 @@ void createAndCallStaticAccessMethodToReplacePrivateFieldAccess(FieldInsnNode fn
mv.visitEnd();
}
+ void debugLocalVariableAccess(LocalVariableNode local, boolean store) {
+ boolean readOnly = methodMutableLocals.containsKey(local.name);
+ debug("variable " + local.name + " " + getSimpleClassName(getType(local.desc))
+ + (store ? (readOnly ? " initalized in" : " stored in") : " read from")
+ + (readOnly ? " final" : " wrapped array in") + " lambda field "
+ + getFieldNameForLocal(local)
+ + (isMethodParameter(local) ? " method parameter " : " local ") + local.name);
+ }
+
+ void debugLambdaParameterAccess(FieldInsnNode fin, int realLocalIndex) {
+ debug("parameter " + fin.name + " " + getSimpleClassName(getType(fin.desc))
+ + (fin.getOpcode() == PUTSTATIC ? " stored in" : " read from") + " lambda local "
+ + realLocalIndex);
+ }
+
void createAndCallStaticAccessMethodToReplacePrivateMethodInvocation(MethodInsnNode mn) {
List<Type> argumentTypes = new ArrayList<Type>();
@@ -652,6 +701,9 @@ void captureDefaultParameterValue(String name, int start, int end, InsnList insn
int parameterIndex = getParameterIndex(name);
Type defaultParameterValueType = getParameterTypes().get(parameterIndex);
+ debug("parameter " + name + " " + getSimpleClassName(defaultParameterValueType)
+ + " has default value");
+
MethodNode mv = (MethodNode) lambda
.visitMethod(ACC_PROTECTED | ACC_SYNTHETIC, "default$" + (parameterIndex + 1),
getMethodDescriptor(getType(Object.class), new Type[0]), null, null);
@@ -678,6 +730,8 @@ void accessParameter(FieldInsnNode fin) {
Type type = getType(fin.desc);
int realLocalIndex = getParameterRealLocalIndex(fin.name);
+ debugLambdaParameterAccess(fin, realLocalIndex);
+
if (fin.getOpcode() == PUTSTATIC) {
saMethod.visitVarInsn(type.getOpcode(ISTORE), realLocalIndex);
@@ -730,6 +784,9 @@ void convertMethodArgumentsToLambdaParameterTypes() {
void convertMethodArgumentIntoLambdaParameterType(int parameterIndex, Type methodParameterType,
Type lambdaParameterType) {
int localIndex = getParameterRealLocalIndex(getParameter(parameterIndex));
+ debug("parameter " + getParameter(parameterIndex) + " converted from "
+ + getSimpleClassName(methodParameterType) + " to "
+ + getSimpleClassName(lambdaParameterType) + " in lambda local " + localIndex);
if (isReference(methodParameterType) && isPrimitive(lambdaParameterType))
unboxLocal(localIndex, lambdaParameterType);
@@ -828,9 +885,13 @@ void returnFromSAMethod() {
void handleBoxingAndUnboxingOfReturnFromLambda(Type returnType, Type lambdaExpressionType) {
if (isPrimitive(returnType) && isReference(lambdaExpressionType)) {
unbox(returnType);
+ debug("unboxed return value with type " + getSimpleClassName(lambdaExpressionType) + " as "
+ + getSimpleClassName(returnType));
}
if (isReference(returnType) && isPrimitive(lambdaExpressionType)) {
box(saMethod, lambdaExpressionType);
+ debug("boxed return value with type " + getSimpleClassName(lambdaExpressionType) + " as "
+ + getSimpleClassName(returnType));
}
}
@@ -939,6 +1000,24 @@ Type getSuperType() throws IOException {
return result.toArray(new Type[0]);
}
+ String getTypedParametersString() {
+ List<String> result = new ArrayList<String>();
+ for (FieldNode parameter : parameters.values())
+ result.add(getSimpleClassName(getType(parameter.desc)) + " " + parameter.name);
+ return toParameterString(result);
+ }
+
+ String toParameterString(Collection<?> parameters) {
+ StringBuffer sb = new StringBuffer(parameters.toString());
+ sb.setCharAt(0, '(');
+ sb.setCharAt(sb.length() - 1, ')');
+ return sb.toString();
+ }
+
+ String sourceAndLine() {
+ return c.sourceFile != null ? "(" + c.sourceFile + ":" + line + ")" : "(Unknown Source)";
+ }
+
Type resolveLambdaType() {
Type lambdaType = newLambdaMethod.getReturnType();
if (getType(Object.class).equals(lambdaType) && m.instructions.size() > end) {
@@ -950,21 +1029,14 @@ Type resolveLambdaType() {
}
void analyze() throws IOException {
- debug("lambda ================ " + start + " -> " + end);
- if (debug)
- out.print("index" + "\t");
- if (debug)
- out.print("stack");
- debug("");
-
- ASMifierMethodVisitor asm = new ASMifierMethodVisitor();
+ devDebug("lambda ================ " + start + " -> " + end);
+ devDebugPrintInstructionHeader();
lastParameterStart = start - 1;
for (int i = start; i <= end; i++) {
AbstractInsnNode n = m.instructions.get(i);
- n.accept(asm);
- printInstruction(i, i - start, frames[i], asm);
+ devDebugPrintInstruction(i, i - start, frames[i], n);
int type = n.getType();
if (type == VAR_INSN)
@@ -1000,29 +1072,46 @@ void analyze() throws IOException {
} else
bodyStart = start;
- debug("end =================== " + start + " -> " + end);
- debug(" body starts at: " + bodyStart);
- debug(" type: " + lambdaType);
- debug(" class: " + lambdaClass());
+ devDebug("end =================== " + start + " -> " + end);
+ devDebug(" body starts at: " + bodyStart);
+ devDebug(" type: " + lambdaType);
+ devDebug(" class: " + lambdaClass());
sam = findSAM(lambdaType);
if (sam != null)
- debug(" SAM is: " + sam);
+ devDebug(" SAM is: " + sam);
else
throw new IllegalStateException("Found no potential abstract method to override");
- debug(" parameters: " + parameters.keySet());
- debug(" method parameter types: " + newLambdaParameterTypes);
- debug(" expression type: " + expressionType);
- debug(" mutable locals: " + getMutableLocals().keySet());
- debug(" final locals: " + locals.keySet());
+ devDebug(" parameters: " + parameters.keySet());
+ devDebug(" method parameter types: " + newLambdaParameterTypes);
+ devDebug(" expression type: " + expressionType);
+ devDebug(" mutable locals: " + getMutableLocals().keySet());
+ devDebug(" final locals: " + locals.keySet());
if (newLambdaParameterTypes.size() != parameters.size())
throw new IllegalStateException("Got " + parameters.keySet() + " as parameters need exactly "
+ newLambdaParameterTypes.size());
}
+ void devDebugPrintInstructionHeader() {
+ if (!devDebug)
+ return;
+ out.print("index" + "\t");
+ out.print("stack");
+ out.println("");
+ }
+
+ void devDebugPrintInstruction(int index, int textIndex, Frame frame, AbstractInsnNode n) {
+ if (!devDebug)
+ return;
+ n.accept(devDebugAsm);
+ out.print(index + "\t");
+ out.print(frame + "\t\t");
+ out.print(devDebugAsm.getText().get(textIndex));
+ }
+
@SuppressWarnings("unchecked")
Method findSAM(Type type) throws IOException {
ClassNode cn = readClassNoCode(type.getInternalName());
@@ -1059,7 +1148,7 @@ void lambdaParameter(int i, FieldInsnNode fin) throws IOException {
lastParameterStart + 1 + (parameterHasConversionAtDefinition ? 1 : 0), i });
lastParameterStart = i;
- debug(" -- defined parameter "
+ devDebug(" -- defined parameter "
+ fin.name
+ " "
+ argumentType.getClassName()
@@ -1069,7 +1158,7 @@ void lambdaParameter(int i, FieldInsnNode fin) throws IOException {
+ newLambdaParameterTypes.size()
+ (hasDefaultValue ? " (has default value starting at " + lastParameterStart + ")" : ""));
} else
- debug(" -- accessed parameter " + fin.name + " " + getType(f.desc).getClassName() + " ("
+ devDebug(" -- accessed parameter " + fin.name + " " + getType(f.desc).getClassName() + " ("
+ (fin.getOpcode() == PUTSTATIC ? "write" : "read") + ")");
}
@@ -1077,7 +1166,7 @@ void localVariable(VarInsnNode vin) {
LocalVariableNode local = accessLocal(vin);
locals.put(local.name, local);
- debug(" -- accessed var " + local.index + " " + local.name + " "
+ devDebug(" -- accessed var " + local.index + " " + local.name + " "
+ getType(local.desc).getClassName() + " write: " + isStoreInstruction(vin));
}
@@ -1199,6 +1288,10 @@ int parameterNarrowConversionOpcode(String name) {
return result;
}
}
+
+ boolean isMethodParameter(LocalVariableNode local) {
+ return local.index != 0 && local.index < method.getArgumentTypes().length;
+ }
}
Type toArrayType(Type type) {
@@ -1273,19 +1366,19 @@ boolean hasAnnotation(MemberNode mn, Class<? extends Annotation> a) {
return false;
}
- void printInstruction(int index, int textIndex, Frame frame, ASMifierMethodVisitor asm) {
- if (debug)
- out.print(index + "\t");
- if (debug)
- out.print(frame + "\t\t");
- if (debug)
- out.print(asm.getText().get(textIndex));
+ String getSimpleClassName(Type type) {
+ String name = type.getClassName();
+ if (!name.contains("."))
+ return name;
+ return name.substring(name.lastIndexOf('.') + 1, name.length());
}
- void print(MethodNode m, Writer w) {
+ void devDebugAsm(MethodNode m) {
+ if (!devDebug)
+ return;
ASMifierMethodVisitor asm = new ASMifierMethodVisitor();
m.instructions.accept(asm);
- PrintWriter pw = new PrintWriter(w);
+ PrintWriter pw = new PrintWriter(out);
asm.print(pw);
pw.flush();
}
View
6 src/test/java/lambda/ControlBlocksTest.java
@@ -89,7 +89,7 @@ public void ifFalse() throws Exception {
static BufferedReader r;
@SuppressWarnings("serial")
- public static <C extends Closeable> Fn1<C, ?> when(final Fn1<C, ?> block) {
+ public static <C extends Closeable> Fn1<C, ?> with(final Fn1<C, ?> block) {
return new Fn1<C, Object>() {
Closeable c;
@@ -123,7 +123,7 @@ public Object call(C c) {
boolean wasClosed;
@Test
- public void when() throws Exception {
+ public void with() throws Exception {
BufferedReader br = new BufferedReader(new StringReader("hello\nworld") {
public void close() {
super.close();
@@ -135,7 +135,7 @@ public void close() {
PrintWriter w = new PrintWriter(sw);
String line;
- when(λ(r = br, (line = r.readLine()) != null)).whileTrue(λ(w.printf(line + "\n")));
+ with(λ(r = br, (line = r.readLine()) != null)).whileTrue(λ(w.printf(line + "\n")));
assertTrue(wasClosed);
assertEquals("hello\nworld\n", sw.toString());
Please sign in to comment.
Something went wrong with that request. Please try again.