JDK 9 RFR of JDK-8036747: Fix unchecked lint warnings in java.security.Provider
Joe Darcy
joe.darcy at oracle.com
Thu Mar 6 01:35:59 UTC 2014
Hello,
Please review the patch below which addresses
JDK-8036747: Fix unchecked lint warnings in java.security.Provider
In brief, java.security.Provider extends Properties which in extends
Hashtable<Object, Object> even though morally Properties are a
Map<String, String>.
The implementations of new-in-JDK-8 methods like
replaceAll(BiFunction<? super K, ? super V, ? extends V> function)
need to have a public signature where K and V are replaced with
"Object", but the actual function needs to operate over "String".
The patch suppresses warnings related to several unchecked casts from
Object-based functions to String-based functions.
Thanks,
-Joe
diff -r 07d78a5dd853 src/share/classes/java/security/Provider.java
--- a/src/share/classes/java/security/Provider.java Wed Mar 05
17:08:37 2014 -0800
+++ b/src/share/classes/java/security/Provider.java Wed Mar 05
17:30:04 2014 -0800
@@ -769,6 +769,7 @@
return super.replace(key, value);
}
+ @SuppressWarnings("unchecked") // Function must actually operate
over strings
private void implReplaceAll(BiFunction<? super Object, ? super
Object, ? extends Object> function) {
legacyChanged = true;
if (legacyStrings == null) {
@@ -779,7 +780,7 @@
super.replaceAll(function);
}
-
+ @SuppressWarnings("unchecked") // Function must actually operate
over strings
private Object implMerge(Object key, Object value, BiFunction<?
super Object, ? super Object, ? extends Object> remappingFunction) {
if ((key instanceof String) && (value instanceof String)) {
if (!checkLegacy(key)) {
@@ -791,6 +792,7 @@
return super.merge(key, value, remappingFunction);
}
+ @SuppressWarnings("unchecked") // Function must actually operate
over strings
private Object implCompute(Object key, BiFunction<? super Object,
? super Object, ? extends Object> remappingFunction) {
if (key instanceof String) {
if (!checkLegacy(key)) {
@@ -802,6 +804,7 @@
return super.compute(key, remappingFunction);
}
+ @SuppressWarnings("unchecked") // Function must actually operate
over strings
private Object implComputeIfAbsent(Object key, Function<? super
Object, ? extends Object> mappingFunction) {
if (key instanceof String) {
if (!checkLegacy(key)) {
@@ -813,6 +816,7 @@
return super.computeIfAbsent(key, mappingFunction);
}
+ @SuppressWarnings("unchecked") // Function must actually operate
over strings
private Object implComputeIfPresent(Object key, BiFunction<? super
Object, ? super Object, ? extends Object> remappingFunction) {
if (key instanceof String) {
if (!checkLegacy(key)) {
More information about the security-dev
mailing list