Any language can be used to write device driver, provided a few condition have to be satisfied:
- Direct memory access. Look at this source code:
https://patchwork.kernel.org/patch/8163061/
As device driver you may be accessing the virtual memory or physical memory directly (in the case of DMA), and thus bypassing the virtual memory setup by the MMU is needed. Direct accessing the virtual memory means you know the virtual address, and want to read the address directly.
Java or Javascript does not have any language construct to read memory via known address directly.
Assembly language sensitive tasks: Access the hardware very often need special assembly instruction, like disabling the interrupt, or switching from one CPU to another, or broadcasting inter-CPU messages etc. There is no Java construct to do all these, perhaps not even C language. So which is why combining C + assembly is often needed. But there is no way to combine Java and assembly.
Native vs interpreted language: All intepreted language will have to go through a intepreter to execute the language. In Javascript or Java, you need JVM to execute the Java. So if you need Java in the kernel, then you will need a JVM intepreter in the kernel. This is not impossible - recent Linux kernel have a BPF intepreter running in the kernel, so you have a BPF VM running in the kernel:
https://events.linuxfoundation.org/sites/events/files/slides/bpf_collabsummit_2015feb20.pdf
https://lwn.net/Articles/599755/
The idea of Java as a device driver HAS been implemented before, as a research paper/project (for Sun Solaris OS):
http://dl.acm.org/citation.cfm?id=1215998
http://www.c0t0d0s0.org/archives/2587-Device-driver-in-Java.html
But I am not sure how the problem of directly memory access is solved.
Still, it is always possible to design a system whereby part of the tasks can be done by a low level module, which is C/Assembly dependent, and other component which can be written in non-C language, as shown in this recent paper (Usenix 2009):
https://www.usenix.org/legacy/event/usenix09/tech/full_papers/renzelmann/renzelmann_html/
See the diagram below:
Click to see picture