test/tools/javac/meth/XlintWarn.java

Fri, 12 Nov 2010 12:33:52 +0000

author
mcimadamore
date
Fri, 12 Nov 2010 12:33:52 +0000
changeset 742
fdc67f5170e9
child 810
15484cb7e5ae
permissions
-rw-r--r--

6999067: cast for invokeExact call gets redundant cast to <type> warnings
Summary: Xlint:cast should not report cast used in order to specify target type in polymorphic signature calls
Reviewed-by: jjg

mcimadamore@742 1 /*
mcimadamore@742 2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
mcimadamore@742 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@742 4 *
mcimadamore@742 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@742 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@742 7 * published by the Free Software Foundation.
mcimadamore@742 8 *
mcimadamore@742 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@742 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@742 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@742 12 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@742 13 * accompanied this code).
mcimadamore@742 14 *
mcimadamore@742 15 * You should have received a copy of the GNU General Public License version
mcimadamore@742 16 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@742 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@742 18 *
mcimadamore@742 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mcimadamore@742 20 * or visit www.oracle.com if you need additional information or have any
mcimadamore@742 21 * questions.
mcimadamore@742 22 */
mcimadamore@742 23
mcimadamore@742 24 /*
mcimadamore@742 25 * @test
mcimadamore@742 26 * @bug 6999067
mcimadamore@742 27 * @summary cast for invokeExact call gets redundant cast to <type> warnings
mcimadamore@742 28 * @author mcimadamore
mcimadamore@742 29 *
mcimadamore@742 30 * @compile -Werror -Xlint:cast XlintWarn.java
mcimadamore@742 31 */
mcimadamore@742 32
mcimadamore@742 33 import java.dyn.*;
mcimadamore@742 34
mcimadamore@742 35 class XlintWarn {
mcimadamore@742 36 void test(MethodHandle mh) throws Throwable {
mcimadamore@742 37 int i1 = (int)mh.invoke();
mcimadamore@742 38 int i2 = (int)mh.invokeExact();
mcimadamore@742 39 int i3 = (int)mh.invokeVarargs();
mcimadamore@742 40 int i4 = (int)InvokeDynamic.test();
mcimadamore@742 41 }
mcimadamore@742 42 }

mercurial