Skip to content

Commit ce8a947

Browse files
committed
Add experimental JShell support & amd64 Linux JDK
1 parent 4aa25e9 commit ce8a947

File tree

4 files changed

+79
-3
lines changed

4 files changed

+79
-3
lines changed

build/Dockerfile.scripts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ FROM ev3dev-lang-java:jdk9-system
22

33
# copy build patches & scripts
44
COPY *.patch *.sh /opt/jdkcross/
5-
RUN chmod +x /opt/jdkcross/*.sh
5+
RUN chmod +x /opt/jdkcross/*.sh && mkdir /opt/jdkcross/jshellhack
6+
COPY DumpPort.java /opt/jdkcross/jshellhack/
67

78
# this directory should be mounted
89
VOLUME /build

build/DumpPort.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package jshellhack;
2+
3+
import java.nio.file.*;
4+
import java.lang.*;
5+
6+
import static java.nio.file.StandardOpenOption.CREATE;
7+
import static java.nio.file.StandardOpenOption.WRITE;
8+
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
9+
10+
public class DumpPort {
11+
12+
public static void main(String[] args) throws Exception {
13+
StringBuilder build = new StringBuilder();
14+
build.append(args[0]);
15+
build.append("\n");
16+
OpenOption[] opts = new OpenOption[] { CREATE, WRITE, TRUNCATE_EXISTING };
17+
Files.write(Paths.get("/tmp/jshellargs"), build.toString().getBytes(), opts);
18+
}
19+
}

build/jshell-launch.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
ARG_FIFO="/tmp/jshellargs"
4+
EV3_PORT="8000"
5+
JAR_PATH="./jshellhack.jar"
6+
TIMEOUT="20000"
7+
8+
if [ "$#" -lt 1 ]; then
9+
echo "Please provide SSH args." >&2
10+
exit 1
11+
fi
12+
13+
# cd to bin directory
14+
cd "$( dirname "${BASH_SOURCE[0]}" )"
15+
16+
# (re)create fifo
17+
rm "$ARG_FIFO"
18+
mkfifo "$ARG_FIFO"
19+
20+
if [ "$?" -ne 0 ]; then
21+
echo "Creation of argument pipe failed." >&2
22+
exit 2
23+
fi
24+
25+
# background ssh & agent
26+
ssh -R "$EV3_PORT:localhost:$(cat ${ARG_FIFO})" "$@" "java" "jdk.jshell.execution.RemoteExecutionControl" "$EV3_PORT" &
27+
28+
# foreground jshell
29+
CLASSPATH="$JAR_PATH" ./jshell --execution "jdi:hostname(localhost),launch(false),remoteAgent(jshellhack.DumpPort),timeout($TIMEOUT)"
30+
31+
exit "$?"

build/zip.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,48 @@ set -e
55
# enter images directory
66
pushd /build/jdk9u/build/linux-arm-normal-client-release/images
77

8-
rm -rf jre-ev3
9-
rm jdk-ev3
8+
# clean destinations
9+
rm -rf ./jre-ev3
10+
rm -rf ./jdk-pc
11+
rm -rf ./jshell-support
12+
rm ./jdk-ev3
1013

1114
# build ev3 runtime image
1215
/opt/jdkcross/jdk-9.0.1/bin/jlink \
1316
--module-path ./jmods/ \
1417
--endian little \
1518
--compress 0 \
1619
--strip-debug \
20+
--no-header-files \
21+
--no-man-pages \
1722
--add-modules java.se,jdk.jdwp.agent,jdk.jshell \
1823
--output ./jre-ev3
1924

25+
# build microjdk
26+
/opt/jdkcross/jdk-9.0.1/bin/jlink \
27+
--module-path /opt/jdkcross/jdk-9.0.1/jmods \
28+
--compress 2 \
29+
--strip-debug \
30+
--no-header-files \
31+
--no-man-pages \
32+
--add-modules java.se,jdk.attach,jdk.jdwp.agent,jdk.jlink,jdk.jartool,jdk.compiler,jdk.jdi,jdk.jshell \
33+
--output ./jdk-pc
34+
35+
cp -r ./jmods ./jdk-pc/jmods-ev3
36+
2037
# rename jdk directory
2138
ln -s ./jdk ./jdk-ev3
2239

40+
# JShell hack
41+
mkdir jshell-support
42+
/opt/jdkcross/jdk-9.0.1/bin/javac -d ./jshell-support /opt/jdkcross/jshellhack/DumpPort.java
43+
/opt/jdkcross/jdk-9.0.1/bin/jar cf ./jshellhack.jar -C ./jshell-support jshellhack/DumpPort.class
44+
cp ./jshellhack.jar ./jdk-pc/bin
45+
cp /opt/jdkcross/jshell-launch.sh ./jdk-pc/bin
46+
2347
# create zip files
2448
zip -9r /build/jdk-ev3.zip jdk-ev3
2549
zip -9r /build/jre-ev3.zip jre-ev3
50+
zip -9r /build/jdk-pc.zip jdk-pc
2651

2752
popd

0 commit comments

Comments
 (0)