Giter Club home page Giter Club logo

com4j's People

Contributors

bagges avatar fcarriedo avatar guykv avatar joejensen avatar kllbzz avatar kohsuke avatar martian111 avatar mpoindexter avatar sakamotodesu avatar salmito avatar viruscamp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

com4j's Issues

BStr* support problem.

Hi all!
I'am having problem mapping a COM library from ZKSoftware to access the VF600 IFace clock.
The method header is:

VARIANT_BOOL SSR_GetGeneralLogData(
[in] LONG dwMachineNumber,
[out] BSTR* dwEnrollNumber,
[out] LONG* dwVerifyMode, [out] LONG* dwInOutMode, [out] LONG* dwYear, [out] LONG* dwMonth, [out] LONG* dwDay, [out] LONG* dwHour, [out] LONG*
dwMinute, [out] LONG* dwSecond, [out] LONG* dwWorkcode)

and com4j generate:

@DISPID(145) //= 0x91. The runtime will prefer the VTID if present
@VTID(153)
boolean ssR_GetGeneralLogData(
int dwMachineNumber,
Holder<java.lang.String> dwEnrollNumber,
Holder dwVerifyMode,
Holder dwInOutMode,
Holder dwYear,
Holder dwMonth,
Holder dwDay,
Holder dwHour,
Holder dwMinute,
Holder dwSecond,
Holder dwWorkCode);

Other methods works and I suspect that the problems is the BSTR* pointer. Tha JVM blow up when the program reach function call.
Does sombothy know any workaround?
Thanks!

Marcelo

COMsurrogate has stopped working

I am using com4j-20120426-2 to generate java skeleton from dll and connect. It is working fine. But after some time windows showing "COMsurrogate has stopped working" error , in that box if I click ok the running java terminated. Please find the detailed windows exception.

Problem signature:
Problem Event Name: APPCRASH
Application Name: DllHost.exe
Application Version: 6.1.7600.16385
Application Timestamp: 4a5bc6b7
Fault Module Name: StackHash_a13a
Fault Module Version: 6.1.7601.17725
Fault Module Timestamp: 4ec49b8f
Exception Code: c0000374
Exception Offset: 000ce6c3
OS Version: 6.1.7601.2.1.0.272.7
Locale ID: 1033
Additional Information 1: a13a
Additional Information 2: a13adc6fde0255c16bdfac2a7fa7b5e9
Additional Information 3: e1f9
Additional Information 4: e1f970ab2e475d4dc578f4188f488cfc

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt

Exception :

com4j.ComException: 800706be The remote procedure call failed. : The remote procedure call failed. : .\invoke.cpp:517
at com4j.Wrapper.invoke(Wrapper.java:187)
at $Proxy15.get(Unknown Source)
Caused by: com4j.ComException: 800706be The remote procedure call failed. : The remote procedure call failed. : .\invoke.cpp:517
at com4j.Native.invoke(Native Method)
at com4j.StandardComMethod.invoke(StandardComMethod.java:35)
at com4j.Wrapper$InvocationThunk.call(Wrapper.java:356)
at com4j.Task.invoke(Task.java:50)
at com4j.ComThread.run0(ComThread.java:172)
at com4j.ComThread.run(ComThread.java:153)

Dependencies required for executing excel macro

I have included the below dependency in my project

org.jvnet.com4j com4j 2.1

But the line
import excel._Application;
is giving the error import excel cannot be resolved ,is there a need to add any other dependencies

Using com4j to drive UIAutomationClient (WIndows Automation)

I am using com4j for UIAutomationClient, and whilst it largely works, there are several methods that were either not extracted, or fail to work when implemented manually.

One of these is the following ..

@VTID(43)
void
Get_CurrentBoundingRectangle(
/[out, retval]/ RECT retVal
);

When I call this, I get the following execption ...

Exception in thread "main" com4j.IllegalAnnotationException: no default conversion available for class com.sun.jna.platform.win32.WinDef$RECT

