diff options
author | Stephan Bergmann <sb@openoffice.org> | 2002-12-06 10:35:41 +0000 |
---|---|---|
committer | Stephan Bergmann <sb@openoffice.org> | 2002-12-06 10:35:41 +0000 |
commit | 347cf26141e3b3da5a062ece1978123f6a6705b1 (patch) | |
tree | 4b5b094262d8d460a41b9325c55da5f2060c4e2c | |
parent | 726ff22056a085a7ebcd59a8e42dff0c6d80f515 (diff) |
#105077#
-rw-r--r-- | jvmaccess/inc/jvmaccess/virtualmachine.hxx | 190 | ||||
-rw-r--r-- | jvmaccess/prj/build.lst | 3 | ||||
-rw-r--r-- | jvmaccess/prj/d.lst | 6 | ||||
-rw-r--r-- | jvmaccess/source/makefile.mk | 73 | ||||
-rw-r--r-- | jvmaccess/source/virtualmachine.cxx | 193 | ||||
-rw-r--r-- | jvmaccess/util/cc5_solaris_sparc.map | 17 | ||||
-rw-r--r-- | jvmaccess/util/makefile.mk | 94 | ||||
-rw-r--r-- | jvmaccess/util/msvc_win32_intel.map | 14 | ||||
-rw-r--r-- | jvmaccess/workbench/exceptiontest1.cxx | 80 | ||||
-rw-r--r-- | jvmaccess/workbench/exceptiontest2.cxx | 80 | ||||
-rw-r--r-- | jvmaccess/workbench/java/TestComponent.java | 138 | ||||
-rw-r--r-- | jvmaccess/workbench/java/makefile.mk | 80 | ||||
-rw-r--r-- | jvmaccess/workbench/java/manifest | 1 | ||||
-rw-r--r-- | jvmaccess/workbench/makefile.mk | 85 |
14 files changed, 1054 insertions, 0 deletions
diff --git a/jvmaccess/inc/jvmaccess/virtualmachine.hxx b/jvmaccess/inc/jvmaccess/virtualmachine.hxx new file mode 100644 index 000000000..3fd8f1728 --- /dev/null +++ b/jvmaccess/inc/jvmaccess/virtualmachine.hxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * $RCSfile: virtualmachine.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sb $ $Date: 2002-12-06 11:33:26 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#if !defined INCLUDED_JVMACCESS_VIRTUALMACHINE_HXX +#define INCLUDED_JVMACCESS_VIRTUALMACHINE_HXX + +#include "rtl/ref.hxx" +#include "salhelper/simplereferenceobject.hxx" + +#include "jni.h" + +namespace jvmaccess { + +/** An encapsulating wrapper around a Java virtual machine. + */ +class VirtualMachine: public salhelper::SimpleReferenceObject +{ +public: + /** A helper to attach a thread to a Java virtual machine. + + @descr + Upon construction of a guard the current thread is attached to the + virtual machine, and upon destruction of the guard the thread is + detached again. For any one thread, multiple instances of this class + may be used in a stack-like fashion (care is taken to only really + detach the thread from the virtual machine upon destruction of the guard + at the bottom of the stack). + */ + class AttachGuard + { + public: + /** An exception indicating failure to create an AttachGuard. + */ + class CreationException + { + public: + CreationException(); + + CreationException(CreationException const &); + + virtual ~CreationException(); + + CreationException & operator =(CreationException const &); + }; + + /** Attach the current thread to a virtual machine. + + @param rMachine + The virtual machine to attach to. + + @exception CreationException + Thrown in case attaching fails (due to a JNI problem). + */ + explicit AttachGuard(rtl::Reference< VirtualMachine > const & rMachine); + + /** Detach the current thread from the virtual machine again. + */ + ~AttachGuard(); + + /** Get a JNI environment pointer for the current thread. + + @return + A valid JNI environment pointer. Will never be null. + */ + inline JNIEnv * getEnvironment() const { return m_pEnvironment; } + + private: + AttachGuard(AttachGuard &); // not implemented + void operator =(AttachGuard); // not implemented + + rtl::Reference< VirtualMachine > m_xMachine; + JNIEnv * m_pEnvironment; + bool m_bDetach; + }; + + /** Create a wrapper around a Java virtual machine. + + @param pVm + A JNI pointer to virtual machine. Must not be null. + + @param nVersion + The JNI version of the virtual machine pointed to by pVm. Must be at + least JNI_VERSION_1_2. + + @param bDestroy + Whether to destroy the virtual machine when destructing the wrapper + (i.e., whether the wrapper owns the virtual machine pointed to by pVm). + + @param pMainThreadEnv + A valid JNI environment pointer for the current thread; must not be + null. The current thread must be "initially attached" to the virtual + machine while this constructor is being called (i.e., it must be the + thread that has called JNI_CreateJavaVM in case the virtual machine has + been started via the JNI Invocation API, and it must not already have + called DetachCurrentThread; or it must be executing native code called + from a "primordial" virtual machine). This environment pointer is used + to obtain a reference to the thread's current context class loader + (java.lang.Thread.getCurrentClassLoader). If later a native thread is + attached to the virtual machine, that thread's context class loader + would be null, so the AttachGuard first of all sets it to the saved + value. In a nutshell, this means that all native threads attached to + the virtual machine use the context class loader of the "initial Java + thread." + */ + VirtualMachine(JavaVM * pVm, jint nVersion, bool bDestroy, + JNIEnv * pMainThreadEnv); + +private: + VirtualMachine(VirtualMachine &); // not implemented + void operator =(VirtualMachine); // not implemented + + virtual ~VirtualMachine(); + + void acquireInitialContextClassLoader(JNIEnv * pEnv); + + void releaseInitialContextClassLoader() const; + + JNIEnv * attachThread(bool * pAttached) const; + + void detachThread() const; + + JavaVM * m_pVm; + jint m_nVersion; + bool m_bDestroy; + jobject m_aInitialContextClassLoader; + + friend class AttachGuard; // to access attachThread, detachThread +}; + +} + +#endif // INCLUDED_JVMACCESS_VIRTUALMACHINE_HXX diff --git a/jvmaccess/prj/build.lst b/jvmaccess/prj/build.lst new file mode 100644 index 000000000..b96befb83 --- /dev/null +++ b/jvmaccess/prj/build.lst @@ -0,0 +1,3 @@ +jvmaccess jvmaccess : sal salhelper NULL +jvmaccess jvmaccess\source nmake - all jvmaccess_source NULL +jvmaccess jvmaccess\util nmake - all jvmaccess_util jvmaccess_source NULL diff --git a/jvmaccess/prj/d.lst b/jvmaccess/prj/d.lst new file mode 100644 index 000000000..05e100209 --- /dev/null +++ b/jvmaccess/prj/d.lst @@ -0,0 +1,6 @@ +mkdir: %_DEST%\inc%_EXT%\jvmaccess +..\inc\jvmaccess\virtualmachine.hxx %_DEST%\inc%_EXT%\jvmaccess\virtualmachine.hxx +..\%__SRC%\bin\jvmaccess*.dll %_DEST%\bin%_EXT%\* +..\%__SRC%\lib\ijvmaccess.lib %_DEST%\lib%_EXT%\ijvmaccess.lib +..\%__SRC%\lib\libjvmaccess*.so.*.*.* %_DEST%\lib%_EXT%\* +linklib: libjvmaccess*.so.*.*.* diff --git a/jvmaccess/source/makefile.mk b/jvmaccess/source/makefile.mk new file mode 100644 index 000000000..f6a34ba39 --- /dev/null +++ b/jvmaccess/source/makefile.mk @@ -0,0 +1,73 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: sb $ $Date: 2002-12-06 11:35:36 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +#************************************************************************* + +PRJ = .. +PRJNAME = jvmaccess +TARGET = $(PRJNAME) + +ENABLE_EXCEPTIONS = TRUE + +.INCLUDE: settings.mk + +SLOFILES = \ + $(SLO)$/virtualmachine.obj + +.INCLUDE: target.mk diff --git a/jvmaccess/source/virtualmachine.cxx b/jvmaccess/source/virtualmachine.cxx new file mode 100644 index 000000000..89efacc5d --- /dev/null +++ b/jvmaccess/source/virtualmachine.cxx @@ -0,0 +1,193 @@ +/************************************************************************* + * + * $RCSfile: virtualmachine.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sb $ $Date: 2002-12-06 11:35:36 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "jvmaccess/virtualmachine.hxx" + +#include "osl/diagnose.h" + +using jvmaccess::VirtualMachine; + +VirtualMachine::AttachGuard::CreationException::CreationException() +{} + +VirtualMachine::AttachGuard::CreationException::CreationException( + CreationException const &) +{} + +VirtualMachine::AttachGuard::CreationException::~CreationException() +{} + +VirtualMachine::AttachGuard::CreationException & +VirtualMachine::AttachGuard::CreationException::operator =( + CreationException const &) +{ + return *this; +} + +VirtualMachine::AttachGuard::AttachGuard( + rtl::Reference< VirtualMachine > const & rMachine): + m_xMachine(rMachine) +{ + OSL_ENSURE(m_xMachine.is(), "bad parameter"); + m_pEnvironment = m_xMachine->attachThread(&m_bDetach); + if (m_pEnvironment == 0) + throw CreationException(); +} + +VirtualMachine::AttachGuard::~AttachGuard() +{ + if (m_bDetach) + m_xMachine->detachThread(); +} + +VirtualMachine::VirtualMachine(JavaVM * pVm, jint nVersion, bool bDestroy, + JNIEnv * pMainThreadEnv): + m_pVm(pVm), m_nVersion(nVersion), m_bDestroy(bDestroy) +{ + OSL_ENSURE(pVm != 0 && nVersion >= JNI_VERSION_1_2 && pMainThreadEnv != 0, + "bad parameter"); + acquireInitialContextClassLoader(pMainThreadEnv); +} + +VirtualMachine::~VirtualMachine() +{ + releaseInitialContextClassLoader(); + if (m_bDestroy) + { + jint n = m_pVm->DestroyJavaVM(); + OSL_ENSURE(n == JNI_OK, "JNI: DestroyJavaVM failed"); + } +} + +void VirtualMachine::acquireInitialContextClassLoader(JNIEnv * pEnv) +{ + jclass aClass = pEnv->FindClass("java/lang/Thread"); + jmethodID aMethod1 = pEnv->GetStaticMethodID(aClass, "currentThread", + "()Ljava/lang/Thread;"); + jobject aThread = pEnv->CallStaticObjectMethod(aClass, aMethod1); + jmethodID aMethod2 = pEnv->GetMethodID(aClass, "getContextClassLoader", + "()Ljava/lang/ClassLoader;"); + jobject aClassLoader = pEnv->CallObjectMethod(aThread, aMethod2); + OSL_ENSURE(!pEnv->ExceptionCheck(), "JNI: exception occured"); + pEnv->ExceptionClear(); + if (aClassLoader == 0) + m_aInitialContextClassLoader = 0; + else + { + m_aInitialContextClassLoader = pEnv->NewGlobalRef(aClassLoader); + OSL_ENSURE(m_aInitialContextClassLoader != 0, + "JNI: NewGlobalRef failed"); + } +} + +void VirtualMachine::releaseInitialContextClassLoader() const +{ + if (m_aInitialContextClassLoader != 0) + { + JNIEnv * pEnv; + jint n = m_pVm->AttachCurrentThread(reinterpret_cast< void ** >(&pEnv), + 0); + OSL_ENSURE(n == JNI_OK, "JNI: AttachCurrentThread failed"); + if (n == JNI_OK) + { + pEnv->DeleteGlobalRef(m_aInitialContextClassLoader); + n = m_pVm->DetachCurrentThread(); + OSL_ENSURE(n == JNI_OK, "JNI: DetachCurrentThread failed"); + } + } +} + +JNIEnv * VirtualMachine::attachThread(bool * pAttached) const +{ + OSL_ENSURE(pAttached != 0, "bad parameter"); + JNIEnv * pEnv; + jint n = m_pVm->GetEnv(reinterpret_cast< void ** >(&pEnv), m_nVersion); + OSL_ENSURE(n == JNI_OK || n == JNI_EDETACHED, "JNI: GetEnv failed"); + if (pEnv == 0) + { + if (m_pVm->AttachCurrentThread(reinterpret_cast< void ** >(&pEnv), 0) + != JNI_OK) + return 0; + if (m_aInitialContextClassLoader != 0) + { + jclass aClass = pEnv->FindClass("java/lang/Thread"); + jmethodID aMethod1 = pEnv->GetStaticMethodID( + aClass, "currentThread", "()Ljava/lang/Thread;"); + jobject aThread = pEnv->CallStaticObjectMethod(aClass, aMethod1); + jmethodID aMethod2 = pEnv->GetMethodID( + aClass, "setContextClassLoader", "(Ljava/lang/ClassLoader;)V"); + pEnv->CallObjectMethod(aThread, aMethod2, + m_aInitialContextClassLoader); + OSL_ENSURE(!pEnv->ExceptionCheck(), "JNI: exception occured"); + pEnv->ExceptionClear(); + } + *pAttached = true; + } + else + *pAttached = false; + return pEnv; +} + +void VirtualMachine::detachThread() const +{ + jint n = m_pVm->DetachCurrentThread(); + OSL_ENSURE(n == JNI_OK, "JNI: DetachCurrentThread failed"); +} diff --git a/jvmaccess/util/cc5_solaris_sparc.map b/jvmaccess/util/cc5_solaris_sparc.map new file mode 100644 index 000000000..e363e0de6 --- /dev/null +++ b/jvmaccess/util/cc5_solaris_sparc.map @@ -0,0 +1,17 @@ +UDK_3.1 { + global: + # jvmaccess/virtualmachine.hxx: + __1cJjvmaccessOVirtualMachineLAttachGuardRCreationException2t6M_v_; # jvmaccess::VirtualMachine::AttachGuard::CreationException::CreationException() + __1cJjvmaccessOVirtualMachineLAttachGuardRCreationException2t6Mrk3_v_; # jvmaccess::VirtualMachine::AttachGuard::CreationException::CreationException(CreationException const &) + __1cJjvmaccessOVirtualMachineLAttachGuardRCreationException2T6M_v_; # jvmaccess::VirtualMachine::AttachGuard::CreationException::~CreationException() + __1cJjvmaccessOVirtualMachineLAttachGuardRCreationException2G6Mrk3_r3_; # jvmaccess::VirtualMachine::AttachGuard::CreationException::operator =(CreationException const &) + __1cJjvmaccesscO__RTTI__1nJjvmaccessOVirtualMachineLAttachGuardRCreationException__; # RTTI for jvmaccess::VirtualMachine::AttachGuard::CreationException + __1cJjvmaccessOVirtualMachineLAttachGuard2t6MrknDrtlJReference4n0B____v_; # jvmaccess::VirtualMachine::AttachGuard::AttachGuard(rtl::Reference< VirtualMachine > const &) + __1cJjvmaccessOVirtualMachineLAttachGuard2t5B6MrknDrtlJReference4n0B____v_; # jvmaccess::VirtualMachine::AttachGuard::AttachGuard #Nvariant 1(rtl::Reference< VirtualMachine > const &) + __1cJjvmaccessOVirtualMachineLAttachGuard2T6M_v_; # jvmaccess::VirtualMachine::AttachGuard::~AttachGuard() + __1cJjvmaccessOVirtualMachineLAttachGuard2T5B6M_v_; # jvmaccess::VirtualMachine::AttachGuard::~AttachGuard #Nvariant 1() + __1cJjvmaccessOVirtualMachine2t6MpnHJavaVM__lbpnHJNIEnv___v_; # jvmaccess::VirtualMachine::VirtualMachine(JavaVM *, jint, bool, JNIEnv *) + + local: + *; +}; diff --git a/jvmaccess/util/makefile.mk b/jvmaccess/util/makefile.mk new file mode 100644 index 000000000..6e454b7be --- /dev/null +++ b/jvmaccess/util/makefile.mk @@ -0,0 +1,94 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: sb $ $Date: 2002-12-06 11:35:37 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +#************************************************************************* + +PRJ = .. +PRJNAME = jvmaccess +TARGET = $(PRJNAME) + +ENABLE_EXCEPTIONS = TRUE + +.IF "$(OS)" != "WNT" +UNIXVERSIONNAMES = UDK +.ENDIF # WNT + +.INCLUDE: settings.mk + +.IF "$(UNIXVERSIONNAMES)" == "" +SHL1TARGET = $(TARGET)$(UDK_MAJOR)$(COMID) +.ELSE # UNIXVERSIONNAMES +SHL1TARGET = $(TARGET)$(COMID) +.ENDIF # UNIXVERSIONNAMES + +SHL1IMPLIB = i$(TARGET) +SHL1LIBS = $(SLB)$/$(TARGET).lib +SHL1STDLIBS = $(SALLIB) $(SALHELPERLIB) + +.IF "$(COMNAME)" == "msci" +SHL1VERSIONMAP = msvc_win32_intel.map +.ELIF "$(COMNAME)" == "sunpro5" +SHL1VERSIONMAP = cc5_solaris_sparc.map +.ELIF "$(OS)$(CPU)$(COMNAME)" == "LINUXIgcc3" +SHL1VERSIONMAP = gcc3_linux_intel.map +.ENDIF + +DEF1NAME = $(SHL1TARGET) + +.INCLUDE: target.mk diff --git a/jvmaccess/util/msvc_win32_intel.map b/jvmaccess/util/msvc_win32_intel.map new file mode 100644 index 000000000..9898e43b5 --- /dev/null +++ b/jvmaccess/util/msvc_win32_intel.map @@ -0,0 +1,14 @@ +UDK_3.1 { + global: + # jvmaccess/virtualmachine.hxx: + ??0CreationException@AttachGuard@VirtualMachine@jvmaccess@@QAE@XZ; # jvmaccess::VirtualMachine::AttachGuard::CreationException::CreationException() + ??0CreationException@AttachGuard@VirtualMachine@jvmaccess@@QAE@ABV0123@@Z; # jvmaccess::VirtualMachine::AttachGuard::CreationException::CreationException(CreationException const &) + ??1CreationException@AttachGuard@VirtualMachine@jvmaccess@@UAE@XZ; # jvmaccess::VirtualMachine::AttachGuard::CreationException::~CreationException() + ??4CreationException@AttachGuard@VirtualMachine@jvmaccess@@QAEAAV0123@ABV0123@@Z; # jvmaccess::VirtualMachine::AttachGuard::CreationException::operator =(CreationException const &) + ??0AttachGuard@VirtualMachine@jvmaccess@@QAE@ABV?$Reference@VVirtualMachine@jvmaccess@@@rtl@@@Z; # jvmaccess::VirtualMachine::AttachGuard::AttachGuard(rtl::Reference< VirtualMachine > const &) + ??1AttachGuard@VirtualMachine@jvmaccess@@QAE@XZ; # jvmaccess::VirtualMachine::AttachGuard::~AttachGuard() + ??0VirtualMachine@jvmaccess@@QAE@PAUJavaVM_@@J_NPAUJNIEnv_@@@Z; # jvmaccess::VirtualMachine::VirtualMachine(JavaVM *, jint, bool, JNIEnv *) + + local: + *; +}; diff --git a/jvmaccess/workbench/exceptiontest1.cxx b/jvmaccess/workbench/exceptiontest1.cxx new file mode 100644 index 000000000..56ee709b4 --- /dev/null +++ b/jvmaccess/workbench/exceptiontest1.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: exceptiontest1.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sb $ $Date: 2002-12-06 11:35:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "jvmaccess/virtualmachine.hxx" + +#include <iostream> + +// Modify source/virtualmachine.cxx before running this test, by letting the +// AttachGuard ctor directly throw a CreationExcepiton (without even setting the +// m_xMachine member). + +int main() +{ + try + { + jvmaccess::VirtualMachine::AttachGuard aGuard(0); + } + catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) + { + std::cout << "Exception caught" << std::endl; + } +} diff --git a/jvmaccess/workbench/exceptiontest2.cxx b/jvmaccess/workbench/exceptiontest2.cxx new file mode 100644 index 000000000..6ba37a1a6 --- /dev/null +++ b/jvmaccess/workbench/exceptiontest2.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: exceptiontest2.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sb $ $Date: 2002-12-06 11:35:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "jvmaccess/virtualmachine.hxx" + +#include <iostream> + +// Modify source/virtualmachine.cxx before running this test, by letting the +// AttachGuard ctor directly throw a CreationExcepiton (without even setting the +// m_xMachine member). + +int main() +{ + try + { + jvmaccess::VirtualMachine::AttachGuard aGuard(0); + } + catch (...) + { + std::cout << "Exception caught" << std::endl; + } +} diff --git a/jvmaccess/workbench/java/TestComponent.java b/jvmaccess/workbench/java/TestComponent.java new file mode 100644 index 000000000..ab9220518 --- /dev/null +++ b/jvmaccess/workbench/java/TestComponent.java @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: TestComponent.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sb $ $Date: 2002-12-06 11:35:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package com.sun.star.comp.jvmaccess.workbench; + +import com.sun.star.comp.loader.FactoryHelper; +import com.sun.star.lang.XMain; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.registry.XRegistryKey; +import com.sun.star.uno.Type; + +/* Deploy this component with pkgchk, and call it with the Basic program + + Sub Main + dim args$() + o = createunoservice("com.sun.star.comp.jvmaccess.workbench.TestComponent") + o.run args$() + End Sub + + The name of the context class loader should appear on the console. + */ + +public final class TestComponent implements XTypeProvider, XServiceInfo, XMain { + public Type[] getTypes() { + return new Type[] { new Type(XTypeProvider.class), + new Type(XServiceInfo.class), + new Type(XMain.class) }; + } + + public byte[] getImplementationId() { + byte[] id = new byte[16]; + int n = hashCode(); + id[0] = (byte) (n & 0xFF); + id[1] = (byte) ((n >> 8) & 0xFF); + id[2] = (byte) ((n >> 16) & 0xFF); + id[3] = (byte) ((n >> 24) & 0xFF); + return id; + } + + public String getImplementationName() { + return getClass().getName(); + } + + public boolean supportsService(String serviceName) { + return serviceName.equals(serviceName); + } + + public String[] getSupportedServiceNames() { + return new String[] { serviceName }; + } + + public int run(String[] arguments) { + System.out.println("context class loader: " + + Thread.currentThread().getContextClassLoader()); + return 0; + } + + public static XSingleServiceFactory __getServiceFactory( + String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey) + { + if (implName.equals(TestComponent.class.getName())) { + return FactoryHelper.getServiceFactory(TestComponent.class, + serviceName, multiFactory, + regKey); + } else { + return null; + } + } + + public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { + return FactoryHelper.writeRegistryServiceInfo( + TestComponent.class.getName(), serviceName, regKey); + } + + private static final String serviceName + = "com.sun.star.comp.jvmaccess.workbench.TestComponent"; +} diff --git a/jvmaccess/workbench/java/makefile.mk b/jvmaccess/workbench/java/makefile.mk new file mode 100644 index 000000000..e25310732 --- /dev/null +++ b/jvmaccess/workbench/java/makefile.mk @@ -0,0 +1,80 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: sb $ $Date: 2002-12-06 11:35:40 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc.. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ = ..$/.. +PRJNAME = jvmaccess +TARGET = workbench_java + +PACKAGE = com$/sun$/star$/comp$/jvmaccess$/workbench + +.INCLUDE: settings.mk + +JARFILES = sandbox.jar ridl.jar jurt.jar juh.jar +JAVACLASSFILES = $(CLASSDIR)$/$(PACKAGE)$/TestComponent.class +JAVAFILES = \ + $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES))) +JARCLASSDIRS = $(PACKAGE) +JARTARGET = jvmaccesstestcomponent.jar +JARCOMPRESS = TRUE +CUSTOMMANIFESTFILE = manifest + +.INCLUDE: target.mk diff --git a/jvmaccess/workbench/java/manifest b/jvmaccess/workbench/java/manifest new file mode 100644 index 000000000..73b21eca3 --- /dev/null +++ b/jvmaccess/workbench/java/manifest @@ -0,0 +1 @@ +RegistrationClassName: com.sun.star.comp.jvmaccess.workbench.TestComponent diff --git a/jvmaccess/workbench/makefile.mk b/jvmaccess/workbench/makefile.mk new file mode 100644 index 000000000..4e96529f8 --- /dev/null +++ b/jvmaccess/workbench/makefile.mk @@ -0,0 +1,85 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: sb $ $Date: 2002-12-06 11:35:39 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +#************************************************************************* + +PRJ = .. +PRJNAME = jvmaccess +TARGET = workbench + +ENABLE_EXCEPTIONS = TRUE + +LIBTARGET = NO +TARGETTYPE = CUI + +.INCLUDE: settings.mk + +APP1TARGET = exceptiontest1 +APP1OBJS = $(OBJ)$/exceptiontest1.obj +APP1STDLIBS = \ + $(JVMACCESSLIB) \ + $(SALLIB) + +APP2TARGET = exceptiontest2 +APP2OBJS = $(OBJ)$/exceptiontest2.obj +APP2STDLIBS = \ + $(JVMACCESSLIB) \ + $(SALLIB) + +.INCLUDE: target.mk |