sun.tools.java.ClassDeclaration Java Examples

The following examples show how to use sun.tools.java.ClassDeclaration. 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
/**
 * Add to the supplied list all exceptions in the "from" array
 * that are subclasses of an exception in the "with" array.
 */
private void collectCompatibleExceptions(ClassDeclaration[] from,
                                         ClassDeclaration[] with,
                                         Vector<ClassDeclaration> list)
    throws ClassNotFound
{
    for (int i = 0; i < from.length; i++) {
        ClassDefinition exceptionDef = from[i].getClassDefinition(env);
        if (!list.contains(from[i])) {
            for (int j = 0; j < with.length; j++) {
                if (exceptionDef.subClassOf(env, with[j])) {
                    list.addElement(from[i]);
                    break;
                }
            }
        }
    }
}
 
Example #2
Source File: ClassType.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected boolean initParents(ContextStack stack) {

        stack.setNewContextCode(ContextStack.EXTENDS);
        BatchEnvironment env = stack.getEnv();

        // Init parent...

        boolean result = true;

        try {
            ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
            if (parentDecl != null) {
                ClassDefinition parentDef = parentDecl.getClassDefinition(env);
                parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
                if (parent == null) {
                    result = false;
                }
            }
        } catch (ClassNotFound e) {
            classNotFound(stack,e);
            throw new CompilerError("ClassType constructor");
        }

        return result;
    }
 
Example #3
Source File: CompoundType.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected boolean inheritsFrom(ClassDefinition def, ClassDefinition otherDef) {
    if (def == otherDef)
        return true;

    ClassDefinition superDef;
    if (def.getSuperClass() != null) {
        superDef = def.getSuperClass().getClassDefinition();
        if (inheritsFrom(superDef, otherDef))
            return true;
    }

    ClassDeclaration[] interfaces = def.getInterfaces();
    for (int i=0; i<interfaces.length; i++) {
        superDef = interfaces[i].getClassDefinition();
        if (inheritsFrom(superDef, otherDef))
            return true;
    }
    return false;
}
 
Example #4
Source File: RemoteClass.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add to the supplied list all exceptions in the "from" array
 * that are subclasses of an exception in the "with" array.
 */
private void collectCompatibleExceptions(ClassDeclaration[] from,
                                         ClassDeclaration[] with,
                                         Vector<ClassDeclaration> list)
    throws ClassNotFound
{
    for (int i = 0; i < from.length; i++) {
        ClassDefinition exceptionDef = from[i].getClassDefinition(env);
        if (!list.contains(from[i])) {
            for (int j = 0; j < with.length; j++) {
                if (exceptionDef.subClassOf(env, with[j])) {
                    list.addElement(from[i]);
                    break;
                }
            }
        }
    }
}
 
Example #5
Source File: ClassType.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected boolean initParents(ContextStack stack) {

        stack.setNewContextCode(ContextStack.EXTENDS);
        BatchEnvironment env = stack.getEnv();

        // Init parent...

        boolean result = true;

        try {
            ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
            if (parentDecl != null) {
                ClassDefinition parentDef = parentDecl.getClassDefinition(env);
                parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
                if (parent == null) {
                    result = false;
                }
            }
        } catch (ClassNotFound e) {
            classNotFound(stack,e);
            throw new CompilerError("ClassType constructor");
        }

        return result;
    }
 
Example #6
Source File: RemoteClass.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sort array of class declarations alphabetically by their mangled
 * fully-qualified class name.  This is used to feed a method's exceptions
 * in a canonical order into the digest stream for the interface hash
 * computation.
 */
private void sortClassDeclarations(ClassDeclaration[] decl) {
    for (int i = 1; i < decl.length; i++) {
        ClassDeclaration curr = decl[i];
        String name = Names.mangleClass(curr.getName()).toString();
        int j;
        for (j = i; j > 0; j--) {
            if (name.compareTo(
                               Names.mangleClass(decl[j - 1].getName()).toString()) >= 0)
                {
                    break;
                }
            decl[j] = decl[j - 1];
        }
        decl[j] = curr;
    }
}
 
