private FieldDeclaration addInstanceVar(ConstructorDeclaration constructor, TypeReference typeReference, TypeDeclaration innerClass) { FieldDeclaration field = new FieldDeclaration(); field.modifiers = AccPrivate | AccStatic | AccFinal; field.name = "INSTANCE".toCharArray(); field.type = typeReference; AllocationExpression exp = new AllocationExpression(); exp.type = typeReference; exp.binding = constructor.binding; exp.sourceStart = innerClass.sourceStart; exp.sourceEnd = innerClass.sourceEnd; field.initialization = exp; return field; }
checkIllegalNullAnnotation(scope, this.resolvedType); checkParameterizedAllocation: { if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() this.binding = inferConstructorOfElidedParameterizedType(scope); if (this.binding == null || !this.binding.isValidBinding()) { scope.problemReporter().cannotInferElidedTypes(this); resolvePolyExpressionArguments(this, this.binding, this.argumentTypes, scope); } else { this.binding = findConstructorBinding(scope, this, (ReferenceBinding) this.resolvedType, this.argumentTypes); scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(scope, null, this.resolvedType, this.binding, this.arguments, this.argumentTypes, this.argsContainCast, this)) { this.bits |= ASTNode.Unchecked; checkTypeArgumentRedundancy((ParameterizedTypeBinding) this.resolvedType, scope);
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { checkCapturedLocalInitializationIfNecessary((ReferenceBinding)this.binding.declaringClass.erasure(), currentScope, flowInfo); analyseArguments(currentScope, flowContext, flowInfo, this.binding, this.arguments); manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo); manageSyntheticAccessIfNecessary(currentScope, flowInfo);
@Override public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { cleanUpInferenceContexts(); if (!valueRequired) currentScope.problemReporter().unusedObjectAllocation(this); currentScope, allocatedType, enclosingInstance(), this); generateArguments(this.binding, this.arguments, currentScope, codeStream); switch (postConversionType(currentScope).id) { case T_long : case T_double :
currentScope, allocatedType, enclosingInstance(), this); generateArguments(this.binding, this.arguments, currentScope, codeStream); switch (postConversionType(currentScope).id) { case T_long : case T_double :
state.scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, state.scope, true)) { state.scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(state.scope, null, allocationType, this.binding, this.arguments, state.argumentTypes, state.argsContainCast, this)) { this.bits |= ASTNode.Unchecked; checkTypeArgumentRedundancy((ParameterizedTypeBinding) this.resolvedType, this.resolvedType.enclosingType(), state.argumentTypes, state.scope); .checkImplicitNullAnnotations(this.binding, null/*srcMethod*/, false, state.scope); recordExceptionsForEnclosingLambda(state.scope, this.binding.thrownExceptions); return allocationType;
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { checkCapturedLocalInitializationIfNecessary((ReferenceBinding)this.binding.declaringClass.erasure(), currentScope, flowInfo); currentScope); manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo); manageSyntheticAccessIfNecessary(currentScope, flowInfo);
TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), null, argumentTypes, scope); if (inferredTypes == null) { scope.problemReporter().cannotInferElidedTypes(this); scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, scope, true)) scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { this.bits |= ASTNode.Unchecked; checkTypeArgumentRedundancy((ParameterizedTypeBinding) this.resolvedType, null, argumentTypes, scope);
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) return; // if constructor from parameterized type got found, use the original constructor at codegen time MethodBinding codegenBinding = this.binding.original(); ReferenceBinding declaringClass; if (codegenBinding.isPrivate() && currentScope.enclosingSourceType() != (declaringClass = codegenBinding.declaringClass)) { // from 1.4 on, local type constructor can lose their private flag to ease emulation if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { // constructor will not be dumped as private, no emulation required thus codegenBinding.tagBits |= TagBits.ClearPrivateModifier; } else { this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess()); currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this); } } }
scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, scope, true)) scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { this.bits |= ASTNode.Unchecked;
} else if (allocationExpression.expectedType() != null) { constructorCall.setType(references.getTypeReference(allocationExpression.expectedType())); if (allocationExpression.genericTypeArguments() != null) { constructorCall.setActualTypeArguments(references.getBoundedTypesReferences(allocationExpression.genericTypeArguments())); if (allocationExpression.enclosingInstance() != null) { context.target.push(constructorCall); allocationExpression.enclosingInstance().traverse(this, scope); context.target.pop();
checkIllegalNullAnnotation(scope, this.resolvedType); checkParameterizedAllocation: { if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() this.binding = inferConstructorOfElidedParameterizedType(scope); if (this.binding == null || !this.binding.isValidBinding()) { scope.problemReporter().cannotInferElidedTypes(this); resolvePolyExpressionArguments(this, this.binding, this.argumentTypes, scope); } else { this.binding = findConstructorBinding(scope, this, (ReferenceBinding) this.resolvedType, this.argumentTypes); scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(scope, null, this.resolvedType, this.binding, this.arguments, this.argumentTypes, this.argsContainCast, this)) { this.bits |= ASTNode.Unchecked; checkTypeArgumentRedundancy((ParameterizedTypeBinding) this.resolvedType, scope);
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { checkCapturedLocalInitializationIfNecessary((ReferenceBinding)this.binding.declaringClass.erasure(), currentScope, flowInfo); analyseArguments(currentScope, flowContext, flowInfo, this.binding, this.arguments); manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo); manageSyntheticAccessIfNecessary(currentScope, flowInfo);
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { cleanUpInferenceContexts(); if (!valueRequired) currentScope.problemReporter().unusedObjectAllocation(this); currentScope, allocatedType, enclosingInstance(), this); generateArguments(this.binding, this.arguments, currentScope, codeStream); switch (postConversionType(currentScope).id) { case T_long : case T_double :
currentScope, allocatedType, enclosingInstance(), this); generateArguments(this.binding, this.arguments, currentScope, codeStream); switch (postConversionType(currentScope).id) { case T_long : case T_double :
state.scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, state.scope, true)) { state.scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(state.scope, null, allocationType, this.binding, this.arguments, state.argumentTypes, state.argsContainCast, this)) { this.bits |= ASTNode.Unchecked; checkTypeArgumentRedundancy((ParameterizedTypeBinding) this.resolvedType, this.resolvedType.enclosingType(), state.argumentTypes, state.scope); .checkImplicitNullAnnotations(this.binding, null/*srcMethod*/, false, state.scope); recordExceptionsForEnclosingLambda(state.scope, this.binding.thrownExceptions); return allocationType;
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { checkCapturedLocalInitializationIfNecessary((ReferenceBinding)this.binding.declaringClass.erasure(), currentScope, flowInfo); manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo); manageSyntheticAccessIfNecessary(currentScope, flowInfo);
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return; // if constructor from parameterized type got found, use the original constructor at codegen time MethodBinding codegenBinding = this.binding.original(); ReferenceBinding declaringClass; if (codegenBinding.isPrivate() && currentScope.enclosingSourceType() != (declaringClass = codegenBinding.declaringClass)) { // from 1.4 on, local type constructor can lose their private flag to ease emulation if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { // constructor will not be dumped as private, no emulation required thus codegenBinding.tagBits |= TagBits.ClearPrivateModifier; } else { this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess()); currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this); } } }
scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, scope, true)) scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { this.bits |= ASTNode.Unchecked;
checkIllegalNullAnnotation(scope, this.resolvedType); checkParameterizedAllocation: { if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() this.binding = inferConstructorOfElidedParameterizedType(scope); if (this.binding == null || !this.binding.isValidBinding()) { scope.problemReporter().cannotInferElidedTypes(this); resolvePolyExpressionArguments(this, this.binding, this.argumentTypes, scope); } else { this.binding = findConstructorBinding(scope, this, (ReferenceBinding) this.resolvedType, this.argumentTypes); scope.problemReporter().missingTypeInConstructor(this, this.binding); if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().deprecatedMethod(this.binding, this); if (checkInvocationArguments(scope, null, this.resolvedType, this.binding, this.arguments, this.argumentTypes, this.argsContainCast, this)) { this.bits |= ASTNode.Unchecked; checkTypeArgumentRedundancy((ParameterizedTypeBinding) this.resolvedType, scope);