Thu, 06 Jun 2013 15:38:42 +0100
Merge
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Jun 06 15:37:23 2013 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Jun 06 15:38:42 2013 +0100 1.3 @@ -2711,9 +2711,14 @@ 1.4 if (fvs.nonEmpty()) { 1.5 List<Type> addedargtypes = List.nil(); 1.6 for (List<VarSymbol> l = fvs; l.nonEmpty(); l = l.tail) { 1.7 - if (TreeInfo.isInitialConstructor(tree)) 1.8 + if (TreeInfo.isInitialConstructor(tree)) { 1.9 + final Name pName = proxyName(l.head.name); 1.10 + m.extraParams = 1.11 + m.extraParams.append((VarSymbol) 1.12 + (proxies.lookup(pName).sym)); 1.13 added = added.prepend( 1.14 - initField(tree.body.pos, proxyName(l.head.name))); 1.15 + initField(tree.body.pos, pName)); 1.16 + } 1.17 addedargtypes = addedargtypes.prepend(l.head.erasure(types)); 1.18 } 1.19 Type olderasure = m.erasure(types);
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/8015701/AnonymousParameters.java Thu Jun 06 15:38:42 2013 +0100 2.3 @@ -0,0 +1,89 @@ 2.4 +/* 2.5 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test 2.29 + * @bug 8015701 2.30 + * @summary javac should generate method parameters correctly. 2.31 + * @compile -parameters AnonymousParameters.java 2.32 + * @run main AnonymousParameters 2.33 + */ 2.34 +import java.lang.Class; 2.35 +import java.lang.reflect.Constructor; 2.36 +import java.lang.reflect.Parameter; 2.37 +import java.util.concurrent.Callable; 2.38 + 2.39 +public class AnonymousParameters { 2.40 + 2.41 + String[] names = { 2.42 + "this$0", 2.43 + "val$message" 2.44 + }; 2.45 + 2.46 + public static void main(String... args) throws Exception { 2.47 + new AnonymousParameters().run(); 2.48 + } 2.49 + 2.50 + void run() throws Exception { 2.51 + Class<?> cls = new ParameterNames().makeInner("hello").getClass(); 2.52 + Constructor<?> ctor = cls.getDeclaredConstructors()[0]; 2.53 + Parameter[] params = ctor.getParameters(); 2.54 + 2.55 + if(params.length == 2) { 2.56 + for(int i = 0; i < 2; i++) { 2.57 + System.err.println("Testing parameter " + params[i].getName()); 2.58 + if(!params[i].getName().equals(names[i])) 2.59 + error("Expected parameter name " + names[i] + 2.60 + " got " + params[i].getName()); 2.61 + } 2.62 + } else 2.63 + error("Expected 2 parameters"); 2.64 + 2.65 + if(0 != errors) 2.66 + throw new Exception("MethodParameters test failed with " + 2.67 + errors + " errors"); 2.68 + } 2.69 + 2.70 + void error(String msg) { 2.71 + System.err.println("Error: " + msg); 2.72 + errors++; 2.73 + } 2.74 + 2.75 + int errors; 2.76 +} 2.77 + 2.78 +class ParameterNames { 2.79 + 2.80 + public Callable<String> makeInner(final String message) { 2.81 + return new Callable<String>() { 2.82 + public String call() throws Exception { 2.83 + return message; 2.84 + } 2.85 + }; 2.86 + } 2.87 + 2.88 + public static void main(String... args) throws Exception { 2.89 + ParameterNames test = new ParameterNames(); 2.90 + System.out.println(test.makeInner("Hello").call()); 2.91 + } 2.92 +}