diff --git a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java index ef422a8d4e957..6b7062091e47e 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -1097,7 +1097,7 @@ private static int getTableBorder(AttributeSet tableAttr) { * up a translation from StyleConstants (i.e. the well known * attributes) to the associated CSS attributes. */ - private static final Hashtable styleConstantToCssMap = new Hashtable(17); + private static final Map styleConstantToCssMap; /** Maps from HTML value to a CSS value. Used in internal mapping. */ private static final Hashtable htmlValueToCssValueMap = new Hashtable(8); /** Maps from CSS value (string) to internal value. */ @@ -1167,38 +1167,40 @@ private static int getTableBorder(AttributeSet tableAttr) { ); // initialize StyleConstants mapping - styleConstantToCssMap.put(StyleConstants.FontFamily, - CSS.Attribute.FONT_FAMILY); - styleConstantToCssMap.put(StyleConstants.FontSize, - CSS.Attribute.FONT_SIZE); - styleConstantToCssMap.put(StyleConstants.Bold, - CSS.Attribute.FONT_WEIGHT); - styleConstantToCssMap.put(StyleConstants.Italic, - CSS.Attribute.FONT_STYLE); - styleConstantToCssMap.put(StyleConstants.Underline, - CSS.Attribute.TEXT_DECORATION); - styleConstantToCssMap.put(StyleConstants.StrikeThrough, - CSS.Attribute.TEXT_DECORATION); - styleConstantToCssMap.put(StyleConstants.Superscript, - CSS.Attribute.VERTICAL_ALIGN); - styleConstantToCssMap.put(StyleConstants.Subscript, - CSS.Attribute.VERTICAL_ALIGN); - styleConstantToCssMap.put(StyleConstants.Foreground, - CSS.Attribute.COLOR); - styleConstantToCssMap.put(StyleConstants.Background, - CSS.Attribute.BACKGROUND_COLOR); - styleConstantToCssMap.put(StyleConstants.FirstLineIndent, - CSS.Attribute.TEXT_INDENT); - styleConstantToCssMap.put(StyleConstants.LeftIndent, - CSS.Attribute.MARGIN_LEFT); - styleConstantToCssMap.put(StyleConstants.RightIndent, - CSS.Attribute.MARGIN_RIGHT); - styleConstantToCssMap.put(StyleConstants.SpaceAbove, - CSS.Attribute.MARGIN_TOP); - styleConstantToCssMap.put(StyleConstants.SpaceBelow, - CSS.Attribute.MARGIN_BOTTOM); - styleConstantToCssMap.put(StyleConstants.Alignment, - CSS.Attribute.TEXT_ALIGN); + styleConstantToCssMap = Map.ofEntries( + Map.entry(StyleConstants.FontFamily, + CSS.Attribute.FONT_FAMILY), + Map.entry(StyleConstants.FontSize, + CSS.Attribute.FONT_SIZE), + Map.entry(StyleConstants.Bold, + CSS.Attribute.FONT_WEIGHT), + Map.entry(StyleConstants.Italic, + CSS.Attribute.FONT_STYLE), + Map.entry(StyleConstants.Underline, + CSS.Attribute.TEXT_DECORATION), + Map.entry(StyleConstants.StrikeThrough, + CSS.Attribute.TEXT_DECORATION), + Map.entry(StyleConstants.Superscript, + CSS.Attribute.VERTICAL_ALIGN), + Map.entry(StyleConstants.Subscript, + CSS.Attribute.VERTICAL_ALIGN), + Map.entry(StyleConstants.Foreground, + CSS.Attribute.COLOR), + Map.entry(StyleConstants.Background, + CSS.Attribute.BACKGROUND_COLOR), + Map.entry(StyleConstants.FirstLineIndent, + CSS.Attribute.TEXT_INDENT), + Map.entry(StyleConstants.LeftIndent, + CSS.Attribute.MARGIN_LEFT), + Map.entry(StyleConstants.RightIndent, + CSS.Attribute.MARGIN_RIGHT), + Map.entry(StyleConstants.SpaceAbove, + CSS.Attribute.MARGIN_TOP), + Map.entry(StyleConstants.SpaceBelow, + CSS.Attribute.MARGIN_BOTTOM), + Map.entry(StyleConstants.Alignment, + CSS.Attribute.TEXT_ALIGN) + ); // HTML->CSS htmlValueToCssValueMap.put("disc", CSS.Value.DISC);