So, is there a way around this - i.e. to add conversions ?

Thanks

Mark H

Error 8000ffff Invocation failed

Hello,

I used line command in order to generate my classes from ocx and when i tried to execute code, i have this error
=> " com4j.ComException: 8000ffff Invocation failed: (null) : Défaillance irrémédiable : .\com4j.cpp:82"

My main code :
_DSoftPhone softphone = ClassFactory.createSoftPhone();
softphone.initialize("", "0019001", "0019001", "srvfr01-0001:4063"); //error on this line

I think my working environnement is well configurated. I'm working with 64bits machine

Can you help me ?
Thanks

Java definitions from a dll-library

The com4j generates no „struct“ data from a type library. It’s generated only interfaces and “enum “ data type. What can I do with this problem?

Maven compile issues

trying to compile the com4j parent produces

 Non-resolvable parent POM: Could not find artifact org.jvnet.com4j:com4j-parent:pom:2.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 3, column 11

trying seperately to compile the com4j type library importer produces

 Failed to execute goal on project tlbimp: Could not resolve dependencies for project org.jvnet.com4j:tlbimp:jar:2.2-SNAPSHOT: Failed to collect dependencies for [org.jvnet.com4j:com4j:jar:2.2-SNAPSHOT (compile), args4j:args4j:jar:2.0.8 (compile), ant:ant:jar:1.6.5 (provided), junit:junit:jar:4.11 (test)]: Failed to read artifact descriptor for org.jvnet.com4j:com4j:jar:2.2-SNAPSHOT: Failure to find org.jvnet.com4j:com4j-parent:pom:2.2-SNAPSHOT in http://repo.jenkins-ci.org/public/ was cached in the local repository, resolution will not be reattempted until the update interval of repo.jenkins-ci.org has elapsed or updates are forced -> [Help 1]

error in namespace generation with maven plugin

this command line
java -jar "tlbimp-2.1.jar" -o "target\generated-sources\com4j\java" -p "my.test" "C:\Program Files (x86)\Microsoft Office\Office14\MSWORD.OLB"

generate java files in folder target\generated-sources\com4j\java\my\test\events using a right package definition package my.test.events;

but the maven plugin

        <plugin>
            <groupId>org.jvnet.com4j</groupId>
            <artifactId>maven-com4j-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <id>Word 2010 (OFFICE14/MSWORD.OLB)</id>
                    <goals>
                        <goal>gen</goal>
                    </goals>
                    <configuration>
                        <!--<libId>00020905-0000-0000-C000-000000000046</libId>-->
                        <file>C:\Program Files (x86)\Microsoft Office\Office14\MSWORD.OLB</file>
                        <package>my.test</package>
                    </configuration>
                </execution>
            </executions>
        </plugin>

generate some files in folder target\generated-sources\com4j\java\events with an invalid package package .events; like for _CommandBarButtonEvents class

java.lang.IllegalArgumentException

Hi
I get an IllegalArgumentException when calling a method in a com dll.

My code is the following:
IManager manager = ClassFactory.createManager();
String bstrFile = "1.xml";
String pbstrSchema=new String();
Holder<IRequest> ppIRequest = new Holder<IRequest>();
Holder<IResult> ppIResult = new Holder<IResult>();
manager.load(bstrFile, pbstrSchema, ppIRequest, ppIResult);

The C/C++ Interface has the following signature
HRESULT load(BSTR bstrFile,
BSTR *pbstrSchema,
IRequest **ppIRequest,
IResult **ppIResult)

Stacktrace:

Exception in thread "main" com4j.ExecutionException: java.lang.IllegalArgumentException
	at com4j.ComThread.execute(ComThread.java:236)
	at com4j.Task.execute(Task.java:40)
	at com4j.Wrapper$InvocationThunk.invoke(Wrapper.java:345)
	at com4j.Wrapper.invoke(Wrapper.java:184)
	at com.sun.proxy.$Proxy3.loadXML(Unknown Source)
	at test.DllCall.DllCall.main(DllCall.java:25)
Caused by: java.lang.IllegalArgumentException
	at com4j.Wrapper.<init>(Wrapper.java:82)
	at com4j.Wrapper.create(Wrapper.java:98)
	at com4j.NativeType$5.toJava(NativeType.java:279)
	at com4j.StandardComMethod.invoke(StandardComMethod.java:55)
	at com4j.Wrapper$InvocationThunk.call(Wrapper.java:356)
	at com4j.Task.invoke(Task.java:50)
	at com4j.ComThread.run0(ComThread.java:172)
	at com4j.ComThread.run(ComThread.java:153)

Any idea what could be wrong?
Thanks for your help!

When converting from VARIANT to Java type the target type should be boxed

When a COM method returns a VARIANT and the Java return type is a primitive type, the conversion function Variant.convertTo falls back to converting based on the type of the variant, and not the Java type.

This is because all the Java types in the SetterEntry mapping are the boxed types, and the type that is tested against is the primitive type.

Falling back to the VTTYPE is usually fine as the variant should be the type expected. This is not always the case though, and so com4j should handle coercing the type into the expected type. For example, many Excel COM methods that are described in the typelib as returning VT_I4 (long) actually return VT_R8 (double). These methods cause a problem when called through com4j as variant gets converted to the type matching the variant which doesn't match the expected return type.

To fix this, when converting to the java return type the target type should be the boxed type.

Timeout for the Native call + PID of the COM

We are using the COM4J to activate some MS-Office module.
However, we faced a very rare situation that the COM is blocked (not responding)
And therefore our entire Java Application is blocked due to deadlock.
Is it possible to add a timeout feature for the native calling?
With this timeout event, we may continue and create alternative COM instance.
Moreover, it will be great to add also API that provide the COM Windows Process ID (PID)
With this PID we may also kill the blocked COM.

Thanks for your answer and for this great module.

Some methods subscribers are not invoked

I'm using com4j and it's working as expected but I've a problem when it comes to event subscribe that
I can't figure out what's going on, when I subscribe my class some methods are invoked but some not.

fooClass.advise(IFooEvent.class, new FooEventImplementation());
this is an example of a method that is not invoked when the action occurs on the application com side, but I don't see errors or anything related.

   @DISPID(213) //this method is not invoked when the action occurs.
   public void onExit(
           int exitCode,
           java.lang.String description) {
       throw new UnsupportedOperationException();
   }

   @DISPID(214) //this method is invoked
   public void onLineChangedEvent() {
       throw new UnsupportedOperationException();
   }

Any idea what could it be?

Thanks beforehand.

com4j.Variant.convertTo( java.lang.Object.class ) crashes for variant array of variant arrays

The com4j generated java wrapper for a method returning a variant is

@returnvalue(type=NativeType.VARIANT) java.lang.Object methodReturningVariant()

so on calling

Object o = methodReturningVariant();

the com4j.NativeType.toJava method is called to do the conversion (see below)

    @Override
    Object toJava(Class<?> signature, Type genericSignature, Object param) {
        if(param instanceof Variant) {
            Variant v = (Variant)param;
            Object r = v.convertTo(signature);
            v.clear();
            return r;
        } else if(param instanceof Enum){
            return EnumDictionary.get((Class<? extends Enum>)signature).constant((Integer)param);
        }
        return param;
    }

but it crashes on the native convertTo call.

Changing the method signature to

@returnvalue(type=NativeType.VARIANT) com4j.Variant methodReturningVariant()

and instead calling

com4j.Variant v = methodReturningVariant()

will avoid the crash but then I don't know how to dig out the arrays in v.

Any ideas?

Weird deadlock issue

Using com4j to access opendss through it's dll results in some weird deadlocks.

