{"id":"36c7b74ebae27dcc","repo":"spring-projects/spring-boot","slug":"failed-to-get-dir-mode-from-copyspec","errorCode":null,"errorMessage":"Failed to get dir mode from CopySpec","messagePattern":"Failed to get dir mode from CopySpec","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java","lineNumber":158,"sourceCode":"\t\treturn (GradleVersion.current().compareTo(GradleVersion.version(\"8.3\")) >= 0)\n\t\t\t\t? asUnixNumeric(copySpec.getDirPermissions()) : getDirMode(copySpec);\n\t}\n\n\tprivate @Nullable Integer getUnixNumericFilePermissions(CopySpec copySpec) {\n\t\treturn (GradleVersion.current().compareTo(GradleVersion.version(\"8.3\")) >= 0)\n\t\t\t\t? asUnixNumeric(copySpec.getFilePermissions()) : getFileMode(copySpec);\n\t}\n\n\tprivate @Nullable Integer asUnixNumeric(Property<ConfigurableFilePermissions> permissions) {\n\t\treturn permissions.isPresent() ? permissions.get().toUnixNumeric() : null;\n\t}\n\n\tprivate @Nullable Integer getDirMode(CopySpec copySpec) {\n\t\ttry {\n\t\t\treturn (Integer) copySpec.getClass().getMethod(\"getDirMode\").invoke(copySpec);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new RuntimeException(\"Failed to get dir mode from CopySpec\", ex);\n\t\t}\n\t}\n\n\tprivate @Nullable Integer getFileMode(CopySpec copySpec) {\n\t\ttry {\n\t\t\treturn (Integer) copySpec.getClass().getMethod(\"getFileMode\").invoke(copySpec);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new RuntimeException(\"Failed to get file mode from CopySpec\", ex);\n\t\t}\n\t}\n\n\tprivate boolean isUsingDefaultLoader(Jar jar) {\n\t\treturn DEFAULT_LAUNCHER_CLASSES.contains(jar.getManifest().getAttributes().get(\"Main-Class\"));\n\t}\n\n\tvoid requiresUnpack(String... patterns) {\n\t\tthis.requiresUnpack.include(patterns);","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java#L140-L176","documentation":"Thrown by BootArchiveSupport.getDirMode() when reflective invocation of CopySpec.getDirMode() fails. This reflection path is only used on Gradle < 8.3 (the dirPermissions API is used on 8.3+). Since the plugin requires Gradle 8.14+, this code path is unreachable in supported setups; encountering it means an unsupported Gradle or a non-standard CopySpec during bootJar/bootWar archive creation.","triggerScenarios":"getUnixNumericDirPermissions() routes to getDirMode() only when GradleVersion.current() < 8.3; the reflective getMethod(\"getDirMode\").invoke(copySpec) throws, wrapped as RuntimeException at line 158.","commonSituations":"Running an unsupported old Gradle; a custom CopySpec injected into the boot archive that lacks getDirMode; JVM module restrictions blocking reflection on Gradle internals.","solutions":["Upgrade Gradle to 8.14 or later so getDirPermissions().toUnixNumeric() is used instead.","Verify GradleVersion.current() is not being spoofed by a malformed gradle-runtime.","Ensure any custom CopySpec passed into bootJar/bootWar is a standard Gradle implementation."],"exampleFix":"// gradle/wrapper/gradle-wrapper.properties\n// before:\n//   distributionUrl=...gradle-8.2-bin.zip\n// after:\n//   distributionUrl=...gradle-8.14-bin.zip\n","handlingStrategy":"validation","validationCode":"import org.gradle.util.GradleVersion\nrequire(GradleVersion.current() >= GradleVersion.version(\"8.3\")) {\n    \"Boot archive file/dir mode requires Gradle 8.3+ (use 8.14+)\"\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run Gradle 8.14+ to use the modern dirPermissions API.","Avoid injecting non-standard CopySpec instances into bootJar/bootWar."],"tags":["gradle","version-compat","reflection","file-permissions","boot-archive"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}