-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating synthetic classes for unsolved FieldAccessExpr #61
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
90a4b52
add codes and tests for unsolved field access
LoiNguyenCS 9eaf3e2
clarify docs and apply spotless
LoiNguyenCS 8a1f84b
add test file
LoiNguyenCS 97f9232
change isStatic to String
LoiNguyenCS 4a181cb
apply spotless and clarify comments
LoiNguyenCS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 18 additions & 0 deletions
18
src/test/java/org/checkerframework/specimin/UnsolvedNonStaticField.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,18 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that if Specimin will work if there is an unsolved, non-static field used by | ||
* target methods | ||
*/ | ||
public class UnsolvedNonStaticField { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"unsolvednonstaticfield", | ||
new String[] {"com/example/Foo.java"}, | ||
new String[] {"com.example.Foo#test()"}); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/java/org/checkerframework/specimin/UnsolvedStaticQualifiedField.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,18 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that if Specimin will work if there is an unsolved, static field in a qualified | ||
* name form used by a target method. | ||
*/ | ||
public class UnsolvedStaticQualifiedField { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"unsolvedstaticqualifiedfield", | ||
new String[] {"com/example/Foo.java"}, | ||
new String[] {"com.example.Foo#bar()"}); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/java/org/checkerframework/specimin/UnsolvedStaticSimpleField.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,18 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that if Specimin will work if there is an unsolved, static field in a simple | ||
* name form used by target methods | ||
*/ | ||
public class UnsolvedStaticSimpleField { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"unsolvedstaticsimplefield", | ||
new String[] {"com/example/Foo.java"}, | ||
new String[] {"com.example.Foo#bar()"}); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/java/org/checkerframework/specimin/UnsolvedStaticSimplePrimitiveField.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,18 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that if Specimin will work if there is an unsolved, static field in a simple | ||
* name form with a primitive type. | ||
*/ | ||
public class UnsolvedStaticSimplePrimitiveField { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"unsolvedstaticsimpleprimitivefield", | ||
new String[] {"com/example/Foo.java"}, | ||
new String[] {"com.example.Foo#bar()"}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/resources/unsolvednonstaticfield/expected/com/example/Foo.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,11 @@ | ||
package com.example; | ||
|
||
import org.sampling.Baz; | ||
|
||
class Foo { | ||
|
||
void test() { | ||
Baz testing = new Baz(); | ||
testing.cal.doAddition(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/resources/unsolvednonstaticfield/expected/org/sampling/Baz.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,10 @@ | ||
package org.sampling; | ||
|
||
public class Baz { | ||
|
||
public OrgSamplingBazCalType cal; | ||
|
||
public Baz() { | ||
throw new Error(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/resources/unsolvednonstaticfield/expected/org/sampling/DoAdditionReturnType.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,4 @@ | ||
package org.sampling; | ||
|
||
public class DoAdditionReturnType { | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/resources/unsolvednonstaticfield/expected/org/sampling/OrgSamplingBazCalType.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,8 @@ | ||
package org.sampling; | ||
LoiNguyenCS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public class OrgSamplingBazCalType { | ||
|
||
public DoAdditionReturnType doAddition() { | ||
throw new Error(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/resources/unsolvednonstaticfield/input/com/example/Foo.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,8 @@ | ||
package com.example; | ||
import org.sampling.Baz; | ||
class Foo { | ||
void test() { | ||
Baz testing = new Baz(); | ||
testing.cal.doAddition(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/resources/unsolvedstaticqualifiedfield/expected/com/example/Foo.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,8 @@ | ||
package com.example; | ||
|
||
class Foo { | ||
|
||
void bar() { | ||
org.sampling.Baz.myField.doAddition(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/test/resources/unsolvedstaticqualifiedfield/expected/org/sampling/Baz.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,6 @@ | ||
package org.sampling; | ||
|
||
public class Baz { | ||
|
||
public static OrgSamplingBazMyFieldType myField; | ||
} |
4 changes: 4 additions & 0 deletions
4
...st/resources/unsolvedstaticqualifiedfield/expected/org/sampling/DoAdditionReturnType.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,4 @@ | ||
package org.sampling; | ||
|
||
public class DoAdditionReturnType { | ||
} |
8 changes: 8 additions & 0 deletions
8
...sources/unsolvedstaticqualifiedfield/expected/org/sampling/OrgSamplingBazMyFieldType.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,8 @@ | ||
package org.sampling; | ||
|
||
public class OrgSamplingBazMyFieldType { | ||
|
||
public DoAdditionReturnType doAddition() { | ||
throw new Error(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand why being uppercase tells us whether the field is unsolved. Is there some other invariant here that I'm missing, such as that unsolved fields always are static and need to be accessed via a class name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Professor, I will rename it. We know the field is unsolved because in the visit method for
FieldAccessExpr
, we check to see if the field is solved first before coming to this check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please neglect my earlier response. Before that line, we have a try-catch block to see if the field is solvable. The uppercase check is for the caller of this field. Since we don't have jar paths, we simply assume that if a symbol is capital, then that capital is a class name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not fully happy with this, but I'll let it go for now as tech debt given the need to move quickly