Java Code Examples for sun.tools.java.ClassDeclaration#getClassDefinition()

The following examples show how to use sun.tools.java.ClassDeclaration#getClassDefinition() . 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: ClassType.java    From TencentKona-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 2
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 3
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 4
Source File: ClassType.java    From jdk8u60 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 5
Source File: ClassType.java    From openjdk-jdk9 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: ClassType.java    From openjdk-jdk8u-backup 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 7
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 8
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 9
Source File: CFCTest.java    From dragonwell8_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 10
Source File: CFCTest.java    From openjdk-jdk9 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);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example 11
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 12
Source File: CFCTest.java    From hottub 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 13
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 14
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 15
Source File: CompoundType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected Vector updateParentClassMethods(ClassDefinition current,
                                          Vector currentMethods,
                                          boolean quiet,
                                          ContextStack stack)
    throws ClassNotFound {

    ClassDeclaration parentDecl = current.getSuperClass(env);

    while (parentDecl != null) {

        ClassDefinition parentDef = parentDecl.getClassDefinition(env);
        Identifier currentID = parentDecl.getName();

        if ( currentID == idJavaLangObject ) break;

        // Walk all members of this class and update any that
        // already exist in currentMethods...

        for (MemberDefinition member = parentDef.getFirstMember();
             member != null;
             member = member.getNextMember()) {

            if (member.isMethod() &&
                !member.isInitializer() &&
                !member.isConstructor() &&
                !member.isPrivate()) {

                // It's a method.  Is it valid?

                Method method;
                try {
                    method = new Method((CompoundType)this,member,quiet,stack);
                } catch (Exception e) {
                    // Don't report anything here, it's already been reported...
                    return null;
                }

                // Have we already seen it?

                int index = currentMethods.indexOf(method);
                if (index >= 0) {

                    // Yes, so update it...

                    Method currentMethod = (Method)currentMethods.elementAt(index);
                    currentMethod.setDeclaredBy(currentID);
                }
                else currentMethods.addElement(method);
            }
        }

        // Update parent and keep walking up the chain...

        parentDecl = parentDef.getSuperClass(env);
    }

    return currentMethods;
}
 
Example 16
Source File: CompoundType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected Vector updateParentClassMethods(ClassDefinition current,
                                          Vector currentMethods,
                                          boolean quiet,
                                          ContextStack stack)
    throws ClassNotFound {

    ClassDeclaration parentDecl = current.getSuperClass(env);

    while (parentDecl != null) {

        ClassDefinition parentDef = parentDecl.getClassDefinition(env);
        Identifier currentID = parentDecl.getName();

        if ( currentID == idJavaLangObject ) break;

        // Walk all members of this class and update any that
        // already exist in currentMethods...

        for (MemberDefinition member = parentDef.getFirstMember();
             member != null;
             member = member.getNextMember()) {

            if (member.isMethod() &&
                !member.isInitializer() &&
                !member.isConstructor() &&
                !member.isPrivate()) {

                // It's a method.  Is it valid?

                Method method;
                try {
                    method = new Method((CompoundType)this,member,quiet,stack);
                } catch (Exception e) {
                    // Don't report anything here, it's already been reported...
                    return null;
                }

                // Have we already seen it?

                int index = currentMethods.indexOf(method);
                if (index >= 0) {

                    // Yes, so update it...

                    Method currentMethod = (Method)currentMethods.elementAt(index);
                    currentMethod.setDeclaredBy(currentID);
                }
                else currentMethods.addElement(method);
            }
        }

        // Update parent and keep walking up the chain...

        parentDecl = parentDef.getSuperClass(env);
    }

    return currentMethods;
}
 
Example 17
Source File: CompoundType.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected Vector updateParentClassMethods(ClassDefinition current,
                                          Vector currentMethods,
                                          boolean quiet,
                                          ContextStack stack)
    throws ClassNotFound {

    ClassDeclaration parentDecl = current.getSuperClass(env);

    while (parentDecl != null) {

        ClassDefinition parentDef = parentDecl.getClassDefinition(env);
        Identifier currentID = parentDecl.getName();

        if ( currentID == idJavaLangObject ) break;

        // Walk all members of this class and update any that
        // already exist in currentMethods...

        for (MemberDefinition member = parentDef.getFirstMember();
             member != null;
             member = member.getNextMember()) {

            if (member.isMethod() &&
                !member.isInitializer() &&
                !member.isConstructor() &&
                !member.isPrivate()) {

                // It's a method.  Is it valid?

                Method method;
                try {
                    method = new Method((CompoundType)this,member,quiet,stack);
                } catch (Exception e) {
                    // Don't report anything here, it's already been reported...
                    return null;
                }

                // Have we already seen it?

                int index = currentMethods.indexOf(method);
                if (index >= 0) {

                    // Yes, so update it...

                    Method currentMethod = (Method)currentMethods.elementAt(index);
                    currentMethod.setDeclaredBy(currentID);
                }
                else currentMethods.addElement(method);
            }
        }

        // Update parent and keep walking up the chain...

        parentDecl = parentDef.getSuperClass(env);
    }

    return currentMethods;
}
 
