Community
Participate
Working Groups
I20050830-0800 IPackageFragmentRoot#getPackageFragment(String) should not accept invalid package names. Currently, it e.g. accepts "p1/". This leads to strange effects with buffers. I accidentally passed such a package name. I asked the returned IPackageFragment for a compilation unit, and called cu.getSource(). This returned not the current contents of the CU, but the previous version (which has been deleted on the file system by then). I'll attach patches for jdt.ui and jdt.ui.tests.refactoring in case you'd like to reproduce the problem. Run RenamePackageTests, and test1 will fail, because it got the wrong contents for p1/A.java (the contents from test0). The bug in the test (wrong package name passed) is marked with //XXX: bug
Created attachment 26690 [details] jdt.ui
Created attachment 26691 [details] jdt.ui.tests.refactoring
The problem with the wrong buffer may or may not have something to do with bug 77204.
Comment on attachment 26690 [details] jdt.ui Unfortunately this patch cannot longer be applied => set as obsolete
Comment on attachment 26691 [details] jdt.ui.tests.refactoring Unfortunately this patch cannot longer be applied => set as obsolete
Strengthening the precondition of #getPackageFragment() would be a breaking change. I guess the best fix would be to make sure that such packages (and their children) don't exist.
Created attachment 76885 [details] Proposed fix and regression tests
Fix and tests released for 3.4M2 in HEAD.
Verified for 3.4 M2 using I20070917-0010.