8358530: Properties#list should warn against non-String values

Reviewed-by: jlu, liach
This commit is contained in:
Edoardo Patti 2025-07-23 16:31:14 +00:00 committed by Justin Lu
parent 594c080b2b
commit 03e9ea169b

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2025, 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
@ -70,10 +70,10 @@ import jdk.internal.util.xml.PropertiesDefaultHandler;
* {@code Properties} object. Their use is strongly discouraged as they
* allow the caller to insert entries whose keys or values are not
* {@code Strings}. The {@code setProperty} method should be used
* instead. If the {@code store} or {@code save} method is called
* instead. If the {@code store}, {@code save}, or {@code list} method is called
* on a "compromised" {@code Properties} object that contains a
* non-{@code String} key or value, the call will fail. Similarly,
* the call to the {@code propertyNames} or {@code list} method
* the call to the {@code propertyNames} method
* will fail if it is called on a "compromised" {@code Properties}
* object that contains a non-{@code String} key.
*
@ -1215,8 +1215,8 @@ public class Properties extends Hashtable<Object,Object> {
* This method is useful for debugging.
*
* @param out an output stream.
* @throws ClassCastException if any key in this property list
* is not a string.
* @throws ClassCastException if either a key or a value
* in this property list is not a string.
*/
public void list(PrintStream out) {
out.println("-- listing properties --");
@ -1237,8 +1237,8 @@ public class Properties extends Hashtable<Object,Object> {
* This method is useful for debugging.
*
* @param out an output stream.
* @throws ClassCastException if any key in this property list
* is not a string.
* @throws ClassCastException if either a key or a value
* in this property list is not a string.
* @since 1.1
*/
/*