character code point in the Basic Multilingual Plane, encoded with UTF-16 D double double-precision floating-point value F float single-precision floating-point value I int integer J long long integer L ClassName reference an instance of class ClassName Q ClassName inline types S short signed short Z boolean true or false [ reference one array dimension
interface Foo we say that L-Foo is the L- type of Foo. When the type is obviously not a value type we may omit the “L-” prefix, thus Object and Object[] for L-Object and L-Object[]. As dictated by today’s JVMS, any variable of L-type will accept null. A Q-type is a reference to a value instance. All value instances have a named class, which is incorporated into the spelling of the Q-type. (For regularity we say “reference to a value”, but the reference is not detectable to the user; there are no identity or aliasing relations between values.) For any given named value class Val we say that Q-Val is the Q-type of Val. http://cr.openjdk.java.net/~jrose/values/q-types.html September 2018
fields containing value types. No support for @Contended value type fields. No JVMTI, AOT, CDS, ZGC, or serviceability agent. Only -Xint and C2 are supported. No C1, no tiered compilation, and no Graal. The interpreter is not optimized, since our focus is on the JIT implementation. Unsafe field and array-accessor APIs are not supported for value types. Low-level unsafe APIs are UNSAFE and will not be changed to support value types. If a value type has been flattened in a container, unsafe does not know the layout, so getObject could return the first flattened element rather than the expected reference. Immutable types can be copied, so updates may not be seen.
x; public final int y; public Point(int x, int y) { this.x = x; this.y = y; } public static Point of(int x, int y) { Point p = Point.default; Point p1 = __WithField(p.x, x); //WithField operator is allowed only with -XDallowWithFieldOperator Point p2 = __WithField(p1.y, y); return p2; }
class Alsatian extends Dog { // Error: cannot inherit from final com.gamasoft.animals.Dog public value class Alsatian extends Dog { // Error: value type may not extend another value or class
String name; public Cat(String name) { this.name = name; } @Override public String name() { // return super.toString(); //Error: value types do not support invocation of super.toString return name; }
new Cat("Ginger"); //VT var s = new Shark(); //Object List<Animal> animalList = new ArrayList<>(); animalList.add(d); animalList.add(c); animalList.add(s); Set<Cat> catSet = new HashSet<>(); catSet.add(new Cat("Tom")); catSet.add(new Cat("Jerry")); catSet.add(new Cat("Silvester"));
startPoint; public __Flattenable final Point endPoint; public Line(Point p1, Point p2) { this.startPoint = p1; this.endPoint = p2; } } var memBefore = Runtime.getRuntime().freeMemory(); var values = new Line[1_000_000]; var memUsed = memBefore - Runtime.getRuntime().freeMemory(); System.out.println("Memory for 1M Lines " + memUsed); //16MB