From bcfe003f41a5c19638f86d9a6e566f88418e31a4 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Fri, 5 Feb 2021 16:37:20 -0500 Subject: [PATCH] Remove find-java-rt-jar.sh, document how -b interacts with older JDKs * Remove the use of the `find-java-rt-jar.sh` script in CI, as this is no longer necessary with the advent of `--java-bin-dirs`/searching the `PATH` for Java. This fixes #1061. * Now that `find-java-rt-jar.sh` is gone, there is no longer any need for the `.github/PropertiesTest.java` utility, nor is there any need for the `find_java` bash function that leverages this. This patch remove both of them as well. * On a related note, it turns out that SAW's approach to detecting where `rt.jar` lives likely doesn't work on pre-7 JDKs on macOS. Given how ancient these versions of Java anymore, let's just document this infelicity in the manual and describe a workaround for those brave enough to try this. Fixes #1062. --- .github/PropertiesTest.java | 7 ------- .github/ci.sh | 11 ----------- doc/manual/manual.md | 10 ++++++++-- intTests/runtests.sh | 12 ++++++------ intTests/support/find-java-rt-jar.sh | 17 ----------------- 5 files changed, 14 insertions(+), 43 deletions(-) delete mode 100644 .github/PropertiesTest.java delete mode 100755 intTests/support/find-java-rt-jar.sh diff --git a/.github/PropertiesTest.java b/.github/PropertiesTest.java deleted file mode 100644 index 0d770eca8c..0000000000 --- a/.github/PropertiesTest.java +++ /dev/null @@ -1,7 +0,0 @@ -public class PropertiesTest { - public static void main(String[] args) - throws Exception { - String value = System.getProperty("sun.boot.class.path"); - System.out.println(value); - } -} diff --git a/.github/ci.sh b/.github/ci.sh index cf547e7d6f..b8389a0574 100755 --- a/.github/ci.sh +++ b/.github/ci.sh @@ -164,7 +164,6 @@ install_system_deps() { } test_dist() { - find_java pushd intTests for t in test0019_jss_switch_statement test_crucible_jvm test_ecdsa test_issue108 test_tutorial1 test_tutorial2 test_tutorial_w4; do echo $t >> disabled_tests.txt; done env @@ -196,16 +195,6 @@ bundle_files() { cp -r examples/* dist/examples } -find_java() { - pushd .github - javac PropertiesTest.java - RT_JAR="$(java PropertiesTest | tr : '\n' | grep rt.jar | head -n 1)" - export RT_JAR - echo "RT_JAR=$RT_JAR" >> "$GITHUB_ENV" - rm PropertiesTest.class - popd -} - sign() { gpg --batch --import <(echo "$SIGNING_KEY") fingerprint="$(gpg --list-keys | grep galois -a1 | head -n1 | awk '{$1=$1};1')" diff --git a/doc/manual/manual.md b/doc/manual/manual.md index b03030771d..84740cb0a5 100644 --- a/doc/manual/manual.md +++ b/doc/manual/manual.md @@ -1557,8 +1557,14 @@ control where to look for classes: files found in that directory (and its subdirectories) to the class database. By default, the current directory is included in the class path. -Most Java programs will only require setting the `-b` flag, as that is enough -to bring in the standard Java libraries. +Most Java programs will only require setting the `-b` flag (or the `PATH`), as +that is enough to bring in the standard Java libraries. Note that when +searching the `PATH`, SAW makes assumptions about where the standard library +classes live. These assumptions are likely to hold on JDK 7 or later, but they +may not hold on older JDKs on certain operating systems. If you are using an +old version of the JDK and SAW is unable to find a standard Java class, you may +need to specify the location of the standard classes' JAR file with the `-j` +flag (or, alternatively, with the `SAW_JDK_JAR` environment variable). Once the class path is configured, you can pass the name of a class to the `java_load_class` function. diff --git a/intTests/runtests.sh b/intTests/runtests.sh index fc06f239c0..63e3df8ccf 100755 --- a/intTests/runtests.sh +++ b/intTests/runtests.sh @@ -36,17 +36,17 @@ fi # Build the class path. On Windows, Java requires Windows-style paths # here, even in Cygwin. -# -# Locate rt.jar. This is already a Windows path on windows, so no need -# to 'cygpath' it. -JDK=$(support/find-java-rt-jar.sh) -CP="$JDK" +CP="" # Add our bundled .jars to the class path. for i in "$TESTBASE"/jars/*.jar; do if [ "$OS" == "Windows_NT" ]; then i=$(cygpath -w "$i") fi - CP=$CP$CPSEP$i + if [ -z "$CP" ]; then + CP=$i + else + CP=$CP$CPSEP$i + fi done export CP diff --git a/intTests/support/find-java-rt-jar.sh b/intTests/support/find-java-rt-jar.sh deleted file mode 100755 index 19a89d66a6..0000000000 --- a/intTests/support/find-java-rt-jar.sh +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/bash - -# Find the Java core classes JAR, 'rt.jar' (called 'classes.jar' on OS -# X for JDKs prior to 1.7). - -if [ -z "$RT_JAR" ]; then - JDK=$(java -verbose 2>&1 | sed -n -e '1 s/\[Opened \(.*\)\]/\1/p') -else - JDK="$RT_JAR" -fi -if [ -z "$JDK" ]; then - echo "Failed to locate Java core classes (rt.jar / classes.jar)!" >&2 - echo "The trick used by this script is only known to work with" >&2 - echo "Sun-based JDKs." >&2 - exit 1 -fi -echo -n $JDK