Bug 107580 - Putting a period after an enum element with a constructor causes a crash
Summary: Putting a period after an enum element with a constructor causes a crash
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 blocker (vote)
Target Milestone: 3.2 M2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 114314 120138 137484 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-22 05:32 EDT by Stefan Uldum Grinsted CLA
Modified: 2006-04-19 13:59 EDT (History)
4 users (show)

See Also:


Attachments
patch proposal (1010 bytes, text/plain)
2005-08-24 06:32 EDT, David Audel CLA
no flags Details
Proposed patch for 3.1.1 (1022 bytes, text/plain)
2005-08-24 07:38 EDT, David Audel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Uldum Grinsted CLA 2005-08-22 05:32:32 EDT
Consider the following code:
---------------------------------------------------
public enum Element {
	BEGIN			("body.jsp"),
	END			("body.jsp");

	private String file;
	Element(String file) {
		this.file = file;
	}
}
---------------------------------------------------
I experienced that accidentally replacing the ";", after the second 
element "END", with a dot/period (.), causes eclipse to crash. I really just 
wanted to add an additional element, so i meant to replace it with a comma 
instead.

Nothing interesting showed up in the .log file. This was what it read during 
next startup:
---------------------------------------------------
!ENTRY org.eclipse.core.resources 2 10035 2005-08-22 10:50:21.264
!MESSAGE A workspace crash was detected. The previous session did not exit 
normally.
---------------------------------------------------
Comment 1 Olivier Thomann CLA 2005-08-22 09:42:20 EDT
This is severe.
Putting a dot is causing an OutOfMemoryError. This means that the workspace
needs to be exited.
I will investigate.
Comment 2 Olivier Thomann CLA 2005-08-22 09:54:10 EDT
You need the parenthesis before the dot.

public enum X {
	BEGIN		("body.jsp"),
	END			("body.jsp").

	private String file;
	X(String file) {
		this.file = file;
	}
}

if you remove the ("body.jsp") it works fine and you get:
----------
1. WARNING in d:\tests_sources\X.java
 (at line 2)
	BEGIN			("body.jsp"),
	     			 ^^^^^^^^^^
Non-externalized string literal; it should be followed by //$NON-NLS-<n>$
----------
2. ERROR in d:\tests_sources\X.java
 (at line 3)
	END			.
	   			^
Syntax error on token ".", ; expected
----------
2 problems (1 error, 1 warning)
Comment 3 David Audel CLA 2005-08-24 06:32:02 EDT
Created attachment 26400 [details]
patch proposal

The problem is inside Parser#consumeEnumConstantheader(). There is a special
recovery when a dot is after an enum constant header but now this recovery not
useful any more and cause the bug.
Comment 4 David Audel CLA 2005-08-24 06:34:37 EDT
Fix released in head and test added.
  EnumDietRecoveryTest#test0016()
Comment 5 David Audel CLA 2005-08-24 07:37:48 EDT
This bug could be a candidate for 3.1.1.
Comment 6 David Audel CLA 2005-08-24 07:38:34 EDT
Created attachment 26401 [details]
Proposed patch for 3.1.1
Comment 7 Olivier Thomann CLA 2005-09-20 11:34:36 EDT
Verified in I20050920-0010 for 3.2M2
Comment 8 Olivier Thomann CLA 2005-10-30 21:42:01 EST
*** Bug 114314 has been marked as a duplicate of this bug. ***
Comment 9 David Audel CLA 2005-12-13 10:48:42 EST
*** Bug 120138 has been marked as a duplicate of this bug. ***
Comment 10 Olivier Thomann CLA 2006-04-19 13:59:25 EDT
*** Bug 137484 has been marked as a duplicate of this bug. ***