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

The following examples show how to use sun.tools.java.ClassDefinition#superClassOf() . 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: RMIGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 2
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 3
Source File: RMIGenerator.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 4
Source File: RMIGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 5
Source File: CompoundType.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}
 
Example 6
Source File: RMIGenerator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 7
Source File: CompoundType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}
 
Example 8
Source File: RMIGenerator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 9
Source File: CompoundType.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}
 
Example 10
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 11
Source File: RMIGenerator.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 12
Source File: CompoundType.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}
 
Example 13
Source File: RMIGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 14
Source File: CompoundType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}
 
Example 15
Source File: RMIGenerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 16
Source File: CompoundType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}
 
Example 17
Source File: RMIGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 18
Source File: CompoundType.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}
 
Example 19
Source File: RMIGenerator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 20
Source File: CompoundType.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return an array containing only those exceptions which
 * need to be caught.  Removes java.rmi.RemoteException,
 * java.lang.RuntimeException, java.lang.Error, and their
 * subclasses, then removes any exceptions which are more
 * derived than another in the list. Returns null if no
 * exceptions need to be caught.
 */
public ValueType[] getUniqueCatchList(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        // First, remove RemoteException, RuntimeException, Error, and their subclasses...
        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if (env.defRemoteException.superClassOf(env, decl) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = null;
                newSize--;
            }
        }

        // Now remove derived types...
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                ClassDefinition current = list[i].getClassDefinition();
                for (int j = 0; j < list.length; j++) {
                    if (j != i && list[i] != null && list[j] != null &&
                        current.superClassOf(env, list[j].getClassDeclaration())) {
                        list[j] = null;
                        newSize--;
                    }
                }
            }
        }

    } catch (ClassNotFound e) {
        classNotFound(stack,e); // Report error but do not stop.
    }

    // Create new list if we removed anything...

    if (newSize < list.length) {
        ValueType[] temp = new ValueType[newSize];
        int offset = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != null) {
                temp[offset++] = list[i];
            }
        }
        list = temp;
    }

    if (list.length == 0) {
        return null;
    } else {
        return list;
    }
}