Skip to content

Commit 1e749e0

Browse files
committed
Experimental support for loading JIMAGE (JDK 9+) files
This bumps the `crucible` submodule to include GaloisInc/crucible#638, which adds basic support for handling JDK 9 or later. JDK 9+ packages its standard library not in a JAR file, but in a JIMAGE file. For more details on how `crucible-jvm` handles JIMAGE files, refer to `Note [Loading classes from JIMAGE files]` in `Lang.JVM.Codebase`. This fixes #861, although there are still unsolved issues that arise when using modern JDKs with certain classes, such as `String`. As a result, I have decided to label support for JDK 9+ as experimental: * I have updated the SAW documentation to mention these shortcomings. * I have opened GaloisInc/crucible#641 to track the remaining issues. Other things: * GaloisInc/crucible#636 and GaloisInc/crucible#638 upstreamed the code from `SAWScript.JavaTools` and `SAWScript.ProcessUtils` into `crucible-jvm`, so we can remove these modules in favor of importing `Lang.JVM.JavaTools` and `Lang.JVM.ProcessUtils` from `crucible-jvm`. * 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 856f4e0 commit 1e749e0

File tree

12 files changed

+27
-122
lines changed

12 files changed

+27
-122
lines changed

CHANGES.md

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

33
## New Features
44

5+
SAW now includes experimental support for verifying Java code using JDK 9 or
6+
later. Verifying Java code that only uses primitive data types is known to work
7+
well, but code that imports certain classes (e.g., `String`) is known to suffer
8+
from issues documented
9+
[here](https://github.com/GaloisInc/crucible/issues/641).
10+
511
When verifying Java code, the path to Java can be specified with the new
612
`--java-bin-dirs`/`-b` command-line option. Alternatively, if
713
`--java-bin-dirs` is not set, then SAW searches the `PATH` to find Java.

deps/crucible

Submodule crucible updated 49 files

doc/manual/manual.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1575,9 +1575,11 @@ The resulting `JavaClass` can be passed into the various functions
15751575
described below to perform analysis of specific Java methods.
15761576

15771577
Java class files from any JDK newer than version 6 should work. However,
1578-
JDK version 9 and newer do not contain a JAR file containing the
1579-
standard libraries, and therefore do not currently work with SAW. We are
1580-
investigating the best way to resolve this issue.
1578+
support for JDK 9 and later is experimental. Verifying code that only uses
1579+
primitive data types is known to work well, but there are some as-of-yet
1580+
unresolved issues in verifying code involving classes such as `String`. For
1581+
more information on these issues, refer to
1582+
[this GitHub issue](https://github.com/GaloisInc/crucible/issues/641).
15811583

15821584
## Notes on Compiling Code for SAW
15831585

doc/tutorial/tutorial.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ Alternatively, if Java is located on your `PATH`, you can omit the `-b`
237237
option entirely.
238238

239239
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.
240+
SAW also includes experimental support for JDK 9 and later. Code that only
241+
involves primitive data types (such as `FFS.java` above) is known to work well
242+
under JDK 9+, but there are some as-of-yet unresolved issues in verifying code
243+
involving classes such as `String`. For more information on these issues, refer
244+
to [this GitHub issue](https://github.com/GaloisInc/crucible/issues/641).
243245

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

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)