Konloch/bytecode-viewer · error · Exception

Unable to resolve type.

Error message

Unable to resolve type.

What it means

ProcyonDecompiler.decompileToZip throws this per entry while bulk-decompiling: metadataSystem.lookupType(internalName) returned null or the returned TypeReference could not be resolved to a TypeDefinition. It means one .class entry in the input jar could not be loaded by Procyon's metadata system, so it is skipped-with-exception instead of decompiled.

Source

Thrown at src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java:175

                {
                    JarEntry entry = ent.nextElement();

                    if (entry.getName().endsWith(".class"))
                    {
                        JarEntry etn = new JarEntry(entry.getName().replace(".class", ".java"));

                        if (history.add(etn))
                        {
                            zip.putNextEntry(etn);

                            try
                            {
                                String internalName = StringUtilities.removeRight(entry.getName(), ".class");
                                TypeReference type = metadataSystem.lookupType(internalName);
                                TypeDefinition resolvedType;

                                if ((type == null) || ((resolvedType = type.resolve()) == null))
                                    throw new Exception("Unable to resolve type.");

                                Writer writer = new OutputStreamWriter(zip);
                                settings.getLanguage().decompileType(resolvedType, new PlainTextOutput(writer), decompilationOptions);
                                writer.flush();
                            }
                            finally
                            {
                                zip.closeEntry();
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            JarEntry etn = new JarEntry(entry.getName());

                            if (history.add(etn))

View on GitHub (pinned to 31430e0033)

Solutions

  1. Skip-and-continue per entry on this exception so the rest of the jar decompiles.
  2. Validate each entry (magic/version) before decompiling and report failures in a summary.
  3. Upgrade the decompiler/backend to a Procyon version supporting the jar's class-file versions.
  4. Check entry-name handling (removeRight ".class", package path) matches lookupType's expected internal name.

Example fix

// before
if ((type == null) || ((resolvedType = type.resolve()) == null))
    throw new Exception("Unable to resolve type.");
// after
if ((type == null) || ((resolvedType = type.resolve()) == null)) {
    log.warn("Skipping unresolvable class: " + entry.getName());
    continue;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// inside the per-entry loop, before decompiling
byte[] data = readEntry(entry);
boolean looksLikeClass = data != null && data.length > 8 && data[0]==(byte)0xCA && data[1]==(byte)0xFE && data[2]==(byte)0xBA && data[3]==(byte)0xBE;
if (!looksLikeClass) { log.warn("skip non-class entry " + entry.getName()); continue; }

Try / catch

try {
    decompileEntry(entry, zip);
} catch (Exception e) {
    if (e.getMessage() != null && e.getMessage().contains("Unable to resolve type")) {
        failures.add(entry.getName()); // skip-and-continue, report at end
    } else throw e;
}

Prevention

When it happens

Trigger: Iterating a jar/zip whose entries include malformed or unsupported class files; internalName derivation from entry name mismatching what lookupType expects; multi-release jars or classes referencing missing outer/inner types; entries not actually .class content despite the extension.

Common situations: Decompiling dependency jars with intentionally broken or anti-decompiler entries; shaded jars with corrupt duplicates; jars built for class-file versions newer than the decompiler supports; obfuscated jars (ProGuard/Allatori) with inconsistent name references.

Related errors


AI-assisted analysis of Konloch/bytecode-viewer@31430e0033 (2026-09-05). Data as JSON: /api/errors/86aa5a8e17904b92. Report an issue: GitHub.