-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Serialization: Split field initialization region into smaller reg…
…ions (#658) This PR resolves #657 by splitting the field initialization region into smaller regions. We currently only consider the value "null", for all `errors/fixes` reported in this regions. In large classes which they have many number of field, this can easily create a lot builds as they all have the value "null" for enclosing method causing conflicts in regions. This PR generalizes the concept of enclosing method to enclosing member, and breaks a single regions of field initialization regions into a separate region for each field declaration and reduce the conflicts in regions dramatically. The equivalent for enclosing member is described: The enclosing member for `fix` or `error` is: - If it is triggered inside a __method__, the enclosing member will be the __enclosing method__. - If it is enclosed by a __field declaration statement__, the enclosing member will be the __declared field__. - If __none__ of the above, the enclosing member will be `"null"` (used for __static initialization region__). With the current approach the following errors will have the values below: ```java class C { Field foo1 = Field(null); // Passing nullable, enclMethod = "null" Field foo2 = null; // assigning nullable, enclMethod = "null" static Field foo3 3 = null; // assigning nullable, enclMethod = "null" { foo3 = null; // assigning nullable, enclMethod = "null" } void bar(){ this.foo1 = null; // assigning nullable, enclMethod = "bar()" } } ``` From the point of view of Annotator, that is __4__ conflicts in regions as they all have `enclMethod = "null"`. This can be greatly improved with the new approach suggested and changed to below: ```java class C { Field foo1 = Field(null); // Passing nullable, enclMember = "foo1" Field foo2 = null; // assigning nullable, enclMember = "foo2" static Field foo3 = null; // assigning nullable, enclMember = "foo3" { Field3 = null; // assigning nullable, enclMember = "null" } void bar(){ this.foo1 = null; // assigning nullable, enclMember = "bar()" } } ``` None of the error reported above have any conflicts and can be allocated to separate regions.
- Loading branch information
1 parent
19bbb91
commit eb62d57
Showing
5 changed files
with
177 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters