Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some of the failing COM unittests #578

Merged
merged 5 commits into from
Feb 21, 2016

Commits on Feb 21, 2016

  1. Make REFIID a real pointer type to fix native callbacks

    After the change introduced in d7f91f1
    native callbacks for the COM handling error out (see below). Analysing the
    stack trace this happens after the java function was called. There
    structures are syncing back from java to native. I asume the calling
    programm passes in a readonly version of the IID and so the write fails.
    
    This code path was not hit before the above mentioned changeset, because
    there is a typeguard, that prevents syncing for ByValue calls (which were
    removed be the changeset).
    
    In addition to this, a fix ComEventCallbacks_Test to not depend on an
    installed office was commited. Now the Internet Explorer is used, as it
    can be expected to be present.
    
    Tests from ConnectionPointerContainer_Test duplicated a good part of
    ComEventCallbacks_Test so the cases were integrated into ComEventCallbacks_Test.
    
    The exception leading to this fix
    (CallbackReference.java:513 synchronised structed passed by reference after the java invocation):
    
    JNA: Callback com.sun.jna.platform.win32.COM.DispatchListener$1@233c0b17 threw the following exception:
    java.lang.Error: Invalid memory access
    	at com.sun.jna.Native.setInt(Native Method)
    	at com.sun.jna.Pointer.setInt(Pointer.java:1124)
    	at com.sun.jna.Pointer.setValue(Pointer.java:925)
    	at com.sun.jna.Structure.writeField(Structure.java:842)
    	at com.sun.jna.Structure.write(Structure.java:754)
    	at com.sun.jna.Structure.autoWrite(Structure.java:2047)
    	at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:513)
    	at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:528)
    	at com.sun.jna.Native.invokeInt(Native Method)
    	at com.sun.jna.Function.invoke(Function.java:390)
    	at com.sun.jna.Function.invoke(Function.java:323)
    	at com.sun.jna.Function.invoke(Function.java:275)
    	at com.sun.jna.Function.invoke(Function.java:266)
    	at com.sun.jna.platform.win32.COM.COMInvoker._invokeNativeObject(COMInvoker.java:37)
    	at com.sun.jna.platform.win32.COM.ConnectionPoint.Advise(ConnectionPoint.java:42)
    	at com.sun.jna.platform.win32.COM.ComEventCallbacks_Test.cause_Quit_Event(ComEventCallbacks_Test.java:236)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:497)
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    	at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:38)
    	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:532)
    	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1179)
    	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:1030)
    matthiasblaesing committed Feb 21, 2016
    Configuration menu
    Copy the full SHA
    95d845c View commit details
    Browse the repository at this point in the history
  2. Make (Un)marshalling context sensitive

    Depending on the context the unmarshalling of the supplied data in callbacks
    is unwrapped further than before. The NavigateComplete2 event from the interface
    DWebBrowserEvents2 demonstrates this. The URL is passed as a Variant pointing to
    a Variant containing the string. Without this fix NULL is returned.
    
    To test this ComEventCallbacks_Test.java was moved to use Internet Explorer
    instead of MS Office.
    matthiasblaesing committed Feb 21, 2016
    Configuration menu
    Copy the full SHA
    3602338 View commit details
    Browse the repository at this point in the history
  3. Move callback invocation in c.s.j.p.w.C.util.CallbackProxy into calli…

    …ng thread
    
    Dispatching the invocation of the callback handler into an executor
    makes it impossible to fill [out] parameters, as the return has already
    happend and [in] parameters can not be savely used if they are not
    marshalled to java code because the calling code will free the parameters
    after the call.
    
    To prevent deadlocks ComThread is modified to allow COM calls from the
    callback by modifying the ComThread helper to only dispatch the COM call
    into the ComThread only if the calling thread has not COM already enabled.
    
    Reference counting was modified, so that now on construction of a
    ProxyObject the reference count is AddRef'ed once and Released once on
    finalization.
    matthiasblaesing committed Feb 21, 2016
    Configuration menu
    Copy the full SHA
    334ae3f View commit details
    Browse the repository at this point in the history
  4. Correct freeing of BSTRs

    According to MSDN the caller is responsible to free BSTRs.
    matthiasblaesing committed Feb 21, 2016
    Configuration menu
    Copy the full SHA
    78e6d0f View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ad12bf7 View commit details
    Browse the repository at this point in the history