Example usage for org.eclipse.jdt.internal.compiler.env IBinaryMethod getExceptionTypeNames

List of usage examples for org.eclipse.jdt.internal.compiler.env IBinaryMethod getExceptionTypeNames

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.env IBinaryMethod getExceptionTypeNames.

Prototype

char[][] getExceptionTypeNames();

Source Link

Document

Answer the resolved names of the exception types in the class file format as specified in section 4.2 of the Java 2 VM spec or null if the array is empty.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryMethod.java

License:Open Source License

public String[] getExceptionTypes() throws JavaModelException {
    if (this.exceptionTypes == null) {
        IBinaryMethod info = (IBinaryMethod) getElementInfo();
        char[] genericSignature = info.getGenericSignature();
        if (genericSignature != null) {
            char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
            this.exceptionTypes = Signature.getThrownExceptionTypes(new String(dotBasedSignature));
        }//w w w . ja  v  a 2 s  .  c om
        if (this.exceptionTypes == null || this.exceptionTypes.length == 0) {
            char[][] eTypeNames = info.getExceptionTypeNames();
            if (eTypeNames == null || eTypeNames.length == 0) {
                this.exceptionTypes = CharOperation.NO_STRINGS;
            } else {
                eTypeNames = ClassFile.translatedNames(eTypeNames);
                this.exceptionTypes = new String[eTypeNames.length];
                for (int j = 0, length = eTypeNames.length; j < length; j++) {
                    // 1G01HRY: ITPJCORE:WINNT - method.getExceptionType not in correct format
                    int nameLength = eTypeNames[j].length;
                    char[] convertedName = new char[nameLength + 2];
                    System.arraycopy(eTypeNames[j], 0, convertedName, 1, nameLength);
                    convertedName[0] = 'L';
                    convertedName[nameLength + 1] = ';';
                    this.exceptionTypes[j] = new String(convertedName);
                }
            }
        }
    }
    return this.exceptionTypes;
}

From source file:org.eclipse.che.jdt.BinaryTypeConvector.java

License:Open Source License

private static JsonElement toJsonMethod(IBinaryMethod method) {
    JsonObject object = new JsonObject();
    object.addProperty("modifiers", method.getModifiers());
    object.addProperty("constructor", method.isConstructor());
    object.add("argumentNames", toJsonArrayString(method.getArgumentNames()));
    object.add("annotations", toJsonAnnotations(method.getAnnotations()));
    object.add("defaultValue", toJsonDefaultValue(method.getDefaultValue()));
    object.add("exceptionTypeNames", toJsonArrayString(method.getExceptionTypeNames()));
    object.add("genericSignature", method.getGenericSignature() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(method.getGenericSignature())));
    object.add("methodDescriptor", method.getMethodDescriptor() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(method.getMethodDescriptor())));
    object.add("parameterAnnotations", toJsonParameterAnnotations(method));
    object.add("selector", method.getSelector() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(method.getSelector())));
    object.addProperty("tagBits", String.valueOf(method.getTagBits()));
    object.addProperty("clinit", method.isClinit());
    return object;
}