-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inline method to check access modifiers of inlined code (#1381)
* Fix inline method to check access modifiers of inlined code - add new checkAccessCompatible() method to SourceProvider that checks if code from declaration can be moved to target without causing an access violation - add new AccessVisitor to SourceAnalyzer to log non-public accesses (private, package-private, and protected) - add call to checkAccessCompatible() in CallInliner - add new tests to InlineMethodTests - fixes #1358
- Loading branch information
Showing
12 changed files
with
265 additions
and
2 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
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
17 changes: 17 additions & 0 deletions
17
...ests.refactoring/resources/InlineMethodWorkspace/TestCases/bugs_in/Test_issue_1358_2.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package bugs_in; | ||
|
||
class MyClass { | ||
static int value= 10; | ||
|
||
public static void staticMethod() { | ||
System.out.println("Value: " + value); | ||
} | ||
} | ||
|
||
public class Test_issue_1358_2 { | ||
private int value= 20; | ||
|
||
public void callStaticMethod() { | ||
new MyClass()./*]*/staticMethod()/*[*/; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ests.refactoring/resources/InlineMethodWorkspace/TestCases/bugs_in/Test_issue_1358_3.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package bugs_in; | ||
|
||
public class Test_issue_1358_3 { | ||
class MyClass { | ||
private int value= 10; | ||
|
||
public void method() { | ||
System.out.println("Value: " + value); | ||
} | ||
} | ||
private int value= 20; | ||
|
||
public void callMethod() { | ||
new MyClass()./*]*/method()/*[*/; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...sts.refactoring/resources/InlineMethodWorkspace/TestCases/bugs_out/Test_issue_1358_2.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package bugs_in; | ||
|
||
class MyClass { | ||
static int value= 10; | ||
|
||
public static void staticMethod() { | ||
System.out.println("Value: " + value); | ||
} | ||
} | ||
|
||
public class Test_issue_1358_2 { | ||
private int value= 20; | ||
|
||
public void callStaticMethod() { | ||
System.out.println("Value: " + MyClass.value); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...sts.refactoring/resources/InlineMethodWorkspace/TestCases/bugs_out/Test_issue_1358_3.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package bugs_in; | ||
|
||
public class Test_issue_1358_3 { | ||
class MyClass { | ||
private int value= 10; | ||
|
||
public void method() { | ||
System.out.println("Value: " + value); | ||
} | ||
} | ||
private int value= 20; | ||
|
||
public void callMethod() { | ||
System.out.println("Value: " + new MyClass().value); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ests.refactoring/resources/InlineMethodWorkspace/TestCases/invalid/Test_issue_1358_1.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package invalid; | ||
|
||
class MyClass { | ||
private static int value= 10; | ||
|
||
public static void staticMethod() { | ||
System.out.println("Value: " + value); | ||
} | ||
} | ||
|
||
class AnotherClass { | ||
private int value= 20; | ||
|
||
public void callStaticMethod() { | ||
new MyClass()./*]*/staticMethod()/*[*/; | ||
} | ||
} |
Oops, something went wrong.