Example 18
Source File: ValueType.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an ValueType object for the given class.
 *
 * If the class is not a properly formed or if some other error occurs, the
 * return value will be null, and errors will have been reported to the
 * supplied BatchEnvironment.
 */
public static ValueType forValue(ClassDefinition classDef,
                                 ContextStack stack,
                                 boolean quiet) {

    if (stack.anyErrors()) return null;

    // Do we already have it?

    sun.tools.java.Type theType = classDef.getType();
    String typeKey = theType.toString();
    Type existing = getType(typeKey,stack);

    if (existing != null) {

        if (!(existing instanceof ValueType)) return null; // False hit.

        // Yep, so return it...

        return (ValueType) existing;
    }

    // Is this java.lang.Class?

    boolean javaLangClass = false;

    if (classDef.getClassDeclaration().getName() == idJavaLangClass) {

        // Yes, so replace classDef with one for
        // javax.rmi.CORBA.ClassDesc...

        javaLangClass = true;
        BatchEnvironment env = stack.getEnv();
        ClassDeclaration decl = env.getClassDeclaration(idClassDesc);
        ClassDefinition def = null;

        try {
            def = decl.getClassDefinition(env);
        } catch (ClassNotFound ex) {
            classNotFound(stack,ex);
            return null;
        }

        classDef = def;
    }

    // Could this be a value?

    if (couldBeValue(stack,classDef)) {

        // Yes, so check it...

        ValueType it = new ValueType(classDef,stack,javaLangClass);
        putType(typeKey,it,stack);
        stack.push(it);

        if (it.initialize(stack,quiet)) {
            stack.pop(true);
            return it;
        } else {
            removeType(typeKey,stack);
            stack.pop(false);
            return null;
        }
    } else {
        return null;
    }
}
 
Example 19
Source File: CompoundType.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected Vector updateParentClassMethods(ClassDefinition current,
                                          Vector currentMethods,
                                          boolean quiet,
                                          ContextStack stack)
    throws ClassNotFound {

    ClassDeclaration parentDecl = current.getSuperClass(env);

    while (parentDecl != null) {

        ClassDefinition parentDef = parentDecl.getClassDefinition(env);
        Identifier currentID = parentDecl.getName();

        if ( currentID == idJavaLangObject ) break;

        // Walk all members of this class and update any that
        // already exist in currentMethods...

        for (MemberDefinition member = parentDef.getFirstMember();
             member != null;
             member = member.getNextMember()) {

            if (member.isMethod() &&
                !member.isInitializer() &&
                !member.isConstructor() &&
                !member.isPrivate()) {

                // It's a method.  Is it valid?

                Method method;
                try {
                    method = new Method((CompoundType)this,member,quiet,stack);
                } catch (Exception e) {
                    // Don't report anything here, it's already been reported...
                    return null;
                }

                // Have we already seen it?

                int index = currentMethods.indexOf(method);
                if (index >= 0) {

                    // Yes, so update it...

                    Method currentMethod = (Method)currentMethods.elementAt(index);
                    currentMethod.setDeclaredBy(currentID);
                }
                else currentMethods.addElement(method);
            }
        }

        // Update parent and keep walking up the chain...

        parentDecl = parentDef.getSuperClass(env);
    }

    return currentMethods;
}
 
Example 20
Source File: CompoundType.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected Vector updateParentClassMethods(ClassDefinition current,
                                          Vector currentMethods,
                                          boolean quiet,
                                          ContextStack stack)
    throws ClassNotFound {

    ClassDeclaration parentDecl = current.getSuperClass(env);

    while (parentDecl != null) {

        ClassDefinition parentDef = parentDecl.getClassDefinition(env);
        Identifier currentID = parentDecl.getName();

        if ( currentID == idJavaLangObject ) break;

        // Walk all members of this class and update any that
        // already exist in currentMethods...

        for (MemberDefinition member = parentDef.getFirstMember();
             member != null;
             member = member.getNextMember()) {

            if (member.isMethod() &&
                !member.isInitializer() &&
                !member.isConstructor() &&
                !member.isPrivate()) {

                // It's a method.  Is it valid?

                Method method;
                try {
                    method = new Method((CompoundType)this,member,quiet,stack);
                } catch (Exception e) {
                    // Don't report anything here, it's already been reported...
                    return null;
                }

                // Have we already seen it?

                int index = currentMethods.indexOf(method);
                if (index >= 0) {

                    // Yes, so update it...

                    Method currentMethod = (Method)currentMethods.elementAt(index);
                    currentMethod.setDeclaredBy(currentID);
                }
                else currentMethods.addElement(method);
            }
        }

        // Update parent and keep walking up the chain...

        parentDecl = parentDef.getSuperClass(env);
    }

    return currentMethods;
}