Package org.eclipse.jdt.internal.compiler.util

Examples of org.eclipse.jdt.internal.compiler.util.HashtableOfObject


   * @param value the new index
   * @return the given index
   */
  private int putInCacheIfAbsent(final char[] key1, final char[] key2, final char[] key3, int value) {
    int index;
    HashtableOfObject key1Value = (HashtableOfObject) this.methodsAndFieldsCache.get(key1);
    if (key1Value == null) {
      key1Value = new HashtableOfObject();
      this.methodsAndFieldsCache.put(key1, key1Value);
      CachedIndexEntry cachedIndexEntry = new CachedIndexEntry(key3, value);
      index = -value;
      key1Value.put(key2, cachedIndexEntry);
    } else {
      Object key2Value = key1Value.get(key2);
      if (key2Value == null) {
        CachedIndexEntry cachedIndexEntry = new CachedIndexEntry(key3, value);
        index = -value;
        key1Value.put(key2, cachedIndexEntry);
      } else if (key2Value instanceof CachedIndexEntry) {
        // adding a second entry
        CachedIndexEntry entry = (CachedIndexEntry) key2Value;
        if (CharOperation.equals(key3, entry.signature)) {
          index = entry.index;
        } else {
          CharArrayCache charArrayCache = new CharArrayCache();
          charArrayCache.putIfAbsent(entry.signature, entry.index);
          index = charArrayCache.putIfAbsent(key3, value);
          key1Value.put(key2, charArrayCache);
        }
      } else {
        CharArrayCache charArrayCache = (CharArrayCache) key2Value;
        index = charArrayCache.putIfAbsent(key3, value);
      }
View Full Code Here


    TypeVariableBinding var = this.type.typeVariables[i];
    // must verify bounds if the variable has more than 1
    if (var.superInterfaces == Binding.NO_SUPERINTERFACES) continue;
    if (var.superInterfaces.length == 1 && var.superclass.id == TypeIds.T_JavaLangObject) continue;

    this.currentMethods = new HashtableOfObject(0);
    ReferenceBinding superclass = var.superclass();
    if (superclass.kind() == Binding.TYPE_PARAMETER)
      superclass = (ReferenceBinding) superclass.erasure();
    ReferenceBinding[] itsInterfaces = var.superInterfaces();
    ReferenceBinding[] superInterfaces = new ReferenceBinding[itsInterfaces.length];
View Full Code Here

        return foundType;
    }

    // at this point the scope is a compilation unit scope
    CompilationUnitScope unitScope = (CompilationUnitScope) scope;
    HashtableOfObject typeOrPackageCache = unitScope.typeOrPackageCache;
    if (typeOrPackageCache != null) {
      Binding cachedBinding = (Binding) typeOrPackageCache.get(name);
      if (cachedBinding != null) { // can also include NotFound ProblemReferenceBindings if we already know this name is not found
        if (cachedBinding instanceof ImportBinding) { // single type import cached in faultInImports(), replace it in the cache with the type
          ImportReference importReference = ((ImportBinding) cachedBinding).reference;
          if (importReference != null) {
            importReference.bits |= ASTNode.Used;
          }
          if (cachedBinding instanceof ImportConflictBinding)
            typeOrPackageCache.put(name, cachedBinding = ((ImportConflictBinding) cachedBinding).conflictingTypeBinding); // already know its visible
          else
            typeOrPackageCache.put(name, cachedBinding = ((ImportBinding) cachedBinding).resolvedImport); // already know its visible
        }
        if ((mask & Binding.TYPE) != 0) {
          if (foundType != null && foundType.problemId() != ProblemReasons.NotVisible && cachedBinding.problemId() != ProblemReasons.Ambiguous)
            return foundType; // problem type from above supercedes NotFound type but not Ambiguous import case
          if (cachedBinding instanceof ReferenceBinding)
            return cachedBinding; // cached type found in previous walk below
        }
        if ((mask & Binding.PACKAGE) != 0 && cachedBinding instanceof PackageBinding)
          return cachedBinding; // cached package found in previous walk below
      }
    }

    // ask for the imports + name
    if ((mask & Binding.TYPE) != 0) {
      ImportBinding[] imports = unitScope.imports;
      if (imports != null && typeOrPackageCache == null) { // walk single type imports since faultInImports() has not run yet
        nextImport : for (int i = 0, length = imports.length; i < length; i++) {
          ImportBinding importBinding = imports[i];
          if (!importBinding.onDemand) {
            if (CharOperation.equals(importBinding.compoundName[importBinding.compoundName.length - 1], name)) {
              Binding resolvedImport = unitScope.resolveSingleImport(importBinding, Binding.TYPE);
              if (resolvedImport == null) continue nextImport;
              if (resolvedImport instanceof TypeBinding) {
                ImportReference importReference = importBinding.reference;
                if (importReference != null)
                  importReference.bits |= ASTNode.Used;
                return resolvedImport; // already know its visible
              }
            }
          }
        }
      }
      // In this location we had a fix for
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318401
      // However, as of today (4.3M6 candidate) this fix seems unnecessary, while causing StackOverflowError in
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=401271

      // check if the name is in the current package, skip it if its a sub-package
      PackageBinding currentPackage = unitScope.fPackage;
      unitScope.recordReference(currentPackage.compoundName, name);
      Binding binding = currentPackage.getTypeOrPackage(name);
      if (binding instanceof ReferenceBinding) {
        ReferenceBinding referenceType = (ReferenceBinding) binding;
        if ((referenceType.tagBits & TagBits.HasMissingType) == 0) {
          if (typeOrPackageCache != null)
            typeOrPackageCache.put(name, referenceType);
          return referenceType; // type is always visible to its own package
        }
      }

      // check on demand imports
      if (imports != null) {
        boolean foundInImport = false;
        ReferenceBinding type = null;
        for (int i = 0, length = imports.length; i < length; i++) {
          ImportBinding someImport = imports[i];
          if (someImport.onDemand) {
            Binding resolvedImport = someImport.resolvedImport;
            ReferenceBinding temp = null;
            if (resolvedImport instanceof PackageBinding) {
              temp = findType(name, (PackageBinding) resolvedImport, currentPackage);
            } else if (someImport.isStatic()) {
              temp = findMemberType(name, (ReferenceBinding) resolvedImport); // static imports are allowed to see inherited member types
              if (temp != null && !temp.isStatic())
                temp = null;
            } else {
              temp = findDirectMemberType(name, (ReferenceBinding) resolvedImport);
            }
            if (temp != type && temp != null) {
              if (temp.isValidBinding()) {
                ImportReference importReference = someImport.reference;
                if (importReference != null) {
                  importReference.bits |= ASTNode.Used;
                }
                if (foundInImport) {
                  // Answer error binding -- import on demand conflict; name found in two import on demand packages.
                  temp = new ProblemReferenceBinding(new char[][]{name}, type, ProblemReasons.Ambiguous);
                  if (typeOrPackageCache != null)
                    typeOrPackageCache.put(name, temp);
                  return temp;
                }
                type = temp;
                foundInImport = true;
              } else if (foundType == null) {
                foundType = temp;
              }
            }
          }
        }
        if (type != null) {
          if (typeOrPackageCache != null)
            typeOrPackageCache.put(name, type);
          return type;
        }
      }
    }

    unitScope.recordSimpleReference(name);
    if ((mask & Binding.PACKAGE) != 0) {
      PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
      if (packageBinding != null) {
        if (typeOrPackageCache != null)
          typeOrPackageCache.put(name, packageBinding);
        return packageBinding;
      }
    }

    // Answer error binding -- could not find name
    if (foundType == null) {
      char[][] qName = new char[][] { name };
      ReferenceBinding closestMatch = null;
      if ((mask & Binding.PACKAGE) != 0) {
        if (needResolve) {
          closestMatch = environment().createMissingType(unitScope.fPackage, qName);
        }
      } else {
        PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
        if (packageBinding == null || !packageBinding.isValidBinding()) {
          if (needResolve) {
            closestMatch = environment().createMissingType(unitScope.fPackage, qName);
          }
        }
      }
      foundType = new ProblemReferenceBinding(qName, closestMatch, ProblemReasons.NotFound);
      if (typeOrPackageCache != null && (mask & Binding.PACKAGE) != 0) { // only put NotFound type in cache if you know its not a package
        typeOrPackageCache.put(name, foundType);
      }
    } else if ((foundType.tagBits & TagBits.HasMissingType) != 0) {
      char[][] qName = new char[][] { name };
      foundType = new ProblemReferenceBinding(qName, foundType, ProblemReasons.NotFound);
      if (typeOrPackageCache != null && (mask & Binding.PACKAGE) != 0) // only put NotFound type in cache if you know its not a package
        typeOrPackageCache.put(name, foundType);
    }
    return foundType;
  }
