Community
Participate
Working Groups
Given: public void foo(Object o) { System.out.println(o.getClass().isEnum()); } 1. Select 'o.getClass().isEnum()' 2. Extract to local variable Is: public void foo(Object o) { boolean enum = o.getClass().isEnum(); System.out.println(enum); } Should: something else then 'enum' since in 1.5 enum is a keyword.
Moving to jdt.core: We're using NamingConventions.suggestLocalVariableNames to get a name.
The problem comes from the fact that the call JavaConventions.validateFieldName(new String(suffixName)) returns true even if the field name is a keyword. The scanner used by JavaConventions is used in 1.3 mode. So technically assert or enum can be returned as valid identifiers (field or variable names).
Created attachment 37130 [details] Proposed fix
With this patch, "enum1" is returned.
Created attachment 37132 [details] Regression test
Fixed and released in HEAD. Regression tests added in org.eclipse.jdt.core.tests.model.NamingConventionTests.testSuggestLocalName001/testSuggestLocalName002
+1 for 3.2RC1
Verified for 3.2 RC1 using build I20060413-0010