I'm downloading the com4j source right now to look through it, but it took me a while to get to this point due to the way opendss handled this occurence. I hope you can help me or at least point me in the right direction.

Thanks,

ainawing.

EDIT: Just realized I'm running on an older version of com4j. Making my search rather difficult. Will I have to recreate the java files for the dll or can I just use the new jar?

Here's the dump:

Java stack information for the threads listed above:
"Thread-18":
at com4j.ComThread.execute(ComThread.java:179)
- waiting to lock <0x00000000c21ab0a0> (a com4j.ComThread)
- locked <0x00000000f67e15d8> (a com4j.Wrapper$InvocationThunk)
at com4j.Task.execute(Task.java:39)
at com4j.Wrapper$InvocationThunk.invoke(Wrapper.java:329)
- locked <0x00000000f67e15d8> (a com4j.Wrapper$InvocationThunk)
at com4j.Wrapper.invoke(Wrapper.java:163)
at com.sun.proxy.$Proxy11.result(Unknown Source)
at de.fraunhofer.iosb.ast.io.opendss.server.DSSsrv.getResult(DSSsrv.java:80)
at de.fraunhofer.iosb.ast.io.opendss.server.DSSsrv.readLine(DSSsrv.java:325)
at de.fraunhofer.iosb.ast.io.opendss.client.DSScl.sendComment(DSScl.java:186)
at de.fraunhofer.iosb.ast.io.opendss.client.SimulationWrapper.createNetwork(SimulationWrapper.java:268)
at de.fraunhofer.iosb.ast.io.SimulationRunner.run(SimulationRunner.java:38)

"ComThread for SwingWorker-pool-3-thread-1":
at com4j.Task.invoke(Task.java:46)
- waiting to lock <0x00000000f67e15d8> (a com4j.Wrapper$InvocationThunk)
at com4j.ComThread.run0(ComThread.java:153)
- locked <0x00000000c21ab0a0> (a com4j.ComThread)
at com4j.ComThread.run(ComThread.java:134)

Found 1 deadlock.

If param as return value is not the last param, it may cause a segment fault.

Example:

// define in idl
HRESULT _stdcall out_int_as_ret([out] int *p, int ommited);

// java method generated by tlbimp, may cause a segment fault
@VTID(23)
@ReturnValue(index=0)
int out_int_as_ret(int ommited);

// java method which is correct
@VTID(23)
void out_int_as_ret(Holder<Integer> hi, int ommited);

I think we should insert a empty position in args, paramConvs,
in method com4j.StandardComMethod.invoke( long ptr, Object[] args)
around the line "messageParameters(args);";

I will try to fix it tomorrow.

No way to call IDispatch.getIDsOfName

I'm working on some code that needs to invoke a COM function that is created dynamically at runtime. To do this, I need to determine the DISPID of the function at runtime and then call IDispatch.Invoke on the COM object to actually invoke the method at runtime.

Just to give you more background, I'm working on a Selenium Webdriver for IE. I'd like to be able to dynamically execute javascript code against IE. In order to do this, I need to use the IHTMLWindow2.executeScript to create the new javascript function, which is then exposed as a new COM function on the IHTMLDocument2 object.

I looked all over the existing com4j, but couldn't find a way to do this. It would be great if this could be supported. Any help or pointers would be greatly appreciated.

Support licensed object instantiation with IClassFactory2

We've been using com4j happily for years but the software we integrate with is about to start requiring a license key and we're trying to figure out if that's something com4j supports or could be modified to support easily. The examples we were shown for passing the license key are in C# and use CoGetClassObject (https://msdn.microsoft.com/en-us/library/windows/desktop/ms684007(v=vs.85).aspx) to get an instance of IClassFactory2 (https://msdn.microsoft.com/en-us/library/windows/desktop/ms680095(v=vs.85).aspx), on which they call CreateInstanceLic (https://msdn.microsoft.com/en-us/library/windows/desktop/ms694342(v=vs.85).aspx) to get an instance of the actual COM interface needed.

