{"record":{"id":"43cf4ce49096036d","repo":"elastic/elasticsearch","slug":"failed-to-load-one-of-the-given-class-files","errorCode":null,"errorMessage":"Failed to load one of the given class files.","messagePattern":"Failed to load one of the given class files\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckForbiddenApisTask.java","lineNumber":536,"sourceCode":"                } catch (ParseException pe) {\n                    throw new InvalidUserDataException(\"Parsing signatures failed: \" + pe.getMessage(), pe);\n                }\n\n                if (checker.hasNoSignatures()) {\n                    if (checker.noSignaturesFilesParsed()) {\n                        throw new InvalidUserDataException(\n                            \"No signatures were added to task; use properties 'signatures', 'bundledSignatures', 'signaturesURLs', and/or 'signaturesFiles' to define those!\"\n                        );\n                    } else {\n                        logger.info(\"Skipping execution because no API signatures are available.\");\n                        return;\n                    }\n                }\n\n                try {\n                    checker.addClassesToCheck(getParameters().getClassFiles());\n                } catch (IOException ioe) {\n                    throw new GradleException(\"Failed to load one of the given class files.\", ioe);\n                }\n                checker.run();\n                writeMarker(getParameters().getSuccessMarker().getAsFile().get());\n            } catch (ForbiddenApiException e) {\n                throw new VerificationException(\"Forbidden API verification failed\", e);\n            } catch (Exception e) {\n                throw new RuntimeException(e);\n            } finally {\n                // Close the classloader to free resources:\n                try {\n                    if (urlLoader != null) urlLoader.close();\n                } catch (IOException ioe) {\n                    // getLogger().warn(\"Cannot close classloader: \".concat(ioe.toString()));\n                }\n            }\n        }\n\n        private void writeMarker(File successMarker) throws IOException {","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckForbiddenApisTask.java#L518-L554","documentation":"Thrown when checker.addClassesToCheck raises an IOException while loading the class files to be checked. The forbidden-apis checker could not read or parse the supplied class files (getClassFiles()), so it cannot scan them for forbidden API usage.","triggerScenarios":"A class file in getClassFiles() that is missing, unreadable, truncated, or not valid bytecode at the moment the checker loads it.","commonSituations":"Running the forbidden-apis task before compilation finished; stale build outputs referencing deleted classes; corrupted class files from an interrupted compile; file permission issues on the build output dir.","solutions":["Clean and recompile: ./gradlew clean compileJava (or the relevant compile task) before the forbidden-apis task.","Inspect the wrapped IOException for the failing class path.","Confirm the task's classFiles input is wired to the correct source set output directory.","Check permissions / disk space on the build directory."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm the class files input is non-empty and all files exist\nList<File> classes = getClassFiles();\nif (classes.isEmpty()) throw new InvalidUserDataException(\"No class files to check; did compilation run?\");\nfor (File c : classes) if (!c.isFile()) throw new InvalidUserDataException(\"Missing class file: \" + c);","typeGuard":null,"tryCatchPattern":"try {\n    checker.addClassesToCheck(getClassFiles());\n} catch (GradleException e) {\n    if (e.getCause() instanceof IOException) {\n        // clean & recompile, then re-run this task\n        throw new GradleException(\"Class files unreadable; run clean compileJava first\", e);\n    }\n    throw e;\n}","preventionTips":["Make sure compilation tasks are declared as dependencies of the forbidden-apis task.","Run a clean build when class-file errors appear out of nowhere.","Avoid deleting build outputs while a build is in progress."],"tags":["gradle","forbidden-apis","precommit","class-loading","io"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}