On Tue, 24 Jun 2025 14:01:04 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> Note that this was a preview language feature until **JDK 25**.
>
> I haven't done my due diligence to verify whether this feature can be used. 
> Even if this particular way can't be used, it's still a viable option, just 
> move the code above into a helper method.
> 
> 
>     public ImageIcon(Image image, String description) {
>         this.image = image;
>         this.description = description;
> 
>         loadImage(image);
>     }
> 
>     public ImageIcon (Image image) {
>         this(image, getImageComment(image));
>     }
> 
>     /**
>      * {@return the {@code "comment"} property of the image
>      * if the value of the property is a sting}
>      * @param image the image to get the {@code "comment"}  property
>      */
>     private static String getImageComment(Image image) {
>         if (image == null) {
>             return null;
>         }
> 
>         Object o = image.getProperty("comment", null);
>         return (o instanceof String) ? (String) o : null;
>     }
> 
> 
> This should be done separately from this changeset, I think, to have shorter, 
> more specific changes.

> Note that this was a preview language feature until **JDK 25**.

Huh… We're developing JDK 26 now, so the **Flexible Constructor Bodies** [[JEP 
513](https://openjdk.org/jeps/513)] feature can safely be used.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2180838579

Reply via email to