Bug 23050

Summary: DOM - IVariableBinding.getModifiers() doesn't give final modifier for local variables
Product: [Eclipse Project] JDT Reporter: mark_dixon
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description mark_dixon CLA 2002-08-30 16:06:57 EDT
Using I200208270833

This code
IWorkspace ws = testcasesPlugin.getWorkspace();
IWorkspaceRoot root = ws.getRoot();
IProject project = root.getProjects()[0];
IJavaProject jp = JavaCore.create(project);
		
CompilationUnit cu = AST.parseCompilationUnit(
   "public class Class {void theMethod() {final int i;}}".toCharArray(),
   "Class", jp);
cu.accept(new ASTVisitor() {
   public boolean visit(VariableDeclarationFragment node) {
      IVariableBinding binding = node.resolveBinding();
      if (!Modifier.isFinal(binding.getModifiers())) {
         System.out.println("No final modifier on binding");
      }
      return true;
   }
});

produces
No final modifier on binding

The code for VariableBinding.getModifiers() is
public int getModifiers() {
   if (isField()) {
      return ((FieldBinding) this.binding).getAccessFlags();
   }
   return 0;
}

I expected to get back the final modifier - is this a bug or is there some 
other way I should be getting this information?

Thanks
Mark
Comment 1 Olivier Thomann CLA 2002-09-04 11:54:00 EDT
Yes, this is a bug and it will be fixed shortly.
Comment 2 Olivier Thomann CLA 2002-09-04 12:02:45 EDT
Fixed and released in 2.1 stream.
Comment 3 David Audel CLA 2002-09-19 04:48:17 EDT
Verified.
Comment 4 Olivier Thomann CLA 2002-09-19 11:06:20 EDT
Regression test added (test0377)