OpenJDK / lambda / lambda / langtools
changeset 1906:b0d1bcd07069
8010469: Bad assertion in LambdaToMethod
8010404: Lambda debugging: redundant LineNumberTable entry for lambda capture
author | mcimadamore |
---|---|
date | Thu, 21 Mar 2013 12:42:23 +0000 |
parents | 85ba5a25c9e2 |
children | b6f403a0f73f |
files | src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java src/share/classes/com/sun/tools/javac/jvm/Code.java src/share/classes/com/sun/tools/javac/jvm/Gen.java test/tools/javac/lambda/TestInvokeDynamic.java |
diffstat | 4 files changed, 34 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Mar 20 12:05:11 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Mar 21 12:42:23 2013 +0000 @@ -1321,8 +1321,8 @@ // the generated lambda method will not have type yet, but the // enclosing method's name will have been generated with this same // method, so it will be unique and never be overloaded. - if (owner.type != null) { - assert(directlyEnclosingLambda() != null); + Assert.check(owner.type != null || directlyEnclosingLambda() != null); + if (owner.type != null) { int methTypeHash = methodSig(owner.type).hashCode(); buf.append(Integer.toHexString(methTypeHash)); }
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Mar 20 12:05:11 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Mar 21 12:42:23 2013 +0000 @@ -459,7 +459,15 @@ public void emitInvokedynamic(int desc, Type mtype) { // N.B. this format is under consideration by the JSR 292 EG int argsize = width(mtype.getParameterTypes()); - emitop(invokedynamic); + int prevPos = pendingStatPos; + try { + //disable line number generation (we could have used 'emit1', that + //bypasses stackmap generation - which is needed for indy calls) + pendingStatPos = Position.NOPOS; + emitop(invokedynamic); + } finally { + pendingStatPos = prevPos; + } if (!alive) return; emit2(desc); emit2(0);
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Mar 20 12:05:11 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Mar 21 12:42:23 2013 +0000 @@ -1748,10 +1748,13 @@ // Generate code for all arguments, where the expected types are // the parameters of the method's external type (that is, any implicit // outer instance of a super(...) call appears as first parameter). + MethodSymbol msym = (MethodSymbol)TreeInfo.symbol(tree.meth); genArgs(tree.args, - TreeInfo.symbol(tree.meth).externalType(types).getParameterTypes()); - code.statBegin(tree.pos); - code.markStatBegin(); + msym.externalType(types).getParameterTypes()); + if (!msym.isDynamic()) { + code.statBegin(tree.pos); + code.markStatBegin(); + } result = m.invoke(); }
--- a/test/tools/javac/lambda/TestInvokeDynamic.java Wed Mar 20 12:05:11 2013 -0700 +++ b/test/tools/javac/lambda/TestInvokeDynamic.java Thu Mar 21 12:42:23 2013 +0000 @@ -24,7 +24,7 @@ /* * @test * @bug 7194586 - * @bug 8003280 8006694 + * @bug 8003280 8006694 8010404 * @summary Add lambda tests * Add back-end support for invokedynamic * temporarily workaround combo tests are causing time out in several platforms @@ -48,6 +48,7 @@ import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool.*; import com.sun.tools.classfile.Instruction; +import com.sun.tools.classfile.LineNumberTable_attribute; import com.sun.tools.classfile.Method; import com.sun.tools.javac.api.JavacTaskImpl; @@ -239,7 +240,7 @@ int id = checkCount.incrementAndGet(); JavaSource source = new JavaSource(id); JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc, - null, null, Arrays.asList(source)); + Arrays.asList("-g"), null, Arrays.asList(source)); Context context = ct.getContext(); Symtab syms = Symtab.instance(context); Names names = Names.instance(context); @@ -349,6 +350,16 @@ bsm_ref.getNameAndTypeInfo().getType() + " " + asBSMSignatureString()); } + + LineNumberTable_attribute lnt = + (LineNumberTable_attribute)ea.attributes.get(Attribute.LineNumberTable); + + if (lnt == null) { + throw new Error("No LineNumberTable attribute"); + } + if (lnt.line_number_table_length != 2) { + throw new Error("Wrong number of entries in LineNumberTable"); + } } catch (Exception e) { e.printStackTrace(); throw new Error("error reading " + compiledTest +": " + e); @@ -376,7 +387,10 @@ "}\n" + "class Test#ID {\n" + " void m() { }\n" + - " void test() { m(); }\n" + + " void test() {\n" + + " Object o = this; // marker statement \n" + + " m();\n" + + " }\n" + "}"; String source;