Skip to content

Commit 30c9bb9

Browse files
committed
WIP: Support JDK 9 or later
This allows SAW to deal with JDK 9 or later, which packages its standard library not in a JAR file, but in a JIMAGE file. This leverages `crucible-jvm` changes from GaloisInc/crucible#634. This fixes #861. Other things: * I removed the dependency on the `xdg-basedir`, as it was unused. This dependency was likely added quite some time ago, and it appears that `saw-script` switched over to using XDG-related functionality from the `directory` library since then. I opted to use `directory` to find the `.cache` directory as well, so I have made that clear in the `.cabal` file. * The `biJavaCodebase :: Codebase` field of `BuiltinContext` is completely unused, which I noticed when making changes to the `Codebase` type. Let's just remove it.
1 parent f8449a1 commit 30c9bb9

File tree

15 files changed

+24
-128
lines changed

15 files changed

+24
-128
lines changed

.github/ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ bundle_files() {
199199
find_java() {
200200
pushd .github
201201
javac PropertiesTest.java
202-
RT_JAR="$(java PropertiesTest | tr : '\n' | grep rt.jar | head -n 1)"
202+
RT_JAR="$(java PropertiesTest | tr : '\n' | grep rt.jar | head -n 1 || true)"
203203
export RT_JAR
204204
echo "RT_JAR=$RT_JAR" >> "$GITHUB_ENV"
205205
rm PropertiesTest.class

.github/workflows/build.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
matrix:
3939
os: [ubuntu-18.04]
4040
ghc: ["8.6.5", "8.8.4", "8.10.2"]
41+
jdk: ["8", "15"]
4142
continue-on-error: [false]
4243
include:
4344
- os: macos-latest
@@ -52,7 +53,7 @@ jobs:
5253
exclude:
5354
- os: windows-latest
5455
ghc: "8.8.4"
55-
name: SAWScript - GHC v${{ matrix.ghc }} - ${{ matrix.os }}
56+
name: SAWScript - GHC v${{ matrix.ghc }} - JDK ${{ matrix.jdk }} - ${{ matrix.os }}
5657
env:
5758
RELEASE: ${{ needs.outputs.outputs.release }}
5859
continue-on-error: ${{ matrix.continue-on-error }}
@@ -111,7 +112,7 @@ jobs:
111112

112113
- uses: actions/setup-java@v1
113114
with:
114-
java-version: "8"
115+
java-version: ${{ matrix.jdk }}
115116
java-package: jdk
116117
architecture: x64
117118

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## New Features
44

5+
SAW now supports verifying Java code using JDK 9 or later.
6+
57
When verifying Java code, the path to Java can be specified with the new
68
`--java-bin-dirs`/`-b` command-line option. Alternatively, if
79
`--java-bin-dirs` is not set, then SAW searches the `PATH` to find Java.

deps/crucible

Submodule crucible updated 48 files

doc/manual/manual.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1568,10 +1568,7 @@ the `java_load_class` function.
15681568
The resulting `JavaClass` can be passed into the various functions
15691569
described below to perform analysis of specific Java methods.
15701570

1571-
Java class files from any JDK newer than version 6 should work. However,
1572-
JDK version 9 and newer do not contain a JAR file containing the
1573-
standard libraries, and therefore do not currently work with SAW. We are
1574-
investigating the best way to resolve this issue.
1571+
Java class files from any JDK newer than version 6 should work.
15751572

15761573
## Notes on Compiling Code for SAW
15771574

doc/tutorial/tutorial.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,7 @@ locates Java. Run the code in this section with the command:
236236
Alternatively, if Java is located on your `PATH`, you can omit the `-b`
237237
option entirely.
238238

239-
Both Oracle JDK and OpenJDK versions 6 through 8 work well with SAW.
240-
From version 9 onward, the core libraries are no longer stored in a
241-
standard JAR file, making them inacessible to SAW. We're currently
242-
considering strategies for working with newer Java versions.
239+
Both Oracle JDK and OpenJDK versions 6 and later work well with SAW.
243240

244241
Now we can do the proof both within and across languages (from
245242
`ffs_compare.saw`):

intTests/runtests.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ for i in "$TESTBASE"/jars/*.jar; do
4646
if [ "$OS" == "Windows_NT" ]; then
4747
i=$(cygpath -w "$i")
4848
fi
49-
CP=$CP$CPSEP$i
49+
if [ -z "$CP" ]; then
50+
CP=$i
51+
else
52+
CP=$CP$CPSEP$i
53+
fi
5054
done
5155
export CP
5256

saw-remote-api/src/SAWServer.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ initialState readFileFn =
165165
ss <- basic_ss sc
166166
let jarFiles = []
167167
classPaths = []
168-
jcb <- JSS.loadCodebase jarFiles classPaths
168+
javaBinDirs = []
169+
jcb <- JSS.loadCodebase jarFiles classPaths javaBinDirs
169170
let bic = BuiltinContext { biSharedContext = sc
170-
, biJavaCodebase = jcb
171171
, biBasicSS = ss
172172
}
173173
cenv <- initCryptolEnv sc

saw-script.cabal

-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ library
8585
, utf8-string
8686
, what4 >= 0.4
8787
, vector
88-
, xdg-basedir
8988
, GraphSCC
9089
, macaw-base
9190
, macaw-x86
@@ -115,15 +114,13 @@ library
115114
SAWScript.ImportAIG
116115
SAWScript.Interpreter
117116
SAWScript.JavaExpr
118-
SAWScript.JavaTools
119117
SAWScript.JavaPretty
120118
SAWScript.Lexer
121119
SAWScript.LLVMBuiltins
122120
SAWScript.Options
123121
SAWScript.Panic
124122
SAWScript.Parser
125123
SAWScript.PathVC
126-
SAWScript.ProcessUtils
127124
SAWScript.Proof
128125
SAWScript.Position
129126
SAWScript.SBVParser

src/SAWScript/Builtins.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ import Verifier.SAW.TypedAST
7777

7878
import SAWScript.Position
7979

80+
-- crucible-jvm
81+
import Lang.JVM.ProcessUtils
82+
8083
-- cryptol-saw-core
8184
import qualified Verifier.SAW.CryptolEnv as CEnv
8285

@@ -118,7 +121,6 @@ import SAWScript.ImportAIG
118121

119122
import SAWScript.AST (getVal, pShow, Located(..))
120123
import SAWScript.Options as Opts
121-
import SAWScript.ProcessUtils
122124
import SAWScript.Proof
123125
import SAWScript.TopLevel
124126
import qualified SAWScript.Value as SV

src/SAWScript/Interpreter.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ buildTopLevelEnv proxy opts =
418418
simps <- scSimpset sc0 cryptolDefs [] convs
419419
let sc = rewritingSharedContext sc0 simps
420420
ss <- basic_ss sc
421-
jcb <- JCB.loadCodebase (jarList opts) (classPath opts)
421+
jcb <- JCB.loadCodebase (jarList opts) (classPath opts) (javaBinDirs opts)
422422
currDir <- getCurrentDirectory
423423
Crucible.withHandleAllocator $ \halloc -> do
424424
let ro0 = TopLevelRO
@@ -433,7 +433,6 @@ buildTopLevelEnv proxy opts =
433433
}
434434
let bic = BuiltinContext {
435435
biSharedContext = sc
436-
, biJavaCodebase = jcb
437436
, biBasicSS = ss
438437
}
439438
primsAvail = Set.fromList [Current]

src/SAWScript/JavaTools.hs

-74
This file was deleted.

src/SAWScript/Options.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import System.IO
2121
import Text.Read (readMaybe)
2222
import Text.Show.Functions ()
2323

24-
import SAWScript.JavaTools
24+
import Lang.JVM.JavaTools
2525

2626
-- TODO: wouldn't it be better to extract the options-processing code from this file and put it in saw/Main.hs (which already does part of the options processing)? It seems that other parts of SAW only need the datatype definition below, and not the rest.
2727
data Options = Options
@@ -207,8 +207,9 @@ processEnv opts = do
207207
-- --java-bin-dirs or PATH, see the Haddocks for findJavaIn), then use that
208208
-- to detect the path to Java's standard rt.jar file and add it to the
209209
-- jarList on Java 8 or earlier. (Later versions of Java do not use
210-
-- rt.jar—see #861.) If Java's path is not specified, return the Options
211-
-- unchanged.
210+
-- rt.jar—see Note [Loading classes from JIMAGE files] in
211+
-- Lang.JVM.Codebase in crucible-jvm.)
212+
-- If Java's path is not specified, return the Options unchanged.
212213
addJavaBinDirInducedOpts :: Options -> IO Options
213214
addJavaBinDirInducedOpts os@Options{javaBinDirs} = do
214215
mbJavaPath <- findJavaIn javaBinDirs

src/SAWScript/ProcessUtils.hs

-29
This file was deleted.

src/SAWScript/Value.hs

-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ data SAW_CFG where
164164
JVM_CFG :: Crucible.AnyCFG JVM -> SAW_CFG
165165

166166
data BuiltinContext = BuiltinContext { biSharedContext :: SharedContext
167-
, biJavaCodebase :: JSS.Codebase
168167
, biBasicSS :: Simpset
169168
}
170169
deriving Generic

0 commit comments

Comments
 (0)