Java Code Examples for sun.tools.java.ClassDefinition#getName()

The following examples show how to use sun.tools.java.ClassDefinition#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompoundType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected ValueType[] getMethodExceptions (MemberDefinition member,
                                           boolean quiet,
                                           ContextStack stack) throws Exception {

    boolean result = true;
    stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
    ClassDeclaration[] except = member.getExceptions(env);
    ValueType[] exceptions = new ValueType[except.length];

    try {
        for (int i = 0; i < except.length; i++) {
            ClassDefinition theClass = except[i].getClassDefinition(env);
            try {
                ValueType type = ValueType.forValue(theClass,stack,false);
                if (type != null) {
                        exceptions[i] = type;
                    } else {
                        result = false;
                    }
            } catch (ClassCastException e1) {
                failedConstraint(22,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
            } catch (NullPointerException e2) {
                failedConstraint(23,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: caught null pointer exception");
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(quiet,stack,e);
        result = false;
    }

    if (!result) {
        throw new Exception();
    }

    // Remove any duplicates (javac seems to allow them, but rmic will
    // generate bad ties)...

    int dupCount = 0;
    for (int i = 0; i < exceptions.length; i++) {
        for (int j = 0; j < exceptions.length; j++) {
            if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
                exceptions[j] = null;
                dupCount++;
            }
        }
    }
    if (dupCount > 0) {
        int offset = 0;
        ValueType[] temp = new ValueType[exceptions.length - dupCount];
        for (int i = 0; i < exceptions.length; i++) {
            if (exceptions[i] != null) {
                temp[offset++] = exceptions[i];
            }
        }
        exceptions = temp;
    }

    return exceptions;
}
 
Example 2
Source File: CompoundType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected ValueType[] getMethodExceptions (MemberDefinition member,
                                           boolean quiet,
                                           ContextStack stack) throws Exception {

    boolean result = true;
    stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
    ClassDeclaration[] except = member.getExceptions(env);
    ValueType[] exceptions = new ValueType[except.length];

    try {
        for (int i = 0; i < except.length; i++) {
            ClassDefinition theClass = except[i].getClassDefinition(env);
            try {
                ValueType type = ValueType.forValue(theClass,stack,false);
                if (type != null) {
                        exceptions[i] = type;
                    } else {
                        result = false;
                    }
            } catch (ClassCastException e1) {
                failedConstraint(22,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
            } catch (NullPointerException e2) {
                failedConstraint(23,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: caught null pointer exception");
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(quiet,stack,e);
        result = false;
    }

    if (!result) {
        throw new Exception();
    }

    // Remove any duplicates (javac seems to allow them, but rmic will
    // generate bad ties)...

    int dupCount = 0;
    for (int i = 0; i < exceptions.length; i++) {
        for (int j = 0; j < exceptions.length; j++) {
            if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
                exceptions[j] = null;
                dupCount++;
            }
        }
    }
    if (dupCount > 0) {
        int offset = 0;
        ValueType[] temp = new ValueType[exceptions.length - dupCount];
        for (int i = 0; i < exceptions.length; i++) {
            if (exceptions[i] != null) {
                temp[offset++] = exceptions[i];
            }
        }
        exceptions = temp;
    }

    return exceptions;
}
 
Example 3
Source File: CompoundType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a CompoundType instance for the given class.  The resulting
 * object is not yet completely initialized.
 */
protected CompoundType(ContextStack stack, ClassDefinition classDef,
                       int typeCode) {
    super(stack,typeCode);
    this.classDef = classDef;
    classDecl = classDef.getClassDeclaration();

    // If we are an inner class/interface, reset the type codes...

    if (classDef.isInnerClass()) {
        setTypeCode(typeCode | TM_INNER);
    }

    // Set special flags...

    setFlags();

    // Set names...

    Identifier id = classDef.getName();
    String idlName;
    String[] idlModuleNames;

    try {

        // These can fail if we get case-sensitive name matches...

        idlName = IDLNames.getClassOrInterfaceName(id,env);
        idlModuleNames = IDLNames.getModuleNames(id,isBoxed(),env);

        setNames(id,idlModuleNames,idlName);

        // Is this an exception?

        if (isException()) {

            // Yes, so set our mangled exception names...

            isException = true;
            idlExceptionName = IDLNames.getExceptionName(getIDLName());
            qualifiedIDLExceptionName =
                IDLNames.getQualifiedName(getIDLModuleNames(),idlExceptionName);
        }

        // Set interfaces, methods and members...

        interfaces = null;          // set in initialize()
        methods = null;                     // set in initialize()
        members = null;                 // set in initialize()

    } catch (Exception e) {
        failedConstraint(7,false,stack,id.toString(),e.getMessage());
        throw new CompilerError("");
    }
}
 
Example 4
Source File: SpecialClassType.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an SpecialClassType instance for the given class.
 */
private SpecialClassType(ContextStack stack, int typeCode,
                         ClassDefinition theClass) {
    super(stack,typeCode | TM_SPECIAL_CLASS | TM_CLASS | TM_COMPOUND, theClass);
    Identifier id = theClass.getName();
    String idlName = null;
    String[] idlModuleName = null;
    boolean constant = stack.size() > 0 && stack.getContext().isConstant();

    // Set names...

    switch (typeCode) {
    case TYPE_STRING:   {
        idlName = IDLNames.getTypeName(typeCode,constant);
        if (!constant) {
            idlModuleName = IDL_CORBA_MODULE;
        }
        break;
    }

    case TYPE_ANY:   {
        idlName = IDL_JAVA_LANG_OBJECT;
        idlModuleName = IDL_JAVA_LANG_MODULE;
        break;
    }
    }

    setNames(id,idlModuleName,idlName);

    // Init parents...

    if (!initParents(stack)) {

        // Should not be possible!

        throw new CompilerError("SpecialClassType found invalid parent.");
    }

    // Initialize CompoundType...

    initialize(null,null,null,stack,false);
}
 
Example 5
Source File: CompoundType.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected ValueType[] getMethodExceptions (MemberDefinition member,
                                           boolean quiet,
                                           ContextStack stack) throws Exception {

    boolean result = true;
    stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
    ClassDeclaration[] except = member.getExceptions(env);
    ValueType[] exceptions = new ValueType[except.length];

    try {
        for (int i = 0; i < except.length; i++) {
            ClassDefinition theClass = except[i].getClassDefinition(env);
            try {
                ValueType type = ValueType.forValue(theClass,stack,false);
                if (type != null) {
                        exceptions[i] = type;
                    } else {
                        result = false;
                    }
            } catch (ClassCastException e1) {
                failedConstraint(22,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
            } catch (NullPointerException e2) {
                failedConstraint(23,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: caught null pointer exception");
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(quiet,stack,e);
        result = false;
    }

    if (!result) {
        throw new Exception();
    }

    // Remove any duplicates (javac seems to allow them, but rmic will
    // generate bad ties)...

    int dupCount = 0;
    for (int i = 0; i < exceptions.length; i++) {
        for (int j = 0; j < exceptions.length; j++) {
            if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
                exceptions[j] = null;
                dupCount++;
            }
        }
    }
    if (dupCount > 0) {
        int offset = 0;
        ValueType[] temp = new ValueType[exceptions.length - dupCount];
        for (int i = 0; i < exceptions.length; i++) {
            if (exceptions[i] != null) {
                temp[offset++] = exceptions[i];
            }
        }
        exceptions = temp;
    }

    return exceptions;
}
 
Example 6
Source File: CompoundType.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a CompoundType instance for the given class.  The resulting
 * object is not yet completely initialized.
 */
protected CompoundType(ContextStack stack, ClassDefinition classDef,
                       int typeCode) {
    super(stack,typeCode);
    this.classDef = classDef;
    classDecl = classDef.getClassDeclaration();

    // If we are an inner class/interface, reset the type codes...

    if (classDef.isInnerClass()) {
        setTypeCode(typeCode | TM_INNER);
    }

    // Set special flags...

    setFlags();

    // Set names...

    Identifier id = classDef.getName();
    String idlName;
    String[] idlModuleNames;

    try {

        // These can fail if we get case-sensitive name matches...

        idlName = IDLNames.getClassOrInterfaceName(id,env);
        idlModuleNames = IDLNames.getModuleNames(id,isBoxed(),env);

        setNames(id,idlModuleNames,idlName);

        // Is this an exception?

        if (isException()) {

            // Yes, so set our mangled exception names...

            isException = true;
            idlExceptionName = IDLNames.getExceptionName(getIDLName());
            qualifiedIDLExceptionName =
                IDLNames.getQualifiedName(getIDLModuleNames(),idlExceptionName);
        }

        // Set interfaces, methods and members...

        interfaces = null;          // set in initialize()
        methods = null;                     // set in initialize()
        members = null;                 // set in initialize()

    } catch (Exception e) {
        failedConstraint(7,false,stack,id.toString(),e.getMessage());
        throw new CompilerError("");
    }
}
 
Example 7
Source File: SpecialClassType.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an SpecialClassType instance for the given class.
 */
private SpecialClassType(ContextStack stack, int typeCode,
                         ClassDefinition theClass) {
    super(stack,typeCode | TM_SPECIAL_CLASS | TM_CLASS | TM_COMPOUND, theClass);
    Identifier id = theClass.getName();
    String idlName = null;
    String[] idlModuleName = null;
    boolean constant = stack.size() > 0 && stack.getContext().isConstant();

    // Set names...

    switch (typeCode) {
    case TYPE_STRING:   {
        idlName = IDLNames.getTypeName(typeCode,constant);
        if (!constant) {
            idlModuleName = IDL_CORBA_MODULE;
        }
        break;
    }

    case TYPE_ANY:   {
        idlName = IDL_JAVA_LANG_OBJECT;
        idlModuleName = IDL_JAVA_LANG_MODULE;
        break;
    }
    }

    setNames(id,idlModuleName,idlName);

    // Init parents...

    if (!initParents(stack)) {

        // Should not be possible!

        throw new CompilerError("SpecialClassType found invalid parent.");
    }

    // Initialize CompoundType...

    initialize(null,null,null,stack,false);
}
 
Example 8
Source File: CompoundType.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected ValueType[] getMethodExceptions (MemberDefinition member,
                                           boolean quiet,
                                           ContextStack stack) throws Exception {

    boolean result = true;
    stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
    ClassDeclaration[] except = member.getExceptions(env);
    ValueType[] exceptions = new ValueType[except.length];

    try {
        for (int i = 0; i < except.length; i++) {
            ClassDefinition theClass = except[i].getClassDefinition(env);
            try {
                ValueType type = ValueType.forValue(theClass,stack,false);
                if (type != null) {
                        exceptions[i] = type;
                    } else {
                        result = false;
                    }
            } catch (ClassCastException e1) {
                failedConstraint(22,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
            } catch (NullPointerException e2) {
                failedConstraint(23,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: caught null pointer exception");
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(quiet,stack,e);
        result = false;
    }

    if (!result) {
        throw new Exception();
    }

    // Remove any duplicates (javac seems to allow them, but rmic will
    // generate bad ties)...

    int dupCount = 0;
    for (int i = 0; i < exceptions.length; i++) {
        for (int j = 0; j < exceptions.length; j++) {
            if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
                exceptions[j] = null;
                dupCount++;
            }
        }
    }
    if (dupCount > 0) {
        int offset = 0;
        ValueType[] temp = new ValueType[exceptions.length - dupCount];
        for (int i = 0; i < exceptions.length; i++) {
            if (exceptions[i] != null) {
                temp[offset++] = exceptions[i];
            }
        }
        exceptions = temp;
    }

    return exceptions;
}
 
Example 9
Source File: SpecialClassType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an SpecialClassType instance for the given class.
 */
private SpecialClassType(ContextStack stack, int typeCode,
                         ClassDefinition theClass) {
    super(stack,typeCode | TM_SPECIAL_CLASS | TM_CLASS | TM_COMPOUND, theClass);
    Identifier id = theClass.getName();
    String idlName = null;
    String[] idlModuleName = null;
    boolean constant = stack.size() > 0 && stack.getContext().isConstant();

    // Set names...

    switch (typeCode) {
    case TYPE_STRING:   {
        idlName = IDLNames.getTypeName(typeCode,constant);
        if (!constant) {
            idlModuleName = IDL_CORBA_MODULE;
        }
        break;
    }

    case TYPE_ANY:   {
        idlName = IDL_JAVA_LANG_OBJECT;
        idlModuleName = IDL_JAVA_LANG_MODULE;
        break;
    }
    }

    setNames(id,idlModuleName,idlName);

    // Init parents...

    if (!initParents(stack)) {

        // Should not be possible!

        throw new CompilerError("SpecialClassType found invalid parent.");
    }

    // Initialize CompoundType...

    initialize(null,null,null,stack,false);
}
 
Example 10
Source File: SpecialClassType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an SpecialClassType instance for the given class.
 */
private SpecialClassType(ContextStack stack, int typeCode,
                         ClassDefinition theClass) {
    super(stack,typeCode | TM_SPECIAL_CLASS | TM_CLASS | TM_COMPOUND, theClass);
    Identifier id = theClass.getName();
    String idlName = null;
    String[] idlModuleName = null;
    boolean constant = stack.size() > 0 && stack.getContext().isConstant();

    // Set names...

    switch (typeCode) {
    case TYPE_STRING:   {
        idlName = IDLNames.getTypeName(typeCode,constant);
        if (!constant) {
            idlModuleName = IDL_CORBA_MODULE;
        }
        break;
    }

    case TYPE_ANY:   {
        idlName = IDL_JAVA_LANG_OBJECT;
        idlModuleName = IDL_JAVA_LANG_MODULE;
        break;
    }
    }

    setNames(id,idlModuleName,idlName);

    // Init parents...

    if (!initParents(stack)) {

        // Should not be possible!

        throw new CompilerError("SpecialClassType found invalid parent.");
    }

    // Initialize CompoundType...

    initialize(null,null,null,stack,false);
}
 
Example 11
Source File: CompoundType.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a CompoundType instance for the given class.  The resulting
 * object is not yet completely initialized.
 */
protected CompoundType(ContextStack stack, ClassDefinition classDef,
                       int typeCode) {
    super(stack,typeCode);
    this.classDef = classDef;
    classDecl = classDef.getClassDeclaration();

    // If we are an inner class/interface, reset the type codes...

    if (classDef.isInnerClass()) {
        setTypeCode(typeCode | TM_INNER);
    }

    // Set special flags...

    setFlags();

    // Set names...

    Identifier id = classDef.getName();
    String idlName;
    String[] idlModuleNames;

    try {

        // These can fail if we get case-sensitive name matches...

        idlName = IDLNames.getClassOrInterfaceName(id,env);
        idlModuleNames = IDLNames.getModuleNames(id,isBoxed(),env);

        setNames(id,idlModuleNames,idlName);

        // Is this an exception?

        if (isException()) {

            // Yes, so set our mangled exception names...

            isException = true;
            idlExceptionName = IDLNames.getExceptionName(getIDLName());
            qualifiedIDLExceptionName =
                IDLNames.getQualifiedName(getIDLModuleNames(),idlExceptionName);
        }

        // Set interfaces, methods and members...

        interfaces = null;          // set in initialize()
        methods = null;                     // set in initialize()
        members = null;                 // set in initialize()

    } catch (Exception e) {
        failedConstraint(7,false,stack,id.toString(),e.getMessage());
        throw new CompilerError("");
    }
}
 
Example 12
Source File: CompoundType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a CompoundType instance for the given class.  The resulting
 * object is not yet completely initialized.
 */
protected CompoundType(ContextStack stack, ClassDefinition classDef,
                       int typeCode) {
    super(stack,typeCode);
    this.classDef = classDef;
    classDecl = classDef.getClassDeclaration();

    // If we are an inner class/interface, reset the type codes...

    if (classDef.isInnerClass()) {
        setTypeCode(typeCode | TM_INNER);
    }

    // Set special flags...

    setFlags();

    // Set names...

    Identifier id = classDef.getName();
    String idlName;
    String[] idlModuleNames;

    try {

        // These can fail if we get case-sensitive name matches...

        idlName = IDLNames.getClassOrInterfaceName(id,env);
        idlModuleNames = IDLNames.getModuleNames(id,isBoxed(),env);

        setNames(id,idlModuleNames,idlName);

        // Is this an exception?

        if (isException()) {

            // Yes, so set our mangled exception names...

            isException = true;
            idlExceptionName = IDLNames.getExceptionName(getIDLName());
            qualifiedIDLExceptionName =
                IDLNames.getQualifiedName(getIDLModuleNames(),idlExceptionName);
        }

        // Set interfaces, methods and members...

        interfaces = null;          // set in initialize()
        methods = null;                     // set in initialize()
        members = null;                 // set in initialize()

    } catch (Exception e) {
        failedConstraint(7,false,stack,id.toString(),e.getMessage());
        throw new CompilerError("");
    }
}
 
Example 13
Source File: SpecialClassType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an SpecialClassType instance for the given class.
 */
private SpecialClassType(ContextStack stack, int typeCode,
                         ClassDefinition theClass) {
    super(stack,typeCode | TM_SPECIAL_CLASS | TM_CLASS | TM_COMPOUND, theClass);
    Identifier id = theClass.getName();
    String idlName = null;
    String[] idlModuleName = null;
    boolean constant = stack.size() > 0 && stack.getContext().isConstant();

    // Set names...

    switch (typeCode) {
    case TYPE_STRING:   {
        idlName = IDLNames.getTypeName(typeCode,constant);
        if (!constant) {
            idlModuleName = IDL_CORBA_MODULE;
        }
        break;
    }

    case TYPE_ANY:   {
        idlName = IDL_JAVA_LANG_OBJECT;
        idlModuleName = IDL_JAVA_LANG_MODULE;
        break;
    }
    }

    setNames(id,idlModuleName,idlName);

    // Init parents...

    if (!initParents(stack)) {

        // Should not be possible!

        throw new CompilerError("SpecialClassType found invalid parent.");
    }

    // Initialize CompoundType...

    initialize(null,null,null,stack,false);
}
 
Example 14
Source File: CompoundType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected ValueType[] getMethodExceptions (MemberDefinition member,
                                           boolean quiet,
                                           ContextStack stack) throws Exception {

    boolean result = true;
    stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
    ClassDeclaration[] except = member.getExceptions(env);
    ValueType[] exceptions = new ValueType[except.length];

    try {
        for (int i = 0; i < except.length; i++) {
            ClassDefinition theClass = except[i].getClassDefinition(env);
            try {
                ValueType type = ValueType.forValue(theClass,stack,false);
                if (type != null) {
                        exceptions[i] = type;
                    } else {
                        result = false;
                    }
            } catch (ClassCastException e1) {
                failedConstraint(22,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
            } catch (NullPointerException e2) {
                failedConstraint(23,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: caught null pointer exception");
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(quiet,stack,e);
        result = false;
    }

    if (!result) {
        throw new Exception();
    }

    // Remove any duplicates (javac seems to allow them, but rmic will
    // generate bad ties)...

    int dupCount = 0;
    for (int i = 0; i < exceptions.length; i++) {
        for (int j = 0; j < exceptions.length; j++) {
            if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
                exceptions[j] = null;
                dupCount++;
            }
        }
    }
    if (dupCount > 0) {
        int offset = 0;
        ValueType[] temp = new ValueType[exceptions.length - dupCount];
        for (int i = 0; i < exceptions.length; i++) {
            if (exceptions[i] != null) {
                temp[offset++] = exceptions[i];
            }
        }
        exceptions = temp;
    }

    return exceptions;
}
 
Example 15
Source File: CompoundType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a CompoundType instance for the given class.  The resulting
 * object is not yet completely initialized.
 */
protected CompoundType(ContextStack stack, ClassDefinition classDef,
                       int typeCode) {
    super(stack,typeCode);
    this.classDef = classDef;
    classDecl = classDef.getClassDeclaration();

    // If we are an inner class/interface, reset the type codes...

    if (classDef.isInnerClass()) {
        setTypeCode(typeCode | TM_INNER);
    }

    // Set special flags...

    setFlags();

    // Set names...

    Identifier id = classDef.getName();
    String idlName;
    String[] idlModuleNames;

    try {

        // These can fail if we get case-sensitive name matches...

        idlName = IDLNames.getClassOrInterfaceName(id,env);
        idlModuleNames = IDLNames.getModuleNames(id,isBoxed(),env);

        setNames(id,idlModuleNames,idlName);

        // Is this an exception?

        if (isException()) {

            // Yes, so set our mangled exception names...

            isException = true;
            idlExceptionName = IDLNames.getExceptionName(getIDLName());
            qualifiedIDLExceptionName =
                IDLNames.getQualifiedName(getIDLModuleNames(),idlExceptionName);
        }

        // Set interfaces, methods and members...

        interfaces = null;          // set in initialize()
        methods = null;                     // set in initialize()
        members = null;                 // set in initialize()

    } catch (Exception e) {
        failedConstraint(7,false,stack,id.toString(),e.getMessage());
        throw new CompilerError("");
    }
}
 
Example 16
Source File: CompoundType.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a CompoundType instance for the given class.  The resulting
 * object is not yet completely initialized.
 */
protected CompoundType(ContextStack stack, ClassDefinition classDef,
                       int typeCode) {
    super(stack,typeCode);
    this.classDef = classDef;
    classDecl = classDef.getClassDeclaration();

    // If we are an inner class/interface, reset the type codes...

    if (classDef.isInnerClass()) {
        setTypeCode(typeCode | TM_INNER);
    }

    // Set special flags...

    setFlags();

    // Set names...

    Identifier id = classDef.getName();
    String idlName;
    String[] idlModuleNames;

    try {

        // These can fail if we get case-sensitive name matches...

        idlName = IDLNames.getClassOrInterfaceName(id,env);
        idlModuleNames = IDLNames.getModuleNames(id,isBoxed(),env);

        setNames(id,idlModuleNames,idlName);

        // Is this an exception?

        if (isException()) {

            // Yes, so set our mangled exception names...

            isException = true;
            idlExceptionName = IDLNames.getExceptionName(getIDLName());
            qualifiedIDLExceptionName =
                IDLNames.getQualifiedName(getIDLModuleNames(),idlExceptionName);
        }

        // Set interfaces, methods and members...

        interfaces = null;          // set in initialize()
        methods = null;                     // set in initialize()
        members = null;                 // set in initialize()

    } catch (Exception e) {
        failedConstraint(7,false,stack,id.toString(),e.getMessage());
        throw new CompilerError("");
    }
}
 
Example 17
Source File: CompoundType.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected ValueType[] getMethodExceptions (MemberDefinition member,
                                           boolean quiet,
                                           ContextStack stack) throws Exception {

    boolean result = true;
    stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
    ClassDeclaration[] except = member.getExceptions(env);
    ValueType[] exceptions = new ValueType[except.length];

    try {
        for (int i = 0; i < except.length; i++) {
            ClassDefinition theClass = except[i].getClassDefinition(env);
            try {
                ValueType type = ValueType.forValue(theClass,stack,false);
                if (type != null) {
                        exceptions[i] = type;
                    } else {
                        result = false;
                    }
            } catch (ClassCastException e1) {
                failedConstraint(22,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
            } catch (NullPointerException e2) {
                failedConstraint(23,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: caught null pointer exception");
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(quiet,stack,e);
        result = false;
    }

    if (!result) {
        throw new Exception();
    }

    // Remove any duplicates (javac seems to allow them, but rmic will
    // generate bad ties)...

    int dupCount = 0;
    for (int i = 0; i < exceptions.length; i++) {
        for (int j = 0; j < exceptions.length; j++) {
            if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
                exceptions[j] = null;
                dupCount++;
            }
        }
    }
    if (dupCount > 0) {
        int offset = 0;
        ValueType[] temp = new ValueType[exceptions.length - dupCount];
        for (int i = 0; i < exceptions.length; i++) {
            if (exceptions[i] != null) {
                temp[offset++] = exceptions[i];
            }
        }
        exceptions = temp;
    }

    return exceptions;
}
 
Example 18
Source File: CompoundType.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a CompoundType instance for the given class.  The resulting
 * object is not yet completely initialized.
 */
protected CompoundType(ContextStack stack, ClassDefinition classDef,
                       int typeCode) {
    super(stack,typeCode);
    this.classDef = classDef;
    classDecl = classDef.getClassDeclaration();

    // If we are an inner class/interface, reset the type codes...

    if (classDef.isInnerClass()) {
        setTypeCode(typeCode | TM_INNER);
    }

    // Set special flags...

    setFlags();

    // Set names...

    Identifier id = classDef.getName();
    String idlName;
    String[] idlModuleNames;

    try {

        // These can fail if we get case-sensitive name matches...

        idlName = IDLNames.getClassOrInterfaceName(id,env);
        idlModuleNames = IDLNames.getModuleNames(id,isBoxed(),env);

        setNames(id,idlModuleNames,idlName);

        // Is this an exception?

        if (isException()) {

            // Yes, so set our mangled exception names...

            isException = true;
            idlExceptionName = IDLNames.getExceptionName(getIDLName());
            qualifiedIDLExceptionName =
                IDLNames.getQualifiedName(getIDLModuleNames(),idlExceptionName);
        }

        // Set interfaces, methods and members...

        interfaces = null;          // set in initialize()
        methods = null;                     // set in initialize()
        members = null;                 // set in initialize()

    } catch (Exception e) {
        failedConstraint(7,false,stack,id.toString(),e.getMessage());
        throw new CompilerError("");
    }
}
 
Example 19
Source File: SpecialClassType.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an SpecialClassType instance for the given class.
 */
private SpecialClassType(ContextStack stack, int typeCode,
                         ClassDefinition theClass) {
    super(stack,typeCode | TM_SPECIAL_CLASS | TM_CLASS | TM_COMPOUND, theClass);
    Identifier id = theClass.getName();
    String idlName = null;
    String[] idlModuleName = null;
    boolean constant = stack.size() > 0 && stack.getContext().isConstant();

    // Set names...

    switch (typeCode) {
    case TYPE_STRING:   {
        idlName = IDLNames.getTypeName(typeCode,constant);
        if (!constant) {
            idlModuleName = IDL_CORBA_MODULE;
        }
        break;
    }

    case TYPE_ANY:   {
        idlName = IDL_JAVA_LANG_OBJECT;
        idlModuleName = IDL_JAVA_LANG_MODULE;
        break;
    }
    }

    setNames(id,idlModuleName,idlName);

    // Init parents...

    if (!initParents(stack)) {

        // Should not be possible!

        throw new CompilerError("SpecialClassType found invalid parent.");
    }

    // Initialize CompoundType...

    initialize(null,null,null,stack,false);
}
 
Example 20
Source File: CompoundType.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected ValueType[] getMethodExceptions (MemberDefinition member,
                                           boolean quiet,
                                           ContextStack stack) throws Exception {

    boolean result = true;
    stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
    ClassDeclaration[] except = member.getExceptions(env);
    ValueType[] exceptions = new ValueType[except.length];

    try {
        for (int i = 0; i < except.length; i++) {
            ClassDefinition theClass = except[i].getClassDefinition(env);
            try {
                ValueType type = ValueType.forValue(theClass,stack,false);
                if (type != null) {
                        exceptions[i] = type;
                    } else {
                        result = false;
                    }
            } catch (ClassCastException e1) {
                failedConstraint(22,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
            } catch (NullPointerException e2) {
                failedConstraint(23,quiet,stack,getQualifiedName());
                throw new CompilerError("Method: caught null pointer exception");
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(quiet,stack,e);
        result = false;
    }

    if (!result) {
        throw new Exception();
    }

    // Remove any duplicates (javac seems to allow them, but rmic will
    // generate bad ties)...

    int dupCount = 0;
    for (int i = 0; i < exceptions.length; i++) {
        for (int j = 0; j < exceptions.length; j++) {
            if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
                exceptions[j] = null;
                dupCount++;
            }
        }
    }
    if (dupCount > 0) {
        int offset = 0;
        ValueType[] temp = new ValueType[exceptions.length - dupCount];
        for (int i = 0; i < exceptions.length; i++) {
            if (exceptions[i] != null) {
                temp[offset++] = exceptions[i];
            }
        }
        exceptions = temp;
    }

    return exceptions;
}