{"record":{"id":"481df3219fd92d26","repo":"apache/maven","slug":"not-allowed-to-set-injectable-field","errorCode":null,"errorMessage":"Not allowed to set injectable field {}","messagePattern":"Not allowed to set injectable field (.+?)","errorType":"exception","errorClass":"DIException","httpStatus":null,"severity":"error","filePath":"impl/maven-di/src/main/java/org/apache/maven/di/impl/ReflectionUtils.java","lineNumber":239,"sourceCode":"                .collect(toList());\n        return BindingInitializer.combine(initializers);\n    }\n\n    public static <T> BindingInitializer<T> fieldInjector(Key<T> container, Field field) {\n        field.setAccessible(true);\n        Key<Object> key = keyOf(container.getType(), field.getGenericType(), field);\n        boolean optional = field.isAnnotationPresent(Nullable.class);\n        Dependency<Object> dep = new Dependency<>(key, optional);\n        return new BindingInitializer<T>(Collections.singleton(dep)) {\n            @Override\n            public Consumer<T> compile(Function<Dependency<?>, Supplier<?>> compiler) {\n                Supplier<?> binding = compiler.apply(dep);\n                return (T instance) -> {\n                    Object arg = binding.get();\n                    try {\n                        field.set(instance, arg);\n                    } catch (IllegalAccessException e) {\n                        throw new DIException(\"Not allowed to set injectable field \" + field, e);\n                    }\n                };\n            }\n        };\n    }\n\n    public static <T> BindingInitializer<T> methodInjector(Key<T> container, Method method) {\n        method.setAccessible(true);\n        Dependency<?>[] dependencies = toDependencies(container.getType(), method);\n        return new BindingInitializer<T>(new HashSet<>(Arrays.asList(dependencies))) {\n            @Override\n            public Consumer<T> compile(Function<Dependency<?>, Supplier<?>> compiler) {\n                return instance -> {\n                    Object[] args = getDependencies().stream()\n                            .map(compiler)\n                            .map(Supplier::get)\n                            .toArray();\n                    try {","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-di/src/main/java/org/apache/maven/di/impl/ReflectionUtils.java#L221-L257","documentation":"Error \"Not allowed to set injectable field {}\" thrown in apache/maven.","triggerScenarios":"Thrown at impl/maven-di/src/main/java/org/apache/maven/di/impl/ReflectionUtils.java:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}