Java Class Load getClassDescriptor(Class type)

Here you can find the source of getClassDescriptor(Class type)

Description

Get the JNI class descriptor corresponding to the provided type parameter.

License

Mozilla Public License

Parameter

Parameter Description
type Class to determine the corresponding JNI descriptor for.

Return

Class descripor as a String

Declaration

public static String getClassDescriptor(Class<?> type) 

Method Source Code

//package com.java2s;
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import java.util.HashMap;

public class Main {
    private static final HashMap<String, String> CLASS_DESCRIPTORS = new HashMap<String, String>();

    /**//from w  ww .  ja  v a 2s.  c  o  m
     * Get the JNI class descriptor corresponding to the provided type parameter.
     *
     * @param type Class to determine the corresponding JNI descriptor for.
     * @return Class descripor as a String
     */
    public static String getClassDescriptor(Class<?> type) {
        final String name = type.getName().replace('.', '/');

        if (CLASS_DESCRIPTORS.containsKey(name)) {
            return CLASS_DESCRIPTORS.get(name);
        }

        if (type.isArray()) {
            // Array names are already in class descriptor form.
            return name;
        }

        return "L" + name + ';';
    }
}

Related

  1. getClass(String className)
  2. getClass(String fullClassName)
  3. getClass(String name)
  4. getClass(String name)
  5. getClass(String upnpDataType)
  6. getClasses(Class infoClass)
  7. getClasses(Class t)
  8. getClasses(Object... objects)
  9. getClasses(String input)