diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7660b69a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,63 @@ +name: Build + +on: + push: + branches: [ master ] + pull_request: + workflow_dispatch: + +jobs: + build: + # windows-2022 ships Visual Studio 2022 (with the C++ ATL and MFC + # components the native build needs) and CMake preinstalled. + runs-on: windows-2022 + + steps: + - name: Check out repository (with submodules) + uses: actions/checkout@v7 + with: + submodules: recursive + + - name: Set up JDK + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '17' + cache: maven + + - name: Show build tool versions + shell: pwsh + run: | + cmake --version + java -version + + # -DbuildNative=true forces a real rebuild instead of packaging the + # committed bin/ DLLs (JitPack's only option, since it can't run + # MSVC). package-only, run first, just to catch Release-only compile + # regressions before the Debug build below becomes the installed jar. + - name: Build native (Release) + shell: pwsh + run: mvn -B -pl "!test" package -DbuildNative=true -Dmode=Release + + # TestObject (needed by tests) only compiles into Debug builds. + # install, not package, so "Run tests" below can resolve com4j from + # the local repo without rebuilding or needing -am. + - name: Build native (Debug) + shell: pwsh + run: mvn -B -pl "!test" install -DbuildNative=true -Dmode=Debug + + # Registers com4j.dll as TestObject's COM server. Plain regsvr32 + # works unelevated: GitHub's Windows runners run as Administrator + # with UAC disabled (actions/runner-images discussion #6557). + - name: Register COM test object + shell: pwsh + run: | + $dll = Resolve-Path "bin\x64\Debug\com4j.dll" + $p = Start-Process -FilePath "$env:SystemRoot\System32\regsvr32.exe" -ArgumentList "/s", "$dll" -Wait -PassThru -NoNewWindow + if ($p.ExitCode -ne 0) { + throw "regsvr32 failed with exit code $($p.ExitCode)" + } + + - name: Run tests + shell: pwsh + run: mvn -B test -pl test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..d4206ef1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: Release + +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + build-and-upload: + runs-on: windows-2022 + + steps: + - name: Check out repository (with submodules) at the release tag + uses: actions/checkout@v7 + with: + submodules: recursive + ref: ${{ github.event.release.tag_name }} + + - name: Set up JDK + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '17' + cache: maven + + # Sets the version to the release tag + - name: Set version to release tag + shell: pwsh + run: mvn -B versions:set "-DnewVersion=${{ github.event.release.tag_name }}" -DgenerateBackupPoms=false + + # Rebuilds native/com4j.dll (Release, x86+x64) from source rather than + # trusting whatever's committed, so the uploaded jar always reflects + # the exact code at this tag. + - name: Build native (Release) and package + shell: pwsh + run: mvn -B -pl "!test" package -DbuildNative=true -Dmode=Release + + # Uploads all modules' built artifacts as release assets + - name: Upload build artifacts to the release + shell: pwsh + env: + GH_TOKEN: ${{ github.token }} + run: | + function Latest($pattern) { + (Get-ChildItem $pattern | Sort-Object LastWriteTime -Descending | Select-Object -First 1).FullName + } + $files = @( + Latest "runtime/target/com4j-*.jar" + Latest "tlbimp/target/tlbimp-*.jar" + Latest "maven-com4j-plugin/target/maven-com4j-plugin-*.jar" + Latest "distribution/target/com4j-dist-*-all.zip" + ) + gh release upload "${{ github.event.release.tag_name }}" $files --repo ${{ github.repository }} --clobber diff --git a/.gitignore b/.gitignore index b64eccbe..5f2553b5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,8 @@ *.tli vc90.idb vc90.pdb +native/cmake-build*/ + +# bin/ holds the prebuilt com4j.dll (x86 and x64, Release and Debug) that the +# Java build packages by default and that JitPack relies on, since it can't +# build native/ itself - these are intentionally committed, do not ignore. diff --git a/.gitmodules b/.gitmodules index e88115bb..73ce5766 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "jnitl"] path = jnitl - url = git://github.com/kohsuke/jnitl.git + url = https://github.com/kohsuke/jnitl.git diff --git a/native/x64/Debug/com4j.dll b/bin/x64/Debug/com4j.dll similarity index 100% rename from native/x64/Debug/com4j.dll rename to bin/x64/Debug/com4j.dll diff --git a/native/x64/Debug/com4j.pdb b/bin/x64/Debug/com4j.pdb similarity index 100% rename from native/x64/Debug/com4j.pdb rename to bin/x64/Debug/com4j.pdb diff --git a/native/x64/Release/com4j.dll b/bin/x64/Release/com4j.dll similarity index 100% rename from native/x64/Release/com4j.dll rename to bin/x64/Release/com4j.dll diff --git a/native/x64/Release/com4j.pdb b/bin/x64/Release/com4j.pdb similarity index 100% rename from native/x64/Release/com4j.pdb rename to bin/x64/Release/com4j.pdb diff --git a/native/Debug/com4j.dll b/bin/x86/Debug/com4j.dll similarity index 100% rename from native/Debug/com4j.dll rename to bin/x86/Debug/com4j.dll diff --git a/native/Debug/com4j.pdb b/bin/x86/Debug/com4j.pdb similarity index 100% rename from native/Debug/com4j.pdb rename to bin/x86/Debug/com4j.pdb diff --git a/native/Release/com4j.dll b/bin/x86/Release/com4j.dll similarity index 100% rename from native/Release/com4j.dll rename to bin/x86/Release/com4j.dll diff --git a/native/Release/com4j.pdb b/bin/x86/Release/com4j.pdb similarity index 100% rename from native/Release/com4j.pdb rename to bin/x86/Release/com4j.pdb diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 00000000..a2da34bf --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,21 @@ +jdk: + - openjdk17 + +# Skip building from source (this project needs a Windows/MSVC toolchain +# JitPack's Linux build servers don't have) and instead install the +# prebuilt artifacts already uploaded to the matching GitHub release by +# .github/workflows/release.yml. +install: + - OWNER=${GROUP#com.github.} + - REPO=${ARTIFACT} + - MODULE_GROUP=${GROUP}.${REPO} + - BASE_URL=https://github.com/${OWNER}/${REPO}/releases/download/${VERSION} + + - curl -L -f -o com4j.jar ${BASE_URL}/com4j-${VERSION}.jar + - mvn install:install-file -Dfile=com4j.jar -DgroupId=${MODULE_GROUP} -DartifactId=com4j -Dversion=${VERSION} -Dpackaging=jar -DgeneratePom=true + + - curl -L -f -o tlbimp.jar ${BASE_URL}/tlbimp-${VERSION}.jar + - mvn install:install-file -Dfile=tlbimp.jar -DgroupId=${MODULE_GROUP} -DartifactId=tlbimp -Dversion=${VERSION} -Dpackaging=jar -DgeneratePom=true + + - curl -L -f -o maven-com4j-plugin.jar ${BASE_URL}/maven-com4j-plugin-${VERSION}.jar + - mvn install:install-file -Dfile=maven-com4j-plugin.jar -DgroupId=${MODULE_GROUP} -DartifactId=maven-com4j-plugin -Dversion=${VERSION} -Dpackaging=jar -DgeneratePom=true diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt new file mode 100644 index 00000000..65772aa1 --- /dev/null +++ b/native/CMakeLists.txt @@ -0,0 +1,174 @@ +cmake_minimum_required(VERSION 3.20) + +cmake_policy(SET CMP0091 NEW) +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + +project(com4j_native LANGUAGES C CXX ASM_MASM) + +if(NOT MSVC) + message(FATAL_ERROR "This project only builds with MSVC on Windows.") +endif() + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(COM4J_ARCH_DEFINE X86_WIN64) + set(COM4J_PLATFORM_DEFINE WIN64) + set(LIBFFI_ASM ${CMAKE_CURRENT_SOURCE_DIR}/../libffi/src/x86/win64.asm64) + set(MIDL_ENV win64) +else() + set(COM4J_ARCH_DEFINE X86_WIN32) + set(COM4J_PLATFORM_DEFINE WIN32) + set(LIBFFI_ASM ${CMAKE_CURRENT_SOURCE_DIR}/../libffi/src/x86/win32.asm) + set(MIDL_ENV win32) +endif() + +set_source_files_properties(${LIBFFI_ASM} PROPERTIES LANGUAGE ASM_MASM) + +# --------------------------------------------------------------------------- +# JNI +# --------------------------------------------------------------------------- +if(DEFINED JAVA_HOME) + set(ENV{JAVA_HOME} ${JAVA_HOME}) +endif() +find_package(JNI REQUIRED) + +# --------------------------------------------------------------------------- +# jnitl (git submodule, ../jnitl) - built as a small static lib. +# native/stdafx.h pulls in jnitl.h, which does: +# #pragma comment(lib, "jnitl.lib") (Release, static CRT) +# #pragma comment(lib, "jnitld.lib") (Debug, static CRT) +# so name the output to match and make sure it's on the link path. +# --------------------------------------------------------------------------- +set(JNITL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../jnitl) + +add_library(jnitl STATIC + ${JNITL_DIR}/source/jnitl.cpp + ${JNITL_DIR}/source/accessor.cpp +) +target_include_directories(jnitl PUBLIC ${JNITL_DIR}/include) +target_include_directories(jnitl PRIVATE ${JNI_INCLUDE_DIRS}) +set_target_properties(jnitl PROPERTIES + OUTPUT_NAME "jnitl" + DEBUG_POSTFIX "d" + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/jnitl-lib +) +target_compile_definitions(jnitl PRIVATE WIN32 ${COM4J_PLATFORM_DEFINE} UNICODE _UNICODE) +# original vcproj built with TreatWChar_tAsBuiltInType="false" (/Zc:wchar_t-), +# which is why jni.h's `jchar` (unsigned short) and `wchar_t*`/BSTR interconvert +# implicitly all over this codebase. +target_compile_options(jnitl PRIVATE /Zc:wchar_t-) + +# --------------------------------------------------------------------------- +# MIDL: com4j.idl -> com4j.tlb (+ generated .h/.c, unused but let midl emit +# its normal output). typelib.cpp does `#import "com4j.tlb" no_namespace` +# and com4j.rc embeds it as a TYPELIB resource, so both need the tlb's +# directory on their include search path. +# --------------------------------------------------------------------------- +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(MIDL_SDK_ARCH x64) +else() + set(MIDL_SDK_ARCH x86) +endif() +file(GLOB MIDL_SDK_HINTS "C:/Program Files (x86)/Windows Kits/10/bin/10.0.*/${MIDL_SDK_ARCH}") +list(SORT MIDL_SDK_HINTS ORDER DESCENDING) +find_program(MIDL_EXECUTABLE midl.exe HINTS ${MIDL_SDK_HINTS} REQUIRED) + +set(COM4J_TLB ${CMAKE_CURRENT_BINARY_DIR}/com4j.tlb) +set(COM4J_MIDL_H ${CMAKE_CURRENT_BINARY_DIR}/com4j_midl.h) +set(COM4J_MIDL_C ${CMAKE_CURRENT_BINARY_DIR}/com4j_midl_i.c) + +add_custom_command( + OUTPUT ${COM4J_TLB} + COMMAND ${MIDL_EXECUTABLE} + /nologo + /env ${MIDL_ENV} + /tlb ${COM4J_TLB} + /h ${COM4J_MIDL_H} + /iid ${COM4J_MIDL_C} + /out ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/com4j.idl + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/com4j.idl + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Running MIDL on com4j.idl" + VERBATIM +) +add_custom_target(com4j_idl DEPENDS ${COM4J_TLB}) + +# --------------------------------------------------------------------------- +# com4j.dll +# --------------------------------------------------------------------------- +set(COM4J_SOURCES + com4j.cpp + com4j_Win32Lock.cpp + error.cpp + eventReceiver.cpp + invoke.cpp + java_id.cpp + registry.cpp + safearray.cpp + stdafx.cpp + TestObject.cpp + toJava.cpp + typelib.cpp + variant.cpp +) + +set(LIBFFI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libffi) +set(LIBFFI_SOURCES + ${LIBFFI_DIR}/src/debug.c + ${LIBFFI_DIR}/src/x86/ffi.c + ${LIBFFI_DIR}/src/prep_cif.c + ${LIBFFI_DIR}/src/types.c + ${LIBFFI_ASM} +) + +add_library(com4j SHARED + ${COM4J_SOURCES} + ${LIBFFI_SOURCES} + com4j.rc +) + +add_dependencies(com4j com4j_idl) + +target_include_directories(com4j PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${JNITL_DIR}/include + ${LIBFFI_DIR}/include + ${JNI_INCLUDE_DIRS} +) + +target_compile_definitions(com4j PRIVATE + ${COM4J_PLATFORM_DEFINE} + _WINDOWS + _USRDLL + COM4J_EXPORTS + ${COM4J_ARCH_DEFINE} + UNICODE + _UNICODE + $<$:_DEBUG> + $<$>:NDEBUG> +) +target_compile_options(com4j PRIVATE $<$:/Zc:wchar_t->) + +# jnitl.h does `#pragma comment(lib, "jnitl.lib"/"jnitld.lib")` - that pragma-driven +# search needs the jnitl target's actual (per-config) output dir on the /LIBPATH, +# in addition to linking it directly as a CMake target dependency. +target_link_directories(com4j PRIVATE $) +target_link_libraries(com4j PRIVATE jnitl ole32 oleaut32 uuid) + +set(COM4J_LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/com4j.def") +if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + # libffi's hand-written win32.asm predates SAFESEH exception-handler records; + # the modern linker refuses to produce a SAFESEH image without this. + set(COM4J_LINK_FLAGS "${COM4J_LINK_FLAGS} /SAFESEH:NO") +endif() +set_target_properties(com4j PROPERTIES + LINK_FLAGS "${COM4J_LINK_FLAGS}" +) + +# make sure the rc compile step can find com4j.tlb (embedded via `1 TYPELIB "com4j.tlb"`) +set_source_files_properties(com4j.rc PROPERTIES + COMPILE_OPTIONS "/I${CMAKE_CURRENT_BINARY_DIR}" +) + +# TestObject.cpp compiles to nothing outside _DEBUG - fine to always include. diff --git a/native/TestObject.cpp b/native/TestObject.cpp index 53b888ce..b4bdd912 100644 --- a/native/TestObject.cpp +++ b/native/TestObject.cpp @@ -31,8 +31,15 @@ STDMETHODIMP CTestObject::raw_TestVariant(VARIANT v1, VARIANT* v2, VARIANT* v3) STDMETHODIMP CTestObject::raw_outByteBuf(BSTR bstrEncodedData, long* plSize, unsigned char** ppbData) { - *plSize = 30; - *ppbData = (BYTE*)"Hello, World!"; + static const char text[] = "Hello, World!"; + const long len = sizeof(text)-1; // exclude the terminating '\0' + + *ppbData = (BYTE*)CoTaskMemAlloc(len); + if(*ppbData==NULL) + return E_OUTOFMEMORY; + + memcpy(*ppbData, text, len); + *plSize = len; return S_OK; } @@ -45,4 +52,4 @@ STDMETHODIMP CTestObject::raw_testUI8Conv(VARIANT* in, VARIANT* out) return ::VariantCopy(out,in); } -#endif \ No newline at end of file +#endif diff --git a/native/build.xml b/native/build.xml deleted file mode 100644 index a10782bf..00000000 --- a/native/build.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/native/safearray.h b/native/safearray.h index bef1b617..263521e0 100644 --- a/native/safearray.h +++ b/native/safearray.h @@ -31,7 +31,7 @@ namespace safearray { template < VARTYPE itemType, class XDUCER > class BasicArrayXducer { public: - typedef array::Array JARRAY; + typedef jnitl::array::Array JARRAY; typedef SAFEARRAY* NativeType; typedef jarray JavaType; @@ -79,7 +79,7 @@ namespace safearray { // XDUCER : converter for each array item template < VARTYPE itemType, class XDUCER > class ToJavaMultiDimlArrayMarshaller { - typedef array::Array JARRAY; + typedef jnitl::array::Array JARRAY; typedef SAFEARRAY* NativeType; typedef jarray JavaType; @@ -129,13 +129,13 @@ namespace safearray { return a; } else { - jobjectArray a = array::Array::newArray(env, dimSizes[curDim]); - jobject* const pDst = array::Array::lock(env, a); + jobjectArray a = jnitl::array::Array::newArray(env, dimSizes[curDim]); + jobject* const pDst = jnitl::array::Array::lock(env, a); for( int i = 0; i < dimSizes[curDim]; i++ ) { pDst[i] = toJavaRec(pSrc, curDim - 1); } - array::Array::unlock(env, a, pDst); + jnitl::array::Array::unlock(env, a, pDst); return a; } @@ -182,7 +182,7 @@ namespace safearray { // XDUCER : converter for each array item template < VARTYPE itemType, class XDUCER > class ToNativeMultiDimlArrayMarshaller { - typedef array::Array JARRAY; + typedef jnitl::array::Array JARRAY; typedef SAFEARRAY* NativeType; typedef jarray JavaType; @@ -234,12 +234,12 @@ namespace safearray { } else { - JavaType* pSrc = array::Array::lock(env, static_cast(_array)); + JavaType* pSrc = jnitl::array::Array::lock(env, static_cast(_array)); for(size_t i = 0; i < bounds[curDim].cElements; i++) toNativeRec(pSrc[i], curDim - 1); - array::Array::unlock(env,static_cast(_array), pSrc); + jnitl::array::Array::unlock(env,static_cast(_array), pSrc); } } diff --git a/native/stdafx.cpp b/native/stdafx.cpp index 7b953e76..787d74b7 100644 --- a/native/stdafx.cpp +++ b/native/stdafx.cpp @@ -1,35 +1,33 @@ #include "stdafx.h" -CComModule _Module; +CTestObjectModule _Module; JNIModule jniModule; -BOOL APIENTRY DllMain( HINSTANCE hModule, - DWORD dwReason, +BOOL APIENTRY DllMain( HINSTANCE hModule, + DWORD dwReason, LPVOID lpReserved ) { - _Module.DllMain(hModule, dwReason, lpReserved, NULL, NULL ); -// _Module.Init(ObjectMap, m_hInstance, &LIBID_LIB2USRLib); AtlAxWinInit(); - return TRUE; + return _Module.DllMain(dwReason, lpReserved); } STDAPI DllCanUnloadNow(void) { - return (_Module.GetLockCount()==0) ? S_OK :S_FALSE; + return _Module.DllCanUnloadNow(); } STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { - return _Module.GetClassObject(rclsid, riid, ppv); + return _Module.DllGetClassObject(rclsid, riid, ppv); } STDAPI DllRegisterServer(void) { - return _Module.RegisterServer(TRUE); + return _Module.DllRegisterServer(); } STDAPI DllUnregisterServer(void) { - return _Module.UnregisterServer(TRUE); + return _Module.DllUnregisterServer(); } diff --git a/native/stdafx.h b/native/stdafx.h index b34f0057..5d45b10a 100644 --- a/native/stdafx.h +++ b/native/stdafx.h @@ -14,7 +14,12 @@ #include #include -extern CComModule _Module; +// CAtlDllModuleT (not the old CComModule) is required for OBJECT_ENTRY_AUTO +// (used by TestObject.h) to actually register its class - CComModule only +// knows about the old BEGIN_OBJECT_MAP/_Module.Init() style object map. +class CTestObjectModule : public CAtlDllModuleT { +}; +extern CTestObjectModule _Module; #include #include #include diff --git a/native/xducer.h b/native/xducer.h index 4a5733e1..b8b7e8f5 100644 --- a/native/xducer.h +++ b/native/xducer.h @@ -112,13 +112,13 @@ namespace xducer { return 0; ULONGLONG val = 0; - sscanf(JString(env,javaMathBigInteger_toString(env,value)),"%Lu",&val); + sscanf(JString(env,javaMathBigInteger_toString(env,value)),"%llu",&val); return val; } static inline JavaType toJava( JNIEnv* env, NativeType value ) { char w[128]; - sprintf(w,"%Lu",value); + sprintf(w,"%llu",value); return javaMathBigInteger_new(env,env->NewStringUTF(w)); } }; diff --git a/native/xducer2.h b/native/xducer2.h index fb44616e..f9e44f16 100644 --- a/native/xducer2.h +++ b/native/xducer2.h @@ -1,5 +1,6 @@ // com4j specific transducers #pragma once +#include #include "xducer.h" #include "com4j.h" #include "java_id.h" @@ -14,7 +15,7 @@ namespace xducer { typedef jobject JavaType; static inline NativeType toNative( JNIEnv* env, JavaType value ) { - std::auto_ptr v(convertToVariant(env,value)); // need to be deleted after copy as return value + std::unique_ptr v(convertToVariant(env,value)); // need to be deleted after copy as return value return *v; } diff --git a/pom.xml b/pom.xml index 801bbb30..23e6c985 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,9 @@ UTF-8 + + Release + Visual Studio 17 2022 @@ -91,8 +94,8 @@ maven-compiler-plugin - 1.5 - 1.5 + 1.8 + 1.8 @@ -109,6 +112,122 @@ test + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + build-native + generate-resources + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + run + + + + + + diff --git a/release.sh b/release.sh deleted file mode 100644 index 7380173b..00000000 --- a/release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -ex - -# build the bootstrap jar -pushd runtime - ant clean jar -popd -pushd tlbimp - ant clean jar -popd -cp runtime/build/com4j.jar bootstrap/com4j.jar -cp tlbimp/build/tlbimp.jar bootstrap/com4j.jar - -# use that bootstrap jar to build the whole distribution -ant clean dist deploy -lib ./bootstrap - -# done -#dt=$(date +%Y%m%d) -#jnupload com4j "/$(date +%Y-%m-%d) release" "$(date +%Y/%m/%d) release" stable build/com4j-$dt.zip diff --git a/runtime/pom.xml b/runtime/pom.xml index 3412f02e..5028f59a 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -21,8 +21,15 @@ generate-resources - - + + + diff --git a/test/pom.xml b/test/pom.xml index 1cce5b86..93037d04 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -3,11 +3,11 @@ org.jvnet.com4j com4j-parent - 2.0-SNAPSHOT + 2.2-SNAPSHOT com4j-test - 2.0-SNAPSHOT + 2.2-SNAPSHOT com4j Tests diff --git a/test/src/test/java/ITestObject2.java b/test/src/test/java/ITestObject2.java index c4682c41..d48415d8 100644 --- a/test/src/test/java/ITestObject2.java +++ b/test/src/test/java/ITestObject2.java @@ -20,5 +20,5 @@ int testVariant2( @MarshalAs(NativeType.VARIANT_ByRef) Holder v2); @VTID(8) - int outByteBuf( String s, Holder size ); + long outByteBuf( String s, Holder size ); } diff --git a/test/src/test/java/OutByteBufTest.java b/test/src/test/java/OutByteBufTest.java index e603b7e4..0497bcf3 100644 --- a/test/src/test/java/OutByteBufTest.java +++ b/test/src/test/java/OutByteBufTest.java @@ -12,7 +12,7 @@ public class OutByteBufTest extends TestCase { public void test1() throws Exception { ITestObject2 t = ClassFactory.createTestObject().queryInterface(ITestObject2.class); Holder sz = new Holder(); - int ptr = t.outByteBuf("Test",sz); + long ptr = t.outByteBuf("Test",sz); ByteBuffer buf = COM4J.createBuffer(ptr, sz.value); byte[] tmp = new byte[13]; diff --git a/tlbimp/src/main/java/com4j/tlbimp/TypeLibInfo.java b/tlbimp/src/main/java/com4j/tlbimp/TypeLibInfo.java index 2062d273..a90c1469 100644 --- a/tlbimp/src/main/java/com4j/tlbimp/TypeLibInfo.java +++ b/tlbimp/src/main/java/com4j/tlbimp/TypeLibInfo.java @@ -108,9 +108,13 @@ public static TypeLibInfo locate( GUID libid, String version ) throws BindingExc String fileName; try { - fileName = Native.readRegKey(verKey+"\\"+lcid+"\\win32"); - } catch( ComException e ) { - throw new BindingException(Messages.NO_WIN32_TYPELIB.format(libid,version),e); + fileName = Native.readRegKey(verKey+"\\"+lcid+"\\win64"); + } catch( ComException e64 ) { + try { + fileName = Native.readRegKey(verKey+"\\"+lcid+"\\win32"); + } catch( ComException e32 ) { + throw new BindingException(Messages.NO_WIN32_TYPELIB.format(libid,version),e32); + } } return new TypeLibInfo( libName, new File(fileName), new Version(version), lcid );