8013179: assertion failure in javac when compiling with -source 1.6 -target 1.6

Wed, 31 Jul 2013 10:52:01 +0100

author
vromero
date
Wed, 31 Jul 2013 10:52:01 +0100
changeset 1925
7696282873f6
parent 1924
cd9e8cea1b3c
child 1926
453a305e1165
child 1928
05370ef9dccb

8013179: assertion failure in javac when compiling with -source 1.6 -target 1.6
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/comp/TransTypes.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/resources/compiler.properties file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/MethodInvokedWithWrongNumberOfArgs.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Sun Jul 28 10:17:45 2013 +0200
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 31 10:52:01 2013 +0100
     1.3 @@ -674,7 +674,11 @@
     1.4          if (tree.varargsElement != null)
     1.5              tree.varargsElement = types.erasure(tree.varargsElement);
     1.6          else
     1.7 -            Assert.check(tree.args.length() == argtypes.length());
     1.8 +            if (tree.args.length() != argtypes.length()) {
     1.9 +                log.error(tree.pos(),
    1.10 +                              "method.invoked.with.incorrect.number.arguments",
    1.11 +                              tree.args.length(), argtypes.length());
    1.12 +            }
    1.13          tree.args = translateArgs(tree.args, argtypes, tree.varargsElement);
    1.14  
    1.15          tree.type = types.erasure(tree.type);
     2.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Sun Jul 28 10:17:45 2013 +0200
     2.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 31 10:52:01 2013 +0100
     2.3 @@ -918,6 +918,10 @@
     2.4  compiler.err.signature.doesnt.match.intf=\
     2.5      signature does not match {0}; incompatible interfaces
     2.6  
     2.7 +# 0: number, 1: number
     2.8 +compiler.err.method.invoked.with.incorrect.number.arguments=\
     2.9 +    method invoked with incorrect number of arguments; expected {0}, found {1}
    2.10 +
    2.11  # 0: symbol, 1: symbol, 2: symbol
    2.12  compiler.err.does.not.override.abstract=\
    2.13      {0} is not abstract and does not override abstract method {1} in {2}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/diags/examples/MethodInvokedWithWrongNumberOfArgs.java	Wed Jul 31 10:52:01 2013 +0100
     3.3 @@ -0,0 +1,32 @@
     3.4 +/*
     3.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +// key: compiler.err.method.invoked.with.incorrect.number.arguments
    3.28 +// options: -Xlint:-options -source 6 -target 6
    3.29 +
    3.30 +class MethodInvokedWithWrongNumberOfArgs {
    3.31 +    static java.lang.invoke.MethodHandle getNamedMember;
    3.32 +    public static Object getMember(String name, Object rec) throws Throwable {
    3.33 +        return getNamedMember.invoke(rec, name);
    3.34 +    }
    3.35 +}

mercurial