Class ModuleScanDiagnostics

java.lang.Object
com.ultikits.ultitools.utils.ModuleScanDiagnostics

@Internal public final class ModuleScanDiagnostics extends Object
Turns a silently-skipped class from a module or external plugin startup scan into a single, named, loud line an operator actually reads (D-19).

ComponentScanner and PluginManager both catch ClassNotFoundException | LinkageError per class during a module's scan and skip-and-continue — the module still loads, every other command still registers, and the one stale command silently does not exist. This class does not change that shape; it only makes it loud. Its API is deliberately small: recordSkippedClass(String, String, Throwable) accumulates one skipped class for the owner currently being scanned, and emitSummary(String) — called once, after that owner's scan loop finishes — turns the accumulated list into exactly ONE Level.SEVERE record naming the owner and every skipped class, with a migration guide link for framework mismatches. A scan that skips nothing produces no output from this class.

Never routes through the root logger. DIAGNOSTICS_LOGGER disables parent handlers, exactly as RemoteActionLog does and for the same measured reason: SystemLogHandler attaches only to the root (empty-name) logger and auto-reports any Level.SEVERE record carrying a Throwable into ErrorReportCollector — which would turn this per-module summary into an error report and risk the circular logging both classes' javadoc already warns about. The summary emitted by emitSummary(String) deliberately carries no Throwable for the same reason: it names each cause's type and message as text, and the stack traces live only on the per-class Level.FINE detail recorded by recordSkippedClass(String, String, Throwable). Disabling parent handlers also disconnects this logger from the console/logs/latest.log sink the server installs on the root logger, so a PluginLoggerBridge forwards the records to the plugin's own logger (#557) -- the summary then reaches the console at its real level and in the server's normal log format. (A private console handler used here before wrote to the standard error stream, which Paper prints as two WARN lines per record.)

Since:
6.3.0
  • Field Details

    • DIAGNOSTICS_LOGGER

      private static final Logger DIAGNOSTICS_LOGGER
    • OLDER_API_CAUSE

      public static final String OLDER_API_CAUSE
      The cause phrase shared by this class's scan summary and PluginManager's refusal of a module whose declared main class fails to link against this framework, so an operator reads one wording for one cause.
      See Also:
    • COMPATIBILITY_POINTER

      public static final String COMPATIBILITY_POINTER
      The pointer to the compatibility record that follows OLDER_API_CAUSE in both places.
      See Also:
    • SKIPPED_CLASSES_BY_SCAN

      private static final Map<String, List<String>> SKIPPED_CLASSES_BY_SCAN
      One accumulator entry per scan; cleared as each is emitted.
  • Constructor Details

    • ModuleScanDiagnostics

      private ModuleScanDiagnostics()
  • Method Details

    • recordSkippedClass

      public static void recordSkippedClass(String scanKey, String className, Throwable cause)
      Records one class that failed to load or initialize during the owner's scan, and immediately logs the per-class detail at Level.FINE with cause attached — matching the shape the GEN-07 audit evaluator (D-14) also uses, so the two diagnostics read as one pattern.

      A null or blank scanKey or className is ignored entirely — neither the accumulator nor the FINE detail record it — rather than producing a summary entry reading the literal text "null".

      Parameters:
      scanKey - the module name or base package; external entity scans prefix the plugin name or JAR basename with NUL to keep a separate accumulator without altering the log label
      className - the class that failed to load or initialize
      cause - the exception the scan caught; may be null
    • emitSummary

      public static void emitSummary(String scanKey)
      Emits ONE Level.SEVERE summary for the scan only if at least one class was recorded since the last call, then resets the accumulator so a subsequent clean scan never repeats it.
      Parameters:
      scanKey - the key passed to recordSkippedClass(String, String, Throwable)
    • scanOwnerLabel

      private static String scanOwnerLabel(String scanKey)
    • describeFailure

      private static String describeFailure(String className, Throwable cause)
    • inlineCause

      private static String inlineCause(Throwable cause)
      The per-class detail is logged at Level.FINE, which a default console hides, so the summary names the caught failure itself rather than pointing at a line the operator cannot see.
    • isServerClass

      private static boolean isServerClass(String name)
    • isBlank

      private static boolean isBlank(String value)