Skip to content
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

Fix Class literals default and add class literal node in CFG #550

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
dc8ee8e
fix typo
Ao-senXiong Aug 2, 2023
984656b
fix typo
Ao-senXiong Aug 2, 2023
c5f519a
fix typo
Ao-senXiong Aug 2, 2023
a6980ca
fix typo
Ao-senXiong Aug 2, 2023
b9d3d64
test changes
Ao-senXiong Aug 4, 2023
179e55d
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Aug 4, 2023
9de8f06
Merge branch 'fix-fieldaccess' of https://github.com/Ao-senXiong/chec…
Ao-senXiong Aug 4, 2023
4b73445
apply spotless
Ao-senXiong Aug 4, 2023
92248dc
apply spotless
Ao-senXiong Aug 4, 2023
00a3855
test pipelines
Ao-senXiong Aug 8, 2023
acf6530
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Oct 14, 2023
17e79e3
initial commit
Ao-senXiong Oct 16, 2023
cc6844f
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Oct 17, 2023
63f45e6
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Oct 17, 2023
32b0f01
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Oct 21, 2023
ef96c4c
Merge branch 'eisop:master' into fix-fieldaccess
Ao-senXiong Oct 23, 2023
d7cd564
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Dec 12, 2023
709e717
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Jun 1, 2024
1424533
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Aug 27, 2024
1c55e46
Merge branch 'master' into fix-fieldaccess
Ao-senXiong Dec 15, 2024
ec79fa2
Add new Class literalNode and remove hardcode fix
Ao-senXiong Dec 15, 2024
d896862
Clean up old hardcoding
Ao-senXiong Dec 15, 2024
4990cc9
Override toString to use correct name for class literal
Ao-senXiong Dec 15, 2024
2d1aea1
Update expected CFG
Ao-senXiong Dec 15, 2024
bc92643
Leave qualified this in another PR
Ao-senXiong Dec 15, 2024
fcd6950
Javadoc for NodeVisitor
Ao-senXiong Dec 15, 2024
e6b6177
Update expected CFG
Ao-senXiong Dec 15, 2024
c89b017
A lot of Javadoc
Ao-senXiong Dec 15, 2024
4d04987
Maybe this is the cause of daikon failure
Ao-senXiong Dec 15, 2024
9fee97c
Revert the change
Ao-senXiong Dec 15, 2024
ea6b44e
Fix broken link
Ao-senXiong Dec 15, 2024
a59417e
Don't check Daikon 2 to see if there is other failure
Ao-senXiong Dec 15, 2024
5a15cd4
Undo CI
Ao-senXiong Dec 15, 2024
47b2f63
Use PrimitiveTypeNode to represent class literal
Ao-senXiong Dec 15, 2024
b7c80f1
Remove extra comma
Ao-senXiong Dec 15, 2024
f5dec68
Use dummy constructor parameter to prevent ClassCastException
Ao-senXiong Dec 15, 2024
ac88eef
Change field tree to Tree type
Ao-senXiong Dec 15, 2024
731e05e
Only handle class literal
Ao-senXiong Dec 15, 2024
076d3d3
PrimitiveTypeNode Javadoc
Ao-senXiong Dec 15, 2024
691d206
Handle class literal seperately
Ao-senXiong Dec 16, 2024
699ffd3
Also generate javaexpression for class literal and undo lockvisitor c…
Ao-senXiong Dec 16, 2024
838fa79
Don't do cast and comment out unknown condition for testing
Ao-senXiong Dec 16, 2024
e5a3cd8
Don't run JSpecify first
Ao-senXiong Dec 16, 2024
3527e17
Use ClassLiteralNode again and remove hacks
Ao-senXiong Dec 16, 2024
e3a6381
Add ClassLiteral file
Ao-senXiong Dec 16, 2024
86d7d43
Don't check jspeicfy yet
Ao-senXiong Dec 16, 2024
0ec3a94
Javadoc
Ao-senXiong Dec 16, 2024
de55ec0
Javadoc
Ao-senXiong Dec 16, 2024
115ba24
Javadoc
Ao-senXiong Dec 16, 2024
eda8624
Enable JSpecify check since others already passed
Ao-senXiong Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions checker/jtreg/nullness/EISOPissue548/ConservativeClassLiteral.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* @test
* @summary Test class literals in CFGs and their type with conservative nullness.
*
* @compile MyEnum.java
* @compile -processor org.checkerframework.checker.nullness.NullnessChecker -AuseConservativeDefaultsForUncheckedCode=bytecode,-source ConservativeClassLiteral.java
*/

