{"record":{"id":"7c013c3f5fede302","repo":"java-native-access/jna","slug":"cominterface-must-define-a-value-for-iid-proxyobject","errorCode":null,"errorMessage":"ComInterface must define a value for iid","messagePattern":"ComInterface must define a value for iid","errorType":"exception","errorClass":"com.sun.jna.platform.win32.COM.COMException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java","lineNumber":519,"sourceCode":"                String formatMessageFromHR = Kernel32Util.formatMessage(hr);\n                throw new COMException(\"queryInterface: \" + formatMessageFromHR, hr);\n            }\n        } catch (RuntimeException e) {\n            // Do not rewrap COMException\n            if (e instanceof COMException) {\n                throw e;\n            } else {\n                throw new COMException(\"Error occured when trying to query for interface \" + comInterface.getName(), e);\n            }\n        }\n    }\n\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    }","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java#L501-L537","documentation":"Thrown by ProxyObject's private getIID(ComInterface) helper when the @ComInterface annotation exists but its iid() attribute is null or empty. The IID is mandatory for all proxy operations (QI, advise, unadvise), so an annotation without a GUID is treated as invalid configuration. This is caught during advise/queryInterface flows that do check for the annotation first.","triggerScenarios":"@ComInterface present with empty iid string, e.g. @ComInterface(iid=\"\") or relying on a default that resolves to empty; annotation processed through a proxy/subclass where iid resolution fails.","commonSituations":"Copy-pasted annotation where the GUID was deleted; templates with placeholder GUIDs left blank; annotation defined with iid pointing to a constant that failed to initialize.","solutions":["Set a valid GUID in @ComInterface(iid=\"{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\")","Validate iid strings with a GUID parser before use in interfaces","Regenerate the annotation value from the COM type library (oleview / tlbimp output)"],"exampleFix":"// before\n@ComInterface(iid = \"\")\ninterface MyEvents extends IComEventCallbackListener { ... }\n// after\n@ComInterface(iid = \"{D666E0F0-...}\")\ninterface MyEvents extends IComEventCallbackListener { ... }","handlingStrategy":"validation","validationCode":"ComInterface a = iface.getAnnotation(ComInterface.class); if (a == null || a.iid() == null || a.iid().isEmpty()) throw new IllegalArgumentException(\"@ComInterface must define non-empty iid on \" + iface.getName());","typeGuard":"boolean hasIid = (Class<?> c) -> c.isAnnotationPresent(ComInterface.class) && !c.getAnnotation(ComInterface.class).iid().isEmpty();","tryCatchPattern":"try { proxy.advise(iface, listener); } catch (COMException e) { LOG.error(\"iid resolution failed\", e); }","preventionTips":["Validate @ComInterface iid values in unit tests (GUID format check)","Never ship placeholder/empty GUIDs","Regenerate GUIDs from the type library when it changes"],"tags":["com","annotation","iid","empty-value"],"backgroundTag":"empty-required-field","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"}