Bug 99655 - ACC_ABSTRACT set for enum classes when it is not required
Summary: ACC_ABSTRACT set for enum classes when it is not required
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-13 10:15 EDT by Olivier Thomann CLA
Modified: 2009-08-30 02:13 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2005-06-13 10:15:32 EDT
With the following example:

public enum X {
  A() {}
}

we tag the enum as abstract and I don't think this is needed. There is no
abstract method that needs to be implemented.
Comment 1 Kent Johnson CLA 2005-06-13 10:18:27 EDT
Philippe : candidate for RC3.
Comment 2 Philipe Mulet CLA 2005-06-13 12:20:23 EDT
+1 for RC3

Dani: pls also approve this one. After final bit, there is an issue with
abstract bit where we are inconsistent.
Comment 3 Dani Megert CLA 2005-06-13 12:27:53 EDT
+1 for 3.1 RC3.
Comment 4 Kent Johnson CLA 2005-06-13 16:10:11 EDT
Philippe, for this case:

public enum EnumTest {
  B {
    int value() { return 1; }
  };
  int value(){ return 0; }
}

the test fieldDecl.initialization instanceof QualifiedAllocationExpression 
from ClassScope.checkAndSetModifiers() is not sufficient:

TypeDeclaration typeDeclaration = this.referenceContext;
FieldDeclaration[] fields = typeDeclaration.fields;
int length = typeDeclaration.fields == null ? 0 : 
typeDeclaration.fields.length;
checkAbstractEnum: {
  if (length == 0) break checkAbstractEnum; // must implement the method itself
  for (int i = 0; i < length; i++) {
    FieldDeclaration fieldDecl = fields[i];
    if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT)
      if (!(fieldDecl.initialization instanceof QualifiedAllocationExpression))
        break checkAbstractEnum;
  }
  modifiers |= AccAbstract;
}

Any ideas?
Comment 5 Kent Johnson CLA 2005-06-15 10:15:56 EDT
Added EnumTest test114.

We are better than before but still not 100%.

We still tag enums that implement all the methods defined by an interface as 
abstract, such as:

enum EnumX implements I {
  BLUE {};
  public void foo(){}
}
interface I {
  void foo();
}
Comment 6 Denis Roy CLA 2009-08-30 02:13:53 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.