Skip to content

Commit 78931d9

Browse files
committed
start java
1 parent 03f1b08 commit 78931d9

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

README.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20936,6 +20936,8 @@ Maybe some day someone will use this setup to study the performance of interpret
2093620936

2093720937
==== Python
2093820938

20939+
link:rootfs_overlay/lkmc/python[]
20940+
2093920941
Examples:
2094020942

2094120943
* link:rootfs_overlay/lkmc/python/hello.py[]: hello world
@@ -21095,6 +21097,8 @@ pybind11 is amazingly easy to use. But it can also make your builds really slow:
2109521097

2109621098
==== Node.js
2109721099

21100+
link:rootfs_overlay/lkmc/nodejs[]
21101+
2109821102
Host installation shown at: https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612
2109921103

2110021104
Build and install the interpreter in Buildroot with:
@@ -21161,6 +21165,8 @@ https://stackoverflow.com/questions/31642477/how-to-publish-a-npm-package-with-d
2116121165

2116221166
==== Java
2116321167

21168+
link:rootfs_overlay/lkmc/java[]
21169+
2116421170
No OpenJDK package as of 2018.08: https://stackoverflow.com/questions/28874150/buildroot-with-jamvm-2-0-for-java-8/59290927#59290927 partly because their build system is shit like the rest of the project's setup.
2116521171

2116621172
Unmerged patch at: http://lists.busybox.net/pipermail/buildroot/2018-February/213282.html
@@ -25639,6 +25645,8 @@ TODO create a minimal working aarch64 example analogous to the x86 one at: https
2563925645

2564025646
A general introduction to paging with x86 examples can be found at: https://cirosantilli.com/x86-paging[].
2564125647

25648+
Then, this article is amazing: https://www.starlab.io/blog/deep-dive-mmu-virtualization-with-xen-on-arm
25649+
2564225650
ARM paging is documented at <<armarm8-db>> Chapter D5 and is mostly called VMSAv8 in the ARMv8 manual (Virtual Memory System Architecture).
2564325651

2564425652
Paging is enabled by the `SCTLR_EL1.M` bit.

java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootfs_overlay/lkmc/java
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
# LinkedHashMap
3+
4+
http://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashMap.html
5+
6+
Hash map that is iterable in insertion order.
7+
8+
Application LRU cache:
9+
10+
- https://github.com/haoel/leetcode/pull/90/files
11+
- http://stackoverflow.com/questions/23772102/lru-cache-in-java-with-generics-and-o1-operations
12+
13+
This is a sub-case of a binary heap: it is efficient
14+
when every item update makes it either the most recent, or oldest.
15+
For more general binary heap, the new item can go anywhere.
16+
17+
# removeEldestEntry
18+
19+
Example:
20+
https://github.com/cirosantilli/haoel-leetcode/commit/ff04930b2dc31f270854e40b560723577c7b49fd
21+
22+
Only acts on `put`, `get` does not update values for us.
23+
*/
24+
25+
import java.util.LinkedList;
26+
import java.util.LinkedHashMap;
27+
import java.util.Iterator;
28+
29+
public class LinkedHashMapCheat {
30+
public static void main(String[] args) {
31+
LinkedList<Integer> output;
32+
LinkedList<Integer> expected;
33+
Iterator<Integer> it;
34+
35+
LinkedHashMap<Integer,Integer> m = new LinkedHashMap<>();
36+
assert m.put(2, -2) == null;
37+
assert m.put(1, -1) == null;
38+
assert m.put(3, -3) == null;
39+
output = new LinkedList<>();
40+
expected = new LinkedList<>();
41+
expected.add(2);
42+
expected.add(1);
43+
expected.add(3);
44+
for (int i : m.keySet())
45+
output.add(i);
46+
assert output.equals(expected);
47+
48+
it = m.keySet().iterator();
49+
it.next();
50+
it.remove();
51+
output = new LinkedList<>();
52+
expected = new LinkedList<>();
53+
expected.add(1);
54+
expected.add(3);
55+
for (int i : m.keySet())
56+
output.add(i);
57+
assert output.equals(expected);
58+
}
59+
}

rootfs_overlay/lkmc/java/Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
IN_EXT ?= .java
2+
OUT_EXT ?= .class
3+
RUN ?= Main
4+
TEST ?= test
5+
6+
OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT))))
7+
8+
-include Makefile_params
9+
10+
.PHONY: all clean run
11+
12+
all:
13+
javac *.java
14+
15+
clean:
16+
rm -f *$(OUT_EXT)
17+
18+
run: all
19+
java -ea $(RUN)
20+
21+
test: all
22+
@\
23+
if [ -x $(TEST) ]; then \
24+
./$(TEST) '$(OUTS)' ;\
25+
else\
26+
fail=false ;\
27+
for t in $(basename $(OUTS)); do\
28+
if ! java -ea "$$t"; then \
29+
fail=true ;\
30+
break ;\
31+
fi ;\
32+
done ;\
33+
if $$fail; then \
34+
echo "TEST FAILED: $$t" ;\
35+
exit 1 ;\
36+
else \
37+
echo 'ALL TESTS PASSED' ;\
38+
exit 0 ;\
39+
fi ;\
40+
fi ;\

0 commit comments

Comments
 (0)