Bug 239833

Summary: [compiler] Odd compiler error message "Illegal modifier for the method ..."
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: jerome_lanneluc, philippe_mulet
Version: 3.5   
Target Milestone: 3.5 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch with testcase none

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.