Package sun.tools.java

Examples of sun.tools.java.ClassDefinition


                                                 ClassDeclaration[] with,
                                                 Vector 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;
                        }
                    }
                }
View Full Code Here


         */
        if (catchList.size() > 0) {
            for (Enumeration enumeration = catchList.elements();
                 enumeration.hasMoreElements();)
            {
                ClassDefinition def = (ClassDefinition) enumeration.nextElement();
                p.pOlnI("} catch (" + def.getName() + " e) {");
                p.pln("throw e;");
            }
            p.pOlnI("} catch (java.lang.Exception e) {");
            p.pln("throw new " + idUnexpectedException +
                "(\"undeclared checked exception\", e);");
View Full Code Here

                /*
                 * Compare this exception against the current list of
                 * exceptions that need to be caught:
                 */
                for (int j = 0; j < uniqueList.size();) {
                    ClassDefinition def =
                        (ClassDefinition) 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);
View Full Code Here

                 */
                implClassName = Names.mangleClass(implClassName);

                ClassDeclaration decl = env.getClassDeclaration(implClassName);
                try {
                    ClassDefinition def = decl.getClassDefinition(env);
                    for (int j = 0; j < generators.size(); j++) {
                        Generator gen = (Generator)generators.elementAt(j);
                        gen.generate(env, def, destDir);
                    }
                } catch (ClassNotFound ex) {
View Full Code Here

             classDef != null;)
            {
                try {
                    ClassDeclaration[] interfaces = classDef.getInterfaces();
                    for (int i = 0; i < interfaces.length; i++) {
                        ClassDefinition interfaceDef =
                            interfaces[i].getClassDefinition(env);
                        /*
                         * Add interface to the list if it extends Remote and
                         * it is not already there.
                         */
                        if (!remotesImplemented.contains(interfaceDef) &&
                            defRemote.implementedBy(env, interfaces[i]))
                            {
                                remotesImplemented.addElement(interfaceDef);
                                /***** <DEBUG> */
                                if (env.verbose()) {
                                    System.out.println("[found remote interface: " +
                                                       interfaceDef.getName() + "]");
                                    /***** </DEBUG> */
                                }
                            }
                    }

                    /*
                     * Verify that the candidate remote implementation class
                     * implements at least one remote interface directly.
                     */
                    if (classDef == implClassDef && remotesImplemented.isEmpty()) {
                        if (defRemote.implementedBy(env,
                                                    implClassDef.getClassDeclaration()))
                            {
                                /*
                                 * This error message is used if the class does
                                 * implement a remote interface through one of
                                 * its superclasses, but not directly.
                                 */
                                env.error(0, "rmic.must.implement.remote.directly",
                                          implClassDef.getName());
                            } else {
                                /*
                                 * This error message is used if the class never
                                 * implements a remote interface.
                                 */
                                env.error(0, "rmic.must.implement.remote",
                                          implClassDef.getName());
                            }
                        return false;
                    }

                    /*
                     * Get definition for next superclass.
                     */
                    classDef = (classDef.getSuperClass() != null ?
                                classDef.getSuperClass().getClassDefinition(env) :
                                null);

                } catch (ClassNotFound e) {
                    env.error(0, "class.not.found", e.name, classDef.getName());
                    return false;
                }
            }

        /*
         * The "remotesImplemented" vector now contains all of the remote
         * interfaces directly implemented by the remote class or by any
         * of its superclasses.
         *
         * At this point, we could optimize the list by removing superfluous
         * entries, i.e. any interfaces that are implemented by some other
         * interface in the list anyway.
         *
         * This should be correct; would it be worthwhile?
         *
         *      for (int i = 0; i < remotesImplemented.size();) {
         *          ClassDefinition interfaceDef =
         *              (ClassDefinition) remotesImplemented.elementAt(i);
         *          boolean isOtherwiseImplemented = false;
         *          for (int j = 0; j < remotesImplemented.size; j++) {
         *              if (j != i &&
         *                  interfaceDef.implementedBy(env, (ClassDefinition)
         *                  remotesImplemented.elementAt(j).
         *                      getClassDeclaration()))
         *              {
         *                  isOtherwiseImplemented = true;
         *                  break;
         *              }
         *          }
         *          if (isOtherwiseImplemented) {
         *              remotesImplemented.removeElementAt(i);
         *          } else {
         *              ++i;
         *          }
         *      }
         */

        /*
         * Now we collect the methods from all of the remote interfaces
         * into a hashtable.
         */
        Hashtable methods = new Hashtable();
        boolean errors = false;
        for (Enumeration enumeration = remotesImplemented.elements();
             enumeration.hasMoreElements();)
            {
                ClassDefinition interfaceDef =
                    (ClassDefinition) enumeration.nextElement();
                if (!collectRemoteMethods(interfaceDef, methods))
                    errors = true;
            }
        if (errors)
View Full Code Here

         * Recursively collect methods for all superinterfaces.
         */
        try {
            ClassDeclaration[] superDefs = interfaceDef.getInterfaces();
            for (int i = 0; i < superDefs.length; i++) {
                ClassDefinition superDef =
                    superDefs[i].getClassDefinition(env);
                if (!collectRemoteMethods(superDef, table))
                    errors = true;
            }
        } catch (ClassNotFound e) {
View Full Code Here

        case TC_CLASS:
            {
                try {
                                // First, make sure we have the class definition...

                    ClassDefinition theClass = classDef;

                    if (theClass == null) {
                        theClass = env.getClassDeclaration(theType).getClassDefinition(env);
                    }

                                // Is it an interface or a class?

                    if (theClass.isInterface()) {

                        // An interface. Is it a special case?

                        result = SpecialInterfaceType.forSpecial(theClass,stack);

                        if (result == null) {

                            // No, does it implement java.rmi.Remote?

                            if (env.defRemote.implementedBy(env,theClass.getClassDeclaration())) {

                                // Yep, so just see if we can create an instance of RemoteType
                                // from it...

                                boolean parentIsValue = stack.isParentAValue();
                                result = RemoteType.forRemote(theClass,stack,parentIsValue);

                                // If we did not succeed AND we are in a value context, then
                                // go ahead and make an NC type out of it...

                                if (result == null && parentIsValue) {
                                    result = NCInterfaceType.forNCInterface(theClass,stack);
                                }
                            } else {

                                // Nope, is it an AbstractType?

                                result = AbstractType.forAbstract(theClass,stack,true);

                                if (result == null) {

                                    // No, so treat it as a non-conforming interface type...

                                    result = NCInterfaceType.forNCInterface(theClass,stack);
                                }
                            }
                        }
                    } else {

                        // A class. Is it a special case?

                        result = SpecialClassType.forSpecial(theClass,stack);

                        if (result == null) {

                            ClassDeclaration classDecl = theClass.getClassDeclaration();

                            // Nope, does it implement java.rmi.Remote?

                            if (env.defRemote.implementedBy(env,classDecl)) {
View Full Code Here

        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;
    }
View Full Code Here

                            !stack.isParentAValue() && !stack.getContext().isValue()) {

                            // Nope. Say so and signal error by returning null..

                            Method existingMethod = (Method) directMethods.elementAt(directMethods.indexOf(method));
                            ClassDefinition existingMemberClassDef = existingMethod.getMemberDefinition().getClassDefinition();

                            // There are more legal cases to consider here.
                            // If the two methods belong to interfaces that inherit from each other
                            // then it is just a redefinition which is legal.
                            if ( current != existingMemberClassDef &&
                                 ! inheritsFrom(current, existingMemberClassDef) &&
                                 ! inheritsFrom(existingMemberClassDef, current))
                            {
                                //Identifier int1 = existingMethod.getEnclosing().getIdentifier();
                                //Identifier int2 = current.getName();
                                //String message = int1.toString() + " and " + int2.toString();
                                String message = existingMemberClassDef.getName() + " and " + current.getName();
                                failedConstraint(6,quiet,stack,classDef,message,method);
                                return null;
                            }
                        }
View Full Code Here

    // Works for both, classes and interfaces.
    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;
        }
View Full Code Here

TOP

Related Classes of sun.tools.java.ClassDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.