You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2021/07/03 06:42:50 UTC
[commons-compress] branch pack200-harmony-as-fallback updated
(fd3f09c -> d358036)
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a change to branch pack200-harmony-as-fallback
in repository https://gitbox.apache.org/repos/asf/commons-compress.git.
omit fd3f09c adapt to changed test dependencies in master
omit 3b2227a sync pom with parent, hoping to get github actions build to pass
omit 18cb531 sync github actions config with master
omit 58c250c run tests on Java 14+ in CI
omit d3ef88f try to use java.util.jar.Packe200, only fall back to Harmony
add 92d9df3 ignore Pack200 tests for jdk14+ (#129)
add 4ede294 Trigger GitHub builds for PRs.
add 08d754c COMPRESS-548 : throw exception if length of zip extra field is too short
add a0ec219 Use US English spelling.
add 319a848 COMPRESS-554 : throw IOExcepiton if error is met
add 3b28227 COMPRESS-554 : update name of testcase
add 4eb3bbe COMPRESS-547 : add asserts for Arrays.copyOf
add a40c53d COMPRESS-550 : add writePreamble to ZipArchiveInputStream
add b0d590d COMPRESS-550 : document in changes
add db932dd Bump actions/setup-java from v1.4.1 to v1.4.2 (#133)
add 876ee87 Update actions/setup-java from v1.4.1 to v1.4.2 #133.
add 550e525 Update actions/setup-java from v1.4.1 to v1.4.2 #133.
add cf2f6c6 Replace Java 14 with Java 15 as the latest Java version to test. Use Jaav 16 EA as the EA version to test.
add 0628668 Use uppercase for long literal suffix.
add 8a65cc9 Fix for CFH detect in ZipArchiveInputStream
add 555daa4 COMPRESS-553 : fix for pax header of tar
add 5c6f14c update CRLF to LF
add 294f555 Add SECURITY.MD.
add f56300c Use lambdas.
add ef3cad0 Modify some calls of method Collection.toArray
add 80057c3 Typo.
add ea1cba2 Access static methods directly.
add 82f7401 Use final.
add 3c05472 Remove unused import.
add cbdb1e2 No need to nest else clause.
add d68da9b No need to throw UnsupportedEncodingException from this private method.
add e61abc3 No need to throw IOException from this private method.
add e0b11ec Use try-with-resources.
add e21f1ac Fix Javadoc link.
add 99cc3fb Use Objects.equals().
add 3a69e1c Bump junit from 4.13 to 4.13.1 (#143)
add d8a0142 Bump actions/checkout from v2.3.2 to v2.3.3 (#139)
add 7ceae5d Bump actions/setup-java from v1.4.2 to v1.4.3 (#141)
add 16a7fbb Bump junit from 4.13 to 4.13.1 #143. Bump actions/checkout from v2.3.2 to v2.3.3 #139. Bump actions/setup-java from v1.4.2 to v1.4.3 #141.
add b08186b Update com.github.luben:zstd-jni from 1.4.5-6 -> 1.4.5-12.
add 176abe1 Replace Java 14 with 15 (latest) on Travis.
add 9e3c2ae Bump memoryfilesystem from 1.3.0 to 2.1.0 #131.
add 16391f3 Bump memoryfilesystem from 1.3.0 to 2.1.0 (#131)
add 648602a Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-compress.git
add bf2fbb6 Update Mockito 1.10.19 -> 3.6.0.
add 498db43 Remove dead comments.
add bc754a3 Bump actions/checkout from v2.3.3 to v2.3.4 (#150)
add 4ded585 Bump actions/checkout from v2.3.3 to v2.3.4 #150.
add 6c53849 COMPRESS-509 : document this change in changes.xml
add 4f52e4a COMPRESS-558: Fix accidentally added / to file names
add de1f857 document COMPRESS-558 in changes.xml
add 64f01c6 Use a switch instead of a cascading if-else.
add 4c73313 Use Objects.hash().
add 32012f9 Remove redundant calls to super().
add 5cacb5d No need to initialize to default.
add 993d587 Use final.
add d959766 Use try-with-resource.
add ae5baa9 Remove redundant modifiers like private on enum constructors.
add ef28595 Use blocks.
add 37f193f Use final.
add 50174a9 Use upper-case 'L' instead of 'l' for long literal suffix.
add 0bff34c Redundant return.
add b86feb6 COMPRESS-560: Do not return false if the entry is a tar sparse entry
add 7d00426 COMPRESS-560: Use assumeTrue/assumeFalse to check if the test should be run on the current OS
add 291b49d COMPRESS-560: Add message to assume check
add 1258341 document pull request #153
add 05a995e do not use wildcard imports
add 75a16c2 COMPRESS-559: Extract sparsefile-0.1 also on Linux
add d98e849 COMPRESS-559: Skip extracting with GNU tar 1.28
add 4cf5b34 document COMPRESS-559 and make some comments
add 1470c26 Fix spelling.
add d462ac4 COMPRESS-561 - Minor improvement
add ffc5c18 Add final
add 57bcd9b document COMPRESS-561
add 81299d2 add more information about allowStoredEntriesWithDataDescriptor
add ced31bd Add Java 17-EA to the GitHub build.
add 505feaf Use String#isEmpty().
add b0df98a Breaking binary compatibility should break the build instead of generating a report one might skip reading, especially for PRs.
add 4944b13 mockito.version 3.6.0 -> 3.6.28 to try to get the build to pass on Java 16 and 17.
add bec6bd4 Migrate to non-deprecated Mockito class.
add 7fdf1ed Fix compiler warnings.
add d065cff Bump maven-pmd-plugin from 3.13.0 to 3.14.0 (#154)
add 648b6fc Bump maven-pmd-plugin from 3.13.0 to 3.14.0 #154.
add 34ec017 Bump zstd-jni from 1.4.5-12 to 1.4.8-1 #159.
add 770f2c1 Bump zstd-jni from 1.4.5-12 to 1.4.8-1 (#159)
add 8f46229 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-compress.git
add 145a640 No need to initialize instance variable to its default value.
add e723fb3 Bump mockito-core from 3.6.28 to 3.7.0 (#161)
add f405abe Bump mockito-core from 3.6.28 to 3.7.0 #161.
add a9eabd5 Remove unused import.
add 81f2084 COMPRESS-540: Implement TarFile to allow random access to tar files
add f11c897 COMPRESS-540: Change visibility of methods moved to TarUtils to protected
add 9f7c5aa COMPRESS-540: Implement storage of data offset in tar entries via EntryStreamOffsets instead of reinventing it
add 57e2b28 COMPRESS-540: Include fix for COMPRESS-544
add 3b7f0ae COMPRESS-540: Include fix for COMPRESS-554
add 6270ff5 COMPRESS-540: Include fix for COMPRESS-553
add f0aaab6 COMPRESS-540: Fix problems with long filenames
add 543ac95 COMPRESS-540: Javadoc enhancement
add a9a03f6 COMPRESS-540: Implement reading of padded last record
add 53bc2f7 COMPRESS-540: Rename BoundedNIOInputStream -> BoundedArchiveInputStream
add 20f8b3e COMPRESS-540: Include changes from COMPRESS-559
add 34759ba COMPRESS-540: Remove commented out code in test
add f36fe7e COMPRESS-540: Tar entry offset should not be smaller than 0
add 46b652c document COMPRESS-540
add 0bdc408 Define and reuse constants.
add adab245 Use isEmpty().
add 34bcf90 Use isEmpty().
add 1e6d998 Use isEmpty().
add 67da739 Use isEmpty().
add 6fed9fb Update Mockito 3.7.0 -> 3.7.7.
add 221b2ba use final
add 36a33fe Normalize to US English spelling.
add fdeacdb Normalize to US English spelling.
add 04ed3f1 OMPRESS-565 : add BufferPool support in zstd
add 77db855 document COMPRESS-565 with PR#165
add 1b7528f Remove trailing whitepsace.
add fda4e34 Remove empty loop in X0017_StrongEncryptionHeader
add 627045d Merge pull request #172 from fmeum/patch-1
add bcc009c record #172
add 32509ee COMPRESS-567 use IOException rather than RuntimeExceptions
add 7e5c489 Remove use of redundant String.substring() parameter.
add 65cbce6 Use String.replace() instead of replaceAll() when we don't need a Regex.
add 06ab954 Bump actions/cache from v2 to v2.1.4 (#164)
add f999414 Bump junit from 4.13.1 to 4.13.2 (#167)
add aef3e6d Bump mockito-core from 3.7.7 to 3.8.0 (#170)
add d8aece0 Bump actions/cache from v2 to v2.1.4 #164 Bump junit from 4.13.1 to 4.13.2 #167 Bump mockito-core from 3.7.7 to 3.8.0 #170
add 80b0628 Bump zstd-jni from 1.4.8-1 to 1.4.8-6 (#173)
add ac2b6e4 Bump zstd-jni from 1.4.8-1 to 1.4.8-6 #173.
add 5feac5f Consolidate updates.
add eb0b2c1 Bump zstd-jni from 1.4.8-6 to 1.4.8-7 (#174)
add 2ff3889 Bump zstd-jni from 1.4.8-6 to 1.4.8-7 #174.
add 768722d No need to nest in else.
add 703d411 Fix Javadoc warnings in builds.
add 6082d64 Fix test leaking file handles.
add 1a52e2f Fix test leaking file handles.
add 46eab6b Use try-with-resources.
add 8543b03 COMPRESS-569 don't move backwards while scanning the archive
add 5c5f8a8 COMPRESS-569 ensure sizes read for archive entries are non-negative
add 851dbed COMPRESS-569 also check sizes in ZipArchiveInputStream
add 5aa752a COMPRESS-569 add testcase for the specific error in TarFile
add 30a7750 COMPRESS-552 use a more complex and more reliable way to detect OSGi
add 2841f2d try dealing with Jacoco not working for Java 16+ right now
add e1c1fe9 Revert "try dealing with Jacoco not working for Java 16+ right now"
add d2d1834 actually this looks like a Maven problem with Java 17-ea, not Jacoco
add 65a5c75 COMPRESS-571 : SevenZFile.getEntries now return a copy of entries
add f387340 Replace GitHub build for Java 15 with Java 16 and drop Java 16-ea.
add e03b8d4 Bump zstd-jni from 1.4.8-7 to 1.4.9-1
add a669dfb record #176
add af92156 * Use lambda and method reference * Simplify conditions
add 2ea18b8 Merge pull request #178 from arturobernalg/feature/lambda
add 33789f6 * Remove redundant initializer * Remove not use return value
add 40fcdf6 Replace construction of FileInputStream and FileOutputStream objects with Files NIO APIs.
add 735e99a Change test to use NIO Api's
add 84b8b7a Merge pull request #186 from arturobernalg/feature/filesNioApi
add 63c4e15 Update `actions/setup-java` to v2.
add d4db6e5 Add oss-fuzz to README.md
add 61615b3 COMPRESS-575 harden parser for PAX 0.0 sparse headers
add ef765af COMPRESS-575 extract and harden parsing of GNU stuct_sparse entries
add ecf514b COMPRESS-575 harden parser of PAX 0.1 GNU sparse map
add c7c1a8b COMPRESS-575 forgot tests for parseSparseStructs
add 2887391 COMPRESS-575 harden parser for PAX 1.0 sparse struct blocks
add f196253 COMPRESS-575 extract and harden sorting of sparse structs
add ad40318 whitespace changes only
add 8645883 COMPRESS-575 confine sparse entry to its claimed realSize
add 30ff58d COMPRESS-567 overlooked a RuntimeException in BoundedArchiveInputStream
add deabd92 COMPRESS-575 document changes
add 9631715 AsiExtraField actually expects quite a few more bytes than it claims
add 51265b2 JDK's ZipEntry#setExtra parses a few extra fields itself ...
add cf4608b more stongly guard what is supposed to become an array size
add 004e873 COMPRESS-567 parsing tar headers actually throws IllegalArgumentException
add 02dbe7b only update name, wnen present in PAX header, deal with non-numbers in header
add 5672064 update XZ for Java to get access to improved performance
add 26924e9 COMPRESS-542 sanity check 7z metadata with minimizing allocations
add 882c6dd one more case where the JDK throwing RuntimeEx may hurt us
add 190939b handle integer overflow
add 8046bd2 properly fulfill InputStream's contract
add de39b85 COMPRESS-567 turn possible RuntimeExceptions into IOExceptions
add ed32eb9 actually, InputStream wants an IIOBE here
add 2d1392d fix single-byte read when nothing has been read
add 8a825f0 really fix single-byte read when nothing has been read
add 8bae05c COMPRESS-542 clear temporary storage after it is no longer needed
add c51de6c COMPRESS-542 add some extra sanity checks
add 0aba8b8 COMPRESS-542 and some final sanity checks
add 23b758f COMPRESS-552 check interfaces of superclasses as well
add 60d551a COMPRESS-542 guard against integer overflow
add bf5a534 COMPRESS-542 hit commit to quickly
add 5761493 COMPRESS-542 each folder requires at least one coder
add 8542c81 Add GitHub code of conduct page that points to the Apache page.
add d15c285 COMPRESS-567 more uncaught runtime exceptions
add f4b5586 COMPRESS-565 : add a new option in Zip64Mode
add b5a9e88 document #169 and COMPRESS-565
add 03fba28 fix build failure
add 24788a9 looks as if we may forget flipping the buffer for sparse entries
add 9bc02b2 simplify BoundedArchiveIS#read, add upper bounds check for offset
add 06f1169 Fix typo
add 0f8a69c Grammar glitch
add e893413 COMPRESS-577 - Simplify assertion
add e404cbc Merge pull request #193 from arturobernalg/feature/COMPRESS-577
add 8dbf582 COMPRESS-579 - Remove redundant local variable
add 8fc60bf Merge pull request #195 from arturobernalg/feature/COMPRESS-579
add ce1c3f0 COMPRESS-580 - Remove redundant operation
add 93aab64 Merge pull request #196 from arturobernalg/feature/COMPRESS-580
add f8a4a3e simplify readEncodedHeader a bit
add a3b3b82 add back assertion that has been removed
add 6a72242 tiny performance improvement
add 1dde1a3 extra guard against illegal sparse struct values
add 7072023 COMPRESS-578 - Java 8 improvements
add 8225539 Merge pull request #194 from arturobernalg/feature/COMPRESS-578
add 8289193 handle cases where more data attempted to be read than exists
add b05ed49 COMPRESS-567 and even more 7z sanity checks
add b1cbfdd COMPRESS-567 more structured way to deal with buffer undeflow
add 8797ec4 COMPRESS-566 allow gzip buffer size to be configured
add 309681f COMPRESS-566 allow gzip buffer size to be configured
add 7928482 Merge pull request #168 from bokken/COMPRESS-566_buf_size
add 6efdc66 record COMPRESS-566
add f1218e2 minor cleanup of unused variables
add c5b60ca avoid NPE when there is no GNU tar extended header where one should be
add e0d4555 add TarFile special case to Lister and Expander
add 9450bcc properly document difference between tar getSize and getRealSize ...
add ae2b27c COMPRESS-542 make memory limit configuration apply to 7z metadata as well
add e1e5635 Bump actions/cache from 2.1.4 to 2.1.6 (#200)
add 017317f Bump actions/cache from 2.1.4 to 2.1.6 #200.
add 80a494c Bump commons.jacoco.version 0.8.5 -> 0.8.7, to build on Java 16.
add 3af47ee simplify comparator
add 4eea958 ZipFile could use some sanity checks as well
add 9ddce50 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-compress.git
add 0e9d6b0 Bump maven-bundle-plugin from 5.1.1 to 5.1.2 (#180)
add 8327310 Bump maven-bundle-plugin from 5.1.1 to 5.1.2 #180
add eb076ba Bump mockito-core from 3.8.0 to 3.11.1 (#204)
add c8e4459 Bump mockito-core from 3.8.0 to 3.11.1 #204.
add 3343cb3 Bump org.apache.felix:org.apache.felix.framework 6.0.3 -> 6.0.4.
add f95bcc4 Bump org.apache.felix:org.apache.felix.framework from 6.0.4 to 7.0.0.
add 4881382 Bump commons.japicmp.version from 0.14.3 to 0.15.3 (Java 16 builds).
add 00bc638 Bump zstd-jni from 1.4.9-1 to 1.5.0-2 (#203)
add 6efc056 Bump zstd-jni from 1.4.9-1 to 1.5.0-2 #203.
add de54e4d Bump commons.javadoc.version from 3.2.0 to 3.3.0.
add 7c79a74 FIx all Javadoc warnings issued by the Maven plugin.
add c24ac00 remove some redundant tests of the read phase that have been checked earlier
add 488425c only try to recover from broken 7z archive if explicitly asked to
add 3fe6b42 make sure coders are only used once in folder
add d0af873 make sure PAX header value fits into the size of the current entry
add 7ce1b07 potential integer overflow in check
add ef5d70b sanity check for link length in AsiExtraField
add d80d76f sanity check entry sizes in TarFile
add 80124dd remove pattern where we first allocate an array and then try to fill it
add c754db3 Merge from develop and resolve conflicts in pom.xml.
add a3a7883 Merge remote-tracking branch 'origin/master' into pack200
add 2d30030 Javadoc fixes and TODOs.
add e7cbb63 Merge remote-tracking branch 'origin/master' into pack200
add b1bfa29 Javadoc fixes, minimal Javadoc, and Jaavdoc TODOs.
add 87d322a Code clean ups.
add e251aa5 Format.
add 8522651 Update my developer entry.
add bce1af0 Merge remote-tracking branch 'origin/pack200'
add 9ab66a2 Simplify Assertions (#205)
add ec4b19c [COMPRESS-507] Commons Compress cannot be built with JDK14 due to Pack200 removal.
add fc24c6c Spelling.
add 821a23a Simplify Assertions #205.
new d358036 try to use java.util.jar.Packe200, only fall back to Harmony
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (fd3f09c)
\
N -- N -- N refs/heads/pack200-harmony-as-fallback (d358036)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/maven.yml | 3 +-
.gitignore | 14 +-
.travis.yml | 8 +-
src/assembly/src.xml => CODE_OF_CONDUCT.md | 27 +-
README.md | 1 +
src/assembly/src.xml => SECURITY.md | 27 +-
pom.xml | 56 +-
src/changes/changes.xml | 223 +++-
.../compress/archivers/ArchiveInputStream.java | 2 +-
.../compress/archivers/ArchiveOutputStream.java | 2 +-
.../compress/archivers/ArchiveStreamFactory.java | 16 +-
.../apache/commons/compress/archivers/Lister.java | 16 +-
.../compress/archivers/ar/ArArchiveEntry.java | 9 +-
.../archivers/ar/ArArchiveInputStream.java | 28 +-
.../archivers/ar/ArArchiveOutputStream.java | 24 +-
.../compress/archivers/arj/ArjArchiveEntry.java | 8 +-
.../archivers/arj/ArjArchiveInputStream.java | 37 +-
.../compress/archivers/arj/LocalFileHeader.java | 2 +-
.../commons/compress/archivers/arj/MainHeader.java | 2 +-
.../compress/archivers/cpio/CpioArchiveEntry.java | 32 +-
.../archivers/cpio/CpioArchiveInputStream.java | 34 +-
.../archivers/cpio/CpioArchiveOutputStream.java | 9 +-
.../commons/compress/archivers/cpio/CpioUtil.java | 4 +-
.../archivers/dump/DumpArchiveConstants.java | 4 +-
.../compress/archivers/dump/DumpArchiveEntry.java | 7 +-
.../archivers/dump/DumpArchiveInputStream.java | 28 +-
.../archivers/dump/DumpArchiveSummary.java | 6 +-
.../compress/archivers/dump/TapeInputStream.java | 15 +-
.../compress/archivers/examples/Archiver.java | 5 +-
.../compress/archivers/examples/Expander.java | 37 +-
.../archivers/jar/JarArchiveOutputStream.java | 2 +-
.../archivers/sevenz/AES256SHA256Decoder.java | 4 +-
.../commons/compress/archivers/sevenz/Archive.java | 4 +-
.../BoundedSeekableByteChannelInputStream.java | 4 +-
.../commons/compress/archivers/sevenz/CLI.java | 2 +-
.../commons/compress/archivers/sevenz/Coder.java | 2 +-
.../compress/archivers/sevenz/CoderBase.java | 6 +-
.../commons/compress/archivers/sevenz/Coders.java | 4 +-
.../commons/compress/archivers/sevenz/Folder.java | 29 +-
.../archivers/sevenz/SevenZArchiveEntry.java | 6 +-
.../compress/archivers/sevenz/SevenZFile.java | 741 +++++++++++--
.../archivers/sevenz/SevenZFileOptions.java | 59 +-
.../compress/archivers/sevenz/SevenZMethod.java | 5 +-
.../archivers/sevenz/SevenZOutputFile.java | 6 +-
.../compress/archivers/tar/TarArchiveEntry.java | 219 +++-
.../archivers/tar/TarArchiveInputStream.java | 323 +-----
.../archivers/tar/TarArchiveOutputStream.java | 22 +-
.../archivers/tar/TarArchiveSparseEntry.java | 16 +-
.../tar/TarArchiveSparseZeroInputStream.java} | 31 +-
.../archivers/tar/TarArchiveStructSparse.java | 6 +
.../commons/compress/archivers/tar/TarFile.java | 755 +++++++++++++
.../commons/compress/archivers/tar/TarUtils.java | 362 ++++++-
.../compress/archivers/zip/AsiExtraField.java | 34 +-
.../commons/compress/archivers/zip/BinaryTree.java | 21 +-
.../archivers/zip/ExplodingInputStream.java | 9 +-
.../compress/archivers/zip/ExtraFieldUtils.java | 34 +-
.../compress/archivers/zip/GeneralPurposeBit.java | 8 +-
.../zip/InflaterInputStreamWithStatistics.java | 4 +-
.../commons/compress/archivers/zip/JarMarker.java | 7 +-
.../compress/archivers/zip/NioZipEncoding.java | 16 +-
.../archivers/zip/ParallelScatterZipCreator.java | 33 +-
.../archivers/zip/ResourceAlignmentExtraField.java | 2 +-
.../archivers/zip/ScatterZipOutputStream.java | 2 +-
.../compress/archivers/zip/StreamCompressor.java | 6 +-
.../archivers/zip/UnshrinkingInputStream.java | 36 +-
.../zip/X0017_StrongEncryptionHeader.java | 12 +-
.../compress/archivers/zip/X7875_NewUnix.java | 9 +-
.../zip/Zip64ExtendedInformationExtraField.java | 6 +-
.../commons/compress/archivers/zip/Zip64Mode.java | 12 +-
.../compress/archivers/zip/ZipArchiveEntry.java | 42 +-
.../archivers/zip/ZipArchiveInputStream.java | 135 ++-
.../archivers/zip/ZipArchiveOutputStream.java | 98 +-
.../commons/compress/archivers/zip/ZipFile.java | 249 ++---
.../commons/compress/archivers/zip/ZipMethod.java | 2 +-
.../archivers/zip/ZipSplitOutputStream.java | 16 +-
.../zip/ZipSplitReadOnlySeekableByteChannel.java | 9 +-
.../commons/compress/archivers/zip/ZipUtil.java | 7 +-
.../apache/commons/compress/changes/ChangeSet.java | 1 -
.../compressors/CompressorInputStream.java | 2 +-
.../compressors/CompressorStreamFactory.java | 2 +-
.../compress/compressors/brotli/BrotliUtils.java | 10 +-
.../bzip2/BZip2CompressorInputStream.java | 48 +-
.../bzip2/BZip2CompressorOutputStream.java | 24 +-
.../compress/compressors/bzip2/BlockSort.java | 92 +-
.../commons/compress/compressors/bzip2/CRC.java | 4 +-
.../compressors/deflate64/HuffmanDecoder.java | 42 +-
.../gzip/GzipCompressorInputStream.java | 4 +-
.../gzip/GzipCompressorOutputStream.java | 7 +-
.../compress/compressors/gzip/GzipParameters.java | 26 +
.../lz4/BlockLZ4CompressorOutputStream.java | 15 +-
.../lz4/FramedLZ4CompressorOutputStream.java | 17 +-
.../AbstractLZ77CompressorInputStream.java | 2 +-
.../compressors/lz77support/LZ77Compressor.java | 10 +-
.../compress/compressors/lzma/LZMAUtils.java | 7 +-
.../pack200/Pack200CompressorOutputStream.java | 2 +-
.../compress/compressors/pack200/Pack200Utils.java | 9 +-
.../snappy/FramedSnappyCompressorInputStream.java | 3 +-
.../snappy/FramedSnappyCompressorOutputStream.java | 2 +-
.../snappy/SnappyCompressorInputStream.java | 4 +-
.../snappy/SnappyCompressorOutputStream.java | 2 +-
.../commons/compress/compressors/xz/XZUtils.java | 7 +-
.../compressors/z/ZCompressorInputStream.java | 22 +-
.../zstandard/ZstdCompressorInputStream.java | 17 +
.../compress/compressors/zstandard/ZstdUtils.java | 10 +-
.../harmony/archive/internal/nls/Messages.java | 162 ++-
.../commons/compress/harmony/pack200/Archive.java | 111 +-
.../harmony/pack200/AttributeDefinitionBands.java | 139 +--
.../compress/harmony/pack200/BHSDCodec.java | 222 ++--
.../commons/compress/harmony/pack200/BandSet.java | 528 ++++-----
.../commons/compress/harmony/pack200/BcBands.java | 299 +++---
.../commons/compress/harmony/pack200/CPClass.java | 12 +-
.../compress/harmony/pack200/CPConstant.java | 6 +-
.../commons/compress/harmony/pack200/CPDouble.java | 7 +-
.../commons/compress/harmony/pack200/CPFloat.java | 7 +-
.../commons/compress/harmony/pack200/CPInt.java | 13 +-
.../commons/compress/harmony/pack200/CPLong.java | 14 +-
.../compress/harmony/pack200/CPMethodOrField.java | 17 +-
.../compress/harmony/pack200/CPNameAndType.java | 15 +-
.../compress/harmony/pack200/CPSignature.java | 25 +-
.../commons/compress/harmony/pack200/CPString.java | 8 +-
.../commons/compress/harmony/pack200/CPUTF8.java | 8 +-
.../harmony/pack200/CanonicalCodecFamilies.java | 61 +-
.../compress/harmony/pack200/ClassBands.java | 1126 +++++++++-----------
.../commons/compress/harmony/pack200/Codec.java | 172 ++-
.../compress/harmony/pack200/CodecEncoding.java | 347 +++---
.../harmony/pack200/ConstantPoolEntry.java | 2 +-
.../commons/compress/harmony/pack200/CpBands.java | 419 ++++----
.../compress/harmony/pack200/FileBands.java | 78 +-
.../commons/compress/harmony/pack200/IcBands.java | 112 +-
.../commons/compress/harmony/pack200/IntList.java | 120 +--
.../harmony/pack200/MetadataBandGroup.java | 364 +++----
.../compress/harmony/pack200/NewAttribute.java | 75 +-
.../harmony/pack200/NewAttributeBands.java | 465 ++++----
.../harmony/pack200/Pack200ClassReader.java | 29 +-
.../compress/harmony/pack200/Pack200Exception.java | 5 +-
.../compress/harmony/pack200/PackingOptions.java | 193 ++--
.../compress/harmony/pack200/PackingUtils.java | 129 +--
.../compress/harmony/pack200/PopulationCodec.java | 62 +-
.../commons/compress/harmony/pack200/RunCodec.java | 72 +-
.../commons/compress/harmony/pack200/Segment.java | 465 ++++----
.../compress/harmony/pack200/SegmentHeader.java | 87 +-
.../compress/harmony/unpack200/Archive.java | 97 +-
.../harmony/unpack200/AttrDefinitionBands.java | 34 +-
.../harmony/unpack200/AttributeLayout.java | 102 +-
.../harmony/unpack200/AttributeLayoutMap.java | 304 ++----
.../compress/harmony/unpack200/BandSet.java | 425 ++++----
.../compress/harmony/unpack200/BcBands.java | 270 ++---
.../compress/harmony/unpack200/ClassBands.java | 957 +++++++----------
.../compress/harmony/unpack200/CpBands.java | 421 +++-----
.../compress/harmony/unpack200/FileBands.java | 44 +-
.../compress/harmony/unpack200/IMatcher.java | 2 +-
.../compress/harmony/unpack200/IcBands.java | 216 ++--
.../compress/harmony/unpack200/IcTuple.java | 93 +-
.../harmony/unpack200/MetadataBandGroup.java | 82 +-
.../harmony/unpack200/NewAttributeBands.java | 470 ++++----
.../compress/harmony/unpack200/Segment.java | 391 +++----
.../harmony/unpack200/SegmentConstantPool.java | 296 +++--
.../unpack200/SegmentConstantPoolArrayCache.java | 100 +-
.../compress/harmony/unpack200/SegmentHeader.java | 228 ++--
.../compress/harmony/unpack200/SegmentOptions.java | 26 +-
.../compress/harmony/unpack200/SegmentUtils.java | 66 +-
.../bytecode/AnnotationDefaultAttribute.java | 21 +-
.../unpack200/bytecode/AnnotationsAttribute.java | 38 +-
.../harmony/unpack200/bytecode/Attribute.java | 48 +-
.../unpack200/bytecode/BCIRenumberedAttribute.java | 32 +-
.../harmony/unpack200/bytecode/ByteCode.java | 230 ++--
.../harmony/unpack200/bytecode/CPClass.java | 36 +-
.../harmony/unpack200/bytecode/CPConstant.java | 34 +-
.../unpack200/bytecode/CPConstantNumber.java | 2 +-
.../harmony/unpack200/bytecode/CPDouble.java | 6 +-
.../harmony/unpack200/bytecode/CPField.java | 3 +-
.../harmony/unpack200/bytecode/CPFieldRef.java | 46 +-
.../harmony/unpack200/bytecode/CPFloat.java | 6 +-
.../harmony/unpack200/bytecode/CPInteger.java | 6 +-
.../unpack200/bytecode/CPInterfaceMethodRef.java | 11 +-
.../harmony/unpack200/bytecode/CPLong.java | 6 +-
.../harmony/unpack200/bytecode/CPMember.java | 61 +-
.../harmony/unpack200/bytecode/CPMethod.java | 7 +-
.../harmony/unpack200/bytecode/CPMethodRef.java | 10 +-
.../harmony/unpack200/bytecode/CPNameAndType.java | 53 +-
.../compress/harmony/unpack200/bytecode/CPRef.java | 45 +-
.../harmony/unpack200/bytecode/CPString.java | 18 +-
.../harmony/unpack200/bytecode/CPUTF8.java | 31 +-
.../unpack200/bytecode/ClassConstantPool.java | 124 +--
.../harmony/unpack200/bytecode/ClassFile.java | 6 +-
.../harmony/unpack200/bytecode/ClassFileEntry.java | 16 +-
.../harmony/unpack200/bytecode/CodeAttribute.java | 89 +-
.../unpack200/bytecode/ConstantPoolEntry.java | 13 +-
.../unpack200/bytecode/ConstantValueAttribute.java | 34 +-
.../unpack200/bytecode/DeprecatedAttribute.java | 7 +-
.../bytecode/EnclosingMethodAttribute.java | 20 +-
.../unpack200/bytecode/ExceptionTableEntry.java | 42 +-
.../unpack200/bytecode/ExceptionsAttribute.java | 41 +-
.../unpack200/bytecode/InnerClassesAttribute.java | 75 +-
.../bytecode/LineNumberTableAttribute.java | 26 +-
.../bytecode/LocalVariableTableAttribute.java | 49 +-
.../bytecode/LocalVariableTypeTableAttribute.java | 49 +-
.../harmony/unpack200/bytecode/NewAttribute.java | 115 +-
.../harmony/unpack200/bytecode/OperandManager.java | 34 +-
...timeVisibleorInvisibleAnnotationsAttribute.java | 28 +-
...leorInvisibleParameterAnnotationsAttribute.java | 34 +-
.../unpack200/bytecode/SignatureAttribute.java | 15 +-
.../unpack200/bytecode/SourceFileAttribute.java | 35 +-
.../unpack200/bytecode/forms/ByteCodeForm.java | 339 +++---
.../harmony/unpack200/bytecode/forms/ByteForm.java | 15 +-
.../unpack200/bytecode/forms/ClassRefForm.java | 24 +-
.../bytecode/forms/ClassSpecificReferenceForm.java | 25 +-
.../unpack200/bytecode/forms/DoubleForm.java | 10 +-
.../unpack200/bytecode/forms/FieldRefForm.java | 9 +-
.../unpack200/bytecode/forms/FloatRefForm.java | 14 +-
.../unpack200/bytecode/forms/IMethodRefForm.java | 26 +-
.../harmony/unpack200/bytecode/forms/IincForm.java | 20 +-
.../bytecode/forms/InitMethodReferenceForm.java | 28 +-
.../unpack200/bytecode/forms/IntRefForm.java | 11 +-
.../unpack200/bytecode/forms/LabelForm.java | 43 +-
.../unpack200/bytecode/forms/LocalForm.java | 22 +-
.../harmony/unpack200/bytecode/forms/LongForm.java | 9 +-
.../unpack200/bytecode/forms/LookupSwitchForm.java | 17 +-
.../unpack200/bytecode/forms/MethodRefForm.java | 13 +-
.../bytecode/forms/MultiANewArrayForm.java | 19 +-
.../bytecode/forms/NarrowClassRefForm.java | 17 +-
.../unpack200/bytecode/forms/NewClassRefForm.java | 29 +-
.../bytecode/forms/NewInitMethodRefForm.java | 23 +-
.../unpack200/bytecode/forms/NoArgumentForm.java | 20 +-
.../unpack200/bytecode/forms/ReferenceForm.java | 32 +-
.../unpack200/bytecode/forms/ShortForm.java | 15 +-
.../bytecode/forms/SingleByteReferenceForm.java | 18 +-
.../unpack200/bytecode/forms/StringRefForm.java | 27 +-
.../bytecode/forms/SuperFieldRefForm.java | 14 +-
.../bytecode/forms/SuperInitMethodRefForm.java | 8 +-
.../bytecode/forms/SuperMethodRefForm.java | 16 +-
.../unpack200/bytecode/forms/SwitchForm.java | 22 +-
.../unpack200/bytecode/forms/TableSwitchForm.java | 19 +-
.../unpack200/bytecode/forms/ThisFieldRefForm.java | 16 +-
.../bytecode/forms/ThisInitMethodRefForm.java | 8 +-
.../bytecode/forms/ThisMethodRefForm.java | 14 +-
.../bytecode/forms/VariableInstructionForm.java | 87 +-
.../harmony/unpack200/bytecode/forms/WideForm.java | 68 +-
.../commons/compress/utils/ArchiveUtils.java | 2 +-
.../commons/compress/utils/BitInputStream.java | 8 +-
.../compress/utils/BoundedArchiveInputStream.java | 97 ++
.../BoundedSeekableByteChannelInputStream.java | 57 +
.../apache/commons/compress/utils/ByteUtils.java | 8 +
.../compress/utils/CountingOutputStream.java | 2 +-
.../utils/FixedLengthBlockOutputStream.java | 2 +-
.../org/apache/commons/compress/utils/IOUtils.java | 105 +-
.../utils/MultiReadOnlySeekableByteChannel.java | 2 +-
.../apache/commons/compress/utils/OsgiUtils.java | 59 +
.../utils/SeekableInMemoryByteChannel.java | 6 +-
.../compress/utils/ServiceLoaderIterator.java | 14 +-
src/site/xdoc/examples.xml | 2 +-
.../apache/commons/compress/AbstractTestCase.java | 22 +-
.../apache/commons/compress/ArchiveReadTest.java | 18 +-
.../apache/commons/compress/ArchiveUtilsTest.java | 10 +-
.../apache/commons/compress/ChainingTestCase.java | 27 +-
.../commons/compress/DetectArchiverTestCase.java | 64 +-
.../org/apache/commons/compress/IOMethodsTest.java | 12 +-
.../org/apache/commons/compress/OsgiITest.java | 32 +-
.../commons/compress/archivers/ArTestCase.java | 71 +-
.../archivers/ArchiveOutputStreamTest.java | 10 +-
.../archivers/ArchiveStreamFactoryTest.java | 33 +-
.../commons/compress/archivers/CpioTestCase.java | 49 +-
.../commons/compress/archivers/DumpTestCase.java | 13 +-
.../compress/archivers/ExceptionMessageTest.java | 4 +-
.../commons/compress/archivers/JarTestCase.java | 21 +-
.../commons/compress/archivers/LongPathTest.java | 17 +-
.../compress/archivers/LongSymLinkTest.java | 17 +-
.../commons/compress/archivers/SevenZTestCase.java | 13 +-
.../commons/compress/archivers/TarTestCase.java | 328 +++++-
.../commons/compress/archivers/ZipTestCase.java | 57 +-
.../archivers/ar/ArArchiveInputStreamTest.java | 29 +-
.../archivers/ar/ArArchiveOutputStreamTest.java | 10 +-
.../archivers/arj/ArjArchiveInputStreamTest.java | 16 +-
.../archivers/cpio/CpioArchiveInputStreamTest.java | 16 +-
.../cpio/CpioArchiveOutputStreamTest.java | 13 +-
.../compress/archivers/cpio/CpioArchiveTest.java | 6 +-
.../archivers/dump/DumpArchiveInputStreamTest.java | 15 +-
.../compress/archivers/examples/ExpanderTest.java | 36 +-
.../archivers/jar/JarArchiveOutputStreamTest.java | 8 +-
.../archivers/memory/MemoryArchiveInputStream.java | 7 +-
.../archivers/memory/MemoryArchiveTestCase.java | 4 +-
.../archivers/sevenz/AES256SHA256DecoderTest.java | 3 +-
.../compress/archivers/sevenz/SevenZFileTest.java | 57 +-
.../archivers/sevenz/SevenZNativeHeapTest.java | 7 +-
.../archivers/sevenz/SevenZOutputFileTest.java | 14 +-
.../commons/compress/archivers/tar/BigFilesIT.java | 82 +-
.../compress/archivers/tar/SparseFilesTest.java | 361 +++++--
.../archivers/tar/TarArchiveEntryTest.java | 81 +-
.../archivers/tar/TarArchiveInputStreamTest.java | 170 ++-
.../archivers/tar/TarArchiveOutputStreamTest.java | 15 +-
.../compress/archivers/tar/TarFileTest.java | 365 +++++++
.../commons/compress/archivers/tar/TarLister.java | 10 +-
.../archivers/tar/TarMemoryFileSystemTest.java | 14 +-
.../compress/archivers/tar/TarUtilsTest.java | 418 +++++++-
.../compress/archivers/zip/AsiExtraFieldTest.java | 14 +-
.../compress/archivers/zip/BinaryTreeTest.java | 4 +-
.../compress/archivers/zip/BitStreamTest.java | 7 +-
.../compress/archivers/zip/CircularBufferTest.java | 4 +-
.../compress/archivers/zip/DataDescriptorTest.java | 13 +-
.../archivers/zip/EncryptedArchiveTest.java | 16 +-
.../compress/archivers/zip/ExplodeSupportTest.java | 8 +-
.../archivers/zip/ExtraFieldUtilsTest.java | 4 +-
.../archivers/zip/GeneralPurposeBitTest.java | 18 +-
.../commons/compress/archivers/zip/Lister.java | 21 +-
.../archivers/zip/Maven221MultiVolumeTest.java | 31 +-
.../zip/ParallelScatterZipCreatorTest.java | 134 +--
.../compress/archivers/zip/ScatterSample.java | 4 +-
.../compress/archivers/zip/ScatterSampleTest.java | 9 +-
.../archivers/zip/ScatterZipOutputStreamTest.java | 8 +-
.../compress/archivers/zip/UTF8ZipFilesTest.java | 41 +-
.../compress/archivers/zip/X000A_NTFSTest.java | 7 +-
.../archivers/zip/X5455_ExtendedTimestampTest.java | 58 +-
.../compress/archivers/zip/X7875_NewUnixTest.java | 55 +-
.../Zip64ExtendedInformationExtraFieldTest.java | 5 +-
.../compress/archivers/zip/Zip64SupportIT.java | 82 +-
.../archivers/zip/ZipArchiveEntryTest.java | 26 +-
.../archivers/zip/ZipArchiveInputStreamTest.java | 144 ++-
.../archivers/zip/ZipEightByteIntegerTest.java | 20 +-
.../zip/ZipFileIgnoringLocalFileHeaderTest.java | 4 +-
.../compress/archivers/zip/ZipFileTest.java | 137 ++-
.../compress/archivers/zip/ZipLongTest.java | 21 +-
.../compress/archivers/zip/ZipShortTest.java | 17 +-
.../archivers/zip/ZipSplitOutputStreamTest.java | 8 +-
.../compress/archivers/zip/ZipUtilTest.java | 10 +-
.../compress/changes/ChangeSetTestCase.java | 162 ++-
.../compress/compressors/BZip2TestCase.java | 24 +-
.../compress/compressors/BZip2UtilsTestCase.java | 4 +-
.../compress/compressors/DeflateTestCase.java | 40 +-
.../compressors/DetectCompressorTestCase.java | 22 +-
.../compress/compressors/FramedSnappyTestCase.java | 68 +-
.../commons/compress/compressors/GZipTestCase.java | 76 +-
.../compress/compressors/GzipUtilsTestCase.java | 4 +-
.../commons/compress/compressors/LZMATestCase.java | 28 +-
.../compress/compressors/Pack200TestCase.java | 27 +-
.../commons/compress/compressors/XZTestCase.java | 26 +-
.../commons/compress/compressors/ZTestCase.java | 46 +-
.../brotli/BrotliCompressorInputStreamTest.java | 31 +-
.../bzip2/BZip2CompressorInputStreamTest.java | 9 +-
.../bzip2/BZip2NSelectorsOverflowTest.java | 4 +-
.../bzip2/PythonTruncatedBzip2Test.java | 2 +-
.../deflate/DeflateCompressorInputStreamTest.java | 12 +-
.../Deflate64CompressorInputStreamTest.java | 58 +-
.../lz4/BlockLZ4CompressorInputStreamTest.java | 11 +-
.../lz4/BlockLZ4CompressorRoundtripTest.java | 19 +-
.../compress/compressors/lz4/FactoryTest.java | 11 +-
.../lz4/FramedLZ4CompressorInputStreamTest.java | 97 +-
.../lz4/FramedLZ4CompressorRoundtripTest.java | 41 +-
.../compress/compressors/lz4/XXHash32Test.java | 5 +-
.../AbstractLZ77CompressorInputStreamTest.java | 5 +-
.../lz77support/LZ77CompressorTest.java | 138 ++-
.../compressors/lzma/LZMAUtilsTestCase.java | 4 +-
.../compressors/pack200/Pack200UtilsTest.java | 16 +-
.../FramedSnappyCompressorInputStreamTest.java | 56 +-
.../compressors/snappy/SnappyRoundtripTest.java | 18 +-
.../xz/XZCompressorInputStreamTest.java | 7 +-
.../compress/compressors/xz/XZUtilsTestCase.java | 4 +-
.../compressors/z/ZCompressorInputStreamTest.java | 8 +-
.../zstandard/ZstdCompressorInputStreamTest.java | 65 +-
.../compressors/zstandard/ZstdRoundtripTest.java | 47 +-
.../commons/compress/utils/BitInputStreamTest.java | 8 +-
...BoundedSeekableByteChannelInputStreamTest.java} | 32 +-
.../commons/compress/utils/ByteUtilsTest.java | 31 +-
.../commons/compress/utils/CharsetsTest.java | 4 +-
.../utils/ChecksumCalculatingInputStreamTest.java | 8 +-
.../apache/commons/compress/utils/IOUtilsTest.java | 137 ++-
.../MultiReadOnlySeekableByteChannelTest.java | 12 +-
.../{CharsetsTest.java => OsgiUtilsTest.java} | 21 +-
.../utils/SeekableInMemoryByteChannelTest.java | 8 +-
.../ZipSplitReadOnlySeekableByteChannelTest.java | 4 +-
src/test/resources/COMPRESS-548.zip | Bin 0 -> 79 bytes
src/test/resources/{bla.cpio => COMPRESS-553.tar} | Bin 5120 -> 7168 bytes
.../{COMPRESS-114.tar => COMPRESS-554.tar} | Bin 10240 -> 10842 bytes
src/test/resources/COMPRESS-569.tar | Bin 0 -> 513 bytes
.../resources/{COMPRESS-529.tar => directory.tar} | Bin 1536 -> 1536 bytes
374 files changed, 12810 insertions(+), 10312 deletions(-)
copy src/assembly/src.xml => CODE_OF_CONDUCT.md (50%)
copy src/assembly/src.xml => SECURITY.md (50%)
copy src/main/java/org/apache/commons/compress/{PasswordRequiredException.java => archivers/tar/TarArchiveSparseZeroInputStream.java} (60%)
create mode 100644 src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
create mode 100644 src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java
create mode 100644 src/main/java/org/apache/commons/compress/utils/BoundedSeekableByteChannelInputStream.java
create mode 100644 src/main/java/org/apache/commons/compress/utils/OsgiUtils.java
create mode 100644 src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java
copy src/test/java/org/apache/commons/compress/{archivers/zip/X000A_NTFSTest.java => utils/BoundedSeekableByteChannelInputStreamTest.java} (55%)
copy src/test/java/org/apache/commons/compress/utils/{CharsetsTest.java => OsgiUtilsTest.java} (55%)
create mode 100644 src/test/resources/COMPRESS-548.zip
copy src/test/resources/{bla.cpio => COMPRESS-553.tar} (63%)
copy src/test/resources/{COMPRESS-114.tar => COMPRESS-554.tar} (54%)
create mode 100644 src/test/resources/COMPRESS-569.tar
copy src/test/resources/{COMPRESS-529.tar => directory.tar} (58%)
[commons-compress] 01/01: try to use java.util.jar.Packe200,
only fall back to Harmony
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch pack200-harmony-as-fallback
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit d35803651d0e992d19db9da71a0a2e5082c865d2
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Thu Jul 1 22:12:51 2021 +0200
try to use java.util.jar.Packe200, only fall back to Harmony
---
.../compressors/pack200/HarmonyPack200.java | 133 ++++++++
.../compressors/pack200/JavaUtilPack200.java | 106 +++++++
.../pack200/Pack200CompressorInputStream.java | 3 +-
.../pack200/Pack200CompressorOutputStream.java | 3 +-
.../compressors/pack200/Pack200Facade.java | 295 ++++++++++++++++++
.../compress/compressors/pack200/Pack200Utils.java | 7 +-
.../compress/harmony/pack200/Pack200Adapter.java | 59 ----
.../harmony/pack200/Pack200PackerAdapter.java | 103 -------
.../harmony/unpack200/Pack200UnpackerAdapter.java | 73 -----
.../commons/compress/java/util/jar/Pack200.java | 339 ---------------------
.../compressors/pack200/Pack200FacadeTest.java | 50 +++
11 files changed, 589 insertions(+), 582 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/HarmonyPack200.java b/src/main/java/org/apache/commons/compress/compressors/pack200/HarmonyPack200.java
new file mode 100644
index 0000000..b52c4da
--- /dev/null
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/HarmonyPack200.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.compress.compressors.pack200;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+
+import org.apache.commons.compress.harmony.pack200.Pack200Exception;
+import org.apache.commons.compress.harmony.pack200.PackingOptions;
+import org.apache.commons.compress.harmony.unpack200.Archive;
+
+/**
+ * Class factory for {@link Pack200Facade.Packer} and {@link Pack200Facade.Unpacker} based on the {@code
+ * org.apache.commons.compress.harmony} package.
+ */
+public abstract class HarmonyPack200 {
+
+ /**
+ * Prevent this class from being instantiated.
+ */
+ private HarmonyPack200() {
+ // do nothing
+ }
+
+ /**
+ * Returns a new instance of a packer engine.
+ *
+ * @return an instance of {@code Pack200Facade.Packer}
+ */
+ public static Pack200Facade.Packer newPacker() {
+ return new Pack200PackerAdapter();
+ }
+
+ /**
+ * Returns a new instance of a unpacker engine.
+ *
+ * @return a instance of {@code Pack200Facade.Unpacker}.
+ */
+ public static Pack200Facade.Unpacker newUnpacker() {
+ return new Pack200UnpackerAdapter();
+ }
+
+ private static abstract class Pack200Adapter {
+
+ protected static final int DEFAULT_BUFFER_SIZE = 8192;
+
+ private final SortedMap<String, String> properties = new TreeMap<String, String>();
+
+ public SortedMap<String, String> properties() {
+ return properties;
+ }
+
+ }
+
+ static class Pack200UnpackerAdapter extends Pack200Adapter implements Pack200Facade.Unpacker {
+ @Override
+ public void unpack(InputStream in, JarOutputStream out) throws IOException {
+ if (in == null || out == null)
+ throw new IllegalArgumentException("Must specify both input and output streams");
+ try {
+ new Archive(in, out).unpack();
+ } catch (Pack200Exception e) {
+ throw new IOException("Failed to unpack Jar:" + String.valueOf(e));
+ }
+ in.close();
+ }
+
+ @Override
+ public void unpack(File file, JarOutputStream out) throws IOException {
+ if (file == null || out == null)
+ throw new IllegalArgumentException("Must specify both input and output streams");
+ int size = (int) file.length();
+ int bufferSize = (size > 0 && size < DEFAULT_BUFFER_SIZE ? size
+ : DEFAULT_BUFFER_SIZE);
+ InputStream in = new BufferedInputStream(new FileInputStream(file), bufferSize);
+ unpack(in, out);
+ }
+ }
+
+ static class Pack200PackerAdapter extends Pack200Adapter implements Pack200Facade.Packer {
+
+ private final PackingOptions options = new PackingOptions();
+
+ @Override
+ public void pack(JarFile file, OutputStream out) throws IOException {
+ if (file == null || out == null)
+ throw new IllegalArgumentException("Must specify both input and output streams");
+ try {
+ new org.apache.commons.compress.harmony.pack200.Archive(file, out, options).pack();
+ } catch (Pack200Exception e) {
+ throw new IOException("Failed to pack Jar:" + String.valueOf(e));
+ }
+ }
+
+ @Override
+ public void pack(JarInputStream in, OutputStream out) throws IOException {
+ if (in == null || out == null)
+ throw new IllegalArgumentException("Must specify both input and output streams");
+ PackingOptions options = new PackingOptions();
+
+ try {
+ new org.apache.commons.compress.harmony.pack200.Archive(in, out, options).pack();
+ } catch (Pack200Exception e) {
+ throw new IOException("Failed to pack Jar:" + String.valueOf(e));
+ }
+ in.close();
+ }
+
+ }
+}
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/JavaUtilPack200.java b/src/main/java/org/apache/commons/compress/compressors/pack200/JavaUtilPack200.java
new file mode 100644
index 0000000..eb475ae
--- /dev/null
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/JavaUtilPack200.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.compress.compressors.pack200;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.SortedMap;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200;
+
+/**
+ * Class factory for {@link Pack200Facade.Packer} and {@link Pack200Facade.Unpacker} based on the {@code
+ * org.apache.commons.compress.harmony} package.
+ */
+public abstract class JavaUtilPack200 {
+
+ /**
+ * Prevent this class from being instantiated.
+ */
+ private JavaUtilPack200() {
+ // do nothing
+ }
+
+ /**
+ * Returns a new instance of a packer engine.
+ *
+ * @return an instance of {@code Pack200Facade.Packer}
+ */
+ public static Pack200Facade.Packer newPacker() {
+ return new Pack200PackerAdapter(Pack200.newPacker());
+ }
+
+ /**
+ * Returns a new instance of a unpacker engine.
+ *
+ * @return a instance of {@code Pack200Facade.Unpacker}.
+ */
+ public static Pack200Facade.Unpacker newUnpacker() {
+ return new Pack200UnpackerAdapter(Pack200.newUnpacker());
+ }
+
+ private static class Pack200UnpackerAdapter implements Pack200Facade.Unpacker {
+ private final Pack200.Unpacker unpacker;
+
+ private Pack200UnpackerAdapter(final Pack200.Unpacker unpacker) {
+ this.unpacker = unpacker;
+ }
+
+ @Override
+ public void unpack(InputStream in, JarOutputStream out) throws IOException {
+ unpacker.unpack(in, out);
+ }
+
+ @Override
+ public void unpack(File file, JarOutputStream out) throws IOException {
+ unpacker.unpack(file, out);
+ }
+
+ @Override
+ public SortedMap<String, String> properties() {
+ return unpacker.properties();
+ }
+ }
+
+ private static class Pack200PackerAdapter implements Pack200Facade.Packer {
+ private final Pack200.Packer packer;
+
+ private Pack200PackerAdapter(final Pack200.Packer packer) {
+ this.packer = packer;
+ }
+
+ @Override
+ public void pack(JarFile file, OutputStream out) throws IOException {
+ packer.pack(file, out);
+ }
+
+ @Override
+ public void pack(JarInputStream in, OutputStream out) throws IOException {
+ packer.pack(in, out);
+ }
+
+ @Override
+ public SortedMap<String, String> properties() {
+ return packer.properties();
+ }
+ }
+}
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
index 0336fed..2d4d0d7 100644
--- a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.jar.JarOutputStream;
-import org.apache.commons.compress.java.util.jar.Pack200;
import org.apache.commons.compress.compressors.CompressorInputStream;
import org.apache.commons.compress.utils.CloseShieldFilterInputStream;
@@ -173,7 +172,7 @@ public class Pack200CompressorInputStream extends CompressorInputStream {
originalInput = in;
streamBridge = mode.newStreamBridge();
try (final JarOutputStream jarOut = new JarOutputStream(streamBridge)) {
- final Pack200.Unpacker u = Pack200.newUnpacker();
+ final Pack200Facade.Unpacker u = Pack200Facade.newUnpacker();
if (props != null) {
u.properties().putAll(props);
}
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
index 374b89a..cbefeff 100644
--- a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
import java.util.jar.JarInputStream;
-import org.apache.commons.compress.java.util.jar.Pack200;
import org.apache.commons.compress.compressors.CompressorOutputStream;
@@ -128,7 +127,7 @@ public class Pack200CompressorOutputStream extends CompressorOutputStream {
public void finish() throws IOException {
if (!finished) {
finished = true;
- final Pack200.Packer p = Pack200.newPacker();
+ final Pack200Facade.Packer p = Pack200Facade.newPacker();
if (properties != null) {
p.properties().putAll(properties);
}
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Facade.java b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Facade.java
new file mode 100644
index 0000000..49dd738
--- /dev/null
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Facade.java
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.compress.compressors.pack200;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.SortedMap;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+
+/**
+ * Class factory for {@link Pack200Facade.Packer} and {@link Pack200Facade.Unpacker} that tries to use {@link
+ * JavaUtilPack200} and falls back to {@link HarmonyPack200}.
+ */
+public abstract class Pack200Facade {
+
+ private static final Method newPackerMethod;
+ private static final Method newUnpackerMethod;
+
+ static {
+ Method newPacker, newUnpacker;
+ newPacker = newUnpacker = null;
+ try {
+ Class p = Class.forName("org.apache.commons.compress.compressors.pack200.JavaUtilPack200");
+ newPacker = p.getMethod("newPacker");
+ newUnpacker = p.getMethod("newUnpacker");
+ } catch (Exception ex) {
+ newPacker = newUnpacker = null;
+ }
+ newPackerMethod = newPacker;
+ newUnpackerMethod = newUnpacker;
+ }
+
+ /**
+ * Prevent this class from being instantiated.
+ */
+ private Pack200Facade() {
+ // do nothing
+ }
+
+ /**
+ * Returns a new instance of a packer engine.
+ *
+ * @return an instance of {@code Packer}
+ */
+ public static Packer newPacker() {
+ if (newPackerMethod != null) {
+ try {
+ return (Packer) newPackerMethod.invoke(null);
+ } catch (IllegalAccessException | InvocationTargetException ex) {
+ }
+ }
+ return HarmonyPack200.newPacker();
+ }
+
+ /**
+ * Returns a new instance of a unpacker engine.
+ *
+ * @return a instance of {@code Unpacker}.
+ */
+ public static Unpacker newUnpacker() {
+ if (newUnpackerMethod != null) {
+ try {
+ return (Unpacker) newUnpackerMethod.invoke(null);
+ } catch (IllegalAccessException | InvocationTargetException ex) {
+ }
+ }
+ return HarmonyPack200.newUnpacker();
+ }
+
+ /**
+ * The interface defining the API for converting a JAR file to an output
+ * stream in the Pack200 format.
+ */
+ public static interface Packer {
+
+ /**
+ * the format of a class attribute name.
+ */
+ static final String CLASS_ATTRIBUTE_PFX = "pack.class.attribute.";
+
+ /**
+ * the format of a code attribute name.
+ */
+ static final String CODE_ATTRIBUTE_PFX = "pack.code.attribute.";
+
+ /**
+ * the deflation hint to set in the output archive.
+ */
+ static final String DEFLATE_HINT = "pack.deflate.hint";
+
+ /**
+ * the indicated amount of effort to use in compressing the archive.
+ */
+ static final String EFFORT = "pack.effort";
+
+ /**
+ * a String representation for {@code error}.
+ */
+ static final String ERROR = "error";
+
+ /**
+ * a String representation of {@code false}.
+ */
+ static final String FALSE = "false";
+
+ /**
+ * the format of a field attribute name.
+ */
+ static final String FIELD_ATTRIBUTE_PFX = "pack.field.attribute.";
+
+ /**
+ * a String representation for {@code keep}.
+ */
+ static final String KEEP = "keep";
+
+ /**
+ * decide if all elements shall transmit in their original order.
+ */
+ static final String KEEP_FILE_ORDER = "pack.keep.file.order";
+
+ /**
+ * a String representation for {@code latest}.
+ */
+ static final String LATEST = "latest";
+
+ /**
+ * the format of a method attribute name.
+ */
+ static final String METHOD_ATTRIBUTE_PFX = "pack.method.attribute.";
+
+ /**
+ * if it shall attempt to determine the latest modification time if this
+ * is set to {@code LATEST}.
+ */
+ static final String MODIFICATION_TIME = "pack.modification.time";
+
+ /**
+ * a String representation of {@code pass}.
+ */
+ static final String PASS = "pass";
+
+ /**
+ * the file that will not be compressed.
+ */
+ static final String PASS_FILE_PFX = "pack.pass.file.";
+
+ /**
+ * packer progress as a percentage.
+ */
+ static final String PROGRESS = "pack.progress";
+
+ /**
+ * The number of bytes of each archive segment.
+ */
+ static final String SEGMENT_LIMIT = "pack.segment.limit";
+
+ /**
+ * a String representation of {@code strip}.
+ */
+ static final String STRIP = "strip";
+
+ /**
+ * a String representation of {@code true}.
+ */
+ static final String TRUE = "true";
+
+ /**
+ * the action to take if an unknown attribute is encountered.
+ */
+ static final String UNKNOWN_ATTRIBUTE = "pack.unknown.attribute";
+
+ /**
+ * Returns a sorted map of the properties of this packer.
+ *
+ * @return the properties of the packer.
+ */
+ SortedMap<String, String> properties();
+
+ /**
+ * Pack the specified JAR file to the specified output stream.
+ *
+ * @param in
+ * JAR file to be compressed.
+ * @param out
+ * stream of compressed data.
+ * @throws IOException
+ * if I/O exception occurs.
+ */
+ void pack(JarFile in, OutputStream out) throws IOException;
+
+ /**
+ * Pack the data from the specified jar input stream to the specified
+ * output stream.
+ *
+ * @param in
+ * stream of uncompressed JAR data.
+ * @param out
+ * stream of compressed data.
+ * @throws IOException
+ * if I/O exception occurs.
+ */
+ void pack(JarInputStream in, OutputStream out) throws IOException;
+
+ }
+
+ /**
+ * The interface defining the API for converting a packed stream in the
+ * Pack200 format to a JAR file.
+ */
+ public static interface Unpacker {
+
+ /**
+ * The String indicating if the unpacker should ignore all transmitted
+ * values,can be replaced by either {@code true} or {@code false}.
+ */
+ static final String DEFLATE_HINT = "unpack.deflate.hint";
+
+ /**
+ * a String representation of {@code false}.
+ */
+ static final String FALSE = "false";
+
+ /**
+ * a String representation of {@code keep}.
+ */
+ static final String KEEP = "keep";
+
+ /**
+ * the progress as a {@code percentage}.
+ */
+ static final String PROGRESS = "unpack.progress";
+
+ /**
+ * a String representation of {@code true}.
+ */
+ static final String TRUE = "true";
+
+ /**
+ * Returns a sorted map of the properties of this unpacker.
+ *
+ * @return the properties of unpacker.
+ */
+ SortedMap<String, String> properties();
+
+ /**
+ * Unpack the specified stream to the specified JAR output stream.
+ *
+ * @param in
+ * stream to uncompressed.
+ * @param out
+ * JAR output stream of uncompressed data.
+ * @throws IOException
+ * if I/O exception occurs.
+ */
+ void unpack(InputStream in, JarOutputStream out) throws IOException;
+
+ /**
+ * Unpack the contents of the specified {@code File} to the specified
+ * JAR output stream.
+ *
+ * @param in
+ * file to be uncompressed.
+ * @param out
+ * JAR output stream of uncompressed data.
+ * @throws IOException
+ * if I/O exception occurs.
+ */
+ void unpack(File in, JarOutputStream out) throws IOException;
+
+ }
+
+}
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Utils.java b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Utils.java
index 94b5235..b12f2ce 100644
--- a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Utils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Utils.java
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
-import org.apache.commons.compress.java.util.jar.Pack200;
/**
* Utility methods for Pack200.
@@ -130,16 +129,16 @@ public class Pack200Utils {
if (props == null) {
props = new HashMap<>();
}
- props.put(Pack200.Packer.SEGMENT_LIMIT, "-1");
+ props.put(Pack200Facade.Packer.SEGMENT_LIMIT, "-1");
final File tempFile = File.createTempFile("commons-compress", "pack200normalize");
try {
try (OutputStream fos = Files.newOutputStream(tempFile.toPath());
JarFile jarFile = new JarFile(from)) {
- final Pack200.Packer packer = Pack200.newPacker();
+ final Pack200Facade.Packer packer = Pack200Facade.newPacker();
packer.properties().putAll(props);
packer.pack(jarFile, fos);
}
- final Pack200.Unpacker unpacker = Pack200.newUnpacker();
+ final Pack200Facade.Unpacker unpacker = Pack200Facade.newUnpacker();
try (JarOutputStream jos = new JarOutputStream(Files.newOutputStream(to.toPath()))) {
unpacker.unpack(tempFile, jos);
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/Pack200Adapter.java b/src/main/java/org/apache/commons/compress/harmony/pack200/Pack200Adapter.java
deleted file mode 100644
index 0d37fe5..0000000
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/Pack200Adapter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.compress.harmony.pack200;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Provides generic JavaBeans support for the Pack/UnpackAdapters
- */
-public abstract class Pack200Adapter {
-
- protected static final int DEFAULT_BUFFER_SIZE = 8192;
-
- private final PropertyChangeSupport support = new PropertyChangeSupport(this);
-
- private final SortedMap<String, String> properties = new TreeMap<>();
-
- public SortedMap<String, String> properties() {
- return properties;
- }
-
- public void addPropertyChangeListener(final PropertyChangeListener listener) {
- support.addPropertyChangeListener(listener);
- }
-
- protected void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) {
- support.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- public void removePropertyChangeListener(final PropertyChangeListener listener) {
- support.removePropertyChangeListener(listener);
- }
-
- /**
- * Completion between 0..1.
- *
- * @param value Completion between 0..1.
- */
- protected void completed(final double value) {
- firePropertyChange("pack.progress", null, String.valueOf((int) (100 * value))); //$NON-NLS-1$
- }
-}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/Pack200PackerAdapter.java b/src/main/java/org/apache/commons/compress/harmony/pack200/Pack200PackerAdapter.java
deleted file mode 100644
index d078399..0000000
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/Pack200PackerAdapter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.compress.harmony.pack200;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.jar.JarFile;
-import java.util.jar.JarInputStream;
-
-import org.apache.commons.compress.java.util.jar.Pack200.Packer;
-
-/**
- * This class provides the binding between the standard Pack200 interface and the internal interface for (un)packing. As
- * this uses generics for the SortedMap, this class must be compiled and run on a Java 1.5 system. However, Java 1.5 is
- * not necessary to use the internal libraries for unpacking.
- */
-public class Pack200PackerAdapter extends Pack200Adapter implements Packer {
-
- private final PackingOptions options = new PackingOptions();
-
- @Override
- public void pack(final JarFile file, final OutputStream out) throws IOException {
- if (file == null || out == null) {
- throw new IllegalArgumentException("Must specify both input and output streams");
- }
- completed(0);
- try {
- new org.apache.commons.compress.harmony.pack200.Archive(file, out, options).pack();
- } catch (final Pack200Exception e) {
- throw new IOException("Failed to pack Jar:" + String.valueOf(e));
- }
- completed(1);
- }
-
- @Override
- public void pack(final JarInputStream in, final OutputStream out) throws IOException {
- if (in == null || out == null) {
- throw new IllegalArgumentException("Must specify both input and output streams");
- }
- completed(0);
- final PackingOptions options = new PackingOptions();
-
- try {
- new org.apache.commons.compress.harmony.pack200.Archive(in, out, options).pack();
- } catch (final Pack200Exception e) {
- throw new IOException("Failed to pack Jar:" + String.valueOf(e));
- }
- completed(1);
- in.close();
- }
-
- @Override
- protected void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) {
- super.firePropertyChange(propertyName, oldValue, newValue);
- if (newValue != null && !newValue.equals(oldValue)) {
- if (propertyName.startsWith(CLASS_ATTRIBUTE_PFX)) {
- final String attributeName = propertyName.substring(CLASS_ATTRIBUTE_PFX.length());
- options.addClassAttributeAction(attributeName, (String) newValue);
- } else if (propertyName.startsWith(CODE_ATTRIBUTE_PFX)) {
- final String attributeName = propertyName.substring(CODE_ATTRIBUTE_PFX.length());
- options.addCodeAttributeAction(attributeName, (String) newValue);
- } else if (propertyName.equals(DEFLATE_HINT)) {
- options.setDeflateHint((String) newValue);
- } else if (propertyName.equals(EFFORT)) {
- options.setEffort(Integer.parseInt((String) newValue));
- } else if (propertyName.startsWith(FIELD_ATTRIBUTE_PFX)) {
- final String attributeName = propertyName.substring(FIELD_ATTRIBUTE_PFX.length());
- options.addFieldAttributeAction(attributeName, (String) newValue);
- } else if (propertyName.equals(KEEP_FILE_ORDER)) {
- options.setKeepFileOrder(Boolean.parseBoolean((String) newValue));
- } else if (propertyName.startsWith(METHOD_ATTRIBUTE_PFX)) {
- final String attributeName = propertyName.substring(METHOD_ATTRIBUTE_PFX.length());
- options.addMethodAttributeAction(attributeName, (String) newValue);
- } else if (propertyName.equals(MODIFICATION_TIME)) {
- options.setModificationTime((String) newValue);
- } else if (propertyName.startsWith(PASS_FILE_PFX)) {
- if (oldValue != null && !oldValue.equals("")) {
- options.removePassFile((String) oldValue);
- }
- options.addPassFile((String) newValue);
- } else if (propertyName.equals(SEGMENT_LIMIT)) {
- options.setSegmentLimit(Long.parseLong((String) newValue));
- } else if (propertyName.equals(UNKNOWN_ATTRIBUTE)) {
- options.setUnknownAttributeAction((String) newValue);
- }
- }
- }
-
-}
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/Pack200UnpackerAdapter.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/Pack200UnpackerAdapter.java
deleted file mode 100644
index c100176..0000000
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/Pack200UnpackerAdapter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.compress.harmony.unpack200;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.jar.JarOutputStream;
-
-import org.apache.commons.compress.harmony.pack200.Pack200Adapter;
-import org.apache.commons.compress.harmony.pack200.Pack200Exception;
-import org.apache.commons.compress.java.util.jar.Pack200.Unpacker;
-
-/**
- * This class provides the binding between the standard Pack200 interface and the internal interface for (un)packing. As
- * this uses generics for the SortedMap, this class must be compiled and run on a Java 1.5 system. However, Java 1.5 is
- * not necessary to use the internal libraries for unpacking.
- */
-public class Pack200UnpackerAdapter extends Pack200Adapter implements Unpacker {
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.compress.java.util.jar.Pack200.Unpacker#unpack(java.io.InputStream,
- * java.util.jar.JarOutputStream)
- */
- @Override
- public void unpack(final InputStream in, final JarOutputStream out) throws IOException {
- if (in == null || out == null) {
- throw new IllegalArgumentException("Must specify both input and output streams");
- }
- completed(0);
- try {
- new Archive(in, out).unpack();
- } catch (final Pack200Exception e) {
- throw new IOException("Failed to unpack Jar:" + String.valueOf(e));
- }
- completed(1);
- in.close();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.compress.java.util.jar.Pack200.Unpacker#unpack(java.io.File,
- * java.util.jar.JarOutputStream)
- */
- @Override
- public void unpack(final File file, final JarOutputStream out) throws IOException {
- if (file == null || out == null) {
- throw new IllegalArgumentException("Must specify both input and output streams");
- }
- final int size = (int) file.length();
- final int bufferSize = (size > 0 && size < DEFAULT_BUFFER_SIZE ? size : DEFAULT_BUFFER_SIZE);
- final InputStream in = new BufferedInputStream(new FileInputStream(file), bufferSize);
- unpack(in, out);
- }
-}
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
deleted file mode 100644
index a2c9df2..0000000
--- a/src/main/java/org/apache/commons/compress/java/util/jar/Pack200.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.compress.java.util.jar;
-
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.SortedMap;
-import java.util.jar.JarFile;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-
-import org.apache.commons.compress.harmony.archive.internal.nls.Messages;
-
-/**
- * Class factory for {@link Pack200.Packer} and {@link Pack200.Unpacker}.
- */
-public abstract class Pack200 {
-
- private static final String SYSTEM_PROPERTY_PACKER = "java.util.jar.Pack200.Packer"; //$NON-NLS-1$
-
- private static final String SYSTEM_PROPERTY_UNPACKER = "java.util.jar.Pack200.Unpacker"; //$NON-NLS-1$
-
- /**
- * Prevent this class from being instantiated.
- */
- private Pack200() {
- // do nothing
- }
-
- /**
- * Returns a new instance of a packer engine.
- * <p>
- * The implementation of the packer engine is defined by the system property
- * {@code 'java.util.jar.Pack200.Packer'}. If this system property is
- * defined an instance of the specified class is returned, otherwise the
- * system's default implementation is returned.
- *
- * @return an instance of {@code Packer}
- */
- public static Pack200.Packer newPacker() {
- return (Packer) AccessController
- .doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- String className = System
- .getProperty(SYSTEM_PROPERTY_PACKER,
- "org.apache.commons.compress.harmony.pack200.Pack200PackerAdapter"); //$NON-NLS-1$
- try {
- // TODO Not sure if this will cause problems with
- // loading the packer
- return ClassLoader.getSystemClassLoader()
- .loadClass(className).newInstance();
- } catch (Exception e) {
- throw new Error(Messages.getString("archive.3E",className), e); //$NON-NLS-1$
- }
- }
- });
-
- }
-
- /**
- * Returns a new instance of a unpacker engine.
- * <p>
- * The implementation of the unpacker engine is defined by the system
- * property {@code 'java.util.jar.Pack200.Unpacker'}. If this system
- * property is defined an instance of the specified class is returned,
- * otherwise the system's default implementation is returned.
- *
- * @return a instance of {@code Unpacker}.
- */
- public static Pack200.Unpacker newUnpacker() {
- return (Unpacker) AccessController
- .doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- String className = System
- .getProperty(SYSTEM_PROPERTY_UNPACKER,
- "org.apache.commons.compress.harmony.unpack200.Pack200UnpackerAdapter");//$NON-NLS-1$
- try {
- return ClassLoader.getSystemClassLoader()
- .loadClass(className).newInstance();
- } catch (Exception e) {
- throw new Error(Messages.getString("archive.3E",className), e); //$NON-NLS-1$
- }
- }
- });
- }
-
- /**
- * The interface defining the API for converting a JAR file to an output
- * stream in the Pack200 format.
- */
- public static interface Packer {
-
- /**
- * the format of a class attribute name.
- */
- static final String CLASS_ATTRIBUTE_PFX = "pack.class.attribute."; //$NON-NLS-1$
-
- /**
- * the format of a code attribute name.
- */
- static final String CODE_ATTRIBUTE_PFX = "pack.code.attribute."; //$NON-NLS-1$
-
- /**
- * the deflation hint to set in the output archive.
- */
- static final String DEFLATE_HINT = "pack.deflate.hint";//$NON-NLS-1$
-
- /**
- * the indicated amount of effort to use in compressing the archive.
- */
- static final String EFFORT = "pack.effort";//$NON-NLS-1$
-
- /**
- * a String representation for {@code error}.
- */
- static final String ERROR = "error";//$NON-NLS-1$
-
- /**
- * a String representation of {@code false}.
- */
- static final String FALSE = "false";//$NON-NLS-1$
-
- /**
- * the format of a field attribute name.
- */
- static final String FIELD_ATTRIBUTE_PFX = "pack.field.attribute.";//$NON-NLS-1$
-
- /**
- * a String representation for {@code keep}.
- */
- static final String KEEP = "keep";//$NON-NLS-1$
-
- /**
- * decide if all elements shall transmit in their original order.
- */
- static final String KEEP_FILE_ORDER = "pack.keep.file.order";//$NON-NLS-1$
-
- /**
- * a String representation for {@code latest}.
- */
- static final String LATEST = "latest";//$NON-NLS-1$
-
- /**
- * the format of a method attribute name.
- */
- static final String METHOD_ATTRIBUTE_PFX = "pack.method.attribute.";//$NON-NLS-1$
-
- /**
- * if it shall attempt to determine the latest modification time if this
- * is set to {@code LATEST}.
- */
- static final String MODIFICATION_TIME = "pack.modification.time";//$NON-NLS-1$
-
- /**
- * a String representation of {@code pass}.
- */
- static final String PASS = "pass";//$NON-NLS-1$
-
- /**
- * the file that will not be compressed.
- */
- static final String PASS_FILE_PFX = "pack.pass.file.";//$NON-NLS-1$
-
- /**
- * packer progress as a percentage.
- */
- static final String PROGRESS = "pack.progress";//$NON-NLS-1$
-
- /**
- * The number of bytes of each archive segment.
- */
- static final String SEGMENT_LIMIT = "pack.segment.limit";//$NON-NLS-1$
-
- /**
- * a String representation of {@code strip}.
- */
- static final String STRIP = "strip";//$NON-NLS-1$
-
- /**
- * a String representation of {@code true}.
- */
- static final String TRUE = "true";//$NON-NLS-1$
-
- /**
- * the action to take if an unknown attribute is encountered.
- */
- static final String UNKNOWN_ATTRIBUTE = "pack.unknown.attribute";//$NON-NLS-1$
-
- /**
- * Returns a sorted map of the properties of this packer.
- *
- * @return the properties of the packer.
- */
- SortedMap<String, String> properties();
-
- /**
- * Pack the specified JAR file to the specified output stream.
- *
- * @param in
- * JAR file to be compressed.
- * @param out
- * stream of compressed data.
- * @throws IOException
- * if I/O exception occurs.
- */
- void pack(JarFile in, OutputStream out) throws IOException;
-
- /**
- * Pack the data from the specified jar input stream to the specified
- * output stream.
- *
- * @param in
- * stream of uncompressed JAR data.
- * @param out
- * stream of compressed data.
- * @throws IOException
- * if I/O exception occurs.
- */
- void pack(JarInputStream in, OutputStream out) throws IOException;
-
- /**
- * add a listener for PropertyChange events
- *
- * @param listener
- * the listener to listen if PropertyChange events occurs
- */
- void addPropertyChangeListener(PropertyChangeListener listener);
-
- /**
- * remove a listener
- *
- * @param listener
- * listener to remove
- */
- void removePropertyChangeListener(PropertyChangeListener listener);
- }
-
- /**
- * The interface defining the API for converting a packed stream in the
- * Pack200 format to a JAR file.
- */
- public static interface Unpacker {
-
- /**
- * The String indicating if the unpacker should ignore all transmitted
- * values,can be replaced by either {@code true} or {@code false}.
- */
- static final String DEFLATE_HINT = "unpack.deflate.hint";//$NON-NLS-1$
-
- /**
- * a String representation of {@code false}.
- */
- static final String FALSE = "false";//$NON-NLS-1$
-
- /**
- * a String representation of {@code keep}.
- */
- static final String KEEP = "keep";//$NON-NLS-1$
-
- /**
- * the progress as a {@code percentage}.
- */
- static final String PROGRESS = "unpack.progress";//$NON-NLS-1$
-
- /**
- * a String representation of {@code true}.
- */
- static final String TRUE = "true";//$NON-NLS-1$
-
- /**
- * Returns a sorted map of the properties of this unpacker.
- *
- * @return the properties of unpacker.
- */
- SortedMap<String, String> properties();
-
- /**
- * Unpack the specified stream to the specified JAR output stream.
- *
- * @param in
- * stream to uncompressed.
- * @param out
- * JAR output stream of uncompressed data.
- * @throws IOException
- * if I/O exception occurs.
- */
- void unpack(InputStream in, JarOutputStream out) throws IOException;
-
- /**
- * Unpack the contents of the specified {@code File} to the specified
- * JAR output stream.
- *
- * @param in
- * file to be uncompressed.
- * @param out
- * JAR output stream of uncompressed data.
- * @throws IOException
- * if I/O exception occurs.
- */
- void unpack(File in, JarOutputStream out) throws IOException;
-
- /**
- * add a listener for {@code PropertyChange} events.
- *
- * @param listener
- * the listener to listen if {@code PropertyChange} events
- * occurs.
- */
- void addPropertyChangeListener(PropertyChangeListener listener);
-
- /**
- * remove a listener.
- *
- * @param listener
- * listener to remove.
- */
- void removePropertyChangeListener(PropertyChangeListener listener);
- }
-
-}
diff --git a/src/test/java/org/apache/commons/compress/compressors/pack200/Pack200FacadeTest.java b/src/test/java/org/apache/commons/compress/compressors/pack200/Pack200FacadeTest.java
new file mode 100644
index 0000000..a598b0e
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/compressors/pack200/Pack200FacadeTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.compress.compressors.pack200;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class Pack200FacadeTest {
+
+ @Test
+ public void loadsTheExpectedPacker() {
+ try {
+ Class.forName("java.util.jar.Pack200");
+ assertFalse(Pack200Facade.newPacker() instanceof HarmonyPack200.Pack200PackerAdapter);
+ } catch (ClassNotFoundException ex) {
+ assertTrue(Pack200Facade.newPacker() instanceof HarmonyPack200.Pack200PackerAdapter);
+ }
+ }
+
+ @Test
+ public void loadsTheExpectedUnpacker() {
+ try {
+ Class.forName("java.util.jar.Pack200");
+ assertFalse(Pack200Facade.newUnpacker() instanceof HarmonyPack200.Pack200UnpackerAdapter);
+ } catch (ClassNotFoundException ex) {
+ assertTrue(Pack200Facade.newUnpacker() instanceof HarmonyPack200.Pack200UnpackerAdapter);
+ }
+ }
+
+
+}