From 30893c2401d98395636345c6b3bd3766f9ca5f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Sat, 12 Mar 2016 16:34:06 +0100 Subject: [PATCH] Fix NullPointer Exception in TlbCodegenerator --- .../win32/COM/tlb/imp/TlbCoClass.java | 23 +++++++--------- .../win32/COM/tlb/imp/TlbDispInterface.java | 26 +++++++------------ 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCoClass.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCoClass.java index 1cf55e0822..ba6c108e99 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCoClass.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCoClass.java @@ -97,21 +97,18 @@ protected void createFunctions(TypeInfoUtil typeInfoUtil, String bindingMode) { FUNCDESC funcDesc = typeInfoUtil.getFuncDesc(i); TlbAbstractMethod method = null; - if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_FUNC)) { - if(this.isVTableMode()) + if (funcDesc.invkind.value == INVOKEKIND.INVOKE_FUNC.value) { + if(this.isVTableMode()) { method = new TlbFunctionVTable(i, index, typeLibUtil, funcDesc, typeInfoUtil); - else + } else { method = new TlbFunctionDispId(i, index, typeLibUtil, funcDesc, typeInfoUtil); - } else if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_PROPERTYGET)) { - method = new TlbPropertyGet(i, index, typeLibUtil, funcDesc, - typeInfoUtil); - } else if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_PROPERTYPUT)) { - method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc, - typeInfoUtil); - } else if (funcDesc.invkind - .equals(INVOKEKIND.INVOKE_PROPERTYPUTREF)) { - method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc, - typeInfoUtil); + } + } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYGET.value) { + method = new TlbPropertyGet(i, index, typeLibUtil, funcDesc, typeInfoUtil); + } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYPUT.value) { + method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc, typeInfoUtil); + } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYPUTREF.value) { + method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc, typeInfoUtil); } if(!isReservedMethod(method.getMethodName())) diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java index 14de7ed353..c294a1a001 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java @@ -73,27 +73,21 @@ public TlbDispInterface(int index, String packagename, TlbAbstractMethod method = null; if (!isReservedMethod(methodName)) { - if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_FUNC)) { - method = new TlbFunctionStub(index, typeLibUtil, funcDesc, - typeInfoUtil); - } else if (funcDesc.invkind - .equals(INVOKEKIND.INVOKE_PROPERTYGET)) { - method = new TlbPropertyGetStub(index, typeLibUtil, - funcDesc, typeInfoUtil); - } else if (funcDesc.invkind - .equals(INVOKEKIND.INVOKE_PROPERTYPUT)) { - method = new TlbPropertyPutStub(index, typeLibUtil, - funcDesc, typeInfoUtil); - } else if (funcDesc.invkind - .equals(INVOKEKIND.INVOKE_PROPERTYPUTREF)) { - method = new TlbPropertyPutStub(index, typeLibUtil, - funcDesc, typeInfoUtil); + if (funcDesc.invkind.value == INVOKEKIND.INVOKE_FUNC.value) { + method = new TlbFunctionStub(index, typeLibUtil, funcDesc, typeInfoUtil); + } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYGET.value) { + method = new TlbPropertyGetStub(index, typeLibUtil, funcDesc, typeInfoUtil); + } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYPUT.value) { + method = new TlbPropertyPutStub(index, typeLibUtil, funcDesc, typeInfoUtil); + } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYPUTREF.value) { + method = new TlbPropertyPutStub(index, typeLibUtil, funcDesc, typeInfoUtil); } this.content += method.getClassBuffer(); - if (i < cFuncs - 1) + if (i < cFuncs - 1) { this.content += CR; + } } // Release our function description stuff