Wed, 16 Oct 2013 10:47:21 -0700
8026704: Build failure with --enable-debug
Reviewed-by: ksrini
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java Tue Oct 15 15:57:13 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Wed Oct 16 10:47:21 2013 -0700 1.3 @@ -270,11 +270,6 @@ 1.4 */ 1.5 public static final long POTENTIALLY_AMBIGUOUS = 1L<<48; 1.6 1.7 - /** 1.8 - * Flag that marks a synthetic method body for a lambda expression 1.9 - */ 1.10 - public static final long LAMBDA_METHOD = 1L<<49; 1.11 - 1.12 /** Modifier masks. 1.13 */ 1.14 public static final int 1.15 @@ -383,8 +378,7 @@ 1.16 NOT_IN_PROFILE(Flags.NOT_IN_PROFILE), 1.17 BAD_OVERRIDE(Flags.BAD_OVERRIDE), 1.18 SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC), 1.19 - THROWS(Flags.THROWS), 1.20 - LAMBDA_METHOD(Flags.LAMBDA_METHOD); 1.21 + THROWS(Flags.THROWS); 1.22 1.23 Flag(long flag) { 1.24 this.value = flag;
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Oct 15 15:57:13 2013 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Wed Oct 16 10:47:21 2013 -0700 2.3 @@ -1718,9 +1718,9 @@ 2.4 if (tree.body == null) { 2.5 return; 2.6 } 2.7 - /* Ignore synthetic methods, except for translated lambda methods. 2.8 + /* MemberEnter can generate synthetic methods, ignore them 2.9 */ 2.10 - if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) { 2.11 + if ((tree.sym.flags() & SYNTHETIC) != 0) { 2.12 return; 2.13 } 2.14
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Oct 15 15:57:13 2013 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Oct 16 10:47:21 2013 -0700 3.3 @@ -30,7 +30,6 @@ 3.4 import com.sun.tools.javac.tree.TreeMaker; 3.5 import com.sun.tools.javac.tree.TreeTranslator; 3.6 import com.sun.tools.javac.code.Attribute; 3.7 -import com.sun.tools.javac.code.Flags; 3.8 import com.sun.tools.javac.code.Kinds; 3.9 import com.sun.tools.javac.code.Scope; 3.10 import com.sun.tools.javac.code.Symbol; 3.11 @@ -1756,7 +1755,7 @@ 3.12 ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; 3.13 break; 3.14 case CAPTURED_VAR: 3.15 - ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) { 3.16 + ret = new VarSymbol(SYNTHETIC | FINAL, name, types.erasure(sym.type), translatedSym) { 3.17 @Override 3.18 public Symbol baseSymbol() { 3.19 //keep mapping with original captured symbol 3.20 @@ -1764,13 +1763,6 @@ 3.21 } 3.22 }; 3.23 break; 3.24 - case LOCAL_VAR: 3.25 - ret = new VarSymbol(FINAL, name, types.erasure(sym.type), translatedSym); 3.26 - break; 3.27 - case PARAM: 3.28 - ret = new VarSymbol(FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym); 3.29 - ((VarSymbol) ret).adr = ((VarSymbol) sym).adr; 3.30 - break; 3.31 default: 3.32 ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); 3.33 } 3.34 @@ -1853,7 +1845,7 @@ 3.35 // If instance access isn't needed, make it static. 3.36 // Interface instance methods must be default methods. 3.37 // Lambda methods are private synthetic. 3.38 - translatedSym.flags_field = SYNTHETIC | LAMBDA_METHOD | 3.39 + translatedSym.flags_field = SYNTHETIC | 3.40 PRIVATE | 3.41 (thisReferenced? (inInterface? DEFAULT : 0) : STATIC); 3.42
4.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Oct 15 15:57:13 2013 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Oct 16 10:47:21 2013 -0700 4.3 @@ -2892,8 +2892,7 @@ 4.4 4.5 @Override 4.6 public void visitMethodDef(JCMethodDecl tree) { 4.7 - if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0 4.8 - && (tree.sym.flags() & LAMBDA_METHOD) == 0) { 4.9 + if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0) { 4.10 return; 4.11 } 4.12 if (tree.name.equals(names.clinit)) { 4.13 @@ -2907,7 +2906,6 @@ 4.14 return; 4.15 } 4.16 currentMethod = tree.sym; 4.17 - 4.18 super.visitMethodDef(tree); 4.19 } 4.20
5.1 --- a/test/tools/javac/lambda/LocalVariableTable.java Tue Oct 15 15:57:13 2013 -0700 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,206 +0,0 @@ 5.4 -/* 5.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 5.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 - * 5.8 - * This code is free software; you can redistribute it and/or modify it 5.9 - * under the terms of the GNU General Public License version 2 only, as 5.10 - * published by the Free Software Foundation. 5.11 - * 5.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 - * version 2 for more details (a copy is included in the LICENSE file that 5.16 - * accompanied this code). 5.17 - * 5.18 - * You should have received a copy of the GNU General Public License version 5.19 - * 2 along with this work; if not, write to the Free Software Foundation, 5.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 - * 5.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 - * or visit www.oracle.com if you need additional information or have any 5.24 - * questions. 5.25 - */ 5.26 - 5.27 -/* 5.28 - * @test 5.29 - * @bug 8025998 5.30 - * @summary Missing LV table in lambda bodies 5.31 - * @compile -g LocalVariableTable.java 5.32 - * @run main LocalVariableTable 5.33 - */ 5.34 - 5.35 -import java.lang.annotation.*; 5.36 -import java.util.*; 5.37 -import com.sun.tools.classfile.*; 5.38 - 5.39 -/* 5.40 - * The test checks that a LocalVariableTable attribute is generated for the 5.41 - * method bodies representing lambda expressions, and checks that the expected 5.42 - * set of entries is found in the attribute. 5.43 - * 5.44 - * Since the bug was about missing entries in the LVT, not malformed entries, 5.45 - * the test is not intended to be a detailed test of the contents of each 5.46 - * LocalVariableTable entry: it is assumed that if a entry is present, it 5.47 - * will have the correct contents. 5.48 - * 5.49 - * The test looks for test cases represented by nested classes whose 5.50 - * name begins with "Lambda". Each such class contains a lambda expression 5.51 - * that will mapped into a lambda method, and because the test is compiled 5.52 - * with -g, these methods should have a LocalVariableTable. The set of 5.53 - * expected names in the LVT is provided in an annotation on the class for 5.54 - * the test case. 5.55 - */ 5.56 -public class LocalVariableTable { 5.57 - public static void main(String... args) throws Exception { 5.58 - new LocalVariableTable().run(); 5.59 - } 5.60 - 5.61 - void run() throws Exception { 5.62 - // the declared classes are returned in an unspecified order, 5.63 - // so for neatness, sort them by name before processing them 5.64 - Class<?>[] classes = getClass().getDeclaredClasses(); 5.65 - Arrays.sort(classes, (c1, c2) -> c1.getName().compareTo(c2.getName())); 5.66 - 5.67 - for (Class<?> c : classes) { 5.68 - if (c.getSimpleName().startsWith("Lambda")) 5.69 - check(c); 5.70 - } 5.71 - if (errors > 0) 5.72 - throw new Exception(errors + " errors found"); 5.73 - } 5.74 - 5.75 - /** Check an individual test case. */ 5.76 - void check(Class<?> c) throws Exception { 5.77 - System.err.println("Checking " + c.getSimpleName()); 5.78 - 5.79 - Expect expect = c.getAnnotation(Expect.class); 5.80 - if (expect == null) { 5.81 - error("@Expect not found for class " + c.getSimpleName()); 5.82 - return; 5.83 - } 5.84 - 5.85 - ClassFile cf = ClassFile.read(getClass().getResource(c.getName() + ".class").openStream()); 5.86 - Method m = getLambdaMethod(cf); 5.87 - if (m == null) { 5.88 - error("lambda method not found"); 5.89 - return; 5.90 - } 5.91 - 5.92 - Code_attribute code = (Code_attribute) m.attributes.get(Attribute.Code); 5.93 - if (code == null) { 5.94 - error("Code attribute not found"); 5.95 - return; 5.96 - } 5.97 - 5.98 - LocalVariableTable_attribute lvt = 5.99 - (LocalVariableTable_attribute) code.attributes.get(Attribute.LocalVariableTable); 5.100 - if (lvt == null) { 5.101 - error("LocalVariableTable attribute not found"); 5.102 - return; 5.103 - } 5.104 - 5.105 - Set<String> foundNames = new LinkedHashSet<>(); 5.106 - for (LocalVariableTable_attribute.Entry e: lvt.local_variable_table) { 5.107 - foundNames.add(cf.constant_pool.getUTF8Value(e.name_index)); 5.108 - } 5.109 - 5.110 - Set<String> expectNames = new LinkedHashSet<>(Arrays.asList(expect.value())); 5.111 - if (!foundNames.equals(expectNames)) { 5.112 - Set<String> foundOnly = new LinkedHashSet<>(foundNames); 5.113 - foundOnly.removeAll(expectNames); 5.114 - for (String s: foundOnly) 5.115 - error("Unexpected name found: " + s); 5.116 - Set<String> expectOnly = new LinkedHashSet<>(expectNames); 5.117 - expectOnly.removeAll(foundNames); 5.118 - for (String s: expectOnly) 5.119 - error("Expected name not found: " + s); 5.120 - } 5.121 - } 5.122 - 5.123 - /** Get a method whose name begins "lambda$...". */ 5.124 - Method getLambdaMethod(ClassFile cf) throws ConstantPoolException { 5.125 - for (Method m: cf.methods) { 5.126 - if (m.getName(cf.constant_pool).startsWith("lambda$")) 5.127 - return m; 5.128 - } 5.129 - return null; 5.130 - } 5.131 - 5.132 - /** Report an error. */ 5.133 - void error(String msg) { 5.134 - System.err.println("Error: " + msg); 5.135 - errors++; 5.136 - } 5.137 - 5.138 - int errors; 5.139 - 5.140 - /** 5.141 - * Annotation used to provide the set of names expected in the LVT attribute. 5.142 - */ 5.143 - @Retention(RetentionPolicy.RUNTIME) 5.144 - @interface Expect { 5.145 - String[] value(); 5.146 - } 5.147 - 5.148 - /** Functional interface with nullary method. */ 5.149 - interface Run0 { 5.150 - public void run(); 5.151 - } 5.152 - 5.153 - /** Functional interface with 1-ary method. */ 5.154 - interface Run1 { 5.155 - public void run(int a0); 5.156 - } 5.157 - 5.158 - /** Functional interface with 2-ary method. */ 5.159 - interface Run2 { 5.160 - public void run(int a0, int a1); 5.161 - } 5.162 - 5.163 - /* 5.164 - * ---------- Test cases --------------------------------------------------- 5.165 - */ 5.166 - 5.167 - @Expect({ "x" }) 5.168 - static class Lambda_Args0_Local1 { 5.169 - Run0 r = () -> { int x = 0; }; 5.170 - } 5.171 - 5.172 - @Expect({ "x", "this" }) 5.173 - static class Lambda_Args0_Local1_this { 5.174 - int v; 5.175 - Run0 r = () -> { int x = v; }; 5.176 - } 5.177 - 5.178 - @Expect({ "a" }) 5.179 - static class Lambda_Args1_Local0 { 5.180 - Run1 r = (a) -> { }; 5.181 - } 5.182 - 5.183 - @Expect({ "a", "x" }) 5.184 - static class Lambda_Args1_Local1 { 5.185 - Run1 r = (a) -> { int x = a; }; 5.186 - } 5.187 - 5.188 - @Expect({ "a", "x" }) 5.189 - static class Lambda_Args1_Local1_Captured1 { 5.190 - void m() { 5.191 - int v = 0; 5.192 - Run1 r = (a) -> { int x = a + v; }; 5.193 - } 5.194 - } 5.195 - 5.196 - @Expect({ "a1", "a2", "x1", "x2", "this" }) 5.197 - static class Lambda_Args2_Local2_Captured2_this { 5.198 - int v; 5.199 - void m() { 5.200 - int v1 = 0; 5.201 - int v2 = 0; 5.202 - Run2 r = (a1, a2) -> { 5.203 - int x1 = a1 + v1 + v; 5.204 - int x2 = a2 + v2 + v; 5.205 - }; 5.206 - } 5.207 - } 5.208 -} 5.209 -