Example #7
Source File: RemoteClass.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add to the supplied list all exceptions in the "from" array
 * that are subclasses of an exception in the "with" array.
 */
private void collectCompatibleExceptions(ClassDeclaration[] from,
                                         ClassDeclaration[] with,
                                         Vector<ClassDeclaration> list)
    throws ClassNotFound
{
    for (int i = 0; i < from.length; i++) {
        ClassDefinition exceptionDef = from[i].getClassDefinition(env);
        if (!list.contains(from[i])) {
            for (int j = 0; j < with.length; j++) {
                if (exceptionDef.subClassOf(env, with[j])) {
                    list.addElement(from[i]);
                    break;
                }
            }
        }
    }
}
 
Example #8
Source File: RemoteClass.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add to the supplied list all exceptions in the "from" array
 * that are subclasses of an exception in the "with" array.
 */
private void collectCompatibleExceptions(ClassDeclaration[] from,
                                         ClassDeclaration[] with,
                                         Vector<ClassDeclaration> list)
    throws ClassNotFound
{
    for (int i = 0; i < from.length; i++) {
        ClassDefinition exceptionDef = from[i].getClassDefinition(env);
        if (!list.contains(from[i])) {
            for (int j = 0; j < with.length; j++) {
                if (exceptionDef.subClassOf(env, with[j])) {
                    list.addElement(from[i]);
                    break;
                }
            }
        }
    }
}
 
Example #9
Source File: CompoundType.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected boolean inheritsFrom(ClassDefinition def, ClassDefinition otherDef) {
    if (def == otherDef)
        return true;

    ClassDefinition superDef;
    if (def.getSuperClass() != null) {
        superDef = def.getSuperClass().getClassDefinition();
        if (inheritsFrom(superDef, otherDef))
            return true;
    }

    ClassDeclaration[] interfaces = def.getInterfaces();
    for (int i=0; i<interfaces.length; i++) {
        superDef = interfaces[i].getClassDefinition();
        if (inheritsFrom(superDef, otherDef))
            return true;
    }
    return false;
}
 
Example #10
Source File: RemoteClass.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add to the supplied list all exceptions in the "from" array
 * that are subclasses of an exception in the "with" array.
 */
private void collectCompatibleExceptions(ClassDeclaration[] from,
                                         ClassDeclaration[] with,
                                         Vector<ClassDeclaration> list)
    throws ClassNotFound
{
    for (int i = 0; i < from.length; i++) {
        ClassDefinition exceptionDef = from[i].getClassDefinition(env);
        if (!list.contains(from[i])) {
            for (int j = 0; j < with.length; j++) {
                if (exceptionDef.subClassOf(env, with[j])) {
                    list.addElement(from[i]);
                    break;
                }
            }
        }
    }
}
 
Example #11
Source File: RemoteClass.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add to the supplied list all exceptions in the "from" array
 * that are subclasses of an exception in the "with" array.
 */
private void collectCompatibleExceptions(ClassDeclaration[] from,
                                         ClassDeclaration[] with,
                                         Vector<ClassDeclaration> list)
    throws ClassNotFound
{
    for (int i = 0; i < from.length; i++) {
        ClassDefinition exceptionDef = from[i].getClassDefinition(env);
        if (!list.contains(from[i])) {
            for (int j = 0; j < with.length; j++) {
                if (exceptionDef.subClassOf(env, with[j])) {
                    list.addElement(from[i]);
                    break;
                }
            }
        }
    }
}
 
Example #12
Source File: ClassType.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean initParents(ContextStack stack) {

        stack.setNewContextCode(ContextStack.EXTENDS);
        BatchEnvironment env = stack.getEnv();

        // Init parent...

        boolean result = true;

        try {
            ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
            if (parentDecl != null) {
                ClassDefinition parentDef = parentDecl.getClassDefinition(env);
                parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
                if (parent == null) {
                    result = false;
                }
            }
        } catch (ClassNotFound e) {
            classNotFound(stack,e);
            throw new CompilerError("ClassType constructor");
        }

        return result;
    }
 
