{"id":"176a62bc970b5573","repo":"junit-team/junit5","slug":"failed-to-read-contents-of-reference","errorCode":null,"errorMessage":"Failed to read contents of ${reference}.","messagePattern":"Failed to read contents of (.+?)\\.","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-platform-commons/src/main/java/org/junit/platform/commons/util/ModuleUtils.java","lineNumber":269,"sourceCode":"\t\t * Scan module reference for classes that potentially contain testable methods.\n\t\t */\n\t\tList<Class<?>> scan(ModuleReference reference) {\n\t\t\ttry (ModuleReader reader = reference.open()) {\n\t\t\t\ttry (Stream<String> names = reader.list()) {\n\t\t\t\t\t// @formatter:off\n\t\t\t\t\treturn names.filter(name -> !name.endsWith(\"/\")) // remove directories\n\t\t\t\t\t\t\t.map(Path::of)\n\t\t\t\t\t\t\t.filter(SearchPathUtils::isClassOrSourceFile)\n\t\t\t\t\t\t\t.map(SearchPathUtils::determineFullyQualifiedClassName)\n\t\t\t\t\t\t\t.filter(classFilter::match)\n\t\t\t\t\t\t\t.<Class<?>> map(this::loadClassUnchecked)\n\t\t\t\t\t\t\t.filter(classFilter::match)\n\t\t\t\t\t\t\t.toList();\n\t\t\t\t\t// @formatter:on\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {\n\t\t\t\tthrow new JUnitException(\"Failed to read contents of \" + reference + \".\", e);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Load class by its binary name.\n\t\t *\n\t\t * @see ClassLoader#loadClass(String)\n\t\t */\n\t\tprivate Class<?> loadClassUnchecked(String binaryName) {\n\t\t\ttry {\n\t\t\t\treturn classLoader.loadClass(binaryName);\n\t\t\t}\n\t\t\tcatch (ClassNotFoundException e) {\n\t\t\t\tthrow new JUnitException(\"Failed to load class with name '\" + binaryName + \"'.\", e);\n\t\t\t}\n\t\t}\n\n\t}","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ModuleUtils.java#L251-L287","documentation":"Error \"Failed to read contents of ${reference}.\" thrown in junit-team/junit5.","triggerScenarios":"Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/util/ModuleUtils.java:269 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}