import java.util.EnumSet;

class ConservativeClassLiteral {
EnumSet<MyEnum> none() {
return EnumSet.noneOf(MyEnum.class);
}
}
3 changes: 3 additions & 0 deletions checker/jtreg/nullness/EISOPissue548/MyEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enum MyEnum {
VALUE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public TransferResult<V, S> visitAssignment(AssignmentNode n, TransferInput<V, S
}

/**
* If an invariant field is initialized and has the invariant annotation, than it has at least
* If an invariant field is initialized and has the invariant annotation, then it has at least
* the invariant annotation. Note that only fields of the 'this' receiver are tracked for
* initialization.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.checkerframework.checker.nullness.qual.PolyNull;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.dataflow.analysis.ConditionalTransferResult;
import org.checkerframework.dataflow.analysis.RegularTransferResult;
import org.checkerframework.dataflow.analysis.TransferInput;
import org.checkerframework.dataflow.analysis.TransferResult;
import org.checkerframework.dataflow.cfg.node.ArrayAccessNode;
Expand Down Expand Up @@ -351,6 +352,14 @@ public TransferResult<NullnessValue, NullnessStore> visitMethodAccess(
@Override
public TransferResult<NullnessValue, NullnessStore> visitFieldAccess(
FieldAccessNode n, TransferInput<NullnessValue, NullnessStore> p) {
if (n.getFieldName().equals("class")) {
Ao-senXiong marked this conversation as resolved.
Show resolved Hide resolved
NullnessStore store = p.getRegularStore();
NullnessValue storeValue = store.getValue(n);
TransferResult<NullnessValue, NullnessStore> result =
new RegularTransferResult<NullnessValue, NullnessStore>(storeValue, store);
makeNonNull(result, n.getReceiver());
return result;
}
TransferResult<NullnessValue, NullnessStore> result = super.visitFieldAccess(n, p);
makeNonNull(result, n.getReceiver());
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @checker_framework.manual #optional-checker Optional Checker
*/
// TODO: For a call to ofNullable, if the argument has type @NonNull, make the return type have type
// @Present. Make Optional Checker a subchecker of the Nullness Checker.
// TODO: For a call to of Nullable, if the argument has type @NonNull, make the return type have
// type @Present. Make Optional Checker a subchecker of the Nullness Checker.
@RelevantJavaTypes(Optional.class)
public class OptionalChecker extends BaseTypeChecker {}
1 change: 1 addition & 0 deletions checker/tests/nullness/Issue3020.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ enum Issue3020 {
void retrieveConstant() {
Class<?> theClass = Issue3020.class;
// :: error: (accessing.nullable)
// :: error: (dereference.of.nullable)
Ao-senXiong marked this conversation as resolved.
Show resolved Hide resolved
Object unused = passThrough(theClass.getEnumConstants())[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class FieldAccessNode extends Node {
* Creates a new FieldAccessNode.
*
* @param tree the tree from which to create a FieldAccessNode
* @param receiver the receiver for the resuling FieldAccessNode
* @param receiver the receiver for the resulting FieldAccessNode
*/
public FieldAccessNode(Tree tree, Node receiver) {
super(TreeUtils.typeOf(tree));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3103,12 +3103,14 @@ protected void commonAssignmentCheck(
Tree valueExpTree,
@CompilerMessageKey String errorKey,
Object... extraArgs) {

commonAssignmentCheckStartDiagnostic(varType, valueType, valueExpTree);

AnnotatedTypeMirror widenedValueType = atypeFactory.getWidenedType(valueType, varType);
boolean success = atypeFactory.getTypeHierarchy().isSubtype(widenedValueType, varType);

boolean success;
if (valueExpTree.toString().endsWith(".class")) {
Ao-senXiong marked this conversation as resolved.
Show resolved Hide resolved
success = true;
} else {
commonAssignmentCheckStartDiagnostic(varType, valueType, valueExpTree);
AnnotatedTypeMirror widenedValueType = atypeFactory.getWidenedType(valueType, varType);
success = atypeFactory.getTypeHierarchy().isSubtype(widenedValueType, varType);
}
// TODO: integrate with subtype test.
if (success) {
for (Class<? extends Annotation> mono :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ protected TransferResult<V, S> createTransferResult(@Nullable V value, TransferI
*
* @param value the value; possibly null
* @param in the TransferResult to copy
* @return the input informatio
* @return the input information
*/
@SideEffectFree
protected TransferResult<V, S> recreateTransferResult(
Expand Down