-
Bug
-
Resolution: Fixed
-
P3
-
15, 16, 17, 18
-
b22
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8276361 | 17.0.3-oracle | Mandy Chung | P3 | Resolved | Fixed | b01 |
JDK-8276261 | 17.0.2 | Mandy Chung | P3 | Resolved | Fixed | b04 |
This is to follow up the behavorial change on LambdaMetaFactory::metafactory when the implementation is REF_invokeSpecial method handle on a public/protected method in the target class. This won't happen for classes compiled from javac since REF_invokeSpecial method handle is generated when the method is a private method whereas REF_invokeVirtual method handle would be generated on a public/protected.
To reproduce:
1. compile it with java 8
2. modify the access of testPrivate from private to public in .class file (do not modify any invokespecial and ref_invokespecial).
3. Java 14 without JEP 371, the method reference `this::testPrivate` with REF_invokeSpecial kind will be resolved to ExampleClass::testPrivate on a receiver of type ExampleClass$SubClass. With JEP 371 change, the method reference `test::testPrivate` with REF_invokeSpecial kind will be resolved to ExampleClass$Subclass::testPrivate instead.
import java.util.function.Supplier;
public class ExampleClass {
public static void main(String[] args) {
System.out.println(new SubClass().test());
System.out.println(new SubClass().testWithLMF());
}
public String test() {
return this.testPrivate();
}
public String testWithLMF() {
Supplier<String> supplier = this::testPrivate;
return supplier.get();
}
private String testPrivate() {
return "123";
}
public static class SubClass extends ExampleClass {
public String testPrivate() {
return "456";
}
}
}
Java 14:
$ java ExampleClass
123
123
Java 15:
$ java ExampleClass
123
456
- backported by
-
JDK-8276261 LambdaMetaFactory::metafactory on REF_invokeSpecial impl method has incorrect behavior
- Resolved
-
JDK-8276361 LambdaMetaFactory::metafactory on REF_invokeSpecial impl method has incorrect behavior
- Resolved
- csr for
-
JDK-8276255 LambdaMetaFactory::metafactory on REF_invokeSpecial impl method has incorrect behavior
- Closed
- relates to
-
JDK-8246790 LambdaMetafactory fails to support invokespecial method handle with hidden class
- Closed
- links to
-
Commit openjdk/jdk17u/a0899bfb
-
Commit openjdk/jdk/21da2183
-
Review openjdk/jdk17u/221
-
Review openjdk/jdk/5901