Example #13
Source File: CompoundType.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean inheritsFrom(ClassDefinition def, ClassDefinition otherDef) {
    if (def == otherDef)
        return true;

    ClassDefinition superDef;
    if (def.getSuperClass() != null) {
        superDef = def.getSuperClass().getClassDefinition();
        if (inheritsFrom(superDef, otherDef))
            return true;
    }

    ClassDeclaration[] interfaces = def.getInterfaces();
    for (int i=0; i<interfaces.length; i++) {
        superDef = interfaces[i].getClassDefinition();
        if (inheritsFrom(superDef, otherDef))
            return true;
    }
    return false;
}
 
Example #14
Source File: RemoteClass.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sort array of class declarations alphabetically by their mangled
 * fully-qualified class name.  This is used to feed a method's exceptions
 * in a canonical order into the digest stream for the interface hash
 * computation.
 */
private void sortClassDeclarations(ClassDeclaration[] decl) {
    for (int i = 1; i < decl.length; i++) {
        ClassDeclaration curr = decl[i];
        String name = Names.mangleClass(curr.getName()).toString();
        int j;
        for (j = i; j > 0; j--) {
            if (name.compareTo(
                               Names.mangleClass(decl[j - 1].getName()).toString()) >= 0)
                {
                    break;
                }
            decl[j] = decl[j - 1];
        }
        decl[j] = curr;
    }
}
 
Example #15
Source File: RemoteClass.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add to the supplied list all exceptions in the "from" array
 * that are subclasses of an exception in the "with" array.
 */
private void collectCompatibleExceptions(ClassDeclaration[] from,
                                         ClassDeclaration[] with,
                                         Vector<ClassDeclaration> list)
    throws ClassNotFound
{
    for (int i = 0; i < from.length; i++) {
        ClassDefinition exceptionDef = from[i].getClassDefinition(env);
        if (!list.contains(from[i])) {
            for (int j = 0; j < with.length; j++) {
                if (exceptionDef.subClassOf(env, with[j])) {
                    list.addElement(from[i]);
                    break;
                }
            }
        }
    }
}
 
Example #16
Source File: RemoteClass.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sort array of class declarations alphabetically by their mangled
 * fully-qualified class name.  This is used to feed a method's exceptions
 * in a canonical order into the digest stream for the interface hash
 * computation.
 */
private void sortClassDeclarations(ClassDeclaration[] decl) {
    for (int i = 1; i < decl.length; i++) {
        ClassDeclaration curr = decl[i];
        String name = Names.mangleClass(curr.getName()).toString();
        int j;
        for (j = i; j > 0; j--) {
            if (name.compareTo(
                               Names.mangleClass(decl[j - 1].getName()).toString()) >= 0)
                {
                    break;
                }
            decl[j] = decl[j - 1];
        }
        decl[j] = curr;
    }
}
 
Example #17
Source File: ValueType.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize this instance.
 */

