Tencent/tinker · error · NullPointerException

name == null

Error message

name == null

What it means

TinkerZipEntry's name constructor requires a non-null name; passing null throws NullPointerException("name == null") immediately (name validation for length happens next, in validateStringLength). TinkerZipEntry is this library's self-contained clone of java.util.zip.ZipEntry, so it keeps the same fail-fast contract as the platform class.

Source

Thrown at third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/TinkerZipEntry.java:84

        this.compressedSize = compressedSize;
        this.size = size;
        this.compressionMethod = compressionMethod;
        this.time = time;
        this.modDate = modDate;
        this.extra = extra;
        this.localHeaderRelOffset = localHeaderRelOffset;
        this.dataOffset = dataOffset;
    }
    /**
     * Constructs a new {@code ZipEntry} with the specified name. The name is actually a path,
     * and may contain {@code /} characters.
     *
     * @throws IllegalArgumentException
     *             if the name length is outside the range (> 0xFFFF).
     */
    public TinkerZipEntry(String name) {
        if (name == null) {
            throw new NullPointerException("name == null");
        }
        validateStringLength("Name", name);
        this.name = name;
    }
    /**
     * Constructs a new {@code ZipEntry} using the values obtained from {@code
     * ze}.
     *
     * @param ze
     *            the {@code ZipEntry} from which to obtain values.
     */
    public TinkerZipEntry(TinkerZipEntry ze) {
        name = ze.name;
        comment = ze.comment;
        time = ze.time;
        size = ze.size;
        compressedSize = ze.compressedSize;
        crc = ze.crc;

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Null-check (or Objects.requireNonNull) the name at the point of construction with a descriptive message naming the source of the value.
  2. Fix the upstream lookup so missing names surface as an explicit error (key not found) rather than silently becoming null.
  3. Default to a computed fallback name (e.g. "entry-" + index) only if an anonymous entry is genuinely intended.

Example fix

// before: map lookup may return null
entryList.add(new TinkerZipEntry(nameById.get(id))); // NPE: name == null

// after: fail fast with context
String name = nameById.get(id);
if (name == null) throw new IllegalArgumentException("no entry name for id " + id);
entryList.add(new TinkerZipEntry(name));
Defensive patterns

Strategy: validation

Validate before calling

String name = source != null ? source.getName() : null;
java.util.Objects.requireNonNull(name, "entry name source produced null");
new TinkerZipEntry(name);

Prevention

When it happens

Trigger: Constructing new TinkerZipEntry(name) where name came from a null-producing source: a map lookup miss, a path join returning null, or splitting an entry name on a separator that produced an empty/null segment.

Common situations: Repackaging loops keyed by string maps where absent keys yield null; code ported from java.util.zip that assumed a different null policy; test fixtures creating entries from uninitialized fields.

Related errors


AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14). Data as JSON: /api/errors/1f774525d1d819fd. Report an issue: GitHub.