On Thu, 20 Apr 2023 16:20:18 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
> > The original version of this test was validating serialization > > compatibility with previous releases. > > The current changes seems to have removed that validation in the re-write > > of the test > > One option is to convert the various *.ser files to a byte array and have > > the test write them out or read them from a stream to do the validation > > Good point. You can also base64-encode the bytes into a string - here is an > example: > https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/logging/HigherResolutionTimeStamps/SerializeLogRecord.java Trivial code to create a Byte array in addition to Daniel's example /** * Utility method which takes an byte array and converts to byte array * declaration. For example: * <pre> * {@code * var fooJar = Files.readAllBytes(Path.of("foo.jar")); * var result = createByteArray(fooJar, "FOOBYTES"); * } * </pre> * @param bytes A byte array used to create a byte array declaration * @param name Name to be used in the byte array declaration * @return The formatted byte array declaration */ public static String createByteArray(byte[] bytes, String name) { StringBuilder sb = new StringBuilder(bytes.length * 5); Formatter fmt = new Formatter(sb); fmt.format(" public static byte[] %s = {", name); final int linelen = 8; for (int i = 0; i < bytes.length; i++) { if (i % linelen == 0) { fmt.format("%n "); } fmt.format(" (byte) 0x%x,", bytes[i] & 0xff); } fmt.format("%n };%n"); return sb.toString(); } ------------- PR Comment: https://git.openjdk.org/jdk/pull/13537#issuecomment-1516672731