Bug 239833 - [compiler] Odd compiler error message "Illegal modifier for the method ..."
Summary: [compiler] Odd compiler error message "Illegal modifier for the method ..."
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-07 13:23 EDT by Markus Keller CLA
Modified: 2008-09-15 09:18 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch with testcase (11.44 KB, patch)
2008-08-14 11:53 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-07-07 13:23:44 EDT
I20080702-0939

public class Try {
	//Illegal modifier for the method Try.Try():
	public synchronized Try(int a) { }
	
	//Illegal modifier for the method Try.Try():
	public final static Try() { }
	
	//Illegal modifier for the method m.Try():
	public volatile void m() { }
	
	//Illegal modifier for the field fField; only public, protected,
	// private, static, final, transient & volatile are permitted
	public synchronized int fField;
}

The errors for illegal modifiers on methods and constructors are a bit odd:
- Range is the method & parameter list
   => Expected: The actually illegal modifier
- Talk about method even for constructors
- Would be nice if they listed the allowed modifiers (as in the error for fields)
Comment 1 Markus Keller CLA 2008-07-07 13:28:36 EDT
One more:
- "... for the method m.Try()"
   => should be Try.m()
Comment 2 Kent Johnson CLA 2008-08-14 11:53:58 EDT
Created attachment 109995 [details]
Proposed patch with testcase
Comment 3 Kent Johnson CLA 2008-08-14 13:34:39 EDT
Released for 3.5M2
Comment 4 Markus Keller CLA 2008-08-15 05:38:53 EDT
When you set 3.4 as API Baseline (and everyone should do this), you get an error for the missing @since 3.5 tag on org.eclipse.jdt.core.compiler.IProblem.IllegalModifierForConstructor.
Comment 5 Markus Keller CLA 2008-08-15 06:16:19 EDT
Adapted quick fix "Remove invalid modifiers" to new API in HEAD.
Comment 6 Kent Johnson CLA 2008-08-15 10:50:31 EDT
Added since 3.5 tag

thanks Markus
Comment 7 Jerome Lanneluc CLA 2008-09-15 09:18:12 EDT
3 problems were reported in comment 0:
- range problem (not fixed)
- odd message (fixed)
- request to list allowed modifiers (fixed)

Marking verified for 3.5M2 using I20080914-2000.

Markus, please open a separate bug for the range problem if this is important to you.