Skip to content

Commit

Permalink
Update to eisop master 2022-07-03 (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl authored Jul 4, 2022
2 parents a61ae54 + a3c7106 commit 92dbdfb
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
group: [ cfi-tests, downstream-ontology, downstream-security-demo, downstream-universe ]
jdk: [ 8, 11 ]
jdk: [ 8, 11, 17 ]
runs-on: ubuntu-latest
steps:
- name: Install dependencies
Expand Down
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ ext {
isJava8 = JavaVersion.current() == JavaVersion.VERSION_1_8

errorproneJavacVersion = '9+181-r4173-1'

// Keep in sync with checker-framework/build.gradle.
// TODO: find a way to directly use that variable.
compilerArgsForRunningCF = [
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
}

println '===================================='
Expand Down Expand Up @@ -127,6 +141,7 @@ test {
// Without this, the test throw "java.lang.OutOfMemoryError: Java heap space"
// Corresponding pull request: https://github.com/opprop/checker-framework-inference/pull/263
forkEvery(1)
jvmArgs += compilerArgsForRunningCF
}

testLogging {
Expand Down
2 changes: 1 addition & 1 deletion scripts/inference-dev
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ libDir="$cfiDir"/lib
CFBuild="${cfDir}"/dataflow/"${classes}":"${cfDir}"/javacutil/"${classes}":"${cfDir}"/framework/"${classes}":"${cfDir}"/framework/"${resources}"
CFBuild="${CFBuild}":"${cfDir}"/checker/"${classes}":"${cfDir}"/checker/"${resources}":"${annoToolsDir}"/scene-lib/bin

CFDepJars="${stubparserDir}"/javaparser-core/target/stubparser-3.24.0.jar:"${afuDir}"/annotation-file-utilities-all.jar
CFDepJars="${stubparserDir}"/javaparser-core/target/stubparser-3.24.2.jar:"${afuDir}"/annotation-file-utilities-all.jar

# sanity check: ensure each jar in CFDepJars actually exists in the file system
# total number of jars
Expand Down
5 changes: 3 additions & 2 deletions src/checkers/inference/ExistentialVariableInserter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import checkers.inference.model.ConstraintManager;
import checkers.inference.model.ExistentialVariableSlot;
import checkers.inference.model.Slot;
import checkers.inference.util.InferenceUtil;

/**
*
Expand Down Expand Up @@ -113,7 +114,7 @@ public void insert(final Slot potentialVariable, final AnnotatedTypeMirror typeU
typeUse.addAnnotation(slotManager.getAnnotation(potentialVariable));

// now remove only the primary (which has already been propagated to the bounds by fixUpBoundAnnotations)
typeUse.removeAnnotation(potentialVarAnno);
InferenceUtil.removePrimaryTypeVariableAnnotation((AnnotatedTypeVariable) typeUse, potentialVarAnno);


final InsertionVisitor insertionVisitor = new InsertionVisitor(potentialVariable, potentialVarAnno, mustExist);
Expand Down Expand Up @@ -254,7 +255,7 @@ public Void visitNull_Null(AnnotatedNullType type1, AnnotatedNullType type2, Voi
@Override
public Void visitTypevar_Typevar(AnnotatedTypeVariable type1, AnnotatedTypeVariable type2, Void aVoid) {
if (matchesSlot(type1)) {
type1.removeAnnotation(potentialVarAnno);
InferenceUtil.removePrimaryTypeVariableAnnotation(type1, potentialVarAnno);
}

return super.visitTypevar_Typevar(type1, type2, aVoid);
Expand Down
1 change: 1 addition & 0 deletions src/checkers/inference/InferenceAnnotatedTypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public ParameterizedExecutableType constructorFromUse(final NewClassTree newClas
"Current path:\n" + getVisitorTreePath();

final ExecutableElement constructorElem = TreeUtils.constructor(newClassTree);;
@SuppressWarnings("deprecation") // TODO
final AnnotatedTypeMirror constructorReturnType = fromNewClass(newClassTree);
addComputedTypeAnnotations(newClassTree, constructorReturnType);

Expand Down
14 changes: 14 additions & 0 deletions src/checkers/inference/InferenceLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import org.checkerframework.framework.util.CheckerMain;
import org.checkerframework.framework.util.ExecUtil;
import org.checkerframework.javacutil.SystemUtil;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -165,6 +166,19 @@ public void infer() {
argList.add("-Xbootclasspath/p:" + bcp);
}

if (SystemUtil.getJreVersion() > 8) {
// Keep in sync with build.gradle
argList.addAll(Arrays.asList("--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED"));
}

argList.add("-classpath");
argList.add(getInferenceRuntimeClassPath());

Expand Down
25 changes: 0 additions & 25 deletions src/checkers/inference/dataflow/InferenceTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.checkerframework.dataflow.cfg.node.FieldAccessNode;
import org.checkerframework.dataflow.cfg.node.LocalVariableNode;
import org.checkerframework.dataflow.cfg.node.Node;
import org.checkerframework.dataflow.cfg.node.StringConcatenateAssignmentNode;
import org.checkerframework.dataflow.cfg.node.TernaryExpressionNode;
import org.checkerframework.framework.flow.CFStore;
import org.checkerframework.framework.flow.CFTransfer;
Expand Down Expand Up @@ -176,30 +175,6 @@ public TransferResult<CFValue, CFStore> visitAssignment(AssignmentNode assignmen
}
}

@Override
public TransferResult<CFValue, CFStore> visitStringConcatenateAssignment(StringConcatenateAssignmentNode assignmentNode, TransferInput<CFValue, CFStore> transferInput) {
// TODO: CompoundAssigment trees are not refined, see Issue 9
CFStore store = transferInput.getRegularStore();

Tree targetTree = assignmentNode.getLeftOperand().getTree();

// Code for geting the ATM is copied from visitCompoundAssigment.
AnnotatedTypeMirror atm;
if (targetTree != null) {
// Try to use the target tree if possible.
// Getting the Type of a tree for a desugared compound assignment returns a comb variable
// which is not what we want to make a refinement variable of.
atm = typeFactory.getAnnotatedType(targetTree);
} else {
// Target trees can be null for refining library fields.
atm = typeFactory.getAnnotatedType(assignmentNode.getTree());
}

CFValue result = analysis.createAbstractValue(atm);
return new RegularTransferResult<CFValue, CFStore>(finishValue(result, store), store);

}

/**
* Create a refinement variable for atm type. This inserts the refinement variable
* into the store as the value for the lhs cfg node.
Expand Down
18 changes: 18 additions & 0 deletions src/checkers/inference/util/InferenceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ public static Set<AnnotationMirror> clearAnnos(final AnnotatedTypeMirror atm) {
return oldAnnos;
}

/**
* TODO: This method is similar to the code in https://github.com/eisop/checker-framework
* /blob/6f12277290642f8fb89a5c614b31fe419eb0a7b1/framework/src/main/java/
* org/checkerframework/framework/type/DefaultInferredTypesApplier.java#L134,
* it should be cleaned up when the code of this link is improved.
*/
public static void removePrimaryTypeVariableAnnotation(AnnotatedTypeVariable atv, AnnotationMirror potentialVarAnno) {
AnnotationMirror ub = atv.getUpperBound().getAnnotationInHierarchy(potentialVarAnno);
AnnotationMirror lb = atv.getLowerBound().getAnnotationInHierarchy(potentialVarAnno);
atv.removeAnnotation(potentialVarAnno);
if (ub != null) {
atv.getUpperBound().addAnnotation(ub);
}
if (lb != null) {
atv.getLowerBound().addAnnotation(lb);
}
}

/**
* If the given condition isn't true throw an illegal argument exception with the given message
*/
Expand Down
6 changes: 3 additions & 3 deletions src/nninf/MapGetHeuristics.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType;
import org.checkerframework.javacutil.AnnotationUtils;
import org.checkerframework.javacutil.ElementUtils;
import org.checkerframework.javacutil.Resolver;
import org.checkerframework.javacutil.TreeUtils;

import java.util.List;
Expand Down Expand Up @@ -65,7 +66,6 @@
private final ProcessingEnvironment env;
private final NninfAnnotatedTypeFactory factory;
private final AnnotatedTypeFactory keyForFactory;
private final Resolver2 resolver;

private final ExecutableElement mapGet;

Expand All @@ -75,7 +75,6 @@ public MapGetHeuristics(ProcessingEnvironment env,
this.env = env;
this.factory = factory;
this.keyForFactory = keyForFactory;
this.resolver = new Resolver2(env);

mapGet = TreeUtils.getMethod("java.util.Map", "get", 1, env);
}
Expand Down Expand Up @@ -139,7 +138,8 @@ private boolean keyForInMap(ExpressionTree key,

List<String> maps = AnnotationUtils.getElementValueArray(anno, factory.keyForValueElement, String.class);
for (String map: maps) {
Element elt = resolver.findVariable(map, path);
// TODO: this whole class should be re-implemented
Element elt = null; // resolver.findVariable(map, path);
if (elt != null &&
elt.equals(mapElement) &&
!isSiteRequired(TreeUtils.getReceiverTree((ExpressionTree)path.getLeaf()), elt)) {
Expand Down
163 changes: 0 additions & 163 deletions src/nninf/Resolver2.java

This file was deleted.

0 comments on commit 92dbdfb

Please sign in to comment.