Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and centralize override computations.
Each JMethod contains a list of the methods it overrides; such list should be exhaustive but the previous computation would not include all overriden methods. In the following example public class A { public void m() { } } public interface I { void m(); } public class B extends A implement I { } A.m() overrides I.m() but was not recorded in the JMethod representation of A.m() (we will call this type of override accidental). This patch creates stubs or forwarding methods to anchor accidental overrides, e.g. in the previous example a forwarding stub public void m() { super.m(); } will be created in class and will be marked as overriding both A.m() and I.m(). If the super method was abstract then only an abstract stub will be created. Default methods are handled also integrally as part of the override computation. The override information had duplicated/overlapping implementations in UnifyAst and JTypeOracle, neither of which complete nor correct. Override informatin is mostly used in optimizations resulting in at best missed optimization opportunities and subtle bugs at worst. This patch: 1) fixes the override computation in UnifyAST to take into account package-private methods and accidental override. 2) fixes the selection of the concrete default method implementation. 3) centralizes override information in JMethod. Now JMethod holds both overriden methods and overriding methods, and 4) updates the list of overrides in JMethod when pruning. Change-Id: I1f9af8df529f48b021c8c5de1290780ab5c0f645
- Loading branch information
Showing
21 changed files
with
1,213 additions
and
412 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
Oops, something went wrong.