-
Bug
-
Resolution: Duplicate
-
P2
-
None
Fails started from JDK8b115
Minimized test:
--------------------------------------------------------------------------------
public class MiniTest {
public static void main(String[] args) throws IOException {
for(int i = 0; i < 17; i++) {
ser();
}
}
public static void ser() throws IOException {
try (ByteOutputStream bos = new ByteOutputStream(); ObjectOutputStream ostream = new ObjectOutputStream(bos)) {
ostream.writeObject((FuncInt) () -> {});
}
}
}
@FunctionalInterface
interface FuncInt extends Serializable {
void m();
}
--------------------------------------------------------------------------------
Output:
--------------------------------------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: javasoft/sqe/tests/api/java/lang/invoke/SerializedLambda/serial/MiniTest$$Lambda$1/804564176
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:1075)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1136)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at javasoft.sqe.tests.api.java.lang.invoke.SerializedLambda.serial.MiniTest.ser(MiniTest.java:25)
at javasoft.sqe.tests.api.java.lang.invoke.SerializedLambda.serial.MiniTest.main(MiniTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: javasoft.sqe.tests.api.java.lang.invoke.SerializedLambda.serial.MiniTest$$Lambda$1.804564176
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
--------------------------------------------------------------------------------
Minimized test:
--------------------------------------------------------------------------------
public class MiniTest {
public static void main(String[] args) throws IOException {
for(int i = 0; i < 17; i++) {
ser();
}
}
public static void ser() throws IOException {
try (ByteOutputStream bos = new ByteOutputStream(); ObjectOutputStream ostream = new ObjectOutputStream(bos)) {
ostream.writeObject((FuncInt) () -> {});
}
}
}
@FunctionalInterface
interface FuncInt extends Serializable {
void m();
}
--------------------------------------------------------------------------------
Output:
--------------------------------------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: javasoft/sqe/tests/api/java/lang/invoke/SerializedLambda/serial/MiniTest$$Lambda$1/804564176
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:1075)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1136)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at javasoft.sqe.tests.api.java.lang.invoke.SerializedLambda.serial.MiniTest.ser(MiniTest.java:25)
at javasoft.sqe.tests.api.java.lang.invoke.SerializedLambda.serial.MiniTest.main(MiniTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: javasoft.sqe.tests.api.java.lang.invoke.SerializedLambda.serial.MiniTest$$Lambda$1.804564176
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
--------------------------------------------------------------------------------
- duplicates
-
JDK-8027681 Lambda serialization fails once reflection proxy generation kicks in
- Closed
- relates to
-
JDK-7194897 JSR 292: Cannot create more than 16 instances of an anonymous class
- Resolved