Skip to content
Permalink
Browse files
8268148: unchecked warnings handle ? and ? extends Object differently
Reviewed-by: jlahoda
  • Loading branch information
Vicente Romero committed Sep 3, 2021
1 parent 8c37909 commit ff4018bc867841b566d619029fb637a128bc39a7
@@ -877,7 +877,9 @@ public boolean isExtendsBound() {
kind == UNBOUND;
}
public boolean isUnbound() {
return kind == UNBOUND;
// is it `?` or `? extends Object`?
return kind == UNBOUND ||
(kind == EXTENDS && type.tsym.flatName() == type.tsym.name.table.names.java_lang_Object);
}

@Override
@@ -1,8 +1,7 @@
T8176534.java:12:43: compiler.warn.unchecked.meth.invocation.applied: kindname.method, forEnumeration, java.util.Enumeration<T>, java.util.Enumeration, kindname.class, T8176534
T8176534.java:12:44: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Enumeration, java.util.Enumeration<T>
T8176534.java:12:28: compiler.warn.unchecked.meth.invocation.applied: kindname.method, newArrayList, java.util.Iterator<? extends E>, java.util.Iterator, kindname.class, T8176534
T8176534.java:12:43: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Iterator, java.util.Iterator<? extends E>
T8176534.java:12:28: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.ArrayList, java.util.List<java.lang.String>
- compiler.err.warnings.and.werror
1 error
5 warnings
4 warnings
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2021, 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.
*/

/*
* @test
* @bug 8268148
* @summary unchecked warnings handle ? and ? extends Object differently
* @compile -Xlint:all -Werror UnboundAndBoundByObjectTest.java
*/

import java.util.List;

class UnboundAndBoundByObjectTest {
void f(List<? extends Object> x) {}
void g(List<?> x) {}

void h(List<String> x) {
f((List) x);
g((List) x);
}
}

1 comment on commit ff4018b

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on ff4018b Sep 3, 2021

Please sign in to comment.