On Tue, 5 Sep 2023 23:07:03 GMT, Michael Strauß <mstra...@openjdk.org> wrote:
>> modules/javafx.graphics/src/main/java/com/sun/javafx/application/preferences/PlatformPreferences.java >> line 112: >> >>> 110: } >>> 111: >>> 112: throw new IllegalArgumentException( >> >> should this behavior be documented? >> there is no mention of an exception in case of type mismatch in the base >> class. >> >> also, do we want to have some kind of trivial conversion implemented such as >> int -> long -> double ? >> or not? > > It is documented in the `Platform.Preferences` interface, which is > implemented by this class: > > > /** > * Returns the value to which the specified key is mapped. > * > * @param <T> the type of the value > * @param key the key > * @param type the type of the value > * @throws NullPointerException if {@code key} is null > * @throws IllegalArgumentException if the key is not mapped to a > {@code type} instance > * @return the value to which the key is mapped, or {@code > Optional.empty()} > * if no mapping exists for the specified key > */ > <T> Optional<T> getValue(String key, Class<T> type); > > > I'm a bit hesitant regarding an automatic conversion. What would be the use > case for this? one [possible] use case is when different versions of the native platform have different types (int32/int64 ?). or, if the property value is String with the semantics of an integer. Of course, the app dev can always request an Object and parse that. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1014#discussion_r1316515202