Andi Vajda <va...@apache.org> wrote:

> It may be simplest if you can send me the source file for this class
> as well as a small jar file I can use to reproduce this ?

Turns out to be simple to reproduce.  Put the attached in a file called
test.java, and run this sequence:

% javac -classpath . test.java
% jar cf test.jar *.class
% python -m jcc.__main__ --python test --shared --jar /tmp/test.jar --build 
--vmarg -Djava.awt.headless=true

Bill

import java.util.*;
import java.io.*;

public class test implements Iterable<File> {
    File m_file;
    FileFilter m_filter;
    public test(final File file) {
        this(file, null, true);
    }
        
    public test (final File file, final FileFilter filter, boolean filterDirectories) {
        m_file = file;
        if (filterDirectories || filter==null) {
            m_filter = filter;
        } else {
            m_filter = new FileFilter() {
                    public boolean accept(File f) { return f.isDirectory() || filter.accept(f); } 
                };
        }
    }
        
    public Iterator<File> iterator() {
        if (m_file.isDirectory())
            return new Iterator<File>() {
                public boolean hasNext() { return false; }
                public File next() {
                    return new File("foo");
                }
                public void remove() { throw new UnsupportedOperationException(); }
            };
        if (m_file.isFile() && m_filter.accept(m_file)) {
            return new Iterator<File>() {
                boolean hasNext = true;
                public boolean hasNext() { return hasNext; }
                public File next() {
                    if (!hasNext) throw new NoSuchElementException();
                    hasNext = false;
                    return m_file;
                }
                public void remove() { throw new UnsupportedOperationException(); }
            };
        }
        return new Iterator<File>() {
            public boolean hasNext() { return false; }
            public File next() { throw new NoSuchElementException(); }
            public void remove() { throw new UnsupportedOperationException(); }
        };            
    }
}

Reply via email to