My research so far leads me to believe that the IClassFactory2 method of instantiation is at a lower level than what com4j provides, and library internals would have to be augmented to allow passing the license key in from Java.

Can anyone confirm this?

Thanks!

Marshalling between threads when using COM4J.wrap

When constructing a wrapper from a C pointer to an interface using COM4J.wrap, all subsequent method calls on that object are done on a com4j.ComThread. This isn't the same thread that was used to create the object, and so it will cause problems.

When wrapping the pointer, com4j should marshal the object across to its com4j.ComThread instead of just taking the pointer.

One possible solution would be to use RegisterInterfaceInGlobal/GetInterfaceFromGlobal to pass a handle across the thread boundary and add a call to RevokeInterfaceFromGlobal when releasing the native object.

Is this something that anyone else has come across? Have I missed something, or is using COM4J.wrap not the right thing to be using for this purpose?

I'm happy to make the changes necessary, but is this project still being actively maintained by anyone? Are my changes likely to be merged?

Variant type VT_ARRAY_UI1 returns null on toJava but should return byte array

Trying to get the objectGUID from an object in LDAP through the ado20 typelib, but com4j does not implement a conversion from native to java for the type VT_ARRAY_UI1 (array of bytes).

I suspect that the com4j.Variant class toJava method ends up in the safearray.cpp class calling SafeArrayXducer::toJava but this class does not handle the VT_ARRAY_UI1 type and falls through to return null.

Native project will not build

Seems like visual studio was removing the instruction to build win64.asm using MASM64, so I changed the extension to .asm64 and changed the rules file to match. I also removed libffi from the includes since it's now built as part of the project.

mpoindexter@91fab41

COM4J.loadNativeLibrary() fails with ExceptionInInitializerError when com4j JAR is on UNC path

When the com4j.jar file is located on an UNC path (for example: \host\share\foo\lib\com4j-20120426-2.jar), it will cause an ExceptionInInitializerError with root cause:
Caused by: java.lang.NullPointerException
at com4j.COM4J.loadNativeLibrary(COM4J.java:567)
at com4j.COM4J.(COM4J.java:522)
... 7 more

First the NPE is caused by using LOGGER before it's initialized (since both are part of the class's static init code and the LOGGER part is a the end) in the IOException catch block. The real root cause is a bug in the file path parsing code, causing the process that copies the DLL file to the filesystem to throw an IOException.

Found that if the COM4J.class URL is:

jar:file://host/share/foo/lib/com4j-20120426-2.jar!/com4j/COM4J.class

The dllFile will be:

\host\share\foo\lib\com4j-x86.dll

which is invalid. It should be:

\\host\share\foo\lib\com4j-x86.dll

COM4J.createInstance() returns null in some cases

In the process of looking for a memory leak in a program that uses com4j, I've come across some rather bug-like behavior. My test program ran multiple threads allocating COM objects to perform a certain task thousands of times. In some rare cases, the tlbimp generated ClassFactory createSomething methods simply returned null, with no ComException being thrown. I've been able to reproduce it in this simple program based on the VBScript runtime.

First, create proxy classes for the VBScript runtime:

java -jar tlbimp.jar -o . %WINDIR%\system32\scrrun.dll

Delete all files except CompareMethod.java and IDictionary.java. Then create a file called ReproduceCreateReturnsNull.java containing the following code:

import com4j.*;
import java.io.Console;
import java.util.List;
import java.util.ArrayList;

