Bug 100695

Summary: [1.5][search] Renaming a field of generic array type has no effect
Product: [Eclipse Project] JDT Reporter: baikuo21
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dirk_baeumer, mlists, philippe_mulet
Version: 3.1   
Target Milestone: 3.1.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Patch to implement this fix none

Description baikuo21 CLA 2005-06-17 22:37:32 EDT
3.1RC2

eg.
class A {
  Class<Class>[] a;
  Class<Class>[] b = a;
  A() {
    a = null;
  }
}

While renaming the field "a", all "a"s are unchanged except the declaring one.
Comment 1 Frederic Fusier CLA 2005-06-21 11:03:50 EDT
Created attachment 23628 [details]
Patch to implement this fix

ArrayBinding are not taken into account while resolving level of field
declaring type.
Easy and localized fix which does not impact existing search.
However, this is not a stop ship defect => good candidate for 3.1.1
Comment 2 Philipe Mulet CLA 2005-06-21 12:33:25 EDT
Dirk - do you agree with the non-critical statement ? I mean in term of impact
on refactorings.
Comment 3 Dirk Baeumer CLA 2005-06-22 04:06:33 EDT
Frederic, can you confirm that 

- this is only a problem with arrays where the element type is a parameterized 
  types. 
- methods having arrays for paramterized types as a return type or parameter
  type are still found so that refactoring works

class A {
	  public void foo(Class<Class>[] a) {
	  }
	  
	  void bar() {
		  foo(null);
	  }
}

If the above is true then only fields are affected. Since fields are most of the
time local to a class and Local rename works in this case it is OK for me to
postpone to 3.1.1. 
Comment 4 Frederic Fusier CLA 2005-06-22 05:00:24 EDT
I confirm that in RC3:

1) search find references to field with non-parameterized array or simple
parameterized type declaring class.
=> correct references are found and refactoring works well in following cases:
class C {
  Class<Class> foo;
  Class<Class> bar = foo;
  C() {
    foo = null;
  }
}
class B {
  Class[] field;
  Class[] bar = field;
  B() {
    field = null;
  }
}

2) search find references to method with return types and parameters as
parameterized type arrays.
=> correct references are found and refactoring works well in following cases:
public class X {
	  public Class<Class>[] foo(Class<Class>[] a) {
		  return a;
	  }
	  void bar() {
		  foo(new Class[0]);
	  }
}
public class Y {
	  public void foo(Class<Class>[] a) {}
	  
	  void bar() {
		  foo(new Class[0]);
	  }
}
public class Z {
	  public Class<Class>[] foo() {
		  return new Class[0];
	  }
	  
	  void bar() {
		  foo();
	  }
}
Comment 5 Frederic Fusier CLA 2005-07-08 07:29:20 EDT
Fixed and released in R3_1_maintenance.

[jdt-core internal]
Test cases added in JavaSearchBugsTests
Comment 6 Frederic Fusier CLA 2005-08-03 10:20:38 EDT
Backported to HEAD stream.
Comment 7 Olivier Thomann CLA 2005-08-09 10:18:56 EDT
Verified in 3.2M1 (I20050808-2000)
Comment 8 Maxime Daniel CLA 2005-09-26 10:07:25 EDT
Verified for 3.1.1 using build M20050923-1430.