{"record":{"id":"704fbe6fec56c148","repo":"juicedata/juicefs","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"sdk/java/libjfs/callback.c","lineNumber":42,"sourceCode":"\nstatic void (*log_callback)(const char *msg);\n\ntypedef void LogCallBack(const char *msg);\n\nvoid jfs_set_logger(void*p);\n\nEXPORT void jfs_set_callback(LogCallBack *callback)\n{\n    log_callback = callback;\n    jfs_set_logger(callback);\n}\n\nEXPORT void jfs_callback(const char *msg)\n{\n    if (log_callback != NULL) {\n        (*log_callback)(msg);\n    } else {\n        fprintf(stderr, \"%s\", msg);\n    }\n}\n","sourceCodeStart":24,"sourceCodeEnd":45,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/libjfs/callback.c#L24-L45","documentation":"jfs_callback is the C entry point the JuiceFS JNI layer uses to deliver log/error messages to the JVM. The message '%s' is not a template error itself; the C code prints whatever message string the Go/JNI side passed via fprintf(stderr, \"%s\", msg) (or forwards it to a registered Java callback). Seeing raw text here means a lower-level message reached stderr through this pass-through channel.","triggerScenarios":"Any Go-side log/panic message routed through the JNI log hook while no Java log_callback is registered (it goes straight to stderr), or with one registered (it is forwarded to the callback).","commonSituations":"Java clients embedding JuiceFS via sdk/java see native stderr output because the logging callback was never installed; low-level mount/init messages appear on the console instead of the application's log framework.","solutions":["Register a log callback (the JNI log_callback / corresponding Java-side hook) so messages go to your logger instead of raw stderr","Inspect the printed message itself for the actual underlying problem (init failure, missing libjfs, metadata errors)","Check that libjfs loaded correctly and the JuiceFS URI/mount settings are valid"],"exampleFix":"// before\n// no callback; messages appear as raw fprintf(stderr) text\n// after\n// install the log callback so jfs_callback forwards to your logger\nlib.jfs_init(...); /* plus register log_callback before use */","handlingStrategy":"try-catch","validationCode":"/* ensure libjfs is loadable before use: */ System.loadLibrary(\"jfs\");","typeGuard":null,"tryCatchPattern":"try {\n  // JNI-backed operations\n} catch (UnsatisfiedLinkError | IOException e) {\n  LOG.error(\"JuiceFS native message: {}\", e.getMessage());\n}","preventionTips":["Register a log callback at startup so native messages route to your logger","Keep libjfs versions matched with the juicefs.jar","Watch stderr for unregistered-callback output during integration tests"],"tags":["jni","native","logging"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}