public class ReproduceCreateReturnsNull {
    public static void main(String[] args) {
        Console c = System.console();
        c.format("Press ENTER to start.\n");
        c.readLine();

        int threadCount = 20;
        while (true) {
            Thread[] threads = new Thread[threadCount];
            for (int i = 0; i < threadCount; i++) {
                threads[i] = new Thread(new ThreadClass());
                threads[i].start();
            }

            for (int i = 0; i < threadCount; i++) {
                try {
                    threads[i].join();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    }

    public static IDictionary createDictionary() {
        return COM4J.createInstance( IDictionary.class, "{EE09B103-97E0-11CF-978F-00A02463E06F}" );
    }

    static class ThreadClass implements Runnable {
        @Override
        public void run() {
            List<IDictionary> l = new ArrayList<IDictionary>();
            for (int i = 0; i < 100000; i++) {
                IDictionary dict = createDictionary();
                if (dict == null) {
                    System.out.println("createDictionary() returned null!");
                    return;
                }

                l.add(dict);
            }
        }
    }
}

Warning: This program will consume all available CPU and RAM. After a couple of attempts, I was able to get a "createDictionary() returned null!" message on my console a few seconds after pressing the enter key.

Test computer specs:

  • com4j 20120426-2
  • 16GB RAM
  • 4 core Intel Core i7 CPU
  • Windows 7 SP1 x64
  • JDK 7 update 45 x64

Unmarshal proper types for the elements of Collections ?

Is it possible to unmarshal proper types for the elements of Collections ?

Example:
The generated Excel Workbooks interface implements Iterable<Com4jObject> instead of Iterable<_Workbook>. As far as I understand, I have to call .queryInterface(_Workbook.class) on each element manually:

for (final Com4jObject p : excel.getWorkbooks()) {
	System.out.println(p.queryInterface(_Workbook.class).getName());
}

Is it possible to get that conversion automagically? I think of something like the following...

  • I manually change the signatures of class Workbooks and its method iterator to the generic type _Workbook.

  • The above does not seem to be enough: My JVM dumps when I try that. So I think we need at least ComCollection's fetch method to call queryInterface to cast to the proper class?

Variant.java uses 32bit pointer when object() method is called

mpoindexter@f3ae351 contains a fix

The code was:

changeType(Type.VT_UNKNOWN);
int ptr = image.getInt(8);
if(ptr==0) return null;
Native.addRef(ptr);
return Wrapper.create(type,ptr);

Now it calls
convertTo(Com4JObject.class) to let the native code extract an IUnknown* out of the variant, and then does a queryInterface on the returned Com4JObject

SHDocVw: [tlbimp] Unable to handle the type (IDISPATCH)*

Hi, I am generating interfaces for Internet Explorer (SHDocVw) and some of the event interface functions are not generated, because it says it is "Unable to handle the type (IDISPATCH)*". The affected event interface is DWebBrowserEvents2 and one of the affected functions is "newWindow2".

I don't have enough knowledge at this point to be able to see if this is a missing support in com4j or some other issue. I am willing to patch com4j if it is simple enough fix.

Could anyone advise?

Many Thanks
Martin

IllegalMonitorStateException

Operating system: Windows XP
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) Client VM (build 23.3-b01, mixed mode, sharing)

What I did:

  • downloadad kohsuke-com4j-release-20120426-2-21-gb5143ce.tar.gz
  • DOS prompt at the extracted root directory
  • Run ant in this directory - builds the distribution
  • cd to build\dist
  • execute tutorial:
    java -jar tlbimp.jar -o wsh -p test.wsh %WINDIR%\system32\wshom.ocx

Result:

Exception in thread "main" java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:503)
at com4j.ComThread.execute(ComThread.java:220)
at com4j.Task.execute(Task.java:25)
at com4j.COM4J.loadTypeLibrary(COM4J.java:322)
at com4j.tlbimp.driver.Lib.getLibid(Lib.java:90)
at com4j.tlbimp.driver.Driver.addLib(Driver.java:38)
at com4j.tlbimp.driver.Main.doMain(Main.java:123)
at com4j.tlbimp.driver.Main.main(Main.java:56)

Is late binding with Com4j possible?

Hello,

looking for a solution to use Excel COM objects in Java I found Com4j. Until now I was able to implement a lot of code, but I am now encountered a problem with the CustomProperties in Excel Workbooks. Tlbimp generates correct Workbook and DocumentProperties classes, but the following command unfortunately returns "null":

DocumentProperties customDocumentProperties = workbook.customDocumentProperties().queryInterface(DocumentProperties.class);

The problem is not new and occurs also for C#. A solution for C# is described here:

Is the there described late binding approach in Com4j also possible?
Or knows someone another way to get the right DocumentProperties object?

Many Thanks!

Lars

Maven release of version 2.2?

Are there any plans to produce a maven release of the current 2.2-SNAPSHOT build?

Failing that, is there any chance of getting the latest dll binaries committed so I can build it myself without having to build the native parts?

Incorrect Date marshalling

Two issues:

Issue #1:

