java-native-access/jna · error · java.lang.RuntimeException
Property Accessor name must start with 'get', or set the ano
Error message
Property Accessor name must start with 'get', or set the anotation 'name' value
What it means
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.
Source
Thrown at contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java:531
private IID getIID(ComInterface annotation) {
String iidStr = annotation.iid();
if (null != iidStr && !iidStr.isEmpty()) {
return new IID(iidStr);
} else {
throw new COMException("ComInterface must define a value for iid");
}
}
// --------------------- ProxyObject ---------------------
private String getAccessorName(java.lang.reflect.Method method, ComProperty prop) {
if (prop.name().isEmpty()) {
String methName = method.getName();
if (methName.startsWith("get")) {
return methName.replaceFirst("get", "");
} else {
throw new RuntimeException(
"Property Accessor name must start with 'get', or set the anotation 'name' value");
}
} else {
return prop.name();
}
}
private String getMutatorName(java.lang.reflect.Method method, ComProperty prop) {
if (prop.name().isEmpty()) {
String methName = method.getName();
if (methName.startsWith("set")) {
return methName.replaceFirst("set", "");
} else {
throw new RuntimeException(
"Property Mutator name must start with 'set', or set the anotation 'name' value");
}
} else {
return prop.name();View on GitHub (pinned to d036ad9781)
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
Example fix
// before @ComProperty public String Value(); // after @ComProperty(name = "Value") public String Value(); // or @ComProperty public String getValue();
Defensive patterns
Strategy: validation
Validate before calling
java.lang.reflect.Method m = ...;
ComProperty prop = m.getAnnotation(ComProperty.class);
if (prop != null && prop.name().isEmpty() && !m.getName().startsWith("get")) {
throw new IllegalArgumentException(m.getName() + " must start with 'get' or set @ComProperty(name=...)");
} Type guard
boolean isValidAccessor(java.lang.reflect.Method m) {
ComProperty p = m.getAnnotation(ComProperty.class);
return p == null || (!p.name().isEmpty() || m.getName().startsWith("get"));
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Property Mutator name must start with 'set', or set the anot
- advise: Interface must define a value for either iid via the
- ComInterface must define a value for iid
- createObject: Interface must define a value for either clsId
- ComObject must define a value for either clsId or progId
AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12).
Data as JSON: /api/errors/07779fe622e8710d.
Report an issue: GitHub.