Skip to content

[Bug] FindClass supports more than standard states #810

@hextriclosan

Description

@hextriclosan

Java program that reproduces it

package samples.javacore.loadlibrary.example;

public class JniClassOperationsDemo {
    static {
        System.loadLibrary("jni_test_lib");
    }

    private static native Class<?> findClass(String className);

    public static void main(String[] args) {
        test("dot notation", "java.lang.String"); // fixme: should not pass
        test("primitive I", "I"); // fixme: should not pass
        test("primitive J", "J"); // fixme: should not pass
        test("primitive V", "V"); // fixme: should not pass
    }

    private static void test(String label, String className) {
        try {
            Class<?> clazz = findClass(className);
            System.out.printf("[OK] %s -> %s%n", label, clazz);
        } catch (Throwable t) {
            System.out.printf("[FAIL] %s -> %s%n", label, t);
        }
    }
}

Steps to reproduce

Run: cargo run -- package samples.javacore.loadlibrary.example.JniClassOperationsDemo

Expected behaviour

Should throw java.lang.NoClassDefFoundError

Actual behaviour

Creates corresponding Class<?>

Environment

Field Value
OS Ubuntu 24.04 x86_64 / macOS 14 arm64 / Windows 11
Rust version rustc 1.95.0 (59807616e 2026-04-14)
JDK version 25

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions