-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
-
generic
-
generic
For JDK-8222711, I have pushed an initial implementation here:
http://hg.openjdk.java.net/valhalla/valhalla/rev/cc473d393abf.
Basically, instead of generating synthetic static factory methods of the name $makeValue$ as was the case with LW1, javac now under the option -XDstaticInitValueFactory emits source level constructors into class file level static factories that
- have the name <init>
- are static methods
- have a return type that matches the class
- are invoked via invokestatic at the new V() construction site.
Given the following program:
public value class X {
int x = 10;
public X(String s) {
}
public static void main(String [] args) {
X x = new X("");
}
If I compile as:
valhalla/valhalla/build/linux-x86_64-server-release/jdk/bin/javac -XDstaticInitValueFactory -g X.java
and attempt to run it as:
valhalla/valhalla/build/linux-x86_64-server-release/images/jdk/bin/java -XX:+EnableValhalla X
I get:
Error: LinkageError occurred while loading main class X
java.lang.ClassFormatError: Method "<init>" in class X has illegal signature "(Ljava/lang/String;)QX;"
All the 4 changes listed are potential irritants for the VM and need to be addressed.
http://hg.openjdk.java.net/valhalla/valhalla/rev/cc473d393abf.
Basically, instead of generating synthetic static factory methods of the name $makeValue$ as was the case with LW1, javac now under the option -XDstaticInitValueFactory emits source level constructors into class file level static factories that
- have the name <init>
- are static methods
- have a return type that matches the class
- are invoked via invokestatic at the new V() construction site.
Given the following program:
public value class X {
int x = 10;
public X(String s) {
}
public static void main(String [] args) {
X x = new X("");
}
If I compile as:
valhalla/valhalla/build/linux-x86_64-server-release/jdk/bin/javac -XDstaticInitValueFactory -g X.java
and attempt to run it as:
valhalla/valhalla/build/linux-x86_64-server-release/images/jdk/bin/java -XX:+EnableValhalla X
I get:
Error: LinkageError occurred while loading main class X
java.lang.ClassFormatError: Method "<init>" in class X has illegal signature "(Ljava/lang/String;)QX;"
All the 4 changes listed are potential irritants for the VM and need to be addressed.
- blocks
-
JDK-8222711 [lworld] Value construction modalities in class file
- Resolved
- relates to
-
JDK-8224057 [lworld] a hidden value class can't have <vnew> static factory method
- Resolved
-
JDK-8224068 [lworld] JCK api/java_lang/invoke/MethodHandles/Lookup/ExceptionsTests crashes
- Resolved
-
JDK-8223349 [lworld] core reflection support on static <init> factory methods for inline types
- Resolved
-
JDK-8224045 [lworld] Need additional tests for static <init> factory methods for inline types
- Closed