RFR [15] 8241921: Remove leftover diagnostic from test/jdk/java/io/Serializable/records/SerialPersistentFieldsTest.java

Chris Hegarty chris.hegarty at oracle.com
Tue Mar 31 10:40:35 UTC 2020

Remove leftover diagnostic that dumps generated class from test/jdk/java/io/Serializable/records/SerialPersistentFieldsTest.java 

At one point it was useful to be able to inspect the generated bytecode using javap, but it was noticed recently for a different reason that the output file is always R1.class, which is clearly wrong. Anyway, this can simply be removed. 

--- a/test/jdk/java/io/Serializable/records/SerialPersistentFieldsTest.java
+++ b/test/jdk/java/io/Serializable/records/SerialPersistentFieldsTest.java
@@ -25,28 +25,26 @@
  * @test
  * @summary Basic tests for prohibited magic serialPersistentFields
  * @library /test/lib
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @compile --enable-preview -source ${jdk.version} SerialPersistentFieldsTest.java
  * @run testng/othervm --enable-preview SerialPersistentFieldsTest
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamClass;
 import java.io.ObjectStreamField;
 import java.io.Serializable;
-import java.io.UncheckedIOException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.math.BigDecimal;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassVisitor;
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.FieldVisitor;
 import jdk.internal.org.objectweb.asm.MethodVisitor;
 import jdk.internal.org.objectweb.asm.Type;
 import jdk.test.lib.ByteCodeLoader;
@@ -222,27 +220,20 @@
         return deserialize(serialize(obj));
     // -- machinery for augmenting a record class with prohibited serial field --
     static byte[] addSerialPersistentFields(byte[] classBytes,
                                             ObjectStreamField[] spf) {
         ClassReader reader = new ClassReader(classBytes);
         ClassWriter writer = new ClassWriter(reader, COMPUTE_MAXS | COMPUTE_FRAMES);
         reader.accept(new SerialPersistentFieldsVisitor(writer, spf), 0);
-        try {
-            FileOutputStream fos = new FileOutputStream("R1.class");
-            fos.write(writer.toByteArray());
-            fos.close();
-        } catch (IOException ioe) {
-            throw new UncheckedIOException(ioe);
-        }
         return writer.toByteArray();
     /** A visitor that adds a serialPersistentFields field, and assigns it in clinit. */
     static final class SerialPersistentFieldsVisitor extends ClassVisitor {
         static final String FIELD_NAME = "serialPersistentFields";
         static final String FIELD_DESC = "[Ljava/io/ObjectStreamField;";
         final ObjectStreamField[] spf;
         String className;
         SerialPersistentFieldsVisitor(ClassVisitor cv, ObjectStreamField[] spf) {


More information about the core-libs-dev mailing list