Skip to content

Commit

Permalink
Merge pull request #21 from vpa-research/patches-mikhail
Browse files Browse the repository at this point in the history
Specs for `java.lang.System`, `java.lang.Integer`, `java.lang.Float`, `java.util.concurrent.atomic.AtomicBoolean/Integer/Long/Reference` + Minor improvements to `java.util.ArrayList`, `java.util.LinkedList`
  • Loading branch information
alexeev509 authored Dec 12, 2023
2 parents 490f0bf + db77c7d commit 79ff35f
Show file tree
Hide file tree
Showing 110 changed files with 10,808 additions and 2,368 deletions.
2 changes: 2 additions & 0 deletions spec/java.common.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ annotation packageprivate ();

annotation public ();

annotation abstract ();

annotation extends (
canonicalClassName: string,
);
Expand Down
27 changes: 27 additions & 0 deletions spec/java/io/Console.lsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//#! pragma: non-synthesizable
libsl "1.1.0";

library std
version "11"
language "Java"
url "https://github.com/openjdk/jdk11/blob/master/src/java.base/share/classes/java/io/Console.java";

// imports

import java/io/Flushable;


// primary semantic types

@final type Console
is java.io.Console
for Flushable
{
}

// see java.io.Console#istty
val CONSOLE_IS_TTY: boolean = action SYMBOLIC("boolean");


// global aliases and type overrides

24 changes: 24 additions & 0 deletions spec/java/io/FileDescriptor.lsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//#! pragma: non-synthesizable
libsl "1.1.0";

library std
version "11"
language "Java"
url "https://github.com/openjdk/jdk11/blob/master/src/java.base/share/classes/java/io/FileDescriptor.java";

// imports

import java/lang/Object;


// primary semantic types

@public type FileDescriptor
is java.io.FileDescriptor
for Object
{
fun valid(): boolean;

@throws(["java.io.SyncFailedException"])
fun sync(): void;
}
3 changes: 2 additions & 1 deletion spec/java/lang/Byte.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import java/lang/Number;
@FunctionalInterface("byteValue")
@final type Byte
is java.lang.Byte
for Comparable, Number, byte
for Comparable, Number
{
// WARNING: use 'byteValue' to get primitive value
}


Expand Down
7 changes: 5 additions & 2 deletions spec/java/lang/Character.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ library std
// imports

import java/io/Serializable;
import java/lang/CharSequence;
import java/lang/Comparable;


Expand All @@ -17,11 +18,13 @@ import java/lang/Comparable;
@FunctionalInterface("charValue")
@final type Character
is java.lang.Character
for Comparable, Serializable, char
for Comparable, Serializable
{
// WARNING: use 'charValue' to get primitive value

fun *.charValue(): char;

@static fun offsetByCodePoints(seq: CharSequence, index: int, codePointOffset: int): int;
@static fun *.offsetByCodePoints(seq: CharSequence, index: int, codePointOffset: int): int;
}


Expand Down
24 changes: 24 additions & 0 deletions spec/java/lang/ClassLoader.lsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//#! pragma: non-synthesizable
libsl "1.1.0";

library std
version "11"
language "Java"
url "https://github.com/openjdk/jdk11/blob/master/src/java.base/share/classes/java/lang/ClassLoader.java";

// imports

import java/lang/Object;


// primary semantic types

@final type ClassLoader
is java.lang.ClassLoader
for Object
{
}


// global aliases and type overrides

41 changes: 36 additions & 5 deletions spec/java/lang/Double.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ library std
// imports

import java/lang/Comparable;
import java/lang/Class;
import java/lang/Number;


Expand All @@ -17,14 +18,44 @@ import java/lang/Number;
@FunctionalInterface("doubleValue")
@final type Double
is java.lang.Double
for Comparable, Number, double
for Comparable, Number
{
}
// WARNING: use 'doubleValue' to get primitive value

@static fun *.isNaN(x: double): boolean;

val DOUBLE_POSITIVE_INFINITY: double = 1.0 / 0.0;
val DOUBLE_NEGATIVE_INFINITY: double = -1.0 / 0.0;
val DOUBLE_NAN: double = 0.0 / 0.0;
@static fun *.isFinite(x: double): boolean;
@static fun *.isInfinite(x: double): boolean;

@static fun *.valueOf(x: double): Number; // #problem: self-reference
}


// global aliases and type overrides

@extends("java.lang.Number")
@implements("java.lang.Comparable<Double>")
@final type LSLDouble
is java.lang.Double
for Double
{
@private @static val serialVersionUID: long = -9172774392245257468L;

@static val BYTES: int = 8;
@static val SIZE: int = 64;

@static val MAX_EXPONENT: int = 1023;
@static val MIN_EXPONENT: int = -1022;

// #problem: no support for scientific notation
@static val MAX_VALUE: double = action DEBUG_DO("1.7976931348623157E308");
@static val MIN_VALUE: double = action DEBUG_DO("4.9E-324");
@static val MIN_NORMAL: double = action DEBUG_DO("2.2250738585072014E-308");

@static val POSITIVE_INFINITY: double = 1.0 / 0.0;
@static val NEGATIVE_INFINITY: double = -1.0 / 0.0;

@static val NaN: double = 0.0 / 0.0;

@static val TYPE: Class = action TYPE_OF("Double");
}
Loading

0 comments on commit 79ff35f

Please sign in to comment.