List of usage examples for org.eclipse.jdt.internal.compiler.lookup MethodBinding isVarargs
public boolean isVarargs()
From source file:com.redhat.ceylon.eclipse.core.model.mirror.JDTMethod.java
License:Open Source License
public JDTMethod(JDTClass enclosingClass, MethodBinding method) { this.enclosingClass = enclosingClass; bindingRef = new WeakReference<MethodBinding>(method); name = new String(method.selector); readableName = new String(method.readableName()); isStatic = method.isStatic();/*from w w w. ja v a 2 s . com*/ isPublic = method.isPublic(); isConstructor = method.isConstructor(); isStaticInit = method.selector == TypeConstants.CLINIT; // TODO : check if it is right isAbstract = method.isAbstract(); isFinal = method.isFinal(); isProtected = method.isProtected(); isDefaultAccess = method.isDefault(); isDeclaredVoid = method.returnType.id == TypeIds.T_void; isVariadic = method.isVarargs(); isDefault = method.getDefaultValue() != null; bindingKey = method.computeUniqueKey(); if (method instanceof ProblemMethodBinding) { annotations = new HashMap<>(); parameters = Collections.emptyList(); returnType = JDTType.UNKNOWN_TYPE; typeParameters = Collections.emptyList(); isOverriding = false; isOverloading = false; } }
From source file:org.eclipse.jdt.internal.compiler.lookup.MethodVerifier15.java
License:Open Source License
void checkConcreteInheritedMethod(MethodBinding concreteMethod, MethodBinding[] abstractMethods) { super.checkConcreteInheritedMethod(concreteMethod, abstractMethods); for (int i = 0, l = abstractMethods.length; i < l; i++) { MethodBinding abstractMethod = abstractMethods[i]; if (concreteMethod.isVarargs() != abstractMethod.isVarargs()) problemReporter().varargsConflict(concreteMethod, abstractMethod, this.type); // so the parameters are equal and the return type is compatible b/w the currentMethod & the substituted inheritedMethod MethodBinding originalInherited = abstractMethod.original(); if (originalInherited.returnType != concreteMethod.returnType) if (!isAcceptableReturnTypeOverride(concreteMethod, abstractMethod)) problemReporter().unsafeReturnTypeOverride(concreteMethod, originalInherited, this.type); // check whether bridge method is already defined above for interface methods // skip generation of bridge method for current class & method if an equivalent // bridge will be/would have been generated in the context of the super class since // the bridge itself will be inherited. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=298362 if (originalInherited.declaringClass.isInterface()) { if ((concreteMethod.declaringClass == this.type.superclass && this.type.superclass.isParameterizedType() && !areMethodsCompatible(concreteMethod, originalInherited)) || this.type.superclass.erasure() .findSuperTypeOriginatingFrom(originalInherited.declaringClass) == null) this.type.addSyntheticBridgeMethod(originalInherited, concreteMethod.original()); }/*from w w w. ja va 2 s .c om*/ } }
From source file:org.eclipse.jdt.internal.compiler.lookup.MethodVerifier15.java
License:Open Source License
void checkForBridgeMethod(MethodBinding currentMethod, MethodBinding inheritedMethod, MethodBinding[] allInheritedMethods) { if (currentMethod.isVarargs() != inheritedMethod.isVarargs()) problemReporter(currentMethod).varargsConflict(currentMethod, inheritedMethod, this.type); // so the parameters are equal and the return type is compatible b/w the currentMethod & the substituted inheritedMethod MethodBinding originalInherited = inheritedMethod.original(); if (originalInherited.returnType != currentMethod.returnType) if (!isAcceptableReturnTypeOverride(currentMethod, inheritedMethod)) problemReporter(currentMethod).unsafeReturnTypeOverride(currentMethod, originalInherited, this.type); MethodBinding bridge = this.type.addSyntheticBridgeMethod(originalInherited, currentMethod.original()); if (bridge != null) { for (int i = 0, l = allInheritedMethods == null ? 0 : allInheritedMethods.length; i < l; i++) { if (allInheritedMethods[i] != null && detectInheritedNameClash(originalInherited, allInheritedMethods[i].original())) return; }//from w ww . j a v a2s .c o m // See if the new bridge clashes with any of the user methods of the class. For this check // we should check for "method descriptor clash" and not just "method signature clash". Really // what we are checking is whether there is a contention for the method dispatch table slot. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=293615. MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(bridge.selector); for (int i = current.length - 1; i >= 0; --i) { final MethodBinding thisMethod = current[i]; if (thisMethod.areParameterErasuresEqual(bridge) && thisMethod.returnType.erasure() == bridge.returnType.erasure()) { // use inherited method for problem reporting. problemReporter(thisMethod).methodNameClash(thisMethod, inheritedMethod.declaringClass.isRawType() ? inheritedMethod : inheritedMethod.original(), ProblemSeverities.Error); return; } } } }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
/** * Internal use only/*from www. j a v a2 s . c om*/ * Given a method, returns null if arguments cannot be converted to parameters. * Will answer a substituted method in case the method was generic and type inference got triggered; * in case the method was originally compatible, then simply answer it back. */ protected final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) { TypeBinding[] genericTypeArguments = invocationSite.genericTypeArguments(); TypeBinding[] parameters = method.parameters; TypeVariableBinding[] typeVariables = method.typeVariables; if (parameters == arguments && (method.returnType.tagBits & TagBits.HasTypeVariable) == 0 && genericTypeArguments == null && typeVariables == Binding.NO_TYPE_VARIABLES) return method; int argLength = arguments.length; int paramLength = parameters.length; boolean isVarArgs = method.isVarargs(); if (argLength != paramLength) if (!isVarArgs || argLength < paramLength - 1) return null; // incompatible // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330435, inference should kick in only at source 1.5+ if (typeVariables != Binding.NO_TYPE_VARIABLES && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // generic method TypeBinding[] newArgs = null; for (int i = 0; i < argLength; i++) { TypeBinding param = i < paramLength ? parameters[i] : parameters[paramLength - 1]; if (arguments[i].isBaseType() != param.isBaseType()) { if (newArgs == null) { newArgs = new TypeBinding[argLength]; System.arraycopy(arguments, 0, newArgs, 0, argLength); } newArgs[i] = environment().computeBoxingType(arguments[i]); } } if (newArgs != null) arguments = newArgs; method = ParameterizedGenericMethodBinding.computeCompatibleMethod(method, arguments, this, invocationSite); if (method == null) return null; // incompatible if (!method.isValidBinding()) return method; // bound check issue is taking precedence } else if (genericTypeArguments != null && compilerOptions().complianceLevel < ClassFileConstants.JDK1_7) { if (method instanceof ParameterizedGenericMethodBinding) { if (!((ParameterizedGenericMethodBinding) method).wasInferred) // attempt to invoke generic method of raw type with type hints <String>foo() return new ProblemMethodBinding(method, method.selector, genericTypeArguments, ProblemReasons.TypeArgumentsForRawGenericMethod); } else if (!method.isOverriding() || !isOverriddenMethodGeneric(method)) { return new ProblemMethodBinding(method, method.selector, genericTypeArguments, ProblemReasons.TypeParameterArityMismatch); } } if (parameterCompatibilityLevel(method, arguments) > NOT_COMPATIBLE) { if ((method.tagBits & TagBits.AnnotationPolymorphicSignature) != 0) { // generate polymorphic method return this.environment().createPolymorphicMethod(method, arguments); } return method; } // if method is generic and type arguments have been supplied, only then answer a problem // of ParameterizedMethodTypeMismatch, else a non-generic method was invoked using type arguments // in which case this problem category will be bogus if (genericTypeArguments != null && typeVariables != Binding.NO_TYPE_VARIABLES) return new ProblemMethodBinding(method, method.selector, arguments, ProblemReasons.ParameterizedMethodTypeMismatch); return null; // incompatible }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
protected boolean isAcceptableMethod(MethodBinding one, MethodBinding two) { TypeBinding[] oneParams = one.parameters; TypeBinding[] twoParams = two.parameters; int oneParamsLength = oneParams.length; int twoParamsLength = twoParams.length; if (oneParamsLength == twoParamsLength) { /* Below 1.5, discard any generics we have left in for the method verifier's benefit, (so it can detect method overriding properly in the presence of generic super types.) This is so as to allow us to determine whether we have been handed an acceptable method in 1.4 terms without all the 1.5isms below kicking in and spoiling the party. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 *///w w w . j a v a 2s. c o m boolean applyErasure = environment().globalOptions.sourceLevel < ClassFileConstants.JDK1_5; next: for (int i = 0; i < oneParamsLength; i++) { TypeBinding oneParam = applyErasure ? oneParams[i].erasure() : oneParams[i]; TypeBinding twoParam = applyErasure ? twoParams[i].erasure() : twoParams[i]; if (oneParam == twoParam || oneParam.isCompatibleWith(twoParam)) { if (two.declaringClass.isRawType()) continue next; TypeBinding leafComponentType = two.original().parameters[i].leafComponentType(); TypeBinding originalTwoParam = applyErasure ? leafComponentType.erasure() : leafComponentType; switch (originalTwoParam.kind()) { case Binding.TYPE_PARAMETER: if (((TypeVariableBinding) originalTwoParam).hasOnlyRawBounds()) continue next; //$FALL-THROUGH$ case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_TYPE: case Binding.PARAMETERIZED_TYPE: TypeBinding originalOneParam = one.original().parameters[i].leafComponentType(); switch (originalOneParam.kind()) { case Binding.TYPE: case Binding.GENERIC_TYPE: TypeBinding inheritedTwoParam = oneParam.findSuperTypeOriginatingFrom(twoParam); if (inheritedTwoParam == null || !inheritedTwoParam.leafComponentType().isRawType()) break; return false; case Binding.TYPE_PARAMETER: if (!((TypeVariableBinding) originalOneParam).upperBound().isRawType()) break; return false; case Binding.RAW_TYPE: // originalOneParam is RAW so it cannot be more specific than a wildcard or parameterized type return false; } } } else { if (i == oneParamsLength - 1 && one.isVarargs() && two.isVarargs()) { TypeBinding eType = ((ArrayBinding) twoParam).elementsType(); if (oneParam == eType || oneParam.isCompatibleWith(eType)) return true; // special case to choose between 2 varargs methods when the last arg is Object[] } return false; } } return true; } if (one.isVarargs() && two.isVarargs()) { if (oneParamsLength > twoParamsLength) { // special case when autoboxing makes (int, int...) better than (Object...) but not (int...) or (Integer, int...) if (((ArrayBinding) twoParams[twoParamsLength - 1]).elementsType().id != TypeIds.T_JavaLangObject) return false; } // check that each parameter before the vararg parameters are compatible (no autoboxing allowed here) for (int i = (oneParamsLength > twoParamsLength ? twoParamsLength : oneParamsLength) - 2; i >= 0; i--) if (oneParams[i] != twoParams[i] && !oneParams[i].isCompatibleWith(twoParams[i])) return false; if (parameterCompatibilityLevel(one, twoParams) == NOT_COMPATIBLE && parameterCompatibilityLevel(two, oneParams) == VARARGS_COMPATIBLE) return true; } return false; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public int parameterCompatibilityLevel(MethodBinding method, TypeBinding[] arguments) { TypeBinding[] parameters = method.parameters; int paramLength = parameters.length; int argLength = arguments.length; if (compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) { if (paramLength != argLength) return NOT_COMPATIBLE; for (int i = 0; i < argLength; i++) { TypeBinding param = parameters[i]; TypeBinding arg = arguments[i]; //https://bugs.eclipse.org/bugs/show_bug.cgi?id=330445 if (arg != param && !arg.isCompatibleWith(param.erasure())) return NOT_COMPATIBLE; }//from ww w.j a v a 2 s.co m return COMPATIBLE; } int level = COMPATIBLE; // no autoboxing or varargs support needed int lastIndex = argLength; LookupEnvironment env = environment(); if (method.isVarargs()) { lastIndex = paramLength - 1; if (paramLength == argLength) { // accept X or X[] but not X[][] TypeBinding param = parameters[lastIndex]; // is an ArrayBinding by definition TypeBinding arg = arguments[lastIndex]; if (param != arg) { level = parameterCompatibilityLevel(arg, param, env); if (level == NOT_COMPATIBLE) { // expect X[], is it called with X param = ((ArrayBinding) param).elementsType(); if (parameterCompatibilityLevel(arg, param, env) == NOT_COMPATIBLE) return NOT_COMPATIBLE; level = VARARGS_COMPATIBLE; // varargs support needed } } } else { if (paramLength < argLength) { // all remaining argument types must be compatible with the elementsType of varArgType TypeBinding param = ((ArrayBinding) parameters[lastIndex]).elementsType(); for (int i = lastIndex; i < argLength; i++) { TypeBinding arg = arguments[i]; if (param != arg && parameterCompatibilityLevel(arg, param, env) == NOT_COMPATIBLE) return NOT_COMPATIBLE; } } else if (lastIndex != argLength) { // can call foo(int i, X ... x) with foo(1) but NOT foo(); return NOT_COMPATIBLE; } level = VARARGS_COMPATIBLE; // varargs support needed } } else if (paramLength != argLength) { return NOT_COMPATIBLE; } // now compare standard arguments from 0 to lastIndex for (int i = 0; i < lastIndex; i++) { TypeBinding param = parameters[i]; TypeBinding arg = arguments[i]; if (arg != param) { int newLevel = parameterCompatibilityLevel(arg, param, env); if (newLevel == NOT_COMPATIBLE) return NOT_COMPATIBLE; if (newLevel > level) level = newLevel; } } return level; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public MethodBinding getStaticFactory(ReferenceBinding allocationType, ReferenceBinding originalEnclosingType, TypeBinding[] argumentTypes, final InvocationSite allocationSite) { TypeVariableBinding[] classTypeVariables = allocationType.typeVariables(); int classTypeVariablesArity = classTypeVariables.length; MethodBinding[] methods = allocationType.getMethods(TypeConstants.INIT, argumentTypes.length); MethodBinding[] staticFactories = new MethodBinding[methods.length]; int sfi = 0;/*from w w w .j a v a 2s . c o m*/ for (int i = 0, length = methods.length; i < length; i++) { MethodBinding method = methods[i]; int paramLength = method.parameters.length; boolean isVarArgs = method.isVarargs(); if (argumentTypes.length != paramLength) if (!isVarArgs || argumentTypes.length < paramLength - 1) continue; // incompatible TypeVariableBinding[] methodTypeVariables = method.typeVariables(); int methodTypeVariablesArity = methodTypeVariables.length; MethodBinding staticFactory = new MethodBinding(method.modifiers | ClassFileConstants.AccStatic, TypeConstants.SYNTHETIC_STATIC_FACTORY, null, null, null, method.declaringClass); staticFactory.typeVariables = new TypeVariableBinding[classTypeVariablesArity + methodTypeVariablesArity]; final SimpleLookupTable map = new SimpleLookupTable(classTypeVariablesArity + methodTypeVariablesArity); // Rename each type variable T of the type to T' final LookupEnvironment environment = environment(); for (int j = 0; j < classTypeVariablesArity; j++) { map.put(classTypeVariables[j], staticFactory.typeVariables[j] = new TypeVariableBinding( CharOperation.concat(classTypeVariables[j].sourceName, "'".toCharArray()), //$NON-NLS-1$ staticFactory, j, environment)); } // Rename each type variable U of method U to U''. for (int j = classTypeVariablesArity, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) { map.put(methodTypeVariables[j - classTypeVariablesArity], (staticFactory.typeVariables[j] = new TypeVariableBinding( CharOperation.concat(methodTypeVariables[j - classTypeVariablesArity].sourceName, "''".toCharArray()), //$NON-NLS-1$ staticFactory, j, environment))); } ReferenceBinding enclosingType = originalEnclosingType; while (enclosingType != null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=345968 if (enclosingType.kind() == Binding.PARAMETERIZED_TYPE) { final ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) enclosingType; final ReferenceBinding genericType = parameterizedType.genericType(); TypeVariableBinding[] enclosingClassTypeVariables = genericType.typeVariables(); int enclosingClassTypeVariablesArity = enclosingClassTypeVariables.length; for (int j = 0; j < enclosingClassTypeVariablesArity; j++) { map.put(enclosingClassTypeVariables[j], parameterizedType.arguments[j]); } } enclosingType = enclosingType.enclosingType(); } final Scope scope = this; Substitution substitution = new Substitution() { public LookupEnvironment environment() { return scope.environment(); } public boolean isRawSubstitution() { return false; } public TypeBinding substitute(TypeVariableBinding typeVariable) { TypeBinding retVal = (TypeBinding) map.get(typeVariable); return retVal != null ? retVal : typeVariable; } }; // initialize new variable bounds for (int j = 0, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) { TypeVariableBinding originalVariable = j < classTypeVariablesArity ? classTypeVariables[j] : methodTypeVariables[j - classTypeVariablesArity]; TypeBinding substitutedType = (TypeBinding) map.get(originalVariable); if (substitutedType instanceof TypeVariableBinding) { TypeVariableBinding substitutedVariable = (TypeVariableBinding) substitutedType; TypeBinding substitutedSuperclass = Scope.substitute(substitution, originalVariable.superclass); ReferenceBinding[] substitutedInterfaces = Scope.substitute(substitution, originalVariable.superInterfaces); if (originalVariable.firstBound != null) { substitutedVariable.firstBound = originalVariable.firstBound == originalVariable.superclass ? substitutedSuperclass // could be array type or interface : substitutedInterfaces[0]; } switch (substitutedSuperclass.kind()) { case Binding.ARRAY_TYPE: substitutedVariable.superclass = environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null); substitutedVariable.superInterfaces = substitutedInterfaces; break; default: if (substitutedSuperclass.isInterface()) { substitutedVariable.superclass = environment .getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null); int interfaceCount = substitutedInterfaces.length; System.arraycopy(substitutedInterfaces, 0, substitutedInterfaces = new ReferenceBinding[interfaceCount + 1], 1, interfaceCount); substitutedInterfaces[0] = (ReferenceBinding) substitutedSuperclass; substitutedVariable.superInterfaces = substitutedInterfaces; } else { substitutedVariable.superclass = (ReferenceBinding) substitutedSuperclass; // typeVar was extending other typeVar which got substituted with interface substitutedVariable.superInterfaces = substitutedInterfaces; } } } } TypeVariableBinding[] returnTypeParameters = new TypeVariableBinding[classTypeVariablesArity]; for (int j = 0; j < classTypeVariablesArity; j++) { returnTypeParameters[j] = (TypeVariableBinding) map.get(classTypeVariables[j]); } staticFactory.returnType = environment.createParameterizedType(allocationType, returnTypeParameters, allocationType.enclosingType()); staticFactory.parameters = Scope.substitute(substitution, method.parameters); staticFactory.thrownExceptions = Scope.substitute(substitution, method.thrownExceptions); if (staticFactory.thrownExceptions == null) { staticFactory.thrownExceptions = Binding.NO_EXCEPTIONS; } staticFactories[sfi++] = new ParameterizedMethodBinding( (ParameterizedTypeBinding) environment.convertToParameterizedType(staticFactory.declaringClass), staticFactory); } if (sfi == 0) return null; if (sfi != methods.length) { System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi); } MethodBinding[] compatible = new MethodBinding[sfi]; int compatibleIndex = 0; for (int i = 0; i < sfi; i++) { MethodBinding compatibleMethod = computeCompatibleMethod(staticFactories[i], argumentTypes, allocationSite); if (compatibleMethod != null) { if (compatibleMethod.isValidBinding()) compatible[compatibleIndex++] = compatibleMethod; } } if (compatibleIndex == 0) { return null; } MethodBinding[] visible = new MethodBinding[compatibleIndex]; int visibleIndex = 0; for (int i = 0; i < compatibleIndex; i++) { MethodBinding method = compatible[i]; if (method.canBeSeenBy(allocationSite, this)) visible[visibleIndex++] = method; } if (visibleIndex == 0) { return null; } return visibleIndex == 1 ? visible[0] : mostSpecificMethodBinding(visible, visibleIndex, argumentTypes, allocationSite, allocationType); }
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
public MethodBinding resolveTypesFor(MethodBinding method) { if ((method.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0) return method; if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { if ((method.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0) method.modifiers |= ClassFileConstants.AccDeprecated; }//from www . ja va2 s .com if (isViewedAsDeprecated() && !method.isDeprecated()) method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; if (hasRestrictedAccess()) method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; AbstractMethodDeclaration methodDecl = method.sourceMethod(); // GROOVY /* old { if (methodDecl == null) return null; // method could not be resolved in previous iteration } new*/ if (methodDecl == null) { if (method instanceof LazilyResolvedMethodBinding) { LazilyResolvedMethodBinding lrMethod = (LazilyResolvedMethodBinding) method; // the rest is a copy of the code below but doesn't depend on the method declaration // nothing to do for method type parameters (there are none) // nothing to do for method exceptions (there are none) TypeBinding ptb = lrMethod.getParameterTypeBinding(); if (ptb == null) { method.parameters = Binding.NO_PARAMETERS; } else { method.parameters = new TypeBinding[] { ptb }; } method.returnType = lrMethod.getReturnTypeBinding(); method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; return method; } // returning null is what this clause would have done anyway return null; } // FIXASC - end TypeParameter[] typeParameters = methodDecl.typeParameters(); if (typeParameters != null) { methodDecl.scope.connectTypeVariables(typeParameters, true); // Perform deferred bound checks for type variables (only done after type variable hierarchy is connected) for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++) typeParameters[i].checkBounds(methodDecl.scope); } TypeReference[] exceptionTypes = methodDecl.thrownExceptions; if (exceptionTypes != null) { int size = exceptionTypes.length; method.thrownExceptions = new ReferenceBinding[size]; int count = 0; ReferenceBinding resolvedExceptionType; for (int i = 0; i < size; i++) { resolvedExceptionType = (ReferenceBinding) exceptionTypes[i].resolveType(methodDecl.scope, true /* check bounds*/); if (resolvedExceptionType == null) continue; if (resolvedExceptionType.isBoundParameterizedType()) { methodDecl.scope.problemReporter().invalidParameterizedExceptionType(resolvedExceptionType, exceptionTypes[i]); continue; } if (resolvedExceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null) { if (resolvedExceptionType.isValidBinding()) { methodDecl.scope.problemReporter().cannotThrowType(exceptionTypes[i], resolvedExceptionType); continue; } } if ((resolvedExceptionType.tagBits & TagBits.HasMissingType) != 0) { method.tagBits |= TagBits.HasMissingType; } method.modifiers |= (resolvedExceptionType.modifiers & ExtraCompilerModifiers.AccGenericSignature); method.thrownExceptions[count++] = resolvedExceptionType; } if (count < size) System.arraycopy(method.thrownExceptions, 0, method.thrownExceptions = new ReferenceBinding[count], 0, count); } final boolean reportUnavoidableGenericTypeProblems = this.scope .compilerOptions().reportUnavoidableGenericTypeProblems; boolean foundArgProblem = false; Argument[] arguments = methodDecl.arguments; if (arguments != null) { int size = arguments.length; method.parameters = Binding.NO_PARAMETERS; TypeBinding[] newParameters = new TypeBinding[size]; for (int i = 0; i < size; i++) { Argument arg = arguments[i]; if (arg.annotations != null) { method.tagBits |= TagBits.HasParameterAnnotations; } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && !method.isConstructor() && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0; TypeBinding parameterType; if (deferRawTypeCheck) { arg.type.bits |= ASTNode.IgnoreRawTypeCheck; } try { parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/); } finally { if (deferRawTypeCheck) { arg.type.bits &= ~ASTNode.IgnoreRawTypeCheck; } } if (parameterType == null) { foundArgProblem = true; } else if (parameterType == TypeBinding.VOID) { methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg); foundArgProblem = true; } else { if ((parameterType.tagBits & TagBits.HasMissingType) != 0) { method.tagBits |= TagBits.HasMissingType; } TypeBinding leafType = parameterType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) method.modifiers |= ExtraCompilerModifiers.AccGenericSignature; newParameters[i] = parameterType; arg.binding = new LocalVariableBinding(arg, parameterType, arg.modifiers, true); } } // only assign parameters if no problems are found if (!foundArgProblem) { method.parameters = newParameters; } } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=337799 if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7) { if ((method.tagBits & TagBits.AnnotationSafeVarargs) != 0) { if (!method.isVarargs()) { methodDecl.scope.problemReporter().safeVarargsOnFixedArityMethod(method); } else if (!method.isStatic() && !method.isFinal() && !method.isConstructor()) { methodDecl.scope.problemReporter().safeVarargsOnNonFinalInstanceMethod(method); } } else if (method.parameters != null && method.parameters.length > 0 && method.isVarargs()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=337795 if (!method.parameters[method.parameters.length - 1].isReifiable()) { methodDecl.scope.problemReporter() .possibleHeapPollutionFromVararg(methodDecl.arguments[methodDecl.arguments.length - 1]); } } } boolean foundReturnTypeProblem = false; if (!method.isConstructor()) { TypeReference returnType = methodDecl instanceof MethodDeclaration ? ((MethodDeclaration) methodDecl).returnType : null; if (returnType == null) { methodDecl.scope.problemReporter().missingReturnType(methodDecl); method.returnType = null; foundReturnTypeProblem = true; } else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0; TypeBinding methodType; if (deferRawTypeCheck) { returnType.bits |= ASTNode.IgnoreRawTypeCheck; } try { methodType = returnType.resolveType(methodDecl.scope, true /* check bounds*/); } finally { if (deferRawTypeCheck) { returnType.bits &= ~ASTNode.IgnoreRawTypeCheck; } } if (methodType == null) { foundReturnTypeProblem = true; } else if (methodType.isArrayType() && ((ArrayBinding) methodType).leafComponentType == TypeBinding.VOID) { methodDecl.scope.problemReporter().returnTypeCannotBeVoidArray((MethodDeclaration) methodDecl); foundReturnTypeProblem = true; } else { if ((methodType.tagBits & TagBits.HasMissingType) != 0) { method.tagBits |= TagBits.HasMissingType; } method.returnType = methodType; TypeBinding leafType = methodType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) method.modifiers |= ExtraCompilerModifiers.AccGenericSignature; } } } if (foundArgProblem) { methodDecl.binding = null; method.parameters = Binding.NO_PARAMETERS; // see 107004 // nullify type parameter bindings as well as they have a backpointer to the method binding // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81134) if (typeParameters != null) for (int i = 0, length = typeParameters.length; i < length; i++) typeParameters[i].binding = null; return null; } if (foundReturnTypeProblem) return method; // but its still unresolved with a null return type & is still connected to its method declaration method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; return method; }