JDK 17 jdk.jconsole.jmod - JConsole Tool

JDK 17 jdk.jconsole.jmod is the JMOD file for JDK 17 JConsole tool, which can be invoked by the "jconsole" command.

JDK 17 JConsole tool compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\jdk.jconsole.jmod.

JDK 17 JConsole tool compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.

JDK 17 JConsole tool source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\jdk.jconsole.

You can click and view the content of each source code file in the list below.

✍: FYIcenter

sun/tools/jconsole/Resources.java

/*
 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package sun.tools.jconsole;

import java.awt.event.KeyEvent;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * Toolkit that provides resource support for JConsole.
 */
public final class Resources {
    private static Map<String, Integer> MNEMONIC_LOOKUP = Collections
            .synchronizedMap(new IdentityHashMap<String, Integer>());

    private Resources() {
        throw new AssertionError();
    }

    /**
     * Convenience method for {@link MessageFormat#format(String, Object...)}.
     *
     * @param pattern the pattern
     * @param objects the arguments for the pattern
     *
     * @return a formatted string
     */
    public static String format(String pattern, Object... arguments) {
            return MessageFormat.format(pattern, arguments);
    }

    /**
     * Returns the mnemonic for a message.
     *
     * @param message the message
     *
     * @return the mnemonic <code>int</code>
     */
    public static int getMnemonicInt(String message) {
        Integer integer = MNEMONIC_LOOKUP.get(message);
        if (integer != null) {
            return integer.intValue();
        }
        return 0;
    }

    /**
     * Initializes all public static non-final fields in the given class with
     * messages from a {@link ResourceBundle}.
     *
     * @param clazz the class containing the fields
     */
    public static void initializeMessages(Class<?> clazz, String rbName) {
        ResourceBundle rb = null;
        try {
            rb = ResourceBundle.getBundle(rbName);
        } catch (MissingResourceException mre) {
            // fall through, handled later
        }
        for (Field field : clazz.getFields()) {
            if (isWritableField(field)) {
                String key = field.getName();
                String message = getMessage(rb, key);
                int mnemonicInt = findMnemonicInt(message);
                message = removeMnemonicAmpersand(message);
                message = replaceWithPlatformLineFeed(message);
                setFieldValue(field, message);
                MNEMONIC_LOOKUP.put(message, mnemonicInt);
            }
        }
    }

    private static boolean isWritableField(Field field) {
        int modifiers = field.getModifiers();
        return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)
                && !Modifier.isFinal(modifiers);
    }

    /**
     * Returns the message corresponding to the key in the bundle or a text
     * describing it's missing.
     *
     * @param rb the resource bundle
     * @param key the key
     *
     * @return the message
     */
    private static String getMessage(ResourceBundle rb, String key) {
        if (rb == null) {
            return "missing resource bundle";
        }
        try {
            return rb.getString(key);
        } catch (MissingResourceException mre) {
            return "missing message for key = \"" + key
                    + "\" in resource bundle ";
        }
    }

    private static void setFieldValue(Field field, String value) {
        try {
            field.set(null, value);
        } catch (IllegalArgumentException | IllegalAccessException e) {
            throw new Error("Unable to access or set message for field " + field.getName());
        }
    }

    /**
     * Returns a {@link String} where all <code>\n</code> in the <text> have
     * been replaced with the line separator for the platform.
     *
     * @param text the to be replaced
     *
     * @return the replaced text
     */
    private static String replaceWithPlatformLineFeed(String text) {
        return text.replace("\n", System.getProperty("line.separator"));
    }

    /**
     * Removes the mnemonic identifier (<code>&</code>) from a string unless
     * it's escaped by <code>&&</code> or placed at the end.
     *
     * @param message the message
     *
     * @return a message with the mnemonic identifier removed
     */
    private static String removeMnemonicAmpersand(String message) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < message.length(); i++) {
            char current = message.charAt(i);
            if (current != '&' || i == message.length() - 1
                    || message.charAt(i + 1) == '&') {
                s.append(current);
            }
        }
        return s.toString();
    }

    /**
     * Finds the mnemonic character in a message.
     *
     * The mnemonic character is the first character followed by the first
     * <code>&</code> that is not followed by another <code>&</code>.
     *
     * @return the mnemonic as an <code>int</code>, or <code>0</code> if it
     *         can't be found.
     */
    private static int findMnemonicInt(String s) {
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == '&') {
                if (s.charAt(i + 1) != '&') {
                    return lookupMnemonicInt(s.substring(i + 1, i + 2));
                } else {
                    i++;
                }
            }
        }
        return 0;
    }

    /**
     * Lookups the mnemonic for a key in the {@link KeyEvent} class.
     *
     * @param c the character to lookup
     *
     * @return the mnemonic as an <code>int</code>, or <code>0</code> if it
     *         can't be found.
     */
    private static int lookupMnemonicInt(String c) {
        try {
            return KeyEvent.class.getDeclaredField("VK_" + c.toUpperCase())
                    .getInt(null);
        } catch (IllegalArgumentException | IllegalAccessException
                | NoSuchFieldException | SecurityException e) {
            // Missing VK is okay
            return 0;
        }
    }
}

sun/tools/jconsole/Resources.java

 

Or download all of them as a single archive file:

File name: jdk.jconsole-17.0.5-src.zip
File size: 169450 bytes
Release date: 2022-09-13
Download 

 

JDK 17 jdk.jdeps.jmod - JDeps Tool

JDK 17 jdk.jcmd.jmod - JCmd Tool

JDK 17 JMod/Module Files

⇑⇑ FAQ for JDK (Java Development Kit) 17

2023-04-17, 3534👍, 0💬