private static boolean couldBeValue(ContextStack stack, ClassDefinition classDef) {

    boolean result = false;
    ClassDeclaration classDecl = classDef.getClassDeclaration();
    BatchEnvironment env = stack.getEnv();

    try {
        // Make sure it's not remote...

        if (env.defRemote.implementedBy(env, classDecl)) {
            failedConstraint(10,false,stack,classDef.getName());
        } else {

            // Make sure it's Serializable...

            if (!env.defSerializable.implementedBy(env, classDecl)) {
                failedConstraint(11,false,stack,classDef.getName());
            } else {
                result = true;
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(stack,e);
    }

    return result;
}
 
Example #18
Source File: Main.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void compileAllClasses (BatchEnvironment env)
    throws ClassNotFound,
           IOException,
           InterruptedException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
    boolean done;

    do {
        done = true;
        for (Enumeration<?> e = env.getClasses() ; e.hasMoreElements() ; ) {
            ClassDeclaration c = (ClassDeclaration)e.nextElement();
            done = compileClass(c,buf,env);
        }
    } while (!done);
}
 
Example #19
Source File: CompoundType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return an array containing only those exceptions which need to be
 * handled explicitly by the stub.  Removes java.lang.RuntimeException,
 * java.lang.Error, and their subclasses, since these are all passed
 * back as CORBA system exceptions.  Also removes subclasses of
 * java.rmi.RemoteException but not java.rmi.RemoteException itself,
 * since this may need to be thrown by the stub.
 */
public ValueType[] getFilteredStubExceptions(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if ((env.defRemoteException.superClassOf(env, decl) &&
                 !env.defRemoteException.getClassDeclaration().equals(decl)) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = 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;
    }

    return list;
}
 
Example #20
Source File: CFCTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #21
Source File: CFCTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #22
Source File: CFCTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #23
Source File: CompoundType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return an array containing only those exceptions which need to be
 * handled explicitly by the stub.  Removes java.lang.RuntimeException,
 * java.lang.Error, and their subclasses, since these are all passed
 * back as CORBA system exceptions.  Also removes subclasses of
 * java.rmi.RemoteException but not java.rmi.RemoteException itself,
 * since this may need to be thrown by the stub.
 */
public ValueType[] getFilteredStubExceptions(ValueType[] list) {
    ValueType[] result = list;
    int newSize = list.length;

    try {

        for (int i = 0; i < list.length; i++) {
            ClassDeclaration decl = list[i].getClassDeclaration();
            if ((env.defRemoteException.superClassOf(env, decl) &&
                 !env.defRemoteException.getClassDeclaration().equals(decl)) ||
                env.defRuntimeException.superClassOf(env, decl) ||
                env.defError.superClassOf(env, decl)) {
                list[i] = 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;
    }

    return list;
}
 
Example #24
Source File: Main.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void compileAllClasses (BatchEnvironment env)
    throws ClassNotFound,
           IOException,
           InterruptedException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
    boolean done;

    do {
        done = true;
        for (Enumeration<?> e = env.getClasses() ; e.hasMoreElements() ; ) {
            ClassDeclaration c = (ClassDeclaration)e.nextElement();
            done = compileClass(c,buf,env);
        }
    } while (!done);
}
 
Example #25
Source File: CFCTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #26
Source File: Main.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void compileAllClasses (BatchEnvironment env)
    throws ClassNotFound,
           IOException,
           InterruptedException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
    boolean done;

    do {
        done = true;
        for (Enumeration<?> e = env.getClasses() ; e.hasMoreElements() ; ) {
            ClassDeclaration c = (ClassDeclaration)e.nextElement();
            done = compileClass(c,buf,env);
        }
    } while (!done);
}
 
Example #27
Source File: ValueType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize this instance.
 */

private static boolean couldBeValue(ContextStack stack, ClassDefinition classDef) {

    boolean result = false;
    ClassDeclaration classDecl = classDef.getClassDeclaration();
    BatchEnvironment env = stack.getEnv();

    try {
        // Make sure it's not remote...

        if (env.defRemote.implementedBy(env, classDecl)) {
            failedConstraint(10,false,stack,classDef.getName());
        } else {

            // Make sure it's Serializable...

            if (!env.defSerializable.implementedBy(env, classDecl)) {
                failedConstraint(11,false,stack,classDef.getName());
            } else {
                result = true;
            }
        }
    } catch (ClassNotFound e) {
        classNotFound(stack,e);
    }

    return result;
}
 
Example #28
Source File: Main.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void compileAllClasses (BatchEnvironment env)
    throws ClassNotFound,
           IOException,
           InterruptedException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
    boolean done;

    do {
        done = true;
        for (Enumeration<?> e = env.getClasses() ; e.hasMoreElements() ; ) {
            ClassDeclaration c = (ClassDeclaration)e.nextElement();
            done = compileClass(c,buf,env);
        }
    } while (!done);
}
 
Example #29
Source File: CFCTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #30
Source File: Main.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void compileAllClasses (BatchEnvironment env)
    throws ClassNotFound,
           IOException,
           InterruptedException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
    boolean done;

    do {
        done = true;
        for (Enumeration<?> e = env.getClasses() ; e.hasMoreElements() ; ) {
            ClassDeclaration c = (ClassDeclaration)e.nextElement();
            done = compileClass(c,buf,env);
        }
    } while (!done);
}