fix(module): log APIScanner class-not-found at info, not warn+stacktrace - #167
fix(module): log APIScanner class-not-found at info, not warn+stacktrace#167soloturn wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesAPI scanner logging
Estimated code review effort: 1 (Trivial) | ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
5281d64 to
32fec58
Compare
This seems more like the issue, rather than the warning itself. Destination Sol gets a lot of these warnings at runtime as well. If I understand correctly, is this effectively prohibiting any modules outside of the engine classpath from being exported to other modules as APIs? |
@BenjaminAmos good question - I traced it through ClassLoader parentLoader = ObtainClassloader(clazz);
if (parentLoader != this && !(parentLoader instanceof ModuleClassLoader)) {
if (permissionProvider.isPermitted(clazz)) {
return clazz;
} else {
logger.error("Denied access...");
return null;
}
}
return clazz; // module-to-module access: no check at allThe permission check only fires when the resolved class's own loader is neither this module's classloader nor any other What the warning storm actually is: Filed the underlying fix separately since |
For anyone wondering whether this PR is now redundant with MovingBlocks/Terasology#5353: it isn't, and we're keeping both. #5353 fixes the one known call site ( This PR fixes So this is defense-in-depth, not overlap: even after #5353 lands, any remaining |
APIScanner.scan() iterates every module's class index during ModuleManager.setupSandbox(), which runs before modules are loaded onto forClassLoader - so most non-engine modules' API classes are expected to be unresolvable there, not an error. WARN + full stack trace on every one of these floods the log at startup. Downgrade to a one-line INFO stating which classloader was checked. Co-Authored-By: soloturn <soloturn@gmail.com>
32fec58 to
4db97e0
Compare
setupSandbox() scanned every registered module's class index against the system classloader, including modules loaded from the application path - whose classes are only ever reachable through their own ModuleClassLoader, never the system classloader. That scan was guaranteed to fail for those modules, and pointless even when it succeeded: JavaModuleClassLoader#loadClass only consults this permission set for classes loaded by a non-module classloader, so module-to-module API access was never gated by it anyway. Restrict the scan to the engine module and any dev-mode classpath modules - the only ones whose classes are actually resolvable via the system classloader setupSandbox() uses. See MovingBlocks/gestalt#167, which downgrades the resulting ClassNotFoundException logging but doesn't address the underlying scan.
Per BenjaminAmos's review on PR #167: the "expected if it belongs to a module's own classloader instead" clause assumed a specific cause for the miss that isn't always true - forClassLoader/classIndex are caller-supplied, so a mismatch can come from other call sites too. Keep the class and classloader detail, drop the assumption. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQriAKnoCEqcmFoSAvU39Q
Summary
APIScanner.scan()logged a full stack trace at WARN for every module classit couldn't resolve on the given classloader. This fires routinely — the
engine's
setupSandbox()scans every registered module's class indexbefore that module's classes are loaded onto the classloader, so most
non-engine modules trip it on every startup. Downgraded to a one-line INFO
naming the class and the classloader checked.
Test plan
Terasology Latest.appand confirm startup no longer logsClassNotFoundExceptionstack traces fromAPIScanner, just INFO linesRelated