  1. create variant with type Date in COM
  2. get its value through com4j.
  3. the value will be off from what you generated in COM by 1 second
    Conjecture is you don't account for leap seconds while evaluating java.util.Date's time.

Issue #2:

  1. Create variant with type Date in COM with value in last days of March or October (time of switching to daylight savings time). For example "Oct 31 08:00:45 2010"
  2. get its value through com4j
  3. The value will be off from what you generated in COM by 1 hour.
    Seems there is bug with DST processing

Memory corruption on IBM Websphere 9

Hi,

When loading the DLL with IBM Websphere Application Server 9, there is a memory corruption which makes the entire application server to crush.
IBM's technical guys checked, and they said that there is a memory corruption in COM4J on the following memory area:

0x1d606250 : B1234567 ACF66C5F 00000020 00000000
0x1d606260 : B92DC7B0 00007FFF B9988CF8 00007FFF
0x1d606270 : 12219C60 00000000 1D605550 00000000
0x1d606280 : 00000000 00000000 1D69F058 00000000
0x1d606290 : 00000000 00000000 00000020 00000000
0x1d6062a0 : B92DC7B0 00007FFF B9988CF8 00007FFF
0x1d6062b0 : 0000006B 000011C0 109E0472 80002608
0x1d6062c0 : 003F005C 005C003F 003A0043 0049005C
0x1d6062d0 : 004D0042 0057005C 00620065 00700053

Kindly check :)
Thanks in advance.

COM4J throws exception - VB.Net DLL

I have a common library of about 150 functions created in VB.Net (compiled COM DLL) which I'm trying to open up to Java using com4J, but when I submit the command line entry (java -cp . -jar tlbimp.jar -o DLL2JAR -p CommonDLL c:\factory\graham_net\Graham_Net.dll) I get the following exception error…
Exception in thread "main" com4j.ExecutionException: com4j.ComException: 80029c4
a LoadTypeLib failed : Error loading type library/DLL. : .\com4j.cpp:398
at com4j.ComThread.execute(ComThread.java:203)
at com4j.Task.execute(Task.java:25)
at com4j.COM4J.loadTypeLibrary(COM4J.java:322)
at com4j.tlbimp.driver.Lib.getLibid(Lib.java:90)
at com4j.tlbimp.driver.Driver.addLib(Driver.java:38)
at com4j.tlbimp.driver.Main.doMain(Main.java:123)
at com4j.tlbimp.driver.Main.main(Main.java:56)
Caused by: com4j.ComException: 80029c4a LoadTypeLib failed : Error loading type
library/DLL. : .\com4j.cpp:398
at com4j.Native.loadTypeLibrary(Native Method)
at com4j.COM4J$2.call(COM4J.java:324)
at com4j.COM4J$2.call(COM4J.java:322)
at com4j.Task.invoke(Task.java:51)
at com4j.ComThread.run0(ComThread.java:153)
at com4j.ComThread.run(ComThread.java:134)

New Binary Build required