View Full Code Here

*/
void computeInheritedMethods(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) {
  // only want to remember inheritedMethods that can have an impact on the current type
  // if an inheritedMethod has been 'replaced' by a supertype's method then skip it, however
    // see usage of canOverridingMethodDifferInErasure below.
  this.inheritedMethods = new HashtableOfObject(51); // maps method selectors to an array of methods... must search to match paramaters & return type

  ReferenceBinding superType = superclass;
  HashtableOfObject nonVisibleDefaultMethods = new HashtableOfObject(3); // maps method selectors to an array of methods

  while (superType != null && superType.isValidBinding()) {

    MethodBinding[] methods = superType.unResolvedMethods();
    nextMethod : for (int m = methods.length; --m >= 0;) {
      MethodBinding inheritedMethod = methods[m];
      if (inheritedMethod.isPrivate() || inheritedMethod.isConstructor() || inheritedMethod.isDefaultAbstract())
        continue nextMethod;
      MethodBinding[] existingMethods = (MethodBinding[]) this.inheritedMethods.get(inheritedMethod.selector);
      if (existingMethods != null) {
        existing : for (int i = 0, length = existingMethods.length; i < length; i++) {
          MethodBinding existingMethod = existingMethods[i];
          // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302358, skip inherited method only if any overriding version
          // in a subclass is guaranteed to have the same erasure as an existing method.
          if (existingMethod.declaringClass != inheritedMethod.declaringClass && areMethodsCompatible(existingMethod, inheritedMethod) && !canOverridingMethodDifferInErasure(existingMethod, inheritedMethod)) {
            if (inheritedMethod.isDefault()) {
              if (inheritedMethod.isAbstract()) {
                checkPackagePrivateAbstractMethod(inheritedMethod);
              } else if (existingMethod.declaringClass.fPackage != inheritedMethod.declaringClass.fPackage) {
                if (this.type.fPackage == inheritedMethod.declaringClass.fPackage && !areReturnTypesCompatible(inheritedMethod, existingMethod))
                  continue existing; // may need to record incompatible return type
              }
            }
            continue nextMethod;
          }
        }
      }

      if (!inheritedMethod.isDefault() || inheritedMethod.declaringClass.fPackage == this.type.fPackage) {
        if (existingMethods == null) {
          existingMethods = new MethodBinding[] {inheritedMethod};
        } else {
          int length = existingMethods.length;
          System.arraycopy(existingMethods, 0, existingMethods = new MethodBinding[length + 1], 0, length);
          existingMethods[length] = inheritedMethod;
        }
        this.inheritedMethods.put(inheritedMethod.selector, existingMethods);
      } else {
        MethodBinding[] nonVisible = (MethodBinding[]) nonVisibleDefaultMethods.get(inheritedMethod.selector);
        if (nonVisible != null)
          for (int i = 0, l = nonVisible.length; i < l; i++)
            if (areMethodsCompatible(nonVisible[i], inheritedMethod))
              continue nextMethod;
        if (nonVisible == null) {
          nonVisible = new MethodBinding[] {inheritedMethod};
        } else {
          int length = nonVisible.length;
          System.arraycopy(nonVisible, 0, nonVisible = new MethodBinding[length + 1], 0, length);
          nonVisible[length] = inheritedMethod;
        }
        nonVisibleDefaultMethods.put(inheritedMethod.selector, nonVisible);

        if (inheritedMethod.isAbstract() && !this.type.isAbstract()) // non visible abstract methods cannot be overridden so the type must be defined abstract
          problemReporter().abstractMethodCannotBeOverridden(this.type, inheritedMethod);

        MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(inheritedMethod.selector);
View Full Code Here

  return false;   // the case for <= 1.4  (cannot differ)
}
void computeMethods() {
  MethodBinding[] methods = this.type.methods();
  int size = methods.length;
  this.currentMethods = new HashtableOfObject(size == 0 ? 1 : size); // maps method selectors to an array of methods... must search to match paramaters & return type
  for (int m = size; --m >= 0;) {
    MethodBinding method = methods[m];
    if (!(method.isConstructor() || method.isDefaultAbstract())) { // keep all methods which are NOT constructors or default abstract
      MethodBinding[] existingMethods = (MethodBinding[]) this.currentMethods.get(method.selector);
      if (existingMethods == null)
View Full Code Here

*  Build the set of compilation source units
*/
public CompilationUnit[] getCompilationUnits() {
  int fileCount = this.filenames.length;
  CompilationUnit[] units = new CompilationUnit[fileCount];
  HashtableOfObject knownFileNames = new HashtableOfObject(fileCount);

  String defaultEncoding = (String) this.options.get(CompilerOptions.OPTION_Encoding);
  if (Util.EMPTY_STRING.equals(defaultEncoding))
    defaultEncoding = null;

  for (int i = 0; i < fileCount; i++) {
    char[] charName = this.filenames[i].toCharArray();
    if (knownFileNames.get(charName) != null)
      throw new IllegalArgumentException(this.bind("unit.more", this.filenames[i])); //$NON-NLS-1$
    knownFileNames.put(charName, charName);
    File file = new File(this.filenames[i]);
    if (!file.exists())
      throw new IllegalArgumentException(this.bind("unit.missing", this.filenames[i])); //$NON-NLS-1$
    String encoding = this.encodings[i];
    if (encoding == null)
View Full Code Here

        return foundType;
    }

    // at this point the scope is a compilation unit scope
    CompilationUnitScope unitScope = (CompilationUnitScope) scope;
    HashtableOfObject typeOrPackageCache = unitScope.typeOrPackageCache;
    if (typeOrPackageCache != null) {
      Binding cachedBinding = (Binding) typeOrPackageCache.get(name);
      if (cachedBinding != null) { // can also include NotFound ProblemReferenceBindings if we already know this name is not found
        if (cachedBinding instanceof ImportBinding) { // single type import cached in faultInImports(), replace it in the cache with the type
          ImportReference importReference = ((ImportBinding) cachedBinding).reference;
          if (importReference != null) {
            importReference.bits |= ASTNode.Used;
          }
          if (cachedBinding instanceof ImportConflictBinding)
            typeOrPackageCache.put(name, cachedBinding = ((ImportConflictBinding) cachedBinding).conflictingTypeBinding); // already know its visible
          else
            typeOrPackageCache.put(name, cachedBinding = ((ImportBinding) cachedBinding).resolvedImport); // already know its visible
        }
        if ((mask & Binding.TYPE) != 0) {
          if (foundType != null && foundType.problemId() != ProblemReasons.NotVisible && cachedBinding.problemId() != ProblemReasons.Ambiguous)
            return foundType; // problem type from above supercedes NotFound type but not Ambiguous import case
          if (cachedBinding instanceof ReferenceBinding)
            return cachedBinding; // cached type found in previous walk below
        }
        if ((mask & Binding.PACKAGE) != 0 && cachedBinding instanceof PackageBinding)
          return cachedBinding; // cached package found in previous walk below
      }
    }

    // ask for the imports + name
    if ((mask & Binding.TYPE) != 0) {
      ImportBinding[] imports = unitScope.imports;
      if (imports != null && typeOrPackageCache == null) { // walk single type imports since faultInImports() has not run yet
        nextImport : for (int i = 0, length = imports.length; i < length; i++) {
          ImportBinding importBinding = imports[i];
          if (!importBinding.onDemand) {
            if (CharOperation.equals(importBinding.compoundName[importBinding.compoundName.length - 1], name)) {
              Binding resolvedImport = unitScope.resolveSingleImport(importBinding, Binding.TYPE);
              if (resolvedImport == null) continue nextImport;
              if (resolvedImport instanceof TypeBinding) {
                ImportReference importReference = importBinding.reference;
                if (importReference != null)
                  importReference.bits |= ASTNode.Used;
                return resolvedImport; // already know its visible
              }
            }
          }
        }
      }
      // walk single static imports. A type found here will shadow types with same name in other CU's, or types coming
      // from on-demand imports. JLS 7.5.3
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318401
      if (imports != null) {
        ReferenceBinding type = null;
        nextImport : for (int i = 0, length = imports.length; i < length; i++) {
          ImportBinding importBinding = imports[i];
          if (importBinding.isStatic()) {
            ReferenceBinding temp = null;
            if (CharOperation.equals(importBinding.compoundName[importBinding.compoundName.length - 1], name)) {
              Binding resolvedImport = importBinding.resolvedImport;
              if (resolvedImport == null) continue nextImport;
              if (resolvedImport instanceof MethodBinding || resolvedImport instanceof FieldBinding) {
                // check to see if there are also member types with the same name
                // must find the importRef's type again since the method/field can be from an inherited type
                // see StaticImportTest#test084 for more clarity
                char[][] importName = importBinding.reference.tokens;
                TypeBinding referencedType = getType(importName, importName.length - 1);
                if (referencedType != null && referencedType instanceof ReferenceBinding) {
                  temp = findMemberType(name, (ReferenceBinding) referencedType);
                }
              }
              if (temp != null && temp.isStatic() && temp != type) {
                if (temp.isValidBinding()) {
                  if (!temp.canBeSeenBy(unitScope.fPackage)) {
                    // Answer error binding - type is not visible
                    foundType = new ProblemReferenceBinding(new char[][]{name}, type, ProblemReasons.NotVisible);
                  } else {
                    ImportReference importReference = importBinding.reference;
                    if (importReference != null) {
                      importReference.bits |= ASTNode.Used;
                    }
                    type = temp;
                  }
                } else if (foundType == null) {
                  foundType = temp;
                }
              }
            }
          }
        }
        if (type != null) {
          if (typeOrPackageCache != null)
            typeOrPackageCache.put(name, type);
          return type;
        }
      }
      // check if the name is in the current package, skip it if its a sub-package
      PackageBinding currentPackage = unitScope.fPackage;
      unitScope.recordReference(currentPackage.compoundName, name);
      Binding binding = currentPackage.getTypeOrPackage(name);
      if (binding instanceof ReferenceBinding) {
        ReferenceBinding referenceType = (ReferenceBinding) binding;
        if ((referenceType.tagBits & TagBits.HasMissingType) == 0) {
          if (typeOrPackageCache != null)
            typeOrPackageCache.put(name, referenceType);
          return referenceType; // type is always visible to its own package
        }
      }

      // check on demand imports
      if (imports != null) {
        boolean foundInImport = false;
        ReferenceBinding type = null;
        for (int i = 0, length = imports.length; i < length; i++) {
          ImportBinding someImport = imports[i];
          if (someImport.onDemand) {
            Binding resolvedImport = someImport.resolvedImport;
            ReferenceBinding temp = null;
            if (resolvedImport instanceof PackageBinding) {
              temp = findType(name, (PackageBinding) resolvedImport, currentPackage);
            } else if (someImport.isStatic()) {
              temp = findMemberType(name, (ReferenceBinding) resolvedImport); // static imports are allowed to see inherited member types
              if (temp != null && !temp.isStatic())
                temp = null;
            } else {
              temp = findDirectMemberType(name, (ReferenceBinding) resolvedImport);
            }
            if (temp != type && temp != null) {
              if (temp.isValidBinding()) {
                ImportReference importReference = someImport.reference;
                if (importReference != null) {
                  importReference.bits |= ASTNode.Used;
                }
                if (foundInImport) {
                  // Answer error binding -- import on demand conflict; name found in two import on demand packages.
                  temp = new ProblemReferenceBinding(new char[][]{name}, type, ProblemReasons.Ambiguous);
                  if (typeOrPackageCache != null)
                    typeOrPackageCache.put(name, temp);
                  return temp;
                }
                type = temp;
                foundInImport = true;
              } else if (foundType == null) {
                foundType = temp;
              }
            }
          }
        }
        if (type != null) {
          if (typeOrPackageCache != null)
            typeOrPackageCache.put(name, type);
          return type;
        }
      }
    }

    unitScope.recordSimpleReference(name);
    if ((mask & Binding.PACKAGE) != 0) {
      PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
      if (packageBinding != null) {
        if (typeOrPackageCache != null)
          typeOrPackageCache.put(name, packageBinding);
        return packageBinding;
      }
    }

    // Answer error binding -- could not find name
    if (foundType == null) {
      char[][] qName = new char[][] { name };
      ReferenceBinding closestMatch = null;
      if ((mask & Binding.PACKAGE) != 0) {
        if (needResolve) {
          closestMatch = environment().createMissingType(unitScope.fPackage, qName);
        }
      } else {
        PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
        if (packageBinding == null || !packageBinding.isValidBinding()) {
          if (needResolve) {
            closestMatch = environment().createMissingType(unitScope.fPackage, qName);
          }
        }
      }
      foundType = new ProblemReferenceBinding(qName, closestMatch, ProblemReasons.NotFound);
      if (typeOrPackageCache != null && (mask & Binding.PACKAGE) != 0) { // only put NotFound type in cache if you know its not a package
        typeOrPackageCache.put(name, foundType);
      }
    } else if ((foundType.tagBits & TagBits.HasMissingType) != 0) {
      char[][] qName = new char[][] { name };
      foundType = new ProblemReferenceBinding(qName, foundType, ProblemReasons.NotFound);
      if (typeOrPackageCache != null && (mask & Binding.PACKAGE) != 0) // only put NotFound type in cache if you know its not a package
        typeOrPackageCache.put(name, foundType);
    }
    return foundType;
  }
View Full Code Here

*/
void computeInheritedMethods(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) {
  // only want to remember inheritedMethods that can have an impact on the current type
  // if an inheritedMethod has been 'replaced' by a supertype's method then skip it, however
    // see usage of canOverridingMethodDifferInErasure below.
  this.inheritedMethods = new HashtableOfObject(51); // maps method selectors to an array of methods... must search to match paramaters & return type
  ReferenceBinding[] interfacesToVisit = null;
  int nextPosition = 0;
  ReferenceBinding[] itsInterfaces = superInterfaces;
  if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
    nextPosition = itsInterfaces.length;
    interfacesToVisit = itsInterfaces;
  }

  ReferenceBinding superType = superclass;
  HashtableOfObject nonVisibleDefaultMethods = new HashtableOfObject(3); // maps method selectors to an array of methods

  while (superType != null && superType.isValidBinding()) {
    // We used to only include superinterfaces if immediate superclasses are abstract
    // but that is problematic. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=302358
    if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
      if (interfacesToVisit == null) {
        interfacesToVisit = itsInterfaces;
        nextPosition = interfacesToVisit.length;
      } else {
        int itsLength = itsInterfaces.length;
        if (nextPosition + itsLength >= interfacesToVisit.length)
          System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
        nextInterface : for (int a = 0; a < itsLength; a++) {
          ReferenceBinding next = itsInterfaces[a];
          for (int b = 0; b < nextPosition; b++)
            if (next == interfacesToVisit[b]) continue nextInterface;
          interfacesToVisit[nextPosition++] = next;
        }
      }
    }

    MethodBinding[] methods = superType.unResolvedMethods();
    nextMethod : for (int m = methods.length; --m >= 0;) {
      MethodBinding inheritedMethod = methods[m];
      if (inheritedMethod.isPrivate() || inheritedMethod.isConstructor() || inheritedMethod.isDefaultAbstract())
        continue nextMethod;
      MethodBinding[] existingMethods = (MethodBinding[]) this.inheritedMethods.get(inheritedMethod.selector);
      if (existingMethods != null) {
        existing : for (int i = 0, length = existingMethods.length; i < length; i++) {
          MethodBinding existingMethod = existingMethods[i];
          // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302358, skip inherited method only if any overriding version
          // in a subclass is guaranteed to have the same erasure as an existing method.
          if (existingMethod.declaringClass != inheritedMethod.declaringClass && areMethodsCompatible(existingMethod, inheritedMethod) && !canOverridingMethodDifferInErasure(existingMethod, inheritedMethod)) {
            if (inheritedMethod.isDefault()) {
              if (inheritedMethod.isAbstract()) {
                checkPackagePrivateAbstractMethod(inheritedMethod);
              } else if (existingMethod.declaringClass.fPackage != inheritedMethod.declaringClass.fPackage) {
                if (this.type.fPackage == inheritedMethod.declaringClass.fPackage && !areReturnTypesCompatible(inheritedMethod, existingMethod))
                  continue existing; // may need to record incompatible return type
              }
            }
            continue nextMethod;
          }
        }
      }

      if (!inheritedMethod.isDefault() || inheritedMethod.declaringClass.fPackage == this.type.fPackage) {
        if (existingMethods == null) {
          existingMethods = new MethodBinding[] {inheritedMethod};
        } else {
          int length = existingMethods.length;
          System.arraycopy(existingMethods, 0, existingMethods = new MethodBinding[length + 1], 0, length);
          existingMethods[length] = inheritedMethod;
        }
        this.inheritedMethods.put(inheritedMethod.selector, existingMethods);
      } else {
        MethodBinding[] nonVisible = (MethodBinding[]) nonVisibleDefaultMethods.get(inheritedMethod.selector);
        if (nonVisible != null)
          for (int i = 0, l = nonVisible.length; i < l; i++)
            if (areMethodsCompatible(nonVisible[i], inheritedMethod))
              continue nextMethod;
        if (nonVisible == null) {
          nonVisible = new MethodBinding[] {inheritedMethod};
        } else {
          int length = nonVisible.length;
          System.arraycopy(nonVisible, 0, nonVisible = new MethodBinding[length + 1], 0, length);
          nonVisible[length] = inheritedMethod;
        }
        nonVisibleDefaultMethods.put(inheritedMethod.selector, nonVisible);

        if (inheritedMethod.isAbstract() && !this.type.isAbstract()) // non visible abstract methods cannot be overridden so the type must be defined abstract
          problemReporter().abstractMethodCannotBeOverridden(this.type, inheritedMethod);

        MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(inheritedMethod.selector);
View Full Code Here

  return false;   // the case for <= 1.4  (cannot differ)
}
void computeMethods() {
  MethodBinding[] methods = this.type.methods();
  int size = methods.length;
  this.currentMethods = new HashtableOfObject(size == 0 ? 1 : size); // maps method selectors to an array of methods... must search to match paramaters & return type
  for (int m = size; --m >= 0;) {
    MethodBinding method = methods[m];
    if (!(method.isConstructor() || method.isDefaultAbstract())) { // keep all methods which are NOT constructors or default abstract
      MethodBinding[] existingMethods = (MethodBinding[]) this.currentMethods.get(method.selector);
      if (existingMethods == null)
View Full Code Here

    TypeVariableBinding var = this.type.typeVariables[i];
    // must verify bounds if the variable has more than 1
    if (var.superInterfaces == Binding.NO_SUPERINTERFACES) continue;
    if (var.superInterfaces.length == 1 && var.superclass.id == TypeIds.T_JavaLangObject) continue;

    this.currentMethods = new HashtableOfObject(0);
    ReferenceBinding superclass = var.superclass();
    if (superclass.kind() == Binding.TYPE_PARAMETER)
      superclass = (ReferenceBinding) superclass.erasure();
    ReferenceBinding[] itsInterfaces = var.superInterfaces();
    ReferenceBinding[] superInterfaces = new ReferenceBinding[itsInterfaces.length];
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.util.HashtableOfObject

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.