iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/naming/jndi/CNNameParser.java
private static NameComponent parseComponent(String compStr)
            throws InvalidNameException {
        NameComponent comp = new NameComponent();
        int kindSep = -1;
        int len = compStr.length();

        int j = 0;
        char[] newStr = new char[len];
        boolean escaped = false;

        // Find the kind separator
        for (int i = 0; i < len && kindSep < 0; i++) {
            if (escaped) {
                newStr[j++] = compStr.charAt(i);
                escaped = false;
            } else if (compStr.charAt(i) == escapeChar) {
                if (i + 1 >= len) {
                    throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
                } else if (isMeta(compStr.charAt(i + 1))) {
                    escaped = true;
                } else {
                    throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
                }
            } else if (compStr.charAt(i) == kindSeparator) {
                kindSep = i;
            } else {
                newStr[j++] = compStr.charAt(i);
            }
        }

        // Set id
        comp.id = new String(newStr, 0, j);

        // Set kind
        if (kindSep < 0) {
            comp.kind = "";  // no kind separator
        } else {
            // unescape kind
            j = 0;
            escaped = false;
            for (int i = kindSep + 1; i < len; i++) {
                if (escaped) {
                    newStr[j++] = compStr.charAt(i);
                    escaped = false;
                } else if (compStr.charAt(i) == escapeChar) {
                    if (i + 1 >= len) {
                        throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
                    } else if (isMeta(compStr.charAt(i + 1))) {
                        escaped = true;
                    } else {
                        throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
                    }
                } else {
                    newStr[j++] = compStr.charAt(i);
                }
            }
            comp.kind = new String(newStr, 0, j);
        }
        return comp;
    }
private static NameComponent parseComponent(String compStr)
            throws InvalidNameException {
        NameComponent comp = new NameComponent();
        int kindSep = -1;
        int len = compStr.length();

        int j = 0;
        char[] newStr = new char[len];
        boolean escaped = false;

        // Find the kind separator
        for (int i = 0; i < len && kindSep < 0; i++) {
            if (escaped) {
                newStr[j++] = compStr.charAt(i);
                escaped = false;
            } else if (compStr.charAt(i) == escapeChar) {
                if (i + 1 >= len) {
                    throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
                } else if (isMeta(compStr.charAt(i + 1))) {
                    escaped = true;
                } else {
                    throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
                }
            } else if (compStr.charAt(i) == kindSeparator) {
                kindSep = i;
            } else {
                newStr[j++] = compStr.charAt(i);
            }
        }

        // Set id
        comp.id = new String(newStr, 0, j);

        // Set kind
        if (kindSep < 0) {
            comp.kind = "";  // no kind separator
        } else {
            // unescape kind
            j = 0;
            escaped = false;
            for (int i = kindSep + 1; i < len; i++) {
                if (escaped) {
                    newStr[j++] = compStr.charAt(i);
                    escaped = false;
                } else if (compStr.charAt(i) == escapeChar) {
                    if (i + 1 >= len) {
                        throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
                    } else if (isMeta(compStr.charAt(i + 1))) {
                        escaped = true;
                    } else {
                        throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
                    }
                } else {
                    newStr[j++] = compStr.charAt(i);
                }
            }
            comp.kind = new String(newStr, 0, j);
        }
        return comp;
    }
Return a NameComponent given its stringified form.