Skip to content

Qute: regression in template extension method with byte array #31077

@FroMage

Description

@FroMage

Describe the bug

During the bump from 2.16.0 to 2.16.1, the following template extension method stopped working:

@TemplateExtension
public class JavaExtensions {

    public static String mimeType(byte[] bytes) {
        if (bytes == null || bytes.length == 0) {
            return null;
        }
        return FileUtils.getMimeType("", bytes);
    }

}

It now generates this at build time:

Caused by: java.lang.NullPointerException: Cannot invoke "org.jboss.jandex.ClassInfo.isInterface()" because "classInfo" is null
	at io.quarkus.qute.deployment.Types$AssignableInfo.from(Types.java:146)
	at io.quarkus.qute.deployment.Types.isAssignableFrom(Types.java:194)
	at io.quarkus.qute.deployment.Types.isAssignableFrom(Types.java:140)
	at io.quarkus.qute.deployment.QuteProcessor.findTemplateExtensionMethod(QuteProcessor.java:2377)
	at io.quarkus.qute.deployment.QuteProcessor.validateNestedExpressions(QuteProcessor.java:1246)
	at io.quarkus.qute.deployment.QuteProcessor.validateExpressions(QuteProcessor.java:860)

Due to looking up the class for [B in Types.java, where className1 is [B and className2 is java.lang.String

    static boolean isAssignableFrom(DotName className1, DotName className2, IndexView index,
            Map<DotName, AssignableInfo> assignableCache) {
        // java.lang.Object is assignable from any type
        if (className1.equals(DotNames.OBJECT)) {
            return true;
        }
        // type1 is the same as type2
        if (className1.equals(className2)) {
            return true;
        }
        ClassInfo class1 = index.getClassByName(className1);
        AssignableInfo assignableInfo = assignableCache.get(className1);
        if (assignableInfo == null) {
            // No cached info
            assignableInfo = AssignableInfo.from(class1, index);
            assignableCache.put(className1, assignableInfo);
            return assignableInfo.isAssignableFrom(className2);
        } else {
            if (assignableInfo.isAssignableFrom(className2)) {
                return true;
            }
            // Cached info does not match - try to update the assignable info (a computing index is used)
            assignableInfo = AssignableInfo.from(class1, index);
            if (assignableInfo.isAssignableFrom(className2)) {
                // Update the cache
                assignableCache.put(className1, assignableInfo);
                return true;
            }
        }
        return false;
    }

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Metadata

Metadata

Assignees

Labels

area/quteThe template enginekind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions