8327208: Remove unused method java.util.jar.Manifest.make72Safe

Reviewed-by: lancea, iris, jpai
This commit is contained in:
Eirik Bjørsnøs 2024-03-05 08:39:43 +00:00
parent d6f2a174fc
commit e9adcebaf2
3 changed files with 12 additions and 31 deletions

View File

@ -219,22 +219,6 @@ public class Manifest implements Cloneable {
dos.flush();
}
/**
* Adds line breaks to enforce a maximum of 72 bytes per line.
*
* @deprecation Replaced with {@link #println72}.
*/
@Deprecated(since = "13")
static void make72Safe(StringBuffer line) {
int length = line.length();
int index = 72;
while (index < length) {
line.insert(index, "\r\n ");
index += 74; // + line width + line break ("\r\n")
length += 3; // + line break ("\r\n") and space
}
}
/**
* Writes {@code line} to {@code out} with line breaks and continuation
* spaces within the limits of 72 bytes of contents per line followed

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.jar.Manifest;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
@ -171,7 +172,7 @@ public class LineBreakLineWidth {
* if the header name is 69 or 70 bytes and in that case the name/value
* delimiter ": " was broken on a new line.
*
* changing the line width in Manifest#make72Safe(StringBuffer),
* changing the line width in {@link Manifest#println72(OutputStream, String)},
* however, also affects at which positions values are broken across
* lines (should always have affected values only and never header
* names or the delimiter) which is tested here.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,12 +22,9 @@
*/
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
@ -46,7 +43,6 @@ import java.util.zip.ZipFile;
import java.util.zip.ZipEntry;
import jdk.security.jarsigner.JarSigner;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform;
import jdk.test.lib.SecurityTools;
import jdk.test.lib.util.JarUtils;
import org.testng.annotations.BeforeTest;
@ -467,14 +463,14 @@ public class PreserveRawManifestEntryAndDigest {
}
/**
* Breaks {@code line} at 70 bytes even though the name says 72 but when
* also counting the line delimiter ("{@code \r\n}") the line totals to 72
* bytes.
* Borrowed from {@link Manifest#make72Safe} before JDK 11
* Pre JDK 11, {@link Manifest#write(OutputStream)} would inject
* line breaks after 70 bytes instead of 72 bytes as mandated by
* the JAR File Specification.
*
* @see Manifest#make72Safe
* This method injects line breaks after 70 bytes to simulate pre
* JDK 11 manifests.
*/
static void make72Safe(StringBuffer line) {
static void injectLineBreaksAt70Bytes(StringBuffer line) {
int length = line.length();
if (length > 72) {
int index = 70;
@ -516,7 +512,7 @@ public class PreserveRawManifestEntryAndDigest {
buf[0].append(line.substring(1));
} else {
if (buf[0] != null) {
make72Safe(buf[0]);
injectLineBreaksAt70Bytes(buf[0]);
sb.append(buf[0].toString());
sb.append("\r\n");
}
@ -524,7 +520,7 @@ public class PreserveRawManifestEntryAndDigest {
buf[0].append(line);
}
});
make72Safe(buf[0]);
injectLineBreaksAt70Bytes(buf[0]);
sb.append(buf[0].toString());
sb.append("\r\n");
return sb.toString().getBytes(UTF_8);