Exemplo n.º 1
0
  /**
   * @ast method
   * @aspect AccessControl
   * @declaredat /home/uoji/JastAddJ/Java1.4Frontend/AccessControl.jrag:167
   */
  public void accessControl() {
    super.accessControl();

    if (!isCircular()) {
      // 9.1.2
      HashSet set = new HashSet();
      for (int i = 0; i < getNumSuperInterfaceId(); i++) {
        TypeDecl decl = getSuperInterfaceId(i).type();

        if (!decl.isInterfaceDecl() && !decl.isUnknown())
          error(
              "interface " + fullName() + " tries to extend non interface type " + decl.fullName());
        if (!decl.isCircular() && !decl.accessibleFrom(this))
          error(
              "interface " + fullName() + " can not extend non accessible type " + decl.fullName());

        if (set.contains(decl))
          error(
              "extended interface "
                  + decl.fullName()
                  + " mentionened multiple times in extends clause");
        set.add(decl);
      }
    }
  }
Exemplo n.º 2
0
 /**
  * @ast method
  * @aspect TypeHierarchyCheck
  * @declaredat /home/uoji/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:312
  */
 public void nameCheck() {
   super.nameCheck();
   if (isCircular()) error("circular inheritance dependency in " + typeName());
   else {
     for (int i = 0; i < getNumSuperInterfaceId(); i++) {
       TypeDecl typeDecl = getSuperInterfaceId(i).type();
       if (typeDecl.isCircular()) error("circular inheritance dependency in " + typeName());
     }
   }
   for (Iterator iter = methodsSignatureMap().values().iterator(); iter.hasNext(); ) {
     SimpleSet set = (SimpleSet) iter.next();
     if (set.size() > 1) {
       Iterator i2 = set.iterator();
       MethodDecl m = (MethodDecl) i2.next();
       while (i2.hasNext()) {
         MethodDecl n = (MethodDecl) i2.next();
         if (!n.mayOverrideReturn(m) && !m.mayOverrideReturn(n))
           error(
               "multiply inherited methods with the same signature must have the same return type");
       }
     }
   }
 }