On Fri, 8 May 2026 19:46:34 GMT, Kevin Walls <[email protected]> wrote:

>> JConsole needs to disable HTML rendering in components populated by MBeans, 
>> as is standard practice.
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Kevin Walls has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains seven additional 
> commits since the last revision:
> 
>  - XTreeRenderer should not change props on the JTree, it has set the 
> property itself already
>  - Merge remote-tracking branch 'upstream/master' into 8383637_Jconsole_html
>  - oops
>  - oops
>  - remove one unnecessary html.disable, add one more
>  - newlines
>  - JConsole should not render HTML in components where it could be confusing

src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/OperationEntry.java 
line 56:

> 54:             for (int i = 0; i < params.length; i++) {
> 55:                 if(params[i].getName() != null) {
> 56:                     JLabel name = new JLabel(params[i].getName(), 
> JLabel.CENTER) {

I think this pattern should be carefully checked, in this particular patch and 
all previous related patches.
Check what the code is actually render in these two similar but different cases:

    private static final String INPUT = "<html><b>BOOM</b></html>";

    public static void main(String[] args) throws Exception {
        JLabel actual = new JLabel(INPUT, JLabel.CENTER);
        actual.putClientProperty("html.disable", Boolean.TRUE);
        System.out.println("Actual: " + getText(actual));

        JLabel expected = new JLabel();
        expected.putClientProperty("html.disable", Boolean.TRUE);
        expected.setText(INPUT);
        System.out.println("Expected: " + getText(expected));
    }

    private static String getText(JLabel label) throws Exception {
        View v = (View) label.getClientProperty("html");
        if (v != null) {
            return v.getDocument().getText(0, v.getDocument().getLength());
        }
        return label.getText();
    }
}

getText above is implemented in a same way as 
https://github.com/openjdk/jdk/blob/22b46872d0d647c9ef9f4414b4685afa8313926d/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java#L193

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30998#discussion_r3255377253

Reply via email to