Preset dictionary in Java

  • Chad

    Chad - 2012-01-22

    First of all, thank you for this excellent library.

    I am trying to use XZ for Java 1.0 (from with a preset dictionary. The JRE is 1.6u30 When I use a preset dictionary, the program enters an infinite loop. I stepped through it in the debugger and found that the "while" loop in LZMA2OutputStream.writeEndMarker() never terminates, apparently because uncompressedSize in writeChunk() is always zero and therefore pendingSize never decreases.

    I do not know if I am making a mistake in calling the library or if this is a bug in the library.

    When I remove the line "opt.setPresetDict(oldBytes);" it works fine. Here is the code I am testing (disclaimer: I know it's messy; it's just for a quick test):

    package local;
    import org.tukaani.xz.*;
    public class Main {
        public static void main(String[] args) {
            try {
                RandomAccessFile raf = new RandomAccessFile("initDict", "r");
                byte[] oldBytes = new byte[(int)raf.length()];
                LZMA2Options opt = new LZMA2Options(7);
                FileOutputStream out = new FileOutputStream("output");
                FinishableWrapperOutputStream fout = new FinishableWrapperOutputStream(out);            
                FinishableOutputStream lzmaOut = opt.getOutputStream(fout);
                raf = new RandomAccessFile("input", "r");
                byte[] newBytes = new byte[(int)raf.length()];
            } catch (Exception e) {
  • Lasse Collin

    Lasse Collin - 2012-01-27

    Looks like a bug in the library. Thanks for the bug report. I don't immediately see what's wrong, but I try to fix it in a few days.

  • Lasse Collin

    Lasse Collin - 2012-01-28

    I have hopefully fixed it now. See today's commits in the git repository.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks