Skip to content

Commit

Permalink
Update from upstream template
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed May 9, 2024
1 parent 9130b5b commit a1df2ac
Show file tree
Hide file tree
Showing 16 changed files with 309 additions and 171 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gradle
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
25 changes: 25 additions & 0 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Java CI with Gradle

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
java: [ '11', '17', '21' ]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
show-progress: false
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: ./gradlew build javadoc
run: ./gradlew build
16 changes: 16 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Validate Gradle Wrapper"
on: [push, pull_request]

permissions:
contents: read

jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
show-progress: false
- uses: gradle/wrapper-validation-action@v1
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generated files
# Gradle
.gradle
build

# IntelliJ
.idea
*.iml

# Emacs backups
# Emacs
*~

# checker-qual
Expand Down
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ install: true

jdk:
- openjdk8
- openjdk11
- openjdk17

script:
- ./gradlew build --stacktrace

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# What is this repository
# This repository

This repository contains a template for an abstract interpretation implementation
assignment. You can find the full instructions for the assignment in `INSTRUCTIONS.md`
Expand All @@ -7,14 +7,18 @@ in this directory, or on your course webpage.
The remainder of this README is the user-facing documentation for the analysis
you will build.

# What is the Divide By Zero Checker
You should remove, from your version, everything above and including this line.


# The Divide By Zero Checker

A common problem when programming is division by zero.
This results in a run-time exception.

The Divide By Zero Checker should guarantee, at compile time, that your code will
The Divide By Zero Checker guarantees, at compile time, that your code will
not suffer that run-time exception.


## How to run the checker

First, publish the checker to your local Maven repository by running
Expand All @@ -36,6 +40,27 @@ dependencies {
Now, when you build your project, the Divide By Zero Checker will also run,
informing you of any potential errors related to division by zero.


## How to specify your code

At compile time, the Divide By Zero Checker estimates what values the program
may compute at run time. It issues a warning if the program may
perform a division by zero.
It works via a technique called pluggable typechecking.

You need to specify the contracts of methods and fields in your code --
that is, their requirements and their guarantees. The Divide By Zero Checker
ensures that your code is consistent with the contracts, and that the
contracts guarantee that the program never divides by zero.

You specify your code by writing *qualifiers* such as `@YourQualifierNameHere`
on types, to indicate more precisely what values the type represents.
Here is a list of the type qualifiers that are supported by
the Divide By Zero Checker, with an explanation of each one:

TODO.


## How to build the checker

Run these commands from the top-level directory.
Expand Down
141 changes: 80 additions & 61 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,97 +1,116 @@
plugins {
id 'java'
id 'maven-publish'
id 'java'
id 'maven-publish'
}

repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
// Use Maven Central for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
}

configurations {
// for putting Error Prone javac in bootclasspath for running tests
errorproneJavac
// for putting Error Prone javac in bootclasspath for running tests
errorproneJavac
}

ext.versions = [
checkerFramework: "3.21.3",
checkerFramework: "3.43.0",
]


sourceCompatibility = 1.8
def checkerframework_local = false // Set this variable to [true] while using local version of checker framework.

dependencies {
// This dependency is found on compile classpath of this component and consumers.
if (checkerframework_local) {
implementation files('${CHECKERFRAMEWORK}/checker/dist/checker-qual.jar')
implementation files('${CHECKERFRAMEWORK}/checker/dist/checker.jar')
}
else {
implementation "org.checkerframework:checker:${versions.checkerFramework}"
implementation "org.checkerframework:checker-qual:${versions.checkerFramework}"
}
// This dependency is found on compile classpath of this component and consumers.
if (checkerframework_local) {
implementation files('${CHECKERFRAMEWORK}/checker/dist/checker-qual.jar')
implementation files('${CHECKERFRAMEWORK}/checker/dist/checker.jar')
}
else {
implementation "org.checkerframework:checker:${versions.checkerFramework}"
implementation "org.checkerframework:checker-qual:${versions.checkerFramework}"
}

compileOnly "com.google.errorprone:javac:9+181-r4173-1"
compileOnly "com.google.errorprone:javac:9+181-r4173-1"

// Testing
testImplementation 'junit:junit:4.13.2'
testImplementation "org.checkerframework:framework-test:${versions.checkerFramework}"
// Testing
testImplementation 'junit:junit:4.13.2'
testImplementation "org.checkerframework:framework-test:${versions.checkerFramework}"

errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}

tasks.withType(JavaCompile).all {
options.compilerArgs.add("-Xlint:all")
options.compilerArgs.add("-Xlint:all")
}

// Add `mavenLocal()` in `repositories`, then run `./gradlew publishToMavenLocal`
// to publish your checker to your local Maven repository.
publishing {
publications {
maven(MavenPublication) {
groupId = 'org.checkerframework'
artifactId = 'dividebyzero-checker'
version = '0.1-SNAPSHOT'

from components.java
}
publications {
maven(MavenPublication) {
groupId = 'org.checkerframework'
artifactId = 'dividebyzero-checker'
version = '0.1-SNAPSHOT'

from components.java
}
}
}

test {
inputs.files("tests/dividebyzero")
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// A list of add-export and add-open arguments to be used when running the Checker Framework.
// Keep this list in sync with the list in the Checker Framework manual.
var compilerArgsForRunningCF = [
// These are required in Java 16+ because the --illegal-access option is set to deny
// by default. None of these packages are accessed via reflection, so the module
// only needs to be exported, but not opened.
"--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",
// Required because the Checker Framework reflectively accesses private members in com.sun.tools.javac.comp.
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
jvmArgs += compilerArgsForRunningCF
}
testLogging {
showStandardStreams = true
// Show the found unexpected diagnostics and expected diagnostics not found.
exceptionFormat "full"
events "failed"
}
inputs.files("tests/dividebyzero")
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// A list of add-export and add-open arguments to be used when running the Checker Framework.
// Keep this list in sync with the list in the Checker Framework manual.
var compilerArgsForRunningCF = [
// These are required in Java 16+ because the --illegal-access option is set to deny
// by default. None of these packages are accessed via reflection, so the module
// only needs to be exported, but not opened.
"--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",
// Required because the Checker Framework reflectively accesses private members in com.sun.tools.javac.comp.
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
jvmArgs += compilerArgsForRunningCF
}
testLogging {
showStandardStreams = true
// Show the found unexpected diagnostics and expected diagnostics not found.
exceptionFormat "full"
events "failed"
}
}

clean.doFirst {
delete "${rootDir}/tests/build/"
delete "${rootDir}/tests/build/"
}

task printClasspath {
description 'Prints the runtime classpath of the checker. ' +
'When typechecking, put the output of this task on either the ' +
'processor path or the classpath of the project being type-checed.'
doLast {
println sourceSets.main.runtimeClasspath.asPath
}
}

sourceSets {
main {
resources {
// ensures that any .stub files present in the same directory as
// the checker source code are copied into the distributed jar
srcDirs += ['src/main/java']
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
Loading

0 comments on commit a1df2ac

Please sign in to comment.