Package org.eclipse.jdt.internal.compiler.lookup

Examples of org.eclipse.jdt.internal.compiler.lookup.MethodBinding


      }
    }

    if (typeDecl.binding.isLocalType()) {
      LocalTypeBinding localTypeBinding = (LocalTypeBinding) typeDecl.binding;
      MethodBinding enclosingMethod = localTypeBinding.enclosingMethod;
      if (enclosingMethod != null) {
        if (enclosingMethod.typeVariables != null
            && enclosingMethod.typeVariables.length != 0) {
          /*
           * This local type can reference the type parameters of its enclosing
View Full Code Here


    }

    private void checkMethodRef(ReferenceBinding clazz, JsniRef jsniRef,
        Set<String> errors, Map<String, Set<String>> warnings) {
      assert jsniRef.isMethod();
      MethodBinding target = getMethod(clazz, jsniRef);
      if (target == null) {
        return;
      }
      if (containsLong(target.returnType)) {
        errors.add("Referencing method '" + jsniRef.className() + "."
            + jsniRef.memberName() + "': return type '"
            + typeString(target.returnType)
            + "' is not safe to access in JSNI code");
      }

      if (target.parameters != null) {
        int i = 0;
        for (TypeBinding paramType : target.parameters) {
          ++i;
          if (containsLong(paramType)) {
            // It would be nice to print the parameter name, but how to find it?
            errors.add("Parameter " + i + " of method '" + jsniRef.className()
                + "." + jsniRef.memberName() + "': type '"
                + typeString(paramType)
                + "' may not be passed out of JSNI code");
          }
        }
      }

      if (target.isDeprecated()) {
        add(warnings, "deprecation", "Referencing deprecated method '"
            + jsniRef.className() + "." + jsniRef.memberName() + "'");
      }
    }
View Full Code Here

      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName + "' cannot be a local class");
      return;
    }
    // Look for a noArg ctor.
    MethodBinding noArgCtor = type.getExactConstructor(TypeBinding.NO_PARAMETERS);
    if (noArgCtor == null) {
      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName
              + "' has no default (zero argument) constructors");
      return;
View Full Code Here

     * for details.
     */
    @Override
    public boolean visit(ConstructorDeclaration ctorDecl, ClassScope scope) {
      try {
        MethodBinding b = ctorDecl.binding;
        JClassType enclosingType = (JClassType) typeMap.get(scope.enclosingSourceType());
        String name = enclosingType.getShortName();
        SourceInfo info = makeSourceInfo(ctorDecl, enclosingType);
        JMethod newMethod = program.createMethod(info, name.toCharArray(),
            enclosingType, enclosingType, false, false, true, b.isPrivate(),
            false);

        // Enums have hidden arguments for name and value
        if (enclosingType.isEnumOrSubclass() != null) {
          program.createParameter(info, "enum$name".toCharArray(),
View Full Code Here

    }

    @Override
    public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
      try {
        MethodBinding b = methodDeclaration.binding;
        JDeclaredType enclosingType = (JDeclaredType) typeMap.get(scope.enclosingSourceType());
        SourceInfo info = makeSourceInfo(methodDeclaration, enclosingType);
        JMethod newMethod = processMethodBinding(b, enclosingType, info);
        mapParameters(newMethod, methodDeclaration);
        info.addCorrelation(program.getCorrelator().by(newMethod));
View Full Code Here

      return toReturn;
    }

    private void mapParameters(JMethod method, AbstractMethodDeclaration x) {
      MethodBinding b = x.binding;
      int paramCount = (b.parameters != null ? b.parameters.length : 0);
      if (paramCount > 0) {
        for (int i = 0, n = x.arguments.length; i < n; ++i) {
          createParameter(x.arguments[i].binding, method);
        }
View Full Code Here

      }
    }

    private void checkMethodRef(ReferenceBinding clazz, JsniRef jsniRef) {
      assert jsniRef.isMethod();
      MethodBinding target = getMethod(clazz, jsniRef);
      if (target == null) {
        emitWarning("jsni", "Referencing method '" + jsniRef.className() + "."
            + jsniRef.memberSignature()
            + "': unable to resolve method, expect subsequent failures");
        return;
      }
      if (target.isDeprecated()) {
        emitWarning("deprecation", "Referencing deprecated method '"
            + jsniRef.className() + "." + jsniRef.memberName() + "'");
      }

      if (hasUnsafeLongsAnnotation) {
View Full Code Here

      ((MethodScope) currentScope).isConstructorCall = true;

      int pc = codeStream.position;
      codeStream.aload_0();

      MethodBinding codegenBinding = this.binding.original();
      ReferenceBinding targetType = codegenBinding.declaringClass;

      // special name&ordinal argument generation for enum constructors
      if (targetType.erasure().id == TypeIds.T_JavaLangEnum || targetType.isEnum()) {
        codeStream.aload_1(); // pass along name param as name arg
View Full Code Here

  }

  public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
    if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0)  {
      // if constructor from parameterized type got found, use the original constructor at codegen time
      MethodBinding codegenBinding = this.binding.original();

      // perform some emulation work in case there is some and we are inside a local type only
      if (this.binding.isPrivate() && this.accessMode != ExplicitConstructorCall.This) {
        ReferenceBinding declaringClass = codegenBinding.declaringClass;
        // from 1.4 on, local type constructor can lose their private flag to ease emulation
View Full Code Here

          for (int i = length; --i >= 0;) {
            pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type
          }
          this.binding = scope.findMethod(receiverType, TypeConstants.INIT, pseudoArgs, this);
          if (this.binding != null && !this.binding.isValidBinding()) {
            MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
            // record the closest match, for clients who may still need hint about possible method match
            if (closestMatch != null) {
              if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method
                // shouldn't return generic method outside its context, rather convert it to raw method (175409)
                closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null);
              }
              this.binding = closestMatch;
              MethodBinding closestMatchOriginal = closestMatch.original();
              if (closestMatchOriginal.isOrEnclosedByPrivateType() && !scope.isDefinedInMethod(closestMatchOriginal)) {
                // ignore cases where method is used from within inside itself (e.g. direct recursions)
                closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
              }
            }
          }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.MethodBinding

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.