changeset 2392:e9d986381414

8010404: Lambda debugging: redundant LineNumberTable entry for lambda capture Summary: Ignore indy entries in LineNumberTable Reviewed-by: jjg
author mcimadamore
date Mon, 08 Apr 2013 15:53:08 +0100
parents b54122b9372d
children 94a202228ec2
files 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 3 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Mon Apr 08 15:52:05 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Mon Apr 08 15:53:08 2013 +0100
@@ -470,7 +470,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	Mon Apr 08 15:52:05 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Mon Apr 08 15:53:08 2013 +0100
@@ -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	Mon Apr 08 15:52:05 2013 +0100
+++ b/test/tools/javac/lambda/TestInvokeDynamic.java	Mon Apr 08 15:53:08 2013 +0100
@@ -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;