Could I request a new binary build since there have been a number of fixes since 2012. Im very much a Java developer (that is why Im using com4j) and don't know how to use VisualStudio and would prefer not to have to try and build it myself, If it was pure Java it would be fine but com4j is not pure Java although the user base is very much pure Java devlopers so its quite an ask to request use of Visual Basic when dont want to change anything just get a recent build of com4j

Fix for looking in win64 registry key enclosed

I found that com4j only looked in the win32 registry key but a library I used installed into the win64 registry key only. Hence I made the fix in TypeLibInfo.java:

    if(System.getProperty("os.arch").equals("amd64")) {
      try {
          fileName = Native.readRegKey(verKey+"\\"+lcid+"\\win64");
      } catch( ComException e ) {
          throw new BindingException(Messages.NO_WIN64_TYPELIB.format(libid,version),e);
      }
    } else {
      try {
          fileName = Native.readRegKey(verKey+"\\"+lcid+"\\win32");
      } catch( ComException e ) {
          throw new BindingException(Messages.NO_WIN32_TYPELIB.format(libid,version),e);
      }
    }

I also added NO_WIN64_TYPELIB in messages.java and in messages.properties, I added:
NO_WIN64_TYPELIB =
The type library "{0}" <{1}> has no win64 binary

Holder parameters not supported for IDispatch methods

com4j.ComException: 80020005 Invocation failed: (null) : Type conflict. : .\com4j.cpp:82

I am getting this exception when running com4j. I am totally stuck. Can someone give me advice how to go on?

The TLB looks like this:

    [id(0x00000003)]
    long InitMesswertkanal(
                    [in] long* lKanalHandle, 
                    [in] BSTR lPruefmittel, 
                    [in] BSTR strPruefauftrag, 
                    [in] BSTR strMerkmal, 
                    [in] BSTR strSensorverknuepfung, 
                    [in] short nMesswertberechnung, 
                    [in] long hWnd);

And here is what com4j wraps:

@DISPID(3)
int initMesswertkanal(
Holder lKanalHandle,
java.lang.String lPruefmittel,
java.lang.String strPruefauftrag,
java.lang.String strMerkmal,
java.lang.String strSensorverknuepfung,
short nMesswertberechnung,
int hWnd);

Thanks!
-Ralf

Does it support, work with java9?

I have created some java code to access a (D)COM dll which works fine with java8 x64.
When I tried to run the same code with Java9 x64 it does not work.

Does com4j support Java9?

Passing COM object by reference throws conversion error

I might be misunderstanding this, but trying to invoke a generated COM method that includes a COM object passed as a reference seems to be causing a COMException. Examining the source code, it looks like this is because the switch statement for converting parameters in invoke.cpp doesn't have a clause for the ComObject_byRef case, causing it to execute the default statement and throw an error.

Methods with return type void fail when using default values

When generateDefaultMethodOverloads is set to true, methods with return type void have a @returnvalue annotation added with index=-1.

Void methods don't need a ReturnValue annotation, even when using default values. This causes problems later as when invoking the method the runtime looks for a converter and doesn't find one.

See MethodBind.java @ line 556 and ComMethod.java @ line 96 (called indirectly from Wrapper.java @ line 179)

3rd party libraries

Thanks for your great work in building the com4j library.

We use it in an open-source project which we would like to transfer under our open-source Eclipse project. In order to do that, Eclipse foundation requires to assess the licenses of any libraries used in the project (in this case we only use com4j). Thus, they asked us to provide the source code of com4j (which we did). Moreover, they require us to point out if com4j is using any other 3rd party libraries itself that need to be assessed by them as well and check if the comply with the Eclipse Public License. However, I couldn't find any information on that. Could you please let us know if you are using any 3rd party libraries in com4j?

fresh github clone doesn't build

The project org.jvnet.com4j:com4j-test:2.0-SNAPSHOT has 1 error.
Non-resolvable parent POM: Could not find artifact org.jvnet.com4j:com4j-parent:pom:2.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 3, column 11 -> [Help 2]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.