Lines 456-469
Link Here
|
456 |
if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) |
456 |
if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) |
457 |
problemReporter().illegalModifierForEnum(sourceType); |
457 |
problemReporter().illegalModifierForEnum(sourceType); |
458 |
} |
458 |
} |
459 |
|
459 |
if (!sourceType.isAnonymousType()) { |
460 |
// what about inherited interface methods? |
|
|
461 |
if ((referenceContext.bits & ASTNode.HasAbstractMethods) != 0) { |
462 |
modifiers |= ClassFileConstants.AccAbstract; |
463 |
} else if (!sourceType.isAnonymousType()) { |
464 |
// body of enum constant must implement any inherited abstract methods |
465 |
// enum type needs to implement abstract methods if one of its constants does not supply a body |
466 |
checkAbstractEnum: { |
460 |
checkAbstractEnum: { |
|
|
461 |
// does define abstract methods ? |
462 |
if ((referenceContext.bits & ASTNode.HasAbstractMethods) != 0) { |
463 |
modifiers |= ClassFileConstants.AccAbstract; |
464 |
break checkAbstractEnum; |
465 |
} |
466 |
// body of enum constant must implement any inherited abstract methods |
467 |
// enum type needs to implement abstract methods if one of its constants does not supply a body |
467 |
TypeDeclaration typeDeclaration = this.referenceContext; |
468 |
TypeDeclaration typeDeclaration = this.referenceContext; |
468 |
FieldDeclaration[] fields = typeDeclaration.fields; |
469 |
FieldDeclaration[] fields = typeDeclaration.fields; |
469 |
int fieldsLength = fields == null ? 0 : fields.length; |
470 |
int fieldsLength = fields == null ? 0 : fields.length; |
Lines 479-488
Link Here
|
479 |
for (int i = 0; i < fieldsLength; i++) { |
480 |
for (int i = 0; i < fieldsLength; i++) { |
480 |
FieldDeclaration fieldDecl = fields[i]; |
481 |
FieldDeclaration fieldDecl = fields[i]; |
481 |
if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) { |
482 |
if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) { |
482 |
if (!(fieldDecl.initialization instanceof QualifiedAllocationExpression)) { |
483 |
if (fieldDecl.initialization instanceof QualifiedAllocationExpression) { |
483 |
break checkAbstractEnum; |
|
|
484 |
} else { |
485 |
needAbstractBit = true; |
484 |
needAbstractBit = true; |
|
|
485 |
} else { |
486 |
break checkAbstractEnum; |
486 |
} |
487 |
} |
487 |
} |
488 |
} |
488 |
} |
489 |
} |
Lines 492-499
Link Here
|
492 |
modifiers |= ClassFileConstants.AccAbstract; |
493 |
modifiers |= ClassFileConstants.AccAbstract; |
493 |
} |
494 |
} |
494 |
} |
495 |
} |
|
|
496 |
// final if no enum constant with anonymous body |
497 |
checkFinalEnum: { |
498 |
TypeDeclaration typeDeclaration = this.referenceContext; |
499 |
FieldDeclaration[] fields = typeDeclaration.fields; |
500 |
if (fields != null) { |
501 |
for (int i = 0, fieldsLength = fields.length; i < fieldsLength; i++) { |
502 |
FieldDeclaration fieldDecl = fields[i]; |
503 |
if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) { |
504 |
if (fieldDecl.initialization instanceof QualifiedAllocationExpression) { |
505 |
break checkFinalEnum; |
506 |
} |
507 |
} |
508 |
} |
509 |
} |
510 |
modifiers |= ClassFileConstants.AccFinal; |
511 |
} |
495 |
} |
512 |
} |
496 |
modifiers |= ClassFileConstants.AccFinal; |
|
|
497 |
} else { |
513 |
} else { |
498 |
// detect abnormal cases for classes |
514 |
// detect abnormal cases for classes |
499 |
if (isMemberType) { // includes member types defined inside local types |
515 |
if (isMemberType) { // includes member types defined inside local types |
Lines 591-598
Link Here
|
591 |
|
607 |
|
592 |
// set the modifiers |
608 |
// set the modifiers |
593 |
final int IMPLICIT_MODIFIERS = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccEnum; |
609 |
final int IMPLICIT_MODIFIERS = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccEnum; |
594 |
if (fieldDecl.initialization instanceof QualifiedAllocationExpression) |
|
|
595 |
declaringClass.modifiers &= ~ClassFileConstants.AccFinal; |
596 |
fieldBinding.modifiers|= IMPLICIT_MODIFIERS; |
610 |
fieldBinding.modifiers|= IMPLICIT_MODIFIERS; |
597 |
return; |
611 |
return; |
598 |
} |
612 |
} |