Bug 83847 - [compiler][1.5] can create annonymous class of an enum
Summary: [compiler][1.5] can create annonymous class of an enum
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-27 12:42 EST by Martin Aeschlimann CLA
Modified: 2005-02-15 06:30 EST (History)
0 users

See Also:


Attachments
Apply on QualifiedAllocationExpression (1.00 KB, patch)
2005-01-27 14:15 EST, Olivier Thomann CLA
no flags Details | Diff
Apply on QualifiedAllocationExpression (1.02 KB, patch)
2005-01-27 14:46 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2005-01-27 12:42:35 EST
20050127

The compiler allows this but probably shouldn't (javac rejects it).

public enum E {
  A;
  private void foo() {
    E e= new E() {
    };
  }
}
Comment 1 Olivier Thomann CLA 2005-01-27 14:15:59 EST
Created attachment 17521 [details]
Apply on QualifiedAllocationExpression
Comment 2 Philipe Mulet CLA 2005-01-27 14:17:16 EST
We should complain. Enums cannot be subclassed by user code (only enum constant
bodies can do so).

Thanks for finding it
Comment 3 Olivier Thomann CLA 2005-01-27 14:35:07 EST
The patch doesn't work.
The test needs to be:
receiverType.isEnum() && type != null
Comment 4 Olivier Thomann CLA 2005-01-27 14:46:00 EST
Created attachment 17522 [details]
Apply on QualifiedAllocationExpression
Comment 5 Philipe Mulet CLA 2005-01-27 15:44:57 EST
I had figured this too.
Comment 6 Philipe Mulet CLA 2005-01-27 15:49:06 EST
Added EnumTest#test065.
Fixed
Comment 7 Jerome Lanneluc CLA 2005-02-15 06:30:59 EST
Verified in I20050214