changeset 7622:85912d2b4773

More serialization test tweaking
author briangoetz
date Tue, 12 Mar 2013 22:38:54 -0400
parents 622996f1e9f2
children 9ba86b004c5a 214c838ad4bd
files src/share/classes/java/util/HashSet.java src/share/classes/java/util/TreeSet.java test-ng/agent/conf/serialize.list test-ng/agent/src/com/oracle/lambda/Agent.java test-ng/agent/src/com/oracle/lambda/SerializationInjector.java test-ng/build.xml
diffstat 4 files changed, 37 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/test-ng/agent/conf/serialize.list	Tue Mar 12 17:46:41 2013 -0700
+++ b/test-ng/agent/conf/serialize.list	Tue Mar 12 22:38:54 2013 -0400
@@ -1,18 +1,25 @@
-#java/util/Optional --- Duplicate class
-#java/util/OptionalDouble --- Duplicate class
 java/lang/invoke/MagicLambdaImpl
+java/util/Optional
+java/util/OptionalDouble
+java/util/OptionalLong
 java/util/OptionalInt
+java/util/Spliterator
 java/util/ArrayList\$SubList
+java/util/HashMap\$.*Spliterator
+java/util/TreeMap\$.*Spliterator
 java/util/function/Function\$\$Lambda.*
 java/util/function/Functions\$\$Lambda.*
 java/util/stream/Collectors.*
 java/util/stream/LambdaTestHelpers\$\$Lambda.*
-java/util/stream/IntStreamTestData\$.*
-java/util/stream/StreamTestData\$.*
 java/util/stream/Nodes.*NodeBuilder
 java/util/stream/Nodes\$.*Node
 java/util/stream/AbstractSpinedBuffer
 java/util/stream/SpinedBuffer
+java/util/stream/.*Pipeline
+java/util/stream/AbstractPipeline\$.*
+java/util/stream/IntermediateOp
+java/util/stream/.*StreamTestData\$.*
+org/openjdk/tests/java/util/stream/OpTestCase\$TestData
 org/openjdk/tests/java/util/stream/OpTestCase\$ExerciseDataStreamBuilder
 org/openjdk/tests/java/util/stream/OpTestCase\$ExerciseDataTerminalBuilder
 org/openjdk/tests/java/util/stream/IntNodeTest
--- a/test-ng/agent/src/com/oracle/lambda/Agent.java	Tue Mar 12 17:46:41 2013 -0700
+++ b/test-ng/agent/src/com/oracle/lambda/Agent.java	Tue Mar 12 22:38:54 2013 -0400
@@ -26,11 +26,15 @@
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.IllegalClassFormatException;
 import java.lang.instrument.Instrumentation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.security.ProtectionDomain;
+import java.util.HashSet;
+import java.util.TreeSet;
 
 public class Agent {
     public static void premain(String agentArgs, Instrumentation instrumentation)
-            throws IOException {
+            throws IOException, NoSuchFieldException, IllegalAccessException {
         // If run without a config file, all we do is set up the shutdown hook
         if (agentArgs != null) {
             final SerializationInjector si = new SerializationInjector(agentArgs);
@@ -43,7 +47,24 @@
                 }
             });
         }
-        else
+        else {
+            // Horrible horrible hack.
+            // TreeSet/HashSet are based off of HashSet/HashMap, and serializing their spliterators
+            // tries to serialize the underlying map, which uses a non-serializable sentinel object.
+            // This hack swaps that out for a serializable sentinel
+            Field f = HashSet.class.getDeclaredField("PRESENT");
+            f.setAccessible(true);
+            Field modifiersField = Field.class.getDeclaredField("modifiers");
+            modifiersField.setAccessible(true);
+            modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
+            f.set(null, Boolean.TRUE);
+
+            f = TreeSet.class.getDeclaredField("PRESENT");
+            f.setAccessible(true);
+            modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
+            f.set(null, Boolean.TRUE);
+
             TestLambdaSerialization.initializeShutDownHook();
+        }
     }
  }
--- a/test-ng/agent/src/com/oracle/lambda/SerializationInjector.java	Tue Mar 12 17:46:41 2013 -0700
+++ b/test-ng/agent/src/com/oracle/lambda/SerializationInjector.java	Tue Mar 12 22:38:54 2013 -0400
@@ -58,7 +58,7 @@
     static final String SERIALIZE = "";
     static PrintStream outputStream;
     static boolean shouldClose = false;
-    static boolean storeStackTraces;
+    static boolean storeStackTraces = true;
     static boolean deserializationWorkaround;
 
     final DebugPrint debug;
--- a/test-ng/build.xml	Tue Mar 12 17:46:41 2013 -0700
+++ b/test-ng/build.xml	Tue Mar 12 22:38:54 2013 -0400
@@ -201,6 +201,7 @@
             <jvmarg value="-Xbootclasspath/p:${agent.jar}"/>
             <jvmarg value="-Xbootclasspath/p:${mangled.bootdir}"/>
             <jvmarg value="-Xbootclasspath/p:${lib.testng.jar}"/>
+            <!--<jvmarg value="-Dsun.io.serialization.extendedDebugInfo=true" />-->
             <jvmarg value="-ea" />
             <jvmarg value="-esa" />
             <jvmarg value="-Xverify:all" />
@@ -217,6 +218,7 @@
             <jvmarg value="-Xbootclasspath/p:${agent.jar}"/>
             <jvmarg value="-Xbootclasspath/p:${mangled.bootdir}"/>
             <jvmarg value="-Xbootclasspath/p:${lib.testng.jar}"/>
+            <!--<jvmarg value="-Dsun.io.serialization.extendedDebugInfo=true" />-->
             <jvmarg value="-ea" />
             <jvmarg value="-esa" />
             <jvmarg value="-Xverify:all" />