mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2025-08-15 22:36:35 +00:00
start java
This commit is contained in:
@ -20936,6 +20936,8 @@ Maybe some day someone will use this setup to study the performance of interpret
|
||||
|
||||
==== Python
|
||||
|
||||
link:rootfs_overlay/lkmc/python[]
|
||||
|
||||
Examples:
|
||||
|
||||
* 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:
|
||||
|
||||
==== Node.js
|
||||
|
||||
link:rootfs_overlay/lkmc/nodejs[]
|
||||
|
||||
Host installation shown at: https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612
|
||||
|
||||
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
|
||||
|
||||
==== Java
|
||||
|
||||
link:rootfs_overlay/lkmc/java[]
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
A general introduction to paging with x86 examples can be found at: https://cirosantilli.com/x86-paging[].
|
||||
|
||||
Then, this article is amazing: https://www.starlab.io/blog/deep-dive-mmu-virtualization-with-xen-on-arm
|
||||
|
||||
ARM paging is documented at <<armarm8-db>> Chapter D5 and is mostly called VMSAv8 in the ARMv8 manual (Virtual Memory System Architecture).
|
||||
|
||||
Paging is enabled by the `SCTLR_EL1.M` bit.
|
||||
|
59
rootfs_overlay/lkmc/java/LinkedHashMapCheat.java
Normal file
59
rootfs_overlay/lkmc/java/LinkedHashMapCheat.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
# LinkedHashMap
|
||||
|
||||
http://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashMap.html
|
||||
|
||||
Hash map that is iterable in insertion order.
|
||||
|
||||
Application LRU cache:
|
||||
|
||||
- https://github.com/haoel/leetcode/pull/90/files
|
||||
- http://stackoverflow.com/questions/23772102/lru-cache-in-java-with-generics-and-o1-operations
|
||||
|
||||
This is a sub-case of a binary heap: it is efficient
|
||||
when every item update makes it either the most recent, or oldest.
|
||||
For more general binary heap, the new item can go anywhere.
|
||||
|
||||
# removeEldestEntry
|
||||
|
||||
Example:
|
||||
https://github.com/cirosantilli/haoel-leetcode/commit/ff04930b2dc31f270854e40b560723577c7b49fd
|
||||
|
||||
Only acts on `put`, `get` does not update values for us.
|
||||
*/
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class LinkedHashMapCheat {
|
||||
public static void main(String[] args) {
|
||||
LinkedList<Integer> output;
|
||||
LinkedList<Integer> expected;
|
||||
Iterator<Integer> it;
|
||||
|
||||
LinkedHashMap<Integer,Integer> m = new LinkedHashMap<>();
|
||||
assert m.put(2, -2) == null;
|
||||
assert m.put(1, -1) == null;
|
||||
assert m.put(3, -3) == null;
|
||||
output = new LinkedList<>();
|
||||
expected = new LinkedList<>();
|
||||
expected.add(2);
|
||||
expected.add(1);
|
||||
expected.add(3);
|
||||
for (int i : m.keySet())
|
||||
output.add(i);
|
||||
assert output.equals(expected);
|
||||
|
||||
it = m.keySet().iterator();
|
||||
it.next();
|
||||
it.remove();
|
||||
output = new LinkedList<>();
|
||||
expected = new LinkedList<>();
|
||||
expected.add(1);
|
||||
expected.add(3);
|
||||
for (int i : m.keySet())
|
||||
output.add(i);
|
||||
assert output.equals(expected);
|
||||
}
|
||||
}
|
40
rootfs_overlay/lkmc/java/Makefile
Normal file
40
rootfs_overlay/lkmc/java/Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
IN_EXT ?= .java
|
||||
OUT_EXT ?= .class
|
||||
RUN ?= Main
|
||||
TEST ?= test
|
||||
|
||||
OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT))))
|
||||
|
||||
-include Makefile_params
|
||||
|
||||
.PHONY: all clean run
|
||||
|
||||
all:
|
||||
javac *.java
|
||||
|
||||
clean:
|
||||
rm -f *$(OUT_EXT)
|
||||
|
||||
run: all
|
||||
java -ea $(RUN)
|
||||
|
||||
test: all
|
||||
@\
|
||||
if [ -x $(TEST) ]; then \
|
||||
./$(TEST) '$(OUTS)' ;\
|
||||
else\
|
||||
fail=false ;\
|
||||
for t in $(basename $(OUTS)); do\
|
||||
if ! java -ea "$$t"; then \
|
||||
fail=true ;\
|
||||
break ;\
|
||||
fi ;\
|
||||
done ;\
|
||||
if $$fail; then \
|
||||
echo "TEST FAILED: $$t" ;\
|
||||
exit 1 ;\
|
||||
else \
|
||||
echo 'ALL TESTS PASSED' ;\
|
||||
exit 0 ;\
|
||||
fi ;\
|
||||
fi ;\
|
Reference in New Issue
Block a user