mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-19 23:48:50 +00:00
8078660: Misleading recommendation from diamond finder
Javac should recommend diamond usage if that could lead to a change in program behavior. Reviewed-by: mcimadamore
This commit is contained in:
parent
ea92f6bf06
commit
3b399ff099
@ -241,8 +241,6 @@ public class Analyzer {
|
||||
}
|
||||
for (Type t : inferredArgs) {
|
||||
if (!types.isSameType(t, explicitArgs.head)) {
|
||||
log.warning(oldTree.clazz, "diamond.redundant.args.1",
|
||||
oldTree.clazz.type, newTree.clazz.type);
|
||||
return;
|
||||
}
|
||||
explicitArgs = explicitArgs.tail;
|
||||
|
||||
@ -1669,12 +1669,6 @@ compiler.warn.raw.class.use=\
|
||||
compiler.warn.diamond.redundant.args=\
|
||||
Redundant type arguments in new expression (use diamond operator instead).
|
||||
|
||||
# 0: type, 1: list of type
|
||||
compiler.warn.diamond.redundant.args.1=\
|
||||
Redundant type arguments in new expression (use diamond operator instead).\n\
|
||||
explicit: {0}\n\
|
||||
inferred: {1}
|
||||
|
||||
compiler.warn.potential.lambda.found=\
|
||||
This anonymous inner class creation can be turned into a lambda expression.
|
||||
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// key: compiler.warn.diamond.redundant.args.1
|
||||
// options: -XDfind=diamond
|
||||
|
||||
class DiamondRedundantArgs1<X> {
|
||||
DiamondRedundantArgs1<?> fs = new DiamondRedundantArgs1<String>();
|
||||
}
|
||||
@ -1,5 +1,3 @@
|
||||
T6939780.java:22:28: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:31:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
4 warnings
|
||||
2 warnings
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
T6939780.java:21:33: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:22:28: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:30:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:31:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
6 warnings
|
||||
4 warnings
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
T6939780.java:21:33: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:22:28: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:24:33: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:25:28: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:26:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:30:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:31:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:33:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:34:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:35:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
12 warnings
|
||||
8 warnings
|
||||
|
||||
@ -1,10 +1,34 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 7002837 8064365
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 7002837 8064365 8078660
|
||||
*
|
||||
* @summary Diamond: javac generates diamond inference errors when in 'finder' mode
|
||||
* @author mcimadamore
|
||||
* @compile/fail/ref=T7002837.out -Werror -XDrawDiagnostics -XDfind=diamond T7002837.java
|
||||
* @compile -Werror -XDrawDiagnostics -XDfind=diamond T7002837.java
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
T7002837.java:13:19: compiler.warn.diamond.redundant.args.1: T7002837<java.lang.Integer>, T7002837<java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>
|
||||
- compiler.err.warnings.and.werror
|
||||
1 error
|
||||
1 warning
|
||||
@ -1,8 +1,32 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8078473
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 8078473 8078660
|
||||
* @summary javac diamond finder crashes when used to build java.base module
|
||||
* @compile/ref=T8078473.out T8078473.java -XDrawDiagnostics -XDfind=diamond
|
||||
* @compile -Werror T8078473.java -XDrawDiagnostics -XDfind=diamond
|
||||
*/
|
||||
|
||||
class T8078473<P, Q> {
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
T8078473.java:15:14: compiler.warn.diamond.redundant.args.1: T8078473.C<Q,Q>, T8078473.C<java.lang.Object,java.lang.Object>
|
||||
T8078473.java:16:14: compiler.warn.diamond.redundant.args.1: T8078473.C<Q,Q>, T8078473.C<java.lang.Object,java.lang.Object>
|
||||
2 warnings
|
||||
@ -1,8 +1,32 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8078473
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 8078473 8078660
|
||||
* @summary javac diamond finder crashes when used to build java.base module
|
||||
* @compile/ref=T8078473_2.out T8078473_2.java -XDrawDiagnostics -XDfind=diamond
|
||||
* @compile -Werror T8078473_2.java -XDrawDiagnostics -XDfind=diamond
|
||||
*/
|
||||
|
||||
package java.util.stream;
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
T8078473_2.java:17:13: compiler.warn.diamond.redundant.args.1: java.util.stream.T8078473_2.C<Q,Q>, java.util.stream.T8078473_2.C<java.lang.Object,java.lang.Object>
|
||||
T8078473_2.java:18:13: compiler.warn.diamond.redundant.args.1: java.util.stream.T8078473_2.C<Q,Q>, java.util.stream.T8078473_2.C<java.lang.Object,java.lang.Object>
|
||||
2 warnings
|
||||
Loading…
x
Reference in New Issue
Block a user