-
Bug
-
Resolution: Fixed
-
P2
-
18
-
b23
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8287955 | 18u-cpu | Jan Lahoda | P2 | Resolved | Fixed | master |
JDK-8286884 | 18.0.2 | Jan Lahoda | P2 | Closed | Fixed | b09 |
This works for JDK 17 and earlier, but fails with JDK 18.
The regression was introduced by https://bugs.openjdk.java.net/browse/JDK-8272564
```
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Paths;
public class X {
interface I extends Serializable {}
interface F<T, R> extends Serializable {
R apply(T t);
}
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
F<I, Integer> f = I::hashCode;
try (OutputStream os = Files.newOutputStream(Paths.get("o"));
ObjectOutputStream oos = new ObjectOutputStream(os)) {
oos.writeObject(f);
}
try (InputStream is = Files.newInputStream(Paths.get("o"));
ObjectInputStream ois = new ObjectInputStream(is)) {
f = (F<I, Integer>) ois.readObject();
}
System.err.println(f.apply(new I() {}));
}
}
```
```
$ javac X.java
$ java X
...
Exception in thread "main" java.io.InvalidObjectException: ReflectiveOperationException during deserialization
at java.base/java.lang.invoke.SerializedLambda.readResolve(SerializedLambda.java:280)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at java.base/java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1321)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2301)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1768)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:543)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:501)
at X.main(X.java:25)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at java.base/java.lang.invoke.SerializedLambda.readResolve(SerializedLambda.java:278)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at java.base/java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1321)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2301)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1768)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:543)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:501)
at X.main(X.java:25)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:421)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:192)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
Caused by: java.lang.IllegalArgumentException: Invalid lambda deserialization
at X.$deserializeLambda$(X.java:9)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 15 more
```
- backported by
-
JDK-8287955 Lambda deserialization fails for Object method references on interfaces
- Resolved
-
JDK-8286884 Lambda deserialization fails for Object method references on interfaces
- Closed
- csr for
-
JDK-8286047 Lambda deserialization fails for Object method references on interfaces
- Closed
- relates to
-
JDK-8286615 Small refactor to SerializedLambda
- Resolved
-
JDK-8286843 Specify more details of lambda serialization
- New
-
JDK-8154236 Deserialization of lambda causes ClassCastException
- Open
-
JDK-8174865 Different method references deserialize to the same class
- Open
-
JDK-8068253 MethodHandleInfo does not provide the referenced class
- In Progress
-
JDK-8174864 SerializedLambda does not preserve markers & bridges
- In Progress
-
JDK-8272564 Incorrect attribution of method invocations of Object methods on interfaces
- Resolved
-
JDK-8300623 Lambda deserialization regression involving Enum method reference
- Closed
- links to
-
Commit openjdk/jdk18u/81f41c60
-
Commit openjdk/jdk/c0d51d42
-
Review openjdk/jdk18u/133
-
Review openjdk/jdk/8054