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 all 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 @@ -793,7 +793,7 @@ public Void visitNewArray(NewArrayTree tree, AnnotatedTypeMirror type) {
@Override
public Void visitMemberSelect(
MemberSelectTree tree, AnnotatedTypeMirror annotatedTypeMirror) {
if (TreeUtils.isArrayLengthAccess(tree)) {
if (TreeUtils.isArrayLengthAccess(tree) || TreeUtils.isClassLiteral(tree)) {
annotatedTypeMirror.replaceAnnotation(INITIALIZED);
}
return super.visitMemberSelect(tree, annotatedTypeMirror);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,10 @@ public Void visitMemberSelect(MemberSelectTree tree, AnnotatedTypeMirror type) {
Element elt = TreeUtils.elementFromUse(tree);
assert elt != null;

// Make primitive variable @NonNull in case the Initialization Checker
// Make primitive variable and class literal @NonNull in case the Initialization Checker
// considers it uninitialized.
if (TypesUtils.isPrimitive(type.getUnderlyingType())) {
if (TypesUtils.isPrimitive(type.getUnderlyingType())
|| TreeUtils.isClassLiteral(tree)) {
type.replaceAnnotation(NONNULL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.checkerframework.dataflow.cfg.node.CatchMarkerNode;
import org.checkerframework.dataflow.cfg.node.CharacterLiteralNode;
import org.checkerframework.dataflow.cfg.node.ClassDeclarationNode;
import org.checkerframework.dataflow.cfg.node.ClassLiteralNode;
import org.checkerframework.dataflow.cfg.node.ClassNameNode;
import org.checkerframework.dataflow.cfg.node.ConditionalAndNode;
import org.checkerframework.dataflow.cfg.node.ConditionalNotNode;
Expand Down Expand Up @@ -3671,6 +3672,11 @@ public Node visitMemberSelect(MemberSelectTree tree, Void p) {
Node result = new PackageNameNode(tree, (PackageNameNode) expr);
extendWithNode(result);
return result;
} else if (element.getKind() == ElementKind.FIELD
&& element.toString().equals("class")) {
Node result = new ClassLiteralNode(tree, expr);
extendWithNode((ClassLiteralNode) result);
return result;
} else {
throw new BugInCF("Unexpected element kind: " + element.getKind());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ public R visitPrimitiveType(PrimitiveTypeNode n, P p) {
return visitNode(n, p);
}

@Override
public R visitClassLiteral(ClassLiteralNode n, P p) {
return visitNode(n, p);
}

@Override
public R visitClassName(ClassNameNode n, P p) {
return visitNode(n, p);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.checkerframework.dataflow.cfg.node;

import com.sun.source.tree.MemberSelectTree;
import com.sun.source.tree.Tree;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.javacutil.TreeUtils;

import java.util.Collection;
import java.util.Collections;

/** A node for a class literal. For example: {@code String.class}. */
public class ClassLiteralNode extends Node {
/** The tree for the class literal. */
protected final MemberSelectTree tree;

/** The class name of class literal */
protected final Node className;

/**
* Create a new ClassLiteralNode.
*
* @param tree the class literal
* @param className the class name for the class literal
*/
public ClassLiteralNode(MemberSelectTree tree, Node className) {
super(TreeUtils.typeOf(tree));
this.tree = tree;
this.className = className;
}

@Override
public @Nullable Tree getTree() {
return tree;
}

/**
* Get the class name of the class literal.
*
* @return the class name of the class literal
*/
public Node getClassName() {
return className;
}

@Override
public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {
return visitor.visitClassLiteral(this, p);
}

@Override
public String toString() {
return tree.toString();
}

@Override
public Collection<Node> getOperands() {
return Collections.emptyList();
}
}
Loading
Loading