Community
Participate
Working Groups
Consider two classes ####### public class Test1 { public void foo() { new Test2().bar(null); } } ####### import org.eclipse.jdt.annotation.NonNull; public class Test2 { public void bar(@NonNull String str) {} } ##### With 'Build Automatically' turned on, change in the nullness of the parameter 'str' in bar() should rebuild Test1. This is not happening now.
Good catch Satyam. See that it works alright for null annotation change on the method return type. (otherwise changes in @Deprecated wouldn't trigger an incremental build.)
Me thinks this could be an omission in org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.hasStructuralMethodChanges(MethodInfo, MethodInfo) (not handling parameter annotations when comparing methods). Does this sound like the right spot to dive into?
(In reply to comment #2) > Me thinks this could be an omission in > org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.hasStructuralMethodChanges(MethodInfo, > MethodInfo) > > (not handling parameter annotations when comparing methods). > > Does this sound like the right spot to dive into? Yes, I believe you are on the right track.
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=149768
(In reply to comment #4) > See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=149768 Thanks for the pointer. Specifically an example how this kind of issue can best be tested comes very handy.
*** Bug 366341 has been marked as a duplicate of this bug. ***
Per bug# 366341 comment #0, adding annotations to return type doesn't trigger incremental build. This was supposed to already work. Stephan, please remember to check and add junits for this scenario too, TIA.
Created attachment 208319 [details] test & fix The test checks adding/removing/changing a null annotation on a method parameter and on the method itself (return type). As expected a small addition in ClassFileReader.hasStructuralMethodChanges(MethodInfo, MethodInfo) suffices to trigger the desired rebuild. The patch also contains a rename requested in bug 365387 comment 15 (in item (21)). I hope the new name is clearer (the proposed name getTotalParameterCount wouldn't fit for the implementation in MethodInfo, which constantly returns 0).
(In reply to comment #8) > The patch also contains a rename requested in bug 365387 comment 15 > (in item (21)). I hope the new name is clearer > (the proposed name getTotalParameterCount wouldn't fit for the > implementation in MethodInfo, which constantly returns 0). It is better, still not totally apt, but I think we can settle for your choice. Ayush, please review, TIA.
Patch looks good. Change in defaults also causes incremental build which is good.
Released for 3.8 M5 via commit d2fd0a411735601d08912dc407d669f4cabc6555
Verified for 3.8 M5 using build id: I20120122-2000