pxb1988/dex2jar · error · NullPointerException

entryName == null

Error message

entryName == null

What it means

A standard argument guard in findFirstEntry: the caller passed a null entryName, which cannot match any zip entry, so a NullPointerException with the message 'entryName == null' is thrown immediately. The faulting input is the entryName argument itself; the zip file state is irrelevant.

Solutions

  1. Pass a non-null entry name; check for null before the call
  2. Return early with a default entry or empty result when the name is absent
  3. Use Map-style lookup with containsKey if the API is extended

Example fix

// before
ZipEntry e = zip.findFirstEntry(name); // NPE if name is null
// after
ZipEntry e = name == null ? null : zip.findFirstEntry(name);
Defensive patterns

Strategy: type-guard

Validate before calling

if (entryName == null) return null; // skip lookup

Type guard

ZipEntry safeFind(ZipFile z, String n) { return (n == null) ? null : z.findFirstEntry(n); }

Try / catch

try { return zip.findFirstEntry(name); } catch (NullPointerException e) { return null; } // only as last resort

Prevention

When it happens

Trigger: Calling zipFile.findFirstEntry(null), typically when a variable holding the entry name was never assigned or a lookup result was passed through unchecked.

Common situations: Programmatic dex/zip tooling where entry names come from user input or config that is missing; reflection-driven extraction of resources.

Related errors


AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08). Data as JSON: /api/errors/0a6fe486728cc746. Report an issue: GitHub.

Appendix: source

Thrown at dex-reader/src/main/java/com/googlecode/d2j/util/zip/ZipFile.java:107

    public List<? extends ZipEntry> entries() {
        return entries;
    }

    /**
     * Returns this file's comment, or null if it doesn't have one. See {@link java.util.zip.ZipOutputStream#setComment}
     * .
     * 
     * @throws IllegalStateException
     *             if this zip file has been closed.
     * @since 1.7
     */
    public String getComment() {
        return comment;
    }

    public ZipEntry findFirstEntry(String entryName) {
        if (entryName == null) {
            throw new NullPointerException("entryName == null");
        }

        ZipEntry ze = findFirstEntry0(entryName);
        if (ze == null) {
            ze = findFirstEntry0(entryName + "/");
        }
        return ze;
    }

    private ZipEntry findFirstEntry0(String entryName) {
        for (ZipEntry e : entries) {
            if (e.getName().equals(entryName)) {
                return e;
            }
        }
        return null;
    }

View on GitHub (pinned to b5bda4fb49)