{"record":{"id":"760d0dfe99bfe755","repo":"NationalSecurityAgency/ghidra","slug":"cannot-apply-to-both-parameters-of","errorCode":null,"errorMessage":"Cannot apply {} to both parameters of {}","messagePattern":"Cannot apply (.+?) to both parameters of (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/framework/options/AutoOptionsListener.java","lineNumber":135,"sourceCode":"\n\t\t\tmethod.setAccessible(true);\n\n\t\t\tParameter[] parameters = method.getParameters();\n\t\t\tif (parameters.length == 0) {\n\t\t\t\tthis.order = ParamOrder.NONE;\n\t\t\t}\n\t\t\telse if (parameters.length == 1) {\n\t\t\t\tif (parameters[0].getAnnotation(OldValue.class) != null) {\n\t\t\t\t\tthis.order = ParamOrder.OLD_ONLY;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.order = ParamOrder.NEW_ONLY;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (parameters.length == 2) {\n\t\t\t\tif (parameters[0].getAnnotation(NewValue.class) != null) {\n\t\t\t\t\tif (parameters[1].getAnnotation(NewValue.class) != null) {\n\t\t\t\t\t\tthrow new IllegalArgumentException(\"Cannot apply \" +\n\t\t\t\t\t\t\tNewValue.class.getName() + \" to both parameters of \" + method);\n\t\t\t\t\t}\n\t\t\t\t\tthis.order = ParamOrder.NEW_OLD;\n\t\t\t\t}\n\t\t\t\telse if (parameters[0].getAnnotation(OldValue.class) != null) {\n\t\t\t\t\tif (parameters[1].getAnnotation(OldValue.class) != null) {\n\t\t\t\t\t\tthrow new IllegalArgumentException(\"Cannot apply \" +\n\t\t\t\t\t\t\tOldValue.class.getName() + \" to both parameters of \" + method);\n\t\t\t\t\t}\n\t\t\t\t\tthis.order = ParamOrder.OLD_NEW;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (parameters[1].getAnnotation(NewValue.class) != null) {\n\t\t\t\t\t\tthis.order = ParamOrder.OLD_NEW;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.order = ParamOrder.NEW_OLD;\n\t\t\t\t\t}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/framework/options/AutoOptionsListener.java#L117-L153","documentation":"Thrown by AutoOptionsListener.MethodOptionSetter when a two-parameter @AutoOptionConsumed method annotates BOTH parameters with @NewValue. The framework maps old/new values to parameters by annotation position; applying @NewValue to both leaves no slot for the old value and is ambiguous, so it is rejected. The message names the annotation class and method.","triggerScenarios":"Annotating a method like void changed(@NewValue String a, @NewValue String b) — both params marked as the new value. Copy-paste annotation errors where both parameters receive the same annotation.","commonSituations":"Misunderstanding the @NewValue/@OldValue parameter-mapping contract; editing a method signature and re-annotating both params identically; IDE auto-annotation applying to all params.","solutions":["Annotate at most one parameter with @NewValue; mark the other with @OldValue or leave it unannotated.","Use a single-parameter method if only the new value is needed.","Review the two-parameter contract: one slot is the new value, the other the old value."],"exampleFix":"// before\n@AutoOptionConsumed(\"my.opt\")\nvoid onChange(@NewValue int a, @NewValue int b) { ... } // both @NewValue\n\n// after\n@AutoOptionConsumed(\"my.opt\")\nvoid onChange(@OldValue int oldVal, @NewValue int newVal) { ... }","handlingStrategy":"validation","validationCode":"long newCount = Arrays.stream(method.getParameters())\n    .filter(p -> p.getAnnotation(NewValue.class) != null).count();\nif (newCount > 1) {\n  throw new IllegalStateException(\"Only one @NewValue per method: \" + method);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Annotate at most one parameter with @NewValue.","Review annotations when editing method signatures.","Add a wiring unit test that constructs the AutoOptionsListener for the plugin."],"tags":["ghidra","options","annotation","parameter-mapping"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}