You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/12/27 22:17:03 UTC
[commons-compress] 02/06: Use final, remove trailing whitespace
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 8866107c8613eb324e0ef2095022a9b0cbb091fa
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Dec 27 16:57:53 2022 -0500
Use final, remove trailing whitespace
Refactor duplicate code
---
.../archivers/dump/DumpArchiveSummary.java | 2 +-
.../compress/archivers/sevenz/AES256Options.java | 12 +-
.../archivers/sevenz/AES256SHA256Decoder.java | 12 +-
.../archivers/sevenz/SevenZArchiveEntry.java | 2 +-
.../archivers/sevenz/SevenZOutputFile.java | 10 +-
.../compress/archivers/tar/TarArchiveEntry.java | 27 ++--
.../commons/compress/archivers/tar/TarFile.java | 6 +-
.../commons/compress/archivers/tar/TarUtils.java | 20 +--
.../archivers/zip/ZipArchiveInputStream.java | 2 +-
.../commons/compress/archivers/zip/ZipFile.java | 10 +-
.../harmony/pack200/AttributeDefinitionBands.java | 2 +-
.../commons/compress/harmony/pack200/BandSet.java | 8 +-
.../commons/compress/harmony/pack200/CPClass.java | 2 +-
.../compress/harmony/pack200/ClassBands.java | 62 ++++----
.../commons/compress/harmony/pack200/Codec.java | 2 +-
.../compress/harmony/pack200/CodecEncoding.java | 10 +-
.../commons/compress/harmony/pack200/CpBands.java | 4 +-
.../compress/harmony/pack200/FileBands.java | 8 +-
.../commons/compress/harmony/pack200/IcBands.java | 4 +-
.../harmony/pack200/MetadataBandGroup.java | 14 +-
.../harmony/pack200/NewAttributeBands.java | 50 +++----
.../compress/harmony/pack200/PackingUtils.java | 2 +-
.../commons/compress/harmony/pack200/Segment.java | 4 +-
.../compress/harmony/unpack200/Archive.java | 4 +-
.../harmony/unpack200/AttributeLayoutMap.java | 4 +-
.../compress/harmony/unpack200/BandSet.java | 2 +-
.../compress/harmony/unpack200/BcBands.java | 4 +-
.../compress/harmony/unpack200/ClassBands.java | 22 +--
.../compress/harmony/unpack200/CpBands.java | 4 +-
.../compress/harmony/unpack200/IcTuple.java | 2 +-
.../harmony/unpack200/MetadataBandGroup.java | 4 +-
.../harmony/unpack200/NewAttributeBands.java | 46 +++---
.../compress/harmony/unpack200/Segment.java | 8 +-
.../harmony/unpack200/SegmentConstantPool.java | 2 +-
.../compress/harmony/unpack200/SegmentUtils.java | 12 +-
.../unpack200/bytecode/AnnotationsAttribute.java | 8 +-
.../harmony/unpack200/bytecode/ByteCode.java | 2 +-
.../unpack200/bytecode/ClassConstantPool.java | 10 +-
.../harmony/unpack200/bytecode/ClassFile.java | 8 +-
.../harmony/unpack200/bytecode/CodeAttribute.java | 12 +-
.../unpack200/bytecode/ExceptionsAttribute.java | 6 +-
.../unpack200/bytecode/InnerClassesAttribute.java | 4 +-
.../harmony/unpack200/bytecode/NewAttribute.java | 4 +-
...timeVisibleorInvisibleAnnotationsAttribute.java | 4 +-
...leorInvisibleParameterAnnotationsAttribute.java | 12 +-
.../unpack200/bytecode/forms/LookupSwitchForm.java | 2 +-
.../commons/compress/java/util/jar/Pack200.java | 4 +-
.../compress/utils/BoundedArchiveInputStream.java | 6 +-
.../apache/commons/compress/utils/OsgiUtils.java | 2 +-
.../commons/compress/archivers/DumpTestCase.java | 8 +-
.../commons/compress/archivers/TarTestCase.java | 28 ++--
.../commons/compress/archivers/ZipTestCase.java | 2 +-
.../cpio/CpioArchiveOutputStreamTest.java | 4 +-
.../archivers/sevenz/SevenZArchiveEntryTest.java | 6 +-
.../compress/archivers/sevenz/SevenZFileTest.java | 8 +-
.../archivers/sevenz/SevenZOutputFileTest.java | 22 +--
.../commons/compress/archivers/tar/BigFilesIT.java | 6 +-
.../compress/archivers/tar/SparseFilesTest.java | 30 ++--
.../archivers/tar/TarArchiveEntryTest.java | 2 +-
.../archivers/tar/TarArchiveInputStreamTest.java | 8 +-
.../archivers/tar/TarArchiveOutputStreamTest.java | 6 +-
.../compress/archivers/tar/TarFileTest.java | 40 ++---
.../archivers/zip/ZipArchiveInputStreamTest.java | 4 +-
.../compress/archivers/zip/ZipFileTest.java | 2 +-
.../archivers/zip/ZipMemoryFileSystemTest.java | 42 +++---
.../harmony/pack200/tests/ArchiveTest.java | 140 +++++++++---------
.../harmony/pack200/tests/BHSDCodecTest.java | 18 +--
.../harmony/pack200/tests/CodecEncodingTest.java | 18 +--
.../compress/harmony/pack200/tests/CodecTest.java | 16 +-
.../pack200/tests/NewAttributeBandsTest.java | 128 ++++++++--------
.../harmony/pack200/tests/PackingOptionsTest.java | 164 ++++++++++-----------
.../harmony/pack200/tests/PopulationCodecTest.java | 2 +-
.../harmony/pack200/tests/RunCodecTest.java | 42 +++---
.../unpack200/tests/AbstractBandsTestCase.java | 4 +-
.../harmony/unpack200/tests/ArchiveTest.java | 74 +++++-----
.../unpack200/tests/AttributeLayoutMapTest.java | 4 +-
.../unpack200/tests/AttributeLayoutTest.java | 18 +--
.../harmony/unpack200/tests/BandSetTest.java | 8 +-
.../harmony/unpack200/tests/BcBandsTest.java | 142 +++++++++---------
.../harmony/unpack200/tests/CPUTF8Test.java | 6 +-
.../harmony/unpack200/tests/ClassBandsTest.java | 56 +++----
.../harmony/unpack200/tests/CodeAttributeTest.java | 16 +-
.../harmony/unpack200/tests/ICTupleTest.java | 4 +-
.../unpack200/tests/NewAttributeBandsTest.java | 74 +++++-----
.../tests/SegmentConstantPoolArrayCacheTest.java | 20 +--
.../unpack200/tests/SegmentConstantPoolTest.java | 6 +-
.../harmony/unpack200/tests/SegmentTest.java | 26 ++--
.../harmony/unpack200/tests/SegmentUtilsTest.java | 2 +-
.../tests/bytecode/ClassFileEntryTest.java | 60 ++++----
.../unpack200/tests/bytecode/ConstantPoolTest.java | 10 +-
.../compress/java/util/jar/Pack200Test.java | 4 +-
.../commons/compress/utils/FileNameUtilsTest.java | 4 +-
.../apache/commons/compress/utils/IOUtilsTest.java | 8 +-
93 files changed, 876 insertions(+), 889 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
index b9378f5d..57e2341d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
@@ -73,7 +73,7 @@ public class DumpArchiveSummary {
if (getClass() != obj.getClass()) {
return false;
}
- DumpArchiveSummary other = (DumpArchiveSummary) obj;
+ final DumpArchiveSummary other = (DumpArchiveSummary) obj;
return Objects.equals(devname, other.devname) && dumpDate == other.dumpDate && Objects.equals(hostname, other.hostname);
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256Options.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256Options.java
index fbfb00b6..f1259ac4 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256Options.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256Options.java
@@ -28,7 +28,7 @@ import javax.crypto.spec.SecretKeySpec;
/**
* Options for {@link SevenZMethod#AES256SHA256} encoder
- *
+ *
* @since 1.23
* @see AES256SHA256Decoder
*/
@@ -41,11 +41,11 @@ class AES256Options {
static SecretKeySpec newSecretKeySpec(final byte[] bytes) {
return new SecretKeySpec(bytes, ALGORITHM);
}
- private static byte[] randomBytes(int size) {
- byte[] bytes = new byte[size];
+ private static byte[] randomBytes(final int size) {
+ final byte[] bytes = new byte[size];
try {
SecureRandom.getInstanceStrong().nextBytes(bytes);
- } catch (NoSuchAlgorithmException e) {
+ } catch (final NoSuchAlgorithmException e) {
throw new IllegalStateException("No strong secure random available to generate strong AES key", e);
}
return bytes;
@@ -60,7 +60,7 @@ class AES256Options {
/**
* @param password password used for encryption
*/
- public AES256Options(char[] password) {
+ public AES256Options(final char[] password) {
this(password, new byte[0], randomBytes(16), 19);
}
@@ -71,7 +71,7 @@ class AES256Options {
* @param numCyclesPower another password security enforcer parameter that controls the cycles of password hashing. More the
* this number is high, more security you'll have but also high CPU usage
*/
- public AES256Options(char[] password, byte[] salt, byte[] iv, int numCyclesPower) {
+ public AES256Options(final char[] password, final byte[] salt, final byte[] iv, final int numCyclesPower) {
this.salt = salt;
this.iv = iv;
this.numCyclesPower = numCyclesPower;
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java
index 827cabc5..2293e58e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java
@@ -38,7 +38,7 @@ import javax.crypto.spec.IvParameterSpec;
import org.apache.commons.compress.PasswordRequiredException;
class AES256SHA256Decoder extends AbstractCoder {
-
+
static byte[] sha256Password(final byte[] password, final int numCyclesPower, final byte[] salt) {
final MessageDigest digest;
try {
@@ -166,7 +166,7 @@ class AES256SHA256Decoder extends AbstractCoder {
}
@Override
- OutputStream encode(OutputStream out, Object options) throws IOException {
+ OutputStream encode(final OutputStream out, final Object options) throws IOException {
final AES256Options opts = (AES256Options) options;
return new OutputStream() {
@@ -199,7 +199,7 @@ class AES256SHA256Decoder extends AbstractCoder {
}
@Override
- public void write(byte[] b, int off, int len) throws IOException {
+ public void write(final byte[] b, final int off, final int len) throws IOException {
int gap = len + count > cipherBlockSize ? cipherBlockSize - count : len;
System.arraycopy(b, off, cipherBlockBuffer, count, gap);
count += gap;
@@ -209,7 +209,7 @@ class AES256SHA256Decoder extends AbstractCoder {
if (len - gap >= cipherBlockSize) {
// skip buffer to encrypt data chunks big enought to fit cipher block size
- int multipleCipherBlockSizeLen = (len - gap) / cipherBlockSize * cipherBlockSize;
+ final int multipleCipherBlockSizeLen = (len - gap) / cipherBlockSize * cipherBlockSize;
cipherOutputStream.write(b, off + gap, multipleCipherBlockSizeLen);
gap += multipleCipherBlockSizeLen;
}
@@ -219,7 +219,7 @@ class AES256SHA256Decoder extends AbstractCoder {
}
@Override
- public void write(int b) throws IOException {
+ public void write(final int b) throws IOException {
cipherBlockBuffer[count++] = (byte) b;
if (count == cipherBlockSize) {
flushBuffer();
@@ -229,7 +229,7 @@ class AES256SHA256Decoder extends AbstractCoder {
}
@Override
- byte[] getOptionsAsProperties(Object options) throws IOException {
+ byte[] getOptionsAsProperties(final Object options) throws IOException {
final AES256Options opts = (AES256Options) options;
final byte[] props = new byte[2 + opts.getSalt().length + opts.getIv().length];
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
index 70ff3b14..d1063b8f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
@@ -120,7 +120,7 @@ public class SevenZArchiveEntry implements ArchiveEntry {
return false;
}
final Iterator<? extends SevenZMethodConfiguration> i2 = c2.iterator();
- for (SevenZMethodConfiguration element : c1) {
+ for (final SevenZMethodConfiguration element : c1) {
if (!i2.hasNext()) {
return false;
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
index 592fc803..c4790135 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
@@ -143,7 +143,7 @@ public class SevenZOutputFile implements Closeable {
* @throws IOException if opening the file fails
* @since 1.23
*/
- public SevenZOutputFile(final File fileName, char[] password) throws IOException {
+ public SevenZOutputFile(final File fileName, final char[] password) throws IOException {
this(
Files.newByteChannel(
fileName.toPath(),
@@ -180,7 +180,7 @@ public class SevenZOutputFile implements Closeable {
* @throws IOException if the channel cannot be positioned properly
* @since 1.23
*/
- public SevenZOutputFile(final SeekableByteChannel channel, char[] password) throws IOException {
+ public SevenZOutputFile(final SeekableByteChannel channel, final char[] password) throws IOException {
this.channel = channel;
channel.position(SevenZFile.SIGNATURE_HEADER_SIZE);
if (password != null) {
@@ -255,7 +255,7 @@ public class SevenZOutputFile implements Closeable {
entry.setName(entryName);
try {
fillDates(inputFile.toPath(), entry);
- } catch (IOException e) { // NOSONAR
+ } catch (final IOException e) { // NOSONAR
entry.setLastModifiedDate(new Date(inputFile.lastModified()));
}
return entry;
@@ -283,7 +283,7 @@ public class SevenZOutputFile implements Closeable {
private void fillDates(final Path inputPath, final SevenZArchiveEntry entry,
final LinkOption... options) throws IOException {
- BasicFileAttributes attributes = Files.readAttributes(inputPath, BasicFileAttributes.class, options);
+ final BasicFileAttributes attributes = Files.readAttributes(inputPath, BasicFileAttributes.class, options);
entry.setLastModifiedTime(attributes.lastModifiedTime());
entry.setCreationTime(attributes.creationTime());
entry.setAccessTime(attributes.lastAccessTime());
@@ -345,7 +345,7 @@ public class SevenZOutputFile implements Closeable {
Iterable<? extends SevenZMethodConfiguration> iter = ms == null ? contentMethods : ms;
if (aes256Options != null) {
- // prepend encryption
+ // prepend encryption
iter =
Stream
.concat(
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index 9efe9976..2474d0ca 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -694,7 +694,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
public void addPaxHeader(final String name, final String value) {
try {
processPaxHeader(name,value);
- } catch (IOException ex) {
+ } catch (final IOException ex) {
throw new IllegalArgumentException("Invalid input", ex);
}
}
@@ -781,7 +781,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
if (headers.containsKey(TarGnuSparseKeys.REALSIZE)) {
try {
realSize = Integer.parseInt(headers.get(TarGnuSparseKeys.REALSIZE));
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
throw new IOException("Corrupted TAR archive. GNU.sparse.realsize header for "
+ name + " contains non-numeric value");
}
@@ -793,7 +793,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
if (headers.containsKey("SCHILY.realsize")) {
try {
realSize = Long.parseLong(headers.get("SCHILY.realsize"));
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
throw new IOException("Corrupted TAR archive. SCHILY.realsize header for "
+ name + " contains non-numeric value");
}
@@ -855,7 +855,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
final List<TarArchiveEntry> entries = new ArrayList<>();
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(file)) {
- for (Path p : dirStream) {
+ for (final Path p : dirStream) {
entries.add(new TarArchiveEntry(p));
}
} catch (final IOException e) {
@@ -1284,15 +1284,14 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
// prefix[130] is is guaranteed to be '\0' with XSTAR/XUSTAR
if (header[XSTAR_PREFIX_OFFSET + 130] != 0) {
// except when typeflag is 'M'
- if (header[LF_OFFSET] == LF_MULTIVOLUME) {
- // We come only here if we try to read in a GNU/xstar/xustar multivolume archive starting past volume #0
- // As of 1.22, commons-compress does not support multivolume tar archives.
- // If/when it does, this should work as intended.
- if ((header[XSTAR_MULTIVOLUME_OFFSET] & 0x80) == 0
- && header[XSTAR_MULTIVOLUME_OFFSET + 11] != ' ') {
- return true;
- }
- } else {
+ if (header[LF_OFFSET] != LF_MULTIVOLUME) {
+ return true;
+ }
+ // We come only here if we try to read in a GNU/xstar/xustar multivolume archive starting past volume #0
+ // As of 1.22, commons-compress does not support multivolume tar archives.
+ // If/when it does, this should work as intended.
+ if ((header[XSTAR_MULTIVOLUME_OFFSET] & 0x80) == 0
+ && header[XSTAR_MULTIVOLUME_OFFSET + 11] != ' ') {
return true;
}
}
@@ -1505,7 +1504,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
throws IOException {
try {
parseTarHeaderUnwrapped(globalPaxHeaders, header, encoding, oldStyle, lenient);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
throw new IOException("Corrupted TAR archive.", ex);
}
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
index 7f0bbb8d..e39a544d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
@@ -346,7 +346,7 @@ public class TarFile implements Closeable {
// logical offset into the extracted entry
long offset = 0;
long numberOfZeroBytesInSparseEntry = 0;
- for (TarArchiveStructSparse sparseHeader : sparseHeaders) {
+ for (final TarArchiveStructSparse sparseHeader : sparseHeaders) {
final long zeroBlockSize = sparseHeader.getOffset() - offset;
if (zeroBlockSize < 0) {
// sparse header says to move backwards inside of the extracted entry
@@ -411,7 +411,7 @@ public class TarFile implements Closeable {
public InputStream getInputStream(final TarArchiveEntry entry) throws IOException {
try {
return new BoundedTarEntryInputStream(entry, archive);
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
throw new IOException("Corrupted TAR archive. Can't read entry", ex);
}
}
@@ -527,7 +527,7 @@ public class TarFile implements Closeable {
} else if (!globalPaxHeaders.isEmpty()) {
applyPaxHeadersToCurrentEntry(globalPaxHeaders, globalSparseHeaders);
}
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new IOException("Error detected parsing the pax header", e);
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index 68c62d58..e8f42696 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -443,8 +443,8 @@ public class TarUtils {
*/
protected static List<TarArchiveStructSparse> parseFromPAX01SparseHeaders(final String sparseMap)
throws IOException {
- List<TarArchiveStructSparse> sparseHeaders = new ArrayList<>();
- String[] sparseHeaderStrings = sparseMap.split(",");
+ final List<TarArchiveStructSparse> sparseHeaders = new ArrayList<>();
+ final String[] sparseHeaderStrings = sparseMap.split(",");
if (sparseHeaderStrings.length % 2 == 1) {
throw new IOException("Corrupted TAR archive. Bad format in GNU.sparse.map PAX Header");
}
@@ -453,7 +453,7 @@ public class TarUtils {
long sparseOffset;
try {
sparseOffset = Long.parseLong(sparseHeaderStrings[i]);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
throw new IOException("Corrupted TAR archive."
+ " Sparse struct offset contains a non-numeric value");
}
@@ -464,7 +464,7 @@ public class TarUtils {
long sparseNumbytes;
try {
sparseNumbytes = Long.parseLong(sparseHeaderStrings[i + 1]);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
throw new IOException("Corrupted TAR archive."
+ " Sparse struct numbytes contains a non-numeric value");
}
@@ -642,7 +642,7 @@ public class TarUtils {
protected static List<TarArchiveStructSparse> parsePAX01SparseHeaders(final String sparseMap) {
try {
return parseFromPAX01SparseHeaders(sparseMap);
- } catch (IOException ex) {
+ } catch (final IOException ex) {
throw new UncheckedIOException(ex.getMessage(), ex);
}
}
@@ -660,7 +660,7 @@ public class TarUtils {
*/
protected static List<TarArchiveStructSparse> parsePAX1XSparseHeaders(final InputStream inputStream, final int recordSize) throws IOException {
// for 1.X PAX Headers
- List<TarArchiveStructSparse> sparseHeaders = new ArrayList<>();
+ final List<TarArchiveStructSparse> sparseHeaders = new ArrayList<>();
long bytesRead = 0;
long[] readResult = readLineOfNumberForPax1X(inputStream);
@@ -690,7 +690,7 @@ public class TarUtils {
}
// skip the rest of this record data
- long bytesToSkip = recordSize - bytesRead % recordSize;
+ final long bytesToSkip = recordSize - bytesRead % recordSize;
IOUtils.skip(inputStream, bytesToSkip);
return sparseHeaders;
}
@@ -812,7 +812,7 @@ public class TarUtils {
}
try {
offset = Long.valueOf(value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
throw new IOException("Failed to read Paxheader."
+ TarGnuSparseKeys.OFFSET + " contains a non-numeric value");
}
@@ -831,7 +831,7 @@ public class TarUtils {
long numbytes;
try {
numbytes = Long.parseLong(value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
throw new IOException("Failed to read Paxheader."
+ TarGnuSparseKeys.NUMBYTES + " contains a non-numeric value.");
}
@@ -929,7 +929,7 @@ public class TarUtils {
throw new IOException("Corrupted TAR archive, sparse entry with negative numbytes");
}
sparseHeaders.add(sparseHeader);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// thrown internally by parseOctalOrBinary
throw new IOException("Corrupted TAR archive, sparse entry is invalid", ex);
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index 21adc992..18faaf01 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -815,7 +815,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
final byte[] extraData = readRange(extraLen);
try {
current.entry.setExtra(extraData);
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
final ZipException z = new ZipException("Invalid extra data in entry " + current.entry.getName());
z.initCause(ex);
throw z;
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index 14e949b6..e6b39576 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -802,7 +802,7 @@ public class ZipFile implements Closeable {
// entries is filled in populateFromCentralDirectory and
// never modified
final String name = ze.getName();
- LinkedList<ZipArchiveEntry> entriesOfThatName = nameMap.computeIfAbsent(name, k -> new LinkedList<>());
+ final LinkedList<ZipArchiveEntry> entriesOfThatName = nameMap.computeIfAbsent(name, k -> new LinkedList<>());
entriesOfThatName.addLast(ze);
});
}
@@ -1140,7 +1140,7 @@ public class ZipFile implements Closeable {
*/
private void positionAtCentralDirectory32()
throws IOException {
- long endOfCentralDirectoryRecordOffset = archive.position();
+ final long endOfCentralDirectoryRecordOffset = archive.position();
if (isSplitZipArchive) {
skipBytes(CFD_DISK_OFFSET);
shortBbuf.rewind();
@@ -1158,7 +1158,7 @@ public class ZipFile implements Closeable {
skipBytes(CFD_LENGTH_OFFSET);
wordBbuf.rewind();
IOUtils.readFully(archive, wordBbuf);
- long centralDirectoryLength = ZipLong.getValue(wordBuf);
+ final long centralDirectoryLength = ZipLong.getValue(wordBuf);
wordBbuf.rewind();
IOUtils.readFully(archive, wordBbuf);
@@ -1352,7 +1352,7 @@ public class ZipFile implements Closeable {
}
try {
ze.setCentralDirectoryExtra(cdExtraData);
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
final ZipException z = new ZipException("Invalid extra data in entry " + ze.getName());
z.initCause(ex);
throw z;
@@ -1398,7 +1398,7 @@ public class ZipFile implements Closeable {
}
try {
ze.setExtra(localExtraData);
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
final ZipException z = new ZipException("Invalid extra data in entry " + ze.getName());
z.initCause(ex);
throw z;
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java
index 1d101679..060c075a 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java
@@ -70,7 +70,7 @@ public class AttributeDefinitionBands extends BandSet {
final Map<String, String> fieldLayouts = new HashMap<>();
final Map<String, String> codeLayouts = new HashMap<>();
- for (Attribute attributePrototype : attributePrototypes) {
+ for (final Attribute attributePrototype : attributePrototypes) {
final NewAttribute newAttribute = (NewAttribute) attributePrototype;
if (!(newAttribute instanceof NewAttribute.ErrorAttribute)
&& !(newAttribute instanceof NewAttribute.PassAttribute)
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java b/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java
index 36dd11c3..b5901cdc 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java
@@ -295,7 +295,7 @@ public abstract class BandSet {
System.out.print("");
}
- for (BHSDCodec[] family : codecFamiliesToTry) {
+ for (final BHSDCodec[] family : codecFamiliesToTry) {
tryCodecs(name, band, defaultCodec, bandData, results, encoded, family);
if (timeToStop(results)) {
break;
@@ -668,13 +668,13 @@ public abstract class BandSet {
*/
private long[] flatten(final long[][] flags) {
int totalSize = 0;
- for (long[] flag : flags) {
+ for (final long[] flag : flags) {
totalSize += flag.length;
}
final long[] flatArray = new long[totalSize];
int index = 0;
- for (long[] flag : flags) {
- for (long element : flag) {
+ for (final long[] flag : flags) {
+ for (final long element : flag) {
flatArray[index] = element;
index++;
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/CPClass.java b/src/main/java/org/apache/commons/compress/harmony/pack200/CPClass.java
index a72f7a3b..a22ef4d9 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/CPClass.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/CPClass.java
@@ -29,7 +29,7 @@ public class CPClass extends CPConstant<CPClass> {
this.utf8 = utf8;
this.className = utf8.getUnderlyingString();
final char[] chars = className.toCharArray();
- for (char element : chars) {
+ for (final char element : chars) {
if (element <= 0x2D) {
isInnerClass = true;
return;
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java
index ea476a62..3fb42001 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java
@@ -358,7 +358,7 @@ public class ClassBands extends BandSet {
public void addClassAttribute(final NewAttribute attribute) {
// TODO: backwards calls
final String attributeName = attribute.type;
- for (NewAttributeBands bands : classAttributeBands) {
+ for (final NewAttributeBands bands : classAttributeBands) {
if (bands.getAttributeName().equals(attributeName)) {
bands.addAttribute(attribute);
final int flagIndex = bands.getFlagIndex();
@@ -379,7 +379,7 @@ public class ClassBands extends BandSet {
public void addCodeAttribute(final NewAttribute attribute) {
final String attributeName = attribute.type;
- for (NewAttributeBands bands : codeAttributeBands) {
+ for (final NewAttributeBands bands : codeAttributeBands) {
if (bands.getAttributeName().equals(attributeName)) {
bands.addAttribute(attribute);
final int flagIndex = bands.getFlagIndex();
@@ -422,7 +422,7 @@ public class ClassBands extends BandSet {
public void addFieldAttribute(final NewAttribute attribute) {
final String attributeName = attribute.type;
- for (NewAttributeBands bands : fieldAttributeBands) {
+ for (final NewAttributeBands bands : fieldAttributeBands) {
if (bands.getAttributeName().equals(attributeName)) {
bands.addAttribute(attribute);
final int flagIndex = bands.getFlagIndex();
@@ -504,7 +504,7 @@ public class ClassBands extends BandSet {
}
if (exceptions != null) {
methodExceptionNumber.add(exceptions.length);
- for (String exception : exceptions) {
+ for (final String exception : exceptions) {
methodExceptionClasses.add(cpBands.getCPClass(exception));
}
flags |= (1 << 18);
@@ -524,7 +524,7 @@ public class ClassBands extends BandSet {
public void addMethodAttribute(final NewAttribute attribute) {
final String attributeName = attribute.type;
- for (NewAttributeBands bands : methodAttributeBands) {
+ for (final NewAttributeBands bands : methodAttributeBands) {
if (bands.getAttributeName().equals(attributeName)) {
bands.addAttribute(attribute);
final int flagIndex = bands.getFlagIndex();
@@ -575,16 +575,16 @@ public class ClassBands extends BandSet {
}
private void createNewAttributeBands() throws IOException {
- for (AttributeDefinition def : attrBands.getClassAttributeLayouts()) {
+ for (final AttributeDefinition def : attrBands.getClassAttributeLayouts()) {
classAttributeBands.add(new NewAttributeBands(effort, cpBands, segment.getSegmentHeader(), def));
}
- for (AttributeDefinition def : attrBands.getMethodAttributeLayouts()) {
+ for (final AttributeDefinition def : attrBands.getMethodAttributeLayouts()) {
methodAttributeBands.add(new NewAttributeBands(effort, cpBands, segment.getSegmentHeader(), def));
}
- for (AttributeDefinition def : attrBands.getFieldAttributeLayouts()) {
+ for (final AttributeDefinition def : attrBands.getFieldAttributeLayouts()) {
fieldAttributeBands.add(new NewAttributeBands(effort, cpBands, segment.getSegmentHeader(), def));
}
- for (AttributeDefinition def : attrBands.getCodeAttributeLayouts()) {
+ for (final AttributeDefinition def : attrBands.getCodeAttributeLayouts()) {
codeAttributeBands.add(new NewAttributeBands(effort, cpBands, segment.getSegmentHeader(), def));
}
}
@@ -616,16 +616,16 @@ public class ClassBands extends BandSet {
renumberDoubleOffsetBci(codeHandlerStartP, codeHandlerEndPO, codeHandlerCatchPO, bciRenumbering,
labelsToOffsets);
- for (NewAttributeBands newAttributeBandSet : classAttributeBands) {
+ for (final NewAttributeBands newAttributeBandSet : classAttributeBands) {
newAttributeBandSet.renumberBci(bciRenumbering, labelsToOffsets);
}
- for (NewAttributeBands newAttributeBandSet : methodAttributeBands) {
+ for (final NewAttributeBands newAttributeBandSet : methodAttributeBands) {
newAttributeBandSet.renumberBci(bciRenumbering, labelsToOffsets);
}
- for (NewAttributeBands newAttributeBandSet : fieldAttributeBands) {
+ for (final NewAttributeBands newAttributeBandSet : fieldAttributeBands) {
newAttributeBandSet.renumberBci(bciRenumbering, labelsToOffsets);
}
- for (NewAttributeBands newAttributeBandSet : codeAttributeBands) {
+ for (final NewAttributeBands newAttributeBandSet : codeAttributeBands) {
newAttributeBandSet.renumberBci(bciRenumbering, labelsToOffsets);
}
}
@@ -750,11 +750,11 @@ public class ClassBands extends BandSet {
int innerN = 0;
final List<IcTuple> innerClasses = segment.getIcBands().getInnerClassesForOuter(cpClass.toString());
if (innerClasses != null) {
- for (IcTuple element : innerClasses) {
+ for (final IcTuple element : innerClasses) {
referencedInnerClasses.remove(element.C);
}
}
- for (CPClass inner : referencedInnerClasses) {
+ for (final CPClass inner : referencedInnerClasses) {
final IcTuple icTuple = segment.getIcBands().getIcTuple(inner);
if (icTuple != null && !icTuple.isAnonymous()) {
// should transmit an icLocal entry
@@ -829,30 +829,30 @@ public class ClassBands extends BandSet {
fieldAttributeBands.sort(comparator);
codeAttributeBands.sort(comparator);
- for (NewAttributeBands bands : classAttributeBands) {
+ for (final NewAttributeBands bands : classAttributeBands) {
if (bands.isUsedAtLeastOnce()) {
- for (int backwardsCallCount : bands.numBackwardsCalls()) {
+ for (final int backwardsCallCount : bands.numBackwardsCalls()) {
classAttrCalls.add(backwardsCallCount);
}
}
}
- for (NewAttributeBands bands : methodAttributeBands) {
+ for (final NewAttributeBands bands : methodAttributeBands) {
if (bands.isUsedAtLeastOnce()) {
- for (int backwardsCallCount : bands.numBackwardsCalls()) {
+ for (final int backwardsCallCount : bands.numBackwardsCalls()) {
methodAttrCalls.add(backwardsCallCount);
}
}
}
- for (NewAttributeBands bands : fieldAttributeBands) {
+ for (final NewAttributeBands bands : fieldAttributeBands) {
if (bands.isUsedAtLeastOnce()) {
- for (int backwardsCallCount : bands.numBackwardsCalls()) {
+ for (final int backwardsCallCount : bands.numBackwardsCalls()) {
fieldAttrCalls.add(backwardsCallCount);
}
}
}
- for (NewAttributeBands bands : codeAttributeBands) {
+ for (final NewAttributeBands bands : codeAttributeBands) {
if (bands.isUsedAtLeastOnce()) {
- for (int backwardsCallCount : bands.numBackwardsCalls()) {
+ for (final int backwardsCallCount : bands.numBackwardsCalls()) {
codeAttrCalls.add(backwardsCallCount);
}
}
@@ -925,7 +925,7 @@ public class ClassBands extends BandSet {
final int totalInterfaces = sum(class_interface_count);
final int[] classInterface = new int[totalInterfaces];
int k = 0;
- for (CPClass[] element : class_interface) {
+ for (final CPClass[] element : class_interface) {
if (element != null) {
for (final CPClass cpClass : element) {
classInterface[k] = cpClass.getIndex();
@@ -1007,7 +1007,7 @@ public class ClassBands extends BandSet {
if ((class_flags[index] & (1 << 22)) != 0) {
class_RIA_bands.removeLatest();
}
- for (Long flagsL : tempFieldFlags) {
+ for (final Long flagsL : tempFieldFlags) {
final long flags = flagsL.longValue();
if ((flags & (1 << 19)) != 0) {
fieldSignature.remove(fieldSignature.size() - 1);
@@ -1022,7 +1022,7 @@ public class ClassBands extends BandSet {
field_RIA_bands.removeLatest();
}
}
- for (Long flagsL : tempMethodFlags) {
+ for (final Long flagsL : tempMethodFlags) {
final long flags = flagsL.longValue();
if ((flags & (1 << 19)) != 0) {
methodSignature.remove(methodSignature.size() - 1);
@@ -1160,7 +1160,7 @@ public class ClassBands extends BandSet {
private int sum(final int[] ints) {
int sum = 0;
- for (int j : ints) {
+ for (final int j : ints) {
sum += j;
}
return sum;
@@ -1246,7 +1246,7 @@ public class ClassBands extends BandSet {
PackingUtils.log("Wrote " + encodedBand.length + " bytes from classFileVersionMajor["
+ classFileVersionMajor.size() + "]");
- for (NewAttributeBands classAttributeBand : classAttributeBands) {
+ for (final NewAttributeBands classAttributeBand : classAttributeBands) {
classAttributeBand.pack(out);
}
}
@@ -1350,7 +1350,7 @@ public class ClassBands extends BandSet {
PackingUtils.log("Wrote " + encodedBand.length + " bytes from code_LocalVariableTypeTable_slot["
+ codeLocalVariableTypeTableSlot.size() + "]");
- for (NewAttributeBands bands : codeAttributeBands) {
+ for (final NewAttributeBands bands : codeAttributeBands) {
bands.pack(out);
}
}
@@ -1420,7 +1420,7 @@ public class ClassBands extends BandSet {
field_RVA_bands.pack(out);
field_RIA_bands.pack(out);
- for (NewAttributeBands bands : fieldAttributeBands) {
+ for (final NewAttributeBands bands : fieldAttributeBands) {
bands.pack(out);
}
}
@@ -1458,7 +1458,7 @@ public class ClassBands extends BandSet {
method_RVPA_bands.pack(out);
method_RIPA_bands.pack(out);
method_AD_bands.pack(out);
- for (NewAttributeBands bands : methodAttributeBands) {
+ for (final NewAttributeBands bands : methodAttributeBands) {
bands.pack(out);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/Codec.java b/src/main/java/org/apache/commons/compress/harmony/pack200/Codec.java
index b3bb7a9b..85c25fd6 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/Codec.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/Codec.java
@@ -191,7 +191,7 @@ public abstract class Codec {
}
final byte[] encoded = new byte[total];
int index = 0;
- for (byte[] element : bytes) {
+ for (final byte[] element : bytes) {
System.arraycopy(element, 0, encoded, index, element.length);
index += element.length;
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/CodecEncoding.java b/src/main/java/org/apache/commons/compress/harmony/pack200/CodecEncoding.java
index a2cbd01f..9854d6ce 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/CodecEncoding.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/CodecEncoding.java
@@ -235,11 +235,11 @@ public class CodecEncoding {
specifier[1] = kx;
index++;
}
- for (int element : aSpecifier) {
+ for (final int element : aSpecifier) {
specifier[index] = element;
index++;
}
- for (int element : bSpecifier) {
+ for (final int element : bSpecifier) {
specifier[index] = element;
index++;
}
@@ -278,15 +278,15 @@ public class CodecEncoding {
+ tokenSpecifier.length];
specifier[0] = first;
int index = 1;
- for (int element : favouredSpecifier) {
+ for (final int element : favouredSpecifier) {
specifier[index] = element;
index++;
}
- for (int element : tokenSpecifier) {
+ for (final int element : tokenSpecifier) {
specifier[index] = element;
index++;
}
- for (int element : unfavouredSpecifier) {
+ for (final int element : unfavouredSpecifier) {
specifier[index] = element;
index++;
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/CpBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/CpBands.java
index 05c240f6..bef2cfe1 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/CpBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/CpBands.java
@@ -84,7 +84,7 @@ public class CpBands extends BandSet {
}
private void addCharacters(final List<Character> chars, final char[] charArray) {
- for (char element : charArray) {
+ for (final char element : charArray) {
chars.add(Character.valueOf(element));
}
}
@@ -98,7 +98,7 @@ public class CpBands extends BandSet {
}
private void addIndices() {
- for (Set<? extends ConstantPoolEntry> set : Arrays.asList(cp_Utf8, cp_Int, cp_Float, cp_Long, cp_Double,
+ for (final Set<? extends ConstantPoolEntry> set : Arrays.asList(cp_Utf8, cp_Int, cp_Float, cp_Long, cp_Double,
cp_String, cp_Class, cp_Signature, cp_Descr, cp_Field, cp_Method, cp_Imethod)) {
int j = 0;
for (final ConstantPoolEntry entry : set) {
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/FileBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/FileBands.java
index f1571a8c..b9c7f0fb 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/FileBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/FileBands.java
@@ -61,7 +61,7 @@ public class FileBands extends BandSet {
final int archiveModtime = segmentHeader.getArchive_modtime();
final Set<String> classNames = new HashSet<>();
- for (ClassReader reader : segmentUnit.getClassList()) {
+ for (final ClassReader reader : segmentUnit.getClassList()) {
classNames.add(reader.getClassName());
}
final CPUTF8 emptyString = cpBands.getCPUtf8("");
@@ -125,13 +125,13 @@ public class FileBands extends BandSet {
private int[] flatten(final byte[][] bytes) {
int total = 0;
- for (byte[] element : bytes) {
+ for (final byte[] element : bytes) {
total += element.length;
}
final int[] band = new int[total];
int index = 0;
- for (byte[] element : bytes) {
- for (byte element2 : element) {
+ for (final byte[] element : bytes) {
+ for (final byte element2 : element) {
band[index++] = element2 & 0xFF;
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java
index fb7fc455..5a86021b 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java
@@ -113,7 +113,7 @@ public class IcBands extends BandSet {
outerToInner.put(outerName, tuples);
tuples.add(icTuple);
} else {
- for (IcTuple tuple : tuples) {
+ for (final IcTuple tuple : tuples) {
if (icTuple.equals(tuple)) {
return;
}
@@ -131,7 +131,7 @@ public class IcBands extends BandSet {
}
public IcTuple getIcTuple(final CPClass inner) {
- for (IcTuple icTuple : innerClasses) {
+ for (final IcTuple icTuple : innerClasses) {
if (icTuple.C.equals(inner)) {
return icTuple;
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/MetadataBandGroup.java b/src/main/java/org/apache/commons/compress/harmony/pack200/MetadataBandGroup.java
index 88f893be..b80993f0 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/MetadataBandGroup.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/MetadataBandGroup.java
@@ -93,7 +93,7 @@ public class MetadataBandGroup extends BandSet {
nameRU.forEach(name -> name_RU.add(cpBands.getCPUtf8(name)));
final Iterator<Object> valuesIterator = values.iterator();
- for (String tag : tags) {
+ for (final String tag : tags) {
T.add(tag);
switch (tag) {
case "B":
@@ -132,14 +132,14 @@ public class MetadataBandGroup extends BandSet {
}
// do nothing here for [ or @ (handled below)
}
- for (Integer element : caseArrayN) {
+ for (final Integer element : caseArrayN) {
final int arraySize = element.intValue();
casearray_N.add(arraySize);
numBackwardsCalls += arraySize;
}
nestTypeRS.forEach(element -> nesttype_RS.add(cpBands.getCPSignature(element)));
nestNameRU.forEach(element -> nestname_RU.add(cpBands.getCPUtf8(element)));
- for (Integer numPairs : nestPairN) {
+ for (final Integer numPairs : nestPairN) {
nestpair_N.add(numPairs.intValue());
numBackwardsCalls += numPairs.intValue();
}
@@ -165,14 +165,14 @@ public class MetadataBandGroup extends BandSet {
final List<Integer> caseArrayN, final List<String> nestTypeRS, final List<String> nestNameRU,
final List<Integer> nestPairN) {
param_NB.add(numParams);
- for (int element : annoN) {
+ for (final int element : annoN) {
anno_N.add(element);
}
pair_N.addAll(pairN);
typeRS.forEach(desc -> type_RS.add(cpBands.getCPSignature(desc)));
nameRU.forEach(name -> name_RU.add(cpBands.getCPUtf8(name)));
final Iterator<Object> valuesIterator = values.iterator();
- for (String tag : tags) {
+ for (final String tag : tags) {
T.add(tag);
switch (tag) {
case "B":
@@ -211,14 +211,14 @@ public class MetadataBandGroup extends BandSet {
}
// do nothing here for [ or @ (handled below)
}
- for (Integer element : caseArrayN) {
+ for (final Integer element : caseArrayN) {
final int arraySize = element.intValue();
casearray_N.add(arraySize);
numBackwardsCalls += arraySize;
}
nestTypeRS.forEach(type -> nesttype_RS.add(cpBands.getCPSignature(type)));
nestNameRU.forEach(name -> nestname_RU.add(cpBands.getCPUtf8(name)));
- for (Integer numPairs : nestPairN) {
+ for (final Integer numPairs : nestPairN) {
nestpair_N.add(numPairs.intValue());
numBackwardsCalls += numPairs.intValue();
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/NewAttributeBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/NewAttributeBands.java
index 95c3ba5e..6f7aec08 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/NewAttributeBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/NewAttributeBands.java
@@ -105,7 +105,7 @@ public class NewAttributeBands extends BandSet {
@Override
public void addAttributeToBand(final NewAttribute attribute, final InputStream inputStream) {
- for (AttributeLayoutElement element : body) {
+ for (final AttributeLayoutElement element : body) {
element.addAttributeToBand(attribute, inputStream);
}
}
@@ -124,14 +124,14 @@ public class NewAttributeBands extends BandSet {
@Override
public void pack(final OutputStream outputStream) throws IOException, Pack200Exception {
- for (AttributeLayoutElement element : body) {
+ for (final AttributeLayoutElement element : body) {
element.pack(outputStream);
}
}
@Override
public void renumberBci(final IntList bciRenumbering, final Map<Label, Integer> labelsToOffsets) {
- for (AttributeLayoutElement element : body) {
+ for (final AttributeLayoutElement element : body) {
element.renumberBci(bciRenumbering, labelsToOffsets);
}
}
@@ -181,9 +181,7 @@ public class NewAttributeBands extends BandSet {
value = readInteger(2, inputStream) & 0xFFFF; // unsigned short
} else if (tag.equals("SH")) {
value = readInteger(2, inputStream);
- } else if (tag.equals("I") || tag.equals("FI")) {
- value = readInteger(4, inputStream);
- } else if (tag.equals("SI")) {
+ } else if ((tag.equals("I") || tag.equals("FI")) || tag.equals("SI")) {
value = readInteger(4, inputStream);
} else if (tag.equals("V") || tag.equals("FV") || tag.equals("SV")) {
// Not currently supported
@@ -366,7 +364,7 @@ public class NewAttributeBands extends BandSet {
countElement.addAttributeToBand(attribute, inputStream);
final int count = countElement.latestValue();
for (int i = 0; i < count; i++) {
- for (AttributeLayoutElement layoutElement : layoutElements) {
+ for (final AttributeLayoutElement layoutElement : layoutElements) {
layoutElement.addAttributeToBand(attribute, inputStream);
}
}
@@ -383,14 +381,14 @@ public class NewAttributeBands extends BandSet {
@Override
public void pack(final OutputStream out) throws IOException, Pack200Exception {
countElement.pack(out);
- for (AttributeLayoutElement layoutElement : layoutElements) {
+ for (final AttributeLayoutElement layoutElement : layoutElements) {
layoutElement.pack(out);
}
}
@Override
public void renumberBci(final IntList bciRenumbering, final Map<Label, Integer> labelsToOffsets) {
- for (AttributeLayoutElement layoutElement : layoutElements) {
+ for (final AttributeLayoutElement layoutElement : layoutElements) {
layoutElement.renumberBci(bciRenumbering, labelsToOffsets);
}
}
@@ -416,14 +414,14 @@ public class NewAttributeBands extends BandSet {
unionTag.addAttributeToBand(attribute, inputStream);
final long tag = unionTag.latestValue();
boolean defaultCase = true;
- for (UnionCase unionCase : unionCases) {
+ for (final UnionCase unionCase : unionCases) {
if (unionCase.hasTag(tag)) {
defaultCase = false;
unionCase.addAttributeToBand(attribute, inputStream);
}
}
if (defaultCase) {
- for (LayoutElement layoutElement : defaultCaseBody) {
+ for (final LayoutElement layoutElement : defaultCaseBody) {
layoutElement.addAttributeToBand(attribute, inputStream);
}
}
@@ -444,20 +442,20 @@ public class NewAttributeBands extends BandSet {
@Override
public void pack(final OutputStream outputStream) throws IOException, Pack200Exception {
unionTag.pack(outputStream);
- for (UnionCase unionCase : unionCases) {
+ for (final UnionCase unionCase : unionCases) {
unionCase.pack(outputStream);
}
- for (LayoutElement element : defaultCaseBody) {
+ for (final LayoutElement element : defaultCaseBody) {
element.pack(outputStream);
}
}
@Override
public void renumberBci(final IntList bciRenumbering, final Map<Label, Integer> labelsToOffsets) {
- for (UnionCase unionCase : unionCases) {
+ for (final UnionCase unionCase : unionCases) {
unionCase.renumberBci(bciRenumbering, labelsToOffsets);
}
- for (LayoutElement element : defaultCaseBody) {
+ for (final LayoutElement element : defaultCaseBody) {
element.renumberBci(bciRenumbering, labelsToOffsets);
}
}
@@ -484,7 +482,7 @@ public class NewAttributeBands extends BandSet {
@Override
public void addAttributeToBand(final NewAttribute attribute, final InputStream inputStream) {
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.addAttributeToBand(attribute, inputStream);
}
}
@@ -499,14 +497,14 @@ public class NewAttributeBands extends BandSet {
@Override
public void pack(final OutputStream outputStream) throws IOException, Pack200Exception {
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.pack(outputStream);
}
}
@Override
public void renumberBci(final IntList bciRenumbering, final Map<Label, Integer> labelsToOffsets) {
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.renumberBci(bciRenumbering, labelsToOffsets);
}
}
@@ -536,7 +534,7 @@ public class NewAttributeBands extends BandSet {
public void addAttribute(final NewAttribute attribute) {
usedAtLeastOnce = true;
final InputStream stream = new ByteArrayInputStream(attribute.getBytes());
- for (AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
+ for (final AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
attributeLayoutElement.addAttributeToBand(attribute, stream);
}
}
@@ -583,7 +581,7 @@ public class NewAttributeBands extends BandSet {
final StringBuilder sb = new StringBuilder();
int foundBracket = -1;
while (foundBracket != 0) {
- int read = reader.read();
+ final int read = reader.read();
if (read == -1) {
break;
}
@@ -611,7 +609,7 @@ public class NewAttributeBands extends BandSet {
@Override
public void pack(final OutputStream outputStream) throws IOException, Pack200Exception {
- for (AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
+ for (final AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
attributeLayoutElement.pack(outputStream);
}
}
@@ -840,7 +838,7 @@ public class NewAttributeBands extends BandSet {
final StringBuilder sb = new StringBuilder();
int foundBracket = -1;
while (foundBracket != 0) {
- int read = reader.read();
+ final int read = reader.read();
if (read == -1) {
break;
}
@@ -865,7 +863,7 @@ public class NewAttributeBands extends BandSet {
* @param labelsToOffsets TODO
*/
public void renumberBci(final IntList bciRenumbering, final Map<Label, Integer> labelsToOffsets) {
- for (AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
+ for (final AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
attributeLayoutElement.renumberBci(bciRenumbering, labelsToOffsets);
}
}
@@ -881,14 +879,14 @@ public class NewAttributeBands extends BandSet {
if (element instanceof Callable) {
final Callable callable = (Callable) element;
final List<LayoutElement> body = callable.body; // Look for calls in the body
- for (LayoutElement layoutElement : body) {
+ for (final LayoutElement layoutElement : body) {
// Set the callable for each call
resolveCallsForElement(i, callable, layoutElement);
}
}
}
int backwardsCallableIndex = 0;
- for (AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
+ for (final AttributeLayoutElement attributeLayoutElement : attributeLayoutElements) {
if (attributeLayoutElement instanceof Callable) {
final Callable callable = (Callable) attributeLayoutElement;
if (callable.isBackwardsCallable) {
@@ -932,7 +930,7 @@ public class NewAttributeBands extends BandSet {
}
} else if (layoutElement instanceof Replication) {
final List<LayoutElement> children = ((Replication) layoutElement).layoutElements;
- for (LayoutElement child : children) {
+ for (final LayoutElement child : children) {
resolveCallsForElement(i, currentCallable, child);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingUtils.java b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingUtils.java
index 8555e3f4..366c1166 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingUtils.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingUtils.java
@@ -93,7 +93,7 @@ public class PackingUtils {
final byte[] bytes = new byte[16384];
final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
- JarEntry jarEntry = entries.nextElement();
+ final JarEntry jarEntry = entries.nextElement();
jarOutputStream.putNextEntry(jarEntry);
try (InputStream inputStream = jarFile.getInputStream(jarEntry)) {
int bytesRead;
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java b/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java
index f4103538..bd9cfd3e 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java
@@ -636,7 +636,7 @@ public class Segment extends ClassVisitor {
private void processClasses(final SegmentUnit segmentUnit, final Attribute[] attributes) throws Pack200Exception {
segmentHeader.setClass_count(segmentUnit.classListSize());
- for (Pack200ClassReader classReader : segmentUnit.getClassList()) {
+ for (final Pack200ClassReader classReader : segmentUnit.getClassList()) {
currentClassReader = classReader;
int flags = 0;
if (stripDebug) {
@@ -652,7 +652,7 @@ public class Segment extends ClassVisitor {
options.addPassFile(name);
cpBands.addCPUtf8(name);
boolean found = false;
- for (PackingFile file : segmentUnit.getFileList()) {
+ for (final PackingFile file : segmentUnit.getFileList()) {
if (file.getName().equals(name)) {
found = true;
file.setContents(classReader.b);
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
index c80d4266..d9b7c579 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
@@ -106,9 +106,7 @@ public class Archive {
}
public void setQuiet(final boolean quiet) {
- if (quiet) {
- logLevel = Segment.LOG_LEVEL_QUIET;
- } else if (logLevel == Segment.LOG_LEVEL_QUIET) {
+ if (quiet || (logLevel == Segment.LOG_LEVEL_QUIET)) {
logLevel = Segment.LOG_LEVEL_QUIET;
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java
index ae838e92..02735c62 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java
@@ -134,7 +134,7 @@ public class AttributeLayoutMap {
private final Map<AttributeLayout, NewAttributeBands> layoutsToBands = new HashMap<>();
public AttributeLayoutMap() throws Pack200Exception {
- for (AttributeLayout defaultAttributeLayout : getDefaultAttributeLayouts()) {
+ for (final AttributeLayout defaultAttributeLayout : getDefaultAttributeLayouts()) {
add(defaultAttributeLayout);
}
}
@@ -186,7 +186,7 @@ public class AttributeLayoutMap {
public AttributeLayout getAttributeLayout(final String name, final int context) {
final Map<Integer, AttributeLayout> map = getLayout(context);
- for (AttributeLayout layout : map.values()) {
+ for (final AttributeLayout layout : map.values()) {
if (layout.getName().equals(name)) {
return layout;
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
index a71a2693..3b1da874 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
@@ -133,7 +133,7 @@ public abstract class BandSet {
final int[] counts) throws IOException, Pack200Exception {
final int[][] result = new int[counts.length][];
int totalCount = 0;
- for (int count : counts) {
+ for (final int count : counts) {
totalCount += count;
}
final int[] twoDResult = decodeBandInt(name, in, defaultCodec, totalCount);
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java
index 6ec06dd1..d36a5f0f 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java
@@ -504,7 +504,7 @@ public class BcBands extends BandSet {
final List<Attribute> methodAttributesList = methodAttributes[c][m];
// Make sure we add the code attribute in the right place
int indexForCodeAttr = 0;
- for (Attribute attribute : methodAttributesList) {
+ for (final Attribute attribute : methodAttributesList) {
if (!(attribute instanceof NewAttribute)
|| (((NewAttribute) attribute).getLayoutIndex() >= 15)) {
break;
@@ -522,7 +522,7 @@ public class BcBands extends BandSet {
} else {
currentAttributes = Collections.EMPTY_LIST;
}
- for (Attribute currentAttribute : currentAttributes) {
+ for (final Attribute currentAttribute : currentAttributes) {
codeAttr.addAttribute(currentAttribute);
// Fix up the line numbers if needed
if (currentAttribute.hasBCIRenumbering()) {
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
index 82ba9f89..8a3355ab 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
@@ -133,15 +133,15 @@ public class ClassBands extends BandSet {
private int getCallCount(final int[][] methodAttrIndexes, final long[][] flags, final int context) {
int callCount = 0;
- for (int[] element : methodAttrIndexes) {
+ for (final int[] element : methodAttrIndexes) {
for (final int index : element) {
final AttributeLayout layout = attrMap.getAttributeLayout(index, context);
callCount += layout.numBackwardsCallables();
}
}
int layoutsUsed = 0;
- for (long[] flag : flags) {
- for (long element : flag) {
+ for (final long[] flag : flags) {
+ for (final long element : flag) {
layoutsUsed |= element;
}
}
@@ -373,8 +373,8 @@ public class ClassBands extends BandSet {
final int[][] classInnerClassesF = decodeBandInt("class_InnerClasses_F", in, Codec.UNSIGNED5,
classInnerClassesN);
int flagsCount = 0;
- for (int[] element : classInnerClassesF) {
- for (int element2 : element) {
+ for (final int[] element : classInnerClassesF) {
+ for (final int element2 : element) {
if (element2 != 0) {
flagsCount++;
}
@@ -504,7 +504,7 @@ public class ClassBands extends BandSet {
// Get from icBands
final IcBands icBands = segment.getIcBands();
final IcTuple[] icAll = icBands.getIcTuples();
- for (IcTuple element : icAll) {
+ for (final IcTuple element : icAll) {
if (element.getC().equals(icTupleC)) {
icTupleF = element.getF();
icTupleC2 = element.getC2();
@@ -597,7 +597,7 @@ public class ClassBands extends BandSet {
final int[] codeAttrCounts = decodeBandInt("code_attr_count", in, Codec.UNSIGNED5, codeAttrCount);
final int[][] codeAttrIndexes = decodeBandInt("code_attr_indexes", in, Codec.UNSIGNED5, codeAttrCounts);
int callCount = 0;
- for (int[] element : codeAttrIndexes) {
+ for (final int[] element : codeAttrIndexes) {
for (final int index : element) {
final AttributeLayout layout = attrMap.getAttributeLayout(index, AttributeLayout.CONTEXT_CODE);
callCount += layout.numBackwardsCallables();
@@ -958,8 +958,8 @@ public class ClassBands extends BandSet {
mbg[i].type_RS = parseCPSignatureReferences(contextName + "_" + rxa + "_type_RS", in, Codec.UNSIGNED5,
mbg[i].anno_N);
mbg[i].pair_N = decodeBandInt(contextName + "_" + rxa + "_pair_N", in, Codec.UNSIGNED5, mbg[i].anno_N);
- for (int[] element : mbg[i].pair_N) {
- for (int element2 : element) {
+ for (final int[] element : mbg[i].pair_N) {
+ for (final int element2 : element) {
pairCount += element2;
}
}
@@ -973,7 +973,7 @@ public class ClassBands extends BandSet {
pairCount + backwardsCallCounts[i]);
int ICount = 0, DCount = 0, FCount = 0, JCount = 0, cCount = 0, eCount = 0, sCount = 0, arrayCount = 0,
atCount = 0;
- for (int element : mbg[i].T) {
+ for (final int element : mbg[i].T) {
final char c = (char) element;
switch (c) {
case 'B':
@@ -1028,7 +1028,7 @@ public class ClassBands extends BandSet {
atCount);
mbg[i].nestpair_N = decodeBandInt(contextName + "_" + rxa + "_nestpair_N", in, Codec.UNSIGNED5, atCount);
int nestPairCount = 0;
- for (int element : mbg[i].nestpair_N) {
+ for (final int element : mbg[i].nestpair_N) {
nestPairCount += element;
}
mbg[i].nestname_RU = parseCPUTF8References(contextName + "_" + rxa + "_nestname_RU", in, Codec.UNSIGNED5,
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java
index 9dcd71dd..6578ff64 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java
@@ -487,7 +487,7 @@ public class CpBands extends BandSet {
for (int i = 0; i < cpSignatureCount; i++) {
final String form = cpSignatureForm[i];
final char[] chars = form.toCharArray();
- for (char element : chars) {
+ for (final char element : chars) {
if (element == 'L') {
cpSignatureInts[i] = -1;
lCount++;
@@ -547,7 +547,7 @@ public class CpBands extends BandSet {
int bigSuffixCount = 0;
final int[] suffix = decodeBandInt("cpUTF8Suffix", in, Codec.UNSIGNED5, cpUTF8Count - 1);
- for (int element : suffix) {
+ for (final int element : suffix) {
if (element == 0) {
bigSuffixCount++;
} else {
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java
index 9ff252c9..89d2f081 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java
@@ -94,7 +94,7 @@ public class IcTuple {
throw new Error("Should have an outer before checking if it's anonymous");
}
- for (String element : result) {
+ for (final String element : result) {
if (isAllDigits(element)) {
return true;
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/MetadataBandGroup.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/MetadataBandGroup.java
index c771469e..a77efd92 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/MetadataBandGroup.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/MetadataBandGroup.java
@@ -165,12 +165,12 @@ public class MetadataBandGroup {
} else if (type.equals("RVPA") || type.equals("RIPA")) {
anno_N_Index = 0;
pair_N_Index = 0;
- for (int element : param_NB) {
+ for (final int element : param_NB) {
attributes.add(getParameterAttribute(element, name_RU_Iterator));
}
}
} else if (type.equals("AD")) {
- for (int element : T) {
+ for (final int element : T) {
attributes.add(new AnnotationDefaultAttribute(new ElementValue(element, getNextValue(element))));
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java
index 926a3510..45dfb602 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java
@@ -144,7 +144,7 @@ public class NewAttributeBands extends BandSet {
* @param attribute TODO
*/
public void addNextToAttribute(final NewAttribute attribute) {
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.addToAttribute(index, attribute);
}
index++;
@@ -154,7 +154,7 @@ public class NewAttributeBands extends BandSet {
public void addToAttribute(final int n, final NewAttribute attribute) {
if (isFirstCallable) {
// Ignore n because bands also contain element parts from calls
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.addToAttribute(index, attribute);
}
index++;
@@ -176,7 +176,7 @@ public class NewAttributeBands extends BandSet {
} else {
count = this.count;
}
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.readBands(in, count);
}
}
@@ -214,9 +214,7 @@ public class NewAttributeBands extends BandSet {
attribute.addInteger(2, value);
} else if (tag.equals("SH")) {
attribute.addInteger(2, (short) value);
- } else if (tag.equals("I") || tag.equals("FI")) {
- attribute.addInteger(4, value);
- } else if (tag.equals("SI")) {
+ } else if ((tag.equals("I") || tag.equals("FI")) || tag.equals("SI")) {
attribute.addInteger(4, value);
} else if (tag.equals("V") || tag.equals("FV") || tag.equals("SV")) {
// Don't add V's - they shouldn't be written out to the class
@@ -400,7 +398,7 @@ public class NewAttributeBands extends BandSet {
}
final long numElements = countElement.getValue(index);
for (int i = offset; i < offset + numElements; i++) {
- for (LayoutElement layoutElement : layoutElements) {
+ for (final LayoutElement layoutElement : layoutElements) {
layoutElement.addToAttribute(i, attribute);
}
}
@@ -421,7 +419,7 @@ public class NewAttributeBands extends BandSet {
for (int i = 0; i < count; i++) {
arrayCount += countElement.getValue(i);
}
- for (LayoutElement layoutElement : layoutElements) {
+ for (final LayoutElement layoutElement : layoutElements) {
layoutElement.readBands(in, arrayCount);
}
}
@@ -451,7 +449,7 @@ public class NewAttributeBands extends BandSet {
final int[] tagBand = unionTag.band;
final int tag = unionTag.getValue(n);
boolean defaultCase = true;
- for (UnionCase unionCase : unionCases) {
+ for (final UnionCase unionCase : unionCases) {
if (unionCase.hasTag(tag)) {
defaultCase = false;
for (int j = 0; j < n; j++) {
@@ -467,7 +465,7 @@ public class NewAttributeBands extends BandSet {
int defaultOffset = 0;
for (int j = 0; j < n; j++) {
boolean found = false;
- for (UnionCase unionCase : unionCases) {
+ for (final UnionCase unionCase : unionCases) {
if (unionCase.hasTag(tagBand[j])) {
found = true;
}
@@ -477,7 +475,7 @@ public class NewAttributeBands extends BandSet {
}
}
if (defaultCaseBody != null) {
- for (LayoutElement element : defaultCaseBody) {
+ for (final LayoutElement element : defaultCaseBody) {
element.addToAttribute(defaultOffset, attribute);
}
}
@@ -504,7 +502,7 @@ public class NewAttributeBands extends BandSet {
caseCounts = new int[unionCases.size()];
for (int i = 0; i < caseCounts.length; i++) {
final UnionCase unionCase = unionCases.get(i);
- for (int value : values) {
+ for (final int value : values) {
if (unionCase.hasTag(value)) {
caseCounts[i]++;
}
@@ -512,9 +510,9 @@ public class NewAttributeBands extends BandSet {
unionCase.readBands(in, caseCounts[i]);
}
// Count number of default cases then read the default bands
- for (int value : values) {
+ for (final int value : values) {
boolean found = false;
- for (UnionCase unionCase : unionCases) {
+ for (final UnionCase unionCase : unionCases) {
if (unionCase.hasTag(value)) {
found = true;
}
@@ -524,7 +522,7 @@ public class NewAttributeBands extends BandSet {
}
}
if (defaultCaseBody != null) {
- for (LayoutElement element : defaultCaseBody) {
+ for (final LayoutElement element : defaultCaseBody) {
element.readBands(in, defaultCount);
}
}
@@ -553,7 +551,7 @@ public class NewAttributeBands extends BandSet {
@Override
public void addToAttribute(final int index, final NewAttribute attribute) {
if (body != null) {
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.addToAttribute(index, attribute);
}
}
@@ -574,7 +572,7 @@ public class NewAttributeBands extends BandSet {
@Override
public void readBands(final InputStream in, final int count) throws IOException, Pack200Exception {
if (body != null) {
- for (LayoutElement element : body) {
+ for (final LayoutElement element : body) {
element.readBands(in, count);
}
}
@@ -631,7 +629,7 @@ public class NewAttributeBands extends BandSet {
private Attribute getOneAttribute(final int index, final List<AttributeLayoutElement> elements) {
final NewAttribute attribute = new NewAttribute(segment.getCpBands().cpUTF8Value(attributeLayout.getName()),
attributeLayout.getIndex());
- for (AttributeLayoutElement element : elements) {
+ for (final AttributeLayoutElement element : elements) {
element.addToAttribute(index, attribute);
}
return attribute;
@@ -649,7 +647,7 @@ public class NewAttributeBands extends BandSet {
final StringBuilder sb = new StringBuilder();
int foundBracket = -1;
while (foundBracket != 0) {
- int read = stream.read();
+ final int read = stream.read();
if (read == -1) {
break;
}
@@ -678,7 +676,7 @@ public class NewAttributeBands extends BandSet {
* @throws Pack200Exception TODO
*/
public List<Attribute> parseAttributes(final InputStream in, final int occurrenceCount) throws IOException, Pack200Exception {
- for (AttributeLayoutElement element : attributeLayoutElements) {
+ for (final AttributeLayoutElement element : attributeLayoutElements) {
element.readBands(in, occurrenceCount);
}
@@ -904,7 +902,7 @@ public class NewAttributeBands extends BandSet {
final StringBuilder sb = new StringBuilder();
int foundBracket = -1;
while (foundBracket != 0) {
- int read = stream.read();
+ final int read = stream.read();
if (read == -1) {
break;
}
@@ -935,7 +933,7 @@ public class NewAttributeBands extends BandSet {
callable.setFirstCallable(true);
}
// Look for calls in the body
- for (LayoutElement layoutElement : callable.body) {
+ for (final LayoutElement layoutElement : callable.body) {
// Set the callable for each call
backwardsCalls += resolveCallsForElement(i, callable, layoutElement);
}
@@ -978,7 +976,7 @@ public class NewAttributeBands extends BandSet {
}
} else if (layoutElement instanceof Replication) {
final List<LayoutElement> children = ((Replication) layoutElement).layoutElements;
- for (LayoutElement child : children) {
+ for (final LayoutElement child : children) {
backwardsCalls += resolveCallsForElement(i, currentCallable, child);
}
}
@@ -996,7 +994,7 @@ public class NewAttributeBands extends BandSet {
public void setBackwardsCalls(final int[] backwardsCalls) throws IOException {
int index = 0;
parseLayout();
- for (AttributeLayoutElement element : attributeLayoutElements) {
+ for (final AttributeLayoutElement element : attributeLayoutElements) {
if (element instanceof Callable && ((Callable) element).isBackwardsCallable()) {
((Callable) element).addCount(backwardsCalls[index]);
index++;
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java
index 14bbf1a5..3f29fc04 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java
@@ -130,7 +130,7 @@ public class Segment {
// Get the source file attribute
final List<Attribute> classAttributes = classBands.getClassAttributes()[classNum];
SourceFileAttribute sourceFileAttribute = null;
- for (Attribute classAttribute : classAttributes) {
+ for (final Attribute classAttribute : classAttributes) {
if (classAttribute.isSourceFileAttribute()) {
sourceFileAttribute = ((SourceFileAttribute) classAttribute);
}
@@ -226,7 +226,7 @@ public class Segment {
final InnerClassesAttribute innerClassesAttribute = new InnerClassesAttribute("InnerClasses");
final IcTuple[] ic_relevant = getIcBands().getRelevantIcTuples(fullName, cp);
final List<IcTuple> ic_stored = computeIcStored(ic_local, ic_relevant);
- for (IcTuple icStored : ic_stored) {
+ for (final IcTuple icStored : ic_stored) {
final int innerClassIndex = icStored.thisClassIndex();
final int outerClassIndex = icStored.outerClassIndex();
final int simpleClassNameIndex = icStored.simpleClassNameIndex();
@@ -311,7 +311,7 @@ public class Segment {
// add ic_local
if (ic_local != null) {
- for (IcTuple element : ic_local) {
+ for (final IcTuple element : ic_local) {
if (isInResult.add(element)) {
result.add(element);
}
@@ -319,7 +319,7 @@ public class Segment {
}
// add ic_relevant
- for (IcTuple element : ic_relevant) {
+ for (final IcTuple element : ic_relevant) {
if (isInResult.add(element)) {
result.add(element);
} else {
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java
index 2a9a7f54..2463faff 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java
@@ -275,7 +275,7 @@ public class SegmentConstantPool {
return -1;
}
- for (Integer element : indexList) {
+ for (final Integer element : indexList) {
final int arrayIndex = element.intValue();
if (regexMatches(secondaryCompareRegex, secondaryArray[arrayIndex])) {
instanceCount++;
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentUtils.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentUtils.java
index e803743b..3371e3c6 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentUtils.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentUtils.java
@@ -70,7 +70,7 @@ public final class SegmentUtils {
public static int countBit16(final int[] flags) {
int count = 0;
- for (int flag : flags) {
+ for (final int flag : flags) {
if ((flag & (1 << 16)) != 0) {
count++;
}
@@ -80,7 +80,7 @@ public final class SegmentUtils {
public static int countBit16(final long[] flags) {
int count = 0;
- for (long flag : flags) {
+ for (final long flag : flags) {
if ((flag & (1 << 16)) != 0) {
count++;
}
@@ -90,8 +90,8 @@ public final class SegmentUtils {
public static int countBit16(final long[][] flags) {
int count = 0;
- for (long[] flag : flags) {
- for (long element : flag) {
+ for (final long[] flag : flags) {
+ for (final long element : flag) {
if ((element & (1 << 16)) != 0) {
count++;
}
@@ -106,7 +106,7 @@ public final class SegmentUtils {
public static int countMatches(final long[] flags, final IMatcher matcher) {
int count = 0;
- for (long flag : flags) {
+ for (final long flag : flags) {
if (matcher.matches(flag)) {
count++;
}
@@ -116,7 +116,7 @@ public final class SegmentUtils {
public static int countMatches(final long[][] flags, final IMatcher matcher) {
int count = 0;
- for (long[] flag : flags) {
+ for (final long[] flag : flags) {
count += countMatches(flag, matcher);
}
return count;
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/AnnotationsAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/AnnotationsAttribute.java
index bbc7a210..5e55e7ef 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/AnnotationsAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/AnnotationsAttribute.java
@@ -112,7 +112,7 @@ public abstract class AnnotationsAttribute extends Attribute {
entries.add(value);
} else if (value instanceof ElementValue[]) {
final ElementValue[] values = (ElementValue[]) value;
- for (ElementValue value2 : values) {
+ for (final ElementValue value2 : values) {
entries.addAll(value2.getClassFileEntries());
}
} else if (value instanceof Annotation) {
@@ -139,7 +139,7 @@ public abstract class AnnotationsAttribute extends Attribute {
case '[':
int length = 3;
final ElementValue[] nestedValues = (ElementValue[]) value;
- for (ElementValue nestedValue : nestedValues) {
+ for (final ElementValue nestedValue : nestedValues) {
length += nestedValue.getLength();
}
return length;
@@ -165,7 +165,7 @@ public abstract class AnnotationsAttribute extends Attribute {
((Annotation) value).resolve(pool);
} else if (value instanceof ElementValue[]) {
final ElementValue[] nestedValues = (ElementValue[]) value;
- for (ElementValue nestedValue : nestedValues) {
+ for (final ElementValue nestedValue : nestedValues) {
nestedValue.resolve(pool);
}
}
@@ -182,7 +182,7 @@ public abstract class AnnotationsAttribute extends Attribute {
} else if (value instanceof ElementValue[]) {
final ElementValue[] nestedValues = (ElementValue[]) value;
dos.writeShort(nestedValues.length);
- for (ElementValue nestedValue : nestedValues) {
+ for (final ElementValue nestedValue : nestedValues) {
nestedValue.writeBody(dos);
}
} else {
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ByteCode.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ByteCode.java
index aec7ff8f..98048427 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ByteCode.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ByteCode.java
@@ -72,7 +72,7 @@ public class ByteCode extends ClassFileEntry {
@Override
protected void doWrite(final DataOutputStream dos) throws IOException {
- for (int element : rewrite) {
+ for (final int element : rewrite) {
dos.writeByte(element);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassConstantPool.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassConstantPool.java
index 54a6cb83..0f292959 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassConstantPool.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassConstantPool.java
@@ -110,7 +110,7 @@ public class ClassConstantPool {
public ClassFileEntry addWithNestedEntries(final ClassFileEntry entry) {
add(entry);
- for (ClassFileEntry nestedEntry : entry.getNestedClassFileEntries()) {
+ for (final ClassFileEntry nestedEntry : entry.getNestedClassFileEntries()) {
addWithNestedEntries(nestedEntry);
}
return entry;
@@ -150,7 +150,7 @@ public class ClassConstantPool {
final TreeSet<ClassFileEntry> cpClassesNotInCpAll = new TreeSet<>(
Comparator.comparing(arg0 -> ((CPClass) arg0).getName()));
- for (ClassFileEntry entry2 : entries) {
+ for (final ClassFileEntry entry2 : entries) {
final ConstantPoolEntry entry = (ConstantPoolEntry) entry2;
if (entry.getGlobalIndex() == -1) {
if (entry instanceof CPUTF8) {
@@ -193,7 +193,7 @@ public class ClassConstantPool {
final List<ClassFileEntry> startOfPool = new ArrayList<>(entries.size());
final List<ClassFileEntry> finalSort = new ArrayList<>(entries.size());
- for (ClassFileEntry entry : entries) {
+ for (final ClassFileEntry entry : entries) {
if (mustStartClassPool.contains(entry)) {
startOfPool.add(entry);
} else {
@@ -208,7 +208,7 @@ public class ClassConstantPool {
entries.clear();
- for (ClassFileEntry entry : startOfPool) {
+ for (final ClassFileEntry entry : startOfPool) {
indexCache.put(entry, Integer.valueOf(index));
if (entry instanceof CPLong || entry instanceof CPDouble) {
@@ -221,7 +221,7 @@ public class ClassConstantPool {
}
}
- for (ClassFileEntry entry : finalSort) {
+ for (final ClassFileEntry entry : finalSort) {
indexCache.put(entry, Integer.valueOf(index));
if (entry instanceof CPLong || entry instanceof CPDouble) {
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassFile.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassFile.java
index 031a83ad..3a61ff76 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassFile.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ClassFile.java
@@ -55,19 +55,19 @@ public class ClassFile {
dos.writeShort(thisClass);
dos.writeShort(superClass);
dos.writeShort(interfaces.length);
- for (int element : interfaces) {
+ for (final int element : interfaces) {
dos.writeShort(element);
}
dos.writeShort(fields.length);
- for (ClassFileEntry field : fields) {
+ for (final ClassFileEntry field : fields) {
field.write(dos);
}
dos.writeShort(methods.length);
- for (ClassFileEntry method : methods) {
+ for (final ClassFileEntry method : methods) {
method.write(dos);
}
dos.writeShort(attributes.length);
- for (Attribute attribute : attributes) {
+ for (final Attribute attribute : attributes) {
attribute.write(dos);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CodeAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CodeAttribute.java
index 1d4a8412..9b86926d 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CodeAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CodeAttribute.java
@@ -82,7 +82,7 @@ public class CodeAttribute extends BCIRenumberedAttribute {
// sizes, fix up the byte code targets
// At this point, byteCodes may be a different size than
// codePacked because of wide bytecodes.
- for (ByteCode byteCode : byteCodes) {
+ for (final ByteCode byteCode : byteCodes) {
byteCode.applyByteCodeTargetFixup(this);
}
}
@@ -100,7 +100,7 @@ public class CodeAttribute extends BCIRenumberedAttribute {
@Override
protected int getLength() {
int attributesSize = 0;
- for (Attribute attribute : attributes) {
+ for (final Attribute attribute : attributes) {
attributesSize += attribute.getLengthIncludingHeader();
}
return 2 + 2 + 4 + codeLength + 2 + exceptionTable.size() * (2 + 2 + 2 + 2) + 2 + attributesSize;
@@ -113,7 +113,7 @@ public class CodeAttribute extends BCIRenumberedAttribute {
nestedEntries.addAll(byteCodes);
nestedEntries.addAll(attributes);
// Don't forget to add the ExceptionTable catch_types
- for (ExceptionTableEntry entry : exceptionTable) {
+ for (final ExceptionTableEntry entry : exceptionTable) {
final CPClass catchType = entry.getCatchType();
// If the catch type is null, this is a finally
// block. If it's not null, we need to add the
@@ -155,17 +155,17 @@ public class CodeAttribute extends BCIRenumberedAttribute {
dos.writeShort(maxLocals);
dos.writeInt(codeLength);
- for (ByteCode byteCode : byteCodes) {
+ for (final ByteCode byteCode : byteCodes) {
byteCode.write(dos);
}
dos.writeShort(exceptionTable.size());
- for (ExceptionTableEntry entry : exceptionTable) {
+ for (final ExceptionTableEntry entry : exceptionTable) {
entry.write(dos);
}
dos.writeShort(attributes.size());
- for (Attribute attribute : attributes) {
+ for (final Attribute attribute : attributes) {
attribute.write(dos);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java
index ac793c40..7d4685e6 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java
@@ -33,7 +33,7 @@ public class ExceptionsAttribute extends Attribute {
return 0;
}
int result = 1;
- for (Object element : array) {
+ for (final Object element : array) {
result = prime * result + (element == null ? 0 : element.hashCode());
}
return result;
@@ -105,7 +105,7 @@ public class ExceptionsAttribute extends Attribute {
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Exceptions: ");
- for (CPClass exception : exceptions) {
+ for (final CPClass exception : exceptions) {
sb.append(exception);
sb.append(' ');
}
@@ -115,7 +115,7 @@ public class ExceptionsAttribute extends Attribute {
@Override
protected void writeBody(final DataOutputStream dos) throws IOException {
dos.writeShort(exceptionIndexes.length);
- for (int element : exceptionIndexes) {
+ for (final int element : exceptionIndexes) {
dos.writeShort(element);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/InnerClassesAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/InnerClassesAttribute.java
index 1a085cf3..8a6aaa6d 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/InnerClassesAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/InnerClassesAttribute.java
@@ -163,7 +163,7 @@ public class InnerClassesAttribute extends Attribute {
@Override
protected void resolve(final ClassConstantPool pool) {
super.resolve(pool);
- for (InnerClassesEntry entry : innerClasses) {
+ for (final InnerClassesEntry entry : innerClasses) {
entry.resolve(pool);
}
}
@@ -177,7 +177,7 @@ public class InnerClassesAttribute extends Attribute {
protected void writeBody(final DataOutputStream dos) throws IOException {
dos.writeShort(innerClasses.size());
- for (InnerClassesEntry entry : innerClasses) {
+ for (final InnerClassesEntry entry : innerClasses) {
entry.write(dos);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
index dd4ec99f..48fc706e 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
@@ -117,7 +117,7 @@ public class NewAttribute extends BCIRenumberedAttribute {
@Override
protected int getLength() {
int length = 0;
- for (Integer len : lengths) {
+ for (final Integer len : lengths) {
length += len.intValue();
}
return length;
@@ -153,7 +153,7 @@ public class NewAttribute extends BCIRenumberedAttribute {
public void renumber(final List<Integer> byteCodeOffsets) {
if (!renumbered) {
Object previous = null;
- for (Object obj : body) {
+ for (final Object obj : body) {
if (obj instanceof BCIndex) {
final BCIndex bcIndex = (BCIndex) obj;
bcIndex.setActualValue(byteCodeOffsets.get(bcIndex.index).intValue());
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
index 3d61f5d4..e59f466c 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleAnnotationsAttribute.java
@@ -49,7 +49,7 @@ public class RuntimeVisibleorInvisibleAnnotationsAttribute extends AnnotationsAt
protected ClassFileEntry[] getNestedClassFileEntries() {
final List<Object> nested = new ArrayList<>();
nested.add(attributeName);
- for (Annotation annotation : annotations) {
+ for (final Annotation annotation : annotations) {
nested.addAll(annotation.getClassFileEntries());
}
return nested.toArray(ClassFileEntry.NONE);
@@ -58,7 +58,7 @@ public class RuntimeVisibleorInvisibleAnnotationsAttribute extends AnnotationsAt
@Override
protected void resolve(final ClassConstantPool pool) {
super.resolve(pool);
- for (Annotation annotation : annotations) {
+ for (final Annotation annotation : annotations) {
annotation.resolve(pool);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
index ebe68f89..af21ea15 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/RuntimeVisibleorInvisibleParameterAnnotationsAttribute.java
@@ -42,7 +42,7 @@ public class RuntimeVisibleorInvisibleParameterAnnotationsAttribute extends Anno
public List<Object> getClassFileEntries() {
final List<Object> nested = new ArrayList<>();
- for (Annotation annotation : annotations) {
+ for (final Annotation annotation : annotations) {
nested.addAll(annotation.getClassFileEntries());
}
return nested;
@@ -50,21 +50,21 @@ public class RuntimeVisibleorInvisibleParameterAnnotationsAttribute extends Anno
public int getLength() {
int length = 2;
- for (Annotation annotation : annotations) {
+ for (final Annotation annotation : annotations) {
length += annotation.getLength();
}
return length;
}
public void resolve(final ClassConstantPool pool) {
- for (Annotation annotation : annotations) {
+ for (final Annotation annotation : annotations) {
annotation.resolve(pool);
}
}
public void writeBody(final DataOutputStream dos) throws IOException {
dos.writeShort(num_annotations);
- for (Annotation annotation : annotations) {
+ for (final Annotation annotation : annotations) {
annotation.writeBody(dos);
}
}
@@ -94,7 +94,7 @@ public class RuntimeVisibleorInvisibleParameterAnnotationsAttribute extends Anno
protected ClassFileEntry[] getNestedClassFileEntries() {
final List<Object> nested = new ArrayList<>();
nested.add(attributeName);
- for (ParameterAnnotation parameter_annotation : parameter_annotations) {
+ for (final ParameterAnnotation parameter_annotation : parameter_annotations) {
nested.addAll(parameter_annotation.getClassFileEntries());
}
return nested.toArray(ClassFileEntry.NONE);
@@ -103,7 +103,7 @@ public class RuntimeVisibleorInvisibleParameterAnnotationsAttribute extends Anno
@Override
protected void resolve(final ClassConstantPool pool) {
super.resolve(pool);
- for (ParameterAnnotation parameter_annotation : parameter_annotations) {
+ for (final ParameterAnnotation parameter_annotation : parameter_annotations) {
parameter_annotation.resolve(pool);
}
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java
index fb55a729..8d531fcf 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java
@@ -94,7 +94,7 @@ public class LookupSwitchForm extends SwitchForm {
// match-offset pairs
// The case_values aren't overwritten, but the
// case_pcs will get overwritten by fixUpByteCodeTargets
- for (int case_value : case_values) {
+ for (final int case_value : case_values) {
// match
setRewrite4Bytes(case_value, rewriteIndex, newRewrite);
rewriteIndex += 4;
diff --git a/src/main/java/org/apache/commons/compress/java/util/jar/Pack200.java b/src/main/java/org/apache/commons/compress/java/util/jar/Pack200.java
index f2955b46..daf994f3 100644
--- a/src/main/java/org/apache/commons/compress/java/util/jar/Pack200.java
+++ b/src/main/java/org/apache/commons/compress/java/util/jar/Pack200.java
@@ -274,11 +274,11 @@ public abstract class Pack200 {
static Object newInstance(final String systemProperty, final String defaultClassName) {
return AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
- String className = System.getProperty(systemProperty, defaultClassName);
+ final String className = System.getProperty(systemProperty, defaultClassName);
try {
// TODO Not sure if this will cause problems loading the class
return Pack200.class.getClassLoader().loadClass(className).newInstance();
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new Error(Messages.getString("archive.3E", className), e); //$NON-NLS-1$
}
});
diff --git a/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java b/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java
index 37d90820..5bdafb16 100644
--- a/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java
@@ -57,7 +57,7 @@ public abstract class BoundedArchiveInputStream extends InputStream {
} else {
singleByteBuffer.rewind();
}
- int read = read(loc, singleByteBuffer);
+ final int read = read(loc, singleByteBuffer);
if (read < 1) {
return -1;
}
@@ -78,8 +78,8 @@ public abstract class BoundedArchiveInputStream extends InputStream {
throw new IndexOutOfBoundsException("offset or len are out of bounds");
}
- ByteBuffer buf = ByteBuffer.wrap(b, off, (int) maxLen);
- int ret = read(loc, buf);
+ final ByteBuffer buf = ByteBuffer.wrap(b, off, (int) maxLen);
+ final int ret = read(loc, buf);
if (ret > 0) {
loc += ret;
}
diff --git a/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java b/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java
index 3553c174..1730b696 100644
--- a/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java
+++ b/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java
@@ -38,7 +38,7 @@ public class OsgiUtils {
if (c.getName().equals("org.osgi.framework.BundleReference")) {
return true;
}
- for (Class<?> ifc : c.getInterfaces()) {
+ for (final Class<?> ifc : c.getInterfaces()) {
if (isBundleReference(ifc)) {
return true;
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java b/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
index 5398e007..7601651f 100644
--- a/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
@@ -85,10 +85,7 @@ public final class DumpTestCase extends AbstractTestCase {
private void unarchiveAll(final File input) throws Exception {
final InputStream is = Files.newInputStream(input.toPath());
- ArchiveInputStream in = null;
- try {
- in = ArchiveStreamFactory.DEFAULT.createArchiveInputStream("dump", is);
-
+ try (ArchiveInputStream in = ArchiveStreamFactory.DEFAULT.createArchiveInputStream("dump", is)) {
ArchiveEntry entry = in.getNextEntry();
while (entry != null) {
final File archiveEntry = new File(dir, entry.getName());
@@ -102,9 +99,6 @@ public final class DumpTestCase extends AbstractTestCase {
entry = in.getNextEntry();
}
} finally {
- if (in != null) {
- in.close();
- }
is.close();
}
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java b/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
index 16ffc264..aecdf58d 100644
--- a/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
@@ -60,7 +60,7 @@ public final class TarTestCase extends AbstractTestCase {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(bos)) {
tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
- TarArchiveEntry longFileNameEntry = new TarArchiveEntry(longName);
+ final TarArchiveEntry longFileNameEntry = new TarArchiveEntry(longName);
tos.putArchiveEntry(longFileNameEntry);
tos.closeArchiveEntry();
}
@@ -147,10 +147,10 @@ public final class TarTestCase extends AbstractTestCase {
final File input = getFile("directory.tar");
try (final InputStream is = Files.newInputStream(input.toPath());
final TarArchiveInputStream in = new TarArchiveInputStream(is)) {
- TarArchiveEntry directoryEntry = in.getNextTarEntry();
+ final TarArchiveEntry directoryEntry = in.getNextTarEntry();
assertEquals("directory/", directoryEntry.getName());
assertTrue(directoryEntry.isDirectory());
- byte[] directoryRead = IOUtils.toByteArray(in);
+ final byte[] directoryRead = IOUtils.toByteArray(in);
assertArrayEquals(ByteUtils.EMPTY_BYTE_ARRAY, directoryRead);
}
}
@@ -415,7 +415,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testTarFileDirectoryEntryFromFile() throws Exception {
final File[] tmp = createTempDirAndFile();
- File archive = File.createTempFile("test.", ".tar", tmp[0]);
+ final File archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(Files.newOutputStream(archive.toPath()))) {
@@ -425,7 +425,7 @@ public final class TarTestCase extends AbstractTestCase {
tos.closeArchiveEntry();
tos.close();
try (final TarFile tarFile = new TarFile(archive)) {
- TarArchiveEntry entry = tarFile.getEntries().get(0);
+ final TarArchiveEntry entry = tarFile.getEntries().get(0);
assertNotNull(entry);
assertEquals("foo/", entry.getName());
assertEquals(0, entry.getSize());
@@ -444,11 +444,11 @@ public final class TarTestCase extends AbstractTestCase {
public void testTarFileDirectoryRead() throws IOException {
final File input = getFile("directory.tar");
try (TarFile tarFile = new TarFile(input)) {
- TarArchiveEntry directoryEntry = tarFile.getEntries().get(0);
+ final TarArchiveEntry directoryEntry = tarFile.getEntries().get(0);
assertEquals("directory/", directoryEntry.getName());
assertTrue(directoryEntry.isDirectory());
try (InputStream directoryStream = tarFile.getInputStream(directoryEntry)) {
- byte[] directoryRead = IOUtils.toByteArray(directoryStream);
+ final byte[] directoryRead = IOUtils.toByteArray(directoryStream);
assertArrayEquals(ByteUtils.EMPTY_BYTE_ARRAY, directoryRead);
}
}
@@ -457,7 +457,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testTarFileEntryFromFile() throws Exception {
final File[] tmp = createTempDirAndFile();
- File archive = File.createTempFile("test.", ".tar", tmp[0]);
+ final File archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(Files.newOutputStream(archive.toPath()))) {
final TarArchiveEntry in = new TarArchiveEntry(tmp[1], "foo");
@@ -471,7 +471,7 @@ public final class TarTestCase extends AbstractTestCase {
tos.closeArchiveEntry();
tos.close();
try (final TarFile tarFile = new TarFile(archive)) {
- TarArchiveEntry entry = tarFile.getEntries().get(0);
+ final TarArchiveEntry entry = tarFile.getEntries().get(0);
assertNotNull(entry);
assertEquals("foo", entry.getName());
assertEquals(tmp[1].length(), entry.getSize());
@@ -488,7 +488,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testTarFileExplicitDirectoryEntry() throws Exception {
final File[] tmp = createTempDirAndFile();
- File archive = File.createTempFile("test.", ".tar", tmp[0]);
+ final File archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(Files.newOutputStream(archive.toPath()))){
final long beforeArchiveWrite = tmp[0].lastModified();
@@ -498,7 +498,7 @@ public final class TarTestCase extends AbstractTestCase {
tos.closeArchiveEntry();
tos.close();
try (final TarFile tarFile = new TarFile(archive)) {
- TarArchiveEntry entry = tarFile.getEntries().get(0);
+ final TarArchiveEntry entry = tarFile.getEntries().get(0);
assertNotNull(entry);
assertEquals("foo/", entry.getName());
assertEquals(0, entry.getSize());
@@ -515,7 +515,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testTarFileExplicitFileEntry() throws Exception {
final File[] tmp = createTempDirAndFile();
- File archive = File.createTempFile("test.", ".tar", tmp[0]);
+ final File archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(Files.newOutputStream(archive.toPath()))){
final TarArchiveEntry in = new TarArchiveEntry("foo");
@@ -531,7 +531,7 @@ public final class TarTestCase extends AbstractTestCase {
tos.closeArchiveEntry();
try (final TarFile tarFile = new TarFile(archive)) {
- TarArchiveEntry entry = tarFile.getEntries().get(0);
+ final TarArchiveEntry entry = tarFile.getEntries().get(0);
assertNotNull(entry);
assertEquals("foo", entry.getName());
assertEquals(tmp[1].length(), entry.getSize());
@@ -554,7 +554,7 @@ public final class TarTestCase extends AbstractTestCase {
assertEquals(length.intValue(), fileName.length());
final byte[] data = createTarWithOneLongNameEntry(fileName);
try (final TarFile tarFile = new TarFile(data)) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertEquals(fileName, entries.get(0).getName());
}
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
index cd837f64..606a7032 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
@@ -165,7 +165,7 @@ public final class ZipTestCase extends AbstractTestCase {
sameNameFile.createNewFile();
assertThrows(IOException.class, () -> addFilesToZip(zipArchiveOutputStream, directoryToZip));
- } catch (Exception e) {
+ } catch (final Exception e) {
// Ignore:
// java.io.IOException: This archive contains unclosed entries.
// at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.finish(ZipArchiveOutputStream.java:563)
diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
index 714e25bd..055ca7de 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
@@ -42,9 +42,9 @@ public class CpioArchiveOutputStreamTest extends AbstractTestCase {
}
try (CpioArchiveInputStream in = new CpioArchiveInputStream(Files.newInputStream(output.toPath()))) {
- final CpioArchiveEntry e = ((CpioArchiveInputStream) in).getNextCPIOEntry();
+ final CpioArchiveEntry e = in.getNextCPIOEntry();
assertEquals("test1.xml", e.getName());
- assertNull(((CpioArchiveInputStream) in).getNextEntry());
+ assertNull(in.getNextEntry());
} finally {
}
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntryTest.java
index 5bb44e9c..d895975b 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntryTest.java
@@ -84,7 +84,7 @@ public class SevenZArchiveEntryTest {
@Test
public void shouldThrowIfAccessDateIsSetToNull() {
assertThrows(UnsupportedOperationException.class, () -> {
- SevenZArchiveEntry entry = new SevenZArchiveEntry();
+ final SevenZArchiveEntry entry = new SevenZArchiveEntry();
entry.setAccessDate(null);
entry.getAccessDate();
});
@@ -93,7 +93,7 @@ public class SevenZArchiveEntryTest {
@Test
public void shouldThrowIfCreationDateIsSetToNull() {
assertThrows(UnsupportedOperationException.class, () -> {
- SevenZArchiveEntry entry = new SevenZArchiveEntry();
+ final SevenZArchiveEntry entry = new SevenZArchiveEntry();
entry.setCreationDate(null);
entry.getCreationDate();
});
@@ -102,7 +102,7 @@ public class SevenZArchiveEntryTest {
@Test
public void shouldThrowIfLastModifiedDateIsSetToNull() {
assertThrows(UnsupportedOperationException.class, () -> {
- SevenZArchiveEntry entry = new SevenZArchiveEntry();
+ final SevenZArchiveEntry entry = new SevenZArchiveEntry();
entry.setLastModifiedDate(null);
entry.getLastModifiedDate();
});
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index 8a963edb..5cef462c 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -166,7 +166,7 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void getEntriesOfUnarchiveInMemoryTest() throws IOException {
- byte[] data = Files.readAllBytes(getFile("bla.7z").toPath());
+ final byte[] data = Files.readAllBytes(getFile("bla.7z").toPath());
try (SevenZFile sevenZFile = new SevenZFile(new SeekableInMemoryByteChannel(data))) {
final Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries();
final Iterator<SevenZArchiveEntry> iter = entries.iterator();
@@ -272,7 +272,7 @@ public class SevenZFileTest extends AbstractTestCase {
SevenZArchiveEntry entry = sevenZFile.getNextEntry();
while (entry != null) {
if (entry.hasStream()) {
- byte[] content = new byte[(int) entry.getSize()];
+ final byte[] content = new byte[(int) entry.getSize()];
sevenZFile.read(content);
}
entry = sevenZFile.getNextEntry();
@@ -373,7 +373,7 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void retrieveInputStreamForShuffledEntries() throws IOException {
try (final SevenZFile sevenZFile = new SevenZFile(getFile("COMPRESS-348.7z"))) {
- List<SevenZArchiveEntry> entries = (List<SevenZArchiveEntry>) sevenZFile.getEntries();
+ final List<SevenZArchiveEntry> entries = (List<SevenZArchiveEntry>) sevenZFile.getEntries();
Collections.shuffle(entries);
for (final SevenZArchiveEntry entry : entries) {
IOUtils.toByteArray(sevenZFile.getInputStream(entry));
@@ -480,7 +480,7 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void testAllEmptyFilesArchive() throws Exception {
try (SevenZFile archive = new SevenZFile(getFile("7z-empty-mhc-off.7z"))) {
- SevenZArchiveEntry e = archive.getNextEntry();
+ final SevenZArchiveEntry e = archive.getNextEntry();
assertNotNull(e);
assertEquals("empty", e.getName());
assertDates(e, "2013-05-14T17:50:19Z", null, null);
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
index 853c991c..16c483e8 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
@@ -64,7 +64,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
final Iterable<? extends SevenZMethodConfiguration> actual) {
assertNotNull(actual);
final Iterator<? extends SevenZMethodConfiguration> actualIter = actual.iterator();
- for (SevenZMethodConfiguration expConfig : expected) {
+ for (final SevenZMethodConfiguration expConfig : expected) {
assertTrue(actualIter.hasNext());
final SevenZMethodConfiguration actConfig = actualIter.next();
assertEquals(expConfig.getMethod(), actConfig.getMethod());
@@ -122,8 +122,8 @@ public class SevenZOutputFileTest extends AbstractTestCase {
}
}
- private byte[] generateFileData(int size) {
- byte[] data = new byte[size];
+ private byte[] generateFileData(final int size) {
+ final byte[] data = new byte[size];
for (int i = 0; i < size; i++) {
data[i] = (byte) ('A' + (i % 26));
}
@@ -480,13 +480,13 @@ public class SevenZOutputFileTest extends AbstractTestCase {
/**
* Test password-based encryption
- *
+ *
* <p>
* As AES/CBC Cipher requires a minimum of 16 bytes file data to be encrypted, some padding logic has been implemented.
* This test checks different file sizes (1, 16..) to ensure code coverage
* </p>
*/
- @Test
+ @Test
public void testEncrypt() throws Exception {
output = new File(dir, "encrypted.7z");
try (SevenZOutputFile outArchive = new SevenZOutputFile(output, "foo".toCharArray())) {
@@ -500,10 +500,10 @@ public class SevenZOutputFileTest extends AbstractTestCase {
// Is archive really password-based encrypted ?
try (SevenZFile archive = new SevenZFile(output)) {
assertThrows(
- "A password should be needed",
- PasswordRequiredException.class,
+ "A password should be needed",
+ PasswordRequiredException.class,
() -> verifyFile(archive, 0));
- }
+ }
try (SevenZFile archive = new SevenZFile(output, "foo".toCharArray())) {
assertEquals(Boolean.TRUE, verifyFile(archive, 0, 1, null));
@@ -668,11 +668,11 @@ public class SevenZOutputFileTest extends AbstractTestCase {
return Boolean.FALSE;
}
assertEquals(size, entry.getSize());
-
- byte[] actual = new byte[size];
+
+ final byte[] actual = new byte[size];
int count = 0;
while (count < size) {
- int read = archive.read(actual, count, actual.length - count);
+ final int read = archive.read(actual, count, actual.length - count);
assertNotEquals(-1, read, "EOF reached before reading all expected data");
count += read;
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java b/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
index abd3e640..b45e75fe 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
@@ -85,15 +85,15 @@ public class BigFilesIT extends AbstractTestCase {
@Test
public void tarFileReadFileHeadersOfArchiveBiggerThan8GByte() throws Exception {
- Path file = getPath("8.posix.tar.gz");
- Path output = resultDir.toPath().resolve("8.posix.tar");
+ final Path file = getPath("8.posix.tar.gz");
+ final Path output = resultDir.toPath().resolve("8.posix.tar");
try (InputStream in = new BufferedInputStream(Files.newInputStream(file));
GzipCompressorInputStream gzin = new GzipCompressorInputStream(in)) {
Files.copy(gzin, output, StandardCopyOption.REPLACE_EXISTING);
}
try (final TarFile tarFile = new TarFile(output)) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertEquals(1, entries.size());
assertNotNull(entries.get(0));
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
index a64b011d..642b82b7 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
@@ -50,7 +50,7 @@ public class SparseFilesTest extends AbstractTestCase {
assertTrue(entry.isPaxGNUSparse());
assertFalse(entry.isOldGNUSparse());
- List<TarArchiveStructSparse> sparseHeaders = entry.getSparseHeaders();
+ final List<TarArchiveStructSparse> sparseHeaders = entry.getSparseHeaders();
assertEquals(3, sparseHeaders.size());
assertEquals(0, sparseHeaders.get(0).getOffset());
@@ -86,10 +86,10 @@ public class SparseFilesTest extends AbstractTestCase {
@Test
public void compareTarArchiveInputStreamWithTarFile() throws IOException {
- Path file = getPath("oldgnu_sparse.tar");
+ final Path file = getPath("oldgnu_sparse.tar");
try (TarArchiveInputStream tarIn = new TarArchiveInputStream(new BufferedInputStream(Files.newInputStream(file)));
TarFile tarFile = new TarFile(file)) {
- TarArchiveEntry tarInEntry = tarIn.getNextTarEntry();
+ final TarArchiveEntry tarInEntry = tarIn.getNextTarEntry();
assertArrayEquals(IOUtils.toByteArray(tarIn), IOUtils.toByteArray(tarFile.getInputStream(tarFile.getEntries().get(0))));
}
}
@@ -308,13 +308,13 @@ public class SparseFilesTest extends AbstractTestCase {
final File file = getFile("oldgnu_extended_sparse.tar");
try (InputStream sparseFileInputStream = extractTarAndGetInputStream(file, "sparse6");
TarFile tarFile = new TarFile(file)) {
- TarArchiveEntry ae = tarFile.getEntries().get(0);
+ final TarArchiveEntry ae = tarFile.getEntries().get(0);
try (InputStream tarInput = tarFile.getInputStream(ae)) {
assertArrayEquals(IOUtils.toByteArray(tarInput), IOUtils.toByteArray(sparseFileInputStream));
}
- List<TarArchiveStructSparse> sparseHeaders = ae.getOrderedSparseHeaders();
+ final List<TarArchiveStructSparse> sparseHeaders = ae.getOrderedSparseHeaders();
assertEquals(7, sparseHeaders.size());
assertEquals(0, sparseHeaders.get(0).getOffset());
@@ -344,10 +344,10 @@ public class SparseFilesTest extends AbstractTestCase {
public void testTarFileExtractOldGNU() throws IOException, InterruptedException {
Assume.assumeFalse("Don't run test on Windows", isOnWindows);
- File file = getFile("oldgnu_sparse.tar");
+ final File file = getFile("oldgnu_sparse.tar");
try (final InputStream sparseFileInputStream = extractTarAndGetInputStream(file, "sparsefile");
final TarFile tarFile = new TarFile(file)) {
- TarArchiveEntry entry = tarFile.getEntries().get(0);
+ final TarArchiveEntry entry = tarFile.getEntries().get(0);
try (InputStream tarInput = tarFile.getInputStream(entry)) {
assertArrayEquals(IOUtils.toByteArray(tarInput), IOUtils.toByteArray(sparseFileInputStream));
}
@@ -365,7 +365,7 @@ public class SparseFilesTest extends AbstractTestCase {
final File file = getFile("pax_gnu_sparse.tar");
try (final TarFile paxGnu = new TarFile(file)) {
- List<TarArchiveEntry> entries = paxGnu.getEntries();
+ final List<TarArchiveEntry> entries = paxGnu.getEntries();
TarArchiveEntry entry = entries.get(0);
try (InputStream sparseFileInputStream = extractTarAndGetInputStream(file, "sparsefile-0.0");
@@ -394,12 +394,12 @@ public class SparseFilesTest extends AbstractTestCase {
final File oldGNUSparseTar = getFile("oldgnu_sparse.tar");
final File paxGNUSparseTar = getFile("pax_gnu_sparse.tar");
try (TarFile paxGnu = new TarFile(paxGNUSparseTar)) {
- List<TarArchiveEntry> entries = paxGnu.getEntries();
+ final List<TarArchiveEntry> entries = paxGnu.getEntries();
// compare between old GNU and PAX 0.0
TarArchiveEntry paxGnuEntry = entries.get(0);
try (TarFile oldGnu = new TarFile(oldGNUSparseTar)) {
- TarArchiveEntry oldGnuEntry = oldGnu.getEntries().get(0);
+ final TarArchiveEntry oldGnuEntry = oldGnu.getEntries().get(0);
try (InputStream old = oldGnu.getInputStream(oldGnuEntry);
InputStream pax = paxGnu.getInputStream(paxGnuEntry)) {
assertArrayEquals(IOUtils.toByteArray(old), IOUtils.toByteArray(pax));
@@ -409,7 +409,7 @@ public class SparseFilesTest extends AbstractTestCase {
// compare between old GNU and PAX 0.1
paxGnuEntry = entries.get(1);
try (TarFile oldGnu = new TarFile(oldGNUSparseTar)) {
- TarArchiveEntry oldGnuEntry = oldGnu.getEntries().get(0);
+ final TarArchiveEntry oldGnuEntry = oldGnu.getEntries().get(0);
try (InputStream old = oldGnu.getInputStream(oldGnuEntry);
InputStream pax = paxGnu.getInputStream(paxGnuEntry)) {
assertArrayEquals(IOUtils.toByteArray(old), IOUtils.toByteArray(pax));
@@ -419,7 +419,7 @@ public class SparseFilesTest extends AbstractTestCase {
// compare between old GNU and PAX 1.0
paxGnuEntry = entries.get(2);
try (TarFile oldGnu = new TarFile(oldGNUSparseTar)) {
- TarArchiveEntry oldGnuEntry = oldGnu.getEntries().get(0);
+ final TarArchiveEntry oldGnuEntry = oldGnu.getEntries().get(0);
try (InputStream old = oldGnu.getInputStream(oldGnuEntry);
InputStream pax = paxGnu.getInputStream(paxGnuEntry)) {
assertArrayEquals(IOUtils.toByteArray(old), IOUtils.toByteArray(pax));
@@ -432,13 +432,13 @@ public class SparseFilesTest extends AbstractTestCase {
public void testTarFileOldGNU() throws Throwable {
final File file = getFile("oldgnu_sparse.tar");
try (final TarFile tarFile = new TarFile(file)) {
- TarArchiveEntry ae = tarFile.getEntries().get(0);
+ final TarArchiveEntry ae = tarFile.getEntries().get(0);
assertEquals("sparsefile", ae.getName());
assertTrue(ae.isOldGNUSparse());
assertTrue(ae.isGNUSparse());
assertFalse(ae.isPaxGNUSparse());
- List<TarArchiveStructSparse> sparseHeaders = ae.getSparseHeaders();
+ final List<TarArchiveStructSparse> sparseHeaders = ae.getSparseHeaders();
assertEquals(4, sparseHeaders.size());
assertEquals(0, sparseHeaders.get(0).getOffset());
@@ -471,7 +471,7 @@ public class SparseFilesTest extends AbstractTestCase {
public void testTarFilePaxGNU() throws IOException {
final File file = getFile("pax_gnu_sparse.tar");
try (final TarFile tarFile = new TarFile(file)) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertPaxGNUEntry(entries.get(0), "0.0");
assertPaxGNUEntry(entries.get(1), "0.1");
assertPaxGNUEntry(entries.get(2), "1.0");
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
index 8b4e53f1..b2fc4bfd 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
@@ -119,7 +119,7 @@ public class TarArchiveEntryTest implements TarConstants {
@Test
public void negativeOffsetInConstructorNotAllowed() {
// @formatter:off
- byte[] entryContent = ("test1.xml\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
+ final byte[] entryContent = ("test1.xml\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
"\u0000" +
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
index e7f0fadd..f4f46625 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
@@ -145,7 +145,7 @@ public class TarArchiveInputStreamTest extends AbstractTestCase {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (TarArchiveOutputStream tos = new TarArchiveOutputStream(bos)) {
tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
- TarArchiveEntry t = new TarArchiveEntry("name");
+ final TarArchiveEntry t = new TarArchiveEntry("name");
t.setGroupId(4294967294L);
t.setSize(1);
tos.putArchiveEntry(t);
@@ -155,7 +155,7 @@ public class TarArchiveInputStreamTest extends AbstractTestCase {
final byte[] data = bos.toByteArray();
final ByteArrayInputStream bis = new ByteArrayInputStream(data);
try (final TarArchiveInputStream tis = new TarArchiveInputStream(bis)) {
- TarArchiveEntry t = tis.getNextTarEntry();
+ final TarArchiveEntry t = tis.getNextTarEntry();
assertEquals(4294967294L, t.getLongGroupId());
}
}
@@ -203,7 +203,7 @@ public class TarArchiveInputStreamTest extends AbstractTestCase {
+ "01234567890\u00e4";
try (TarArchiveOutputStream tos = new TarArchiveOutputStream(bos, encoding)) {
tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
- TarArchiveEntry t = new TarArchiveEntry(name);
+ final TarArchiveEntry t = new TarArchiveEntry(name);
t.setSize(1);
tos.putArchiveEntry(t);
tos.write(30);
@@ -212,7 +212,7 @@ public class TarArchiveInputStreamTest extends AbstractTestCase {
final byte[] data = bos.toByteArray();
final ByteArrayInputStream bis = new ByteArrayInputStream(data);
try (TarArchiveInputStream tis = new TarArchiveInputStream(bis, encoding)) {
- TarArchiveEntry t = tis.getNextTarEntry();
+ final TarArchiveEntry t = tis.getNextTarEntry();
assertEquals(name, t.getName());
}
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
index 5ef0cdaf..5b952417 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
@@ -139,7 +139,7 @@ public class TarArchiveOutputStreamTest extends AbstractTestCase {
@Test
public void testBlockSizes() throws Exception {
final String fileName = "/test1.xml";
- byte[] contents = getResourceContents(fileName);
+ final byte[] contents = getResourceContents(fileName);
testPadding(TarConstants.DEFAULT_BLKSIZE, fileName, contents); // USTAR / pre-pax
testPadding(5120, fileName, contents); // PAX default
testPadding(1<<15, fileName, contents); //PAX max
@@ -152,7 +152,7 @@ public class TarArchiveOutputStreamTest extends AbstractTestCase {
assertThrows(IllegalArgumentException.class, () -> testPadding(0, fileName, contents));
// test with "content" that is an exact multiple of record length
- byte[] contents2 = new byte[2048];
+ final byte[] contents2 = new byte[2048];
java.util.Arrays.fill(contents2, (byte) 42);
testPadding(TarConstants.DEFAULT_BLKSIZE, fileName, contents2);
}
@@ -551,7 +551,7 @@ public class TarArchiveOutputStreamTest extends AbstractTestCase {
@Test
public void testWriteLongFileNamePosixMode() throws Exception {
// @formatter:off
- final String n = "01234567890123456789012345678901234567890123456789"
+ final String n = "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789";
// @formatter:on
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java
index 16b4bd87..a24d9b21 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java
@@ -61,7 +61,7 @@ public class TarFileTest extends AbstractTestCase {
private void datePriorToEpoch(final String archive) throws Exception {
try (final TarFile tarFile = new TarFile(getPath(archive))) {
- TarArchiveEntry entry = tarFile.getEntries().get(0);
+ final TarArchiveEntry entry = tarFile.getEntries().get(0);
assertEquals("foo", entry.getName());
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.set(1969, 11, 31, 23, 59, 59);
@@ -118,7 +118,7 @@ public class TarFileTest extends AbstractTestCase {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(bos)) {
tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
- TarArchiveEntry t = new TarArchiveEntry("name");
+ final TarArchiveEntry t = new TarArchiveEntry("name");
t.setGroupId(4294967294L);
t.setSize(1);
tos.putArchiveEntry(t);
@@ -127,7 +127,7 @@ public class TarFileTest extends AbstractTestCase {
}
final byte[] data = bos.toByteArray();
try (final TarFile tarFile = new TarFile(data)) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertEquals(4294967294L, entries.get(0).getLongGroupId());
}
}
@@ -138,7 +138,7 @@ public class TarFileTest extends AbstractTestCase {
@Test
public void shouldReadGNULongNameEntryWithWrongName() throws Exception {
try (final TarFile tarFile = new TarFile(getPath("COMPRESS-324.tar"))) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertEquals("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"
@@ -164,7 +164,7 @@ public class TarFileTest extends AbstractTestCase {
+ "01234567890\u00e4";
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(bos, encoding)) {
tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
- TarArchiveEntry t = new TarArchiveEntry(name);
+ final TarArchiveEntry t = new TarArchiveEntry(name);
t.setSize(1);
tos.putArchiveEntry(t);
tos.write(30);
@@ -172,7 +172,7 @@ public class TarFileTest extends AbstractTestCase {
}
final byte[] data = bos.toByteArray();
try (final TarFile tarFile = new TarFile(data, encoding)) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertEquals(1, entries.size());
assertEquals(name, entries.get(0).getName());
}
@@ -207,7 +207,7 @@ public class TarFileTest extends AbstractTestCase {
@Test
public void survivesBlankLinesInPaxHeader() throws Exception {
try (final TarFile tarFile = new TarFile(getPath("COMPRESS-355.tar"))) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertEquals(1, entries.size());
assertEquals("package/package.json", entries.get(0).getName());
}
@@ -241,17 +241,17 @@ public class TarFileTest extends AbstractTestCase {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (final TarArchiveOutputStream tos = new TarArchiveOutputStream(bos)) {
tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
- TarArchiveEntry rootfolder = new TarArchiveEntry(folderName);
+ final TarArchiveEntry rootfolder = new TarArchiveEntry(folderName);
tos.putArchiveEntry(rootfolder);
- TarArchiveEntry consumerJava = new TarArchiveEntry(consumerJavaName);
+ final TarArchiveEntry consumerJava = new TarArchiveEntry(consumerJavaName);
tos.putArchiveEntry(consumerJava);
- TarArchiveEntry producerJava = new TarArchiveEntry(producerJavaName);
+ final TarArchiveEntry producerJava = new TarArchiveEntry(producerJavaName);
tos.putArchiveEntry(producerJava);
tos.closeArchiveEntry();
}
final byte[] data = bos.toByteArray();
try (final TarFile tarFile = new TarFile(data)) {
- List<TarArchiveEntry> entries = tarFile.getEntries();
+ final List<TarArchiveEntry> entries = tarFile.getEntries();
assertEquals(folderName, entries.get(0).getName());
assertEquals(consumerJavaName, entries.get(1).getName());
assertEquals(producerJavaName, entries.get(2).getName());
@@ -263,32 +263,32 @@ public class TarFileTest extends AbstractTestCase {
final String rootPath = dir.getAbsolutePath();
final String dirDirectory = "COMPRESS-509";
final int count = 100;
- File root = new File(rootPath + "/" + dirDirectory);
+ final File root = new File(rootPath + "/" + dirDirectory);
root.mkdirs();
for (int i = 1; i < count; i++) {
// -----------------------
// create empty dirs with incremental length
// -----------------------
- StringBuilder subDirBuilder = new StringBuilder();
+ final StringBuilder subDirBuilder = new StringBuilder();
for (int j = 0; j < i; j++) {
subDirBuilder.append("a");
}
- String subDir = subDirBuilder.toString();
- File dir = new File(rootPath + "/" + dirDirectory, "/" + subDir);
+ final String subDir = subDirBuilder.toString();
+ final File dir = new File(rootPath + "/" + dirDirectory, "/" + subDir);
dir.mkdir();
// -----------------------
// tar these dirs
// -----------------------
- String fileName = "/" + dirDirectory + "/" + subDir;
- File tarF = new File(rootPath + "/tar" + i + ".tar");
+ final String fileName = "/" + dirDirectory + "/" + subDir;
+ final File tarF = new File(rootPath + "/tar" + i + ".tar");
try (OutputStream dest = Files.newOutputStream(tarF.toPath());
TarArchiveOutputStream out = new TarArchiveOutputStream(new BufferedOutputStream(dest))) {
out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
out.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
- File file = new File(rootPath, fileName);
- TarArchiveEntry entry = new TarArchiveEntry(file);
+ final File file = new File(rootPath, fileName);
+ final TarArchiveEntry entry = new TarArchiveEntry(file);
entry.setName(fileName);
out.putArchiveEntry(entry);
out.closeArchiveEntry();
@@ -298,7 +298,7 @@ public class TarFileTest extends AbstractTestCase {
// untar these tars
// -----------------------
try (TarFile tarFile = new TarFile(tarF)) {
- for (TarArchiveEntry entry : tarFile.getEntries()) {
+ for (final TarArchiveEntry entry : tarFile.getEntries()) {
assertTrue("Entry name: " + entry.getName(), entry.getName().endsWith("/"));
}
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
index b13c85bf..342dda6e 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
@@ -189,7 +189,7 @@ public class ZipArchiveInputStreamTest {
@Test
public void multiByteReadThrowsAtEofForCorruptedStoredEntry() throws Exception {
- byte[] content = Files.readAllBytes(getFile("COMPRESS-264.zip").toPath());
+ final byte[] content = Files.readAllBytes(getFile("COMPRESS-264.zip").toPath());
// make size much bigger than entry's real size
for (int i = 17; i < 26; i++) {
content[i] = (byte) 0xff;
@@ -445,7 +445,7 @@ public class ZipArchiveInputStreamTest {
@Test
public void singleByteReadThrowsAtEofForCorruptedStoredEntry() throws Exception {
- byte[] content = Files.readAllBytes(getFile("COMPRESS-264.zip").toPath());
+ final byte[] content = Files.readAllBytes(getFile("COMPRESS-264.zip").toPath());
// make size much bigger than entry's real size
for (int i = 17; i < 26; i++) {
content[i] = (byte) 0xff;
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
index 715a466b..031ea3cb 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
@@ -763,7 +763,7 @@ public class ZipFileTest {
assertArrayEquals(fileHeader, IOUtils.toByteArray(input));
}
- ZipArchiveEntry e = archive.getEntry(entryName);
+ final ZipArchiveEntry e = archive.getEntry(entryName);
assertEquals(entryContent.length, e.getSize());
try (InputStream input = archive.getInputStream(e)) {
assertArrayEquals(entryContent, IOUtils.toByteArray(input));
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipMemoryFileSystemTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipMemoryFileSystemTest.java
index 108b853a..06b72f83 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipMemoryFileSystemTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipMemoryFileSystemTest.java
@@ -75,9 +75,9 @@ public class ZipMemoryFileSystemTest {
final Path firstFile = getPath("COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.z01");
final Path secondFile = getPath("COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.z02");
final Path lastFile = getPath("COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.zip");
- byte[] firstBytes = Files.readAllBytes(firstFile);
- byte[] secondBytes = Files.readAllBytes(secondFile);
- byte[] lastBytes = Files.readAllBytes(lastFile);
+ final byte[] firstBytes = Files.readAllBytes(firstFile);
+ final byte[] secondBytes = Files.readAllBytes(secondFile);
+ final byte[] lastBytes = Files.readAllBytes(lastFile);
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
Files.write(fileSystem.getPath("split_zip_created_by_zip.z01"), firstBytes);
Files.write(fileSystem.getPath("split_zip_created_by_zip.z02"), secondBytes);
@@ -99,15 +99,15 @@ public class ZipMemoryFileSystemTest {
final Path firstFile = getPath("COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.z01");
final Path secondFile = getPath("COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.z02");
final Path lastFile = getPath("COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.zip");
- byte[] firstBytes = Files.readAllBytes(firstFile);
- byte[] secondBytes = Files.readAllBytes(secondFile);
- byte[] lastBytes = Files.readAllBytes(lastFile);
+ final byte[] firstBytes = Files.readAllBytes(firstFile);
+ final byte[] secondBytes = Files.readAllBytes(secondFile);
+ final byte[] lastBytes = Files.readAllBytes(lastFile);
final int firstFileSize = firstBytes.length;
final int secondFileSize = secondBytes.length;
final int lastFileSize = lastBytes.length;
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
- Path lastMemoryPath = fileSystem.getPath("split_zip_created_by_zip.zip");
+ final Path lastMemoryPath = fileSystem.getPath("split_zip_created_by_zip.zip");
Files.write(fileSystem.getPath("split_zip_created_by_zip.z01"), firstBytes);
Files.write(fileSystem.getPath("split_zip_created_by_zip.z02"), secondBytes);
Files.write(lastMemoryPath, lastBytes);
@@ -131,7 +131,7 @@ public class ZipMemoryFileSystemTest {
@Test
public void scatterFileInMemory() throws IOException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
- Path scatterFile = fileSystem.getPath("scattertest.notzip");
+ final Path scatterFile = fileSystem.getPath("scattertest.notzip");
final ScatterZipOutputStream scatterZipOutputStream = ScatterZipOutputStream.pathBased(scatterFile);
final byte[] B_PAYLOAD = "RBBBBBBS".getBytes();
final byte[] A_PAYLOAD = "XAAY".getBytes();
@@ -146,7 +146,7 @@ public class ZipMemoryFileSystemTest {
final ByteArrayInputStream payload1 = new ByteArrayInputStream(A_PAYLOAD);
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae, createPayloadSupplier(payload1)));
- Path target = Files.createTempFile(dir, "scattertest", ".zip");
+ final Path target = Files.createTempFile(dir, "scattertest", ".zip");
final ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(target);
scatterZipOutputStream.writeTo(outputStream);
outputStream.close();
@@ -168,7 +168,7 @@ public class ZipMemoryFileSystemTest {
@Test
public void scatterFileWithCompressionAndTargetInMemory() throws IOException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
- Path scatterFile = fileSystem.getPath("scattertest.notzip");
+ final Path scatterFile = fileSystem.getPath("scattertest.notzip");
final ScatterZipOutputStream scatterZipOutputStream = ScatterZipOutputStream.pathBased(scatterFile,
Deflater.BEST_COMPRESSION);
final byte[] B_PAYLOAD = "RBBBBBBS".getBytes();
@@ -184,7 +184,7 @@ public class ZipMemoryFileSystemTest {
final ByteArrayInputStream payload1 = new ByteArrayInputStream(A_PAYLOAD);
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae, createPayloadSupplier(payload1)));
- Path target = fileSystem.getPath("scattertest.zip");
+ final Path target = fileSystem.getPath("scattertest.zip");
final ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(target);
scatterZipOutputStream.writeTo(outputStream);
outputStream.close();
@@ -206,7 +206,7 @@ public class ZipMemoryFileSystemTest {
@Test
public void scatterFileWithCompressionInMemory() throws IOException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
- Path scatterFile = fileSystem.getPath("scattertest.notzip");
+ final Path scatterFile = fileSystem.getPath("scattertest.notzip");
final ScatterZipOutputStream scatterZipOutputStream = ScatterZipOutputStream.pathBased(scatterFile,
Deflater.BEST_COMPRESSION);
final byte[] B_PAYLOAD = "RBBBBBBS".getBytes();
@@ -222,7 +222,7 @@ public class ZipMemoryFileSystemTest {
final ByteArrayInputStream payload1 = new ByteArrayInputStream(A_PAYLOAD);
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae, createPayloadSupplier(payload1)));
- Path target = Files.createTempFile(dir, "scattertest", ".zip");
+ final Path target = Files.createTempFile(dir, "scattertest", ".zip");
final ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(target);
scatterZipOutputStream.writeTo(outputStream);
outputStream.close();
@@ -254,7 +254,7 @@ public class ZipMemoryFileSystemTest {
.forEach(path -> {
try {
Files.deleteIfExists(path);
- } catch (IOException ignore) {
+ } catch (final IOException ignore) {
}
});
}
@@ -263,7 +263,7 @@ public class ZipMemoryFileSystemTest {
@Test
public void zipFileInMemory() throws IOException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
- Path scatterFile = fileSystem.getPath("scattertest.notzip");
+ final Path scatterFile = fileSystem.getPath("scattertest.notzip");
final ScatterZipOutputStream scatterZipOutputStream = ScatterZipOutputStream.pathBased(scatterFile,
Deflater.BEST_COMPRESSION);
final byte[] B_PAYLOAD = "RBBBBBBS".getBytes();
@@ -279,7 +279,7 @@ public class ZipMemoryFileSystemTest {
final ByteArrayInputStream payload1 = new ByteArrayInputStream(A_PAYLOAD);
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae, createPayloadSupplier(payload1)));
- Path target = fileSystem.getPath("scattertest.zip");
+ final Path target = fileSystem.getPath("scattertest.zip");
final ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(target);
scatterZipOutputStream.writeTo(outputStream);
outputStream.close();
@@ -301,7 +301,7 @@ public class ZipMemoryFileSystemTest {
public void zipFromMemoryFileSystemFile() throws IOException, NoSuchAlgorithmException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
final Path textFileInMemSys = fileSystem.getPath("test.txt");
- byte[] bytes = new byte[100 * 1024];
+ final byte[] bytes = new byte[100 * 1024];
SecureRandom.getInstanceStrong().nextBytes(bytes);
Files.write(textFileInMemSys, bytes);
@@ -343,7 +343,7 @@ public class ZipMemoryFileSystemTest {
public void zipFromMemoryFileSystemPath() throws IOException, NoSuchAlgorithmException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
final Path textFileInMemSys = fileSystem.getPath("test.txt");
- byte[] bytes = new byte[100 * 1024];
+ final byte[] bytes = new byte[100 * 1024];
SecureRandom.getInstanceStrong().nextBytes(bytes);
Files.write(textFileInMemSys, bytes);
@@ -365,7 +365,7 @@ public class ZipMemoryFileSystemTest {
public void zipFromMemoryFileSystemSeekableByteChannel() throws IOException, NoSuchAlgorithmException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
final Path textFileInMemSys = fileSystem.getPath("test.txt");
- byte[] bytes = new byte[100 * 1024];
+ final byte[] bytes = new byte[100 * 1024];
SecureRandom.getInstanceStrong().nextBytes(bytes);
Files.write(textFileInMemSys, bytes);
@@ -389,7 +389,7 @@ public class ZipMemoryFileSystemTest {
public void zipFromMemoryFileSystemSplitFile() throws IOException, NoSuchAlgorithmException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
final Path textFileInMemSys = fileSystem.getPath("test.txt");
- byte[] bytes = new byte[100 * 1024];
+ final byte[] bytes = new byte[100 * 1024];
SecureRandom.getInstanceStrong().nextBytes(bytes);
Files.write(textFileInMemSys, bytes);
@@ -485,7 +485,7 @@ public class ZipMemoryFileSystemTest {
public void zipToMemoryFileSystemSplitPath() throws IOException, NoSuchAlgorithmException {
try (FileSystem fileSystem = MemoryFileSystemBuilder.newLinux().build()) {
final Path zipInMemSys = fileSystem.getPath("target.zip");
- byte[] bytes = new byte[100 * 1024];
+ final byte[] bytes = new byte[100 * 1024];
SecureRandom.getInstanceStrong().nextBytes(bytes);
try (final ArchiveOutputStream zipOut = new ZipArchiveOutputStream(zipInMemSys, 64 * 1024L)) {
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java
index 68070b5e..3c003fa5 100755
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java
@@ -55,14 +55,14 @@ public class ArchiveTest {
private void compareFiles(final JarFile jarFile, final JarFile jarFile2)
throws IOException {
- Enumeration<JarEntry> entries = jarFile.entries();
+ final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- String name = entry.getName();
- JarEntry entry2 = jarFile2.getJarEntry(name);
+ final String name = entry.getName();
+ final JarEntry entry2 = jarFile2.getJarEntry(name);
assertNotNull(entry2, "Missing Entry: " + name);
// assertEquals(entry.getTime(), entry2.getTime());
if (!name.equals("META-INF/MANIFEST.MF")) { // Manifests aren't
@@ -70,12 +70,12 @@ public class ArchiveTest {
// byte-for-byte
// identical
- InputStream ours = jarFile.getInputStream(entry);
- InputStream expected = jarFile2.getInputStream(entry2);
+ final InputStream ours = jarFile.getInputStream(entry);
+ final InputStream expected = jarFile2.getInputStream(entry2);
- BufferedReader reader1 = new BufferedReader(
+ final BufferedReader reader1 = new BufferedReader(
new InputStreamReader(ours));
- BufferedReader reader2 = new BufferedReader(
+ final BufferedReader reader2 = new BufferedReader(
new InputStreamReader(expected));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
@@ -95,21 +95,21 @@ public class ArchiveTest {
}
private void compareJarEntries(final JarFile jarFile, final JarFile jarFile2) {
- Enumeration<JarEntry> entries = jarFile.entries();
+ final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- String name = entry.getName();
- JarEntry entry2 = jarFile2.getJarEntry(name);
+ final String name = entry.getName();
+ final JarEntry entry2 = jarFile2.getJarEntry(name);
assertNotNull(entry2, "Missing Entry: " + name);
}
}
@Test
public void testAlternativeConstructor() throws IOException, URISyntaxException, Pack200Exception {
- JarInputStream inStream = new JarInputStream(new FileInputStream(
+ final JarInputStream inStream = new JarInputStream(new FileInputStream(
new File(Archive.class.getResource(
"/pack200/sqlUnpacked.jar").toURI())));
file = File.createTempFile("sql", ".pack.gz");
@@ -129,22 +129,22 @@ public class ArchiveTest {
file = File.createTempFile("annotations", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.setGzip(false);
new Archive(in, out, options).pack();
in.close();
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("annotationsout", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("annotationsout", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
archive.unpack();
- JarFile jarFile = new JarFile(file2);
- JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
+ final JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
"/pack200/annotationsUnpacked.jar").toURI()));
compareFiles(jarFile, jarFile2);
@@ -159,24 +159,24 @@ public class ArchiveTest {
file = File.createTempFile("annotations", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.setGzip(false);
new Archive(in, out, options).pack();
in.close();
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("annotationsout", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("annotationsout", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
archive.unpack();
// TODO: This isn't quite right - to fix
- JarFile jarFile = new JarFile(file2);
- JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
+ final JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
"/pack200/annotationsRI.jar")
.toURI()));
compareFiles(jarFile, jarFile2);
@@ -194,32 +194,32 @@ public class ArchiveTest {
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("helloworld", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("helloworld", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
archive.unpack();
out2.close();
in2.close();
- JarFile jarFile = new JarFile(file2);
- JarEntry entry = jarFile
+ final JarFile jarFile = new JarFile(file2);
+ final JarEntry entry = jarFile
.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
assertNotNull(entry);
- InputStream ours = jarFile.getInputStream(entry);
+ final InputStream ours = jarFile.getInputStream(entry);
- JarFile jarFile2 = new JarFile(new File(Segment.class.getResource(
+ final JarFile jarFile2 = new JarFile(new File(Segment.class.getResource(
"/pack200/hw.jar").toURI()));
- JarEntry entry2 = jarFile2
+ final JarEntry entry2 = jarFile2
.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
assertNotNull(entry2);
- InputStream expected = jarFile2.getInputStream(entry2);
+ final InputStream expected = jarFile2.getInputStream(entry2);
- BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
- BufferedReader reader2 = new BufferedReader(new InputStreamReader(
+ final BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
+ final BufferedReader reader2 = new BufferedReader(new InputStreamReader(
expected));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
@@ -241,21 +241,21 @@ public class ArchiveTest {
file = File.createTempFile("jndi", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.setGzip(false);
new Archive(in, out, options).pack();
in.close();
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("jndiout", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("jndiout", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(in2, out2);
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(in2, out2);
archive.unpack();
- JarFile jarFile = new JarFile(file2);
- JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
+ final JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
"/pack200/jndiUnpacked.jar").toURI()));
compareFiles(jarFile, jarFile2);
@@ -270,24 +270,24 @@ public class ArchiveTest {
file = File.createTempFile("largeClass", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.setGzip(false);
new Archive(in, out, options).pack();
in.close();
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("largeClassOut", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("largeClassOut", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(in2, out2);
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(in2, out2);
archive.unpack();
- JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile = new JarFile(file2);
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/largeClassUnpacked.jar").toURI());
- JarFile jarFile2 = new JarFile(compareFile);
+ final JarFile jarFile2 = new JarFile(compareFile);
assertEquals(jarFile2.size(), jarFile.size());
@@ -297,7 +297,7 @@ public class ArchiveTest {
static Stream<Arguments> loadMultipleJars() throws URISyntaxException, IOException {
return Files.list(Paths.get(Archive.class.getResource("/pack200/jars").toURI()))
.filter(child -> {
- String fileName = child.getFileName().toString();
+ final String fileName = child.getFileName().toString();
return fileName.endsWith(".jar") && !fileName.endsWith("Unpacked.jar");
})
.map(Arguments::of);
@@ -306,7 +306,7 @@ public class ArchiveTest {
@ParameterizedTest
@MethodSource("loadMultipleJars")
public void testMultipleJars(final Path path) throws URISyntaxException, IOException, Pack200Exception {
- File inputFile = path.toFile();
+ final File inputFile = path.toFile();
in = new JarFile(inputFile);
file = File.createTempFile("temp", ".pack.gz");
file.deleteOnExit();
@@ -327,25 +327,25 @@ public class ArchiveTest {
file = File.createTempFile("sql", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.setGzip(false);
- Archive ar = new Archive(in, out, options);
+ final Archive ar = new Archive(in, out, options);
ar.pack();
in.close();
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("sqlout", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("sqlout", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(in2, out2);
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(in2, out2);
archive.unpack();
- JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile = new JarFile(file2);
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/sqlUnpacked.jar").toURI());
- JarFile jarFile2 = new JarFile(compareFile);
+ final JarFile jarFile2 = new JarFile(compareFile);
assertEquals(jarFile2.size(), jarFile.size());
@@ -355,16 +355,16 @@ public class ArchiveTest {
// Test with an archive containing Annotations
@Test
public void testWithAnnotations2() throws Exception {
- InputStream i = Archive.class
+ final InputStream i = Archive.class
.getResourceAsStream("/pack200/annotationsRI.pack.gz");
file = File.createTempFile("annotations", ".jar");
file.deleteOnExit();
- JarOutputStream jout = new JarOutputStream(new FileOutputStream(file));
- org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream jout = new JarOutputStream(new FileOutputStream(file));
+ final org.apache.commons.compress.harmony.unpack200.Archive archive = new org.apache.commons.compress.harmony.unpack200.Archive(
i, jout);
archive.unpack();
- JarFile jarFile = new JarFile(file);
- JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
+ final JarFile jarFile = new JarFile(file);
+ final JarFile jarFile2 = new JarFile(new File(Archive.class.getResource(
"/pack200/annotationsRI.jar")
.toURI()));
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/BHSDCodecTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/BHSDCodecTest.java
index 3b2264bc..71d1ff5d 100644
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/BHSDCodecTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/BHSDCodecTest.java
@@ -41,10 +41,10 @@ public class BHSDCodecTest {
@Test
public void testDeltaEncodings() throws IOException, Pack200Exception {
- Codec c = Codec.UDELTA5;
- int[] sequence = {0, 2, 4, 2, 2, 4};
- byte[] encoded = c.encode(sequence);
- int[] decoded = c.decodeInts(6, new ByteArrayInputStream(encoded));
+ final Codec c = Codec.UDELTA5;
+ final int[] sequence = {0, 2, 4, 2, 2, 4};
+ final byte[] encoded = c.encode(sequence);
+ final int[] decoded = c.decodeInts(6, new ByteArrayInputStream(encoded));
for (int i = 0; i < decoded.length; i++) {
assertEquals(sequence[i], decoded[i]);
}
@@ -57,27 +57,27 @@ public class BHSDCodecTest {
@ParameterizedTest
@MethodSource("encodeDecodeRange")
public void testEncodeDecode(final int i) throws IOException, Pack200Exception {
- BHSDCodec codec = (BHSDCodec) CodecEncoding.getCodec(i, null, null);
+ final BHSDCodec codec = (BHSDCodec) CodecEncoding.getCodec(i, null, null);
if (!codec.isDelta()) {
// Test encode-decode with a selection of numbers within the
// range of the codec
- long largest = codec.largest();
+ final long largest = codec.largest();
long smallest = codec.isSigned() ? codec.smallest() : 0;
if (smallest < Integer.MIN_VALUE) {
smallest = Integer.MIN_VALUE;
}
- long difference = (largest - smallest) / 4;
+ final long difference = (largest - smallest) / 4;
for (long j = smallest; j <= largest; j += difference) {
if (j > Integer.MAX_VALUE) {
break;
}
- byte[] encoded = codec.encode((int) j, 0);
+ final byte[] encoded = codec.encode((int) j, 0);
long decoded = 0;
try {
decoded = codec.decode(
new ByteArrayInputStream(encoded), 0);
- } catch (EOFException e) {
+ } catch (final EOFException e) {
System.out.println(e);
}
if (j != decoded) {
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecEncodingTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecEncodingTest.java
index a0cac94c..d3ebe43c 100644
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecEncodingTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecEncodingTest.java
@@ -57,7 +57,7 @@ public class CodecEncodingTest {
@Test
public void testDefaultCodec() throws Pack200Exception, IOException {
- Codec defaultCodec = new BHSDCodec(2, 16, 0, 0);
+ final Codec defaultCodec = new BHSDCodec(2, 16, 0, 0);
assertEquals(defaultCodec, CodecEncoding.getCodec(0, null, defaultCodec));
}
@@ -190,16 +190,16 @@ public class CodecEncodingTest {
@Test
public void testGetSpeciferForPopulationCodec() throws IOException, Pack200Exception {
- PopulationCodec pCodec = new PopulationCodec(Codec.BYTE1, Codec.CHAR3, Codec.UNSIGNED5);
- int[] specifiers = CodecEncoding.getSpecifier(pCodec, null);
+ final PopulationCodec pCodec = new PopulationCodec(Codec.BYTE1, Codec.CHAR3, Codec.UNSIGNED5);
+ final int[] specifiers = CodecEncoding.getSpecifier(pCodec, null);
assertTrue(specifiers[0] > 140);
assertTrue(specifiers[0] < 189);
- byte[] bytes = new byte[specifiers.length - 1];
+ final byte[] bytes = new byte[specifiers.length - 1];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) specifiers[i+1];
}
- InputStream in = new ByteArrayInputStream(bytes);
- PopulationCodec pCodec2 = (PopulationCodec) CodecEncoding.getCodec(specifiers[0], in, null);
+ final InputStream in = new ByteArrayInputStream(bytes);
+ final PopulationCodec pCodec2 = (PopulationCodec) CodecEncoding.getCodec(specifiers[0], in, null);
assertEquals(pCodec.getFavouredCodec(), pCodec2.getFavouredCodec());
assertEquals(pCodec.getTokenCodec(), pCodec2.getTokenCodec());
assertEquals(pCodec.getUnfavouredCodec(), pCodec2.getUnfavouredCodec());
@@ -299,11 +299,11 @@ public class CodecEncodingTest {
@ParameterizedTest
@MethodSource("specifier")
void testGetSpecifier(final Codec c1) throws IOException, Pack200Exception {
- int[] specifiers = CodecEncoding.getSpecifier(c1, null);
+ final int[] specifiers = CodecEncoding.getSpecifier(c1, null);
assertEquals(3, specifiers.length);
assertEquals(116, specifiers[0]);
- byte[] bytes = {(byte) specifiers[1], (byte) specifiers[2]};
- InputStream in = new ByteArrayInputStream(bytes);
+ final byte[] bytes = {(byte) specifiers[1], (byte) specifiers[2]};
+ final InputStream in = new ByteArrayInputStream(bytes);
assertEquals(c1, CodecEncoding.getCodec(116, in, null));
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java
index 0da2bb47..bdb06288 100644
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java
@@ -65,7 +65,7 @@ public class CodecTest {
@Test
public void testByte1Delta() throws Exception {
- Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
+ final Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
long last = 0;
for (int i = 1; i < 255; i++) {
last = decode(BYTE1D, new byte[] { (byte) 1 }, i, last);
@@ -74,14 +74,14 @@ public class CodecTest {
@Test
public void testByte1DeltaException() throws Exception {
- Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
+ final Codec BYTE1D = new BHSDCodec(1, 256, 0, 1);
assertThrows(Pack200Exception.class, () -> BYTE1D.decode(new ByteArrayInputStream(new byte[]{(byte) 1})),
"Decoding with a delta stream and not passing a last value should throw an exception");
}
@Test
public void testByte1Signed() throws Exception {
- Codec BYTE1S2 = new BHSDCodec(1, 256, 2);
+ final Codec BYTE1S2 = new BHSDCodec(1, 256, 2);
decode(BYTE1S2, new byte[] { 0 }, 0, 0);
decode(BYTE1S2, new byte[] { 1 }, 1, 0);
decode(BYTE1S2, new byte[] { 2 }, 2, 0);
@@ -98,7 +98,7 @@ public class CodecTest {
@Test
public void testCardinality() {
- BHSDCodec byte1 = Codec.BYTE1;
+ final BHSDCodec byte1 = Codec.BYTE1;
assertEquals(256, byte1.cardinality());
assertEquals(0, byte1.smallest());
assertEquals(255, byte1.largest());
@@ -113,7 +113,7 @@ public class CodecTest {
assertTrue(byte1.encodes(1));
assertTrue(byte1.encodes(255));
assertFalse(byte1.encodes(256));
- BHSDCodec byte1s = new BHSDCodec(1, 256, 1);
+ final BHSDCodec byte1s = new BHSDCodec(1, 256, 1);
assertEquals(256, byte1s.cardinality());
assertEquals(-128, byte1s.smallest());
assertEquals(127, byte1s.largest());
@@ -131,7 +131,7 @@ public class CodecTest {
assertFalse(byte1s.encodes(129));
assertFalse(byte1s.encodes(255));
assertFalse(byte1s.encodes(256));
- BHSDCodec byte2s = new BHSDCodec(1, 256, 2);
+ final BHSDCodec byte2s = new BHSDCodec(1, 256, 2);
assertEquals(256, byte2s.cardinality());
assertEquals(-64, byte2s.smallest());
assertEquals(191, byte2s.largest());
@@ -182,8 +182,8 @@ public class CodecTest {
@MethodSource("codecFamily")
public void testCodecFamilies(final BHSDCodec[] family) {
for (int i = 1; i < family.length; i++) {
- BHSDCodec previous = family[i-1];
- BHSDCodec codec = family[i];
+ final BHSDCodec previous = family[i-1];
+ final BHSDCodec codec = family[i];
assertTrue(codec.largest() >= previous.largest());
assertTrue(codec.smallest() <= previous.smallest());
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/NewAttributeBandsTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/NewAttributeBandsTest.java
index 79439ea1..92795212 100644
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/NewAttributeBandsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/NewAttributeBandsTest.java
@@ -67,9 +67,9 @@ public class NewAttributeBandsTest {
@Test
public void testAddAttributes() throws IOException, Pack200Exception {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8("B");
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8("B");
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
@@ -78,11 +78,11 @@ public class NewAttributeBandsTest {
"B", new byte[] { 56 }, null, 0, null));
newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
"B", new byte[] { 3 }, null, 0, null));
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
newAttributeBands.pack(out);
// BYTE1 is used for B layouts so we don't need to unpack to test the
// results
- byte[] bytes = out.toByteArray();
+ final byte[] bytes = out.toByteArray();
assertEquals(3, bytes.length);
assertEquals(27, bytes[0]);
assertEquals(56, bytes[1]);
@@ -92,26 +92,26 @@ public class NewAttributeBandsTest {
@Test
public void testAddAttributesWithReplicationLayout() throws IOException,
Pack200Exception {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8("NB[SH]");
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8("NB[SH]");
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
"B", new byte[] { 1, 0, 100 }, null, 0, null));
- short s = -50;
- byte b1 = (byte) (s >>> 8);
- byte b2 = (byte) s;
+ final short s = -50;
+ final byte b1 = (byte) (s >>> 8);
+ final byte b2 = (byte) s;
newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
"B", new byte[] { 3, 0, 5, 0, 25, b1, b2 }, null, 0, null));
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
newAttributeBands.pack(out);
- byte[] bytes = out.toByteArray();
+ final byte[] bytes = out.toByteArray();
assertEquals(1, bytes[0]);
assertEquals(3, bytes[1]);
- byte[] band = new byte[bytes.length - 2];
+ final byte[] band = new byte[bytes.length - 2];
System.arraycopy(bytes, 2, band, 0, band.length);
- int[] decoded = Codec.SIGNED5.decodeInts(4, new ByteArrayInputStream(
+ final int[] decoded = Codec.SIGNED5.decodeInts(4, new ByteArrayInputStream(
band));
assertEquals(4, decoded.length);
assertEquals(100, decoded[0]);
@@ -122,12 +122,12 @@ public class NewAttributeBandsTest {
@Test
public void testEmptyLayout() throws IOException {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8("");
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8("");
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
- List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
+ final List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
assertEquals(0, layoutElements.size());
}
@@ -137,14 +137,14 @@ public class NewAttributeBandsTest {
"POB", "PH", "OH", "OSH", "POH", "PI", "OI", "OSI", "POI"
})
public void testIntegralLayouts(final String layoutStr) throws IOException {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8(layoutStr);
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8(layoutStr);
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
- List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
+ final List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Integral element = (Integral) layoutElements.get(0);
+ final Integral element = (Integral) layoutElements.get(0);
assertEquals(layoutStr, element.getTag());
}
@@ -207,23 +207,23 @@ public class NewAttributeBandsTest {
@Test
public void testLayoutWithCalls() throws IOException {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8(
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8(
"[NH[(1)]][RSH NH[RUH(1)]][TB(66,67,73,83,90)[KIH](68)[KDH](70)[KFH](74)[KJH](99)[RSH](101)[RSH RUH](115)[RUH](91)[NH[(0)]](64)[RSH[RUH(0)]]()[]]");
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
- List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
+ final List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
assertEquals(3, layoutElements.size());
- Callable firstCallable = (Callable) layoutElements.get(0);
- Callable secondCallable = (Callable) layoutElements.get(1);
- Callable thirdCallable = (Callable) layoutElements.get(2);
- List<LayoutElement> firstBody = firstCallable.getBody();
+ final Callable firstCallable = (Callable) layoutElements.get(0);
+ final Callable secondCallable = (Callable) layoutElements.get(1);
+ final Callable thirdCallable = (Callable) layoutElements.get(2);
+ final List<LayoutElement> firstBody = firstCallable.getBody();
assertEquals(1, firstBody.size());
- Replication rep = (Replication) firstBody.get(0);
- List<LayoutElement> repBody = rep.getLayoutElements();
+ final Replication rep = (Replication) firstBody.get(0);
+ final List<LayoutElement> repBody = rep.getLayoutElements();
assertEquals(1, repBody.size());
- Call call = (Call) repBody.get(0);
+ final Call call = (Call) repBody.get(0);
assertEquals(1, call.getCallableIndex());
assertEquals(secondCallable, call.getCallable());
assertFalse(firstCallable.isBackwardsCallable());
@@ -237,72 +237,72 @@ public class NewAttributeBandsTest {
"RSH", "RDH", "RFH", "RMH", "RIH", "RUH", "RQH", "RQNH", "RQNI"
})
public void testReferenceLayouts(final String layoutStr) throws IOException {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8(layoutStr);
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8(layoutStr);
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
- List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
+ final List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Reference element = (Reference) layoutElements.get(0);
+ final Reference element = (Reference) layoutElements.get(0);
assertEquals(layoutStr, element.getTag());
}
@Test
public void testReplicationLayouts() throws IOException {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8("NH[PHOHRUHRSHH]");
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8("NH[PHOHRUHRSHH]");
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
- List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
+ final List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Replication element = (Replication) layoutElements.get(0);
- Integral countElement = element.getCountElement();
+ final Replication element = (Replication) layoutElements.get(0);
+ final Integral countElement = element.getCountElement();
assertEquals("H", countElement.getTag());
- List<LayoutElement> replicatedElements = element.getLayoutElements();
+ final List<LayoutElement> replicatedElements = element.getLayoutElements();
assertEquals(5, replicatedElements.size());
- Integral firstElement = (Integral) replicatedElements.get(0);
+ final Integral firstElement = (Integral) replicatedElements.get(0);
assertEquals("PH", firstElement.getTag());
- Integral secondElement = (Integral) replicatedElements.get(1);
+ final Integral secondElement = (Integral) replicatedElements.get(1);
assertEquals("OH", secondElement.getTag());
- Reference thirdElement = (Reference) replicatedElements.get(2);
+ final Reference thirdElement = (Reference) replicatedElements.get(2);
assertEquals("RUH", thirdElement.getTag());
- Reference fourthElement = (Reference) replicatedElements.get(3);
+ final Reference fourthElement = (Reference) replicatedElements.get(3);
assertEquals("RSH", fourthElement.getTag());
- Integral fifthElement = (Integral) replicatedElements.get(4);
+ final Integral fifthElement = (Integral) replicatedElements.get(4);
assertEquals("H", fifthElement.getTag());
}
@Test
public void testUnionLayout() throws IOException {
- CPUTF8 name = new CPUTF8("TestAttribute");
- CPUTF8 layout = new CPUTF8("TB(55)[FH](23)[]()[RSH]");
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+ final CPUTF8 name = new CPUTF8("TestAttribute");
+ final CPUTF8 layout = new CPUTF8("TB(55)[FH](23)[]()[RSH]");
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
null, null, new AttributeDefinition(35,
AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
- List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
+ final List<AttributeLayoutElement> layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Union element = (Union) layoutElements.get(0);
- Integral tag = element.getUnionTag();
+ final Union element = (Union) layoutElements.get(0);
+ final Integral tag = element.getUnionTag();
assertEquals("B", tag.getTag());
- List<UnionCase> unionCases = element.getUnionCases();
+ final List<UnionCase> unionCases = element.getUnionCases();
assertEquals(2, unionCases.size());
- UnionCase firstCase = unionCases.get(0);
+ final UnionCase firstCase = unionCases.get(0);
assertTrue(firstCase.hasTag(55));
assertFalse(firstCase.hasTag(23));
List<LayoutElement> body = firstCase.getBody();
assertEquals(1, body.size());
- Integral bodyElement = (Integral) body.get(0);
+ final Integral bodyElement = (Integral) body.get(0);
assertEquals("FH", bodyElement.getTag());
- UnionCase secondCase = unionCases.get(1);
+ final UnionCase secondCase = unionCases.get(1);
assertTrue(secondCase.hasTag(23));
assertFalse(secondCase.hasTag(55));
body = secondCase.getBody();
assertEquals(0, body.size());
- List<LayoutElement> defaultBody = element.getDefaultCaseBody();
+ final List<LayoutElement> defaultBody = element.getDefaultCaseBody();
assertEquals(1, defaultBody.size());
- Reference ref = (Reference) defaultBody.get(0);
+ final Reference ref = (Reference) defaultBody.get(0);
assertEquals("RSH", ref.getTag());
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java
index 918e36d7..1f4aad23 100644
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java
@@ -54,14 +54,14 @@ public class PackingOptionsTest {
private void compareFiles(final JarFile jarFile, final JarFile jarFile2)
throws IOException {
- Enumeration<JarEntry> entries = jarFile.entries();
+ final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- String name = entry.getName();
- JarEntry entry2 = jarFile2.getJarEntry(name);
+ final String name = entry.getName();
+ final JarEntry entry2 = jarFile2.getJarEntry(name);
assertNotNull(entry2, "Missing Entry: " + name);
// assertEquals(entry.getTime(), entry2.getTime());
if (!name.equals("META-INF/MANIFEST.MF")) { // Manifests aren't
@@ -69,12 +69,12 @@ public class PackingOptionsTest {
// byte-for-byte
// identical
- InputStream ours = jarFile.getInputStream(entry);
- InputStream expected = jarFile2.getInputStream(entry2);
+ final InputStream ours = jarFile.getInputStream(entry);
+ final InputStream expected = jarFile2.getInputStream(entry2);
- BufferedReader reader1 = new BufferedReader(
+ final BufferedReader reader1 = new BufferedReader(
new InputStreamReader(ours));
- BufferedReader reader2 = new BufferedReader(
+ final BufferedReader reader2 = new BufferedReader(
new InputStreamReader(expected));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
@@ -94,14 +94,14 @@ public class PackingOptionsTest {
}
private void compareJarEntries(final JarFile jarFile, final JarFile jarFile2) {
- Enumeration<JarEntry> entries = jarFile.entries();
+ final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- String name = entry.getName();
- JarEntry entry2 = jarFile2.getJarEntry(name);
+ final String name = entry.getName();
+ final JarEntry entry2 = jarFile2.getJarEntry(name);
assertNotNull(entry2, "Missing Entry: " + name);
}
}
@@ -109,7 +109,7 @@ public class PackingOptionsTest {
@Test
public void testDeflateHint() {
// Test default first
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
assertEquals("keep", options.getDeflateHint());
options.setDeflateHint("true");
assertEquals("true", options.getDeflateHint());
@@ -122,16 +122,16 @@ public class PackingOptionsTest {
@Test
public void testE0() throws Pack200Exception, IOException,
URISyntaxException {
- File f1 = new File(Archive.class.getResource(
+ final File f1 = new File(Archive.class.getResource(
"/pack200/jndi.jar").toURI());
in = new JarFile(f1);
file = File.createTempFile("jndiE0", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.setGzip(false);
options.setEffort(0);
- Archive archive = new Archive(in, out, options);
+ final Archive archive = new Archive(in, out, options);
archive.pack();
in.close();
out.close();
@@ -150,10 +150,10 @@ public class PackingOptionsTest {
file = File.createTempFile("unknown", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.addClassAttributeAction("Pack200", "error");
- Archive ar = new Archive(in, out, options);
- Error error = assertThrows(Error.class, () -> {
+ final Archive ar = new Archive(in, out, options);
+ final Error error = assertThrows(Error.class, () -> {
ar.pack();
in.close();
out.close();
@@ -201,11 +201,11 @@ public class PackingOptionsTest {
Enumeration<JarEntry> entries2 = jarFile2.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- JarEntry entry2 = entries2.nextElement();
- String name = entry.getName();
- String name2 = entry2.getName();
+ final JarEntry entry2 = entries2.nextElement();
+ final String name = entry.getName();
+ final String name2 = entry2.getName();
assertEquals(name, name2);
}
@@ -244,11 +244,11 @@ public class PackingOptionsTest {
entries2 = jarFile2.entries();
boolean inOrder = true;
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- JarEntry entry2 = entries2.nextElement();
- String name = entry.getName();
- String name2 = entry2.getName();
+ final JarEntry entry2 = entries2.nextElement();
+ final String name = entry.getName();
+ final String name2 = entry2.getName();
if (!name.equals(name2)) {
inOrder = false;
break;
@@ -261,7 +261,7 @@ public class PackingOptionsTest {
@Test
public void testLoggingOptions() throws Exception {
// Test defaults
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
assertFalse(options.isVerbose());
assertNull(options.getLogFile());
options.setVerbose(true);
@@ -269,7 +269,7 @@ public class PackingOptionsTest {
options.setQuiet(true);
assertFalse(options.isVerbose());
- File logFile = File.createTempFile("logfile", ".txt");
+ final File logFile = File.createTempFile("logfile", ".txt");
logFile.deleteOnExit();
options.setLogFile(logFile.getPath());
assertEquals(logFile.getPath(), options.getLogFile());
@@ -312,7 +312,7 @@ public class PackingOptionsTest {
options.setModificationTime("latest");
assertEquals("latest", options.getModificationTime());
assertThrows(IllegalArgumentException.class, () -> {
- PackingOptions illegalOption = new PackingOptions();
+ final PackingOptions illegalOption = new PackingOptions();
illegalOption.setModificationTime("true");
},
"Should throw IllegalArgumentException for incorrect mod time");
@@ -349,11 +349,11 @@ public class PackingOptionsTest {
Enumeration<JarEntry> entries2 = jarFile2.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- JarEntry entry2 = entries2.nextElement();
- String name = entry.getName();
- String name2 = entry2.getName();
+ final JarEntry entry2 = entries2.nextElement();
+ final String name = entry.getName();
+ final String name2 = entry2.getName();
assertEquals(name, name2);
assertEquals(entry.getTime(), entry2.getTime());
}
@@ -392,10 +392,10 @@ public class PackingOptionsTest {
long modtime = -1;
boolean sameAsOriginal = true;
while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- JarEntry entry2 = entries2.nextElement();
- String name = entry.getName();
+ final JarEntry entry2 = entries2.nextElement();
+ final String name = entry.getName();
if (!name.startsWith("META-INF")) {
if (modtime == -1) {
modtime = entry.getTime();
@@ -421,28 +421,28 @@ public class PackingOptionsTest {
file = File.createTempFile("unknown", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.addClassAttributeAction("Pack200", "I");
- Archive ar = new Archive(in, out, options);
+ final Archive ar = new Archive(in, out, options);
ar.pack();
in.close();
out.close();
// unpack and check this was done right
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("unknown", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("unknown", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
u2archive.unpack();
// compare with original
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/jndiWithUnknownAttributes.jar").toURI());
- JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile = new JarFile(file2);
- JarFile jarFile2 = new JarFile(compareFile);
+ final JarFile jarFile2 = new JarFile(compareFile);
assertEquals(jarFile2.size(), jarFile.size());
compareJarEntries(jarFile, jarFile2);
// compareFiles(jarFile, jarFile2);
@@ -459,30 +459,30 @@ public class PackingOptionsTest {
file = File.createTempFile("unknown", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.addFieldAttributeAction("Pack200", "I");
options.addMethodAttributeAction("Pack200", "I");
options.addCodeAttributeAction("Pack200", "I");
- Archive ar = new Archive(in, out, options);
+ final Archive ar = new Archive(in, out, options);
ar.pack();
in.close();
out.close();
// unpack and check this was done right
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("unknown", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("unknown", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
u2archive.unpack();
// compare with original
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/p200WithUnknownAttributes.jar").toURI());
- JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile = new JarFile(file2);
- JarFile jarFile2 = new JarFile(compareFile);
+ final JarFile jarFile2 = new JarFile(compareFile);
assertEquals(jarFile2.size(), jarFile.size());
compareJarEntries(jarFile, jarFile2);
}
@@ -498,28 +498,28 @@ public class PackingOptionsTest {
file = File.createTempFile("unknown", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.addClassAttributeAction("Pack200", "pass");
- Archive ar = new Archive(in, out, options);
+ final Archive ar = new Archive(in, out, options);
ar.pack();
in.close();
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("unknown", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("unknown", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
u2archive.unpack();
// compare with original
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/jndiWithUnknownAttributes.jar").toURI());
- JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile = new JarFile(file2);
- JarFile jarFile2 = new JarFile(compareFile);
+ final JarFile jarFile2 = new JarFile(compareFile);
assertEquals(jarFile2.size(), jarFile.size());
compareJarEntries(jarFile, jarFile2);
}
@@ -530,7 +530,7 @@ public class PackingOptionsTest {
// Don't pass any
in = new JarFile(new File(Archive.class.getResource(
"/pack200/sqlUnpacked.jar").toURI()));
- File file0 = File.createTempFile("sql", ".pack");
+ final File file0 = File.createTempFile("sql", ".pack");
file0.deleteOnExit();
out = new FileOutputStream(file0);
PackingOptions options = new PackingOptions();
@@ -559,7 +559,7 @@ public class PackingOptionsTest {
// Pass a whole directory
in = new JarFile(new File(Archive.class.getResource(
"/pack200/sqlUnpacked.jar").toURI()));
- File file2 = File.createTempFile("sql", ".pack");
+ final File file2 = File.createTempFile("sql", ".pack");
file2.deleteOnExit();
out = new FileOutputStream(file2);
options = new PackingOptions();
@@ -580,15 +580,15 @@ public class PackingOptionsTest {
"If more files are passed then the pack file should be larger");
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file3 = File.createTempFile("sql", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file3 = File.createTempFile("sql", ".jar");
file3.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file3));
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file3));
org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
u2archive.unpack();
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/sqlUnpacked.jar").toURI());
JarFile jarFile = new JarFile(file3);
@@ -597,10 +597,10 @@ public class PackingOptionsTest {
compareJarEntries(jarFile, jarFile2);
// now unpack the file with lots of passed files
- InputStream in3 = new FileInputStream(file2);
- File file4 = File.createTempFile("sql", ".jar");
+ final InputStream in3 = new FileInputStream(file2);
+ final File file4 = File.createTempFile("sql", ".jar");
file4.deleteOnExit();
- JarOutputStream out3 = new JarOutputStream(new FileOutputStream(file4));
+ final JarOutputStream out3 = new JarOutputStream(new FileOutputStream(file4));
u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(in3, out3);
u2archive.unpack();
jarFile = new JarFile(file4);
@@ -672,30 +672,30 @@ public class PackingOptionsTest {
file = File.createTempFile("sql", ".pack");
file.deleteOnExit();
out = new FileOutputStream(file);
- PackingOptions options = new PackingOptions();
+ final PackingOptions options = new PackingOptions();
options.setGzip(false);
options.setStripDebug(true);
- Archive archive = new Archive(in, out, options);
+ final Archive archive = new Archive(in, out, options);
archive.pack();
in.close();
out.close();
// now unpack
- InputStream in2 = new FileInputStream(file);
- File file2 = File.createTempFile("sqloutNoDebug", ".jar");
+ final InputStream in2 = new FileInputStream(file);
+ final File file2 = File.createTempFile("sqloutNoDebug", ".jar");
file2.deleteOnExit();
- JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
- org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
+ final JarOutputStream out2 = new JarOutputStream(new FileOutputStream(file2));
+ final org.apache.commons.compress.harmony.unpack200.Archive u2archive = new org.apache.commons.compress.harmony.unpack200.Archive(
in2, out2);
u2archive.unpack();
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/sqlUnpackedNoDebug.jar")
.toURI());
- JarFile jarFile = new JarFile(file2);
+ final JarFile jarFile = new JarFile(file2);
assertTrue(file2.length() < 250000);
- JarFile jarFile2 = new JarFile(compareFile);
+ final JarFile jarFile2 = new JarFile(compareFile);
compareFiles(jarFile, jarFile2);
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PopulationCodecTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PopulationCodecTest.java
index 9ebe9cbb..d3edd889 100644
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PopulationCodecTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PopulationCodecTest.java
@@ -64,7 +64,7 @@ public class PopulationCodecTest {
@MethodSource("populationCodec")
public void testPopulationCodec(final byte[] data, final long[] expectedResult, final Codec codec) throws IOException, Pack200Exception {
try (InputStream in = new ByteArrayInputStream(data)) {
- int[] result = new PopulationCodec(codec, codec, codec).decodeInts(
+ final int[] result = new PopulationCodec(codec, codec, codec).decodeInts(
expectedResult.length, in);
assertEquals(expectedResult.length, result.length);
for (int i = 0; i < expectedResult.length; i++) {
diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/RunCodecTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/RunCodecTest.java
index 46d46a71..da37b2fb 100644
--- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/RunCodecTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/RunCodecTest.java
@@ -56,16 +56,16 @@ public class RunCodecTest {
@Test
public void testDecodeInts() throws Exception {
- int[] band = { 1, -2, -3, 1000, 55, 5, 10, 20 };
+ final int[] band = { 1, -2, -3, 1000, 55, 5, 10, 20 };
// first 5 of band to be encoded with DELTA5
- byte[] bytes1 = Codec.DELTA5.encode(new int[] { 1, -2, -3, 1000, 55 });
+ final byte[] bytes1 = Codec.DELTA5.encode(new int[] { 1, -2, -3, 1000, 55 });
// rest of band to be encoded with UNSIGNED5
- byte[] bytes2 = Codec.UNSIGNED5.encode(new int[] { 5, 10, 20 });
- byte[] bandEncoded = new byte[bytes1.length + bytes2.length];
+ final byte[] bytes2 = Codec.UNSIGNED5.encode(new int[] { 5, 10, 20 });
+ final byte[] bandEncoded = new byte[bytes1.length + bytes2.length];
System.arraycopy(bytes1, 0, bandEncoded, 0, bytes1.length);
System.arraycopy(bytes2, 0, bandEncoded, bytes1.length, bytes2.length);
- RunCodec runCodec = new RunCodec(5, Codec.DELTA5, Codec.UNSIGNED5);
- int[] bandDecoded = runCodec.decodeInts(8, new ByteArrayInputStream(
+ final RunCodec runCodec = new RunCodec(5, Codec.DELTA5, Codec.UNSIGNED5);
+ final int[] bandDecoded = runCodec.decodeInts(8, new ByteArrayInputStream(
bandEncoded));
assertEquals(band.length, bandDecoded.length);
for (int i = 0; i < band.length; i++) {
@@ -83,23 +83,23 @@ public class RunCodecTest {
@Test
public void testNestedPopulationCodec() throws Exception {
- int[] band = { 11, 12, 33, 4000, -555, 5, 10, 20, 10, 3, 20,
+ final int[] band = { 11, 12, 33, 4000, -555, 5, 10, 20, 10, 3, 20,
20, 20, 10, 10, 999, 20, 789, 10, 10, 355, 12345 };
// first 5 of band to be encoded with DELTA5
- byte[] bytes1 = Codec.DELTA5
+ final byte[] bytes1 = Codec.DELTA5
.encode(new int[] { 11, 12, 33, 4000, -555 });
// rest of band to be encoded with a PopulationCodec
- PopulationCodec popCodec = new PopulationCodec(Codec.UNSIGNED5,
+ final PopulationCodec popCodec = new PopulationCodec(Codec.UNSIGNED5,
Codec.BYTE1, Codec.UNSIGNED5);
- byte[] bytes2 = popCodec.encode(new int[] { 10, 20 }, new int[] { 0, 1,
+ final byte[] bytes2 = popCodec.encode(new int[] { 10, 20 }, new int[] { 0, 1,
2, 1, 0, 2, 2, 2, 1, 1, 0, 2, 0, 1, 1, 0, 0 }, new int[] { 5,
3, 999, 789, 355, 12345 });
- byte[] bandEncoded = new byte[bytes1.length + bytes2.length];
+ final byte[] bandEncoded = new byte[bytes1.length + bytes2.length];
System.arraycopy(bytes1, 0, bandEncoded, 0, bytes1.length);
System.arraycopy(bytes2, 0, bandEncoded, bytes1.length, bytes2.length);
- RunCodec runCodec = new RunCodec(5, Codec.DELTA5, new PopulationCodec(
+ final RunCodec runCodec = new RunCodec(5, Codec.DELTA5, new PopulationCodec(
Codec.UNSIGNED5, Codec.BYTE1, Codec.UNSIGNED5));
- int[] bandDecoded = runCodec.decodeInts(band.length,
+ final int[] bandDecoded = runCodec.decodeInts(band.length,
new ByteArrayInputStream(bandEncoded));
assertEquals(band.length, bandDecoded.length);
for (int i = 0; i < band.length; i++) {
@@ -109,21 +109,21 @@ public class RunCodecTest {
@Test
public void testNestedRunCodec() throws Exception {
- int[] band = { 1, 2, 3, 10, 20, 30, 100, 200, 300 };
+ final int[] band = { 1, 2, 3, 10, 20, 30, 100, 200, 300 };
// first 3 of band to be encoded with UDELTA5
- byte[] bytes1 = Codec.UDELTA5.encode(new int[] { 1, 2, 3 });
+ final byte[] bytes1 = Codec.UDELTA5.encode(new int[] { 1, 2, 3 });
// rest of band to be encoded with a RunCodec
- byte[] bytes2 = Codec.BYTE1.encode(new int[] { 10, 20, 30 });
- byte[] bytes3 = Codec.UNSIGNED5.encode(new int[] { 100, 200, 300 });
- byte[] bandEncoded = new byte[bytes1.length + bytes2.length
+ final byte[] bytes2 = Codec.BYTE1.encode(new int[] { 10, 20, 30 });
+ final byte[] bytes3 = Codec.UNSIGNED5.encode(new int[] { 100, 200, 300 });
+ final byte[] bandEncoded = new byte[bytes1.length + bytes2.length
+ bytes3.length];
System.arraycopy(bytes1, 0, bandEncoded, 0, bytes1.length);
System.arraycopy(bytes2, 0, bandEncoded, bytes1.length, bytes2.length);
System.arraycopy(bytes3, 0, bandEncoded, bytes1.length + bytes2.length,
bytes3.length);
- RunCodec runCodec = new RunCodec(3, Codec.UDELTA5, new RunCodec(3,
+ final RunCodec runCodec = new RunCodec(3, Codec.UDELTA5, new RunCodec(3,
Codec.BYTE1, Codec.UNSIGNED5));
- int[] bandDecoded = runCodec.decodeInts(9, new ByteArrayInputStream(
+ final int[] bandDecoded = runCodec.decodeInts(9, new ByteArrayInputStream(
bandEncoded));
assertEquals(band.length, bandDecoded.length);
for (int i = 0; i < band.length; i++) {
@@ -148,7 +148,7 @@ public class RunCodecTest {
@Test
public void testToString() throws Pack200Exception {
- RunCodec runCodec = new RunCodec(3, Codec.UNSIGNED5, Codec.BYTE1);
+ final RunCodec runCodec = new RunCodec(3, Codec.UNSIGNED5, Codec.BYTE1);
assertEquals(
"RunCodec[k=" + 3 + ";aCodec=" + Codec.UNSIGNED5 + "bCodec=" + Codec.BYTE1 + "]",
runCodec.toString());
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AbstractBandsTestCase.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AbstractBandsTestCase.java
index 7b9425d8..7eda8ea9 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AbstractBandsTestCase.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AbstractBandsTestCase.java
@@ -40,7 +40,7 @@ public abstract class AbstractBandsTestCase {
public AttributeLayoutMap getAttributeDefinitionMap() {
try {
return new AttributeLayoutMap();
- } catch (Pack200Exception e) {
+ } catch (final Pack200Exception e) {
fail(e.getLocalizedMessage());
}
return null;
@@ -75,7 +75,7 @@ public abstract class AbstractBandsTestCase {
public SegmentOptions getOptions() {
try {
return new SegmentOptions(0);
- } catch (Pack200Exception e) {
+ } catch (final Pack200Exception e) {
return null;
}
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ArchiveTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ArchiveTest.java
index 9a39cdad..ad54b752 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ArchiveTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ArchiveTest.java
@@ -56,7 +56,7 @@ public class ArchiveTest {
if (in != null) {
try {
in.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@@ -64,7 +64,7 @@ public class ArchiveTest {
if (out != null) {
out.close();
}
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
file.delete();
@@ -72,12 +72,12 @@ public class ArchiveTest {
@Test
public void testAlternativeConstructor() throws Exception {
- String inputFile = new File(Archive.class
+ final String inputFile = new File(Archive.class
.getResource("/pack200/sql.pack.gz").toURI()).getPath();
file = File.createTempFile("sql", ".jar");
file.deleteOnExit();
- String outputFile = file.getPath();
- Archive archive = new Archive(inputFile, outputFile);
+ final String outputFile = file.getPath();
+ final Archive archive = new Archive(inputFile, outputFile);
archive.unpack();
}
@@ -113,7 +113,7 @@ public class ArchiveTest {
.getResourceAsStream("/pack200/JustResources.pack.gz");
file = File.createTempFile("Just", "ResourcesGz.jar");
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
@@ -156,7 +156,7 @@ public class ArchiveTest {
reader.close();
// test append option
- long length = logFile.length();
+ final long length = logFile.length();
in = Archive.class
.getResourceAsStream("/pack200/sql.pack.gz");
file = File.createTempFile("logtest", ".jar");
@@ -199,14 +199,14 @@ public class ArchiveTest {
@Test
public void testRemovePackFile() throws Exception {
- File original = new File(Archive.class.getResource(
+ final File original = new File(Archive.class.getResource(
"/pack200/sql.pack.gz").toURI());
- File copy = File.createTempFile("sqlcopy", ".pack.gz");
- BufferedInputStream inputStream = new BufferedInputStream(
+ final File copy = File.createTempFile("sqlcopy", ".pack.gz");
+ final BufferedInputStream inputStream = new BufferedInputStream(
new FileInputStream(original));
- BufferedOutputStream outputStream = new BufferedOutputStream(
+ final BufferedOutputStream outputStream = new BufferedOutputStream(
new FileOutputStream(copy));
- byte[] bytes = new byte[256];
+ final byte[] bytes = new byte[256];
int read = inputStream.read(bytes);
while (read > 0) {
outputStream.write(bytes, 0, read);
@@ -214,11 +214,11 @@ public class ArchiveTest {
}
inputStream.close();
outputStream.close();
- String inputFile = copy.getPath();
+ final String inputFile = copy.getPath();
file = File.createTempFile("sqlout", ".jar");
file.deleteOnExit();
- String outputFile = file.getPath();
- Archive archive = new Archive(inputFile, outputFile);
+ final String outputFile = file.getPath();
+ final Archive archive = new Archive(inputFile, outputFile);
archive.setRemovePackFile(true);
archive.unpack();
assertFalse(copy.exists());
@@ -231,7 +231,7 @@ public class ArchiveTest {
.getResourceAsStream("/pack200/annotations.pack.gz");
file = File.createTempFile("annotations", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
@@ -242,7 +242,7 @@ public class ArchiveTest {
.getResourceAsStream("/pack200/simple-E0.pack.gz");
file = File.createTempFile("simple-e0", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
@@ -253,7 +253,7 @@ public class ArchiveTest {
.getResourceAsStream("/pack200/jndi-e1.pack.gz");
file = File.createTempFile("jndi-e1", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
@@ -266,7 +266,7 @@ public class ArchiveTest {
file = File.createTempFile("largeClass", ".jar");
file.deleteOnExit();
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
@@ -278,7 +278,7 @@ public class ArchiveTest {
.getResourceAsStream("/pack200/pack200.pack.gz");
file = File.createTempFile("p200", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
@@ -289,7 +289,7 @@ public class ArchiveTest {
.getResourceAsStream("/pack200/pack200-e1.pack.gz");
file = File.createTempFile("p200-e1", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
@@ -301,40 +301,40 @@ public class ArchiveTest {
file = File.createTempFile("sql", ".jar");
file.deleteOnExit();
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
- JarFile jarFile = new JarFile(file);
+ final JarFile jarFile = new JarFile(file);
- File compareFile = new File(Archive.class.getResource(
+ final File compareFile = new File(Archive.class.getResource(
"/pack200/sqlUnpacked.jar").toURI());
- JarFile jarFile2 = new JarFile(compareFile);
+ final JarFile jarFile2 = new JarFile(compareFile);
- long differenceInJarSizes = Math.abs(compareFile.length()
+ final long differenceInJarSizes = Math.abs(compareFile.length()
- file.length());
assertTrue(differenceInJarSizes < 100, "Expected jar files to be a similar size, difference was "
+ differenceInJarSizes + " bytes");
- Enumeration<JarEntry> entries = jarFile.entries();
- Enumeration<JarEntry> entries2 = jarFile2.entries();
+ final Enumeration<JarEntry> entries = jarFile.entries();
+ final Enumeration<JarEntry> entries2 = jarFile2.entries();
while(entries.hasMoreElements() && entries2.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
+ final JarEntry entry = entries.nextElement();
assertNotNull(entry);
- String name = entry.getName();
+ final String name = entry.getName();
- JarEntry entry2 = entries2.nextElement();
+ final JarEntry entry2 = entries2.nextElement();
assertNotNull(entry2);
- String name2 = entry2.getName();
+ final String name2 = entry2.getName();
assertEquals(name, name2);
- InputStream ours = jarFile.getInputStream(entry);
- InputStream expected = jarFile2.getInputStream(entry2);
+ final InputStream ours = jarFile.getInputStream(entry);
+ final InputStream expected = jarFile2.getInputStream(entry2);
- BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
- BufferedReader reader2 = new BufferedReader(new InputStreamReader(
+ final BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
+ final BufferedReader reader2 = new BufferedReader(new InputStreamReader(
expected));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
@@ -357,7 +357,7 @@ public class ArchiveTest {
.getResourceAsStream("/pack200/sql-e1.pack.gz");
file = File.createTempFile("sql-e1", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
- Archive archive = new Archive(in, out);
+ final Archive archive = new Archive(in, out);
archive.unpack();
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutMapTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutMapTest.java
index 591e7de5..b2559892 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutMapTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutMapTest.java
@@ -31,7 +31,7 @@ public class AttributeLayoutMapTest {
@Test
public void testRepeatable() throws Pack200Exception {
// Check we can retrieve a default layout
- AttributeLayoutMap a = new AttributeLayoutMap();
+ final AttributeLayoutMap a = new AttributeLayoutMap();
AttributeLayout layout = a.getAttributeLayout("SourceFile",
AttributeLayout.CONTEXT_CLASS);
assertNotNull(layout);
@@ -49,7 +49,7 @@ public class AttributeLayoutMapTest {
assertTrue(layout.matches(-1));
assertFalse(layout.matches(0));
// and that changes don't affect subsequent defaults
- AttributeLayoutMap b = new AttributeLayoutMap();
+ final AttributeLayoutMap b = new AttributeLayoutMap();
layout = b.getAttributeLayout("SourceFile",
AttributeLayout.CONTEXT_CLASS);
assertNotNull(layout);
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutTest.java
index d439344e..e2b4d05c 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/AttributeLayoutTest.java
@@ -119,15 +119,15 @@ public class AttributeLayoutTest {
@ParameterizedTest
@MethodSource("codec")
public void testGetCodec(final String name, final int context, final String layout, final Codec expectedCodec) throws Pack200Exception {
- AttributeLayout attributeLayout = new AttributeLayout(name, context, layout, 1);
+ final AttributeLayout attributeLayout = new AttributeLayout(name, context, layout, 1);
assertEquals(expectedCodec, attributeLayout.getCodec());
}
@Test
public void testLayoutRS() throws Pack200Exception {
- AttributeLayout layout = new AttributeLayout("RS",
+ final AttributeLayout layout = new AttributeLayout("RS",
AttributeLayout.CONTEXT_CLASS, "RS", 1);
- Segment segment = new TestSegment();
+ final Segment segment = new TestSegment();
assertNull(layout.getValue(-1, segment.getConstantPool()));
assertEquals("Eins", ((CPUTF8)layout.getValue(0, segment.getConstantPool())).underlyingString());
assertEquals("Zwei", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
@@ -135,9 +135,9 @@ public class AttributeLayoutTest {
@Test
public void testLayoutRSN() throws Pack200Exception {
- AttributeLayout layout = new AttributeLayout("RSN",
+ final AttributeLayout layout = new AttributeLayout("RSN",
AttributeLayout.CONTEXT_CLASS, "RSN", 1);
- Segment segment = new TestSegment();
+ final Segment segment = new TestSegment();
assertNull(layout.getValue(0, segment.getConstantPool()));
assertEquals("Eins", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
assertEquals("Zwei", ((CPUTF8)layout.getValue(2, segment.getConstantPool())).underlyingString());
@@ -145,9 +145,9 @@ public class AttributeLayoutTest {
@Test
public void testLayoutRU() throws Pack200Exception {
- AttributeLayout layout = new AttributeLayout("RU",
+ final AttributeLayout layout = new AttributeLayout("RU",
AttributeLayout.CONTEXT_CLASS, "RU", 1);
- Segment segment = new TestSegment();
+ final Segment segment = new TestSegment();
assertNull(layout.getValue(-1, segment.getConstantPool()));
assertEquals("Zero", ((CPUTF8)layout.getValue(0, segment.getConstantPool())).underlyingString());
assertEquals("One", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
@@ -155,9 +155,9 @@ public class AttributeLayoutTest {
@Test
public void testLayoutRUN() throws Pack200Exception {
- AttributeLayout layout = new AttributeLayout("RUN",
+ final AttributeLayout layout = new AttributeLayout("RUN",
AttributeLayout.CONTEXT_CLASS, "RUN", 1);
- Segment segment = new TestSegment();
+ final Segment segment = new TestSegment();
assertNull(layout.getValue(0, segment.getConstantPool()));
assertEquals("Zero", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
assertEquals("One", ((CPUTF8)layout.getValue(2, segment.getConstantPool())).underlyingString());
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BandSetTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BandSetTest.java
index 3176ee6e..5f4b8005 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BandSetTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BandSetTest.java
@@ -56,10 +56,10 @@ public class BandSetTest {
@Test
public void testDecodeBandInt() throws IOException, Pack200Exception {
- BHSDCodec codec = Codec.BYTE1;
- byte[] bytes = { (byte) 3, (byte) 56, (byte) 122, (byte) 78 };
- InputStream in = new ByteArrayInputStream(bytes);
- int[] ints = bandSet.decodeBandInt("Test Band", in, codec, 4);
+ final BHSDCodec codec = Codec.BYTE1;
+ final byte[] bytes = { (byte) 3, (byte) 56, (byte) 122, (byte) 78 };
+ final InputStream in = new ByteArrayInputStream(bytes);
+ final int[] ints = bandSet.decodeBandInt("Test Band", in, codec, 4);
for (int i = 0; i < ints.length; i++) {
assertEquals(ints[i], bytes[i], "Wrong value in position " + i);
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BcBandsTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BcBandsTest.java
index d1eee192..30bb5ee5 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BcBandsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/BcBandsTest.java
@@ -64,7 +64,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Override
public int[] getClassSuperInts() {
- int[] superClasses = new int[numClasses];
+ final int[] superClasses = new int[numClasses];
for (int index = 0; index < numClasses; index++) {
superClasses[index] = 0;
}
@@ -73,7 +73,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Override
public int[] getClassThisInts() {
- int[] thisClasses = new int[numClasses];
+ final int[] thisClasses = new int[numClasses];
for (int index = 0; index < numClasses; index++) {
thisClasses[index] = 0;
}
@@ -109,7 +109,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Override
public ArrayList[][] getMethodAttributes() {
- ArrayList[][] attributes = new ArrayList[numClasses][];
+ final ArrayList[][] attributes = new ArrayList[numClasses][];
for (int i = 0; i < attributes.length; i++) {
attributes[i] = new ArrayList[numMethods[i]];
for (int j = 0; j < attributes[i].length; j++) {
@@ -121,7 +121,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Override
public String[][] getMethodDescr() {
- String[][] descr = new String[numClasses][];
+ final String[][] descr = new String[numClasses][];
for (int i = 0; i < descr.length; i++) {
descr[i] = new String[numMethods[i]];
for (int j = 0; j < descr[i].length; j++) {
@@ -133,7 +133,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Override
public long[][] getMethodFlags() {
- long[][] flags = new long[numClasses][];
+ final long[][] flags = new long[numClasses][];
for (int i = 0; i < flags.length; i++) {
flags[i] = new long[numMethods[i]];
}
@@ -143,10 +143,10 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Override
public ArrayList getOrderedCodeAttributes() {
int totalMethods = 0;
- for (int numMethod : numMethods) {
+ for (final int numMethod : numMethods) {
totalMethods = totalMethods + numMethod;
}
- ArrayList orderedAttributeList = new ArrayList();
+ final ArrayList orderedAttributeList = new ArrayList();
for (int classIndex = 0; classIndex < totalMethods; classIndex++) {
orderedAttributeList.add(new ArrayList());
}
@@ -269,16 +269,16 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcByteBand() throws IOException, Pack200Exception {
- byte[] bytes = { 16, (byte) 132, (byte) 188, (byte) 197,
+ final byte[] bytes = { 16, (byte) 132, (byte) 188, (byte) 197,
(byte) 255, 8, 8, 8, 8, // bc_byte band
8, // bc_locals band (required by iinc (132))
8 }; // bc_class band (required by multianewarray (197))
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(4, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_byte = bcBands.getBcByte();
+ final int[] bc_byte = bcBands.getBcByte();
assertEquals(4, bc_byte.length);
- for (int element : bc_byte) {
+ for (final int element : bc_byte) {
assertEquals(8, element);
}
assertEquals(1, bcBands.getBcLocal().length);
@@ -294,18 +294,18 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcCaseBands() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 170, (byte) 171, 0, 0, 0, 0, 0, 0,
+ final byte[] bytes = { (byte) 170, (byte) 171, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 255, 2, 5, // bc_case_count
0, 0, 0, 0, 0, 0, 0, // bc_case_value
0, 0, 0, 0, 0, 0, 0, 0, 0 }; // bc_label
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(18, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_case_count = bcBands.getBcCaseCount();
+ final int[] bc_case_count = bcBands.getBcCaseCount();
assertEquals(2, bc_case_count.length);
assertEquals(2, bc_case_count[0]);
assertEquals(5, bc_case_count[1]);
- int[] bc_case_value = bcBands.getBcCaseValue();
+ final int[] bc_case_value = bcBands.getBcCaseValue();
assertEquals(0, bc_case_value[0]);
assertEquals(0, bc_case_value[1]);
assertEquals(9, bcBands.getBcLabel().length);
@@ -319,12 +319,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcClassRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 233, (byte) 236, (byte) 255, 8, 8 }; // bc_classref
+ final byte[] bytes = { (byte) 233, (byte) 236, (byte) 255, 8, 8 }; // bc_classref
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_classref = bcBands.getBcClassRef();
+ final int[] bc_classref = bcBands.getBcClassRef();
assertEquals(2, bc_classref.length);
}
@@ -336,12 +336,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcDoubleRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 239, (byte) 255, 8 }; // bc_doubleref
+ final byte[] bytes = { (byte) 239, (byte) 255, 8 }; // bc_doubleref
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(1, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_doubleref = bcBands.getBcDoubleRef();
+ final int[] bc_doubleref = bcBands.getBcDoubleRef();
assertEquals(1, bc_doubleref.length);
}
@@ -365,12 +365,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcFieldRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 178, (byte) 179, (byte) 180,
+ final byte[] bytes = { (byte) 178, (byte) 179, (byte) 180,
(byte) 181, (byte) 255, 8, 8, 8, 8 }; // bc_fieldref band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(4, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_fieldref = bcBands.getBcFieldRef();
+ final int[] bc_fieldref = bcBands.getBcFieldRef();
assertEquals(4, bc_fieldref.length);
}
@@ -382,12 +382,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcFloatRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 235, (byte) 238, (byte) 255, 8, 8 }; // bc_floatref
+ final byte[] bytes = { (byte) 235, (byte) 238, (byte) 255, 8, 8 }; // bc_floatref
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_floatref = bcBands.getBcFloatRef();
+ final int[] bc_floatref = bcBands.getBcFloatRef();
assertEquals(2, bc_floatref.length);
}
@@ -399,12 +399,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcIMethodRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 185, (byte) 255, 8 }; // bc_imethodref
+ final byte[] bytes = { (byte) 185, (byte) 255, 8 }; // bc_imethodref
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(1, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_imethodref = bcBands.getBcIMethodRef();
+ final int[] bc_imethodref = bcBands.getBcIMethodRef();
assertEquals(1, bc_imethodref.length);
}
@@ -417,12 +417,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Test
@Disabled("TODO: Need to fix this testcase so it has enough data to pass.")
public void testBcInitRefRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 230, (byte) 231, (byte) 232,
+ final byte[] bytes = { (byte) 230, (byte) 231, (byte) 232,
(byte) 255, 8, 8, 8 }; // bc_initrefref band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(3, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_initrefref = bcBands.getBcInitRef();
+ final int[] bc_initrefref = bcBands.getBcInitRef();
assertEquals(3, bc_initrefref.length);
}
@@ -434,12 +434,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcIntRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 234, (byte) 237, (byte) 255, 8, 8 }; // bc_intref
+ final byte[] bytes = { (byte) 234, (byte) 237, (byte) 255, 8, 8 }; // bc_intref
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_intref = bcBands.getBcIntRef();
+ final int[] bc_intref = bcBands.getBcIntRef();
assertEquals(2, bc_intref.length);
}
@@ -451,7 +451,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcLabelBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 159, (byte) 160, (byte) 161,
+ final byte[] bytes = { (byte) 159, (byte) 160, (byte) 161,
(byte) 162, (byte) 163, (byte) 164, (byte) 165, (byte) 166,
(byte) 167, (byte) 168, (byte) 170, (byte) 171, (byte) 198,
(byte) 199, (byte) 200, (byte) 201, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -469,7 +469,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
// band
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // bc_label
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(36, bcBands.getMethodByteCodePacked()[0][0].length);
assertEquals(20, bcBands.getBcLabel().length);
@@ -483,10 +483,10 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcLocalBand() throws IOException, Pack200Exception {
- byte[] bytes = { 21, 22, 23, 24, 25, 54, 55, 56, 57, 58,
+ final byte[] bytes = { 21, 22, 23, 24, 25, 54, 55, 56, 57, 58,
(byte) 169, (byte) 255, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }; // bc_local
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(11, bcBands.getMethodByteCodePacked()[0][0].length);
assertEquals(11, bcBands.getBcLocal().length);
@@ -500,11 +500,11 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcLongRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { 20, (byte) 255, 8 }; // bc_longref band
- InputStream in = new ByteArrayInputStream(bytes);
+ final byte[] bytes = { 20, (byte) 255, 8 }; // bc_longref band
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(1, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_longref = bcBands.getBcLongRef();
+ final int[] bc_longref = bcBands.getBcLongRef();
assertEquals(1, bc_longref.length);
}
@@ -516,12 +516,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcMethodRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 182, (byte) 183, (byte) 184,
+ final byte[] bytes = { (byte) 182, (byte) 183, (byte) 184,
(byte) 255, 8, 8, 8 }; // bc_methodref band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(3, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_methodref = bcBands.getBcMethodRef();
+ final int[] bc_methodref = bcBands.getBcMethodRef();
assertEquals(3, bc_methodref.length);
}
@@ -534,10 +534,10 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Test
public void testBcShortBand() throws IOException, Pack200Exception {
// TODO: Need to fix this testcase so it has enough data to pass.
- byte[] bytes = { 17, (byte) 196, (byte) 132, (byte) 255, 8,
+ final byte[] bytes = { 17, (byte) 196, (byte) 132, (byte) 255, 8,
8,// bc_short band
8 }; // bc_locals band (required by wide iinc (196, 132))
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(3, bcBands.getMethodByteCodePacked()[0][0].length);
assertEquals(2, bcBands.getBcShort().length);
@@ -552,12 +552,12 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcStringRefBand() throws IOException, Pack200Exception {
- byte[] bytes = { 18, 19, (byte) 255, 8, 8 }; // bc_stringref
+ final byte[] bytes = { 18, 19, (byte) 255, 8, 8 }; // bc_stringref
// band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_stringref = bcBands.getBcStringRef();
+ final int[] bc_stringref = bcBands.getBcStringRef();
assertEquals(2, bc_stringref.length);
}
@@ -569,13 +569,13 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcSuperFieldBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 216, (byte) 217, (byte) 218,
+ final byte[] bytes = { (byte) 216, (byte) 217, (byte) 218,
(byte) 219, (byte) 223, (byte) 224, (byte) 225, (byte) 226,
(byte) 255, 8, 8, 8, 8, 8, 8, 8, 8 }; // bc_superfield band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(8, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_superfield = bcBands.getBcSuperField();
+ final int[] bc_superfield = bcBands.getBcSuperField();
assertEquals(8, bc_superfield.length);
}
@@ -588,13 +588,13 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Test
@Disabled("TODO: Need to fix this testcase so it has enough data to pass.")
public void testBcSuperMethodBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 220, (byte) 221, (byte) 222,
+ final byte[] bytes = { (byte) 220, (byte) 221, (byte) 222,
(byte) 227, (byte) 228, (byte) 229, (byte) 255, 8, 8, 8, 8, 8,
8 }; // bc_supermethod band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(6, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_supermethod = bcBands.getBcSuperMethod();
+ final int[] bc_supermethod = bcBands.getBcSuperMethod();
assertEquals(6, bc_supermethod.length);
}
@@ -606,13 +606,13 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcThisFieldBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 202, (byte) 203, (byte) 204,
+ final byte[] bytes = { (byte) 202, (byte) 203, (byte) 204,
(byte) 205, (byte) 209, (byte) 210, (byte) 211, (byte) 212,
(byte) 255, 8, 8, 8, 8, 8, 8, 8, 8 }; // bc_thisfieldref band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(8, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_thisfield = bcBands.getBcThisField();
+ final int[] bc_thisfield = bcBands.getBcThisField();
assertEquals(8, bc_thisfield.length);
}
@@ -624,13 +624,13 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testBcThisMethodBand() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 206, (byte) 207, (byte) 208,
+ final byte[] bytes = { (byte) 206, (byte) 207, (byte) 208,
(byte) 213, (byte) 214, (byte) 215, (byte) 255, 8, 8, 8, 8, 8,
8 }; // bc_thismethod band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(6, bcBands.getMethodByteCodePacked()[0][0].length);
- int[] bc_thismethod = bcBands.getBcThisMethod();
+ final int[] bc_thismethod = bcBands.getBcThisMethod();
assertEquals(6, bc_thismethod.length);
}
@@ -645,8 +645,8 @@ public class BcBandsTest extends AbstractBandsTestCase {
Pack200Exception {
numClasses = 2;
numMethods = new int[] { 1, 1 };
- byte[] bytes = { 50, 50, (byte) 255, 50, 50, (byte) 255 };
- InputStream in = new ByteArrayInputStream(bytes);
+ final byte[] bytes = { 50, 50, (byte) 255, 50, 50, (byte) 255 };
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
@@ -667,9 +667,9 @@ public class BcBandsTest extends AbstractBandsTestCase {
Pack200Exception {
numClasses = 2;
numMethods = new int[] { 3, 1 };
- byte[] bytes = { 50, 50, (byte) 255, 50, 50, (byte) 255, 50,
+ final byte[] bytes = { 50, 50, (byte) 255, 50, 50, (byte) 255, 50,
50, (byte) 255, 50, 50, (byte) 255 };
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
@@ -687,7 +687,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
*/
@Test
public void testSimple() throws IOException, Pack200Exception {
- byte[] bytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ final byte[] bytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
@@ -702,7 +702,7 @@ public class BcBandsTest extends AbstractBandsTestCase {
(byte) 150, (byte) 151, (byte) 172, (byte) 173, (byte) 174,
(byte) 175, (byte) 176, (byte) 177, (byte) 190, (byte) 191,
(byte) 194, (byte) 195, (byte) 255 };
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(bytes.length - 1,
bcBands.getMethodByteCodePacked()[0][0].length);
@@ -710,11 +710,11 @@ public class BcBandsTest extends AbstractBandsTestCase {
@Test
public void testWideForms() throws IOException, Pack200Exception {
- byte[] bytes = { (byte) 196, (byte) 54, // wide istore
+ final byte[] bytes = { (byte) 196, (byte) 54, // wide istore
(byte) 196, (byte) 132, // wide iinc
(byte) 255, 0, // bc_short band
0, 1 }; // bc_locals band
- InputStream in = new ByteArrayInputStream(bytes);
+ final InputStream in = new ByteArrayInputStream(bytes);
bcBands.unpack(in);
assertEquals(4, bcBands.getMethodByteCodePacked()[0][0].length);
assertEquals(2, bcBands.getBcLocal().length);
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CPUTF8Test.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CPUTF8Test.java
index 41dbc652..228a2c65 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CPUTF8Test.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CPUTF8Test.java
@@ -25,9 +25,9 @@ public class CPUTF8Test {
@Test
public void testEquality() {
- CPUTF8 one = new CPUTF8("(III)V", 1);
- CPUTF8 two = new CPUTF8("((I[II)V", 2);
- CPUTF8 three = new CPUTF8("([III)V", 3);
+ final CPUTF8 one = new CPUTF8("(III)V", 1);
+ final CPUTF8 two = new CPUTF8("((I[II)V", 2);
+ final CPUTF8 three = new CPUTF8("([III)V", 3);
assertNotEquals(one, two);
assertNotEquals(one, three);
assertNotEquals(two, three);
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ClassBandsTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ClassBandsTest.java
index e4203044..a447471f 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ClassBandsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ClassBandsTest.java
@@ -96,7 +96,7 @@ public class ClassBandsTest extends AbstractBandsTestCase {
private byte[] encodeBandInt(final int[] data, final BHSDCodec codec)
throws IOException, Pack200Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int i = 0; i < data.length; i++) {
baos.write(codec.encode(data[i], i == 0 ? 0 : data[i - 1]));
}
@@ -109,30 +109,30 @@ public class ClassBandsTest extends AbstractBandsTestCase {
"Interface2" };
cpDescriptor = new String[0];
cpUTF8 = new String[0];
- byte[] classThis = Codec.DELTA5.encode(1, 0);
- byte[] classSuper = Codec.DELTA5.encode(2, 0);
- byte[] classInterfaceCount = Codec.DELTA5.encode(2, 0);
- byte[] classInterfaceRef1 = encodeBandInt(
+ final byte[] classThis = Codec.DELTA5.encode(1, 0);
+ final byte[] classSuper = Codec.DELTA5.encode(2, 0);
+ final byte[] classInterfaceCount = Codec.DELTA5.encode(2, 0);
+ final byte[] classInterfaceRef1 = encodeBandInt(
new int[] { 3, 4 }, Codec.DELTA5);
- byte[] classFieldCount = Codec.DELTA5.encode(0, 0);
- byte[] classMethodCount = Codec.DELTA5.encode(0, 0);
- byte[] classFlags = Codec.UNSIGNED5.encode(0, 0);
- byte[][] allArrays = { classThis, classSuper,
+ final byte[] classFieldCount = Codec.DELTA5.encode(0, 0);
+ final byte[] classMethodCount = Codec.DELTA5.encode(0, 0);
+ final byte[] classFlags = Codec.UNSIGNED5.encode(0, 0);
+ final byte[][] allArrays = { classThis, classSuper,
classInterfaceCount, classInterfaceRef1, classFieldCount,
classMethodCount, classFlags };
- int total = classThis.length + classSuper.length
+ final int total = classThis.length + classSuper.length
+ classInterfaceCount.length + classInterfaceRef1.length
+ classFieldCount.length + classMethodCount.length
+ classFlags.length;
- byte[] bytes = new byte[total];
+ final byte[] bytes = new byte[total];
int index = 0;
- for (byte[] array : allArrays) {
- for (byte element : array) {
+ for (final byte[] array : allArrays) {
+ for (final byte element : array) {
bytes[index] = element;
index++;
}
}
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+ final ByteArrayInputStream in = new ByteArrayInputStream(bytes);
classBands.unpack(in);
assertEquals(1, classBands.getClassThisInts()[0]);
assertEquals(2, classBands.getClassSuperInts()[0]);
@@ -148,32 +148,32 @@ public class ClassBandsTest extends AbstractBandsTestCase {
cpClasses = new String[] { "Class1", "Class2", "Class3" };
cpDescriptor = new String[] { "method1", "method2", "method3" };
cpUTF8 = new String[0];
- byte[] classThis = Codec.DELTA5.encode(1, 0);
- byte[] classSuper = Codec.DELTA5.encode(2, 0);
- byte[] classInterfaceCount = Codec.DELTA5.encode(0, 0);
- byte[] classFieldCount = Codec.DELTA5.encode(0, 0);
- byte[] classMethodCount = Codec.DELTA5.encode(3, 0);
- byte[] methodDescr = encodeBandInt(new int[] { 0, 1, 2 },
+ final byte[] classThis = Codec.DELTA5.encode(1, 0);
+ final byte[] classSuper = Codec.DELTA5.encode(2, 0);
+ final byte[] classInterfaceCount = Codec.DELTA5.encode(0, 0);
+ final byte[] classFieldCount = Codec.DELTA5.encode(0, 0);
+ final byte[] classMethodCount = Codec.DELTA5.encode(3, 0);
+ final byte[] methodDescr = encodeBandInt(new int[] { 0, 1, 2 },
Codec.MDELTA5);
- byte[] methodFlagsLo = encodeBandInt(
+ final byte[] methodFlagsLo = encodeBandInt(
new int[] { 0, 0, 0 }, Codec.UNSIGNED5);
- byte[] classFlags = Codec.UNSIGNED5.encode(0, 0);
- byte[][] allArrays = { classThis, classSuper,
+ final byte[] classFlags = Codec.UNSIGNED5.encode(0, 0);
+ final byte[][] allArrays = { classThis, classSuper,
classInterfaceCount, classFieldCount, classMethodCount,
methodDescr, methodFlagsLo, classFlags, };
int total = 0;
- for (byte[] array : allArrays) {
+ for (final byte[] array : allArrays) {
total += array.length;
}
- byte[] bytes = new byte[total];
+ final byte[] bytes = new byte[total];
int index = 0;
- for (byte[] array : allArrays) {
- for (byte element : array) {
+ for (final byte[] array : allArrays) {
+ for (final byte element : array) {
bytes[index] = element;
index++;
}
}
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+ final ByteArrayInputStream in = new ByteArrayInputStream(bytes);
classBands.unpack(in);
assertEquals(1, classBands.getClassThisInts()[0]);
assertEquals(2, classBands.getClassSuperInts()[0]);
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CodeAttributeTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CodeAttributeTest.java
index 4140c0bd..5a4cfaf5 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CodeAttributeTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/CodeAttributeTest.java
@@ -143,11 +143,11 @@ public class CodeAttributeTest {
@Test
public void testLength() {
- OperandManager operandManager = new MockOperandManager();
+ final OperandManager operandManager = new MockOperandManager();
operandManager.setSegment(segment);
operandManager.setCurrentClass("java/lang/Foo");
- MockCodeAttribute attribute = new MockCodeAttribute(3, // maxStack
+ final MockCodeAttribute attribute = new MockCodeAttribute(3, // maxStack
2, // maxLocals
mixedByteArray, // codePacked
segment, // segment
@@ -162,11 +162,11 @@ public class CodeAttributeTest {
@Test
public void testMixedByteCodes() {
- OperandManager operandManager = new MockOperandManager();
+ final OperandManager operandManager = new MockOperandManager();
operandManager.setSegment(segment);
operandManager.setCurrentClass("java/lang/Foo");
- CodeAttribute attribute = new CodeAttribute(3, // maxStack
+ final CodeAttribute attribute = new CodeAttribute(3, // maxStack
2, // maxLocals
mixedByteArray, // codePacked
segment, // segment
@@ -177,7 +177,7 @@ public class CodeAttributeTest {
assertEquals("aload_0_putfield_this", attribute.byteCodes
.get(4).toString());
- int expectedLabels[] = { 0, 1, 4, 5, 8, 9, 10, 13, 14 };
+ final int expectedLabels[] = { 0, 1, 4, 5, 8, 9, 10, 13, 14 };
for (int index = 0; index < expectedLabels.length; index++) {
assertEquals(expectedLabels[index],
attribute.byteCodeOffsets.get(index).intValue());
@@ -186,11 +186,11 @@ public class CodeAttributeTest {
@Test
public void testSingleByteCodes() {
- OperandManager operandManager = new MockOperandManager();
+ final OperandManager operandManager = new MockOperandManager();
operandManager.setSegment(segment);
operandManager.setCurrentClass("java/lang/Foo");
- CodeAttribute attribute = new CodeAttribute(4, // maxStack
+ final CodeAttribute attribute = new CodeAttribute(4, // maxStack
3, // maxLocals
singleByteArray, // codePacked
segment, // segment
@@ -201,7 +201,7 @@ public class CodeAttributeTest {
assertEquals("invokespecial_this", attribute.byteCodes
.get(3).toString());
- int expectedLabels[] = { 0, 1, 2, 4 };
+ final int expectedLabels[] = { 0, 1, 2, 4 };
for (int index = 0; index < expectedLabels.length; index++) {
assertEquals(expectedLabels[index],
attribute.byteCodeOffsets.get(index).intValue());
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ICTupleTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ICTupleTest.java
index 54b1c0c6..cd63c2fd 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ICTupleTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/ICTupleTest.java
@@ -39,7 +39,7 @@ public class ICTupleTest {
@ParameterizedTest
@MethodSource("explicit")
public void testExplicitClassTupleParsing(final String c, final String c2, final String n, final String expectedSimpleClassName, final String expectedOuterClass) {
- IcTuple tuple = new IcTuple(c, IcTuple.NESTED_CLASS_FLAG, c2, n, -1, -1, -1, -1);
+ final IcTuple tuple = new IcTuple(c, IcTuple.NESTED_CLASS_FLAG, c2, n, -1, -1, -1, -1);
assertAll(
() -> assertEquals(expectedSimpleClassName, tuple.simpleClassName()),
() -> assertEquals(expectedOuterClass, tuple.outerClassString())
@@ -58,7 +58,7 @@ public class ICTupleTest {
@ParameterizedTest
@MethodSource("predicted")
public void testPredictedClassTupleParsing(final String c, final String expectedSimpleClass, final String expectedOuterClass) {
- IcTuple tuple = new IcTuple(c, 0, null, null, -1, -1, -1, -1);
+ final IcTuple tuple = new IcTuple(c, 0, null, null, -1, -1, -1, -1);
assertAll(
() -> assertEquals(expectedSimpleClass, tuple.simpleClassName()),
() -> assertEquals(expectedOuterClass, tuple.outerClassString())
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/NewAttributeBandsTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/NewAttributeBandsTest.java
index 9cc32e33..8ea3b3bf 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/NewAttributeBandsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/NewAttributeBandsTest.java
@@ -57,10 +57,10 @@ public class NewAttributeBandsTest extends AbstractBandsTestCase {
@Test
public void testEmptyLayout() throws IOException, Pack200Exception {
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CLASS, "", 25));
- List<?> layoutElements = newAttributeBands.getLayoutElements();
+ final List<?> layoutElements = newAttributeBands.getLayoutElements();
assertEquals(0, layoutElements.size());
}
@@ -70,12 +70,12 @@ public class NewAttributeBandsTest extends AbstractBandsTestCase {
"OSB", "POB", "PH", "OH", "OSH", "POH", "PI", "OI", "OSI", "POI"
})
public void testIntegralLayout(final String layoutStr) throws IOException, Pack200Exception {
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CLASS, layoutStr, 25));
- List layoutElements = newAttributeBands.getLayoutElements();
+ final List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Integral element = (Integral) layoutElements.get(0);
+ final Integral element = (Integral) layoutElements.get(0);
assertEquals(layoutStr, element.getTag());
}
@@ -135,24 +135,24 @@ public class NewAttributeBandsTest extends AbstractBandsTestCase {
@Test
public void testLayoutWithCalls() throws IOException, Pack200Exception {
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(),
new AttributeLayout(
"test",
AttributeLayout.CONTEXT_FIELD,
"[NH[(1)]][RSH NH[RUH(1)]][TB(66,67,73,83,90)[KIH](68)[KDH](70)[KFH](74)[KJH](99)[RSH](101)[RSH RUH](115)[RUH](91)[NH[(0)]](64)[RSH[RUH(0)]]()[]]",
26));
- List layoutElements = newAttributeBands.getLayoutElements();
+ final List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(3, layoutElements.size());
- Callable firstCallable = (Callable) layoutElements.get(0);
- Callable secondCallable = (Callable) layoutElements.get(1);
- Callable thirdCallable = (Callable) layoutElements.get(2);
- List firstBody = firstCallable.getBody();
+ final Callable firstCallable = (Callable) layoutElements.get(0);
+ final Callable secondCallable = (Callable) layoutElements.get(1);
+ final Callable thirdCallable = (Callable) layoutElements.get(2);
+ final List firstBody = firstCallable.getBody();
assertEquals(1, firstBody.size());
- Replication rep = (Replication) firstBody.get(0);
- List repBody = rep.getLayoutElements();
+ final Replication rep = (Replication) firstBody.get(0);
+ final List repBody = rep.getLayoutElements();
assertEquals(1, repBody.size());
- Call call = (Call) repBody.get(0);
+ final Call call = (Call) repBody.get(0);
assertEquals(1, call.getCallableIndex());
assertEquals(secondCallable, call.getCallable());
assertFalse(firstCallable.isBackwardsCallable());
@@ -166,67 +166,67 @@ public class NewAttributeBandsTest extends AbstractBandsTestCase {
"RSH", "RDH", "RFH", "RMH", "RIH", "RUH", "RQH", "RQNH", "RQNI"
})
public void testReferenceLayouts(final String layout) throws IOException, Pack200Exception {
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CODE, layout, 26));
- List layoutElements = newAttributeBands.getLayoutElements();
+ final List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Reference element = (Reference) layoutElements.get(0);
+ final Reference element = (Reference) layoutElements.get(0);
assertEquals(layout, element.getTag());
}
@Test
public void testReplicationLayout() throws IOException, Pack200Exception {
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CLASS, "NH[PHOHRUHRSHH]", 25));
- List layoutElements = newAttributeBands.getLayoutElements();
+ final List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Replication element = (Replication) layoutElements.get(0);
- Integral countElement = element.getCountElement();
+ final Replication element = (Replication) layoutElements.get(0);
+ final Integral countElement = element.getCountElement();
assertEquals("H", countElement.getTag());
- List replicatedElements = element.getLayoutElements();
+ final List replicatedElements = element.getLayoutElements();
assertEquals(5, replicatedElements.size());
- Integral firstElement = (Integral) replicatedElements.get(0);
+ final Integral firstElement = (Integral) replicatedElements.get(0);
assertEquals("PH", firstElement.getTag());
- Integral secondElement = (Integral) replicatedElements.get(1);
+ final Integral secondElement = (Integral) replicatedElements.get(1);
assertEquals("OH", secondElement.getTag());
- Reference thirdElement = (Reference) replicatedElements.get(2);
+ final Reference thirdElement = (Reference) replicatedElements.get(2);
assertEquals("RUH", thirdElement.getTag());
- Reference fourthElement = (Reference) replicatedElements.get(3);
+ final Reference fourthElement = (Reference) replicatedElements.get(3);
assertEquals("RSH", fourthElement.getTag());
- Integral fifthElement = (Integral) replicatedElements.get(4);
+ final Integral fifthElement = (Integral) replicatedElements.get(4);
assertEquals("H", fifthElement.getTag());
}
@Test
public void testUnionLayout() throws IOException, Pack200Exception {
- MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
+ final MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CODE,
"TB(55)[FH](23)[]()[RSH]", 26));
- List layoutElements = newAttributeBands.getLayoutElements();
+ final List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size());
- Union element = (Union) layoutElements.get(0);
- Integral tag = element.getUnionTag();
+ final Union element = (Union) layoutElements.get(0);
+ final Integral tag = element.getUnionTag();
assertEquals("B", tag.getTag());
- List unionCases = element.getUnionCases();
+ final List unionCases = element.getUnionCases();
assertEquals(2, unionCases.size());
- UnionCase firstCase = (UnionCase) unionCases.get(0);
+ final UnionCase firstCase = (UnionCase) unionCases.get(0);
assertTrue(firstCase.hasTag(55));
assertFalse(firstCase.hasTag(23));
List body = firstCase.getBody();
assertEquals(1, body.size());
- Integral bodyElement = (Integral) body.get(0);
+ final Integral bodyElement = (Integral) body.get(0);
assertEquals("FH", bodyElement.getTag());
- UnionCase secondCase = (UnionCase) unionCases.get(1);
+ final UnionCase secondCase = (UnionCase) unionCases.get(1);
assertTrue(secondCase.hasTag(23));
assertFalse(secondCase.hasTag(55));
body = secondCase.getBody();
assertEquals(0, body.size());
- List defaultBody = element.getDefaultCaseBody();
+ final List defaultBody = element.getDefaultCaseBody();
assertEquals(1, defaultBody.size());
- Reference ref = (Reference) defaultBody.get(0);
+ final Reference ref = (Reference) defaultBody.get(0);
assertEquals("RSH", ref.getTag());
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolArrayCacheTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolArrayCacheTest.java
index c4cc687b..00f9aca2 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolArrayCacheTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolArrayCacheTest.java
@@ -28,9 +28,9 @@ public class SegmentConstantPoolArrayCacheTest {
@Test
public void testMultipleArrayMultipleHit() {
- SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
- String arrayOne[] = {"Zero", "Shared", "Two", "Shared", "Shared"};
- String arrayTwo[] = {"Shared", "One", "Shared", "Shared", "Shared"};
+ final SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
+ final String arrayOne[] = {"Zero", "Shared", "Two", "Shared", "Shared"};
+ final String arrayTwo[] = {"Shared", "One", "Shared", "Shared", "Shared"};
List listOne = arrayCache.indexesForArrayKey(arrayOne, "Shared");
List listTwo = arrayCache.indexesForArrayKey(arrayTwo, "Shared");
@@ -55,15 +55,15 @@ public class SegmentConstantPoolArrayCacheTest {
assertEquals(3, ((Integer)listTwo.get(2)).intValue());
assertEquals(4, ((Integer)listTwo.get(3)).intValue());
- List listThree = arrayCache.indexesForArrayKey(arrayOne, "Not found");
+ final List listThree = arrayCache.indexesForArrayKey(arrayOne, "Not found");
assertEquals(0, listThree.size());
}
@Test
public void testSingleMultipleHitArray() {
- SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
- String array[] = {"Zero", "OneThreeFour", "Two", "OneThreeFour", "OneThreeFour"};
- List list = arrayCache.indexesForArrayKey(array, "OneThreeFour");
+ final SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
+ final String array[] = {"Zero", "OneThreeFour", "Two", "OneThreeFour", "OneThreeFour"};
+ final List list = arrayCache.indexesForArrayKey(array, "OneThreeFour");
assertEquals(3, list.size());
assertEquals(1, ((Integer)list.get(0)).intValue());
assertEquals(3, ((Integer)list.get(1)).intValue());
@@ -72,9 +72,9 @@ public class SegmentConstantPoolArrayCacheTest {
@Test
public void testSingleSimpleArray() {
- SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
- String array[] = {"Zero", "One", "Two", "Three", "Four"};
- List list = arrayCache.indexesForArrayKey(array, "Three");
+ final SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
+ final String array[] = {"Zero", "One", "Two", "Three", "Four"};
+ final List list = arrayCache.indexesForArrayKey(array, "Three");
assertEquals(1, list.size());
assertEquals(3, ((Integer)list.get(0)).intValue());
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java
index cde74cb4..9ace1c9f 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java
@@ -65,7 +65,7 @@ public class SegmentConstantPoolTest {
@Test
public void testMatchSpecificPoolEntryIndex_DoubleArray() {
- MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
+ final MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
// Elements should be found at the proper position.
assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(
testClassArray, testMethodArray, "Object", "^<init>.*", 0));
@@ -90,7 +90,7 @@ public class SegmentConstantPoolTest {
@Test
public void testMatchSpecificPoolEntryIndex_SingleArray() {
- MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
+ final MockSegmentConstantPool mockInstance = new MockSegmentConstantPool();
// Elements should be found at the proper position.
assertEquals(0, mockInstance.matchSpecificPoolEntryIndex(
testClassArray, "Object", 0));
@@ -117,7 +117,7 @@ public class SegmentConstantPoolTest {
@Test
public void testRegexReplacement() {
- MockSegmentConstantPool mockPool = new MockSegmentConstantPool();
+ final MockSegmentConstantPool mockPool = new MockSegmentConstantPool();
assertTrue(mockPool.regexMatchesVisible(".*", "anything"));
assertTrue(mockPool.regexMatchesVisible(".*", ""));
assertTrue(mockPool.regexMatchesVisible("^<init>.*", "<init>"));
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentTest.java
index 5f2d22c5..3ffff9cd 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentTest.java
@@ -47,7 +47,7 @@ public class SegmentTest {
if (in != null) {
try {
in.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@@ -55,7 +55,7 @@ public class SegmentTest {
if (out != null) {
out.close();
}
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
file.delete();
@@ -68,27 +68,27 @@ public class SegmentTest {
file = File.createTempFile("hello", "world.jar");
file.deleteOnExit();
out = new JarOutputStream(new FileOutputStream(file));
- Segment segment = new Segment();
+ final Segment segment = new Segment();
segment.unpack(in, out);
out.close();
out = null;
- JarFile jarFile = new JarFile(file);
+ final JarFile jarFile = new JarFile(file);
- JarEntry entry = jarFile
+ final JarEntry entry = jarFile
.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
assertNotNull(entry);
- InputStream ours = jarFile.getInputStream(entry);
+ final InputStream ours = jarFile.getInputStream(entry);
- JarFile jarFile2 = new JarFile(new File(Segment.class.getResource(
+ final JarFile jarFile2 = new JarFile(new File(Segment.class.getResource(
"/pack200/hw.jar").toURI()));
- JarEntry entry2 = jarFile2
+ final JarEntry entry2 = jarFile2
.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
assertNotNull(entry2);
- InputStream expected = jarFile2.getInputStream(entry2);
+ final InputStream expected = jarFile2.getInputStream(entry2);
- BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
- BufferedReader reader2 = new BufferedReader(new InputStreamReader(expected));
+ final BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
+ final BufferedReader reader2 = new BufferedReader(new InputStreamReader(expected));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
int i = 1;
@@ -108,7 +108,7 @@ public class SegmentTest {
.getResourceAsStream("/pack200/InterfaceOnly.pack");
file = File.createTempFile("Interface", "Only.jar");
out = new JarOutputStream(new FileOutputStream(file));
- Segment segment = new Segment();
+ final Segment segment = new Segment();
segment.unpack(in, out);
}
@@ -118,7 +118,7 @@ public class SegmentTest {
.getResourceAsStream("/pack200/JustResources.pack");
file = File.createTempFile("just", "resources.jar");
out = new JarOutputStream(new FileOutputStream(file));
- Segment segment = new Segment();
+ final Segment segment = new Segment();
segment.unpack(in, out);
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentUtilsTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentUtilsTest.java
index fcc2af92..1eeca2ab 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentUtilsTest.java
@@ -88,7 +88,7 @@ public class SegmentUtilsTest {
@Test
public void testMatches() {
- long[] oneToTen = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ final long[] oneToTen = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
assertEquals(6, SegmentUtils.countMatches(new long[][] { oneToTen,
new long[] { 5, 6, 7 } }, even));
assertEquals(5, SegmentUtils.countMatches(new long[][] { oneToTen },
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ClassFileEntryTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ClassFileEntryTest.java
index d5436e7f..c8934c0e 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ClassFileEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ClassFileEntryTest.java
@@ -32,8 +32,8 @@ import org.junit.jupiter.api.Test;
public class ClassFileEntryTest {
- private void checkEquality(Object equal1, Object equal2, String toString,
- Object unequal) {
+ private void checkEquality(final Object equal1, final Object equal2, final String toString,
+ final Object unequal) {
assertEquals(equal1, equal2);
assertEquals(equal1.hashCode(), equal2.hashCode());
assertTrue(equal1.toString().indexOf(toString) >= 0);
@@ -45,21 +45,21 @@ public class ClassFileEntryTest {
@Test
public void testCPDouble() {
- CPDouble cp1 = new CPDouble(new Double(3), 3);
- CPDouble cp2 = new CPDouble(new Double(3), 3);
- CPDouble cp3 = new CPDouble(new Double(5), 5);
+ final CPDouble cp1 = new CPDouble(Double.valueOf(3), 3);
+ final CPDouble cp2 = new CPDouble(Double.valueOf(3), 3);
+ final CPDouble cp3 = new CPDouble(Double.valueOf(5), 5);
checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
}
@Test
public void testCPField() {
- CPMember cp1 = new CPMember(new CPUTF8("Name", 3), new CPUTF8("I", 4),
+ final CPMember cp1 = new CPMember(new CPUTF8("Name", 3), new CPUTF8("I", 4),
0, null);
- CPMember cp2 = new CPMember(new CPUTF8("Name", 3), new CPUTF8("I", 4),
+ final CPMember cp2 = new CPMember(new CPUTF8("Name", 3), new CPUTF8("I", 4),
0, null);
- CPMember cp3 = new CPMember(new CPUTF8("Name", 3), new CPUTF8("Z", 5),
+ final CPMember cp3 = new CPMember(new CPUTF8("Name", 3), new CPUTF8("Z", 5),
0, null);
- CPMember cp4 = new CPMember(new CPUTF8("GName", 6), new CPUTF8("I", 4),
+ final CPMember cp4 = new CPMember(new CPUTF8("GName", 6), new CPUTF8("I", 4),
0, null);
checkEquality(cp1, cp2, "Name", cp3); //$NON-NLS-1$
checkEquality(cp1, cp2, "I", cp4); //$NON-NLS-1$
@@ -67,52 +67,52 @@ public class ClassFileEntryTest {
@Test
public void testCPFloat() {
- CPFloat cp1 = new CPFloat(new Float(3), 3);
- CPFloat cp2 = new CPFloat(new Float(3), 3);
- CPFloat cp3 = new CPFloat(new Float(5), 5);
+ final CPFloat cp1 = new CPFloat(Float.valueOf(3), 3);
+ final CPFloat cp2 = new CPFloat(Float.valueOf(3), 3);
+ final CPFloat cp3 = new CPFloat(Float.valueOf(5), 5);
checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
}
@Test
public void testCPInteger() {
- CPInteger cp1 = new CPInteger(new Integer(3), 3);
- CPInteger cp2 = new CPInteger(new Integer(3), 3);
- CPInteger cp3 = new CPInteger(new Integer(5), 5);
+ final CPInteger cp1 = new CPInteger(Integer.valueOf(3), 3);
+ final CPInteger cp2 = new CPInteger(Integer.valueOf(3), 3);
+ final CPInteger cp3 = new CPInteger(Integer.valueOf(5), 5);
checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
}
@Test
public void testCPLong() {
- CPLong cp1 = new CPLong(new Long(3), 3);
- CPLong cp2 = new CPLong(new Long(3), 3);
- CPLong cp3 = new CPLong(new Long(5), 5);
+ final CPLong cp1 = new CPLong(Long.valueOf(3), 3);
+ final CPLong cp2 = new CPLong(Long.valueOf(3), 3);
+ final CPLong cp3 = new CPLong(Long.valueOf(5), 5);
checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
}
@Test
public void testCPString() {
- CPString cp1 = new CPString(new CPUTF8(new String("3"), 3), 3);
- CPString cp2 = new CPString(new CPUTF8(new String("3"), 3), 3);
- CPString cp3 = new CPString(new CPUTF8(new String("5"), 5), 5);
+ final CPString cp1 = new CPString(new CPUTF8("3", 3), 3);
+ final CPString cp2 = new CPString(new CPUTF8("3", 3), 3);
+ final CPString cp3 = new CPString(new CPUTF8("5", 5), 5);
checkEquality(cp1, cp2, "3", cp3); //$NON-NLS-1$
}
@Test
public void testSourceAttribute() {
- SourceFileAttribute sfa1 = new SourceFileAttribute(new CPUTF8(
- new String("Thing.java"), 1)); //$NON-NLS-1$
- SourceFileAttribute sfa2 = new SourceFileAttribute(new CPUTF8(
- new String("Thing.java"), 1)); //$NON-NLS-1$
- SourceFileAttribute sfa3 = new SourceFileAttribute(new CPUTF8(
- new String("OtherThing.java"), 2)); //$NON-NLS-1$
+ final SourceFileAttribute sfa1 = new SourceFileAttribute(new CPUTF8(
+ "Thing.java", 1)); //$NON-NLS-1$
+ final SourceFileAttribute sfa2 = new SourceFileAttribute(new CPUTF8(
+ "Thing.java", 1)); //$NON-NLS-1$
+ final SourceFileAttribute sfa3 = new SourceFileAttribute(new CPUTF8(
+ "OtherThing.java", 2)); //$NON-NLS-1$
checkEquality(sfa1, sfa2, "Thing.java", sfa3); //$NON-NLS-1$
}
@Test
public void testUTF8() {
- CPUTF8 u1 = new CPUTF8(new String("thing"), 1); //$NON-NLS-1$
- CPUTF8 u2 = new CPUTF8(new String("thing"), 1); //$NON-NLS-1$
- CPUTF8 u3 = new CPUTF8(new String("otherthing"), 2); //$NON-NLS-1$
+ final CPUTF8 u1 = new CPUTF8("thing", 1); //$NON-NLS-1$
+ final CPUTF8 u2 = new CPUTF8("thing", 1); //$NON-NLS-1$
+ final CPUTF8 u3 = new CPUTF8("otherthing", 2); //$NON-NLS-1$
checkEquality(u1, u2, "thing", u3);
}
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ConstantPoolTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ConstantPoolTest.java
index 8801e06b..9428fd9a 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ConstantPoolTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/bytecode/ConstantPoolTest.java
@@ -38,12 +38,12 @@ public class ConstantPoolTest {
@Test
public void testDuplicateField() {
- CPMember cp1 = new CPMember(new CPUTF8("name", 1), new CPUTF8("I", 2),
+ final CPMember cp1 = new CPMember(new CPUTF8("name", 1), new CPUTF8("I", 2),
0, null);
pool.add(cp1);
pool.addNestedEntries();
assertEquals(2, pool.size());
- CPMember cp2 = new CPMember(new CPUTF8("name", 1), new CPUTF8("I", 2),
+ final CPMember cp2 = new CPMember(new CPUTF8("name", 1), new CPUTF8("I", 2),
0, null);
pool.add(cp2);
pool.addNestedEntries();
@@ -52,8 +52,8 @@ public class ConstantPoolTest {
@Test
public void testDuplicateUTF8() {
- CPUTF8 u1 = new CPUTF8("thing", 1);
- CPUTF8 u2 = new CPUTF8("thing", 1);
+ final CPUTF8 u1 = new CPUTF8("thing", 1);
+ final CPUTF8 u2 = new CPUTF8("thing", 1);
pool.add(u1);
pool.add(u2);
assertEquals(1, pool.size());
@@ -69,7 +69,7 @@ public class ConstantPoolTest {
@Test
public void testIndex() {
pool.add(new CPUTF8("OtherThing", 1));
- CPUTF8 u1 = new CPUTF8("thing", 2);
+ final CPUTF8 u1 = new CPUTF8("thing", 2);
pool.add(u1);
pool.resolve(new Segment());
assertTrue(pool.indexOf(u1) > 0);
diff --git a/src/test/java/org/apache/commons/compress/java/util/jar/Pack200Test.java b/src/test/java/org/apache/commons/compress/java/util/jar/Pack200Test.java
index 321ab72b..abb2ebc7 100644
--- a/src/test/java/org/apache/commons/compress/java/util/jar/Pack200Test.java
+++ b/src/test/java/org/apache/commons/compress/java/util/jar/Pack200Test.java
@@ -24,13 +24,13 @@ public class Pack200Test {
@Test
public void testPacker() {
- Pack200.Packer packer = Pack200.newPacker();
+ final Pack200.Packer packer = Pack200.newPacker();
assertEquals("org.apache.commons.compress.harmony.pack200.Pack200PackerAdapter", packer.getClass().getName());
}
@Test
public void testUnpacker() {
- Pack200.Unpacker unpacker = Pack200.newUnpacker();
+ final Pack200.Unpacker unpacker = Pack200.newUnpacker();
assertEquals("org.apache.commons.compress.harmony.unpack200.Pack200UnpackerAdapter", unpacker.getClass().getName());
}
diff --git a/src/test/java/org/apache/commons/compress/utils/FileNameUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/FileNameUtilsTest.java
index d7ddd53b..115c5c3c 100644
--- a/src/test/java/org/apache/commons/compress/utils/FileNameUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/FileNameUtilsTest.java
@@ -36,7 +36,7 @@ public class FileNameUtilsTest {
assertEquals("foo", FileNameUtils.getBaseName(Paths.get("foo")));
assertEquals("", FileNameUtils.getBaseName(Paths.get("")));
assertEquals("", FileNameUtils.getBaseName(Paths.get(".")));
- for (File f : File.listRoots()) {
+ for (final File f : File.listRoots()) {
assertEquals(null, FileNameUtils.getBaseName(f.toPath()));
}
if (SystemUtils.IS_OS_WINDOWS) {
@@ -70,7 +70,7 @@ public class FileNameUtilsTest {
assertEquals("", FileNameUtils.getExtension(Paths.get("foo")));
assertEquals("", FileNameUtils.getExtension(Paths.get("")));
assertEquals("", FileNameUtils.getExtension(Paths.get(".")));
- for (File f : File.listRoots()) {
+ for (final File f : File.listRoots()) {
assertEquals(null, FileNameUtils.getExtension(f.toPath()));
}
if (SystemUtils.IS_OS_WINDOWS) {
diff --git a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
index 94e5245d..59c13d9b 100644
--- a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
@@ -97,7 +97,7 @@ public class IOUtilsTest {
@Test
public void readRangeFromChannelDoesntReadMoreThanAskedFor() throws IOException {
try (ReadableByteChannel in = new SeekableInMemoryByteChannel(new byte[] { 1, 2, 3, 4, 5 })) {
- byte[] read = IOUtils.readRange(in, 3);
+ final byte[] read = IOUtils.readRange(in, 3);
Assert.assertArrayEquals(new byte[] { 1, 2, 3 }, read);
final ByteBuffer b = ByteBuffer.allocate(1);
Assert.assertEquals(1, in.read(b));
@@ -127,7 +127,7 @@ public class IOUtilsTest {
@Test
public void readRangeFromChannelStopsIfThereIsNothingToReadAnymore() throws IOException {
try (ReadableByteChannel in = new SeekableInMemoryByteChannel(new byte[] { 1, 2, 3, 4, 5 })) {
- byte[] read = IOUtils.readRange(in, 10);
+ final byte[] read = IOUtils.readRange(in, 10);
Assert.assertArrayEquals(new byte[] { 1, 2, 3, 4, 5 }, read);
final ByteBuffer b = ByteBuffer.allocate(1);
Assert.assertEquals(-1, in.read(b));
@@ -137,7 +137,7 @@ public class IOUtilsTest {
@Test
public void readRangeFromStreamDoesntReadMoreThanAskedFor() throws IOException {
try (ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 })) {
- byte[] read = IOUtils.readRange(in, 3);
+ final byte[] read = IOUtils.readRange(in, 3);
Assert.assertArrayEquals(new byte[] { 1, 2, 3 }, read);
Assert.assertEquals(4, in.read());
}
@@ -146,7 +146,7 @@ public class IOUtilsTest {
@Test
public void readRangeFromStreamStopsIfThereIsNothingToReadAnymore() throws IOException {
try (ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 })) {
- byte[] read = IOUtils.readRange(in, 10);
+ final byte[] read = IOUtils.readRange(in, 10);
Assert.assertArrayEquals(new byte[] { 1, 2, 3, 4, 5 }, read);
Assert.assertEquals(-1, in.read());
}