{"record":{"id":"07779fe622e8710d","repo":"java-native-access/jna","slug":"property-accessor-name-must-start-with-get-or-set-the","errorCode":null,"errorMessage":"Property Accessor name must start with 'get', or set the anotation 'name' value","messagePattern":"Property Accessor name must start with 'get', or set the anotation 'name' value","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java","lineNumber":531,"sourceCode":"\n    private IID getIID(ComInterface annotation) {\n        String iidStr = annotation.iid();\n        if (null != iidStr && !iidStr.isEmpty()) {\n            return new IID(iidStr);\n        } else {\n            throw new COMException(\"ComInterface must define a value for iid\");\n        }\n    }\n\n    // --------------------- ProxyObject ---------------------\n\n    private String getAccessorName(java.lang.reflect.Method method, ComProperty prop) {\n        if (prop.name().isEmpty()) {\n            String methName = method.getName();\n            if (methName.startsWith(\"get\")) {\n                return methName.replaceFirst(\"get\", \"\");\n            } else {\n                throw new RuntimeException(\n                        \"Property Accessor name must start with 'get', or set the anotation 'name' value\");\n            }\n        } else {\n            return prop.name();\n        }\n    }\n\n    private String getMutatorName(java.lang.reflect.Method method, ComProperty prop) {\n        if (prop.name().isEmpty()) {\n            String methName = method.getName();\n            if (methName.startsWith(\"set\")) {\n                return methName.replaceFirst(\"set\", \"\");\n            } else {\n                throw new RuntimeException(\n                        \"Property Mutator name must start with 'set', or set the anotation 'name' value\");\n            }\n        } else {\n            return prop.name();","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java#L513-L549","documentation":"This RuntimeException is thrown by ProxyObject.getAccessorName when a COM interface method annotated with @ComProperty is used as a property accessor but the annotation's 'name' attribute is empty and the Java method name does not start with 'get'. JNA derives the underlying COM property DISPID name from the method name by stripping the 'get' prefix, so without a prefix or explicit name it cannot resolve the property.","triggerScenarios":"Declaring a @ComProperty accessor method in a COM interface whose name does not start with 'get' (e.g. 'fetchValue()') while leaving the annotation's name() unset, then invoking the method through the COM proxy.","commonSituations":"Renaming an accessor method during refactoring so it no longer follows JavaBean naming; hand-written COM binding interfaces that use custom method names; copying an accessor and forgetting to update the @ComProperty name.","solutions":["Rename the method so it starts with 'get' (e.g. getValue)","Set the 'name' attribute of @ComProperty explicitly: @ComProperty(name = \"PropName\")","Verify the interface is invoked via the JNA COM proxy (ProxyObject) and the annotation is actually @ComProperty, not another annotation"],"exampleFix":"// before\n@ComProperty\npublic String Value();\n// after\n@ComProperty(name = \"Value\")\npublic String Value();\n// or\n@ComProperty\npublic String getValue();","handlingStrategy":"validation","validationCode":"java.lang.reflect.Method m = ...;\nComProperty prop = m.getAnnotation(ComProperty.class);\nif (prop != null && prop.name().isEmpty() && !m.getName().startsWith(\"get\")) {\n    throw new IllegalArgumentException(m.getName() + \" must start with 'get' or set @ComProperty(name=...)\");\n}","typeGuard":"boolean isValidAccessor(java.lang.reflect.Method m) {\n    ComProperty p = m.getAnnotation(ComProperty.class);\n    return p == null || (!p.name().isEmpty() || m.getName().startsWith(\"get\"));\n}","tryCatchPattern":null,"preventionTips":["Always follow JavaBean naming: getX/isX for accessors of @ComProperty","Set @ComProperty(name=...) explicitly when custom method names are required","Add an interface-load-time validation scan that checks naming conventions before any COM call"],"tags":["java","com","jna","annotation","naming-convention"],"backgroundTag":"missing-required-argument","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}