Skip to content

Commit e1d626c

Browse files
committed
update specs, implement nanotime
1 parent fe3aded commit e1d626c

File tree

6 files changed

+15
-328
lines changed

6 files changed

+15
-328
lines changed

docs/specs/java_JVM.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
% !TEX root = ./java_JVM.tex
2-
\input source_header.tex
2+
\input java_header.tex
33
\usepackage{titlesec}
44

55
\setcounter{secnumdepth}{4}
@@ -38,10 +38,10 @@
3838

3939
\begin{document}
4040
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41-
\docheader{Java}{Source}{}{Martin Henz, Yap Hock Chuan Roland, Chuan Hao Chang}
41+
\docheader{2024}{Java}{JVM}{Martin Henz, Yap Hock Chuan Roland, Chuan Hao Chang}
4242
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4343

44-
\input source_intro.tex
44+
\input java_intro.tex
4545

4646
This JVM follows the Java SE8 Edition \href{https://docs.oracle.com/javase/specs/jvms/se8/html/index.html}{JVM Specification}.
4747

docs/specs/source_header.tex

Lines changed: 0 additions & 154 deletions
This file was deleted.

docs/specs/source_intro.tex

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/jvm/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ export const functions = {
5050
A build script has been provided to create a module of the Java standard library as a hashmap of base64 strings.
5151

5252
```sh
53-
node dist/jvm/utils/build.js /path/to/classfile/directory
53+
npx tsx src/jvm/utils/build path/to/classfiles
5454
```
5555

56-
It has been configured to only include modules with package name starting with `java`, `sun/misc`, `modules`.
57-
58-
You can then import the strings using `import(java-slang/dist/jvm/utils/classfiles)`.
56+
Java packages are deployed as a submodule of the Source Academy modules repository ([link](https://github.com/source-academy/java-packages)).

src/jvm/specification.md

Lines changed: 0 additions & 159 deletions
This file was deleted.

src/jvm/stdlib/java/lang/System.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ const functions = {
181181
'identityHashCode(Ljava/lang/Object;)I': (thread: Thread) => {
182182
logger.warn('System.identityHashCode(Ljava/lang/Object;)I not implemented')
183183
thread.returnStackFrame(0)
184+
},
185+
186+
/**
187+
* Returns the current time in nanoseconds.
188+
* Accuracy is only in millis since browsers do not support hrtime.
189+
* @param thread
190+
*/
191+
'nanoTime()J': (thread: Thread) => {
192+
const time = BigInt(Date.now()) * BigInt(1000000)
193+
thread.returnStackFrame64(time)
184194
}
185195
}
186196

0 commit comments

Comments
 (0)