Details
-
Bug
-
Resolution: Fixed
-
P1
-
8
-
b117
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8028870 | port-stage-ppc-aix | Robert Field | P1 | Resolved | Fixed | master |
Description
Now that lambda proxies are anonymous, when we cross the threshold where reflection proxies are generated to invoke writeReplace, linkage of the reflection proxy fails with CFNE, causing serialization to fail:
LambdaObject: org.openjdk.tests.java.util.stream.IntReduceTest$$Lambda$1004/961982062@69dd3352 [ 20 ]
[testng] Throwable: java.lang.NoClassDefFoundError: org/openjdk/tests/java/util/stream/IntReduceTest$$Lambda$1004/961982062java.lang.NoClassDefFoundError: org/openjdk/tests/java/util/stream/IntReduceTest$$Lambda$1004/961982062
[testng] at sun.reflect.GeneratedMethodAccessor273.invoke(Unknown Source)
[testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[testng] at java.lang.reflect.Method.invoke(Method.java:483)
[testng] at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:1075)
[testng] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1136)
[testng] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[testng] at com.oracle.lambda.TestLambdaSerialization.serializeAndDeserialize0(TestLambdaSerialization.java:128)
Test patch to detect failures:
diff -r f6bc96afc5d4 test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
--- a/test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
+++ b/test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
@@ -45,15 +45,19 @@
*/
@Test
public class SerializedLambdaTest {
+ public static final int REPS = 50;
+
@SuppressWarnings("unchecked")
private<T> void assertSerial(T p, Consumer<T> asserter) throws IOException, ClassNotFoundException {
asserter.accept(p);
- byte[] bytes = serialize(p);
+ for (int i=0; i<REPS; i++) {
+ byte[] bytes = new byte[0];
+ bytes = serialize(p);
assertTrue(bytes.length > 0);
-
asserter.accept((T) deserialize(bytes));
}
+ }
private void assertNotSerial(Predicate<String> p, Consumer<Predicate<String>> asserter)
LambdaObject: org.openjdk.tests.java.util.stream.IntReduceTest$$Lambda$1004/961982062@69dd3352 [ 20 ]
[testng] Throwable: java.lang.NoClassDefFoundError: org/openjdk/tests/java/util/stream/IntReduceTest$$Lambda$1004/961982062java.lang.NoClassDefFoundError: org/openjdk/tests/java/util/stream/IntReduceTest$$Lambda$1004/961982062
[testng] at sun.reflect.GeneratedMethodAccessor273.invoke(Unknown Source)
[testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[testng] at java.lang.reflect.Method.invoke(Method.java:483)
[testng] at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:1075)
[testng] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1136)
[testng] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[testng] at com.oracle.lambda.TestLambdaSerialization.serializeAndDeserialize0(TestLambdaSerialization.java:128)
Test patch to detect failures:
diff -r f6bc96afc5d4 test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
--- a/test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
+++ b/test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
@@ -45,15 +45,19 @@
*/
@Test
public class SerializedLambdaTest {
+ public static final int REPS = 50;
+
@SuppressWarnings("unchecked")
private<T> void assertSerial(T p, Consumer<T> asserter) throws IOException, ClassNotFoundException {
asserter.accept(p);
- byte[] bytes = serialize(p);
+ for (int i=0; i<REPS; i++) {
+ byte[] bytes = new byte[0];
+ bytes = serialize(p);
assertTrue(bytes.length > 0);
-
asserter.accept((T) deserialize(bytes));
}
+ }
private void assertNotSerial(Predicate<String> p, Consumer<Predicate<String>> asserter)
Attachments
Issue Links
- backported by
-
JDK-8028870 Lambda serialization fails once reflection proxy generation kicks in
- Resolved
- duplicates
-
JDK-7194897 JSR 292: Cannot create more than 16 instances of an anonymous class
- Resolved
-
JDK-8028106 Lambda serialization fails on 17 iteration
- Resolved