public class ConstructorDeclaration extends AbstractMethodDeclaration {
public ExplicitConstructorCall constructorCall;
- public final static char[] ConstantPoolName = "<init>".toCharArray(); //$NON-NLS-1$
+
public boolean isDefaultConstructor = false;
+ public TypeParameter[] typeParameters;
public ConstructorDeclaration(CompilationResult compilationResult){
super(compilationResult);
}
}
+ // tag parameters as being set
+ if (this.arguments != null) {
+ for (int i = 0, count = this.arguments.length; i < count; i++) {
+ flowInfo.markAsDefinitelyAssigned(this.arguments[i].binding);
+ }
+ }
+
// propagate to constructor call
if (constructorCall != null) {
// if calling 'this(...)', then flag all non-static fields as definitely
classFile.generateMethodInfoHeader(binding);
int methodAttributeOffset = classFile.contentsOffset;
- int attributeNumber = classFile.generateMethodInfoAttribute(binding);
+ int attributeNumber = classFile.generateMethodInfoAttribute(this.binding);
if ((!binding.isNative()) && (!binding.isAbstract())) {
TypeDeclaration declaringType = classScope.referenceContext;
// initialize local positions - including initializer scope.
ReferenceBinding declaringClass = binding.declaringClass;
- int argSlotSize = 1; // this==aload0
-
+ int enumOffset = declaringClass.isEnum() ? 2 : 0; // String name, int ordinal
+ int argSlotSize = 1 + enumOffset; // this==aload0
+
if (declaringClass.isNestedType()){
NestedTypeBinding nestedType = (NestedTypeBinding) declaringClass;
this.scope.extraSyntheticArguments = nestedType.syntheticOuterLocalVariables();
scope.computeLocalVariablePositions(// consider synthetic arguments if any
- nestedType.enclosingInstancesSlotSize + 1,
+ nestedType.enclosingInstancesSlotSize + 1 + enumOffset,
codeStream);
argSlotSize += nestedType.enclosingInstancesSlotSize;
argSlotSize += nestedType.outerLocalVariablesSlotSize;
} else {
- scope.computeLocalVariablePositions(1, codeStream);
+ scope.computeLocalVariablePositions(1 + enumOffset, codeStream);
}
if (arguments != null) {
return true;
}
- /**
+ /*
* Returns true if the constructor is directly involved in a cycle.
* Given most constructors aren't, we only allocate the visited list
* lazily.
- *
- * @param visited
- * @return
*/
public boolean isRecursive(ArrayList visited) {
}
ConstructorDeclaration targetConstructor =
- ((ConstructorDeclaration)this.scope.referenceType().declarationOf(constructorCall.binding));
+ ((ConstructorDeclaration)this.scope.referenceType().declarationOf(constructorCall.binding.original()));
if (this == targetConstructor) return true; // direct case
if (visited == null) { // lazy allocation
//fill up the constructor body with its statements
if (ignoreFurtherInvestigation)
return;
- if (isDefaultConstructor){
- constructorCall = SuperReference.implicitSuperConstructorCall();
- constructorCall.sourceStart = sourceStart;
- constructorCall.sourceEnd = sourceEnd;
+ if (isDefaultConstructor && this.constructorCall == null){
+ this.constructorCall = SuperReference.implicitSuperConstructorCall();
+ this.constructorCall.sourceStart = this.sourceStart;
+ this.constructorCall.sourceEnd = this.sourceEnd;
return;
}
parser.parse(this, unit);
scope.problemReporter().missingReturnType(this);
}
+ if (this.binding != null && this.binding.declaringClass.isAnnotationType()) {
+ scope.problemReporter().annotationTypeDeclarationCannotHaveConstructor(this);
+ }
// if null ==> an error has occurs at parsing time ....
if (this.constructorCall != null) {
// e.g. using super() in java.lang.Object
if (this.binding != null
- && this.binding.declaringClass.id == T_Object
+ && this.binding.declaringClass.id == T_JavaLangObject
&& this.constructorCall.accessMode != ExplicitConstructorCall.This) {
if (this.constructorCall.accessMode == ExplicitConstructorCall.Super) {
scope.problemReporter().cannotUseSuperInJavaLangObject(this.constructorCall);
ASTVisitor visitor,
ClassScope classScope) {
+
if (visitor.visit(this, classScope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.typeParameters != null) {
+ int typeParametersLength = this.typeParameters.length;
+ for (int i = 0; i < typeParametersLength; i++) {
+ this.typeParameters[i].traverse(visitor, scope);
+ }
+ }
if (arguments != null) {
int argumentLength = arguments.length;
for (int i = 0; i < argumentLength; i++)
}
visitor.endVisit(this, classScope);
}
+ public TypeParameter[] typeParameters() {
+ return this.typeParameters;
+ }
}