Java Code Examples for com.sun.javadoc.ClassDoc#subclassOf()

The following examples show how to use com.sun.javadoc.ClassDoc#subclassOf() . 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: RemoteClass.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 2
Source File: RemoteClass.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 3
Source File: RemoteClass.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 4
Source File: RemoteClass.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 5
Source File: RemoteClass.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 6
Source File: RemoteClass.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 7
Source File: RemoteClass.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 8
Source File: RemoteClass.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 9
Source File: RemoteClass.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 10
Source File: RemoteClass.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds to the supplied list all exceptions in the "froms"
 * array that are subclasses of an exception in the "withs"
 * array.
 **/
private void collectCompatibleExceptions(ClassDoc[] froms,
                                         ClassDoc[] withs,
                                         List<ClassDoc> list)
{
    for (ClassDoc from : froms) {
        if (!list.contains(from)) {
            for (ClassDoc with : withs) {
                if (from.subclassOf(with)) {
                    list.add(from);
                    break;
                }
            }
        }
    }
}
 
Example 11
Source File: StubSkeletonWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 12
Source File: StubSkeletonWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 13
Source File: StubSkeletonWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 14
Source File: StubSkeletonWriter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 15
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 16
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 17
Source File: StubSkeletonWriter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 18
Source File: StubSkeletonWriter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 19
Source File: StubSkeletonWriter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}
 
Example 20
Source File: StubSkeletonWriter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Computes the exceptions that 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 list containing the
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the list,
 * 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 list (unless any of their superclasses
 * are already present), since those exceptions should always be
 * directly rethrown by a stub method.
 *
 * The returned list 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 List<ClassDoc> computeUniqueCatchList(ClassDoc[] exceptions) {
    List<ClassDoc> uniqueList = new ArrayList<ClassDoc>();

    uniqueList.add(env.docRuntimeException());
    uniqueList.add(env.docRemoteException()); // always catch/rethrow these

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (ClassDoc ex : exceptions) {
        if (env.docException().subclassOf(ex)) {
            /*
             * 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 (!ex.subclassOf(env.docException())) {
            /*
             * Ignore other Throwables that do not extend Exception,
             * because they cannot be thrown by the invoke methods.
             */
            continue;
        }
        /*
         * Compare this exception against the current list of
         * exceptions that need to be caught:
         */
        for (Iterator<ClassDoc> i = uniqueList.iterator(); i.hasNext();) {
            ClassDoc ex2 = i.next();
            if (ex.subclassOf(ex2)) {
                /*
                 * If a superclass of this exception is already on
                 * the list to catch, then ignore this one and continue;
                 */
                continue nextException;
            } else if (ex2.subclassOf(ex)) {
                /*
                 * If a subclass of this exception is on the list
                 * to catch, then remove it;
                 */
                i.remove();
            }
        }
        /* This exception is unique: add it to the list to catch. */
        uniqueList.add(ex);
    }
    return uniqueList;
}