View | Details | Raw Unified | Return to bug 108263 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java (-3 lines)
Lines 418-426 Link Here
418
			}
418
			}
419
		}
419
		}
420
		
420
		
421
		if (this.binding != null && this.binding.declaringClass.isAnnotationType()) {
422
			this.scope.problemReporter().annotationTypeDeclarationCannotHaveConstructor(this);
423
		}
424
		// if null ==> an error has occurs at parsing time ....
421
		// if null ==> an error has occurs at parsing time ....
425
		if (this.constructorCall != null) {
422
		if (this.constructorCall != null) {
426
			// e.g. using super() in java.lang.Object
423
			// e.g. using super() in java.lang.Object
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java (-11 lines)
Lines 75-91 Link Here
75
				this);
75
				this);
76
		}
76
		}
77
77
78
		checkAnnotationField: {
79
			if (!this.binding.declaringClass.isAnnotationType())
80
				break checkAnnotationField;
81
			if (this.initialization != null) {
82
				if (this.binding.type.isArrayType() && (this.initialization instanceof ArrayInitializer))
83
					break checkAnnotationField;
84
				if (this.initialization.constant != NotAConstant)
85
					break checkAnnotationField;
86
			}
87
			initializationScope.problemReporter().annotationFieldNeedConstantInitialization(this);
88
		}
89
		if (this.initialization != null) {
78
		if (this.initialization != null) {
90
			flowInfo =
79
			flowInfo =
91
				this.initialization
80
				this.initialization
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java (-6 / +15 lines)
Lines 289-298 Link Here
289
							methods[i] = m;
289
							methods[i] = m;
290
						}
290
						}
291
					} else {
291
					} else {
292
						if (this.kind() == IGenericType.INTERFACE_DECL) {
292
						switch(this.kind()) {
293
							// report the problem and continue the parsing
293
							case IGenericType.INTERFACE_DECL :
294
							parser.problemReporter().interfaceCannotHaveConstructors(
294
								// report the problem and continue the parsing
295
								(ConstructorDeclaration) am);
295
								parser.problemReporter().interfaceCannotHaveConstructors(
296
									(ConstructorDeclaration) am);
297
								break;
298
							case IGenericType.ANNOTATION_TYPE_DECL :
299
								// report the problem and continue the parsing
300
								parser.problemReporter().annotationTypeDeclarationCannotHaveConstructor(
301
									(ConstructorDeclaration) am);
296
						}
302
						}
297
						hasConstructor = true;
303
						hasConstructor = true;
298
					}
304
					}
Lines 806-813 Link Here
806
		if (fields == null)
812
		if (fields == null)
807
			return false;
813
			return false;
808
		
814
		
809
		if (kind() == IGenericType.INTERFACE_DECL)
815
		switch(this.kind()) {
810
			return true; // fields are implicitly statics
816
			case IGenericType.INTERFACE_DECL :
817
			case IGenericType.ANNOTATION_TYPE_DECL :
818
				return true; // fields are implicitly statics
819
		}
811
		for (int i = fields.length; --i >= 0;) {
820
		for (int i = fields.length; --i >= 0;) {
812
			FieldDeclaration field = fields[i];
821
			FieldDeclaration field = fields[i];
813
			//need to test the modifier directly while there is no binding yet
822
			//need to test the modifier directly while there is no binding yet
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-9 / +14 lines)
Lines 181-189 Link Here
181
			int count = 0;
181
			int count = 0;
182
			nextMember : for (int i = 0; i < size; i++) {
182
			nextMember : for (int i = 0; i < size; i++) {
183
				TypeDeclaration memberContext = referenceContext.memberTypes[i];
183
				TypeDeclaration memberContext = referenceContext.memberTypes[i];
184
				if (memberContext.kind() == IGenericType.INTERFACE_DECL) {
184
				switch(memberContext.kind()) {
185
					problemReporter().nestedClassCannotDeclareInterface(memberContext);
185
					case IGenericType.INTERFACE_DECL :
186
					continue nextMember;
186
					case IGenericType.ANNOTATION_TYPE_DECL :
187
						problemReporter().illegalLocalTypeDeclaration(memberContext);
188
						continue nextMember;
187
				}
189
				}
188
				ReferenceBinding type = localType;
190
				ReferenceBinding type = localType;
189
				// check that the member does not conflict with an enclosing type
191
				// check that the member does not conflict with an enclosing type
Lines 232-243 Link Here
232
			int count = 0;
234
			int count = 0;
233
			nextMember : for (int i = 0; i < length; i++) {
235
			nextMember : for (int i = 0; i < length; i++) {
234
				TypeDeclaration memberContext = referenceContext.memberTypes[i];
236
				TypeDeclaration memberContext = referenceContext.memberTypes[i];
235
				if (memberContext.kind() == IGenericType.INTERFACE_DECL
237
				switch(memberContext.kind()) {
236
					&& sourceType.isNestedType()
238
					case IGenericType.INTERFACE_DECL :
237
					&& sourceType.isClass() // no need to check for enum, since implicitly static
239
					case IGenericType.ANNOTATION_TYPE_DECL :
238
					&& !sourceType.isStatic()) {
240
						if (sourceType.isNestedType()
239
					problemReporter().nestedClassCannotDeclareInterface(memberContext);
241
								&& sourceType.isClass() // no need to check for enum, since implicitly static
240
					continue nextMember;
242
								&& !sourceType.isStatic()) {
243
							problemReporter().illegalLocalTypeDeclaration(memberContext);
244
							continue nextMember;
245
						}
241
				}
246
				}
242
				ReferenceBinding type = sourceType;
247
				ReferenceBinding type = sourceType;
243
				// check that the member does not conflict with an enclosing type
248
				// check that the member does not conflict with an enclosing type
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java (-7 / +9 lines)
Lines 214-226 Link Here
214
		}
214
		}
215
		return methodBody.add(typeDeclaration, bracketBalanceValue, true);	
215
		return methodBody.add(typeDeclaration, bracketBalanceValue, true);	
216
	}
216
	}
217
	if (typeDeclaration.kind() == IGenericType.INTERFACE_DECL) {
217
	switch(typeDeclaration.kind()) {
218
		this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));
218
		case IGenericType.INTERFACE_DECL :
219
		if (this.parent == null) {
219
		case IGenericType.ANNOTATION_TYPE_DECL :
220
			return this; // ignore
220
			this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));
221
		}
221
			if (this.parent == null) {
222
		// close the constructor
222
				return this; // ignore
223
		return this.parent.add(typeDeclaration, bracketBalanceValue);
223
			}
224
			// close the constructor
225
			return this.parent.add(typeDeclaration, bracketBalanceValue);
224
	}
226
	}
225
	if (localTypes == null) {
227
	if (localTypes == null) {
226
		localTypes = new RecoveredType[5];
228
		localTypes = new RecoveredType[5];
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-9 lines)
Lines 4075-4089 Link Here
4075
		location.sourceStart, 
4075
		location.sourceStart, 
4076
		location.sourceEnd); 
4076
		location.sourceEnd); 
4077
}
4077
}
4078
public void nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) {
4079
	String[] arguments = new String[] {new String(typeDecl.name)};
4080
	this.handle(
4081
		IProblem.CannotDefineInterfaceInLocalType,
4082
		arguments,
4083
		arguments,
4084
		typeDecl.sourceStart,
4085
		typeDecl.sourceEnd);
4086
}
4087
public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location) {
4078
public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location) {
4088
	String[] arguments = new String[]{ new String(local.name) };
4079
	String[] arguments = new String[]{ new String(local.name) };
4089
	this.handle(
4080
	this.handle(

Return to bug 108263