diff --git a/EventCallbacks.htm b/EventCallbacks.htm new file mode 100644 index 0000000..4859158 --- /dev/null +++ b/EventCallbacks.htm @@ -0,0 +1,283 @@ + + +
+ + + + + +Jacob can register Java classes for MS application events +or callbacks. The normal flow for this +is:
+ +1) +Application thread creates an instance of the +event handler and registers it with Jacob
+ +2) +The application continues on doing other work.
+ +3) +Some time later, the MS application takes some +action and initiates the event callback.
+ +4) +The Java VM receives the event and spins up a +new thread to handle it.
+ +5) +The Jacob EventProxy +in the dll is called by the VM.
+ +6) +The Jacob EventProxy +creates Variant objects to handle the parameters of the passed in event.
+ +7) +The Jacob EventProxy +uses reflection to map the event name to a method name with the exact same +name.
+ +8) +The Jacob EventProxy +sends the message to the registered event handler.
+ +Swing developers should note that this message comes in +on a thread other than the event thread. +All objects receiving events that require user intervention or drawing +in the UI should use invokeLater() to post requests for actions onto the event queue. Failure to do so will insure random failures +in the GUI.
+ +Java Web Start (JWS) and other launchers can have +additional issues related to the class loader. +The Jacob C++ library uses FindClass() to find the Variant class when building the parameter +list. FindClass() uses the system +class loader which includes only the classes specified at run time or in the +CLASSPATH. Most of the application +classes in this situation live in an alternate set of class loaders that were +created when the launcher located and ran the application classes. This means that the search for Variant will +fail usually with the silent and immediate termination of the Java application. The thread classloader +probably can’t be used to try and find the class because this new thread does +not have a classloader associated with it other than +the system class loader. The end result +is that the Variant class needs to be located via other means and that the +thread classloader should be set to be the context +class loader of the event handler class.
+ +The Jacob EventProxy class has +been modified (off of the 1.8 tree) so that it takes a two step approach to towards +fixing these problems.
+ ++ +
1) +EventProxy first +attempts to locate the Variant class using FindClass()
+ +2) +Failing that, it looks to see if the event +callback object implements getVariantClass() that returns the Variant.class +object. If so, it uses that class to +create variants for the callback parameters.
+ +3) +If all that fails, it logs a message and then +fails in the spectacular fashion of the previous versions.
+ +This means developers can receive call back events in JWS +other Java launching programs by implementing getVariantClass() on all of +their classes that receive Microsoft Events. +The getVariantClass() method has the added benefit of providing a spot for the +thread classloader to be set:
+ +Public Class getVariantClass(){
+ +Thread.currentThread().setContextClassLoader(
+ +this.getClass().getClassLoader());
+ +return Variant.class
+ +}
+ +There may still be a dual event queue issue in JWS +applications that needs to be looked at.
+ +haveSTA
+ */
+ public static boolean haveSTA = false;
+
+ /**
+ * Comment for mainSTA
+ */
+ public static MainSTA mainSTA = null;
+
+ /**
+ * Initialize the current java thread to be part of the Multi-threaded COM
+ * Apartment
+ */
+ public static synchronized void InitMTA() {
+ InitMTA(false);
+ }
+
+ /**
+ * Initialize the current java thread to be an STA
+ */
+ public static synchronized void InitSTA() {
+ InitSTA(false);
+ }
+
+ /**
+ * Initialize the current java thread to be part of the Multi-threaded COM
+ * Apartment, if createMainSTA is true, create a separate MainSTA thread
+ * that will house all Apartment Threaded components
+ * @param createMainSTA
+ */
+ public static synchronized void InitMTA(boolean createMainSTA) {
+ Init(createMainSTA, MTA);
+ }
+
+ /**
+ * Initialize the current java thread to be an STA COM Apartment, if
+ * createMainSTA is true, create a separate MainSTA thread that will house
+ * all Apartment Threaded components
+ * @param createMainSTA
+ */
+ public static synchronized void InitSTA(boolean createMainSTA) {
+ Init(createMainSTA, STA);
+ }
+
+ /**
+ *
+ */
+ public static synchronized void startMainSTA() {
+ mainSTA = new MainSTA();
+ haveSTA = true;
+ }
+
+ /**
+ *
+ */
+ public static synchronized void quitMainSTA() {
+ if (mainSTA != null)
+ mainSTA.quit();
+ }
+
+ /**
+ * Initialize the current java thread to be part of the MTA/STA COM
+ * Apartment
+ * @param createMainSTA
+ * @param mode
+ */
+ public static synchronized void Init(boolean createMainSTA, int mode) {
+ if (createMainSTA && !haveSTA) {
+ // if the current thread is going to be in the MTA and there
+ // is no STA thread yet, then create a main STA thread
+ // to avoid COM creating its own
+ startMainSTA();
+ }
+ //System.out.println("before Init: "+mode);
+ doCoInitialize(mode);
+ //System.out.println("after Init");
+ ROT.addThread();
+ //System.out.println("after ROT.addThread");
+ }
+
+ /**
+ * Call CoUninitialize to release this java thread from COM
+ */
+ public static synchronized void Release() {
+ //System.out.println("before clearObjects");
+ ROT.clearObjects();
+ //System.out.println("before UnInit");
+ doCoUninitialize();
+ //System.out.println("after UnInit");
+ }
+
+ /**
+ * @param threadModel
+ */
+ public static native void doCoInitialize(int threadModel);
+
+ /**
+ *
+ */
+ public static native void doCoUninitialize();
+
+ static {
+ System.loadLibrary("jacob");
+ }
+}
\ No newline at end of file
diff --git a/com/jacob/com/DispatchEvents.java b/com/jacob/com/DispatchEvents.java
index 1ef9761..a35c624 100644
--- a/com/jacob/com/DispatchEvents.java
+++ b/com/jacob/com/DispatchEvents.java
@@ -29,36 +29,50 @@
*/
package com.jacob.com;
-public class DispatchEvents extends JacobObject
-{
- int m_pConnPtProxy = 0;
+/**
+ * @author joe
+ *
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class DispatchEvents extends JacobObject {
+ int m_pConnPtProxy = 0;
- public DispatchEvents(Dispatch src, Object sink)
- {
- init(src, sink);
- }
- public DispatchEvents(Dispatch src, Object sink, String progId)
- {
- init2(src, sink,progId);
- }
+ /**
+ * @param src
+ * @param sink
+ */
+ public DispatchEvents(Dispatch src, Object sink) {
+ init(src, sink);
+ }
- // hook up a connection point proxy object
- // event methods on the sink object will be called
- // by name with a signature of m_pStream
+ */
+ public int m_pStream;
+
+ /**
+ * @param localDispatch
+ */
+ public DispatchProxy(Dispatch localDispatch) {
+ MarshalIntoStream(localDispatch);
+ }
+
+ /**
+ * @return
+ */
+ public Dispatch toDispatch() {
+ return MarshalFromStream();
+ }
+
+ private native void MarshalIntoStream(Dispatch d);
+
+ private native Dispatch MarshalFromStream();
+
+ /* (non-Javadoc)
+ * @see com.jacob.com.JacobObject#release()
+ */
+ public native void release();
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ public void finalize() {
+ if (m_pStream != 0)
+ release();
+ }
+}
\ No newline at end of file
diff --git a/com/jacob/com/EnumVariant.java b/com/jacob/com/EnumVariant.java
index 07519e7..aed37ee 100644
--- a/com/jacob/com/EnumVariant.java
+++ b/com/jacob/com/EnumVariant.java
@@ -1,122 +1,131 @@
-/*
- * Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * All rights reserved. Originator: Dan Adler (http://danadler.com).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Redistributions in any form must be accompanied by information on
- * how to obtain complete source code for the JACOB software.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jacob.com;
-
-/**
- * An implementation of IEnumVariant based on code submitted by
- * Thomas Hallgren (mailto:Thomas.Hallgren@eoncompany.com)
- */
-public class EnumVariant extends JacobObject implements java.util.Enumeration
-{
- private int m_pIEnumVARIANT;
- private final Variant[] m_recBuf = new Variant[1];
-
- // this only gets called from JNI
- //
- protected EnumVariant(int pIEnumVARIANT)
- {
- m_pIEnumVARIANT = pIEnumVARIANT;
- }
-
- public EnumVariant(Object disp)
- {
- int[] hres = new int[1];
- Variant evv = Dispatch.invokev(
- disp,
- Dispatch.DISPID_NEWENUM,
- Dispatch.Get,
- new Variant[0],
- hres);
- if(evv.getvt() != Variant.VariantObject)
- //
- // The DISPID_NEWENUM did not result in a valid object
- //
- throw new ComFailException("Can't obtain EnumVARIANT");
-
- EnumVariant tmp = evv.toEnumVariant();
- m_pIEnumVARIANT = tmp.m_pIEnumVARIANT;
- tmp.m_pIEnumVARIANT = 0;
- }
-
- /**
- * Implements java.util.Enumeration
- */
- public boolean hasMoreElements()
- {
- {
- if(m_recBuf[0] == null)
- {
- if(this.Next(m_recBuf) <= 0)
- return false;
- }
- return true;
- }
- }
-
- /**
- * Implements java.util.Enumeration
- */
- public Object nextElement()
- {
- Object last = m_recBuf[0];
- if(last == null)
- {
- if(this.Next(m_recBuf) <= 0)
- throw new java.util.NoSuchElementException();
- last = m_recBuf[0];
- }
- m_recBuf[0] = null;
- return last;
- }
-
- /**
- * Get next element in collection or null if at end
- */
- public Variant Next()
- {
- if (hasMoreElements()) return (Variant)nextElement();
- return null;
- }
-
- public native int Next(Variant[] receiverArray);
-
- public native void Skip(int count);
-
- public native void Reset();
-
- public native void release();
-
- protected void finalize()
- {
- //System.out.println("EnumVariant finalize start");
- if (m_pIEnumVARIANT != 0) this.release();
- //System.out.println("EnumVariant finalize end");
- }
-}
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ * All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Redistributions in any form must be accompanied by information on
+ * how to obtain complete source code for the JACOB software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jacob.com;
+
+/**
+ * An implementation of IEnumVariant based on code submitted by Thomas Hallgren
+ * (mailto:Thomas.Hallgren@eoncompany.com)
+ */
+public class EnumVariant extends JacobObject implements java.util.Enumeration {
+ private int m_pIEnumVARIANT;
+
+ private final Variant[] m_recBuf = new Variant[1];
+
+ // this only gets called from JNI
+ //
+ protected EnumVariant(int pIEnumVARIANT) {
+ m_pIEnumVARIANT = pIEnumVARIANT;
+ }
+
+ /**
+ * @param disp
+ */
+ public EnumVariant(Object disp) {
+ int[] hres = new int[1];
+ Variant evv = Dispatch.invokev(disp, Dispatch.DISPID_NEWENUM,
+ Dispatch.Get, new Variant[0], hres);
+ if (evv.getvt() != Variant.VariantObject)
+ //
+ // The DISPID_NEWENUM did not result in a valid object
+ //
+ throw new ComFailException("Can't obtain EnumVARIANT");
+
+ EnumVariant tmp = evv.toEnumVariant();
+ m_pIEnumVARIANT = tmp.m_pIEnumVARIANT;
+ tmp.m_pIEnumVARIANT = 0;
+ }
+
+ /**
+ * Implements java.util.Enumeration
+ * @return
+ */
+ public boolean hasMoreElements() {
+ {
+ if (m_recBuf[0] == null) {
+ if (this.Next(m_recBuf) <= 0)
+ return false;
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Implements java.util.Enumeration
+ * @return
+ */
+ public Object nextElement() {
+ Object last = m_recBuf[0];
+ if (last == null) {
+ if (this.Next(m_recBuf) <= 0)
+ throw new java.util.NoSuchElementException();
+ last = m_recBuf[0];
+ }
+ m_recBuf[0] = null;
+ return last;
+ }
+
+ /**
+ * Get next element in collection or null if at end
+ * @return
+ */
+ public Variant Next() {
+ if (hasMoreElements())
+ return (Variant) nextElement();
+ return null;
+ }
+
+ /**
+ * @param receiverArray
+ * @return
+ */
+ public native int Next(Variant[] receiverArray);
+
+ /**
+ * @param count
+ */
+ public native void Skip(int count);
+
+ /**
+ *
+ */
+ public native void Reset();
+
+ /* (non-Javadoc)
+ * @see com.jacob.com.JacobObject#release()
+ */
+ public native void release();
+
+ protected void finalize() {
+ //System.out.println("EnumVariant finalize start");
+ if (m_pIEnumVARIANT != 0)
+ this.release();
+ //System.out.println("EnumVariant finalize end");
+ }
+}
\ No newline at end of file
diff --git a/com/jacob/com/JacobObject.java b/com/jacob/com/JacobObject.java
index 4685eb4..51dffe9 100644
--- a/com/jacob/com/JacobObject.java
+++ b/com/jacob/com/JacobObject.java
@@ -1,46 +1,52 @@
-/*
- * Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * All rights reserved. Originator: Dan Adler (http://danadler.com).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Redistributions in any form must be accompanied by information on
- * how to obtain complete source code for the JACOB software.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jacob.com;
-
-/**
- * All COM object created by JACOB extend this class so that
- * we can automatically release them when the thread is detached from
- * COM - if we leave it to the finalizer it will call the release from
- * another thread, which may result in a segmentation violation.
- */
-public class JacobObject
-{
- public JacobObject()
- {
- ROT.addObject(this);
- }
-
- public void release() {}
-}
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ * All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Redistributions in any form must be accompanied by information on
+ * how to obtain complete source code for the JACOB software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jacob.com;
+
+/**
+ * All COM object created by JACOB extend this class so that we can
+ * automatically release them when the thread is detached from COM - if we leave
+ * it to the finalizer it will call the release from another thread, which may
+ * result in a segmentation violation.
+ */
+public class JacobObject {
+ /**
+ * Standard constructor
+ */
+ public JacobObject() {
+ ROT.addObject(this);
+ }
+
+ /**
+ *
+ */
+ public void release() {
+ // currently does nothing
+ }
+}
\ No newline at end of file
diff --git a/com/jacob/com/MainSTA.java b/com/jacob/com/MainSTA.java
index b1e4c79..8cac13a 100644
--- a/com/jacob/com/MainSTA.java
+++ b/com/jacob/com/MainSTA.java
@@ -1,43 +1,42 @@
-/*
- * Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * All rights reserved. Originator: Dan Adler (http://danadler.com).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Redistributions in any form must be accompanied by information on
- * how to obtain complete source code for the JACOB software.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jacob.com;
-
-/**
- * We provide our own main sta thread to avoid COM tagging a random
- * thread as the main STA - this is the thread in which all Apartment
- * threaded components will be created if the client chooses an MTA
- * threading model for the java side of the app.
- */
-public class MainSTA extends STA
-{
- static {
- System.loadLibrary("jacob");
- }
-}
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ * All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Redistributions in any form must be accompanied by information on
+ * how to obtain complete source code for the JACOB software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jacob.com;
+
+/**
+ * We provide our own main sta thread to avoid COM tagging a random
+ * thread as the main STA - this is the thread in which all Apartment
+ * threaded components will be created if the client chooses an MTA
+ * threading model for the java side of the app.
+ */
+public class MainSTA extends STA {
+ static {
+ System.loadLibrary("jacob");
+ }
+}
\ No newline at end of file
diff --git a/com/jacob/com/ROT.java b/com/jacob/com/ROT.java
index ac7704d..e706219 100644
--- a/com/jacob/com/ROT.java
+++ b/com/jacob/com/ROT.java
@@ -1,99 +1,92 @@
-/*
- * Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * All rights reserved. Originator: Dan Adler (http://danadler.com).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Redistributions in any form must be accompanied by information on
- * how to obtain complete source code for the JACOB software.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jacob.com;
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * The Running Object Table (ROT) maps each thread to a vector of
- * all the JacobObjects that were created in that thread. It always
- * operates on the current thread so all the methods are static and
- * they implicitly get the current thread.
- * Conceptually, this is similar to the ThreadLocal class of Java 1.2
- * but we are also supporting Java 1.6
- * The clearObjects method is used to release all the COM objects
- * created by Jacob in the current thread prior to uninitializing COM
- * for that thread. If we leave this job to the garbage collector,
- * then finalize might get called from a separate thread which is not
- * initialized for COM, and also the component itself may have been
- * freed.
- */
-public abstract class ROT
-{
- private static Hashtable rot = new Hashtable();
-
- protected static void addThread()
- {
- String t_name = Thread.currentThread().getName();
- if (rot.contains(t_name)) return;
- Vector v = new Vector();
- rot.put(t_name, v);
- }
-
- protected static void clearObjects()
- {
- String t_name = Thread.currentThread().getName();
- Vector v = (Vector)rot.get(t_name);
- if (v != null)
- {
- while (!v.isEmpty())
- {
- JacobObject o = (JacobObject)v.elementAt(0);
- //System.out.println(t_name + " release:"+o+"->"+o.getClass().getName());
- if (o != null) o.release();
- v.removeElementAt(0);
- }
- rot.remove(t_name);
- }
- }
-
- protected static void addObject(JacobObject o)
- {
- String t_name = Thread.currentThread().getName();
- //System.out.println(t_name + " add:"+o+"->"+o.getClass().getName());
- Vector v = (Vector)rot.get(t_name);
- if (v == null)
- {
- // this thread has not been initialized as a COM thread
- // so make it part of MTA for backwards compatibility
- ComThread.InitMTA(false);
- addThread();
- v = (Vector)rot.get(t_name);
- }
- if (v != null)
- {
- v.addElement(o);
- }
- }
-
- static {
- System.loadLibrary("jacob");
- }
-}
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ * All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Redistributions in any form must be accompanied by information on
+ * how to obtain complete source code for the JACOB software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jacob.com;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * The Running Object Table (ROT) maps each thread to a vector of all the
+ * JacobObjects that were created in that thread. It always operates on the
+ * current thread so all the methods are static and they implicitly get the
+ * current thread. Conceptually, this is similar to the ThreadLocal class of
+ * Java 1.2 but we are also supporting Java 1.6 The clearObjects method is used
+ * to release all the COM objects created by Jacob in the current thread prior
+ * to uninitializing COM for that thread. If we leave this job to the garbage
+ * collector, then finalize might get called from a separate thread which is not
+ * initialized for COM, and also the component itself may have been freed.
+ */
+public abstract class ROT {
+ private static Hashtable rot = new Hashtable();
+
+ protected static void addThread() {
+ String t_name = Thread.currentThread().getName();
+ if (rot.contains(t_name))
+ return;
+ Vector v = new Vector();
+ rot.put(t_name, v);
+ }
+
+ protected static void clearObjects() {
+ String t_name = Thread.currentThread().getName();
+ Vector v = (Vector) rot.get(t_name);
+ if (v != null) {
+ while (!v.isEmpty()) {
+ JacobObject o = (JacobObject) v.elementAt(0);
+ //System.out.println(t_name + "
+ // release:"+o+"->"+o.getClass().getName());
+ if (o != null)
+ o.release();
+ v.removeElementAt(0);
+ }
+ rot.remove(t_name);
+ }
+ }
+
+ protected static void addObject(JacobObject o) {
+ String t_name = Thread.currentThread().getName();
+ //System.out.println(t_name + " add:"+o+"->"+o.getClass().getName());
+ Vector v = (Vector) rot.get(t_name);
+ if (v == null) {
+ // this thread has not been initialized as a COM thread
+ // so make it part of MTA for backwards compatibility
+ ComThread.InitMTA(false);
+ addThread();
+ v = (Vector) rot.get(t_name);
+ }
+ if (v != null) {
+ v.addElement(o);
+ }
+ }
+
+ static {
+ System.loadLibrary("jacob");
+ }
+}
\ No newline at end of file
diff --git a/com/jacob/com/STA.java b/com/jacob/com/STA.java
index 08fb89d..1407ba0 100644
--- a/com/jacob/com/STA.java
+++ b/com/jacob/com/STA.java
@@ -1,98 +1,104 @@
-/*
- * Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * All rights reserved. Originator: Dan Adler (http://danadler.com).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Redistributions in any form must be accompanied by information on
- * how to obtain complete source code for the JACOB software.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jacob.com;
-
-/**
- * A class that implements a Single Threaded Apartment.
- * Users will subclass this and override OnInit() and OnQuit()
- * where they will create and destroy a COM component that wants to
- * run in an STA other than the main STA.
- */
-public class STA extends Thread
-{
- public int threadID;
-
- public STA()
- {
- start(); // start the thread
- }
-
- public void run()
- {
- // init COM
- ComThread.InitSTA();
- if (OnInit())
- {
- // this call blocks in the win32 message loop
- // until quitMessagePump is called
- doMessagePump();
- }
- OnQuit();
- // uninit COM
- ComThread.Release();
- }
-
- /**
- * Override this method to create and initialize any COM
- * component that you want to run in this thread. If anything
- * fails, return false to terminate the thread.
- */
- public boolean OnInit()
- {
- return true;
- }
-
- /**
- * Override this method to destroy any resource
- * before the thread exits and COM in uninitialized
- */
- public void OnQuit()
- {
- }
-
- public void quit()
- {
- quitMessagePump();
- }
-
- /**
- * run a message pump for the main STA
- */
- public native void doMessagePump();
-
- /**
- * quit message pump for the main STA
- */
- public native void quitMessagePump();
-
- static {
- System.loadLibrary("jacob");
- }
-}
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ * All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Redistributions in any form must be accompanied by information on
+ * how to obtain complete source code for the JACOB software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jacob.com;
+
+/**
+ * A class that implements a Single Threaded Apartment. Users will subclass this
+ * and override OnInit() and OnQuit() where they will create and destroy a COM
+ * component that wants to run in an STA other than the main STA.
+ */
+public class STA extends Thread {
+ /**
+ * TODO: no references exist to this. should it be dropped
+ */
+ public int threadID;
+
+ /**
+ * constructor for STA
+ */
+ public STA() {
+ start(); // start the thread
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Thread#run()
+ */
+ public void run() {
+ // init COM
+ ComThread.InitSTA();
+ if (OnInit()) {
+ // this call blocks in the win32 message loop
+ // until quitMessagePump is called
+ doMessagePump();
+ }
+ OnQuit();
+ // uninit COM
+ ComThread.Release();
+ }
+
+ /**
+ * Override this method to create and initialize any COM component that you
+ * want to run in this thread. If anything fails, return false to terminate
+ * the thread.
+ * @return always returns true
+ */
+ public boolean OnInit() {
+ return true;
+ }
+
+ /**
+ * Override this method to destroy any resource before the thread exits and
+ * COM in uninitialized
+ */
+ public void OnQuit() {
+ // there is nothing to see here
+ }
+
+ /**
+ * calls quitMessagePump
+ */
+ public void quit() {
+ quitMessagePump();
+ }
+
+ /**
+ * run a message pump for the main STA
+ */
+ public native void doMessagePump();
+
+ /**
+ * quit message pump for the main STA
+ */
+ public native void quitMessagePump();
+
+ static {
+ System.loadLibrary("jacob");
+ }
+}
\ No newline at end of file
diff --git a/com/jacob/com/SafeArray.java b/com/jacob/com/SafeArray.java
index dc561aa..4c5e2a9 100644
--- a/com/jacob/com/SafeArray.java
+++ b/com/jacob/com/SafeArray.java
@@ -1,247 +1,659 @@
-/*
- * Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * All rights reserved. Originator: Dan Adler (http://danadler.com).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Redistributions in any form must be accompanied by information on
- * how to obtain complete source code for the JACOB software.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jacob.com;
-
-public class SafeArray extends JacobObject
-{
- int m_pV = 0;
-
- public SafeArray() {}
-
- public SafeArray(int vt)
- {
- init(vt, new int[] {0}, new int[] {-1});
- }
-
- public SafeArray(int vt,int celems)
- {
- init(vt, new int[] {0}, new int[] {celems});
- }
-
- public SafeArray(int vt,int celems1,int celems2)
- {
- init(vt, new int[] {0,0}, new int[] {celems1, celems2});
- }
-
- public SafeArray(int vt,int lbounds[],int celems[])
- {
- init(vt, lbounds, celems);
- }
-
- // convert a string to a VT_UI1 array
- public SafeArray(String s)
- {
- char[] ca = s.toCharArray();
- init(Variant.VariantByte, new int[] {0}, new int[] {ca.length});
- fromCharArray(ca);
- }
-
- protected native void init(int vt, int lbounds[], int celems[]);
-
- // not impl
- public int getNumLocks() { return 0; }
-
- // convert a VT_UI1 array to string
- public String asString()
- {
- if (getvt() != Variant.VariantByte) return null;
- char ja[] = toCharArray();
- return new String(ja);
- }
-
-
- public native Object clone();
- // call this to explicitly release the com object before gc
-
- public void release()
- {
- destroy();
- }
-
- public native void destroy();
- public native int getvt();
- protected void finalize()
- {
- //System.out.println("SafeArray finalize start");
- if (m_pV != 0) release();
- //System.out.println("SafeArray finalize end");
- }
- public native void reinit(SafeArray sa);
- public native void reinterpretType(int vt);
-
- public native int getLBound();
- public native int getLBound(int dim);
- public native int getUBound();
- public native int getUBound(int dim);
-
- public native int getNumDim();
- public native int getFeatures();
- public native int getElemSize();
-
- public native void fromCharArray(char ja[]);
- public native void fromIntArray(int ja[]);
- public native void fromShortArray(short ja[]);
- public native void fromDoubleArray(double ja[]);
- public native void fromStringArray(String ja[]);
- public native void fromByteArray(byte ja[]);
- public native void fromFloatArray(float ja[]);
- public native void fromBooleanArray(boolean ja[]);
- public native void fromVariantArray(Variant ja[]);
-
- public native char[] toCharArray();
- public native int[] toIntArray();
- public native short[] toShortArray();
- public native double[] toDoubleArray();
- public native String[] toStringArray();
- public native byte[] toByteArray();
- public native float[] toFloatArray();
- public native boolean[] toBooleanArray();
- public native Variant[] toVariantArray();
-
- // char access
- public native char getChar(int sa_idx);
- public native char getChar(int sa_idx1, int sa_idx2);
- public native void setChar(int sa_idx, char c);
- public native void setChar(int sa_idx1, int sa_idx2, char c);
- public native void getChars(int sa_idx, int nelems, char ja[], int ja_start);
- public native void setChars(int sa_idx, int nelems, char ja[], int ja_start);
-
- // int access
- public native int getInt(int sa_idx);
- public native int getInt(int sa_idx1, int sa_idx2);
- public native void setInt(int sa_idx, int c);
- public native void setInt(int sa_idx1, int sa_idx2, int c);
- public native void getInts(int sa_idx, int nelems, int ja[], int ja_start);
- public native void setInts(int sa_idx, int nelems, int ja[], int ja_start);
-
- // short access
- public native short getShort(int sa_idx);
- public native short getShort(int sa_idx1, int sa_idx2);
- public native void setShort(int sa_idx, short c);
- public native void setShort(int sa_idx1, int sa_idx2, short c);
- public native void getShorts(int sa_idx, int nelems, short ja[], int ja_start);
- public native void setShorts(int sa_idx, int nelems, short ja[], int ja_start);
-
- // double access
- public native double getDouble(int sa_idx);
- public native double getDouble(int sa_idx1, int sa_idx2);
- public native void setDouble(int sa_idx, double c);
- public native void setDouble(int sa_idx1, int sa_idx2, double c);
- public native void getDoubles(int sa_idx, int nelems, double ja[], int ja_start);
- public native void setDoubles(int sa_idx, int nelems, double ja[], int ja_start);
-
- // string access
- public native String getString(int sa_idx);
- public native String getString(int sa_idx1, int sa_idx2);
- public native void setString(int sa_idx, String c);
- public native void setString(int sa_idx1, int sa_idx2, String c);
- public native void getStrings(int sa_idx, int nelems, String ja[], int ja_start);
- public native void setStrings(int sa_idx, int nelems, String ja[], int ja_start);
-
- // byte access
- public native byte getByte(int sa_idx);
- public native byte getByte(int sa_idx1, int sa_idx2);
- public native void setByte(int sa_idx, byte c);
- public native void setByte(int sa_idx1, int sa_idx2, byte c);
- public native void getBytes(int sa_idx, int nelems, byte ja[], int ja_start);
- public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start);
-
- // float access
- public native float getFloat(int sa_idx);
- public native float getFloat(int sa_idx1, int sa_idx2);
- public native void setFloat(int sa_idx, float c);
- public native void setFloat(int sa_idx1, int sa_idx2, float c);
- public native void getFloats(int sa_idx, int nelems, float ja[], int ja_start);
- public native void setFloats(int sa_idx, int nelems, float ja[], int ja_start);
-
- // boolean access
- public native boolean getBoolean(int sa_idx);
- public native boolean getBoolean(int sa_idx1, int sa_idx2);
- public native void setBoolean(int sa_idx, boolean c);
- public native void setBoolean(int sa_idx1, int sa_idx2, boolean c);
- public native void getBooleans(int sa_idx, int nelems, boolean ja[], int ja_start);
- public native void setBooleans(int sa_idx, int nelems, boolean ja[], int ja_start);
-
- // variant access
- public native Variant getVariant(int sa_idx);
- public native Variant getVariant(int sa_idx1, int sa_idx2);
- public native void setVariant(int sa_idx, Variant c);
- public native void setVariant(int sa_idx1, int sa_idx2, Variant c);
- public native void getVariants(int sa_idx, int nelems, Variant ja[], int ja_start);
- public native void setVariants(int sa_idx, int nelems, Variant ja[], int ja_start);
-
- public String toString()
- {
- String s = "";
- int ndim = getNumDim();
- if (ndim == 1)
- {
- int ldim = getLBound();
- int udim = getUBound();
- for (int i = ldim; i <= udim; i++)
- {
- Variant v = getVariant(i);
-
- if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v.getvt())
- {
- return s + "[" + v.toSafeArray().toString() + "]";
- }
- else
- {
- s += " " + v.toString();
- }
- }
- }
- else if (ndim == 2)
- {
- int ldim1 = getLBound(1);
- int udim1 = getUBound(1);
-
- int ldim2 = getLBound(2);
- int udim2 = getUBound(2);
-
- for (int i = ldim1; i <= udim1; i++)
- {
- for (int j = ldim2; j <= udim2; j++)
- {
- Variant v = getVariant(i, j);
- s += " " + v.toString();
- }
- s += "\n";
- }
- }
- return s;
- }
-
- static {
- System.loadLibrary("jacob");
- }
-
-}
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
+ * Originator: Dan Adler (http://danadler.com).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. Redistributions in any form must
+ * be accompanied by information on how to obtain complete source code for the
+ * JACOB software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jacob.com;
+
+/**
+ * @author joe
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SafeArray extends JacobObject {
+ int m_pV = 0;
+
+ /**
+ * constructor
+ *
+ */
+ public SafeArray() {
+ }
+
+ /**
+ * constructor
+ * @param vt
+ */
+ public SafeArray(int vt) {
+ init(vt, new int[] { 0 }, new int[] { -1 });
+ }
+
+ /**
+ * constructor
+ * @param vt
+ * @param celems
+ */
+ public SafeArray(int vt, int celems) {
+ init(vt, new int[] { 0 }, new int[] { celems });
+ }
+
+ /**
+ * @param vt
+ * @param celems1
+ * @param celems2
+ */
+ public SafeArray(int vt, int celems1, int celems2) {
+ init(vt, new int[] { 0, 0 }, new int[] { celems1, celems2 });
+ }
+
+ /**
+ * constructor
+ * @param vt
+ * @param lbounds
+ * @param celems
+ */
+ public SafeArray(int vt, int lbounds[], int celems[]) {
+ init(vt, lbounds, celems);
+ }
+
+ /**
+ * convert a string to a VT_UI1 array
+ * @param s source string
+ */
+ public SafeArray(String s) {
+ char[] ca = s.toCharArray();
+ init(Variant.VariantByte, new int[] { 0 }, new int[] { ca.length });
+ fromCharArray(ca);
+ }
+
+ protected native void init(int vt, int lbounds[], int celems[]);
+
+ /**
+ * not impl
+ * @return 0
+ */
+ public int getNumLocks() {
+ return 0;
+ }
+
+ /**
+ * convert a VT_UI1 array to string
+ * @return variant byte as a string
+ */
+ public String asString() {
+ if (getvt() != Variant.VariantByte)
+ return null;
+ char ja[] = toCharArray();
+ return new String(ja);
+ }
+
+ public native Object clone();
+
+
+ /**
+ * call this to explicitly release the com object before gc
+ */
+ public void release() {
+ destroy();
+ }
+
+ public native void destroy();
+
+ public native int getvt();
+
+ protected void finalize() {
+ //System.out.println("SafeArray finalize start");
+ if (m_pV != 0)
+ release();
+ //System.out.println("SafeArray finalize end");
+ }
+
+ public native void reinit(SafeArray sa);
+
+ public native void reinterpretType(int vt);
+
+ public native int getLBound();
+
+ public native int getLBound(int dim);
+
+ public native int getUBound();
+
+ public native int getUBound(int dim);
+
+ public native int getNumDim();
+
+ public native int getFeatures();
+
+ public native int getElemSize();
+
+ public native void fromCharArray(char ja[]);
+
+ public native void fromIntArray(int ja[]);
+
+ public native void fromShortArray(short ja[]);
+
+ public native void fromDoubleArray(double ja[]);
+
+ public native void fromStringArray(String ja[]);
+
+ public native void fromByteArray(byte ja[]);
+
+ public native void fromFloatArray(float ja[]);
+
+ public native void fromBooleanArray(boolean ja[]);
+
+ public native void fromVariantArray(Variant ja[]);
+
+ public native char[] toCharArray();
+
+ public native int[] toIntArray();
+
+ public native short[] toShortArray();
+
+ public native double[] toDoubleArray();
+
+ public native String[] toStringArray();
+
+ public native byte[] toByteArray();
+
+ public native float[] toFloatArray();
+
+ public native boolean[] toBooleanArray();
+
+ public native Variant[] toVariantArray();
+
+ /**
+ * char access
+ * @param sa_idx
+ * @return
+ */
+ public native char getChar(int sa_idx);
+
+ /**
+ * char access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native char getChar(int sa_idx1, int sa_idx2);
+
+ /**
+ * char access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setChar(int sa_idx, char c);
+
+ /**
+ * char access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setChar(int sa_idx1, int sa_idx2, char c);
+
+ /**
+ * char access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getChars(int sa_idx, int nelems, char ja[], int ja_start);
+
+ /**
+ * char access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setChars(int sa_idx, int nelems, char ja[], int ja_start);
+
+ /**
+ * int access
+ * @param sa_idx
+ * @return
+ */
+ public native int getInt(int sa_idx);
+
+ /**
+ * int access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native int getInt(int sa_idx1, int sa_idx2);
+
+ /**
+ * int access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setInt(int sa_idx, int c);
+
+ /**
+ * int access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setInt(int sa_idx1, int sa_idx2, int c);
+
+ /**
+ * int access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getInts(int sa_idx, int nelems, int ja[], int ja_start);
+
+ /**
+ * int access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setInts(int sa_idx, int nelems, int ja[], int ja_start);
+
+ /**
+ * short access
+ * @param sa_idx
+ * @return
+ */
+ public native short getShort(int sa_idx);
+
+ /**
+ * short access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native short getShort(int sa_idx1, int sa_idx2);
+
+ /**
+ * short access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setShort(int sa_idx, short c);
+
+ /**
+ * short access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setShort(int sa_idx1, int sa_idx2, short c);
+
+ /**
+ * short access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getShorts(int sa_idx, int nelems, short ja[],
+ int ja_start);
+
+ /**
+ * short access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setShorts(int sa_idx, int nelems, short ja[],
+ int ja_start);
+
+ /**
+ * double access
+ * @param sa_idx
+ * @return
+ */
+ public native double getDouble(int sa_idx);
+
+ /**
+ * double access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native double getDouble(int sa_idx1, int sa_idx2);
+
+ /**
+ * double access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setDouble(int sa_idx, double c);
+
+ /**
+ * double access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setDouble(int sa_idx1, int sa_idx2, double c);
+
+ /**
+ * double access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getDoubles(int sa_idx, int nelems, double ja[],
+ int ja_start);
+
+ /**
+ * double access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setDoubles(int sa_idx, int nelems, double ja[],
+ int ja_start);
+
+ /**
+ * string access
+ * @param sa_idx
+ * @return
+ */
+ public native String getString(int sa_idx);
+
+ /**
+ * string access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native String getString(int sa_idx1, int sa_idx2);
+
+ /**
+ * string access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setString(int sa_idx, String c);
+
+ /**
+ * string access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setString(int sa_idx1, int sa_idx2, String c);
+
+ /**
+ * string access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getStrings(int sa_idx, int nelems, String ja[],
+ int ja_start);
+
+ /**
+ * string access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setStrings(int sa_idx, int nelems, String ja[],
+ int ja_start);
+
+ /**
+ * byte access
+ * @param sa_idx
+ * @return
+ */
+ public native byte getByte(int sa_idx);
+
+ /**
+ * byte access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native byte getByte(int sa_idx1, int sa_idx2);
+
+ /**
+ * byte access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setByte(int sa_idx, byte c);
+
+ /**
+ * byte access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setByte(int sa_idx1, int sa_idx2, byte c);
+
+ public native void getBytes(int sa_idx, int nelems, byte ja[], int ja_start);
+
+ public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start);
+
+ /**
+ * float access
+ * @param sa_idx
+ * @return
+ */
+ public native float getFloat(int sa_idx);
+
+ /**
+ * float access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native float getFloat(int sa_idx1, int sa_idx2);
+
+ /**
+ * float access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setFloat(int sa_idx, float c);
+
+ /**
+ * float access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setFloat(int sa_idx1, int sa_idx2, float c);
+
+ /**
+ * float access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getFloats(int sa_idx, int nelems, float ja[],
+ int ja_start);
+
+ /**
+ * float access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setFloats(int sa_idx, int nelems, float ja[],
+ int ja_start);
+
+ /**
+ * boolean access
+ * @param sa_idx
+ * @return
+ */
+ public native boolean getBoolean(int sa_idx);
+
+ /**
+ * boolean access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native boolean getBoolean(int sa_idx1, int sa_idx2);
+
+ /**
+ * boolean access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setBoolean(int sa_idx, boolean c);
+
+ /**
+ * boolean access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setBoolean(int sa_idx1, int sa_idx2, boolean c);
+
+ /**
+ * boolean access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getBooleans(int sa_idx, int nelems, boolean ja[],
+ int ja_start);
+
+ /**
+ * boolean access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setBooleans(int sa_idx, int nelems, boolean ja[],
+ int ja_start);
+
+ /**
+ * variant access
+ * @param sa_idx
+ * @return
+ */
+ public native Variant getVariant(int sa_idx);
+
+ /**
+ * variant access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @return
+ */
+ public native Variant getVariant(int sa_idx1, int sa_idx2);
+
+ /**
+ * variant access
+ * @param sa_idx
+ * @param c
+ */
+ public native void setVariant(int sa_idx, Variant c);
+
+ /**
+ * variant access
+ * @param sa_idx1
+ * @param sa_idx2
+ * @param c
+ */
+ public native void setVariant(int sa_idx1, int sa_idx2, Variant c);
+
+ /**
+ * variant access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void getVariants(int sa_idx, int nelems, Variant ja[],
+ int ja_start);
+
+ /**
+ * variant access
+ * @param sa_idx
+ * @param nelems
+ * @param ja
+ * @param ja_start
+ */
+ public native void setVariants(int sa_idx, int nelems, Variant ja[],
+ int ja_start);
+
+ /**
+ * standard toString
+ * @return
+ */
+ public String toString() {
+ String s = "";
+ int ndim = getNumDim();
+ if (ndim == 1) {
+ int ldim = getLBound();
+ int udim = getUBound();
+ for (int i = ldim; i <= udim; i++) {
+ Variant v = getVariant(i);
+
+ if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v
+ .getvt()) {
+ return s + "[" + v.toSafeArray().toString() + "]";
+ } else {
+ s += " " + v.toString();
+ }
+ }
+ } else if (ndim == 2) {
+ int ldim1 = getLBound(1);
+ int udim1 = getUBound(1);
+
+ int ldim2 = getLBound(2);
+ int udim2 = getUBound(2);
+
+ for (int i = ldim1; i <= udim1; i++) {
+ for (int j = ldim2; j <= udim2; j++) {
+ Variant v = getVariant(i, j);
+ s += " " + v.toString();
+ }
+ s += "\n";
+ }
+ }
+ return s;
+ }
+
+ static {
+ System.loadLibrary("jacob");
+ }
+
+}
\ No newline at end of file
diff --git a/com/jacob/com/WrongThreadException.java b/com/jacob/com/WrongThreadException.java
index 4b79b7f..863af7e 100644
--- a/com/jacob/com/WrongThreadException.java
+++ b/com/jacob/com/WrongThreadException.java
@@ -1,37 +1,48 @@
-/*
- * Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * All rights reserved. Originator: Dan Adler (http://danadler.com).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Redistributions in any form must be accompanied by information on
- * how to obtain complete source code for the JACOB software.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jacob.com;
-
-public class WrongThreadException extends RuntimeException
-{
- // Constructors
- public WrongThreadException() { super(); }
- public WrongThreadException(String s) { super(s); }
-}
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
+ * Originator: Dan Adler (http://danadler.com).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. Redistributions in any form must
+ * be accompanied by information on how to obtain complete source code for the
+ * JACOB software.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jacob.com;
+
+/**
+ * TODO: Exception thrown when? No references found
+ */
+public class WrongThreadException extends RuntimeException {
+ /**
+ * standard 0 arg constructor with no message
+ *
+ */
+ public WrongThreadException() {
+ super();
+ }
+
+ /**
+ * standard constructor with a string message
+ * @param s
+ */
+ public WrongThreadException(String s) {
+ super(s);
+ }
+}
\ No newline at end of file
diff --git a/jni/EventProxy.cpp b/jni/EventProxy.cpp
index 7bcbb92..bc75b7b 100644
--- a/jni/EventProxy.cpp
+++ b/jni/EventProxy.cpp
@@ -35,18 +35,28 @@ EventProxy::EventProxy(JNIEnv *env, jobject aSinkObj,
IID eid, CComBSTR mName[], DISPID mID[], int mNum) :
m_cRef(0), pCP(pConn),
eventIID(eid), MethNum(mNum), MethName(mName),
- MethID(mID), JMethID(NULL), javaSinkClass(NULL)
+ MethID(mID), JMethID(NULL), javaSinkClass(NULL),
+ variantClassMethod(NULL)
{
javaSinkObj = env->NewGlobalRef(aSinkObj);
+ if (env->ExceptionOccurred()) { env->ExceptionDescribe();}
// we need this to attach to the event invocation thread
env->GetJavaVM(&jvm);
+ if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
AddRef();
HRESULT hr = pCP->Advise(this, &dwEventCookie);
if (SUCCEEDED(hr)) {
// create a mapping from the DISPID's to jmethodID's by using
// the method names I extracted from the classinfo
JMethID = new jmethodID[MethNum];
+
javaSinkClass = env->GetObjectClass(javaSinkObj);
+ if (javaSinkClass == NULL){ printf("can't figure out java sink class"); }
+ if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
+ variantClassMethod = env->GetMethodID(javaSinkClass, "getVariantClass", "()Ljava/lang/Class;");
+ if (env->ExceptionOccurred()) { env->ExceptionDescribe(); }
+ if (variantClassMethod == NULL) { printf("variantClassMethod == null\n"); }
+
const char *method;
for(int i=0;i