Examples of ReferenceBinding


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

    return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), null, ProblemReasons.NotFound);
  }

  // know binding is now a ReferenceBinding
  while (currentIndex < length) {
    ReferenceBinding typeBinding = (ReferenceBinding) binding;
    char[] nextName = compoundName[currentIndex++];
    invocationSite.setFieldIndex(currentIndex);
    if ((binding = findFieldForCodeSnippet(typeBinding, nextName, invocationSite)) != null) {
      if (!binding.isValidBinding()) {
        return new ProblemFieldBinding(
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

            && CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) {
          // from 1.5 compliant mode on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast
      this.valueCast = runtimeTimeType;     
    }
        if (this.valueCast instanceof ReferenceBinding) {
      ReferenceBinding referenceCast = (ReferenceBinding) this.valueCast;
      if (!referenceCast.canBeSeenBy(scope)) {
            scope.problemReporter().invalidType(this,
                new ProblemReferenceBinding(
              CharOperation.splitOn('.', referenceCast.shortReadableName()),
              referenceCast,
              ProblemReasons.NotVisible));
      }
        }   
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

  if (isStatic) {
    this.receiver.generateCode(currentScope, codeStream, false);
    codeStream.recordPositionsFrom(pc, this.sourceStart);
  } else if ((this.bits & ASTNode.DepthMASK) != 0 && this.receiver.isImplicitThis()) { // outer access ?
    // outer method can be reached through emulation if implicit access
    ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT);   
    Object[] path = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
    codeStream.generateOuterAccess(path, this, targetType, currentScope);
  } else {
    this.receiver.generateCode(currentScope, codeStream, true);
    if (this.receiverGenericCast != null)
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

  BlockScope currentScope,
  CodeStream codeStream,
  boolean valueRequired) {

  int pc = codeStream.position;
  ReferenceBinding allocatedType = this.codegenBinding.declaringClass;

  if (this.codegenBinding.canBeSeenBy(allocatedType, this, currentScope)) {
    codeStream.new_(allocatedType);
    if (valueRequired) {
      codeStream.dup();
    }
    // better highlight for allocation: display the type individually
    codeStream.recordPositionsFrom(pc, this.type.sourceStart);

    // handling innerclass instance allocation - enclosing instance arguments
    if (allocatedType.isNestedType()) {
      codeStream.generateSyntheticEnclosingInstanceValues(
        currentScope,
        allocatedType,
        enclosingInstance(),
        this);
    }
    // generate the arguments for constructor
    if (this.arguments != null) {
      for (int i = 0, count = this.arguments.length; i < count; i++) {
        this.arguments[i].generateCode(currentScope, codeStream, true);
      }
    }
    // handling innerclass instance allocation - outer local arguments
    if (allocatedType.isNestedType()) {
      codeStream.generateSyntheticOuterArgumentValues(
        currentScope,
        allocatedType,
        this);
    }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

  }
  if (!this.resolvedType.canBeInstantiated()) {
    scope.problemReporter().cannotInstantiate(this.type, this.resolvedType);
    return this.resolvedType;
  }
  ReferenceBinding allocatedType = (ReferenceBinding) this.resolvedType;
  if (!(this.binding = scope.getConstructor(allocatedType, argumentTypes, this)).isValidBinding()) {
    if (this.binding instanceof ProblemMethodBinding
      && ((ProblemMethodBinding) this.binding).problemId() == NotVisible) {
      if (this.evaluationContext.declaringTypeName != null) {
        this.delegateThis = scope.getField(scope.enclosingSourceType(), DELEGATE_THIS, this);
        if (this.delegateThis == null) {
          if (this.binding.declaringClass == null) {
            this.binding.declaringClass = allocatedType;
          }
          scope.problemReporter().invalidConstructor(this, this.binding);
          return this.resolvedType;
        }
      } else {
        if (this.binding.declaringClass == null) {
          this.binding.declaringClass = allocatedType;
        }
        scope.problemReporter().invalidConstructor(this, this.binding);
        return this.resolvedType;
      }
      CodeSnippetScope localScope = new CodeSnippetScope(scope);     
      MethodBinding privateBinding = localScope.getConstructor((ReferenceBinding)this.delegateThis.type, argumentTypes, this);
      if (!privateBinding.isValidBinding()) {
        if (this.binding.declaringClass == null) {
          this.binding.declaringClass = allocatedType;
        }
        scope.problemReporter().invalidConstructor(this, this.binding);
        return this.resolvedType;
      } else {
        this.binding = privateBinding;
      }       
    } else {
      if (this.binding.declaringClass == null) {
        this.binding.declaringClass = allocatedType;
      }
      scope.problemReporter().invalidConstructor(this, this.binding);
      return this.resolvedType;
    }
  }
  if (isMethodUseDeprecated(this.binding, scope, true)) {
    scope.problemReporter().deprecatedMethod(this.binding, this);
  }
  if (arguments != null) {
    for (int i = 0; i < arguments.length; i++) {
        TypeBinding parameterType = binding.parameters[i];
        TypeBinding argumentType = argumentTypes[i];
      arguments[i].computeConversion(scope, parameterType, argumentType);
      if (argumentType.needsUncheckedConversion(parameterType)) {
        scope.problemReporter().unsafeTypeConversion(arguments[i], argumentType, parameterType);
      }
    }
    if (argsContainCast) {
      CastExpression.checkNeedForArgumentCasts(scope, null, allocatedType, binding, this.arguments, argumentTypes, this);
    }
  }
  if (allocatedType.isRawType() && this.binding.hasSubstitutedParameters()) {
      scope.problemReporter().unsafeRawInvocation(this, this.binding);
  }
  return allocatedType;
}
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

            return checkCastTypesCompatibility(scope, ((TypeVariableBinding)castType).upperBound(), expressionType, expression);

          default :
            if (castType.isInterface()) {
              // ( INTERFACE ) INTERFACE
              ReferenceBinding interfaceType = (ReferenceBinding) expressionType;
              match = interfaceType.findSuperTypeWithSameErasure(castType);
              if (match != null) {
                return checkUnsafeCast(scope, castType, interfaceType, match, false);
              }
              tagAsNeedCheckCast();
              match = castType.findSuperTypeWithSameErasure(interfaceType);
              if (match != null) {
                return checkUnsafeCast(scope, castType, interfaceType, match, true);
              }
              if (use15specifics) {
                checkUnsafeCast(scope, castType, expressionType, null /*no match*/, true);
                // ensure there is no collision between both interfaces: i.e. I1 extends List<String>, I2 extends List<Object>
                if (interfaceType.hasIncompatibleSuperType((ReferenceBinding)castType))
                  return false;
              } else {
                // pre1.5 semantics - no covariance allowed (even if 1.5 compliant, but 1.4 source)
                MethodBinding[] castTypeMethods = getAllInheritedMethods((ReferenceBinding) castType);
                MethodBinding[] expressionTypeMethods = getAllInheritedMethods((ReferenceBinding) expressionType);
                int exprMethodsLength = expressionTypeMethods.length;
                for (int i = 0, castMethodsLength = castTypeMethods.length; i < castMethodsLength; i++) {
                  for (int j = 0; j < exprMethodsLength; j++) {
                    if ((castTypeMethods[i].returnType != expressionTypeMethods[j].returnType)
                        && (CharOperation.equals(castTypeMethods[i].selector, expressionTypeMethods[j].selector))
                        && castTypeMethods[i].areParametersEqual(expressionTypeMethods[j])) {
                      return false;
       
                    }
                  }
                }
              }
              return true;   
            } else {
              // ( CLASS ) INTERFACE
              if (castType.id == TypeIds.T_JavaLangObject) { // no runtime error
                tagAsUnnecessaryCast(scope, castType);
                return true;
              }
              // can only be a downcast
              tagAsNeedCheckCast();
              match = castType.findSuperTypeWithSameErasure(expressionType);
              if (match != null) {
                return checkUnsafeCast(scope, castType, expressionType, match, true);
              }
              if (((ReferenceBinding) castType).isFinal()) {
                // no subclass for castType, thus compile-time check is invalid
                return false;
              }
              if (use15specifics) {
                checkUnsafeCast(scope, castType, expressionType, null /*no match*/, true);
                // ensure there is no collision between both interfaces: i.e. I1 extends List<String>, I2 extends List<Object>
                if (((ReferenceBinding)castType).hasIncompatibleSuperType((ReferenceBinding) expressionType)) {
                  return false;
                }
              }
              return true;
            }
        }
      } else {
        switch (castType.kind()) {
          case Binding.ARRAY_TYPE :
            // ( ARRAY ) CLASS
            if (expressionType.id == TypeIds.T_JavaLangObject) { // potential runtime error
              if (use15specifics) checkUnsafeCast(scope, castType, expressionType, expressionType, true);
              tagAsNeedCheckCast();
              return true;
            }
            return false;
           
          case Binding.TYPE_PARAMETER :
            // ( TYPE_PARAMETER ) CLASS
            match = expressionType.findSuperTypeWithSameErasure(castType);
            if (match == null) {
              checkUnsafeCast(scope, castType, expressionType, match, true);
            }
            // recurse on the type variable upper bound
            return checkCastTypesCompatibility(scope, ((TypeVariableBinding)castType).upperBound(), expressionType, expression);
           
          default :
            if (castType.isInterface()) {
              // ( INTERFACE ) CLASS
              ReferenceBinding refExprType = (ReferenceBinding) expressionType;
              match = refExprType.findSuperTypeWithSameErasure(castType);
              if (match != null) {
                return checkUnsafeCast(scope, castType, expressionType, match, false);
              }
              // unless final a subclass may implement the interface ==> no check at compile time
              if (refExprType.isFinal()) {
                return false;
              }
              tagAsNeedCheckCast();
              match = castType.findSuperTypeWithSameErasure(expressionType);
              if (match != null) {
                return checkUnsafeCast(scope, castType, expressionType, match, true);
              }
              if (use15specifics) {
                checkUnsafeCast(scope, castType, expressionType, null /*no match*/, true);
                // ensure there is no collision between both interfaces: i.e. I1 extends List<String>, I2 extends List<Object>
                if (refExprType.hasIncompatibleSuperType((ReferenceBinding) castType))
                  return false;
              }               
              return true;
            } else {
              // ( CLASS ) CLASS
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

*/

public final boolean canBeSeenByForCodeSnippet(FieldBinding fieldBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
  if (fieldBinding.isPublic()) return true;

  ReferenceBinding invocationType = (ReferenceBinding) receiverType;
  if (invocationType == fieldBinding.declaringClass) return true;

  if (fieldBinding.isProtected()) {
    // answer true if the invocationType is the declaringClass or they are in the same package
    // OR the invocationType is a subclass of the declaringClass
    //    AND the receiverType is the invocationType or its subclass
    //    OR the field is a static field accessed directly through a type
    if (invocationType == fieldBinding.declaringClass) return true;
    if (invocationType.fPackage == fieldBinding.declaringClass.fPackage) return true;
    if (fieldBinding.declaringClass.isSuperclassOf(invocationType)) {
      if (invocationSite.isSuperAccess()) return true;
      // receiverType can be an array binding in one case... see if you can change it
      if (receiverType instanceof ArrayBinding)
        return false;
      if (invocationType.isSuperclassOf((ReferenceBinding) receiverType))
        return true;
      if (fieldBinding.isStatic())
        return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
    }
    return false;
  }

  if (fieldBinding.isPrivate()) {
    // answer true if the receiverType is the declaringClass
    // AND the invocationType and the declaringClass have a common enclosingType
    if (receiverType != fieldBinding.declaringClass) return false;

    if (invocationType != fieldBinding.declaringClass) {
      ReferenceBinding outerInvocationType = invocationType;
      ReferenceBinding temp = outerInvocationType.enclosingType();
      while (temp != null) {
        outerInvocationType = temp;
        temp = temp.enclosingType();
      }

      ReferenceBinding outerDeclaringClass = fieldBinding.declaringClass;
      temp = outerDeclaringClass.enclosingType();
      while (temp != null) {
        outerDeclaringClass = temp;
        temp = temp.enclosingType();
      }
      if (outerInvocationType != outerDeclaringClass) return false;
    }
    return true;
  }

  // isDefault()
  if (invocationType.fPackage != fieldBinding.declaringClass.fPackage) return false;

  // receiverType can be an array binding in one case... see if you can change it
  if (receiverType instanceof ArrayBinding)
    return false;
  ReferenceBinding type = (ReferenceBinding) receiverType;
  PackageBinding declaringPackage = fieldBinding.declaringClass.fPackage;
  do {
    if (fieldBinding.declaringClass == type) return true;
    if (declaringPackage != type.fPackage) return false;
  } while ((type = type.superclass()) != null);
  return false;
}
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

* NOTE: Cannot invoke this method with a compilation unit scope.
*/
public final boolean canBeSeenByForCodeSnippet(MethodBinding methodBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
  if (methodBinding.isPublic()) return true;

  ReferenceBinding invocationType = (ReferenceBinding) receiverType;
  if (invocationType == methodBinding.declaringClass && invocationType == receiverType) return true;

  if (methodBinding.isProtected()) {
    // answer true if the invocationType is the declaringClass or they are in the same package
    // OR the invocationType is a subclass of the declaringClass
    //    AND the receiverType is the invocationType or its subclass
    //    OR the method is a static method accessed directly through a type
    if (invocationType == methodBinding.declaringClass) return true;
    if (invocationType.fPackage == methodBinding.declaringClass.fPackage) return true;
    if (methodBinding.declaringClass.isSuperclassOf(invocationType)) {
      if (invocationSite.isSuperAccess()) return true;
      // receiverType can be an array binding in one case... see if you can change it
      if (receiverType instanceof ArrayBinding)
        return false;
      if (invocationType.isSuperclassOf((ReferenceBinding) receiverType))
        return true;
      if (methodBinding.isStatic())
        return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
    }
    return false;
  }

  if (methodBinding.isPrivate()) {
    // answer true if the receiverType is the declaringClass
    // AND the invocationType and the declaringClass have a common enclosingType
    if (receiverType != methodBinding.declaringClass) return false;

    if (invocationType != methodBinding.declaringClass) {
      ReferenceBinding outerInvocationType = invocationType;
      ReferenceBinding temp = outerInvocationType.enclosingType();
      while (temp != null) {
        outerInvocationType = temp;
        temp = temp.enclosingType();
      }

      ReferenceBinding outerDeclaringClass = methodBinding.declaringClass;
      temp = outerDeclaringClass.enclosingType();
      while (temp != null) {
        outerDeclaringClass = temp;
        temp = temp.enclosingType();
      }
      if (outerInvocationType != outerDeclaringClass) return false;
    }
    return true;
  }

  // isDefault()
  if (invocationType.fPackage != methodBinding.declaringClass.fPackage) return false;

  // receiverType can be an array binding in one case... see if you can change it
  if (receiverType instanceof ArrayBinding)
    return false;
  ReferenceBinding type = (ReferenceBinding) receiverType;
  PackageBinding declaringPackage = methodBinding.declaringClass.fPackage;
  do {
    if (methodBinding.declaringClass == type) return true;
    if (declaringPackage != type.fPackage) return false;
  } while ((type = type.superclass()) != null);
  return false;
}
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

  }

  if (referenceBinding.isPrivate()) {
    // answer true if the receiver and the receiverType have a common enclosingType
    // already know they are not the identical type
    ReferenceBinding outerInvocationType = receiverType;
    ReferenceBinding temp = outerInvocationType.enclosingType();
    while (temp != null) {
      outerInvocationType = temp;
      temp = temp.enclosingType();
    }

    ReferenceBinding outerDeclaringClass = referenceBinding;
    temp = outerDeclaringClass.enclosingType();
    while (temp != null) {
      outerDeclaringClass = temp;
      temp = temp.enclosingType();
    }
    return outerInvocationType == outerDeclaringClass;
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

  if (!methodScope.isStatic && !methodScope.isConstructorCall){
    nestedType.addSyntheticArgumentAndField(nestedType.enclosingType())
  }
  // add superclass enclosing instance arg for anonymous types (if necessary)
  if (nestedType.isAnonymousType()) {
    ReferenceBinding superclassBinding = (ReferenceBinding)nestedType.superclass.erasure();
    if (superclassBinding.enclosingType() != null && !superclassBinding.isStatic()) {
      if (!superclassBinding.isLocalType()
          || ((NestedTypeBinding)superclassBinding).getSyntheticField(superclassBinding.enclosingType(), true) != null){

        nestedType.addSyntheticArgument(superclassBinding.enclosingType())
      }
    }
    // From 1.5 on, provide access to enclosing instance synthetic constructor argument when declared inside constructor call
    // only for direct anonymous type
    //public class X {
    //  void foo() {}
    //  class M {
    //    M(Object o) {}
    //    M() { this(new Object() { void baz() { foo(); }}); } // access to #foo() indirects through constructor synthetic arg: val$this$0
    //  }
    //}
    if (!methodScope.isStatic && methodScope.isConstructorCall && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5) {
      ReferenceBinding enclosing = nestedType.enclosingType();
      if (enclosing.isNestedType()) {
        NestedTypeBinding nestedEnclosing = (NestedTypeBinding)enclosing;
//          if (nestedEnclosing.findSuperTypeErasingTo(nestedEnclosing.enclosingType()) == null) { // only if not inheriting
          SyntheticArgumentBinding syntheticEnclosingInstanceArgument = nestedEnclosing.getSyntheticArgument(nestedEnclosing.enclosingType(), true);
          if (syntheticEnclosingInstanceArgument != null) {
            nestedType.addSyntheticArgumentAndField(syntheticEnclosingInstanceArgument)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.